pinctrl-bcm2835 gpio-ranges bugfix
Subsystems (6)
cover pinctrl-bcm2835 gpio-ranges bugfix
Hi all,
This patch series is intended to backport the fix from Phil "pinctrl:
bcm2835: Change init order for gpio hogs" into the 5.4 tree since the blamed commit:
73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")
is in 5.4. To get there, I did backport a number of changes in order for the commit "pinctrl: bcm2835: Change init order for gpio hogs" to apply cleanly with no hunks.
Those should have no functional impact since we do not have support for 7211 or 2711 in the upstream stable 5.4.
Both the pinctrl *and* the DTS changes must be taken in lockstep otherwise the GPIO pins are simply not usable unfortunately.
Thanks!
Florian Fainelli (2):
pinctrl: bcm2835: Match BCM7211 compatible string
pinctrl: bcm2835: Add support for wake-up interrupts
Phil Elwell (2):
pinctrl: bcm2835: Change init order for gpio hogs
ARM: dts: gpio-ranges property is now required
Stefan Wahren (3):
pinctrl: bcm2835: Drop unused define
pinctrl: bcm2835: Refactor platform data
pinctrl: bcm2835: Add support for all GPIOs on BCM2711
arch/arm/boot/dts/bcm283x.dtsi | 1 + drivers/pinctrl/bcm/pinctrl-bcm2835.c | 209 +++++++++++++++++++++----- 2 files changed, 175 insertions(+), 35 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/7 pinctrl: bcm2835: Drop unused define
From: Stefan Wahren <[email protected]>
commit be30d5de0a5a52c6ee2cc453a51301037ab94aa upstream
There is no usage for this define, so drop it.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 3 --- 1 file changed, 3 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +0 -3
@@ -40,9 +40,6 @@#define BCM2835_NUM_BANKS 2#define BCM2835_NUM_IRQS 3 -#define BCM2835_PIN_BITMAP_SZ \ - DIV_ROUND_UP(BCM2835_NUM_GPIOS, sizeof(unsigned long) * 8) -/* GPIO register offsets */ #define GPFSEL0 0x0/* Function Select */ #define GPSET0 0x1c/* Pin Output Set */
Signature · 1 line
2.25.1
Patch "pinctrl: bcm2835: Drop unused define" has been added to the 5.4-stable tree
This is a note to let you know that I've just added the patch titled
pinctrl: bcm2835: Drop unused define
to the 5.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
pinctrl-bcm2835-drop-unused-define.patch
and it can be found in the queue-5.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From foo@baz Thu Jan 27 04:40:37 PM CET 2022
From: Florian Fainelli <[email protected]>
Date: Tue, 25 Jan 2022 11:42:16 -0800
Subject: pinctrl: bcm2835: Drop unused define
To: [email protected]
Cc: Stefan Wahren <[email protected]>, Nicolas Saenz Julienne <[email protected]>, Linus Walleij <[email protected]>, Florian Fainelli <[email protected]>, Rob Herring <[email protected]>, Mark Rutland <[email protected]>, Ray Jui <[email protected]>, Scott Branden <[email protected]>, [email protected] (maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...), Eric Anholt <[email protected]>, Stefan Wahren <[email protected]>, Nicolas Saenz Julienne <[email protected]>, Phil Elwell <[email protected]>, [email protected] (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), [email protected] (open list), [email protected] (open list:PIN CONTROL SUBSYSTEM), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE)
Message-ID: <[email protected]>
From: Stefan Wahren <[email protected]>
commit be30d5de0a5a52c6ee2cc453a51301037ab94aa upstream
There is no usage for this define, so drop it.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 3 --- 1 file changed, 3 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +0 -3
@@ -40,9 +40,6 @@#define BCM2835_NUM_BANKS 2#define BCM2835_NUM_IRQS 3 -#define BCM2835_PIN_BITMAP_SZ \ - DIV_ROUND_UP(BCM2835_NUM_GPIOS, sizeof(unsigned long) * 8) -/* GPIO register offsets */ #define GPFSEL0 0x0/* Function Select */ #define GPSET0 0x1c/* Pin Output Set */
Patches currently in stable-queue which might be from [email protected] are
queue-5.4/pinctrl-bcm2835-drop-unused-define.patch queue-5.4/arm-dts-gpio-ranges-property-is-now-required.patch queue-5.4/pinctrl-bcm2835-add-support-for-wake-up-interrupts.patch queue-5.4/pinctrl-bcm2835-change-init-order-for-gpio-hogs.patch queue-5.4/pinctrl-bcm2835-refactor-platform-data.patch queue-5.4/pinctrl-bcm2835-match-bcm7211-compatible-string.patch queue-5.4/pinctrl-bcm2835-add-support-for-all-gpios-on-bcm2711.patch
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/7 pinctrl: bcm2835: Refactor platform data
In reply to Florian FainelliFrom: Stefan Wahren <[email protected]>
commit 90bfaf028d61a6d523c685b63c2bcc94eebb8057 upstream
This prepares the platform data to be easier to extend for more GPIOs. Except of this there is no functional change.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 57 +++++++++++++++++++++------ 1 file changed, 44 insertions(+), 13 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +44 -13
@@ -82,6 +82,7 @@ struct bcm2835_pinctrl {struct pinctrl_dev *pctl_dev;struct gpio_chip gpio_chip; +struct pinctrl_desc pctl_desc;struct pinctrl_gpio_range gpio_range;raw_spinlock_t irq_lock[BCM2835_NUM_BANKS ];
@@ -1051,7 +1052,7 @@ static const struct pinconf_ops bcm2711_pinconf_ops = { .pin_config_set = bcm2711_pinconf_set, }; -static struct pinctrl_desc bcm2835_pinctrl_desc = { +static const struct pinctrl_desc bcm2835_pinctrl_desc = { .name =MODULE_NAME , .pins = bcm2835_gpio_pins, .npins =ARRAY_SIZE (bcm2835_gpio_pins),
@@ -1061,19 +1062,47 @@ static struct pinctrl_desc bcm2835_pinctrl_desc = { .owner = THIS_MODULE, }; -static struct pinctrl_gpio_range bcm2835_pinctrl_gpio_range = { +static const struct pinctrl_desc bcm2711_pinctrl_desc = { + .name =MODULE_NAME , + .pins = bcm2835_gpio_pins, + .npins =ARRAY_SIZE (bcm2835_gpio_pins), + .pctlops = &bcm2835_pctl_ops, + .pmxops = &bcm2835_pmx_ops, + .confops = &bcm2711_pinconf_ops, + .owner =THIS_MODULE , +}; + +static const struct pinctrl_gpio_range bcm2835_pinctrl_gpio_range = { .name =MODULE_NAME , .npins =BCM2835_NUM_GPIOS , }; +struct bcm_plat_data { +const struct gpio_chip *gpio_chip; +const struct pinctrl_desc *pctl_desc; +const struct pinctrl_gpio_range *gpio_range; +}; + +static const struct bcm_plat_data bcm2835_plat_data = { + .gpio_chip = &bcm2835_gpio_chip, + .pctl_desc = &bcm2835_pinctrl_desc, + .gpio_range = &bcm2835_pinctrl_gpio_range, +}; + +static const struct bcm_plat_data bcm2711_plat_data = { + .gpio_chip = &bcm2835_gpio_chip, + .pctl_desc = &bcm2711_pinctrl_desc, + .gpio_range = &bcm2835_pinctrl_gpio_range, +}; +static const struct of_device_id bcm2835_pinctrl_match[] = { { .compatible ="brcm,bcm2835-gpio" , - .data = &bcm2835_pinconf_ops, + .data = &bcm2835_plat_data, }, { .compatible ="brcm,bcm2711-gpio" , - .data = &bcm2711_pinconf_ops, + .data = &bcm2711_plat_data, }, {} };
@@ -1082,6 +1111,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct device_node *np = dev->of_node; +const struct bcm_plat_data *pdata;struct bcm2835_pinctrl *pc;struct gpio_irq_chip *girq;struct resource iomem;
@@ -1108,7 +1138,13 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)if (IS_ERR (pc->base))return PTR_ERR (pc->base); - pc->gpio_chip = bcm2835_gpio_chip; + match =of_match_node (bcm2835_pinctrl_match, pdev->dev.of_node); +if (!match) +return -EINVAL ; + + pdata = match->data; + + pc->gpio_chip = *pdata->gpio_chip; pc->gpio_chip.parent = dev; pc->gpio_chip.of_node = np;
@@ -1159,19 +1195,14 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)return err; } - match =of_match_node (bcm2835_pinctrl_match, pdev->dev.of_node); -if (match) { - bcm2835_pinctrl_desc.confops = - (const struct pinconf_ops *)match->data; - } - - pc->pctl_dev =devm_pinctrl_register (dev, &bcm2835_pinctrl_desc, pc); + pc->pctl_desc = *pdata->pctl_desc; + pc->pctl_dev =devm_pinctrl_register (dev, &pc->pctl_desc, pc);if (IS_ERR (pc->pctl_dev)) {gpiochip_remove (&pc->gpio_chip);return PTR_ERR (pc->pctl_dev); } - pc->gpio_range = bcm2835_pinctrl_gpio_range; + pc->gpio_range = *pdata->gpio_range; pc->gpio_range.base = pc->gpio_chip.base; pc->gpio_range.gc = &pc->gpio_chip;pinctrl_add_gpio_range (pc->pctl_dev, &pc->gpio_range);
Signature · 1 line
2.25.1
Patch "pinctrl: bcm2835: Refactor platform data" has been added to the 5.4-stable tree
This is a note to let you know that I've just added the patch titled
pinctrl: bcm2835: Refactor platform data
to the 5.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
pinctrl-bcm2835-refactor-platform-data.patch
and it can be found in the queue-5.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From foo@baz Thu Jan 27 04:40:37 PM CET 2022
From: Florian Fainelli <[email protected]>
Date: Tue, 25 Jan 2022 11:42:17 -0800
Subject: pinctrl: bcm2835: Refactor platform data
To: [email protected]
Cc: Stefan Wahren <[email protected]>, Nicolas Saenz Julienne <[email protected]>, Linus Walleij <[email protected]>, Florian Fainelli <[email protected]>, Rob Herring <[email protected]>, Mark Rutland <[email protected]>, Ray Jui <[email protected]>, Scott Branden <[email protected]>, [email protected] (maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...), Eric Anholt <[email protected]>, Stefan Wahren <[email protected]>, Nicolas Saenz Julienne <[email protected]>, Phil Elwell <[email protected]>, [email protected] (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), [email protected] (open list), [email protected] (open list:PIN CONTROL SUBSYSTEM), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE)
Message-ID: <[email protected]>
From: Stefan Wahren <[email protected]>
commit 90bfaf028d61a6d523c685b63c2bcc94eebb8057 upstream
This prepares the platform data to be easier to extend for more GPIOs. Except of this there is no functional change.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 57 ++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 13 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +44 -13
@@ -82,6 +82,7 @@ struct bcm2835_pinctrl {struct pinctrl_dev *pctl_dev;struct gpio_chip gpio_chip; +struct pinctrl_desc pctl_desc;struct pinctrl_gpio_range gpio_range;raw_spinlock_t irq_lock[BCM2835_NUM_BANKS ];
@@ -1051,7 +1052,7 @@ static const struct pinconf_ops bcm2711_ .pin_config_set = bcm2711_pinconf_set, }; -static struct pinctrl_desc bcm2835_pinctrl_desc = { +static const struct pinctrl_desc bcm2835_pinctrl_desc = { .name =MODULE_NAME , .pins = bcm2835_gpio_pins, .npins =ARRAY_SIZE (bcm2835_gpio_pins),
@@ -1061,19 +1062,47 @@ static struct pinctrl_desc bcm2835_pinct .owner = THIS_MODULE, }; -static struct pinctrl_gpio_range bcm2835_pinctrl_gpio_range = { +static const struct pinctrl_desc bcm2711_pinctrl_desc = { + .name =MODULE_NAME , + .pins = bcm2835_gpio_pins, + .npins =ARRAY_SIZE (bcm2835_gpio_pins), + .pctlops = &bcm2835_pctl_ops, + .pmxops = &bcm2835_pmx_ops, + .confops = &bcm2711_pinconf_ops, + .owner =THIS_MODULE , +}; + +static const struct pinctrl_gpio_range bcm2835_pinctrl_gpio_range = { .name =MODULE_NAME , .npins =BCM2835_NUM_GPIOS , }; +struct bcm_plat_data { +const struct gpio_chip *gpio_chip; +const struct pinctrl_desc *pctl_desc; +const struct pinctrl_gpio_range *gpio_range; +}; + +static const struct bcm_plat_data bcm2835_plat_data = { + .gpio_chip = &bcm2835_gpio_chip, + .pctl_desc = &bcm2835_pinctrl_desc, + .gpio_range = &bcm2835_pinctrl_gpio_range, +}; + +static const struct bcm_plat_data bcm2711_plat_data = { + .gpio_chip = &bcm2835_gpio_chip, + .pctl_desc = &bcm2711_pinctrl_desc, + .gpio_range = &bcm2835_pinctrl_gpio_range, +}; +static const struct of_device_id bcm2835_pinctrl_match[] = { { .compatible ="brcm,bcm2835-gpio" , - .data = &bcm2835_pinconf_ops, + .data = &bcm2835_plat_data, }, { .compatible ="brcm,bcm2711-gpio" , - .data = &bcm2711_pinconf_ops, + .data = &bcm2711_plat_data, }, {} };
@@ -1082,6 +1111,7 @@ static int bcm2835_pinctrl_probe(struct {struct device *dev = &pdev->dev;struct device_node *np = dev->of_node; +const struct bcm_plat_data *pdata;struct bcm2835_pinctrl *pc;struct gpio_irq_chip *girq;struct resource iomem;
@@ -1108,7 +1138,13 @@ static int bcm2835_pinctrl_probe(structif (IS_ERR (pc->base))return PTR_ERR (pc->base); - pc->gpio_chip = bcm2835_gpio_chip; + match =of_match_node (bcm2835_pinctrl_match, pdev->dev.of_node); +if (!match) +return -EINVAL ; + + pdata = match->data; + + pc->gpio_chip = *pdata->gpio_chip; pc->gpio_chip.parent = dev; pc->gpio_chip.of_node = np;
@@ -1159,19 +1195,14 @@ static int bcm2835_pinctrl_probe(structreturn err; } - match =of_match_node (bcm2835_pinctrl_match, pdev->dev.of_node); -if (match) { - bcm2835_pinctrl_desc.confops = - (const struct pinconf_ops *)match->data; - } - - pc->pctl_dev =devm_pinctrl_register (dev, &bcm2835_pinctrl_desc, pc); + pc->pctl_desc = *pdata->pctl_desc; + pc->pctl_dev =devm_pinctrl_register (dev, &pc->pctl_desc, pc);if (IS_ERR (pc->pctl_dev)) {gpiochip_remove (&pc->gpio_chip);return PTR_ERR (pc->pctl_dev); } - pc->gpio_range = bcm2835_pinctrl_gpio_range; + pc->gpio_range = *pdata->gpio_range; pc->gpio_range.base = pc->gpio_chip.base; pc->gpio_range.gc = &pc->gpio_chip;pinctrl_add_gpio_range (pc->pctl_dev, &pc->gpio_range);
Patches currently in stable-queue which might be from [email protected] are
queue-5.4/pinctrl-bcm2835-drop-unused-define.patch queue-5.4/arm-dts-gpio-ranges-property-is-now-required.patch queue-5.4/pinctrl-bcm2835-add-support-for-wake-up-interrupts.patch queue-5.4/pinctrl-bcm2835-change-init-order-for-gpio-hogs.patch queue-5.4/pinctrl-bcm2835-refactor-platform-data.patch queue-5.4/pinctrl-bcm2835-match-bcm7211-compatible-string.patch queue-5.4/pinctrl-bcm2835-add-support-for-all-gpios-on-bcm2711.patch
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/7 pinctrl: bcm2835: Add support for all GPIOs on BCM2711
In reply to Florian FainelliFrom: Stefan Wahren <[email protected]>
commit b1d84a3d0a26c5844a22bc09a42704b9371208bb upstream
The BCM2711 supports 58 GPIOs. So extend pinctrl and GPIOs accordingly.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 54 +++++++++++++++++++++------ 1 file changed, 42 insertions(+), 12 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +42 -12
@@ -37,6 +37,7 @@#define MODULE_NAME "pinctrl-bcm2835"#define BCM2835_NUM_GPIOS 54 +#define BCM2711_NUM_GPIOS 58#define BCM2835_NUM_BANKS 2#define BCM2835_NUM_IRQS 3
@@ -78,7 +79,7 @@ struct bcm2835_pinctrl {/* note: locking assumes each bank will have its own unsigned long */ unsigned long enabled_irq_map[BCM2835_NUM_BANKS ]; -unsigned int irq_type[BCM2835_NUM_GPIOS ]; +unsigned int irq_type[BCM2711_NUM_GPIOS ];struct pinctrl_dev *pctl_dev;struct gpio_chip gpio_chip;
@@ -145,6 +146,10 @@ static struct pinctrl_pin_desc bcm2835_gpio_pins[] = {BCM2835_GPIO_PIN (51 ),BCM2835_GPIO_PIN (52 ),BCM2835_GPIO_PIN (53 ), +BCM2835_GPIO_PIN (54 ), +BCM2835_GPIO_PIN (55 ), +BCM2835_GPIO_PIN (56 ), + BCM2835_GPIO_PIN(57), };/* one pin per group */
@@ -203,6 +208,10 @@ static const char * const bcm2835_gpio_groups[] = {"gpio51" ,"gpio52" ,"gpio53" , +"gpio54" , +"gpio55" , +"gpio56" , + "gpio57", }; enum bcm2835_fsel {
@@ -353,6 +362,22 @@ static const struct gpio_chip bcm2835_gpio_chip = { .can_sleep = false, }; +static const struct gpio_chip bcm2711_gpio_chip = { + .label ="pinctrl-bcm2711" , + .owner =THIS_MODULE , + .request = gpiochip_generic_request, + .free = gpiochip_generic_free, + .direction_input = bcm2835_gpio_direction_input, + .direction_output = bcm2835_gpio_direction_output, + .get_direction = bcm2835_gpio_get_direction, + .get = bcm2835_gpio_get, + .set = bcm2835_gpio_set, + .set_config = gpiochip_generic_config, + .base =-1 , + .ngpio =BCM2711_NUM_GPIOS , + .can_sleep = false, +}; +static void bcm2835_gpio_irq_handle_bank (struct bcm2835_pinctrl *pc,unsigned int bank,u32 mask) {
@@ -399,7 +424,7 @@ static void bcm2835_gpio_irq_handler(struct irq_desc *desc)bcm2835_gpio_irq_handle_bank (pc,0 ,0xf0000000 );bcm2835_gpio_irq_handle_bank (pc,1 ,0x00003fff );break ; -case 2 :/* IRQ2 covers GPIOs 46-53 */ +case 2 :/* IRQ2 covers GPIOs 46-57 */ bcm2835_gpio_irq_handle_bank (pc,1 ,0x003fc000 );break ; }
@@ -618,7 +643,7 @@ static struct irq_chip bcm2835_gpio_irq_chip = {static int bcm2835_pctl_get_groups_count (struct pinctrl_dev *pctldev) { -return ARRAY_SIZE (bcm2835_gpio_groups); +return BCM2835_NUM_GPIOS ; } static const char *bcm2835_pctl_get_group_name(struct pinctrl_dev *pctldev,
@@ -776,7 +801,7 @@ static int bcm2835_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, err =of_property_read_u32_index (np,"brcm,pins" , i, &pin);if (err) goto out; -if (pin >=ARRAY_SIZE (bcm2835_gpio_pins)) { +if (pin >= pc->pctl_desc.npins) {dev_err (pc->dev,"%pOF: invalid brcm,pins value %d\n" , np, pin); err = -EINVAL ;
@@ -852,7 +877,7 @@ static int bcm2835_pmx_get_function_groups(struct pinctrl_dev *pctldev, {/* every pin can do every function */ *groups = bcm2835_gpio_groups; - *num_groups =ARRAY_SIZE (bcm2835_gpio_groups); + *num_groups =BCM2835_NUM_GPIOS ;return 0 ; }
@@ -1055,7 +1080,7 @@ static const struct pinconf_ops bcm2711_pinconf_ops = {static const struct pinctrl_desc bcm2835_pinctrl_desc = { .name =MODULE_NAME , .pins = bcm2835_gpio_pins, - .npins =ARRAY_SIZE (bcm2835_gpio_pins), + .npins =BCM2835_NUM_GPIOS , .pctlops = &bcm2835_pctl_ops, .pmxops = &bcm2835_pmx_ops, .confops = &bcm2835_pinconf_ops,
@@ -1063,9 +1088,9 @@ static const struct pinctrl_desc bcm2835_pinctrl_desc = { };static const struct pinctrl_desc bcm2711_pinctrl_desc = { - .name =MODULE_NAME , + .name ="pinctrl-bcm2711" , .pins = bcm2835_gpio_pins, - .npins =ARRAY_SIZE (bcm2835_gpio_pins), + .npins =BCM2711_NUM_GPIOS , .pctlops = &bcm2835_pctl_ops, .pmxops = &bcm2835_pmx_ops, .confops = &bcm2711_pinconf_ops,
@@ -1077,6 +1102,11 @@ static const struct pinctrl_gpio_range bcm2835_pinctrl_gpio_range = { .npins = BCM2835_NUM_GPIOS, }; +static const struct pinctrl_gpio_range bcm2711_pinctrl_gpio_range = { + .name ="pinctrl-bcm2711" , + .npins =BCM2711_NUM_GPIOS , +}; +struct bcm_plat_data {const struct gpio_chip *gpio_chip;const struct pinctrl_desc *pctl_desc;
@@ -1090,9 +1120,9 @@ static const struct bcm_plat_data bcm2835_plat_data = { };static const struct bcm_plat_data bcm2711_plat_data = { - .gpio_chip = &bcm2835_gpio_chip, + .gpio_chip = &bcm2711_gpio_chip, .pctl_desc = &bcm2711_pinctrl_desc, - .gpio_range = &bcm2835_pinctrl_gpio_range, + .gpio_range = &bcm2711_pinctrl_gpio_range, };static const struct of_device_id bcm2835_pinctrl_match[] = {
@@ -1118,8 +1148,8 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)int err, i;const struct of_device_id *match; -BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_pins) !=BCM2835_NUM_GPIOS ); -BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_groups) !=BCM2835_NUM_GPIOS ); +BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_pins) !=BCM2711_NUM_GPIOS ); +BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_groups) !=BCM2711_NUM_GPIOS ); pc =devm_kzalloc (dev,sizeof (*pc),GFP_KERNEL );if (!pc)
Signature · 1 line
2.25.1
Patch "pinctrl: bcm2835: Add support for all GPIOs on BCM2711" has been added to the 5.4-stable tree
This is a note to let you know that I've just added the patch titled
pinctrl: bcm2835: Add support for all GPIOs on BCM2711
to the 5.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
pinctrl-bcm2835-add-support-for-all-gpios-on-bcm2711.patch
and it can be found in the queue-5.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From foo@baz Thu Jan 27 04:40:37 PM CET 2022
From: Florian Fainelli <[email protected]>
Date: Tue, 25 Jan 2022 11:42:18 -0800
Subject: pinctrl: bcm2835: Add support for all GPIOs on BCM2711
To: [email protected]
Cc: Stefan Wahren <[email protected]>, Nicolas Saenz Julienne <[email protected]>, Linus Walleij <[email protected]>, Florian Fainelli <[email protected]>, Rob Herring <[email protected]>, Mark Rutland <[email protected]>, Ray Jui <[email protected]>, Scott Branden <[email protected]>, [email protected] (maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...), Eric Anholt <[email protected]>, Stefan Wahren <[email protected]>, Nicolas Saenz Julienne <[email protected]>, Phil Elwell <[email protected]>, [email protected] (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), [email protected] (open list), [email protected] (open list:PIN CONTROL SUBSYSTEM), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE)
Message-ID: <[email protected]>
From: Stefan Wahren <[email protected]>
commit b1d84a3d0a26c5844a22bc09a42704b9371208bb upstream
The BCM2711 supports 58 GPIOs. So extend pinctrl and GPIOs accordingly.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 54 ++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 12 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +42 -12
@@ -37,6 +37,7 @@#define MODULE_NAME "pinctrl-bcm2835"#define BCM2835_NUM_GPIOS 54 +#define BCM2711_NUM_GPIOS 58#define BCM2835_NUM_BANKS 2#define BCM2835_NUM_IRQS 3
@@ -78,7 +79,7 @@ struct bcm2835_pinctrl {/* note: locking assumes each bank will have its own unsigned long */ unsigned long enabled_irq_map[BCM2835_NUM_BANKS ]; -unsigned int irq_type[BCM2835_NUM_GPIOS ]; +unsigned int irq_type[BCM2711_NUM_GPIOS ];struct pinctrl_dev *pctl_dev;struct gpio_chip gpio_chip;
@@ -145,6 +146,10 @@ static struct pinctrl_pin_desc bcm2835_gBCM2835_GPIO_PIN (51 ),BCM2835_GPIO_PIN (52 ),BCM2835_GPIO_PIN (53 ), +BCM2835_GPIO_PIN (54 ), +BCM2835_GPIO_PIN (55 ), +BCM2835_GPIO_PIN (56 ), + BCM2835_GPIO_PIN(57), };/* one pin per group */
@@ -203,6 +208,10 @@ static const char * const bcm2835_gpio_g"gpio51" ,"gpio52" ,"gpio53" , +"gpio54" , +"gpio55" , +"gpio56" , + "gpio57", }; enum bcm2835_fsel {
@@ -353,6 +362,22 @@ static const struct gpio_chip bcm2835_gp .can_sleep = false, }; +static const struct gpio_chip bcm2711_gpio_chip = { + .label ="pinctrl-bcm2711" , + .owner =THIS_MODULE , + .request = gpiochip_generic_request, + .free = gpiochip_generic_free, + .direction_input = bcm2835_gpio_direction_input, + .direction_output = bcm2835_gpio_direction_output, + .get_direction = bcm2835_gpio_get_direction, + .get = bcm2835_gpio_get, + .set = bcm2835_gpio_set, + .set_config = gpiochip_generic_config, + .base =-1 , + .ngpio =BCM2711_NUM_GPIOS , + .can_sleep = false, +}; +static void bcm2835_gpio_irq_handle_bank (struct bcm2835_pinctrl *pc,unsigned int bank,u32 mask) {
@@ -399,7 +424,7 @@ static void bcm2835_gpio_irq_handler(strbcm2835_gpio_irq_handle_bank (pc,0 ,0xf0000000 );bcm2835_gpio_irq_handle_bank (pc,1 ,0x00003fff );break ; -case 2 :/* IRQ2 covers GPIOs 46-53 */ +case 2 :/* IRQ2 covers GPIOs 46-57 */ bcm2835_gpio_irq_handle_bank (pc,1 ,0x003fc000 );break ; }
@@ -618,7 +643,7 @@ static struct irq_chip bcm2835_gpio_irq_static int bcm2835_pctl_get_groups_count (struct pinctrl_dev *pctldev) { -return ARRAY_SIZE (bcm2835_gpio_groups); +return BCM2835_NUM_GPIOS ; } static const char *bcm2835_pctl_get_group_name(struct pinctrl_dev *pctldev,
@@ -776,7 +801,7 @@ static int bcm2835_pctl_dt_node_to_map(s err =of_property_read_u32_index (np,"brcm,pins" , i, &pin);if (err) goto out; -if (pin >=ARRAY_SIZE (bcm2835_gpio_pins)) { +if (pin >= pc->pctl_desc.npins) {dev_err (pc->dev,"%pOF: invalid brcm,pins value %d\n" , np, pin); err = -EINVAL ;
@@ -852,7 +877,7 @@ static int bcm2835_pmx_get_function_grou {/* every pin can do every function */ *groups = bcm2835_gpio_groups; - *num_groups =ARRAY_SIZE (bcm2835_gpio_groups); + *num_groups =BCM2835_NUM_GPIOS ;return 0 ; }
@@ -1055,7 +1080,7 @@ static const struct pinconf_ops bcm2711_static const struct pinctrl_desc bcm2835_pinctrl_desc = { .name =MODULE_NAME , .pins = bcm2835_gpio_pins, - .npins =ARRAY_SIZE (bcm2835_gpio_pins), + .npins =BCM2835_NUM_GPIOS , .pctlops = &bcm2835_pctl_ops, .pmxops = &bcm2835_pmx_ops, .confops = &bcm2835_pinconf_ops,
@@ -1063,9 +1088,9 @@ static const struct pinctrl_desc bcm2835 };static const struct pinctrl_desc bcm2711_pinctrl_desc = { - .name =MODULE_NAME , + .name ="pinctrl-bcm2711" , .pins = bcm2835_gpio_pins, - .npins =ARRAY_SIZE (bcm2835_gpio_pins), + .npins =BCM2711_NUM_GPIOS , .pctlops = &bcm2835_pctl_ops, .pmxops = &bcm2835_pmx_ops, .confops = &bcm2711_pinconf_ops,
@@ -1077,6 +1102,11 @@ static const struct pinctrl_gpio_range b .npins = BCM2835_NUM_GPIOS, }; +static const struct pinctrl_gpio_range bcm2711_pinctrl_gpio_range = { + .name ="pinctrl-bcm2711" , + .npins =BCM2711_NUM_GPIOS , +}; +struct bcm_plat_data {const struct gpio_chip *gpio_chip;const struct pinctrl_desc *pctl_desc;
@@ -1090,9 +1120,9 @@ static const struct bcm_plat_data bcm283 };static const struct bcm_plat_data bcm2711_plat_data = { - .gpio_chip = &bcm2835_gpio_chip, + .gpio_chip = &bcm2711_gpio_chip, .pctl_desc = &bcm2711_pinctrl_desc, - .gpio_range = &bcm2835_pinctrl_gpio_range, + .gpio_range = &bcm2711_pinctrl_gpio_range, };static const struct of_device_id bcm2835_pinctrl_match[] = {
@@ -1118,8 +1148,8 @@ static int bcm2835_pinctrl_probe(structint err, i;const struct of_device_id *match; -BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_pins) !=BCM2835_NUM_GPIOS ); -BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_groups) !=BCM2835_NUM_GPIOS ); +BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_pins) !=BCM2711_NUM_GPIOS ); +BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_groups) !=BCM2711_NUM_GPIOS ); pc =devm_kzalloc (dev,sizeof (*pc),GFP_KERNEL );if (!pc)
Patches currently in stable-queue which might be from [email protected] are
queue-5.4/pinctrl-bcm2835-drop-unused-define.patch queue-5.4/arm-dts-gpio-ranges-property-is-now-required.patch queue-5.4/pinctrl-bcm2835-add-support-for-wake-up-interrupts.patch queue-5.4/pinctrl-bcm2835-change-init-order-for-gpio-hogs.patch queue-5.4/pinctrl-bcm2835-refactor-platform-data.patch queue-5.4/pinctrl-bcm2835-match-bcm7211-compatible-string.patch queue-5.4/pinctrl-bcm2835-add-support-for-all-gpios-on-bcm2711.patch
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 4/7 pinctrl: bcm2835: Match BCM7211 compatible string
In reply to Florian Fainellicommit 562c856f96d22ef1204b0a314bc52e85617199b4 upstream
The BCM7211 SoC uses the same pinconf_ops as the ones defined for the BCM2711 SoC, match the compatible string and use the correct set of options.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +4 -0
@@ -1134,6 +1134,10 @@ static const struct of_device_id bcm2835_pinctrl_match[] = { .compatible = "brcm,bcm2711-gpio", .data = &bcm2711_plat_data, }, + { + .compatible = "brcm,bcm7211-gpio", + .data = &bcm2711_plat_data, + }, {} };
Signature · 1 line
2.25.1
Patch "pinctrl: bcm2835: Match BCM7211 compatible string" has been added to the 5.4-stable tree
This is a note to let you know that I've just added the patch titled
pinctrl: bcm2835: Match BCM7211 compatible string
to the 5.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
pinctrl-bcm2835-match-bcm7211-compatible-string.patch
and it can be found in the queue-5.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From foo@baz Thu Jan 27 04:40:37 PM CET 2022
From: Florian Fainelli <[email protected]>
Date: Tue, 25 Jan 2022 11:42:19 -0800
Subject: pinctrl: bcm2835: Match BCM7211 compatible string
To: [email protected]
Cc: Florian Fainelli <[email protected]>, Linus Walleij <[email protected]>, Rob Herring <[email protected]>, Mark Rutland <[email protected]>, Ray Jui <[email protected]>, Scott Branden <[email protected]>, [email protected] (maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...), Eric Anholt <[email protected]>, Stefan Wahren <[email protected]>, Nicolas Saenz Julienne <[email protected]>, Phil Elwell <[email protected]>, [email protected] (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), [email protected] (open list), [email protected] (open list:PIN CONTROL SUBSYSTEM), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE)
Message-ID: <[email protected]>
From: Florian Fainelli <[email protected]>
commit 562c856f96d22ef1204b0a314bc52e85617199b4 upstream
The BCM7211 SoC uses the same pinconf_ops as the ones defined for the BCM2711 SoC, match the compatible string and use the correct set of options.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +4 -0
@@ -1134,6 +1134,10 @@ static const struct of_device_id bcm2835 .compatible = "brcm,bcm2711-gpio", .data = &bcm2711_plat_data, }, + { + .compatible = "brcm,bcm7211-gpio", + .data = &bcm2711_plat_data, + }, {} };
Patches currently in stable-queue which might be from [email protected] are
queue-5.4/pinctrl-bcm2835-drop-unused-define.patch queue-5.4/arm-dts-gpio-ranges-property-is-now-required.patch queue-5.4/pinctrl-bcm2835-add-support-for-wake-up-interrupts.patch queue-5.4/pinctrl-bcm2835-change-init-order-for-gpio-hogs.patch queue-5.4/pinctrl-bcm2835-refactor-platform-data.patch queue-5.4/pinctrl-bcm2835-match-bcm7211-compatible-string.patch queue-5.4/pinctrl-bcm2835-add-support-for-all-gpios-on-bcm2711.patch
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 5/7 pinctrl: bcm2835: Add support for wake-up interrupts
In reply to Florian Fainellicommit 920fecc1aa4591da27ef9dcb338fc5da86b404d7 upstream
Leverage the IRQCHIP_MASK_ON_SUSPEND flag in order to avoid having to specifically treat the GPIO interrupts during suspend and resume, and simply implement an irq_set_wake() callback that is responsible for enabling the parent wake-up interrupt as a wake-up interrupt.
To avoid allocating unnecessary resources for other chips, the wake-up interrupts are only initialized if we have a brcm,bcm7211-gpio compatibility string.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 76 ++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +75 -1
@@ -19,6 +19,7 @@#include <linux/irq.h> #include <linux/irqdesc.h> #include <linux/init.h> +#include <linux/interrupt.h> #include <linux/of_address.h> #include <linux/of.h> #include <linux/of_irq.h>
@@ -76,6 +77,7 @@struct bcm2835_pinctrl {struct device *dev;void __iomem *base; +int *wake_irq;/* note: locking assumes each bank will have its own unsigned long */ unsigned long enabled_irq_map[BCM2835_NUM_BANKS ];
@@ -432,6 +434,11 @@ static void bcm2835_gpio_irq_handler(struct irq_desc *desc)chained_irq_exit (host_chip, desc); } +static irqreturn_t bcm2835_gpio_wake_irq_handler (int irq,void *dev_id) +{ +return IRQ_HANDLED ; +} +static inline void __bcm2835_gpio_irq_config (struct bcm2835_pinctrl *pc,unsigned reg,unsigned offset,bool enable) {
@@ -631,6 +638,34 @@ static void bcm2835_gpio_irq_ack(struct irq_data *data)bcm2835_gpio_set_bit (pc,GPEDS0 , gpio); } +static int bcm2835_gpio_irq_set_wake (struct irq_data *data,unsigned int on) +{ +struct gpio_chip *chip =irq_data_get_irq_chip_data (data); +struct bcm2835_pinctrl *pc =gpiochip_get_data (chip); +unsigned gpio =irqd_to_hwirq (data); +unsigned int irqgroup; +int ret = -EINVAL ; + +if (!pc->wake_irq) +return ret; + +if (gpio <=27 ) + irqgroup =0 ; +else if (gpio >=28 && gpio <=45 ) + irqgroup =1 ; +else if (gpio >=46 && gpio <=57 ) + irqgroup =2 ; +else +return ret; + +if (on) + ret =enable_irq_wake (pc->wake_irq[irqgroup]); +else + ret =disable_irq_wake (pc->wake_irq[irqgroup]); + +return ret; +} +static struct irq_chip bcm2835_gpio_irq_chip = { .name =MODULE_NAME , .irq_enable = bcm2835_gpio_irq_enable,
@@ -639,6 +674,8 @@ static struct irq_chip bcm2835_gpio_irq_chip = { .irq_ack = bcm2835_gpio_irq_ack, .irq_mask = bcm2835_gpio_irq_disable, .irq_unmask = bcm2835_gpio_irq_enable, + .irq_set_wake = bcm2835_gpio_irq_set_wake, + .flags = IRQCHIP_MASK_ON_SUSPEND, };static int bcm2835_pctl_get_groups_count (struct pinctrl_dev *pctldev)
@@ -1151,6 +1188,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)struct resource iomem;int err, i;const struct of_device_id *match; +int is_7211 =0 ;BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_pins) !=BCM2711_NUM_GPIOS );BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_groups) !=BCM2711_NUM_GPIOS );
@@ -1177,6 +1215,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)return -EINVAL ; pdata = match->data; + is_7211 =of_device_is_compatible (np,"brcm,bcm7211-gpio" ); pc->gpio_chip = *pdata->gpio_chip; pc->gpio_chip.parent = dev;
@@ -1211,6 +1250,15 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) GFP_KERNEL);if (!girq->parents)return -ENOMEM ; + +if (is_7211) { + pc->wake_irq =devm_kcalloc (dev,BCM2835_NUM_IRQS , +sizeof (*pc->wake_irq), +GFP_KERNEL ); +if (!pc->wake_irq) +return -ENOMEM ; + } +/* * Use the same handler for all groups: this is necessary * since we use one gpiochip to cover all lines - the
@@ -1218,8 +1266,34 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)* bank that was firing the IRQ and look up the per-group * and bank data. */ -for (i =0 ; i <BCM2835_NUM_IRQS ; i++) +for (i =0 ; i <BCM2835_NUM_IRQS ; i++) { +int len; +char *name; + girq->parents[i] =irq_of_parse_and_map (np, i); +if (!is_7211) +continue ; + +/* Skip over the all banks interrupts */ + pc->wake_irq[i] =irq_of_parse_and_map (np, i + +BCM2835_NUM_IRQS +1 ); + + len =strlen (dev_name (pc->dev)) +16 ; + name =devm_kzalloc (pc->dev, len,GFP_KERNEL ); +if (!name) +return -ENOMEM ; + +snprintf (name, len,"%s:bank%d" ,dev_name (pc->dev), i); + +/* These are optional interrupts */ + err =devm_request_irq (dev, pc->wake_irq[i], + bcm2835_gpio_wake_irq_handler, +IRQF_SHARED , name, pc); +if (err) +dev_warn (dev,"unable to request wake IRQ %d\n" , + pc->wake_irq[i]); + } + girq->default_type =IRQ_TYPE_NONE ; girq->handler = handle_level_irq;
Signature · 1 line
2.25.1
Patch "pinctrl: bcm2835: Add support for wake-up interrupts" has been added to the 5.4-stable tree
This is a note to let you know that I've just added the patch titled
pinctrl: bcm2835: Add support for wake-up interrupts
to the 5.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
pinctrl-bcm2835-add-support-for-wake-up-interrupts.patch
and it can be found in the queue-5.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From foo@baz Thu Jan 27 04:40:37 PM CET 2022
From: Florian Fainelli <[email protected]>
Date: Tue, 25 Jan 2022 11:42:20 -0800
Subject: pinctrl: bcm2835: Add support for wake-up interrupts
To: [email protected]
Cc: Florian Fainelli <[email protected]>, Linus Walleij <[email protected]>, Rob Herring <[email protected]>, Mark Rutland <[email protected]>, Ray Jui <[email protected]>, Scott Branden <[email protected]>, [email protected] (maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...), Eric Anholt <[email protected]>, Stefan Wahren <[email protected]>, Nicolas Saenz Julienne <[email protected]>, Phil Elwell <[email protected]>, [email protected] (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), [email protected] (open list), [email protected] (open list:PIN CONTROL SUBSYSTEM), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE)
Message-ID: <[email protected]>
From: Florian Fainelli <[email protected]>
commit 920fecc1aa4591da27ef9dcb338fc5da86b404d7 upstream
Leverage the IRQCHIP_MASK_ON_SUSPEND flag in order to avoid having to specifically treat the GPIO interrupts during suspend and resume, and simply implement an irq_set_wake() callback that is responsible for enabling the parent wake-up interrupt as a wake-up interrupt.
To avoid allocating unnecessary resources for other chips, the wake-up interrupts are only initialized if we have a brcm,bcm7211-gpio compatibility string.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 76 +++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +75 -1
@@ -19,6 +19,7 @@#include <linux/irq.h> #include <linux/irqdesc.h> #include <linux/init.h> +#include <linux/interrupt.h> #include <linux/of_address.h> #include <linux/of.h> #include <linux/of_irq.h>
@@ -76,6 +77,7 @@struct bcm2835_pinctrl {struct device *dev;void __iomem *base; +int *wake_irq;/* note: locking assumes each bank will have its own unsigned long */ unsigned long enabled_irq_map[BCM2835_NUM_BANKS ];
@@ -432,6 +434,11 @@ static void bcm2835_gpio_irq_handler(strchained_irq_exit (host_chip, desc); } +static irqreturn_t bcm2835_gpio_wake_irq_handler (int irq,void *dev_id) +{ +return IRQ_HANDLED ; +} +static inline void __bcm2835_gpio_irq_config (struct bcm2835_pinctrl *pc,unsigned reg,unsigned offset,bool enable) {
@@ -631,6 +638,34 @@ static void bcm2835_gpio_irq_ack(structbcm2835_gpio_set_bit (pc,GPEDS0 , gpio); } +static int bcm2835_gpio_irq_set_wake (struct irq_data *data,unsigned int on) +{ +struct gpio_chip *chip =irq_data_get_irq_chip_data (data); +struct bcm2835_pinctrl *pc =gpiochip_get_data (chip); +unsigned gpio =irqd_to_hwirq (data); +unsigned int irqgroup; +int ret = -EINVAL ; + +if (!pc->wake_irq) +return ret; + +if (gpio <=27 ) + irqgroup =0 ; +else if (gpio >=28 && gpio <=45 ) + irqgroup =1 ; +else if (gpio >=46 && gpio <=57 ) + irqgroup =2 ; +else +return ret; + +if (on) + ret =enable_irq_wake (pc->wake_irq[irqgroup]); +else + ret =disable_irq_wake (pc->wake_irq[irqgroup]); + +return ret; +} +static struct irq_chip bcm2835_gpio_irq_chip = { .name =MODULE_NAME , .irq_enable = bcm2835_gpio_irq_enable,
@@ -639,6 +674,8 @@ static struct irq_chip bcm2835_gpio_irq_ .irq_ack = bcm2835_gpio_irq_ack, .irq_mask = bcm2835_gpio_irq_disable, .irq_unmask = bcm2835_gpio_irq_enable, + .irq_set_wake = bcm2835_gpio_irq_set_wake, + .flags = IRQCHIP_MASK_ON_SUSPEND, };static int bcm2835_pctl_get_groups_count (struct pinctrl_dev *pctldev)
@@ -1151,6 +1188,7 @@ static int bcm2835_pinctrl_probe(structstruct resource iomem;int err, i;const struct of_device_id *match; +int is_7211 =0 ;BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_pins) !=BCM2711_NUM_GPIOS );BUILD_BUG_ON (ARRAY_SIZE (bcm2835_gpio_groups) !=BCM2711_NUM_GPIOS );
@@ -1177,6 +1215,7 @@ static int bcm2835_pinctrl_probe(structreturn -EINVAL ; pdata = match->data; + is_7211 =of_device_is_compatible (np,"brcm,bcm7211-gpio" ); pc->gpio_chip = *pdata->gpio_chip; pc->gpio_chip.parent = dev;
@@ -1211,6 +1250,15 @@ static int bcm2835_pinctrl_probe(struct GFP_KERNEL);if (!girq->parents)return -ENOMEM ; + +if (is_7211) { + pc->wake_irq =devm_kcalloc (dev,BCM2835_NUM_IRQS , +sizeof (*pc->wake_irq), +GFP_KERNEL ); +if (!pc->wake_irq) +return -ENOMEM ; + } +/* * Use the same handler for all groups: this is necessary * since we use one gpiochip to cover all lines - the
@@ -1218,8 +1266,34 @@ static int bcm2835_pinctrl_probe(struct* bank that was firing the IRQ and look up the per-group * and bank data. */ -for (i =0 ; i <BCM2835_NUM_IRQS ; i++) +for (i =0 ; i <BCM2835_NUM_IRQS ; i++) { +int len; +char *name; + girq->parents[i] =irq_of_parse_and_map (np, i); +if (!is_7211) +continue ; + +/* Skip over the all banks interrupts */ + pc->wake_irq[i] =irq_of_parse_and_map (np, i + +BCM2835_NUM_IRQS +1 ); + + len =strlen (dev_name (pc->dev)) +16 ; + name =devm_kzalloc (pc->dev, len,GFP_KERNEL ); +if (!name) +return -ENOMEM ; + +snprintf (name, len,"%s:bank%d" ,dev_name (pc->dev), i); + +/* These are optional interrupts */ + err =devm_request_irq (dev, pc->wake_irq[i], + bcm2835_gpio_wake_irq_handler, +IRQF_SHARED , name, pc); +if (err) +dev_warn (dev,"unable to request wake IRQ %d\n" , + pc->wake_irq[i]); + } + girq->default_type =IRQ_TYPE_NONE ; girq->handler = handle_level_irq;
Patches currently in stable-queue which might be from [email protected] are
queue-5.4/pinctrl-bcm2835-drop-unused-define.patch queue-5.4/arm-dts-gpio-ranges-property-is-now-required.patch queue-5.4/pinctrl-bcm2835-add-support-for-wake-up-interrupts.patch queue-5.4/pinctrl-bcm2835-change-init-order-for-gpio-hogs.patch queue-5.4/pinctrl-bcm2835-refactor-platform-data.patch queue-5.4/pinctrl-bcm2835-match-bcm7211-compatible-string.patch queue-5.4/pinctrl-bcm2835-add-support-for-all-gpios-on-bcm2711.patch
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 6/7 pinctrl: bcm2835: Change init order for gpio hogs
In reply to Florian FainelliFrom: Phil Elwell <[email protected]>
commit 266423e60ea1b953fcc0cd97f3dad85857e434d1 upstream
...and gpio-ranges
pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.
Change the initialisation sequence to register the pinctrl driver first.
This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +16 -13
@@ -1241,6 +1241,18 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)raw_spin_lock_init (&pc->irq_lock[i]); } + pc->pctl_desc = *pdata->pctl_desc; + pc->pctl_dev =devm_pinctrl_register (dev, &pc->pctl_desc, pc); +if (IS_ERR (pc->pctl_dev)) { +gpiochip_remove (&pc->gpio_chip); +return PTR_ERR (pc->pctl_dev); + } + + pc->gpio_range = *pdata->gpio_range; + pc->gpio_range.base = pc->gpio_chip.base; + pc->gpio_range.gc = &pc->gpio_chip; +pinctrl_add_gpio_range (pc->pctl_dev, &pc->gpio_range); + girq = &pc->gpio_chip.irq; girq->chip = &bcm2835_gpio_irq_chip; girq->parent_handler = bcm2835_gpio_irq_handler;
@@ -1248,8 +1260,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) girq->parents =devm_kcalloc (dev,BCM2835_NUM_IRQS ,sizeof (*girq->parents),GFP_KERNEL ); -if (!girq->parents) +if (!girq->parents) { +pinctrl_remove_gpio_range (pc->pctl_dev, &pc->gpio_range);return -ENOMEM ; + }if (is_7211) { pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS,
@@ -1300,21 +1314,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) err =gpiochip_add_data (&pc->gpio_chip, pc);if (err) {dev_err (dev,"could not add GPIO chip\n" ); +pinctrl_remove_gpio_range (pc->pctl_dev, &pc->gpio_range);return err; } - pc->pctl_desc = *pdata->pctl_desc; - pc->pctl_dev =devm_pinctrl_register (dev, &pc->pctl_desc, pc); -if (IS_ERR (pc->pctl_dev)) { -gpiochip_remove (&pc->gpio_chip); -return PTR_ERR (pc->pctl_dev); - } - - pc->gpio_range = *pdata->gpio_range; - pc->gpio_range.base = pc->gpio_chip.base; - pc->gpio_range.gc = &pc->gpio_chip; -pinctrl_add_gpio_range (pc->pctl_dev, &pc->gpio_range); -return 0 ; }
Signature · 1 line
2.25.1
Patch "pinctrl: bcm2835: Change init order for gpio hogs" has been added to the 5.4-stable tree
This is a note to let you know that I've just added the patch titled
pinctrl: bcm2835: Change init order for gpio hogs
to the 5.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
pinctrl-bcm2835-change-init-order-for-gpio-hogs.patch
and it can be found in the queue-5.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From foo@baz Thu Jan 27 04:40:37 PM CET 2022
From: Florian Fainelli <[email protected]>
Date: Tue, 25 Jan 2022 11:42:21 -0800
Subject: pinctrl: bcm2835: Change init order for gpio hogs
To: [email protected]
Cc: Phil Elwell <[email protected]>, Florian Fainelli <[email protected]>, Linus Walleij <[email protected]>, Rob Herring <[email protected]>, Mark Rutland <[email protected]>, Ray Jui <[email protected]>, Scott Branden <[email protected]>, [email protected] (maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...), Eric Anholt <[email protected]>, Stefan Wahren <[email protected]>, Nicolas Saenz Julienne <[email protected]>, [email protected] (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), [email protected] (open list), [email protected] (open list:PIN CONTROL SUBSYSTEM), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE)
Message-ID: <[email protected]>
From: Phil Elwell <[email protected]>
commit 266423e60ea1b953fcc0cd97f3dad85857e434d1 upstream
...and gpio-ranges
pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.
Change the initialisation sequence to register the pinctrl driver first.
This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +16 -13
@@ -1241,6 +1241,18 @@ static int bcm2835_pinctrl_probe(structraw_spin_lock_init (&pc->irq_lock[i]); } + pc->pctl_desc = *pdata->pctl_desc; + pc->pctl_dev =devm_pinctrl_register (dev, &pc->pctl_desc, pc); +if (IS_ERR (pc->pctl_dev)) { +gpiochip_remove (&pc->gpio_chip); +return PTR_ERR (pc->pctl_dev); + } + + pc->gpio_range = *pdata->gpio_range; + pc->gpio_range.base = pc->gpio_chip.base; + pc->gpio_range.gc = &pc->gpio_chip; +pinctrl_add_gpio_range (pc->pctl_dev, &pc->gpio_range); + girq = &pc->gpio_chip.irq; girq->chip = &bcm2835_gpio_irq_chip; girq->parent_handler = bcm2835_gpio_irq_handler;
@@ -1248,8 +1260,10 @@ static int bcm2835_pinctrl_probe(struct girq->parents =devm_kcalloc (dev,BCM2835_NUM_IRQS ,sizeof (*girq->parents),GFP_KERNEL ); -if (!girq->parents) +if (!girq->parents) { +pinctrl_remove_gpio_range (pc->pctl_dev, &pc->gpio_range);return -ENOMEM ; + }if (is_7211) { pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS,
@@ -1300,21 +1314,10 @@ static int bcm2835_pinctrl_probe(struct err =gpiochip_add_data (&pc->gpio_chip, pc);if (err) {dev_err (dev,"could not add GPIO chip\n" ); +pinctrl_remove_gpio_range (pc->pctl_dev, &pc->gpio_range);return err; } - pc->pctl_desc = *pdata->pctl_desc; - pc->pctl_dev =devm_pinctrl_register (dev, &pc->pctl_desc, pc); -if (IS_ERR (pc->pctl_dev)) { -gpiochip_remove (&pc->gpio_chip); -return PTR_ERR (pc->pctl_dev); - } - - pc->gpio_range = *pdata->gpio_range; - pc->gpio_range.base = pc->gpio_chip.base; - pc->gpio_range.gc = &pc->gpio_chip; -pinctrl_add_gpio_range (pc->pctl_dev, &pc->gpio_range); -return 0 ; }
Patches currently in stable-queue which might be from [email protected] are
queue-5.4/pinctrl-bcm2835-drop-unused-define.patch queue-5.4/arm-dts-gpio-ranges-property-is-now-required.patch queue-5.4/pinctrl-bcm2835-add-support-for-wake-up-interrupts.patch queue-5.4/pinctrl-bcm2835-change-init-order-for-gpio-hogs.patch queue-5.4/pinctrl-bcm2835-refactor-platform-data.patch queue-5.4/pinctrl-bcm2835-match-bcm7211-compatible-string.patch queue-5.4/pinctrl-bcm2835-add-support-for-all-gpios-on-bcm2711.patch
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 7/7 ARM: dts: gpio-ranges property is now required
In reply to Florian FainelliFrom: Phil Elwell <[email protected]>
commit c8013355ead68dce152cf426686f8a5f80d88b40 upstream
Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.
[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")
--- arch/arm/boot/dts/bcm283x.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/bcm283x.dtsi +1 -0
@@ -183,6 +183,7 @@ interrupt-controller; #interrupt-cells = <2>; + gpio-ranges = <&gpio 0 0 54>; /* Defines pin muxing groups according to * BCM2835-ARM-Peripherals.pdf page 102.
Signature · 1 line
2.25.1
Patch "ARM: dts: gpio-ranges property is now required" has been added to the 5.4-stable tree
This is a note to let you know that I've just added the patch titled
ARM: dts: gpio-ranges property is now required
to the 5.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
arm-dts-gpio-ranges-property-is-now-required.patch
and it can be found in the queue-5.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From foo@baz Thu Jan 27 04:40:37 PM CET 2022
From: Florian Fainelli <[email protected]>
Date: Tue, 25 Jan 2022 11:42:22 -0800
Subject: ARM: dts: gpio-ranges property is now required
To: [email protected]
Cc: Phil Elwell <[email protected]>, Stefan Wahren <[email protected]>, Florian Fainelli <[email protected]>, Jan Kiszka <[email protected]>, Linus Walleij <[email protected]>, Olof Johansson <[email protected]>, Rob Herring <[email protected]>, Mark Rutland <[email protected]>, Ray Jui <[email protected]>, Scott Branden <[email protected]>, [email protected] (maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...), Eric Anholt <[email protected]>, Stefan Wahren <[email protected]>, Nicolas Saenz Julienne <[email protected]>, [email protected] (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), [email protected] (open list), [email protected] (open list:PIN CONTROL SUBSYSTEM), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), [email protected] (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE)
Message-ID: <[email protected]>
From: Phil Elwell <[email protected]>
commit c8013355ead68dce152cf426686f8a5f80d88b40 upstream
Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.
[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")
--- arch/arm/boot/dts/bcm283x.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/bcm283x.dtsi +1 -0
@@ -183,6 +183,7 @@ interrupt-controller; #interrupt-cells = <2>; + gpio-ranges = <&gpio 0 0 54>; /* Defines pin muxing groups according to * BCM2835-ARM-Peripherals.pdf page 102.
Patches currently in stable-queue which might be from [email protected] are
queue-5.4/pinctrl-bcm2835-drop-unused-define.patch queue-5.4/arm-dts-gpio-ranges-property-is-now-required.patch queue-5.4/pinctrl-bcm2835-add-support-for-wake-up-interrupts.patch queue-5.4/pinctrl-bcm2835-change-init-order-for-gpio-hogs.patch queue-5.4/pinctrl-bcm2835-refactor-platform-data.patch queue-5.4/pinctrl-bcm2835-match-bcm7211-compatible-string.patch queue-5.4/pinctrl-bcm2835-add-support-for-all-gpios-on-bcm2711.patch
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg KH
maintainerQuoted 28 lines · Florian Fainelli
Hi all,
This patch series is intended to backport the fix from Phil "pinctrl:
bcm2835: Change init order for gpio hogs" into the 5.4 tree since the blamed commit:
73345a18d464b("pinctrl: bcm2835: Pass irqchip when adding gpiochip")is in 5.4. To get there, I did backport a number of changes in order for the commit "pinctrl: bcm2835: Change init order for gpio hogs" to apply cleanly with no hunks.
Those should have no functional impact since we do not have support for 7211 or 2711 in the upstream stable 5.4.
Both the pinctrl *and* the DTS changes must be taken in lockstep otherwise the GPIO pins are simply not usable unfortunately.
Thanks!
Florian Fainelli (2):
pinctrl: bcm2835: Match BCM7211 compatible string
pinctrl: bcm2835: Add support for wake-up interruptsPhil Elwell (2):
pinctrl: bcm2835: Change init order for gpio hogs
ARM: dts: gpio-ranges property is now required
Quoted 12 lines
Stefan Wahren (3):
pinctrl: bcm2835: Drop unused define
pinctrl: bcm2835: Refactor platform data
pinctrl: bcm2835: Add support for all GPIOs on BCM2711arch/arm/boot/dts/bcm283x.dtsi | 1 + drivers/pinctrl/bcm/pinctrl-bcm2835.c | 209 +++++++++++++++++++++----- 2 files changed, 175 insertions(+), 35 deletions(-)Signature · 1 line
2.25.1
All now queued up, thanks.
greg k-h