bcm63xx: pinctrl: fix BCM6348 groups
authorDaniel González Cabanelas <dgcbueu@gmail.com>
Tue, 19 May 2020 13:56:29 +0000 (15:56 +0200)
committerÁlvaro Fernández Rojas <noltari@gmail.com>
Tue, 23 Feb 2021 10:01:20 +0000 (11:01 +0100)
The current driver has some troubles:
 - Some groupings are wrong.
 - The pinctrl group0 owns pins never used (at least in Openwrt) for any
   pinmux. The driver hijacks all the pins on the group avoiding any other
   use, spite they're free. I.e. for buttons, causing this kernel error:
   [  4.735928] gpio-keys-polled keys: unable to claim gpio 479, err=-22
   [  4.742642] gpio-keys-polled: probe of keys failed with error -22
 - Minor errors about groupings on the documentation
 - Missing "diag" grouping in dtsi
 - Wrong groupings in dtsi

Fix it by setting the correct groups.
And relax the pin capturing, letting the gpios belonging to any group to
be used for other purposes like buttons. This was the behavior with stock
firmwares and old OpenWrt versions which never caused any trouble.

Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
target/linux/bcm63xx/dts/bcm6348.dtsi
target/linux/bcm63xx/patches-5.10/133-Documentation-add-BCM6348-pincontroller-binding-docu.patch
target/linux/bcm63xx/patches-5.10/134-pinctrl-add-a-pincontrol-driver-for-BCM6348.patch
target/linux/bcm63xx/patches-5.4/133-Documentation-add-BCM6348-pincontroller-binding-docu.patch
target/linux/bcm63xx/patches-5.4/134-pinctrl-add-a-pincontrol-driver-for-BCM6348.patch

index 1e04486909cd7d9da6e60dbfd379b4b65eebf39c..38bb71e53cc35962a449011b051f9b07c72d4c15 100644 (file)
@@ -94,7 +94,7 @@
                        };
 
                        pinctrl_mii_snoop: mii_snoop {
-                               function = "ext_ephy";
+                               function = "mii_snoop";
                                groups = "group1", "group4";
                        };
 
 
                        pinctrl_utopia: utopia {
                                function = "utopia";
-                               groups = "group0", "group1", "group3";
+                               groups = "group1", "group3", "group4";
+                       };
+
+                       pinctrl_diag: diag {
+                               function = "diag";
+                               groups = "group0", "group1", "group2", "group3", "group4";
                        };
                };
 
index 6bac90373c6e4507c48c5695771c4c6aa9798425..800f0540cc98550a074a5c69cbe9b4d00d9d328a 100644 (file)
@@ -41,9 +41,9 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
 +
 +name          pins    functions
 +-----------------------------------------------------------
-+group0                32-36   ext_mii, utopia, diag
++group0                32-36   ext_mii, diag
 +group1                22-31   ext_ephy, mii_snoop, mii_pccard,
 +                      spi_master_uart, utopia, diag
 +group2                16-21   pci, diag
-+group3                8-15    ext_mii, utopia
-+group4                0-7     ext_ephy, mii_snoop, legacy_led, diag
++group3                8-15    ext_mii, utopia, diag
++group4                0-7     ext_ephy, mii_snoop, legacy_led, utopia, diag
index b48723c1b3a0681a2e17606e610b48465e52b3a1..3b613fdca5311144037156e705264420a163ae8c 100644 (file)
@@ -37,7 +37,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
 +obj-$(CONFIG_PINCTRL_BCM6348) += pinctrl-bcm6348.o
 --- /dev/null
 +++ b/drivers/pinctrl/bcm63xx/pinctrl-bcm6348.c
-@@ -0,0 +1,391 @@
+@@ -0,0 +1,370 @@
 +/*
 + * This file is subject to the terms and conditions of the GNU General Public
 + * License.  See the file "COPYING" in the main directory of this archive
@@ -225,15 +225,16 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
 +};
 +
 +static const char * const utopia_groups[] = {
-+      "group0",
 +      "group1",
 +      "group3",
++      "group4",
 +};
 +
 +static const char * const diag_groups[] = {
 +      "group0",
 +      "group1",
 +      "group2",
++      "group3",
 +      "group4",
 +};
 +
@@ -335,27 +336,6 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
 +      return 0;
 +}
 +
-+static int bcm6348_gpio_request_enable(struct pinctrl_dev *pctldev,
-+                                     struct pinctrl_gpio_range *range,
-+                                     unsigned offset)
-+{
-+      struct bcm6348_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
-+      struct pin_desc *desc;
-+      u32 mask;
-+
-+      /* don't reconfigure if already muxed */
-+      desc = pin_desc_get(pctldev, offset);
-+      if (desc->mux_usecount)
-+              return 0;
-+
-+      mask = GROUP_MASK(offset);
-+
-+      /* disable all functions using this pin */
-+      bcm6348_rmw_mux(pctl, mask, 0);
-+
-+      return 0;
-+}
-+
 +static struct pinctrl_ops bcm6348_pctl_ops = {
 +      .get_groups_count       = bcm6348_pinctrl_get_group_count,
 +      .get_group_name         = bcm6348_pinctrl_get_group_name,
@@ -371,8 +351,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
 +      .get_function_name      = bcm6348_pinctrl_get_func_name,
 +      .get_function_groups    = bcm6348_pinctrl_get_groups,
 +      .set_mux                = bcm6348_pinctrl_set_mux,
-+      .gpio_request_enable    = bcm6348_gpio_request_enable,
-+      .strict                 = true,
++      .strict                 = false,
 +};
 +
 +static int bcm6348_pinctrl_probe(struct platform_device *pdev)
index 6bac90373c6e4507c48c5695771c4c6aa9798425..800f0540cc98550a074a5c69cbe9b4d00d9d328a 100644 (file)
@@ -41,9 +41,9 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
 +
 +name          pins    functions
 +-----------------------------------------------------------
-+group0                32-36   ext_mii, utopia, diag
++group0                32-36   ext_mii, diag
 +group1                22-31   ext_ephy, mii_snoop, mii_pccard,
 +                      spi_master_uart, utopia, diag
 +group2                16-21   pci, diag
-+group3                8-15    ext_mii, utopia
-+group4                0-7     ext_ephy, mii_snoop, legacy_led, diag
++group3                8-15    ext_mii, utopia, diag
++group4                0-7     ext_ephy, mii_snoop, legacy_led, utopia, diag
index b48723c1b3a0681a2e17606e610b48465e52b3a1..3b613fdca5311144037156e705264420a163ae8c 100644 (file)
@@ -37,7 +37,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
 +obj-$(CONFIG_PINCTRL_BCM6348) += pinctrl-bcm6348.o
 --- /dev/null
 +++ b/drivers/pinctrl/bcm63xx/pinctrl-bcm6348.c
-@@ -0,0 +1,391 @@
+@@ -0,0 +1,370 @@
 +/*
 + * This file is subject to the terms and conditions of the GNU General Public
 + * License.  See the file "COPYING" in the main directory of this archive
@@ -225,15 +225,16 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
 +};
 +
 +static const char * const utopia_groups[] = {
-+      "group0",
 +      "group1",
 +      "group3",
++      "group4",
 +};
 +
 +static const char * const diag_groups[] = {
 +      "group0",
 +      "group1",
 +      "group2",
++      "group3",
 +      "group4",
 +};
 +
@@ -335,27 +336,6 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
 +      return 0;
 +}
 +
-+static int bcm6348_gpio_request_enable(struct pinctrl_dev *pctldev,
-+                                     struct pinctrl_gpio_range *range,
-+                                     unsigned offset)
-+{
-+      struct bcm6348_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
-+      struct pin_desc *desc;
-+      u32 mask;
-+
-+      /* don't reconfigure if already muxed */
-+      desc = pin_desc_get(pctldev, offset);
-+      if (desc->mux_usecount)
-+              return 0;
-+
-+      mask = GROUP_MASK(offset);
-+
-+      /* disable all functions using this pin */
-+      bcm6348_rmw_mux(pctl, mask, 0);
-+
-+      return 0;
-+}
-+
 +static struct pinctrl_ops bcm6348_pctl_ops = {
 +      .get_groups_count       = bcm6348_pinctrl_get_group_count,
 +      .get_group_name         = bcm6348_pinctrl_get_group_name,
@@ -371,8 +351,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
 +      .get_function_name      = bcm6348_pinctrl_get_func_name,
 +      .get_function_groups    = bcm6348_pinctrl_get_groups,
 +      .set_mux                = bcm6348_pinctrl_set_mux,
-+      .gpio_request_enable    = bcm6348_gpio_request_enable,
-+      .strict                 = true,
++      .strict                 = false,
 +};
 +
 +static int bcm6348_pinctrl_probe(struct platform_device *pdev)