MIPS: TXX9: Legacy GPIO interfaces cleanup
v2 cover MIPS: TXX9: Legacy GPIO interfaces cleanup
Hi all,
This patch series gets rid of legacy GPIO interface usage on the MIPS RBTX4927 development board, preceded and followed by some cleanups. No blinky LEDs were harmed during the production of this series.
Changes compared to v1[1]:
- Add Reviewed-by,
- Return early on platform_device_add() failure.
Thanks for your comments!
[1] "[PATCH 0/9] MIPS: TXX9: Legacy GPIO interfaces cleanup"
https://lore.kernel.org/[email protected]
Geert Uytterhoeven (9):
MIPS: TXX9: Remove tx4938_spi_init() and txx9_spi_init()
MIPS: TXX9: Remove txx9_7segled_*() forward declarations
MIPS: TXX9: rbtx4927: Use GPIO lookup table for SIO DTR
MIPS: TXX9: rbtx4927: Use GPIO lookup table for TXx9 LEDs
MIPS: TXX9: Reduce TXX9_IOCLED_MAXLEDS to 3
MIPS: TXX9: Use GPIO lookup table for iocled LEDs
MIPS: TXX9: Drop GPIOLIB_LEGACY select
MIPS: TXX9: Convert gpio_txx9 to dynamic GPIO base allocation
MIPS: TXX9: Clean up txx9_iocled_init()
arch/mips/include/asm/txx9/generic.h | 9 +----- arch/mips/include/asm/txx9/tx4938.h | 1 - arch/mips/include/asm/txx9pio.h | 3 +- arch/mips/kernel/gpio_txx9.c | 5 ++- arch/mips/txx9/Kconfig | 1 - arch/mips/txx9/generic/setup.c | 45 ++++++++++----------------- arch/mips/txx9/generic/setup_tx4938.c | 6 ---- arch/mips/txx9/rbtx4927/setup.c | 41 ++++++++++++++++++------ 8 files changed, 53 insertions(+), 58 deletions(-)
Signature · 12 lines
2.43.0
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsPATCH v2 1/9 MIPS: TXX9: Remove tx4938_spi_init() and txx9_spi_init()
The last user of tx4938_spi_init() was removed in commit 21d638ef9483d8cf ("MIPS: TXX9: Remove rbtx4938 board support").
---
v2:
- Add Reviewed-by.
--- arch/mips/include/asm/txx9/generic.h | 1 - arch/mips/include/asm/txx9/tx4938.h | 1 - arch/mips/txx9/generic/setup.c | 17 ----------------- arch/mips/txx9/generic/setup_tx4938.c | 6 ------ 4 files changed, 25 deletions(-)
arch/mips/include/asm/txx9/generic.h +0 -1
@@ -45,7 +45,6 @@ extern int (*txx9_irq_dispatch)(int pending);const char *prom_getenv (const char *name);void txx9_wdt_init (unsigned long base);void txx9_wdt_now (unsigned long base); -void txx9_spi_init (int busid,unsigned long base,int irq);void txx9_ethaddr_init (unsigned int id,unsigned char *ethaddr);void txx9_sio_init (unsigned long baseaddr,int irq,unsigned int line,unsigned int sclk,int nocts);
arch/mips/include/asm/txx9/tx4938.h +0 -1
@@ -281,7 +281,6 @@ void tx4938_wdt_init(void);void tx4938_setup (void );void tx4938_time_init (unsigned int tmrnr);void tx4938_sio_init (unsigned int sclk,unsigned int cts_mask); -void tx4938_spi_init (int busid);void tx4938_ethaddr_init (unsigned char *addr0,unsigned char *addr1);int tx4938_report_pciclk (void );void tx4938_report_pci1clk (void );
arch/mips/txx9/generic/setup.c +0 -17
@@ -341,23 +341,6 @@ void txx9_wdt_now(unsigned long base) &tmrptr->tcr); } -/* SPI support */ -void __init txx9_spi_init (int busid,unsigned long base,int irq) -{ -struct resource res[] = { - { - .start = base, - .end = base +0x20 -1 , - .flags =IORESOURCE_MEM , - }, { - .start = irq, - .flags =IORESOURCE_IRQ , - }, - }; -platform_device_register_simple ("spi_txx9" , busid, - res,ARRAY_SIZE (res)); -} -void __init txx9_ethaddr_init (unsigned int id,unsigned char *ethaddr) { struct platform_device *pdev =
arch/mips/txx9/generic/setup_tx4938.c +0 -6
@@ -301,12 +301,6 @@ void __init tx4938_sio_init(unsigned int sclk, unsigned int cts_mask) } } -void __init tx4938_spi_init (int busid) -{ -txx9_spi_init (busid,TX4938_SPI_REG &0xfffffffffULL , -TXX9_IRQ_BASE +TX4938_IR_SPI ); -} -void __init tx4938_ethaddr_init (unsigned char *addr0,unsigned char *addr1) {u64 pcfg =__raw_readq (&tx4938_ccfgptr->pcfg);
Signature · 1 line
2.43.0
PATCH v2 2/9 MIPS: TXX9: Remove txx9_7segled_*() forward declarations
In reply to Geert UytterhoevenThe actual implementation was removed in commit 5a8df9281b052ff3 ("MIPS:
TXX9: Remove rbtx4939 board support").
---
v2:
- Add Reviewed-by.
--- arch/mips/include/asm/txx9/generic.h | 5 ----- 1 file changed, 5 deletions(-)
arch/mips/include/asm/txx9/generic.h +0 -5
@@ -83,11 +83,6 @@ void txx9_iocled_init(unsigned long baseaddr, int basenum, unsigned int num, int lowactive, const char *color, char **deftriggers); -/* 7SEG LED */ -void txx9_7segled_init (unsigned int num, -void (*putc)(unsigned int pos,unsigned char val)); -int txx9_7segled_putc (unsigned int pos,char c); - void __init txx9_aclc_init(unsigned long baseaddr, int irq, unsigned int dmac_id, unsigned int dma_chan_out,
Signature · 1 line
2.43.0
PATCH v2 3/9 MIPS: TXX9: rbtx4927: Use GPIO lookup table for SIO DTR
In reply to Geert UytterhoevenConvert SIO DTR handling from legacy GPIO calls to GPIO descriptors using a GPIO lookup table.
---
v2:
- Add Reviewed-by.
--- arch/mips/txx9/rbtx4927/setup.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
arch/mips/txx9/rbtx4927/setup.c +13 -3
@@ -49,6 +49,7 @@#include <linux/platform_device.h> #include <linux/delay.h> #include <linux/gpio.h> +#include <linux/gpio/machine.h> #include <linux/leds.h> #include <asm/io.h> #include <asm/reboot.h>
@@ -157,11 +158,20 @@ static inline void tx4927_pci_setup(void) {}static inline void tx4937_pci_setup (void ) {}#endif /* CONFIG_PCI */ +/* TX4927-SIO DTR on (PIO[15]) */ +GPIO_LOOKUP_SINGLE (sio_gpio_table,NULL ,"TXx9" ,15 ,"sio-dtr" , +GPIO_ACTIVE_HIGH ); +static void __init rbtx4927_gpio_init (void ) { -/* TX4927-SIO DTR on (PIO[15]) */ -gpio_request (15 ,"sio-dtr" ); -gpio_direction_output (15 ,1 ); +struct gpio_desc *d; + +gpiod_add_lookup_table (&sio_gpio_table); + d =gpiod_get (NULL ,"sio-dtr" ,GPIOD_OUT_HIGH ); +if (IS_ERR (d)) +pr_err ("Unable to get sio-dtr GPIO descriptor\n" ); +else +gpiod_put (d);tx4927_sio_init (0 ,0 ); }
Signature · 1 line
2.43.0
PATCH v2 4/9 MIPS: TXX9: rbtx4927: Use GPIO lookup table for TXx9 LEDs
In reply to Geert UytterhoevenConvert TXx9 LED description from legacy GPIO numbers to GPIO descriptors using a GPIO lookup table.
---
v2:
- Add Reviewed-by,
- Return early on platform_device_add() failure.
--- arch/mips/txx9/rbtx4927/setup.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
arch/mips/txx9/rbtx4927/setup.c +16 -3
@@ -327,11 +327,19 @@ static void __init rbtx4927_mtd_init(void)tx4927_mtd_init (i); } +static struct gpiod_lookup_table rbtx4927_gpioled_table = { + .table = { +GPIO_LOOKUP_IDX ("TXx9" ,0 ,NULL ,0 ,GPIO_ACTIVE_LOW ), +GPIO_LOOKUP_IDX ("TXx9" ,1 ,NULL ,1 ,GPIO_ACTIVE_LOW ), + { }, + }, +}; +static void __init rbtx4927_gpioled_init (void ) {static const struct gpio_led leds[] = { - { .name ="gpioled:green:0" , .gpio =0 , .active_low =1 , }, - { .name ="gpioled:green:1" , .gpio =1 , .active_low =1 , }, + { .name ="gpioled:green:0" , }, + { .name ="gpioled:green:1" , }, };static struct gpio_led_platform_data pdata = { .num_leds =ARRAY_SIZE (leds),
@@ -342,8 +350,13 @@ static void __init rbtx4927_gpioled_init(void)if (!pdev)return ; pdev->dev.platform_data = &pdata; -if (platform_device_add (pdev)) +if (platform_device_add (pdev)) {platform_device_put (pdev); +return ; + } + + rbtx4927_gpioled_table.dev_id =dev_name (&pdev->dev); +gpiod_add_lookup_table (&rbtx4927_gpioled_table); }static void __init rbtx4927_device_init (void )
Signature · 1 line
2.43.0
Re: [PATCH v2 4/9] MIPS: TXX9: rbtx4927: Use GPIO lookup table for TXx9 LEDs
Quoted 6 lines · Geert Uytterhoeven
Convert TXx9 LED description from legacy GPIO numbers to GPIO descriptors using a GPIO lookup table.
Signed-off-by Geert Uytterhoeven <[email protected]>Reviewed-by Bartosz Golaszewski <[email protected]>Reviewed-by Linus Walleij <[email protected]>
Quoted 7 lines
---
v2:
- Add Reviewed-by,
- Return early onplatform_device_add()failure.--- arch/mips/txx9/rbtx4927/setup.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
PATCH v2 5/9 MIPS: TXX9: Reduce TXX9_IOCLED_MAXLEDS to 3
In reply to Geert UytterhoevenThe number of available GPIOs and LEDs on the TXx9 IOC FPGA depends on the platform. Since commit 455481fc9a807798 ("MIPS: Remove TX39XX support"), the only remaining platform (rbtx4927) supports just three. Hence reduce the maximum number, to reduce allocation size.
---
v2:
- Add Reviewed-by.
--- arch/mips/txx9/generic/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/txx9/generic/setup.c +1 -1
@@ -569,7 +569,7 @@ void __init txx9_ndfmc_init(unsigned long baseaddr, #if IS_ENABLED(CONFIG_LEDS_GPIO) static DEFINE_SPINLOCK(txx9_iocled_lock); -#define TXX9_IOCLED_MAXLEDS 8 +#define TXX9_IOCLED_MAXLEDS 3 /* rbtx4927 */ struct txx9_iocled_data { struct gpio_chip chip;
Signature · 1 line
2.43.0
PATCH v2 6/9 MIPS: TXX9: Use GPIO lookup table for iocled LEDs
In reply to Geert UytterhoevenConvert iocled LED description from legacy GPIO numbers to GPIO descriptors using a GPIO lookup table.
For now, just ignore the "lowactive" parameter, and force GPIO_ACTIVE_LOW, as that is what the sole caller wants.
---
v2:
- Add Reviewed-by.
--- arch/mips/txx9/generic/setup.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/mips/txx9/generic/setup.c +12 -2
@@ -19,6 +19,7 @@#include <linux/clkdev.h> #include <linux/err.h> #include <linux/gpio/driver.h> +#include <linux/gpio/machine.h> #include <linux/platform_device.h> #include <linux/platform_data/txx9/ndfmc.h> #include <linux/serial_core.h>
@@ -615,6 +616,15 @@ static int txx9_iocled_dir_out(struct gpio_chip *chip, unsigned int offset,return 0 ; } +static struct gpiod_lookup_table txx9_iocled_table = { + .table = { +GPIO_LOOKUP_IDX ("iocled" ,0 ,NULL ,0 ,GPIO_ACTIVE_LOW ), +GPIO_LOOKUP_IDX ("iocled" ,1 ,NULL ,1 ,GPIO_ACTIVE_LOW ), +GPIO_LOOKUP_IDX ("iocled" ,2 ,NULL ,2 ,GPIO_ACTIVE_LOW ), + { }, + }, +}; +void __init txx9_iocled_init (unsigned long baseaddr,int basenum,unsigned int num,int lowactive,const char *color,char **deftriggers)
@@ -659,14 +669,14 @@ void __init txx9_iocled_init(unsigned long baseaddr,snprintf (iocled->names[i],sizeof (iocled->names[i]),"iocled:%s:%u" , color, i); led->name = iocled->names[i]; - led->gpio = basenum + i; - led->active_low = lowactive;if (deftriggers && *deftriggers) led->default_trigger = *deftriggers++; } pdev->dev.platform_data = &iocled->pdata;if (platform_device_add (pdev)) goto out_pdev; + txx9_iocled_table.dev_id =dev_name (&pdev->dev); +gpiod_add_lookup_table (&txx9_iocled_table);return ; out_pdev:
Signature · 1 line
2.43.0
Re: [PATCH v2 6/9] MIPS: TXX9: Use GPIO lookup table for iocled LEDs
Quoted 9 lines · Geert Uytterhoeven
Convert iocled LED description from legacy GPIO numbers to GPIO descriptors using a GPIO lookup table.
For now, just ignore the "lowactive" parameter, and force
GPIO_ACTIVE_LOW, as that is what the sole caller wants.Signed-off-by Geert Uytterhoeven <[email protected]>Reviewed-by Bartosz Golaszewski <[email protected]>Reviewed-by Linus Walleij <[email protected]>
Quoted 6 lines
---
v2:
- Add Reviewed-by.--- arch/mips/txx9/generic/setup.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
PATCH v2 7/9 MIPS: TXX9: Drop GPIOLIB_LEGACY select
In reply to Geert UytterhoevenTXx has been converted away from the old-style gpiolib interfaces.
---
v2:
- Add Reviewed-by.
--- arch/mips/txx9/Kconfig | 1 - 1 file changed, 1 deletion(-)
arch/mips/txx9/Kconfig +0 -1
@@ -37,7 +37,6 @@ config SOC_TX4927 select IRQ_TXX9 select PCI_TX4927 select GPIO_TXX9 - select GPIOLIB_LEGACY config SOC_TX4938 bool
Signature · 1 line
2.43.0
PATCH v2 8/9 MIPS: TXX9: Convert gpio_txx9 to dynamic GPIO base allocation
In reply to Geert UytterhoevenStatic allocation of GPIO base is deprecated, use dynamic allocation.
---
v2:
- Add Reviewed-by.
--- arch/mips/include/asm/txx9pio.h | 3 +-- arch/mips/kernel/gpio_txx9.c | 5 ++--- arch/mips/txx9/rbtx4927/setup.c | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-)
arch/mips/include/asm/txx9pio.h +1 -2
@@ -23,7 +23,6 @@ struct txx9_pio_reg { __u32 maskext; }; -int txx9_gpio_init (unsigned long baseaddr, -unsigned int base,unsigned int num); +int txx9_gpio_init (unsigned long baseaddr,unsigned int num);#endif /* __ASM_TXX9PIO_H */
arch/mips/kernel/gpio_txx9.c +2 -3
@@ -76,13 +76,12 @@ static struct gpio_chip txx9_gpio_chip = { .label = "TXx9", }; -int __init txx9_gpio_init (unsigned long baseaddr, -unsigned int base,unsigned int num) +int __init txx9_gpio_init (unsigned long baseaddr,unsigned int num) { txx9_pioptr =ioremap (baseaddr,sizeof (struct txx9_pio_reg ));if (!txx9_pioptr)return -ENODEV ; - txx9_gpio_chip.base = base; + txx9_gpio_chip.base =-1 ; txx9_gpio_chip.ngpio = num;return gpiochip_add_data (&txx9_gpio_chip,NULL ); }
arch/mips/txx9/rbtx4927/setup.c +2 -2
@@ -178,7 +178,7 @@ static void __init rbtx4927_gpio_init(void)static void __init rbtx4927_arch_init (void ) { -txx9_gpio_init (TX4927_PIO_REG &0xfffffffffULL ,0 ,TX4927_NUM_PIO ); +txx9_gpio_init (TX4927_PIO_REG &0xfffffffffULL ,TX4927_NUM_PIO );rbtx4927_gpio_init ();
@@ -187,7 +187,7 @@ static void __init rbtx4927_arch_init(void)static void __init rbtx4937_arch_init (void ) { -txx9_gpio_init (TX4938_PIO_REG &0xfffffffffULL ,0 ,TX4938_NUM_PIO ); +txx9_gpio_init (TX4938_PIO_REG &0xfffffffffULL ,TX4938_NUM_PIO );rbtx4927_gpio_init ();
Signature · 1 line
2.43.0
PATCH v2 9/9 MIPS: TXX9: Clean up txx9_iocled_init()
In reply to Geert UytterhoevenThe sole caller already uses dynamic GPIO base allocation, so drop support for static allocation.
While at it, drop the no longer used "lowactive" parameter.
---
v2:
- Add Reviewed-by.
--- arch/mips/include/asm/txx9/generic.h | 3 +-- arch/mips/txx9/generic/setup.c | 12 ++++-------- arch/mips/txx9/rbtx4927/setup.c | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-)
arch/mips/include/asm/txx9/generic.h +1 -2
@@ -79,8 +79,7 @@ static inline unsigned int __fls8(unsigned char x)return r; } -void txx9_iocled_init (unsigned long baseaddr, -int basenum,unsigned int num,int lowactive, +void txx9_iocled_init (unsigned long baseaddr,unsigned int num,const char *color,char **deftriggers); void __init txx9_aclc_init(unsigned long baseaddr, int irq,
arch/mips/txx9/generic/setup.c +4 -8
@@ -625,8 +625,7 @@ static struct gpiod_lookup_table txx9_iocled_table = { }, }; -void __init txx9_iocled_init (unsigned long baseaddr, -int basenum,unsigned int num,int lowactive, +void __init txx9_iocled_init (unsigned long baseaddr,unsigned int num,const char *color,char **deftriggers) {struct txx9_iocled_data *iocled;
@@ -652,14 +651,12 @@ void __init txx9_iocled_init(unsigned long baseaddr, iocled->chip.direction_input = txx9_iocled_dir_in; iocled->chip.direction_output = txx9_iocled_dir_out; iocled->chip.label ="iocled" ; - iocled->chip.base = basenum; + iocled->chip.base =-1 ; iocled->chip.ngpio = num;if (gpiochip_add_data (&iocled->chip, iocled)) goto out_unmap; -if (basenum <0 ) - basenum = iocled->chip.base; - pdev =platform_device_alloc ("leds-gpio" , basenum); + pdev =platform_device_alloc ("leds-gpio" , iocled->chip.base);if (!pdev) goto out_gpio; iocled->pdata.num_leds = num;
@@ -689,8 +686,7 @@ void __init txx9_iocled_init(unsigned long baseaddr, kfree(iocled); }#else /* CONFIG_LEDS_GPIO */ -void __init txx9_iocled_init (unsigned long baseaddr, -int basenum,unsigned int num,int lowactive, +void __init txx9_iocled_init (unsigned long baseaddr,unsigned int num,const char *color,char **deftriggers) { }
arch/mips/txx9/rbtx4927/setup.c +1 -1
@@ -373,7 +373,7 @@ static void __init rbtx4927_device_init(void)tx4938_aclc_init (); }platform_device_register_simple ("txx9aclc-generic" ,-1 ,NULL ,0 ); -txx9_iocled_init (RBTX4927_LED_ADDR -IO_BASE ,-1 ,3 ,1 ,"green" ,NULL ); +txx9_iocled_init (RBTX4927_LED_ADDR -IO_BASE ,3 ,"green" ,NULL );rbtx4927_gpioled_init (); }
Signature · 1 line
2.43.0
Thomas Bogendoerfer
maintainerQuoted 26 lines · Geert Uytterhoeven
Hi all,
This patch series gets rid of legacy GPIO interface usage on the MIPS RBTX4927 development board, preceded and followed by some cleanups. No blinky LEDs were harmed during the production of this series.
Changes compared to v1[1]:
- Add Reviewed-by,
- Return early onplatform_device_add()failure.Thanks for your comments!
[1] "[PATCH 0/9] MIPS: TXX9: Legacy GPIO interfaces cleanup"
https://lore.kernel.org/[email protected]Geert Uytterhoeven (9):
MIPS: TXX9: Removetx4938_spi_init()andtxx9_spi_init()
MIPS: TXX9: Remove txx9_7segled_*() forward declarations
MIPS: TXX9: rbtx4927: Use GPIO lookup table for SIO DTR
MIPS: TXX9: rbtx4927: Use GPIO lookup table for TXx9 LEDs
MIPS: TXX9: ReduceTXX9_IOCLED_MAXLEDSto 3
MIPS: TXX9: Use GPIO lookup table for iocled LEDs
MIPS: TXX9: DropGPIOLIB_LEGACYselect
MIPS: TXX9: Convertgpio_txx9to dynamic GPIO base allocation
MIPS: TXX9: Clean uptxx9_iocled_init()
Quoted 9 lines
arch/mips/include/asm/txx9/generic.h | 9 +----- arch/mips/include/asm/txx9/tx4938.h | 1 - arch/mips/include/asm/txx9pio.h | 3 +- arch/mips/kernel/gpio_txx9.c | 5 ++- arch/mips/txx9/Kconfig | 1 - arch/mips/txx9/generic/setup.c | 45 ++++++++++----------------- arch/mips/txx9/generic/setup_tx4938.c | 6 ---- arch/mips/txx9/rbtx4927/setup.c | 41 ++++++++++++++++++------ 8 files changed, 53 insertions(+), 58 deletions(-)
series applied to mips-next
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]