Add Nuvoton NPCM SGPIO feature
Subsystems (3)
v8 cover Add Nuvoton NPCM SGPIO feature
This SGPIO controller is for NUVOTON NPCM7xx and NPCM8xx SoC. Nuvoton NPCM SGPIO module is combine serial to parallel IC (HC595) and parallel to serial IC (HC165), and use APB3 clock to control it. This interface has 4 pins (D_out , D_in, S_CLK, LDSH). NPCM7xx/NPCM8xx have two sgpio module each module can support up to 64 output pins,and up to 64 input pin, the pin is only for GPI or GPO. GPIO pins have sequential, First half is GPO and second half is GPI.
Jim Liu (3):
dt-bindings: gpio: add NPCM sgpio driver bindings
arm: dts: nuvoton: npcm: Add sgpio feature
gpio: nuvoton: Add Nuvoton NPCM sgpio driver
.../bindings/gpio/nuvoton,sgpio.yaml | 86 +++ .../dts/nuvoton/nuvoton-common-npcm7xx.dtsi | 24 + drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-npcm-sgpio.c | 637 ++++++++++++++++++ 5 files changed, 755 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml create mode 100644 drivers/gpio/gpio-npcm-sgpio.c
Signature · 1 line
2.25.1
PATCH v8 1/3 dt-bindings: gpio: add NPCM sgpio driver bindings
Add dt-bindings document for the Nuvoton NPCM7xx sgpio driver
---
Changes for v8:
- no changed
Changes for v7:
- no changed
Changes for v6:
- Drop quotes for $ref
- Add and drop '|' for description
- Add space after 'exposed.'
- remove status
--- .../bindings/gpio/nuvoton,sgpio.yaml | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml
Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml new file +86 -0
@@ -0,0 +1,86 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/nuvoton,sgpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton SGPIO controller + +maintainers: + - Jim LIU <[email protected]> + +description: | + This SGPIO controller is for NUVOTON NPCM7xx and NPCM8xx SoC. + Nuvoton NPCM7xx SGPIO module is combine serial to parallel IC (HC595) + and parallel to serial IC (HC165), and use APB3 clock to control it. + This interface has 4 pins (D_out , D_in, S_CLK, LDSH). + NPCM7xx/NPCM8xx have two sgpio module each module can support up + to 64 output pins,and up to 64 input pin, the pin is only for gpi or gpo. + GPIO pins have sequential, First half is gpo and second half is gpi. + GPIO pins can be programmed to support the following options + - Support interrupt option for each input port and various interrupt + sensitivity option (level-high, level-low, edge-high, edge-low) + - ngpios is number of nuvoton,input-ngpios GPIO lines and nuvoton,output-ngpios GPIO lines. + nuvoton,input-ngpios GPIO lines is only for gpi. + nuvoton,output-ngpios GPIO lines is only for gpo. + +properties: + compatible: + enum: + - nuvoton,npcm750-sgpio + - nuvoton,npcm845-sgpio + + reg: + maxItems: 1 + + gpio-controller: true + + '#gpio-cells': + const: 2 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + nuvoton,input-ngpios: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The numbers of GPIO's exposed. GPIO lines is only for gpi. + minimum: 0 + maximum: 64 + + nuvoton,output-ngpios: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The numbers of GPIO's exposed. GPIO lines is only for gpo. + minimum: 0 + maximum: 64 + +required: + - compatible + - reg + - gpio-controller + - '#gpio-cells' + - interrupts + - nuvoton,input-ngpios + - nuvoton,output-ngpios + - clocks + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/nuvoton,npcm7xx-clock.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + gpio8: gpio@101000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x101000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + };
Signature · 1 line
2.25.1
PATCH v8 2/3 arm: dts: nuvoton: npcm: Add sgpio feature
In reply to Jim LiuAdd the SGPIO controller to the NPCM7xx devicetree
---
Changes for v8:
- no changed
Changes for v7:
- no changed
Changes for v6:
- remove bus-frequency
- check with dtbs_check
--- .../dts/nuvoton/nuvoton-common-npcm7xx.dtsi | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi +24 -0
@@ -372,6 +372,30 @@ &fanin12_pins &fanin13_pins status = "disabled"; }; + gpio8: gpio@101000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x101000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + status = "disabled"; + }; + + gpio9: gpio@102000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x102000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + status = "disabled"; + }; + i2c0: i2c@80000 { reg = <0x80000 0x1000>; compatible = "nuvoton,npcm750-i2c";
Signature · 1 line
2.25.1
PATCH v8 3/3 gpio: nuvoton: Add Nuvoton NPCM sgpio driver
In reply to Jim LiuAdd Nuvoton BMC NPCM7xx/NPCM8xx sgpio driver support. Nuvoton NPCM SGPIO module is combine serial to parallel IC (HC595) and parallel to serial IC (HC165), and use APB3 clock to control it. This interface has 4 pins (D_out , D_in, S_CLK, LDSH).
BMC can use this driver to increase 64 GPI pins and 64 GPO pins to use.
---
Changes for v8:
- Remove OF_GPIO/GPIO_GENERIC and redundant assignments
- Use GENMASK() and BIT()
- Use dev_WARN and dev_err_probe
- Check indentation issue
- Use raw_spinlock_t
Changes for v7:
- Remove unused variable
- Remove return in bank_reg function
- Fix warning for const issue
--- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-npcm-sgpio.c | 637 +++++++++++++++++++++++++++++++++ 3 files changed, 645 insertions(+) create mode 100644 drivers/gpio/gpio-npcm-sgpio.c
drivers/gpio/Kconfig +7 -0
@@ -478,6 +478,13 @@ config GPIO_MXS select GPIO_GENERIC select GENERIC_IRQ_CHIP +config GPIO_NPCM_SGPIO + bool "Nuvoton SGPIO support" + depends on ARCH_NPCM || COMPILE_TEST + select GPIOLIB_IRQCHIP + help + Say Y here to support Nuvoton NPCM7XX/NPCM8XX SGPIO functionality. + config GPIO_OCTEON tristate "Cavium OCTEON GPIO" depends on CAVIUM_OCTEON_SOC
drivers/gpio/Makefile +1 -0
@@ -116,6 +116,7 @@ obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o +obj-$(CONFIG_GPIO_NPCM_SGPIO) += gpio-npcm-sgpio.o obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o
drivers/gpio/gpio-npcm-sgpio.c new file +637 -0
637 lines not on this page · raw message
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH v8 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver
kernel test robot noticed the following build warnings:
Hi Jim,
kernel test robot noticed the following build warnings:
[auto build test WARNING on brgl/gpio/for-next]
[also build test WARNING on robh/for-next linus/master v6.7-rc4 next-20231206] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jim-Liu/dt-bindings-gpio-add-NPCM-sgpio-driver-bindings/20231206-095724 base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next patch link: https://lore.kernel.org/r/20231206014530.1600151-4-jim.t90615%40gmail.com patch subject: [PATCH v8 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20231206/[email protected]/config) compiler: alpha-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from arch/alpha/include/asm/bug.h:23,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13, from include/asm-generic/current.h:6, from ./arch/alpha/include/generated/asm/current.h:1, from include/linux/mutex.h:14,
from include/linux/notifier.h:14,
from include/linux/clk.h:14,
from drivers/gpio/gpio-npcm-sgpio.c:9:
drivers/gpio/gpio-npcm-sgpio.c: In function 'bank_reg':
>> drivers/gpio/gpio-npcm-sgpio.c:150:26: warning: passing argument 1 of 'dev_driver_string' makes pointer from integer without a cast [-Wint-conversion]
150 | dev_WARN(true, "Getting here is an error condition");
| ^~~~
| |
| int
include/asm-generic/bug.h:99:62: note: in definition of macro '__WARN_printf'
99 | warn_slowpath_fmt(__FILE__, __LINE__, taint, arg); \
| ^~~
include/linux/dev_printk.h:271:9: note: in expansion of macro 'WARN'
271 | WARN(1, "%s %s: " format, dev_driver_string(dev), dev_name(dev), ## arg)
| ^~~~
drivers/gpio/gpio-npcm-sgpio.c:150:17: note: in expansion of macro 'dev_WARN'
150 | dev_WARN(true, "Getting here is an error condition");
| ^~~~~~~~
In file included from include/linux/platform_device.h:13,
from drivers/gpio/gpio-npcm-sgpio.c:16:
include/linux/device.h:1242:52: note: expected 'const struct device *' but argument is of type 'int'
1242 | const char *dev_driver_string(const struct device *dev);
| ~~~~~~~~~~~~~~~~~~~~~^~~
>> drivers/gpio/gpio-npcm-sgpio.c:150:26: warning: passing argument 1 of 'dev_name' makes pointer from integer without a cast [-Wint-conversion]
150 | dev_WARN(true, "Getting here is an error condition");
| ^~~~
| |
| int
include/asm-generic/bug.h:99:62: note: in definition of macro '__WARN_printf'
99 | warn_slowpath_fmt(__FILE__, __LINE__, taint, arg); \
| ^~~
include/linux/dev_printk.h:271:9: note: in expansion of macro 'WARN'
271 | WARN(1, "%s %s: " format, dev_driver_string(dev), dev_name(dev), ## arg)
| ^~~~
drivers/gpio/gpio-npcm-sgpio.c:150:17: note: in expansion of macro 'dev_WARN'
150 | dev_WARN(true, "Getting here is an error condition");
| ^~~~~~~~
include/linux/device.h:858:57: note: expected 'const struct device *' but argument is of type 'int'
858 | static inline const char *dev_name(const struct device *dev)
| ~~~~~~~~~~~~~~~~~~~~~^~~
drivers/gpio/gpio-npcm-sgpio.c: In function 'npcm_sgpio_dir_out':
>> drivers/gpio/gpio-npcm-sgpio.c:211:28: warning: unused variable 'gpio' [-Wunused-variable]
211 | struct npcm_sgpio *gpio = gpiochip_get_data(gc);
| ^~~~
drivers/gpio/gpio-npcm-sgpio.c: At top level:
>> drivers/gpio/gpio-npcm-sgpio.c:534:20: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
534 | .sft_clk = npcm750_SFT_CLK,
| ^~~~~~~~~~~~~~~
drivers/gpio/gpio-npcm-sgpio.c:535:20: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
535 | .clk_sel = npcm750_CLK_SEL,
| ^~~~~~~~~~~~~~~
drivers/gpio/gpio-npcm-sgpio.c:540:20: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
540 | .sft_clk = npcm845_SFT_CLK,
| ^~~~~~~~~~~~~~~
drivers/gpio/gpio-npcm-sgpio.c:541:20: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
541 | .clk_sel = npcm845_CLK_SEL,
| ^~~~~~~~~~~~~~~vim +/dev_driver_string +150 drivers/gpio/gpio-npcm-sgpio.c
134
135 static void __iomem *bank_reg(struct npcm_sgpio *gpio,
136 const struct npcm_sgpio_bank *bank,
137 const enum npcm_sgpio_reg reg)
138 {
139 switch (reg) {
140 case READ_DATA:
141 return gpio->base + bank->rdata_reg;
142 case WRITE_DATA:
143 return gpio->base + bank->wdata_reg;
144 case EVENT_CFG:
145 return gpio->base + bank->event_config;
146 case EVENT_STS:
147 return gpio->base + bank->event_status;
148 default:
149 /* actually if code runs to here, it's an error case */
> 150 dev_WARN(true, "Getting here is an error condition");
151 }
152 return 0;
153 }
154
155 static const struct npcm_sgpio_bank *offset_to_bank(unsigned int offset)
156 {
157 unsigned int bank = GPIO_BANK(offset);
158
159 return &npcm_sgpio_banks[bank];
160 }
161
162 static void irqd_to_npcm_sgpio_data(struct irq_data *d,
163 struct npcm_sgpio **gpio,
164 const struct npcm_sgpio_bank **bank,
165 u8 *bit, unsigned int *offset)
166 {
167 struct npcm_sgpio *internal;
168
169 *offset = irqd_to_hwirq(d);
170 internal = irq_data_get_irq_chip_data(d);
171
172 *gpio = internal;
173 *offset -= internal->nout_sgpio;
174 *bank = offset_to_bank(*offset);
175 *bit = GPIO_BIT(*offset);
176 }
177
178 static int npcm_sgpio_init_port(struct npcm_sgpio *gpio)
179 {
180 u8 in_port, out_port, set_port, reg;
181
182 in_port = GPIO_BANK(gpio->nin_sgpio);
183 if (GPIO_BIT(gpio->nin_sgpio) > 0)
184 in_port += 1;
185
186 out_port = GPIO_BANK(gpio->nout_sgpio);
187 if (GPIO_BIT(gpio->nout_sgpio) > 0)
188 out_port += 1;
189
190 gpio->in_port = in_port;
191 gpio->out_port = out_port;
192 set_port = ((out_port & NPCM_IOXCFG2_PORT) << 4) | (in_port & NPCM_IOXCFG2_PORT);
193 iowrite8(set_port, gpio->base + NPCM_IOXCFG2);
194
195 reg = ioread8(gpio->base + NPCM_IOXCFG2);
196
197 return reg == set_port ? 0 : -EINVAL;
198
199 }
200
201 static int npcm_sgpio_dir_in(struct gpio_chip *gc, unsigned int offset)
202 {
203 struct npcm_sgpio *gpio = gpiochip_get_data(gc);
204
205 return offset < gpio->nout_sgpio ? -EINVAL : 0;
206
207 }
208
209 static int npcm_sgpio_dir_out(struct gpio_chip *gc, unsigned int offset, int val)
210 {
> 211 struct npcm_sgpio *gpio = gpiochip_get_data(gc); 212
213 gc->set(gc, offset, val);
214
215 return 0;
216
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v8 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver
In reply to Jim LiuQuoted 8 lines · Jim Liu
Add Nuvoton BMC NPCM7xx/NPCM8xx sgpio driver support. Nuvoton NPCM SGPIO module is combine serial to parallel IC (HC595) and parallel to serial IC (HC165), and use APB3 clock to control it. This interface has 4 pins (
D_out,D_in,S_CLK, LDSH).
BMC can use this driver to increase 64 GPI pins and 64 GPO pins to use.Signed-off-by Jim Liu <[email protected]>---
...
drivers/gpio/gpio-npcm-sgpio.c line 150
Quoted 12 lines
drivers/gpio/gpio-npcm-sgpio.c new file +12
-0+switch (reg) { +case READ_DATA : +return gpio->base + bank->rdata_reg; +case WRITE_DATA : +return gpio->base + bank->wdata_reg; +case EVENT_CFG : +return gpio->base + bank->event_config; +case EVENT_STS : +return gpio->base + bank->event_status; +default : +/* actually if code runs to here, it's an error case */ +dev_WARN (true,"Getting here is an error condition" );
So you did not even compile your code. v8 and still not built :(
drivers/gpio/gpio-npcm-sgpio.c line 153
Quoted 3 lines
drivers/gpio/gpio-npcm-sgpio.c new file +3
-0+ } +return 0 ; +}
Best regards,
Krzysztof
kernel test robot
build botRe: [PATCH v8 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver
In reply to Jim Liukernel test robot noticed the following build warnings:
Hi Jim,
kernel test robot noticed the following build warnings:
[auto build test WARNING on brgl/gpio/for-next]
[also build test WARNING on robh/for-next linus/master v6.7-rc4 next-20231206] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jim-Liu/dt-bindings-gpio-add-NPCM-sgpio-driver-bindings/20231206-095724 base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next patch link: https://lore.kernel.org/r/20231206014530.1600151-4-jim.t90615%40gmail.com patch subject: [PATCH v8 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver config: nios2-randconfig-r131-20231207 (https://download.01.org/0day-ci/archive/20231207/[email protected]/config) compiler: nios2-linux-gcc (GCC) 13.2.0 reproduce: (https://download.01.org/0day-ci/archive/20231207/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct device const *dev @@ got int @@ drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: expected struct device const *dev drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: got int >> drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct device const *dev @@ got int @@ drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: expected struct device const *dev drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: got int >> drivers/gpio/gpio-npcm-sgpio.c:152:16: sparse: sparse: Using plain integer as NULL pointer >> drivers/gpio/gpio-npcm-sgpio.c:534:20: sparse: sparse: incorrect type in initializer (different modifiers) @@ expected unsigned int *sft_clk @@ got unsigned int const * @@ drivers/gpio/gpio-npcm-sgpio.c:534:20: sparse: expected unsigned int *sft_clk drivers/gpio/gpio-npcm-sgpio.c:534:20: sparse: got unsigned int const * >> drivers/gpio/gpio-npcm-sgpio.c:535:20: sparse: sparse: incorrect type in initializer (different modifiers) @@ expected unsigned int *clk_sel @@ got unsigned int const * @@
drivers/gpio/gpio-npcm-sgpio.c:535:20: sparse: expected unsigned int *clk_sel
drivers/gpio/gpio-npcm-sgpio.c:535:20: sparse: got unsigned int const *
drivers/gpio/gpio-npcm-sgpio.c:540:20: sparse: sparse: incorrect type in initializer (different modifiers) @@ expected unsigned int *sft_clk @@ got unsigned int const * @@
drivers/gpio/gpio-npcm-sgpio.c:540:20: sparse: expected unsigned int *sft_clk
drivers/gpio/gpio-npcm-sgpio.c:540:20: sparse: got unsigned int const *
drivers/gpio/gpio-npcm-sgpio.c:541:20: sparse: sparse: incorrect type in initializer (different modifiers) @@ expected unsigned int *clk_sel @@ got unsigned int const * @@
drivers/gpio/gpio-npcm-sgpio.c:541:20: sparse: expected unsigned int *clk_sel
drivers/gpio/gpio-npcm-sgpio.c:541:20: sparse: got unsigned int const *
vim +150 drivers/gpio/gpio-npcm-sgpio.c
134
135 static void __iomem *bank_reg(struct npcm_sgpio *gpio,
136 const struct npcm_sgpio_bank *bank,
137 const enum npcm_sgpio_reg reg)
138 {
139 switch (reg) {
140 case READ_DATA:
141 return gpio->base + bank->rdata_reg;
142 case WRITE_DATA:
143 return gpio->base + bank->wdata_reg;
144 case EVENT_CFG:
145 return gpio->base + bank->event_config;
146 case EVENT_STS:
147 return gpio->base + bank->event_status;
148 default:
149 /* actually if code runs to here, it's an error case */
> 150 dev_WARN(true, "Getting here is an error condition"); 151 } > 152 return 0;
153 }
154
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki