* [PATCH V2 2/6] MIPS: lantiq: use devm_request_gpio inside xway gpio driver
2012-02-23 16:01 [PATCH V2 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter John Crispin
@ 2012-02-23 16:01 ` John Crispin
2012-02-23 16:01 ` [PATCH V2 3/6] MIPS: lantiq: use devm_request_gpio inside falcon " John Crispin
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: John Crispin @ 2012-02-23 16:01 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, John Crispin
Start using the devm_request_gpio() api inside our xway gpio_request wrapper.
Signed-off-by: John Crispin <blogic@openwrt.org>
---
arch/mips/lantiq/xway/gpio.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/mips/lantiq/xway/gpio.c b/arch/mips/lantiq/xway/gpio.c
index 14ff7c7..54ec6c9 100644
--- a/arch/mips/lantiq/xway/gpio.c
+++ b/arch/mips/lantiq/xway/gpio.c
@@ -50,14 +50,14 @@ int irq_to_gpio(unsigned int gpio)
}
EXPORT_SYMBOL(irq_to_gpio);
-int ltq_gpio_request(unsigned int pin, unsigned int mux,
+int ltq_gpio_request(struct device *dev, unsigned int pin, unsigned int mux,
unsigned int dir, const char *name)
{
int id = 0;
if (pin >= (MAX_PORTS * PINS_PER_PORT))
return -EINVAL;
- if (gpio_request(pin, name)) {
+ if (devm_gpio_request(dev, pin, name)) {
pr_err("failed to setup lantiq gpio: %s\n", name);
return -EBUSY;
}
--
1.7.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH V2 3/6] MIPS: lantiq: use devm_request_gpio inside falcon gpio driver
2012-02-23 16:01 [PATCH V2 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter John Crispin
2012-02-23 16:01 ` [PATCH V2 2/6] MIPS: lantiq: use devm_request_gpio inside xway gpio driver John Crispin
@ 2012-02-23 16:01 ` John Crispin
2012-02-23 16:01 ` [PATCH V2 4/6] NET: MIPS: lantiq: convert etop to managed gpio John Crispin
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: John Crispin @ 2012-02-23 16:01 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, John Crispin
Start using the devm_request_gpio() api inside our falcon gpio_request wrapper.
Signed-off-by: John Crispin <blogic@openwrt.org>
---
arch/mips/lantiq/falcon/gpio.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/mips/lantiq/falcon/gpio.c b/arch/mips/lantiq/falcon/gpio.c
index 3eebd51..b7611d7 100644
--- a/arch/mips/lantiq/falcon/gpio.c
+++ b/arch/mips/lantiq/falcon/gpio.c
@@ -97,7 +97,7 @@ int ltq_gpio_mux_set(unsigned int pin, unsigned int mux)
}
EXPORT_SYMBOL(ltq_gpio_mux_set);
-int ltq_gpio_request(unsigned int pin, unsigned int mux,
+int ltq_gpio_request(struct device *dev, unsigned int pin, unsigned int mux,
unsigned int dir, const char *name)
{
int port = pin / 100;
@@ -106,7 +106,7 @@ int ltq_gpio_request(unsigned int pin, unsigned int mux,
if (offset >= PINS_PER_PORT || port >= MAX_PORTS)
return -EINVAL;
- if (gpio_request(pin, name)) {
+ if (devm_gpio_request(dev, pin, name)) {
pr_err("failed to setup lantiq gpio: %s\n", name);
return -EBUSY;
}
--
1.7.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH V2 4/6] NET: MIPS: lantiq: convert etop to managed gpio
2012-02-23 16:01 [PATCH V2 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter John Crispin
2012-02-23 16:01 ` [PATCH V2 2/6] MIPS: lantiq: use devm_request_gpio inside xway gpio driver John Crispin
2012-02-23 16:01 ` [PATCH V2 3/6] MIPS: lantiq: use devm_request_gpio inside falcon " John Crispin
@ 2012-02-23 16:01 ` John Crispin
2012-02-24 10:36 ` Sergei Shtylyov
2012-02-23 16:01 ` [PATCH V2 5/6] MIPS: lantiq: convert pci " John Crispin
` (2 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: John Crispin @ 2012-02-23 16:01 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, John Crispin, netdev
ltq_gpio_request() now uses devres to manage the gpios. We need to pass a
struct device pointer to make it work.
Signed-off-by: John Crispin <blogic@openwrt.org>
Cc: netdev@vger.kernel.org
---
drivers/net/ethernet/lantiq_etop.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 66ec54a..e5ec8b1 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -292,9 +292,6 @@ ltq_etop_gbit_init(void)
{
ltq_pmu_enable(PMU_SWITCH);
- ltq_gpio_request(42, 2, 1, "MDIO");
- ltq_gpio_request(43, 2, 1, "MDC");
-
ltq_gbit_w32_mask(0, GCTL0_SE, LTQ_GBIT_GCTL0);
/** Disable MDIO auto polling mode */
ltq_gbit_w32_mask(0, PX_CTL_DMDIO, LTQ_GBIT_P0_CTL);
@@ -873,6 +870,12 @@ ltq_etop_probe(struct platform_device *pdev)
err = -ENOMEM;
goto err_out;
}
+ if (ltq_gpio_request(&pdev->dev, 42, 2, 1, "MDIO") ||
+ ltq_gpio_request(&pdev->dev, 43, 2, 1, "MDC")) {
+ dev_err(&pdev->dev, "failed to request MDIO gpios\n");
+ err = -EBUSY;
+ goto err_out;
+ }
}
dev = alloc_etherdev_mq(sizeof(struct ltq_etop_priv), 4);
--
1.7.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH V2 4/6] NET: MIPS: lantiq: convert etop to managed gpio
2012-02-23 16:01 ` [PATCH V2 4/6] NET: MIPS: lantiq: convert etop to managed gpio John Crispin
@ 2012-02-24 10:36 ` Sergei Shtylyov
0 siblings, 0 replies; 10+ messages in thread
From: Sergei Shtylyov @ 2012-02-24 10:36 UTC (permalink / raw)
To: John Crispin; +Cc: Ralf Baechle, linux-mips, netdev
Hello.
On 23-02-2012 20:01, John Crispin wrote:
> ltq_gpio_request() now uses devres to manage the gpios. We need to pass a
> struct device pointer to make it work.
> Signed-off-by: John Crispin<blogic@openwrt.org>
> Cc: netdev@vger.kernel.org
> ---
> drivers/net/ethernet/lantiq_etop.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
> diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
> index 66ec54a..e5ec8b1 100644
> --- a/drivers/net/ethernet/lantiq_etop.c
> +++ b/drivers/net/ethernet/lantiq_etop.c
> @@ -292,9 +292,6 @@ ltq_etop_gbit_init(void)
> {
> ltq_pmu_enable(PMU_SWITCH);
>
> - ltq_gpio_request(42, 2, 1, "MDIO");
> - ltq_gpio_request(43, 2, 1, "MDC");
> -
> ltq_gbit_w32_mask(0, GCTL0_SE, LTQ_GBIT_GCTL0);
> /** Disable MDIO auto polling mode */
> ltq_gbit_w32_mask(0, PX_CTL_DMDIO, LTQ_GBIT_P0_CTL);
> @@ -873,6 +870,12 @@ ltq_etop_probe(struct platform_device *pdev)
> err = -ENOMEM;
> goto err_out;
> }
> + if (ltq_gpio_request(&pdev->dev, 42, 2, 1, "MDIO") ||
> + ltq_gpio_request(&pdev->dev, 43, 2, 1, "MDC")) {
This needs to be merged with patch 1 to keep the git tree bisectable
WBR, Sergei
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH V2 5/6] MIPS: lantiq: convert pci to managed gpio
2012-02-23 16:01 [PATCH V2 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter John Crispin
` (2 preceding siblings ...)
2012-02-23 16:01 ` [PATCH V2 4/6] NET: MIPS: lantiq: convert etop to managed gpio John Crispin
@ 2012-02-23 16:01 ` John Crispin
2012-02-24 10:38 ` Sergei Shtylyov
2012-02-23 16:01 ` [PATCH V2 6/6] MIPS: lantiq: convert gpio_stp " John Crispin
2012-02-24 10:35 ` [PATCH V2 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter Sergei Shtylyov
5 siblings, 1 reply; 10+ messages in thread
From: John Crispin @ 2012-02-23 16:01 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, John Crispin
ltq_gpio_request() now uses devres to manage the gpios. We need to pass a
struct device pointer to make it work.
Signed-off-by: John Crispin <blogic@openwrt.org>
---
arch/mips/pci/pci-lantiq.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
index 3bf42c8..47b5d8e 100644
--- a/arch/mips/pci/pci-lantiq.c
+++ b/arch/mips/pci/pci-lantiq.c
@@ -150,24 +150,26 @@ static u32 ltq_calc_bar11mask(void)
return bar11mask;
}
-static void ltq_pci_setup_gpio(int gpio)
+static void ltq_pci_setup_gpio(struct device *dev)
{
+ struct ltq_pci_data *conf = (struct ltq_pci_data *) dev->platform_data;
int i;
for (i = 0; i < ARRAY_SIZE(ltq_pci_gpio_map); i++) {
- if (gpio & (1 << i)) {
- ltq_gpio_request(ltq_pci_gpio_map[i].pin,
+ if (conf->gpio & (1 << i)) {
+ ltq_gpio_request(dev, ltq_pci_gpio_map[i].pin,
ltq_pci_gpio_map[i].mux,
ltq_pci_gpio_map[i].dir,
ltq_pci_gpio_map[i].name);
}
}
- ltq_gpio_request(21, 0, 1, "pci-reset");
- ltq_pci_req_mask = (gpio >> PCI_REQ_SHIFT) & PCI_REQ_MASK;
+ ltq_gpio_request(dev, 21, 0, 1, "pci-reset");
+ ltq_pci_req_mask = (conf->gpio >> PCI_REQ_SHIFT) & PCI_REQ_MASK;
}
-static int __devinit ltq_pci_startup(struct ltq_pci_data *conf)
+static int __devinit ltq_pci_startup(struct device *dev)
{
u32 temp_buffer;
+ struct ltq_pci_data *conf = (struct ltq_pci_data *) dev->platform_data;
/* set clock to 33Mhz */
if (ltq_is_ar9()) {
@@ -190,7 +192,7 @@ static int __devinit ltq_pci_startup(struct ltq_pci_data *conf)
}
/* setup pci clock and gpis used by pci */
- ltq_pci_setup_gpio(conf->gpio);
+ ltq_pci_setup_gpio(dev);
/* enable auto-switching between PCI and EBU */
ltq_pci_w32(0xa, PCI_CR_CLK_CTRL);
@@ -275,7 +277,7 @@ static int __devinit ltq_pci_probe(struct platform_device *pdev)
ioremap_nocache(LTQ_PCI_CFG_BASE, LTQ_PCI_CFG_BASE);
ltq_pci_controller.io_map_base =
(unsigned long)ioremap(LTQ_PCI_IO_BASE, LTQ_PCI_IO_SIZE - 1);
- ltq_pci_startup(ltq_pci_data);
+ ltq_pci_startup(&pdev->dev);
register_pci_controller(<q_pci_controller);
return 0;
--
1.7.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH V2 5/6] MIPS: lantiq: convert pci to managed gpio
2012-02-23 16:01 ` [PATCH V2 5/6] MIPS: lantiq: convert pci " John Crispin
@ 2012-02-24 10:38 ` Sergei Shtylyov
0 siblings, 0 replies; 10+ messages in thread
From: Sergei Shtylyov @ 2012-02-24 10:38 UTC (permalink / raw)
To: John Crispin; +Cc: Ralf Baechle, linux-mips
Hello.
On 23-02-2012 20:01, John Crispin wrote:
> ltq_gpio_request() now uses devres to manage the gpios. We need to pass a
> struct device pointer to make it work.
> Signed-off-by: John Crispin<blogic@openwrt.org>
[...]
> diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
> index 3bf42c8..47b5d8e 100644
> --- a/arch/mips/pci/pci-lantiq.c
> +++ b/arch/mips/pci/pci-lantiq.c
> @@ -150,24 +150,26 @@ static u32 ltq_calc_bar11mask(void)
> return bar11mask;
> }
>
> -static void ltq_pci_setup_gpio(int gpio)
> +static void ltq_pci_setup_gpio(struct device *dev)
> {
> + struct ltq_pci_data *conf = (struct ltq_pci_data *) dev->platform_data;
> int i;
> for (i = 0; i< ARRAY_SIZE(ltq_pci_gpio_map); i++) {
> - if (gpio & (1 << i)) {
> - ltq_gpio_request(ltq_pci_gpio_map[i].pin,
> + if (conf->gpio & (1 << i)) {
> + ltq_gpio_request(dev, ltq_pci_gpio_map[i].pin,
> ltq_pci_gpio_map[i].mux,
> ltq_pci_gpio_map[i].dir,
> ltq_pci_gpio_map[i].name);
> }
> }
> - ltq_gpio_request(21, 0, 1, "pci-reset");
> - ltq_pci_req_mask = (gpio>> PCI_REQ_SHIFT)& PCI_REQ_MASK;
> + ltq_gpio_request(dev, 21, 0, 1, "pci-reset");
This needs to be merged with patch 1.
WBR, Sergei
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH V2 6/6] MIPS: lantiq: convert gpio_stp to managed gpio
2012-02-23 16:01 [PATCH V2 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter John Crispin
` (3 preceding siblings ...)
2012-02-23 16:01 ` [PATCH V2 5/6] MIPS: lantiq: convert pci " John Crispin
@ 2012-02-23 16:01 ` John Crispin
2012-02-24 10:39 ` Sergei Shtylyov
2012-02-24 10:35 ` [PATCH V2 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter Sergei Shtylyov
5 siblings, 1 reply; 10+ messages in thread
From: John Crispin @ 2012-02-23 16:01 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, John Crispin
ltq_gpio_request() now uses devres to manage the gpios. We need to pass a
struct device pointer to make it work.
Signed-off-by: John Crispin <blogic@openwrt.org>
---
arch/mips/lantiq/xway/gpio_stp.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/mips/lantiq/xway/gpio_stp.c b/arch/mips/lantiq/xway/gpio_stp.c
index cb6f170..e6b4809 100644
--- a/arch/mips/lantiq/xway/gpio_stp.c
+++ b/arch/mips/lantiq/xway/gpio_stp.c
@@ -80,11 +80,6 @@ static struct gpio_chip ltq_stp_chip = {
static int ltq_stp_hw_init(void)
{
- /* the 3 pins used to control the external stp */
- ltq_gpio_request(4, 2, 1, "stp-st");
- ltq_gpio_request(5, 2, 1, "stp-d");
- ltq_gpio_request(6, 2, 1, "stp-sh");
-
/* sane defaults */
ltq_stp_w32(0, LTQ_STP_AR);
ltq_stp_w32(0, LTQ_STP_CPU0);
@@ -133,6 +128,14 @@ static int __devinit ltq_stp_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to remap STP memory\n");
return -ENOMEM;
}
+
+ /* the 3 pins used to control the external stp */
+ if (ltq_gpio_request(&pdev->dev, 4, 2, 1, "stp-st") ||
+ ltq_gpio_request(&pdev->dev, 5, 2, 1, "stp-d") ||
+ ltq_gpio_request(&pdev->dev, 6, 2, 1, "stp-sh")) {
+ dev_err(&pdev->dev, "failed to request needed gpios\n");
+ return -EBUSY;
+ }
ret = gpiochip_add(<q_stp_chip);
if (!ret)
ret = ltq_stp_hw_init();
--
1.7.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH V2 6/6] MIPS: lantiq: convert gpio_stp to managed gpio
2012-02-23 16:01 ` [PATCH V2 6/6] MIPS: lantiq: convert gpio_stp " John Crispin
@ 2012-02-24 10:39 ` Sergei Shtylyov
0 siblings, 0 replies; 10+ messages in thread
From: Sergei Shtylyov @ 2012-02-24 10:39 UTC (permalink / raw)
To: John Crispin; +Cc: Ralf Baechle, linux-mips
Hello.
On 23-02-2012 20:01, John Crispin wrote:
> ltq_gpio_request() now uses devres to manage the gpios. We need to pass a
> struct device pointer to make it work.
> Signed-off-by: John Crispin<blogic@openwrt.org>
> ---
> arch/mips/lantiq/xway/gpio_stp.c | 13 ++++++++-----
> 1 files changed, 8 insertions(+), 5 deletions(-)
> diff --git a/arch/mips/lantiq/xway/gpio_stp.c b/arch/mips/lantiq/xway/gpio_stp.c
> index cb6f170..e6b4809 100644
> --- a/arch/mips/lantiq/xway/gpio_stp.c
> +++ b/arch/mips/lantiq/xway/gpio_stp.c
> @@ -80,11 +80,6 @@ static struct gpio_chip ltq_stp_chip = {
>
> static int ltq_stp_hw_init(void)
> {
> - /* the 3 pins used to control the external stp */
> - ltq_gpio_request(4, 2, 1, "stp-st");
> - ltq_gpio_request(5, 2, 1, "stp-d");
> - ltq_gpio_request(6, 2, 1, "stp-sh");
> -
> /* sane defaults */
> ltq_stp_w32(0, LTQ_STP_AR);
> ltq_stp_w32(0, LTQ_STP_CPU0);
> @@ -133,6 +128,14 @@ static int __devinit ltq_stp_probe(struct platform_device *pdev)
> dev_err(&pdev->dev, "failed to remap STP memory\n");
> return -ENOMEM;
> }
> +
> + /* the 3 pins used to control the external stp */
> + if (ltq_gpio_request(&pdev->dev, 4, 2, 1, "stp-st") ||
> + ltq_gpio_request(&pdev->dev, 5, 2, 1, "stp-d") ||
> + ltq_gpio_request(&pdev->dev, 6, 2, 1, "stp-sh")) {
This needs to be merged to patch 1...
WBR, Sergei
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter
2012-02-23 16:01 [PATCH V2 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter John Crispin
` (4 preceding siblings ...)
2012-02-23 16:01 ` [PATCH V2 6/6] MIPS: lantiq: convert gpio_stp " John Crispin
@ 2012-02-24 10:35 ` Sergei Shtylyov
5 siblings, 0 replies; 10+ messages in thread
From: Sergei Shtylyov @ 2012-02-24 10:35 UTC (permalink / raw)
To: John Crispin; +Cc: Ralf Baechle, linux-mips
Hello.
On 23-02-2012 20:01, John Crispin wrote:
> 3.2 introduced devm_request_gpio() to allow managed gpios.
> The devres api requires a struct device pointer to work. Add a parameter to ltq_gpio_request()
> so that managed gpios can work.
> Signed-off-by: John Crispin<blogic@openwrt.org>
[...]
> diff --git a/arch/mips/include/asm/mach-lantiq/lantiq.h b/arch/mips/include/asm/mach-lantiq/lantiq.h
> index bf05854..d90eef3 100644
> --- a/arch/mips/include/asm/mach-lantiq/lantiq.h
> +++ b/arch/mips/include/asm/mach-lantiq/lantiq.h
> @@ -39,6 +39,10 @@ extern unsigned int ltq_get_soc_type(void);
> /* spinlock all ebu i/o */
> extern spinlock_t ebu_lock;
>
> +/* request a non-gpio and set the PIO config */
> +extern int ltq_gpio_request(struct device *dev, unsigned int pin,
> + unsigned int mux, unsigned int dir, const char *name);
> +
Where are the call sites of this function? Shoudln't they be modified?
WBR, Sergei
^ permalink raw reply [flat|nested] 10+ messages in thread