pinmux: allow exlusive pin allocation among GPIO and peripheral funtions via flag strict in struct pinctrl_desc
Subsystems (3)
PATCH v3 1/1 pinmux: allow exlusive pin allocation among GPIO and peripheral funtions via flag strict in struct pinctrl_desc
From: Sonic Zhang <[email protected]>
The blackfin pinmux and gpio controller doesn't allow user to set up 1 pin for both GPIO and peripheral function. So, add flag strict in struct pinctrl_desc to check both gpio_owner and mux_owner before approving the pin request.
v2-changes:
- if strict flag is set, check gpio_owner and mux_onwer in if and else clause
v3-changes:
- add kerneldoc for this struct
- augment Documentation/pinctrl.txt
--- Documentation/pinctrl.txt | 7 +++++++ drivers/pinctrl/pinctrl-adi2.c | 1 + drivers/pinctrl/pinmux.c | 13 +++++++++++++ include/linux/pinctrl/pinctrl.h | 3 +++ 4 files changed, 24 insertions(+)
Documentation/pinctrl.txt +7 -0
@@ -850,6 +850,13 @@ possible that the GPIO, pin config and pin multiplex registers are placed into the same memory range and the same section of the data sheet, although that need not be the case. +(B.1) +In some processors, although the physical pins are designed in the same way +as (B), the GPIO function still can't be enabled at the same time as the +peripheral functions. So, a flag strict in struct pinctrl_desc is defined +to check both gpio_owner and mux_owner before approving the pin request. +Pinctrl driver should set this flag according to its hardware capability. + From a kernel point of view, however, these are different aspects of the hardware and shall be put into different subsystems:
drivers/pinctrl/pinctrl-adi2.c +1 -0
@@ -710,6 +710,7 @@ static struct pinctrl_desc adi_pinmux_desc = { .name = DRIVER_NAME, .pctlops = &adi_pctrl_ops, .pmxops = &adi_pinmux_ops, + .strict = true, .owner = THIS_MODULE, };
drivers/pinctrl/pinmux.c +13 -0
@@ -107,6 +107,13 @@ static int pin_request(struct pinctrl_dev *pctldev, desc->name, desc->gpio_owner, owner); goto out; } +if (pctldev->desc->strict && desc->mux_usecount && +strcmp (desc->mux_owner, owner)) { +dev_err (pctldev->dev, +"pin %s already requested by %s; cannot claim for %s\n" , + desc->name, desc->mux_owner, owner); + goto out; + } desc->gpio_owner = owner; }else {
@@ -116,6 +123,12 @@ static int pin_request(struct pinctrl_dev *pctldev, desc->name, desc->mux_owner, owner); goto out; } +if (pctldev->desc->strict && desc->gpio_owner) { +dev_err (pctldev->dev, +"pin %s already requested by %s; cannot claim for %s\n" , + desc->name, desc->gpio_owner, owner); + goto out; + } desc->mux_usecount++;if (desc->mux_usecount >1 )
include/linux/pinctrl/pinctrl.h +3 -0
@@ -114,6 +114,8 @@ struct pinctrl_ops {* of the pins field above * @pctlops: pin control operation vtable, to support global concepts like * grouping of pins, this is optional. +* @strict: check both gpio_owner and mux_owner strictly before approving +the pin request * @pmxops: pinmux operations vtable, if you support pinmuxing in your driver * @confops: pin config operations vtable, if you support pin configuration in * your driver
@@ -132,6 +134,7 @@ struct pinctrl_desc {const struct pinctrl_ops *pctlops;const struct pinmux_ops *pmxops;const struct pinconf_ops *confops; +bool strict;struct module *owner;#ifdef CONFIG_GENERIC_PINCONF unsigned int num_custom_params;
Signature · 1 line
1.7.9.5
PING
Quoted 111 lines · Sonic Zhang
From: Sonic Zhang <[email protected]>
The blackfin pinmux and gpio controller doesn't allow user to set up 1 pin for both GPIO and peripheral function. So, add flag strict in struct
pinctrl_descto check bothgpio_ownerandmux_ownerbefore approving the pin request.v2-changes:
- if strict flag is set, checkgpio_ownerandmux_onwerin if and else clausev3-changes:
- add kerneldoc for this struct
- augmentDocumentation/pinctrl.txtSigned-off-by Sonic Zhang <[email protected]>--- Documentation/pinctrl.txt | 7 +++++++ drivers/pinctrl/pinctrl-adi2.c | 1 + drivers/pinctrl/pinmux.c | 13 +++++++++++++ include/linux/pinctrl/pinctrl.h | 3 +++ 4 files changed, 24 insertions(+)Documentation/pinctrl.txt +7
-0@@ -850,6 +850,13 @@ possible that the GPIO, pin config and pin multiplex registers are placed into the same memory range and the same section of the data sheet, although that need not be the case. +(B.1) +In some processors, although the physical pins are designed in the same way +as (B), the GPIO function still can't be enabled at the same time as the +peripheral functions. So, a flag strict in struct pinctrl_desc is defined +to check both gpio_owner and mux_owner before approving the pin request. +Pinctrl driver should set this flag according to its hardware capability. + From a kernel point of view, however, these are different aspects of the hardware and shall be put into different subsystems:drivers/pinctrl/pinctrl-adi2.c +1
-0@@ -710,6 +710,7 @@ static struct pinctrl_desc adi_pinmux_desc = { .name = DRIVER_NAME, .pctlops = &adi_pctrl_ops, .pmxops = &adi_pinmux_ops, + .strict = true, .owner = THIS_MODULE, };drivers/pinctrl/pinmux.c +13
-0@@ -107,6 +107,13 @@ static int pin_request(struct pinctrl_dev *pctldev, desc->name, desc->gpio_owner, owner); goto out; } +if (pctldev->desc->strict && desc->mux_usecount && +strcmp (desc->mux_owner, owner)) { +dev_err (pctldev->dev, +"pin %s already requested by %s; cannot claim for %s\n" , + desc->name, desc->mux_owner, owner); + goto out; + } desc->gpio_owner = owner; }else {@@ -116,6 +123,12 @@ static int pin_request(struct pinctrl_dev *pctldev, desc->name, desc->mux_owner, owner); goto out; } +if (pctldev->desc->strict && desc->gpio_owner) { +dev_err (pctldev->dev, +"pin %s already requested by %s; cannot claim for %s\n" , + desc->name, desc->gpio_owner, owner); + goto out; + } desc->mux_usecount++;if (desc->mux_usecount >1 )include/linux/pinctrl/pinctrl.h +3
-1@@ -114,6 +114,8 @@ struct pinctrl_ops {* of the pins field above * @pctlops: pin control operation vtable, to support global concepts like * grouping of pins, this is optional. +* @strict: check both gpio_owner and mux_owner strictly before approving +the pin request * @pmxops: pinmux operations vtable, if you support pinmuxing in your driver * @confops: pin config operations vtable, if you support pin configuration in * your driver @@ -132,6 +134,7 @@ struct pinctrl_desc {const struct pinctrl_ops *pctlops;const struct pinmux_ops *pmxops;const struct pinconf_ops *confops; +bool strict;struct module *owner;#ifdef CONFIG_GENERIC_PINCONF unsigned int num_custom_params; --1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Sonic Zhang
From: Sonic Zhang <[email protected]>
The blackfin pinmux and gpio controller doesn't allow user to set up 1 pin for both GPIO and peripheral function. So, add flag strict in struct
pinctrl_descto check bothgpio_ownerandmux_ownerbefore approving the pin request.
Quoted 8 lines
v2-changes:
- if strict flag is set, checkgpio_ownerandmux_onwerin if and else clausev3-changes:
- add kerneldoc for this struct
- augmentDocumentation/pinctrl.txtSigned-off-by Sonic Zhang <[email protected]>
Patch applied and then I made some more patches on top to move around and test it out, sorry for taking so long. (Merge window chaos.)
Sending my additional patches soon!
Yours,
Linus Walleij