Skip to contentSkip to conversation

dt-bindings: pinctrl: Add binding for BCM4908 pinctrl

PATCH Superseded Rafał Miłecki 5 participants 11 messages Dec 15, 2021 – Dec 22, 2021

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dt-bindings: pinctrl: Add binding for BCM4908 pinctrl

From: Rafał Miłecki <[email protected]>

It's hardware block that is part of every SoC from BCM4908 family.

---
 .../pinctrl/brcm,bcm4908-pinctrl.yaml         | 72 +++++++++++++++++++
 MAINTAINERS                                   |  7 ++
 2 files changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.yaml new file +72 -0
new file mode 100644
index 000000000000..175a992f15e1
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm4908-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM4908 pin controller
+
+maintainers:
+  - Rafał Miłecki <[email protected]>
+
+description:
+  Binding for pin controller present on BCM4908 family SoCs.
+
+properties:
+  compatible:
+    const: brcm,bcm4908-pinctrl
+
+  reg:
+    maxItems: 1
+
+patternProperties:
+  '-pins$':
+    type: object
+    $ref: pinmux-node.yaml#
+
+    properties:
+      function:
+        enum: [ led_0, led_1, led_2, led_3, led_4, led_5, led_6, led_7, led_8,
+                led_9, led_10, led_11, led_12, led_13, led_14, led_15, led_16,
+                led_17, led_18, led_19, led_20, led_21, led_22, led_23, led_24,
+                led_25, led_26, led_27, led_28, led_29, led_30, led_31,
+                hs_uart, i2c, i2s, nand_ctrl, nand_data, emmc_ctrl, usb0_pwr,
+                usb1_pwr ]
+
+      groups:
+        minItems: 1
+        maxItems: 2
+        items:
+          enum: [ led_0_grp_a, led_1_grp_a, led_2_grp_a, led_3_grp_a,
+                  led_4_grp_a, led_5_grp_a, led_6_grp_a, led_7_grp_a,
+                  led_8_grp_a, led_9_grp_a, led_10_grp_a, led_10_grp_b,
+                  led_11_grp_a, led_11_grp_b, led_12_grp_a, led_12_grp_b,
+                  led_13_grp_a, led_13_grp_b, led_14_grp_a, led_15_grp_a,
+                  led_16_grp_a, led_17_grp_a, led_18_grp_a, led_19_grp_a,
+                  led_20_grp_a, led_21_grp_a, led_22_grp_a, led_23_grp_a,
+                  led_24_grp_a, led_25_grp_a, led_26_grp_a, led_27_grp_a,
+                  led_28_grp_a, led_29_grp_a, led_30_grp_a, led_31_grp_a,
+                  led_31_grp_b, hs_uart_grp, i2c_grp_a, i2c_grp_b, i2s_grp,
+                  nand_ctrl_grp, nand_data_grp, emmc_ctrl_grp, usb0_pwr_grp,
+                  usb1_pwr_grp ]
+
+allOf:
+  - $ref: pinctrl.yaml#
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    pinctrl@ff800560 {
+        compatible = "brcm,bcm4908-pinctrl";
+        reg = <0xff800560 0x10>;
+
+        led_0-a-pins {
+            function = "led_0";
+            groups = "led_0_grp_a";
+        };
+    };
MAINTAINERS +7 -0
index 52653c83de69..949cff4ee1e4 100644
@@ -3666,6 +3666,13 @@ F:	Documentation/devicetree/bindings/net/brcm,bcm4908-enet.yaml
 F:	drivers/net/ethernet/broadcom/bcm4908_enet.*
 F:	drivers/net/ethernet/broadcom/unimac.h
 
+BROADCOM BCM4908 PINMUX DRIVER
+M:	Rafał Miłecki <[email protected]>
+M:	[email protected]
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.yaml
+
 BROADCOM BCM5301X ARM ARCHITECTURE
 M:	Hauke Mehrtens <[email protected]>
 M:	Rafał Miłecki <[email protected]>
Signature · 1 line
2.31.1
#1 lore raw

PATCH 2/2 pinctrl: bcm: add driver for BCM4908 pinmux

From: Rafał Miłecki <[email protected]>

BCM4908 has its own pins layout so it needs a custom binding and a Linux driver.

---
 MAINTAINERS                           |   1 +
 drivers/pinctrl/bcm/Kconfig           |  13 +
 drivers/pinctrl/bcm/Makefile          |   1 +
 drivers/pinctrl/bcm/pinctrl-bcm4908.c | 561 ++++++++++++++++++++++++++
 4 files changed, 576 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm4908.c
MAINTAINERS +1 -0
index 949cff4ee1e4..b906c094a4f6 100644
@@ -3672,6 +3672,7 @@ M:	[email protected]
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.yaml
+F:	drivers/pinctrl/bcm/pinctrl-bcm4908.c
 
 BROADCOM BCM5301X ARM ARCHITECTURE
 M:	Hauke Mehrtens <[email protected]>
drivers/pinctrl/bcm/Kconfig +13 -0
index 5123f4c33854..ea5034cce644 100644
@@ -29,6 +29,19 @@ config PINCTRL_BCM2835
 	help
 	   Say Y here to enable the Broadcom BCM2835 GPIO driver.
 
+config PINCTRL_BCM4908
+	bool "Broadcom BCM4908 pinmux driver"
+	depends on OF && (ARCH_BCM4908 || COMPILE_TEST)
+	select PINMUX
+	select PINCONF
+	select GENERIC_PINCONF
+	select GENERIC_PINCTRL_GROUPS
+	select GENERIC_PINMUX_FUNCTIONS
+	default ARCH_BCM4908
+	help
+	  Say Y here to enable driver for BCM4908 family SoCs with integrated
+	  pin controller.
+
 config PINCTRL_BCM63XX
 	bool
 	select PINMUX
drivers/pinctrl/bcm/Makefile +1 -0
index 00c7b7775e63..82b868ec1471 100644
@@ -3,6 +3,7 @@
 
 obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_BCM4908)		+= pinctrl-bcm4908.o
 obj-$(CONFIG_PINCTRL_BCM63XX)		+= pinctrl-bcm63xx.o
 obj-$(CONFIG_PINCTRL_BCM6318)		+= pinctrl-bcm6318.o
 obj-$(CONFIG_PINCTRL_BCM6328)		+= pinctrl-bcm6328.o
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +561 -0

561 lines not on this page · raw message

Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH 2/2] pinctrl: bcm: add driver for BCM4908 pinmux

I love your patch! Perhaps something to improve:

Hi "Rafał,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linusw-pinctrl/devel]
[also build test WARNING on robh/for-next linus/master v5.16-rc5 next-20211215] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Rafa-Mi-ecki/dt-bindings-pinctrl-Add-binding-for-BCM4908-pinctrl/20211216-044855
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: riscv-allyesconfig (https://download.01.org/0day-ci/archive/20211216/202112161405.FBvHqiWr-lkp(a)intel.com/config)
compiler: riscv64-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/52ad0e1851a5d242cde2829eca853a7369807c42
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Rafa-Mi-ecki/dt-bindings-pinctrl-Add-binding-for-BCM4908-pinctrl/20211216-044855 git checkout 52ad0e1851a5d242cde2829eca853a7369807c42
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=riscv SHELL=/bin/bash drivers/pinctrl/bcm/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/pinctrl/bcm/pinctrl-bcm4908.c: In function 'bcm4908_pinctrl_probe':

>> drivers/pinctrl/bcm/pinctrl-bcm4908.c:542:53: warning: passing argument 3 of 'pinmux_generic_add_function' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     542 |                                             function->groups,
         |                                             ~~~~~~~~^~~~~~~~
   In file included from drivers/pinctrl/bcm/pinctrl-bcm4908.c:18:
   drivers/pinctrl/bcm/../pinmux.h:153:46: note: expected 'const char **' but argument is of type 'const char * const*'
     153 |                                 const char **groups,
         |                                 ~~~~~~~~~~~~~^~~~~~

vim +542 drivers/pinctrl/bcm/pinctrl-bcm4908.c

468
469 static int bcm4908_pinctrl_probe(struct platform_device *pdev)
470 {
471 struct device *dev = &pdev->dev;
472 struct bcm4908_pinctrl *bcm4908_pinctrl;
473 struct pinctrl_desc *pctldesc;
474 struct pinctrl_pin_desc *pins;
475 int i;
476
477 bcm4908_pinctrl = devm_kzalloc(dev, sizeof(*bcm4908_pinctrl), GFP_KERNEL);
478 if (!bcm4908_pinctrl)
479 return -ENOMEM;
480 pctldesc = &bcm4908_pinctrl->pctldesc;
481 platform_set_drvdata(pdev, bcm4908_pinctrl);
482
483 /* Set basic properties */
484
485 bcm4908_pinctrl->dev = dev;
486
487 bcm4908_pinctrl->base = devm_platform_ioremap_resource(pdev, 0);
488 if (IS_ERR(bcm4908_pinctrl->base)) {
489 dev_err(dev, "Failed to map pinctrl regs\n");
490 return PTR_ERR(bcm4908_pinctrl->base);
491 }
492
493 memcpy(pctldesc, &bcm4908_pinctrl_desc, sizeof(*pctldesc));
494
495 /* Set pinctrl properties */
496
497 pins = devm_kcalloc(dev, BCM4908_NUM_PINS,
498 sizeof(struct pinctrl_pin_desc), GFP_KERNEL);
499 if (!pins)
500 return -ENOMEM;
501 for (i = 0; i < BCM4908_NUM_PINS; i++) {
502 pins[i].number = i;
503 pins[i].name = devm_kasprintf(dev, GFP_KERNEL, "pin%d", i);
504 if (!pins[i].name)
505 return -ENOMEM;
506 }
507 pctldesc->pins = pins;
508 pctldesc->npins = BCM4908_NUM_PINS;
509
510 /* Register */
511
512 bcm4908_pinctrl->pctldev = devm_pinctrl_register(dev, pctldesc, bcm4908_pinctrl);
513 if (IS_ERR(bcm4908_pinctrl->pctldev)) {
514 dev_err(dev, "Failed to register pinctrl\n");
515 return PTR_ERR(bcm4908_pinctrl->pctldev);
516 }
517
518 /* Groups */
519
520 for (i = 0; i < ARRAY_SIZE(bcm4908_pinctrl_grps); i++) {
521 const struct bcm4908_pinctrl_grp *group = &bcm4908_pinctrl_grps[i];
522 int *pins;
523 int j;
524
525 pins = devm_kcalloc(dev, group->num_pins, sizeof(*pins), GFP_KERNEL);
526 if (!pins)
527 return -ENOMEM;
528 for (j = 0; j < group->num_pins; j++)
529 pins[j] = group->pins[j].number;
530
531 pinctrl_generic_add_group(bcm4908_pinctrl->pctldev, group->name,
532 pins, group->num_pins, (void *)group);
533 }
534
535 /* Functions */
536
537 for (i = 0; i < ARRAY_SIZE(bcm4908_pinctrl_functions); i++) {
538 const struct bcm4908_pinctrl_function *function = &bcm4908_pinctrl_functions[i];
539
540 pinmux_generic_add_function(bcm4908_pinctrl->pctldev,

   541						    function->name,
 > 542						    function->groups,
   543						    function->num_groups, NULL);

544 }
545
546 return 0;
547 }
548

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw

Re: [PATCH 2/2] pinctrl: bcm: add driver for BCM4908 pinmux

In reply to Rafał Miłecki
I love your patch! Perhaps something to improve:

Hi "Rafał,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linusw-pinctrl/devel]
[also build test WARNING on robh/for-next linus/master v5.16-rc5 next-20211215] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Rafa-Mi-ecki/dt-bindings-pinctrl-Add-binding-for-BCM4908-pinctrl/20211216-044855
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: alpha-randconfig-s031-20211216 (https://download.01.org/0day-ci/archive/20211216/202112162229.R65wpBRJ-lkp(a)intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/52ad0e1851a5d242cde2829eca853a7369807c42
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Rafa-Mi-ecki/dt-bindings-pinctrl-Add-binding-for-BCM4908-pinctrl/20211216-044855
git checkout 52ad0e1851a5d242cde2829eca853a7369807c42
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=alpha SHELL=/bin/bash drivers/perf/ drivers/pinctrl/bcm/

If you fix the issue, kindly add following tag as appropriate

sparse warnings: (new ones prefixed by >>)

>> drivers/pinctrl/bcm/pinctrl-bcm4908.c:542:53: sparse: sparse: incorrect type in argument 3 (different modifiers) @@     expected char const **groups @@     got char const *const *const groups @@

drivers/pinctrl/bcm/pinctrl-bcm4908.c:542:53: sparse: expected char const **groups
drivers/pinctrl/bcm/pinctrl-bcm4908.c:542:53: sparse: got char const *const *const groups

vim +542 drivers/pinctrl/bcm/pinctrl-bcm4908.c

468
469 static int bcm4908_pinctrl_probe(struct platform_device *pdev)
470 {
471 struct device *dev = &pdev->dev;
472 struct bcm4908_pinctrl *bcm4908_pinctrl;
473 struct pinctrl_desc *pctldesc;
474 struct pinctrl_pin_desc *pins;
475 int i;
476
477 bcm4908_pinctrl = devm_kzalloc(dev, sizeof(*bcm4908_pinctrl), GFP_KERNEL);
478 if (!bcm4908_pinctrl)
479 return -ENOMEM;
480 pctldesc = &bcm4908_pinctrl->pctldesc;
481 platform_set_drvdata(pdev, bcm4908_pinctrl);
482
483 /* Set basic properties */
484
485 bcm4908_pinctrl->dev = dev;
486
487 bcm4908_pinctrl->base = devm_platform_ioremap_resource(pdev, 0);
488 if (IS_ERR(bcm4908_pinctrl->base)) {
489 dev_err(dev, "Failed to map pinctrl regs\n");
490 return PTR_ERR(bcm4908_pinctrl->base);
491 }
492
493 memcpy(pctldesc, &bcm4908_pinctrl_desc, sizeof(*pctldesc));
494
495 /* Set pinctrl properties */
496
497 pins = devm_kcalloc(dev, BCM4908_NUM_PINS,
498 sizeof(struct pinctrl_pin_desc), GFP_KERNEL);
499 if (!pins)
500 return -ENOMEM;
501 for (i = 0; i < BCM4908_NUM_PINS; i++) {
502 pins[i].number = i;
503 pins[i].name = devm_kasprintf(dev, GFP_KERNEL, "pin%d", i);
504 if (!pins[i].name)
505 return -ENOMEM;
506 }
507 pctldesc->pins = pins;
508 pctldesc->npins = BCM4908_NUM_PINS;
509
510 /* Register */
511
512 bcm4908_pinctrl->pctldev = devm_pinctrl_register(dev, pctldesc, bcm4908_pinctrl);
513 if (IS_ERR(bcm4908_pinctrl->pctldev)) {
514 dev_err(dev, "Failed to register pinctrl\n");
515 return PTR_ERR(bcm4908_pinctrl->pctldev);
516 }
517
518 /* Groups */
519
520 for (i = 0; i < ARRAY_SIZE(bcm4908_pinctrl_grps); i++) {
521 const struct bcm4908_pinctrl_grp *group = &bcm4908_pinctrl_grps[i];
522 int *pins;
523 int j;
524
525 pins = devm_kcalloc(dev, group->num_pins, sizeof(*pins), GFP_KERNEL);
526 if (!pins)
527 return -ENOMEM;
528 for (j = 0; j < group->num_pins; j++)
529 pins[j] = group->pins[j].number;
530
531 pinctrl_generic_add_group(bcm4908_pinctrl->pctldev, group->name,
532 pins, group->num_pins, (void *)group);
533 }
534
535 /* Functions */
536
537 for (i = 0; i < ARRAY_SIZE(bcm4908_pinctrl_functions); i++) {
538 const struct bcm4908_pinctrl_function *function = &bcm4908_pinctrl_functions[i];
539
540 pinmux_generic_add_function(bcm4908_pinctrl->pctldev,

   541						    function->name,
 > 542						    function->groups,
   543						    function->num_groups, NULL);

544 }
545
546 return 0;
547 }
548

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#4 lore raw

Re: [PATCH 2/2] pinctrl: bcm: add driver for BCM4908 pinmux

In reply to Rafał Miłecki
Quoted 5 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

BCM4908 has its own pins layout so it needs a custom binding and a Linux driver.

...

drivers/pinctrl/bcm/Kconfig config PINCTRL_BCM2835 · line 33

Quoted 2 lines
drivers/pinctrl/bcm/Kconfig +2 -0
+config PINCTRL_BCM4908
+       bool "Broadcom BCM4908 pinmux driver"

Why not tristate?

Quoted 1 line

+ depends on OF && (ARCH_BCM4908 || COMPILE_TEST)

Is there really dependency to OF?

drivers/pinctrl/bcm/Kconfig config PINCTRL_BCM2835 · line 43

Quoted 9 lines
drivers/pinctrl/bcm/Kconfig +9 -0
+       select PINMUX
+       select PINCONF
+       select GENERIC_PINCONF
+       select GENERIC_PINCTRL_GROUPS
+       select GENERIC_PINMUX_FUNCTIONS
+       default ARCH_BCM4908
+       help
+         Say Y here to enable driver for BCM4908 family SoCs with integrated
+         pin controller.

With a module available it's good to mention its name here.

...

Quoted 3 lines

+/*
+ * Copyright (C) 2021 Rafał Miłecki <[email protected]>
+ */

One line?

...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 10

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +5 -0
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
 
+#include <linux/of.h>
+#include <linux/of_device.h>

No evidence of use of these headers.
But missed mod_devicetable.h.

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 13

Quoted 3 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +3 -0
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>

Can you move this group...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 15

Quoted 2 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +2 -0
+#include <linux/platform_device.h>
+#include <linux/slab.h>

...here?

Quoted 2 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +2 -0
+#include "../core.h"
+#include "../pinmux.h"

...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 27

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +6 -0
+#define TEST_PORT_BLOCK_EN_LSB                 0x00
+#define TEST_PORT_BLOCK_DATA_MSB               0x04
+#define TEST_PORT_BLOCK_DATA_LSB               0x08
+#define  TEST_PORT_LSB_PINMUX_DATA_SHIFT       12
+#define TEST_PORT_COMMAND                      0x0c
+#define  TEST_PORT_CMD_LOAD_MUX_REG            0x00000021

The prefix of all above doesn't match the module name.

...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 258

Quoted 5 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +5 -0
+struct bcm4908_pinctrl_grp {
+       const char *name;
+       const struct bcm4908_pinctrl_pin_setup *pins;
+       const unsigned int num_pins;
+};

Why not to (re)use struct group_desc?

...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 442

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +10 -0
+       for (i = 0; i < group->num_pins; i++) {
+               u32 lsb = 0;
+
+               lsb |= group->pins[i].number;
+               lsb |= group->pins[i].function << TEST_PORT_LSB_PINMUX_DATA_SHIFT;
+
+               writel(0x0, bcm4908_pinctrl->base + TEST_PORT_BLOCK_DATA_MSB);
+               writel(lsb, bcm4908_pinctrl->base + TEST_PORT_BLOCK_DATA_LSB);
+               writel(TEST_PORT_CMD_LOAD_MUX_REG, bcm4908_pinctrl->base + TEST_PORT_COMMAND);
+       }

No serialization for IO, is it okay?

...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 490

Quoted 4 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +4 -0
+       bcm4908_pinctrl->base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(bcm4908_pinctrl->base)) {
+               dev_err(dev, "Failed to map pinctrl regs\n");
+               return PTR_ERR(bcm4908_pinctrl->base);

Besides of dev_err_probe(), why you duplicate message that already printed by core?

Quoted 1 line

+ }

...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 496

Quoted 2 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +2 -0
+       /* Set pinctrl properties */
+

Here and everywhere else, please drop redundant blank line.

...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 498

Quoted 2 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +2 -0
+       pins = devm_kcalloc(dev, BCM4908_NUM_PINS,
+                           sizeof(struct pinctrl_pin_desc), GFP_KERNEL);

Please, use sizeof(*foo) form. Then put it on one line.

Quoted 2 lines
(quoted diff) +2 -0
+       if (!pins)
+               return -ENOMEM;

...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 506

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +6 -0
+       for (i = 0; i < BCM4908_NUM_PINS; i++) {
+               pins[i].number = i;
+               pins[i].name = devm_kasprintf(dev, GFP_KERNEL, "pin%d", i);
+               if (!pins[i].name)
+                       return -ENOMEM;
+       }

Can you use the kasprintf_strarray() to make the style unified, please?

...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 515

Quoted 4 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +4 -0
+       bcm4908_pinctrl->pctldev = devm_pinctrl_register(dev, pctldesc, bcm4908_pinctrl);
+       if (IS_ERR(bcm4908_pinctrl->pctldev)) {
+               dev_err(dev, "Failed to register pinctrl\n");
+               return PTR_ERR(bcm4908_pinctrl->pctldev);

return dev_err_probe(...);

Quoted 1 line

+ }

...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 556

Quoted 9 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +8 -0
+static struct platform_driver bcm4908_pinctrl_driver = {
+       .probe = bcm4908_pinctrl_probe,
+       .driver = {
+               .name = "bcm4908-pinctrl",
+               .of_match_table = bcm4908_pinctrl_of_match_table,
+       },
+};
 
+

No need.

Quoted 1 line

+module_platform_driver(bcm4908_pinctrl_driver);

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#5 lore raw

Re: [PATCH 2/2] pinctrl: bcm: add driver for BCM4908 pinmux

Quoted 5 lines · Andy Shevchenko
Quoted 3 lines

+/*
+ * Copyright (C) 2021 Rafał Miłecki <[email protected]>
+ */

One line?

I don't think there's a rule for that. Not in coding-style.rst as much as I'm aware of. checkpatch.pl also doesn't complain.

Quoted 10 lines

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 13

Quoted 3 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +3 -0
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>

Can you move this group...

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 15

Quoted 2 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +2 -0
+#include <linux/platform_device.h>
+#include <linux/slab.h>

...here?

Any reason for that? For most of the time I keep my includes sorted alphabetically. Now I checked coding-style.rst is actually seems to recomment "clang-format" for the same reason: sorting includes.

Quoted 8 lines

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 27

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +6 -0
+#define TEST_PORT_BLOCK_EN_LSB                 0x00
+#define TEST_PORT_BLOCK_DATA_MSB               0x04
+#define TEST_PORT_BLOCK_DATA_LSB               0x08
+#define  TEST_PORT_LSB_PINMUX_DATA_SHIFT       12
+#define TEST_PORT_COMMAND                      0x0c
+#define  TEST_PORT_CMD_LOAD_MUX_REG            0x00000021

The prefix of all above doesn't match the module name.

Those are register names as in Broadcom's documentation. I don't think those names can conflict with any included header defines but I can change it.

Quoted 7 lines

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 258

Quoted 5 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +5 -0
+struct bcm4908_pinctrl_grp {
+       const char *name;
+       const struct bcm4908_pinctrl_pin_setup *pins;
+       const unsigned int num_pins;
+};

Why not to (re)use struct group_desc?

It's because "struct group_desc" has @pins that I can't fill statically as I need struct instead of int.

I also need struct field for "const struct bcm4908_pinctrl_pin_setup" and "void *data" doesn't fit that purpsose 100% because:
1. It's a void
2. It's not static

Quoted 4 lines

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 496

Quoted 2 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +2 -0
+       /* Set pinctrl properties */
+

Here and everywhere else, please drop redundant blank line.

No clear kernel rule for that.

I use blank line to indicate / suggest that comment applies to more than just a single line that follows.

Quoted 8 lines
Quoted 7 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +7 -0
+static struct platform_driver bcm4908_pinctrl_driver = {
+       .probe = bcm4908_pinctrl_probe,
+       .driver = {
+               .name = "bcm4908-pinctrl",
+               .of_match_table = bcm4908_pinctrl_of_match_table,
+       },
+};
Quoted 5 lines
Quoted 1 line

+

No need.

Quoted 1 line

+module_platform_driver(bcm4908_pinctrl_driver);

You have 1344 other source files with empty line above module_platform_driver(). coding-style.rst says to "separate functions with one blank line". Are we supposed to argue now whether a macro can be considered a functio nor not?

grep -B 1 -r "module_platform_driver" drivers/* | egrep -c "\.c-$" 1344

#6 lore raw

Re: [PATCH 2/2] pinctrl: bcm: add driver for BCM4908 pinmux

Quoted 9 lines · Rafał Miłecki
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines

+/*
+ * Copyright (C) 2021 Rafał Miłecki <[email protected]>
+ */

One line?

I don't think there's a rule for that. Not in coding-style.rst as much as I'm aware of. checkpatch.pl also doesn't complain.

There is no rule, but common sense. Why occupy 3 LOCs instead of 1 LOC?

...

Quoted 6 lines
Quoted 6 lines

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 13

Quoted 3 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +3 -0
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>

Can you move this group...

Quoted 8 lines
Quoted 4 lines

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 15

Quoted 2 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +2 -0
+#include <linux/platform_device.h>
+#include <linux/slab.h>

...here?

Any reason for that? For most of the time I keep my includes sorted alphabetically. Now I checked coding-style.rst is actually seems to recomment "clang-format" for the same reason: sorting includes.

Yes. The reason is simple. With moving this group separately you follow the rule of going from most generic to most particular headers in the block. Grouping like this will show better that this code has tighten relations with the pin control subsystem.

...

Quoted 9 lines
Quoted 8 lines

drivers/pinctrl/bcm/pinctrl-bcm4908.c line 27

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm4908.c new file +6 -0
+#define TEST_PORT_BLOCK_EN_LSB                 0x00
+#define TEST_PORT_BLOCK_DATA_MSB               0x04
+#define TEST_PORT_BLOCK_DATA_LSB               0x08
+#define  TEST_PORT_LSB_PINMUX_DATA_SHIFT       12
+#define TEST_PORT_COMMAND                      0x0c
+#define  TEST_PORT_CMD_LOAD_MUX_REG            0x00000021

The prefix of all above doesn't match the module name.

Quoted 3 lines

Those are register names as in Broadcom's documentation. I don't think those names can conflict with any included header defines but I can change it.

They may easily conflict through headers with something more generic not related to your driver or even GPIO. The TEST_PORT_COMMAND seems one of this kind that might potentially collide.

...

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

+

Here and everywhere else, please drop redundant blank line.

No clear kernel rule for that.

I use blank line to indicate / suggest that comment applies to more than just a single line that follows.

Maybe these comments are not so useful after all?

...

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

+

No need.

Quoted 1 line

+module_platform_driver(bcm4908_pinctrl_driver);

Quoted 7 lines

You have 1344 other source files with empty line above module_platform_driver(). coding-style.rst says to "separate functions with one blank line". Are we supposed to argue now whether a macro can be considered a functio nor not?

grep -B 1 -r "module_platform_driver" drivers/* | egrep -c "\.c-$" 1344

Same as above, common sense and the tight relationship between two.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#7 lore raw
In reply to Rafał Miłecki
Quoted 11 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

It's hardware block that is part of every SoC from BCM4908 family.

---
 .../pinctrl/brcm,bcm4908-pinctrl.yaml         | 72 +++++++++++++++++++
 MAINTAINERS                                   |  7 ++
 2 files changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Unknown file referenced: [Errno 2] No such file or directory: '/usr/local/lib/python3.8/dist-packages/dtschema/schemas/pinctrl/pinctrl.yaml'
xargs: dt-doc-validate: exited with status 255; aborting
make[1]: *** Deleting file 'Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.example.dt.yaml'
Unknown file referenced: [Errno 2] No such file or directory: '/usr/local/lib/python3.8/dist-packages/dtschema/schemas/pinctrl/pinctrl.yaml' make[1]: *** [scripts/Makefile.lib:373: Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.example.dt.yaml] Error 255 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1413: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/1568760

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

#8 lore raw

Hi Rob,

Quoted 18 lines · Rob Herring
Quoted 11 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

It's hardware block that is part of every SoC from BCM4908 family.

---
  .../pinctrl/brcm,bcm4908-pinctrl.yaml         | 72 +++++++++++++++++++
  MAINTAINERS                                   |  7 ++
  2 files changed, 79 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

Quoted 8 lines

dtschema/dtc warnings/errors:
Unknown file referenced: [Errno 2] No such file or directory: '/usr/local/lib/python3.8/dist-packages/dtschema/schemas/pinctrl/pinctrl.yaml'
xargs: dt-doc-validate: exited with status 255; aborting
make[1]: *** Deleting file 'Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.example.dt.yaml'
Unknown file referenced: [Errno 2] No such file or directory: '/usr/local/lib/python3.8/dist-packages/dtschema/schemas/pinctrl/pinctrl.yaml' make[1]: *** [scripts/Makefile.lib:373: Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.example.dt.yaml] Error 255 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1413: dt_binding_check] Error 2

this patch targets Linus's git tree:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=for-next

Above tree contains 896568e5b9c8 ("dt-bindings: pinctrl: convert controller description to the json-schema") which provides pinctrl.yaml.

maintainer
#9 lore raw
Quoted 30 lines · Rafał Miłecki

Hi Rob,

Quoted 18 lines · Rob Herring
Quoted 11 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

It's hardware block that is part of every SoC from BCM4908 family.

---
  .../pinctrl/brcm,bcm4908-pinctrl.yaml         | 72 +++++++++++++++++++
  MAINTAINERS                                   |  7 ++
  2 files changed, 79 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

Quoted 8 lines

dtschema/dtc warnings/errors:
Unknown file referenced: [Errno 2] No such file or directory: '/usr/local/lib/python3.8/dist-packages/dtschema/schemas/pinctrl/pinctrl.yaml'
xargs: dt-doc-validate: exited with status 255; aborting
make[1]: *** Deleting file 'Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.example.dt.yaml'
Unknown file referenced: [Errno 2] No such file or directory: '/usr/local/lib/python3.8/dist-packages/dtschema/schemas/pinctrl/pinctrl.yaml' make[1]: *** [scripts/Makefile.lib:373: Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.example.dt.yaml] Error 255 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1413: dt_binding_check] Error 2

Quoted 5 lines

this patch targets Linus's git tree:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=for-next

Above tree contains 896568e5b9c8 ("dt-bindings: pinctrl: convert controller description to the json-schema") which provides pinctrl.yaml.

Please note that in the patch if you don't want to get this message. Otherwise, this is the alert that there's some dependency.

Rob

maintainer Reviewed-by on v1 1/2
#10 lore raw
In reply to Rafał Miłecki
Quoted 11 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

It's hardware block that is part of every SoC from BCM4908 family.

---
 .../pinctrl/brcm,bcm4908-pinctrl.yaml         | 72 +++++++++++++++++++
 MAINTAINERS                                   |  7 ++
 2 files changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm4908-pinctrl.yaml