gpio: davinci: drop platform data support
Subsystems (2)
PATCH 1/2 gpio: davinci: drop platform data support
From: Bartosz Golaszewski <[email protected]>
There are no more any board files that use the platform data for gpio-davinci. We can remove the header defining it and port the code to no longer store any context in pdata.
--- drivers/gpio/gpio-davinci.c | 89 ++++++---------------- include/linux/platform_data/gpio-davinci.h | 21 ----- 2 files changed, 25 insertions(+), 85 deletions(-) delete mode 100644 include/linux/platform_data/gpio-davinci.h
drivers/gpio/gpio-davinci.c +25 -64
@@ -18,7 +18,6 @@#include <linux/of.h> #include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> -#include <linux/platform_data/gpio-davinci.h> #include <linux/property.h> #include <linux/irqchip/chained_irq.h> #include <linux/spinlock.h>
@@ -154,74 +153,37 @@ davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value) value ? &g->set_data : &g->clr_data); } -static struct davinci_gpio_platform_data * -davinci_gpio_get_pdata (struct platform_device *pdev) -{ -struct device_node *dn = pdev->dev.of_node; -struct davinci_gpio_platform_data *pdata; -int ret; -u32 val; - -if (!IS_ENABLED (CONFIG_OF ) || !pdev->dev.of_node) -return dev_get_platdata (&pdev->dev); - - pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); -if (!pdata) -return NULL ; - - ret =of_property_read_u32 (dn,"ti,ngpio" , &val); -if (ret) - goto of_err; - - pdata->ngpio = val; - - ret =of_property_read_u32 (dn,"ti,davinci-gpio-unbanked" , &val); -if (ret) - goto of_err; - - pdata->gpio_unbanked = val; - -return pdata; - -of_err: -dev_err (&pdev->dev,"Populating pdata from DT failed: err %d\n" , ret); -return NULL ; -} -static int davinci_gpio_probe (struct platform_device *pdev) {int bank, i, ret =0 ; -unsigned int ngpio, nbank, nirq; +unsigned int ngpio, nbank, nirq, gpio_unbanked;struct davinci_gpio_controller *chips; -struct davinci_gpio_platform_data *pdata;struct device *dev = &pdev->dev; - - pdata =davinci_gpio_get_pdata (pdev); -if (!pdata) { -dev_err (dev,"No platform data found\n" ); -return -EINVAL ; - } - - dev->platform_data = pdata; +struct device_node *dn =dev_of_node (dev);/* * The gpio banks conceptually expose a segmented bitmap, * and "ngpio" is one more than the largest zero-based * bit index that's valid. */ - ngpio = pdata->ngpio; -if (ngpio ==0 ) { -dev_err (dev,"How many GPIOs?\n" ); -return -EINVAL ; - } + ret =of_property_read_u32 (dn,"ti,ngpio" , &ngpio); +if (ret) +return dev_err_probe (dev, ret,"Failed to get the number of GPIOs\n" ); +if (ngpio ==0 ) +return dev_err_probe (dev, -EINVAL ,"How many GPIOs?\n" );/* * If there are unbanked interrupts then the number of * interrupts is equal to number of gpios else all are banked so * number of interrupts is equal to number of banks(each with 16 gpios) */ -if (pdata->gpio_unbanked) - nirq = pdata->gpio_unbanked; + ret =of_property_read_u32 (dn,"ti,davinci-gpio-unbanked" , + &gpio_unbanked); +if (ret) +return dev_err_probe (dev, ret,"Failed to get the unbanked GPIOs property\n" ); + +if (gpio_unbanked) + nirq = gpio_unbanked;else nirq =DIV_ROUND_UP (ngpio,16 );
@@ -252,7 +214,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) chips->chip.set = davinci_gpio_set; chips->chip.ngpio = ngpio; - chips->chip.base = pdata->no_auto_base ? pdata->base :-1 ; + chips->chip.base =-1 ;#ifdef CONFIG_OF_GPIO chips->chip.parent = dev;
@@ -261,6 +223,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)#endif spin_lock_init (&chips->lock); + chips->gpio_unbanked = gpio_unbanked; + nbank =DIV_ROUND_UP (ngpio,32 );for (bank =0 ; bank < nbank; bank++) chips->regs[bank] = gpio_base + offset_array[bank];
@@ -488,7 +452,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)unsigned ngpio;struct device *dev = &pdev->dev;struct davinci_gpio_controller *chips =platform_get_drvdata (pdev); -struct davinci_gpio_platform_data *pdata = dev->platform_data;struct davinci_gpio_regs __iomem *g;struct irq_domain *irq_domain =NULL ;struct irq_chip *irq_chip;
@@ -502,7 +465,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)if (dev->of_node) gpio_get_irq_chip = (gpio_get_irq_chip_cb_t )device_get_match_data (dev); - ngpio = pdata->ngpio; + ngpio = chips->chip.ngpio; clk =devm_clk_get (dev,"gpio" );if (IS_ERR (clk)) {
@@ -514,7 +477,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)if (ret)return ret; -if (!pdata->gpio_unbanked) { +if (chips->gpio_unbanked) { irq =devm_irq_alloc_descs (dev,-1 ,0 , ngpio,0 );if (irq <0 ) {dev_err (dev,"Couldn't allocate IRQ numbers\n" );
@@ -546,11 +509,11 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)* controller only handling trigger modes. We currently assume no * IRQ mux conflicts; gpio_irq_type_unbanked() is only for GPIOs. */ -if (pdata->gpio_unbanked) { +if (chips->gpio_unbanked) {/* pass "bank 0" GPIO IRQs to AINTC */ chips->chip.to_irq = gpio_to_irq_unbanked; - chips->gpio_unbanked = pdata->gpio_unbanked; - binten =GENMASK (pdata->gpio_unbanked /16 ,0 ); + + binten =GENMASK (chips->gpio_unbanked /16 ,0 );/* AINTC handles mask/unmask; GPIO handles triggering */ irq = chips->irqs[0 ];
@@ -564,7 +527,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)writel_relaxed (~0 , &g->set_rising);/* set the direct IRQs up to use that irqchip */ -for (gpio =0 ; gpio < pdata->gpio_unbanked; gpio++) { +for (gpio =0 ; gpio < chips->gpio_unbanked; gpio++) {irq_set_chip (chips->irqs[gpio], irq_chip);irq_set_handler_data (chips->irqs[gpio], chips); irq_set_status_flags(chips->irqs[gpio],
@@ -675,8 +638,7 @@ static void davinci_gpio_restore_context(struct davinci_gpio_controller *chips,static int davinci_gpio_suspend (struct device *dev) {struct davinci_gpio_controller *chips =dev_get_drvdata (dev); -struct davinci_gpio_platform_data *pdata =dev_get_platdata (dev); -u32 nbank =DIV_ROUND_UP (pdata->ngpio,32 ); +u32 nbank =DIV_ROUND_UP (chips->chip.ngpio,32 );davinci_gpio_save_context (chips, nbank);
@@ -686,8 +648,7 @@ static int davinci_gpio_suspend(struct device *dev)static int davinci_gpio_resume (struct device *dev) {struct davinci_gpio_controller *chips =dev_get_drvdata (dev); -struct davinci_gpio_platform_data *pdata =dev_get_platdata (dev); -u32 nbank =DIV_ROUND_UP (pdata->ngpio,32 ); +u32 nbank =DIV_ROUND_UP (chips->chip.ngpio,32 );davinci_gpio_restore_context (chips, nbank);
include/linux/platform_data/gpio-davinci.h deleted +0 -21
@@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* DaVinci GPIO Platform Related Defines -* -* Copyright (C) 2013 Texas Instruments Incorporated - https://www.ti.com/ -*/ - -#ifndef __DAVINCI_GPIO_PLATFORM_H -#define __DAVINCI_GPIO_PLATFORM_H - -struct davinci_gpio_platform_data { -bool no_auto_base; -u32 base; -u32 ngpio; -u32 gpio_unbanked; -}; - -/* Convert GPIO signal to GPIO pin number */ -#define GPIO_TO_PIN (bank, gpio) (16 * (bank) + (gpio)) - -#endif
Signature · 1 line
2.43.0
PATCH 2/2 gpio: davinci: use devm_clk_get_enabled()
From: Bartosz Golaszewski <[email protected]>
Simplify the code in error paths by using the managed variant of the clock getter that controls the clock state as well.
--- drivers/gpio/gpio-davinci.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/gpio/gpio-davinci.c +2 -11
@@ -446,7 +446,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) {unsigned gpio, bank;int irq; -int ret;struct clk *clk;u32 binten =0 ;unsigned ngpio;
@@ -467,21 +466,16 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) ngpio = chips->chip.ngpio; - clk =devm_clk_get (dev,"gpio" ); + clk =devm_clk_get_enabled (dev,"gpio" );if (IS_ERR (clk)) {dev_err (dev,"Error %ld getting gpio clock\n" ,PTR_ERR (clk));return PTR_ERR (clk); } - ret =clk_prepare_enable (clk); -if (ret) -return ret; -if (chips->gpio_unbanked) { irq =devm_irq_alloc_descs (dev,-1 ,0 , ngpio,0 );if (irq <0 ) {dev_err (dev,"Couldn't allocate IRQ numbers\n" ); -clk_disable_unprepare (clk);return irq; }
@@ -490,7 +484,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) chips);if (!irq_domain) {dev_err (dev,"Couldn't register an IRQ domain\n" ); -clk_disable_unprepare (clk);return -ENODEV ; } }
@@ -559,10 +552,8 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)sizeof (struct davinci_gpio_irq_data ), GFP_KERNEL); -if (!irqdata) { -clk_disable_unprepare (clk); +if (!irqdata)return -ENOMEM ; - } irqdata->regs = g; irqdata->bank_num = bank;
Signature · 1 line
2.43.0
Re: [PATCH 2/2] gpio: davinci: use devm_clk_get_enabled()
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Simplify the code in error paths by using the managed variant of the clock getter that controls the clock state as well.
Signed-off-by Bartosz Golaszewski <[email protected]>
Yours,
Linus Walleij
Quoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
There are no more any board files that use the platform data for gpio-davinci. We can remove the header defining it and port the code to no longer store any context in pdata.
Signed-off-by Bartosz Golaszewski <[email protected]>
Yours,
Linus Walleij
Quoted 9 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
There are no more any board files that use the platform data for gpio-davinci. We can remove the header defining it and port the code to no longer store any context in pdata.
Signed-off-by Bartosz Golaszewski <[email protected]>---
Keerthy,
Do you think you could test it on keystone to avoid any breakage upstream?
Bart
From: Bartosz Golaszewski <[email protected]>
Quoted 5 lines · Bartosz Golaszewski
There are no more any board files that use the platform data for gpio-davinci. We can remove the header defining it and port the code to no longer store any context in pdata.
Oh well, if nobody's complaining then let's get it into next.
[1/2] gpio: davinci: drop platform data support
commit: d29e741cad3f8f41df1834bf74df79380c1c6c6d
[2/2] gpio: davinci: use devm_clk_get_enabled()
commit: d14f6f405fc7b66b0a18967378a4114054b2690cBest regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>