Add Polarfire SoC GPIO support
Subsystems (3)
v5 cover Add Polarfire SoC GPIO support
From: Lewis Hanly <[email protected]>
Add a driver to support the Polarfire SoC gpio controller. Tested with latest 5.19 kernel.
MPFS gpio interrupts are connected to IOMUX configured by system register GPIO_INTERRUPT_FAB_CR(31:0). Interrupt connection for some GPIO's to the PLIC (Platform Level Interrupt Controller) can be shared (not directly connected) or direct if connection is available.
previously upstreamed dt-bindings: gpio: microchip,mpfs-gpio.yaml
Changes in v5
Added the const for the irqchip, removed in error from v2.
Changes in v4
Changed the interrupt handling from Hierarchical flow to chained interrupt flow. The reason for the change was with hierarchical flow we requried a interrupt number mapping array to work with our HW and this was not acceptable. On reviewing the architecture the chained interrupt flow works better for our hardware and configurations which are not fixed in Silicon. Added support to read the optional DT property ngpios.
Changes in v3:
Changed order in kconfig.
Removed blank lines in driver header/source file.
Removed BYTE_BOUNDARY variable and use macro to do *4. mpfs_gpio_assign_bit parameter uses macro instead of (i * BYTE_BOUNDARY). Add correct definitions for direction.
Change order of variables in mpfs_gpio_irq_set_type function. Return dev_err_probe instead of dev_err.
Remove noise of dev_inf.
Avoid using of_match_ptr.
use devm_gpiochip_add_data(..)
Update mpfs_gpio_remove.
Changes in v2:
Use raw_spinlock.
Use __assign_bit() to assign bit, added a bool variable for value. Remove unnecessary checking gpio_index.
Remove default from switch statement.
Use const for irq_chip, name updated and use mask/unmask. Use latest kernel api irq set_chip.
Implemented hierarchical interrupt chip support, although suggested to use chained interrupt flow I believe this fits better.
Lewis Hanly (1):
gpio: mpfs: add polarfire soc gpio support
drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-mpfs.c | 318 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 326 insertions(+) create mode 100644 drivers/gpio/gpio-mpfs.c
Signature · 1 line
2.25.1
PATCH v5 1/1 gpio: mpfs: add polarfire soc gpio support
From: Lewis Hanly <[email protected]>
Add a driver to support the Polarfire SoC gpio controller
--- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-mpfs.c | 318 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 326 insertions(+) create mode 100644 drivers/gpio/gpio-mpfs.c
drivers/gpio/Kconfig +7 -0
@@ -490,6 +490,13 @@ config GPIO_PMIC_EIC_SPRD help Say yes here to support Spreadtrum PMIC EIC device. +config GPIO_POLARFIRE_SOC + bool "Microchip FPGA GPIO support" + depends on OF_GPIO + select GPIOLIB_IRQCHIP + help + Say yes here to support the GPIO device on Microchip FPGAs. + config GPIO_PXA bool "PXA GPIO support" depends on ARCH_PXA || ARCH_MMP || COMPILE_TEST
drivers/gpio/Makefile +1 -0
@@ -119,6 +119,7 @@ obj-$(CONFIG_GPIO_PCI_IDIO_16) += gpio-pci-idio-16.o obj-$(CONFIG_GPIO_PISOSR) += gpio-pisosr.o obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o obj-$(CONFIG_GPIO_PMIC_EIC_SPRD) += gpio-pmic-eic-sprd.o +obj-$(CONFIG_GPIO_POLARFIRE_SOC) += gpio-mpfs.o obj-$(CONFIG_GPIO_PXA) += gpio-pxa.o obj-$(CONFIG_GPIO_RASPBERRYPI_EXP) += gpio-raspberrypi-exp.o obj-$(CONFIG_GPIO_RC5T583) += gpio-rc5t583.o
drivers/gpio/gpio-mpfs.c new file +318 -0
318 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v5 1/1] gpio: mpfs: add polarfire soc gpio support
Le 15/08/2022 à 09:06, [email protected] a écrit :
Quoted 19 lines
From: Lewis Hanly <[email protected]>
Add a driver to support the Polarfire SoC gpio controller
Signed-off-by Lewis Hanly <[email protected]>--- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-mpfs.c | 318 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 326 insertions(+)create mode 100644
drivers/gpio/gpio-mpfs.cdrivers/gpio/gpio-mpfs.c new file +6
-0+static int mpfs_gpio_probe (struct platform_device *pdev) +{ +struct clk *clk; +struct device *dev = &pdev->dev; +struct device_node *node = pdev->dev.of_node; +struct mpfs_gpio_chip *mpfs_gpio;
drivers/gpio/gpio-mpfs.c line 232
Quoted 10 lines
drivers/gpio/gpio-mpfs.c new file +10
-0+struct gpio_irq_chip *girq; +int i, ret, ngpios, nirqs; + + mpfs_gpio =devm_kzalloc (dev,sizeof (*mpfs_gpio),GFP_KERNEL ); +if (!mpfs_gpio) +return -ENOMEM ; + + mpfs_gpio->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (mpfs_gpio->base)) +return dev_err_probe (dev,PTR_ERR (mpfs_gpio->clk),"input clock not found.\n" );
PTR_ERR(mpfs_gpio->base)?
"input clock not found" also looks odd after a devm_platform_ioremap_resource() call.
Quoted 5 lines
drivers/gpio/gpio-mpfs.c new file +5
-0+ + clk =devm_clk_get (dev,NULL ); +if (IS_ERR (clk)) +return dev_err_probe (dev,PTR_ERR (clk),"devm_clk_get failed\n" ); +
Re: [PATCH v5 1/1] gpio: mpfs: add polarfire soc gpio support
Quoted 31 lines · Christophe JAILLET
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 27 lines · Le 15/08/2022 à 09:06, [email protected] a écrit :
From: Lewis Hanly <[email protected]>
Add a driver to support the Polarfire SoC gpio controller
Signed-off-by Lewis Hanly <[email protected]>--- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-mpfs.c | 318 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 326 insertions(+)create mode 100644
drivers/gpio/gpio-mpfs.cdrivers/gpio/gpio-mpfs.c new file +10
-0+static int mpfs_gpio_probe (struct platform_device *pdev) +{ +struct clk *clk; +struct device *dev = &pdev->dev; +struct device_node *node = pdev->dev.of_node; +struct mpfs_gpio_chip *mpfs_gpio; +struct gpio_irq_chip *girq; +int i, ret, ngpios, nirqs; + + mpfs_gpio = devm_kzalloc(dev, sizeof(*mpfs_gpio),
GFP_KERNEL);drivers/gpio/gpio-mpfs.c new file +3
-0+if (!mpfs_gpio) +return -ENOMEM ; +
Quoted 8 lines
Quoted 4 lines
drivers/gpio/gpio-mpfs.c new file +3
-0+ mpfs_gpio->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (mpfs_gpio->base)) + return dev_err_probe(dev, PTR_ERR(mpfs_gpio->clk),"input clock not found.\n");
PTR_ERR(mpfs_gpio->base)?
"input clock not found" also looks odd after adevm_platform_ioremap_resource()call.
Yes, thank you, have fixed in a v6 which is on way.
Quoted 7 lines
Quoted 7 lines
drivers/gpio/gpio-mpfs.c new file +4
-0+ + clk =devm_clk_get (dev,NULL ); +if (IS_ERR (clk)) + return dev_err_probe(dev, PTR_ERR(clk), "devm_clk_getfailed\n");
+
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
kernel test robot
build botRe: [PATCH v5 1/1] gpio: mpfs: add polarfire soc gpio support
In reply to [email protected]Thank you for the patch! Perhaps something to improve:
Hi,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on brgl/gpio/for-next]
[also build test WARNING on linus/master v6.0-rc1 next-20220815] [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/lewis-hanly-microchip-com/Add-Polarfire-SoC-GPIO-support/20220815-150808 base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20220815/[email protected]/config) compiler: m68k-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/0458963d9f39d68b20ed88e71d20ca69d835e7fe
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review lewis-hanly-microchip-com/Add-Polarfire-SoC-GPIO-support/20220815-150808 git checkout 0458963d9f39d68b20ed88e71d20ca69d835e7fe
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/gpio/
If you fix the issue, kindly add following tag where applicable
All warnings (new ones prefixed by >>):
drivers/gpio/gpio-mpfs.c: In function 'mpfs_gpio_irq_handler':
drivers/gpio/gpio-mpfs.c:203:9: error: 'unisgned' undeclared (first use in this function)
203 | unisgned long status;
| ^~~~~~~~
drivers/gpio/gpio-mpfs.c:203:9: note: each undeclared identifier is reported only once for each function it appears in
drivers/gpio/gpio-mpfs.c:203:17: error: expected ';' before 'long'
203 | unisgned long status;
| ^~~~~
| ;
>> drivers/gpio/gpio-mpfs.c:204:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
204 | int offset;
| ^~~
drivers/gpio/gpio-mpfs.c:208:9: error: 'status' undeclared (first use in this function); did you mean 'kstatfs'?
208 | status = readl(mpfs_gpio->base + MPFS_IRQ_REG);
| ^~~~~~
| kstatfs
drivers/gpio/gpio-mpfs.c: In function 'mpfs_gpio_probe':
drivers/gpio/gpio-mpfs.c:268:19: error: 'struct irq_chip' has no member named 'parent_device'
268 | girq->chip->parent_device = dev;
| ^~vim +204 drivers/gpio/gpio-mpfs.c
197
198 static void mpfs_gpio_irq_handler(struct irq_desc *desc)
199 {
200 struct irq_chip *irqchip = irq_desc_get_chip(desc);
201 struct mpfs_gpio_chip *mpfs_gpio =
202 gpiochip_get_data(irq_desc_get_handler_data(desc));
> 203 unisgned long status; > 204 int offset;
205
206 chained_irq_enter(irqchip, desc);
207
208 status = readl(mpfs_gpio->base + MPFS_IRQ_REG);
209 for_each_set_bit(offset, &status, mpfs_gpio->gc.ngpio) {
210 mpfs_gpio_assign_bit(mpfs_gpio->base + MPFS_IRQ_REG, offset, 1);
211 generic_handle_irq(irq_find_mapping(mpfs_gpio->gc.irq.domain, offset));
212 }
213
214 chained_irq_exit(irqchip, desc);
215 }
216
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp