powerpc/sysdev: change CPM GPIO to platform_device
PATCH 1/1 powerpc/sysdev: change CPM GPIO to platform_device
Since commit 9427ecbed46cc ("gpio: Rework of_gpiochip_set_names() to use device property accessors"), gpio chips have to have a parent, otherwise devprop_gpiochip_set_names() prematurely exists with message "GPIO chip parent is NULL" and doesn't proceed 'gpio-line-names' DT property.
This patch wraps the CPM GPIO into a platform driver to allow assignment of the parent device.
Signed-off-by Christophe Leroy <[email protected]>
--- arch/powerpc/include/asm/cpm.h | 2 +- arch/powerpc/include/asm/cpm1.h | 2 + arch/powerpc/sysdev/Makefile | 3 +- arch/powerpc/sysdev/cpm1.c | 33 ++++------------- arch/powerpc/sysdev/cpm2.c | 11 ------ arch/powerpc/sysdev/cpm_common.c | 5 ++- arch/powerpc/sysdev/cpm_gpio.c | 80 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 97 insertions(+), 39 deletions(-) create mode 100644 arch/powerpc/sysdev/cpm_gpio.c
arch/powerpc/include/asm/cpm.h +1 -1
@@ -166,6 +166,6 @@ static inline int cpm_command(u32 command, u8 opcode) }#endif /* CONFIG_CPM */ -int cpm2_gpiochip_add32 (struct device_node *np); +int cpm2_gpiochip_add32 (struct device *dev);#endif
arch/powerpc/include/asm/cpm1.h +2 -0
@@ -605,5 +605,7 @@ enum cpm_clk { };int cpm1_clk_setup (enum cpm_clk_target target,int clock,int mode); +int cpm1_gpiochip_add16 (struct device *dev); +int cpm1_gpiochip_add32 (struct device *dev);#endif /* __CPM1__ */
arch/powerpc/sysdev/Makefile +2 -1
@@ -43,7 +43,8 @@ obj-$(CONFIG_OF_RTC) += of_rtc.o obj-$(CONFIG_CPM) += cpm_common.o obj-$(CONFIG_CPM1) += cpm1.o -obj-$(CONFIG_CPM2) += cpm2.o cpm2_pic.o +obj-$(CONFIG_CPM2) += cpm2.o cpm2_pic.o cpm_gpio.o +obj-$(CONFIG_8xx_GPIO) += cpm_gpio.o obj-$(CONFIG_QUICC_ENGINE) += cpm_common.o obj-$(CONFIG_PPC_DCR) += dcr.o obj-$(CONFIG_UCODE_PATCH) += micropatch.o
arch/powerpc/sysdev/cpm1.c +8 -25
@@ -635,8 +635,9 @@ static int cpm1_gpio16_dir_in(struct gpio_chip *gc, unsigned int gpio)return 0 ; } -int cpm1_gpiochip_add16 (struct device_node *np) +int cpm1_gpiochip_add16 (struct device *dev) { +struct device_node *np = dev->of_node;struct cpm1_gpio16_chip *cpm1_gc;struct of_mm_gpio_chip *mm_gc;struct gpio_chip *gc;
@@ -666,6 +667,8 @@ int cpm1_gpiochip_add16(struct device_node *np) gc->get = cpm1_gpio16_get; gc->set = cpm1_gpio16_set; gc->to_irq = cpm1_gpio16_to_irq; + gc->parent = dev; + gc->owner =THIS_MODULE ;return of_mm_gpiochip_add_data (np, mm_gc, cpm1_gc); }
@@ -761,8 +764,9 @@ static int cpm1_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio)return 0 ; } -int cpm1_gpiochip_add32 (struct device_node *np) +int cpm1_gpiochip_add32 (struct device *dev) { +struct device_node *np = dev->of_node;struct cpm1_gpio32_chip *cpm1_gc;struct of_mm_gpio_chip *mm_gc;struct gpio_chip *gc;
@@ -782,31 +786,10 @@ int cpm1_gpiochip_add32(struct device_node *np) gc->direction_output = cpm1_gpio32_dir_out; gc->get = cpm1_gpio32_get; gc->set = cpm1_gpio32_set; + gc->parent = dev; + gc->owner =THIS_MODULE ; return of_mm_gpiochip_add_data(np, mm_gc, cpm1_gc); } -static int cpm_init_par_io (void ) -{ -struct device_node *np; - -for_each_compatible_node (np,NULL ,"fsl,cpm1-pario-bank-a" ) -cpm1_gpiochip_add16 (np); - -for_each_compatible_node (np,NULL ,"fsl,cpm1-pario-bank-b" ) -cpm1_gpiochip_add32 (np); - -for_each_compatible_node (np,NULL ,"fsl,cpm1-pario-bank-c" ) -cpm1_gpiochip_add16 (np); - -for_each_compatible_node (np,NULL ,"fsl,cpm1-pario-bank-d" ) -cpm1_gpiochip_add16 (np); - -/* Port E uses CPM2 layout */ -for_each_compatible_node (np,NULL ,"fsl,cpm1-pario-bank-e" ) -cpm2_gpiochip_add32 (np); -return 0 ; -} -arch_initcall (cpm_init_par_io); -#endif /* CONFIG_8xx_GPIO */
arch/powerpc/sysdev/cpm2.c +0 -11
@@ -354,14 +354,3 @@ void cpm2_set_pin(int port, int pin, int flags)else clrbits32 (&iop[port].odr, pin); } - -static int cpm_init_par_io (void ) -{ -struct device_node *np; - -for_each_compatible_node (np,NULL ,"fsl,cpm2-pario-bank" ) -cpm2_gpiochip_add32 (np); -return 0 ; -} -arch_initcall (cpm_init_par_io); -
arch/powerpc/sysdev/cpm_common.c +4 -1
@@ -190,8 +190,9 @@ static int cpm2_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio)return 0 ; } -int cpm2_gpiochip_add32 (struct device_node *np) +int cpm2_gpiochip_add32 (struct device *dev) { +struct device_node *np = dev->of_node;struct cpm2_gpio32_chip *cpm2_gc;struct of_mm_gpio_chip *mm_gc;struct gpio_chip *gc;
@@ -211,6 +212,8 @@ int cpm2_gpiochip_add32(struct device_node *np) gc->direction_output = cpm2_gpio32_dir_out; gc->get = cpm2_gpio32_get; gc->set = cpm2_gpio32_set; + gc->parent = dev; + gc->owner =THIS_MODULE ;return of_mm_gpiochip_add_data (np, mm_gc, cpm2_gc); }
arch/powerpc/sysdev/cpm_gpio.c new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
2.13.3