diff mbox series

[1/2] watchdog: simatic-ipc-wdt: make IO region access of one model muxed

Message ID 20230706154831.19100-2-henning.schild@siemens.com (mailing list archive)
State Handled Elsewhere
Headers show
Series platform/x86: add CMOS battery monitoring for simatic IPCs | expand

Commit Message

Henning Schild July 6, 2023, 3:48 p.m. UTC
The IO region used for the watchdog also hold CMOS battery monitoring
information. Make the access muxed so that a hwmon driver can use the
region as well.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 drivers/watchdog/simatic-ipc-wdt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Guenter Roeck July 6, 2023, 4:03 p.m. UTC | #1
On 7/6/23 08:48, Henning Schild wrote:
> The IO region used for the watchdog also hold CMOS battery monitoring
> information. Make the access muxed so that a hwmon driver can use the
> region as well.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/watchdog/simatic-ipc-wdt.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/watchdog/simatic-ipc-wdt.c b/drivers/watchdog/simatic-ipc-wdt.c
> index 6599695dc672..cdc1a2e15180 100644
> --- a/drivers/watchdog/simatic-ipc-wdt.c
> +++ b/drivers/watchdog/simatic-ipc-wdt.c
> @@ -155,9 +155,8 @@ static int simatic_ipc_wdt_probe(struct platform_device *pdev)
>   
>   	switch (plat->devmode) {
>   	case SIMATIC_IPC_DEVICE_227E:
> -		if (!devm_request_region(dev, gp_status_reg_227e_res.start,
> -					 resource_size(&gp_status_reg_227e_res),
> -					 KBUILD_MODNAME)) {
> +		res = &gp_status_reg_227e_res;
> +		if (!request_muxed_region(res->start, resource_size(res), res->name)) {
>   			dev_err(dev,
>   				"Unable to register IO resource at %pR\n",
>   				&gp_status_reg_227e_res);
> @@ -210,6 +209,10 @@ static int simatic_ipc_wdt_probe(struct platform_device *pdev)
>   	if (wdd_data.bootstatus)
>   		dev_warn(dev, "last reboot caused by watchdog reset\n");
>   
> +	if (plat->devmode == SIMATIC_IPC_DEVICE_227E)
> +		release_region(gp_status_reg_227e_res.start,
> +			       resource_size(&gp_status_reg_227e_res));
> +
>   	watchdog_set_nowayout(&wdd_data, nowayout);
>   	watchdog_stop_on_reboot(&wdd_data);
>   	return devm_watchdog_register_device(dev, &wdd_data);
Hans de Goede July 10, 2023, 1:33 p.m. UTC | #2
Hi Guenter,

On 7/6/23 18:03, Guenter Roeck wrote:
> On 7/6/23 08:48, Henning Schild wrote:
>> The IO region used for the watchdog also hold CMOS battery monitoring
>> information. Make the access muxed so that a hwmon driver can use the
>> region as well.
>>
>> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> 
> Acked-by: Guenter Roeck <linux@roeck-us.net>

Thank you. Is it ok if I pick up his patch and merge it together with 2/2
through the pdx86 tree ?

Regards,

Hans


> 
>> ---
>>   drivers/watchdog/simatic-ipc-wdt.c | 9 ++++++---
>>   1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/watchdog/simatic-ipc-wdt.c b/drivers/watchdog/simatic-ipc-wdt.c
>> index 6599695dc672..cdc1a2e15180 100644
>> --- a/drivers/watchdog/simatic-ipc-wdt.c
>> +++ b/drivers/watchdog/simatic-ipc-wdt.c
>> @@ -155,9 +155,8 @@ static int simatic_ipc_wdt_probe(struct platform_device *pdev)
>>         switch (plat->devmode) {
>>       case SIMATIC_IPC_DEVICE_227E:
>> -        if (!devm_request_region(dev, gp_status_reg_227e_res.start,
>> -                     resource_size(&gp_status_reg_227e_res),
>> -                     KBUILD_MODNAME)) {
>> +        res = &gp_status_reg_227e_res;
>> +        if (!request_muxed_region(res->start, resource_size(res), res->name)) {
>>               dev_err(dev,
>>                   "Unable to register IO resource at %pR\n",
>>                   &gp_status_reg_227e_res);
>> @@ -210,6 +209,10 @@ static int simatic_ipc_wdt_probe(struct platform_device *pdev)
>>       if (wdd_data.bootstatus)
>>           dev_warn(dev, "last reboot caused by watchdog reset\n");
>>   +    if (plat->devmode == SIMATIC_IPC_DEVICE_227E)
>> +        release_region(gp_status_reg_227e_res.start,
>> +                   resource_size(&gp_status_reg_227e_res));
>> +
>>       watchdog_set_nowayout(&wdd_data, nowayout);
>>       watchdog_stop_on_reboot(&wdd_data);
>>       return devm_watchdog_register_device(dev, &wdd_data);
>
Guenter Roeck July 10, 2023, 1:45 p.m. UTC | #3
On Mon, Jul 10, 2023 at 03:33:45PM +0200, Hans de Goede wrote:
> Hi Guenter,
> 
> On 7/6/23 18:03, Guenter Roeck wrote:
> > On 7/6/23 08:48, Henning Schild wrote:
> >> The IO region used for the watchdog also hold CMOS battery monitoring
> >> information. Make the access muxed so that a hwmon driver can use the
> >> region as well.
> >>
> >> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> > 
> > Acked-by: Guenter Roeck <linux@roeck-us.net>
> 
> Thank you. Is it ok if I pick up his patch and merge it together with 2/2
> through the pdx86 tree ?
> 

Yes. That was my assumption.

Guenter

> Regards,
> 
> Hans
> 
> 
> > 
> >> ---
> >>   drivers/watchdog/simatic-ipc-wdt.c | 9 ++++++---
> >>   1 file changed, 6 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/watchdog/simatic-ipc-wdt.c b/drivers/watchdog/simatic-ipc-wdt.c
> >> index 6599695dc672..cdc1a2e15180 100644
> >> --- a/drivers/watchdog/simatic-ipc-wdt.c
> >> +++ b/drivers/watchdog/simatic-ipc-wdt.c
> >> @@ -155,9 +155,8 @@ static int simatic_ipc_wdt_probe(struct platform_device *pdev)
> >>         switch (plat->devmode) {
> >>       case SIMATIC_IPC_DEVICE_227E:
> >> -        if (!devm_request_region(dev, gp_status_reg_227e_res.start,
> >> -                     resource_size(&gp_status_reg_227e_res),
> >> -                     KBUILD_MODNAME)) {
> >> +        res = &gp_status_reg_227e_res;
> >> +        if (!request_muxed_region(res->start, resource_size(res), res->name)) {
> >>               dev_err(dev,
> >>                   "Unable to register IO resource at %pR\n",
> >>                   &gp_status_reg_227e_res);
> >> @@ -210,6 +209,10 @@ static int simatic_ipc_wdt_probe(struct platform_device *pdev)
> >>       if (wdd_data.bootstatus)
> >>           dev_warn(dev, "last reboot caused by watchdog reset\n");
> >>   +    if (plat->devmode == SIMATIC_IPC_DEVICE_227E)
> >> +        release_region(gp_status_reg_227e_res.start,
> >> +                   resource_size(&gp_status_reg_227e_res));
> >> +
> >>       watchdog_set_nowayout(&wdd_data, nowayout);
> >>       watchdog_stop_on_reboot(&wdd_data);
> >>       return devm_watchdog_register_device(dev, &wdd_data);
> > 
>
Henning Schild July 10, 2023, 6:54 p.m. UTC | #4
Am Mon, 10 Jul 2023 06:45:14 -0700
schrieb Guenter Roeck <linux@roeck-us.net>:

> On Mon, Jul 10, 2023 at 03:33:45PM +0200, Hans de Goede wrote:
> > Hi Guenter,
> > 
> > On 7/6/23 18:03, Guenter Roeck wrote:  
> > > On 7/6/23 08:48, Henning Schild wrote:  
> > >> The IO region used for the watchdog also hold CMOS battery
> > >> monitoring information. Make the access muxed so that a hwmon
> > >> driver can use the region as well.
> > >>
> > >> Signed-off-by: Henning Schild <henning.schild@siemens.com>  
> > > 
> > > Acked-by: Guenter Roeck <linux@roeck-us.net>  
> > 
> > Thank you. Is it ok if I pick up his patch and merge it together
> > with 2/2 through the pdx86 tree ?
> >   
> 
> Yes. That was my assumption.

Thanks guys. Cant believe i made it with v1. Getting better at this ;)

Henning

> Guenter
> 
> > Regards,
> > 
> > Hans
> > 
> >   
> > >   
> > >> ---
> > >>   drivers/watchdog/simatic-ipc-wdt.c | 9 ++++++---
> > >>   1 file changed, 6 insertions(+), 3 deletions(-)
> > >>
> > >> diff --git a/drivers/watchdog/simatic-ipc-wdt.c
> > >> b/drivers/watchdog/simatic-ipc-wdt.c index
> > >> 6599695dc672..cdc1a2e15180 100644 ---
> > >> a/drivers/watchdog/simatic-ipc-wdt.c +++
> > >> b/drivers/watchdog/simatic-ipc-wdt.c @@ -155,9 +155,8 @@ static
> > >> int simatic_ipc_wdt_probe(struct platform_device *pdev) switch
> > >> (plat->devmode) { case SIMATIC_IPC_DEVICE_227E:
> > >> -        if (!devm_request_region(dev,
> > >> gp_status_reg_227e_res.start,
> > >> -                     resource_size(&gp_status_reg_227e_res),
> > >> -                     KBUILD_MODNAME)) {
> > >> +        res = &gp_status_reg_227e_res;
> > >> +        if (!request_muxed_region(res->start,
> > >> resource_size(res), res->name)) { dev_err(dev,
> > >>                   "Unable to register IO resource at %pR\n",
> > >>                   &gp_status_reg_227e_res);
> > >> @@ -210,6 +209,10 @@ static int simatic_ipc_wdt_probe(struct
> > >> platform_device *pdev) if (wdd_data.bootstatus)
> > >>           dev_warn(dev, "last reboot caused by watchdog
> > >> reset\n");
> > >>   +    if (plat->devmode == SIMATIC_IPC_DEVICE_227E)
> > >> +        release_region(gp_status_reg_227e_res.start,
> > >> +                   resource_size(&gp_status_reg_227e_res));
> > >> +
> > >>       watchdog_set_nowayout(&wdd_data, nowayout);
> > >>       watchdog_stop_on_reboot(&wdd_data);
> > >>       return devm_watchdog_register_device(dev, &wdd_data);  
> > >   
> >
diff mbox series

Patch

diff --git a/drivers/watchdog/simatic-ipc-wdt.c b/drivers/watchdog/simatic-ipc-wdt.c
index 6599695dc672..cdc1a2e15180 100644
--- a/drivers/watchdog/simatic-ipc-wdt.c
+++ b/drivers/watchdog/simatic-ipc-wdt.c
@@ -155,9 +155,8 @@  static int simatic_ipc_wdt_probe(struct platform_device *pdev)
 
 	switch (plat->devmode) {
 	case SIMATIC_IPC_DEVICE_227E:
-		if (!devm_request_region(dev, gp_status_reg_227e_res.start,
-					 resource_size(&gp_status_reg_227e_res),
-					 KBUILD_MODNAME)) {
+		res = &gp_status_reg_227e_res;
+		if (!request_muxed_region(res->start, resource_size(res), res->name)) {
 			dev_err(dev,
 				"Unable to register IO resource at %pR\n",
 				&gp_status_reg_227e_res);
@@ -210,6 +209,10 @@  static int simatic_ipc_wdt_probe(struct platform_device *pdev)
 	if (wdd_data.bootstatus)
 		dev_warn(dev, "last reboot caused by watchdog reset\n");
 
+	if (plat->devmode == SIMATIC_IPC_DEVICE_227E)
+		release_region(gp_status_reg_227e_res.start,
+			       resource_size(&gp_status_reg_227e_res));
+
 	watchdog_set_nowayout(&wdd_data, nowayout);
 	watchdog_stop_on_reboot(&wdd_data);
 	return devm_watchdog_register_device(dev, &wdd_data);