* [PATCH 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter
2012-02-17 10:32 [PATCH 0/6] MIPS: lantiq: use managed gpios John Crispin
@ 2012-02-17 10:32 ` John Crispin
2012-02-17 10:32 ` [PATCH 2/6] MIPS: lantiq: use devm_request_gpio inside xway gpio driver John Crispin
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: John Crispin @ 2012-02-17 10:32 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, John Crispin
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>
---
.../include/asm/mach-lantiq/falcon/lantiq_soc.h | 4 +---
arch/mips/include/asm/mach-lantiq/lantiq.h | 4 ++++
.../mips/include/asm/mach-lantiq/xway/lantiq_soc.h | 3 ---
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/arch/mips/include/asm/mach-lantiq/falcon/lantiq_soc.h b/arch/mips/include/asm/mach-lantiq/falcon/lantiq_soc.h
index 8ac509a..1a4b836 100644
--- a/arch/mips/include/asm/mach-lantiq/falcon/lantiq_soc.h
+++ b/arch/mips/include/asm/mach-lantiq/falcon/lantiq_soc.h
@@ -141,9 +141,7 @@ static inline void ltq_sys1_w32_mask(u32 c, u32 s, u32 r)
ltq_sys1_w32((ltq_sys1_r32(r) & ~(c)) | (s), r);
}
-/* gpio_request wrapper to help configure the pin */
-extern int ltq_gpio_request(unsigned int pin, unsigned int mux,
- unsigned int dir, const char *name);
+/* gpio wrapper to help configure the pin muxing */
extern int ltq_gpio_mux_set(unsigned int pin, unsigned int mux);
/* to keep the irq code generic we need to define these to 0 as falcon
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);
+
/* some irq helpers */
extern void ltq_disable_irq(struct irq_data *data);
extern void ltq_mask_and_ack_irq(struct irq_data *data);
diff --git a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h b/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
index 9d0afeb..4213926 100644
--- a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
+++ b/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
@@ -167,9 +167,6 @@ static inline void ltq_cgu_w32_mask(u32 c, u32 s, u32 r)
ltq_cgu_w32((ltq_cgu_r32(r) & ~(c)) | (s), r);
}
-/* request a non-gpio and set the PIO config */
-extern int ltq_gpio_request(unsigned int pin, unsigned int mux,
- unsigned int dir, const char *name);
extern void ltq_pmu_enable(unsigned int module);
extern void ltq_pmu_disable(unsigned int module);
extern void ltq_cgu_enable(unsigned int clk);
--
1.7.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/6] MIPS: lantiq: use devm_request_gpio inside xway gpio driver
2012-02-17 10:32 [PATCH 0/6] MIPS: lantiq: use managed gpios John Crispin
2012-02-17 10:32 ` [PATCH 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter John Crispin
@ 2012-02-17 10:32 ` John Crispin
2012-02-17 10:32 ` [PATCH 3/6] MIPS: lantiq: use devm_request_gpio inside falcon " John Crispin
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: John Crispin @ 2012-02-17 10:32 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] 8+ messages in thread* [PATCH 3/6] MIPS: lantiq: use devm_request_gpio inside falcon gpio driver
2012-02-17 10:32 [PATCH 0/6] MIPS: lantiq: use managed gpios John Crispin
2012-02-17 10:32 ` [PATCH 1/6] MIPS: lantiq: remove redunant ltq_gpio_request() declaration and add device parameter John Crispin
2012-02-17 10:32 ` [PATCH 2/6] MIPS: lantiq: use devm_request_gpio inside xway gpio driver John Crispin
@ 2012-02-17 10:32 ` John Crispin
2012-02-17 10:32 ` [PATCH 4/6] NET: MIPS: lantiq: convert etop to managed gpio John Crispin
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: John Crispin @ 2012-02-17 10:32 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] 8+ messages in thread* [PATCH 4/6] NET: MIPS: lantiq: convert etop to managed gpio
2012-02-17 10:32 [PATCH 0/6] MIPS: lantiq: use managed gpios John Crispin
` (2 preceding siblings ...)
2012-02-17 10:32 ` [PATCH 3/6] MIPS: lantiq: use devm_request_gpio inside falcon " John Crispin
@ 2012-02-17 10:32 ` John Crispin
2012-02-17 12:24 ` John Crispin
2012-02-17 10:32 ` [PATCH 5/6] MIPS: lantiq: convert pci " John Crispin
2012-02-17 10:32 ` [PATCH 6/6] MIPS: lantiq: convert gpio_stp " John Crispin
5 siblings, 1 reply; 8+ messages in thread
From: John Crispin @ 2012-02-17 10:32 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
---
This patch should go via MIPS with the rest of the series.
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..80ce6d9 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 = -ENOMEM;
+ goto err_out;
+ }
}
dev = alloc_etherdev_mq(sizeof(struct ltq_etop_priv), 4);
--
1.7.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 4/6] NET: MIPS: lantiq: convert etop to managed gpio
2012-02-17 10:32 ` [PATCH 4/6] NET: MIPS: lantiq: convert etop to managed gpio John Crispin
@ 2012-02-17 12:24 ` John Crispin
0 siblings, 0 replies; 8+ messages in thread
From: John Crispin @ 2012-02-17 12:24 UTC (permalink / raw)
To: John Crispin; +Cc: Ralf Baechle, linux-mips, netdev
> 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 = -ENOMEM;
-EBUSY should go here instead of -ENOMEM
> + goto err_out;
> + }
> }
>
> dev = alloc_etherdev_mq(sizeof(struct ltq_etop_priv), 4);
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/6] MIPS: lantiq: convert pci to managed gpio
2012-02-17 10:32 [PATCH 0/6] MIPS: lantiq: use managed gpios John Crispin
` (3 preceding siblings ...)
2012-02-17 10:32 ` [PATCH 4/6] NET: MIPS: lantiq: convert etop to managed gpio John Crispin
@ 2012-02-17 10:32 ` John Crispin
2012-02-17 10:32 ` [PATCH 6/6] MIPS: lantiq: convert gpio_stp " John Crispin
5 siblings, 0 replies; 8+ messages in thread
From: John Crispin @ 2012-02-17 10:32 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] 8+ messages in thread* [PATCH 6/6] MIPS: lantiq: convert gpio_stp to managed gpio
2012-02-17 10:32 [PATCH 0/6] MIPS: lantiq: use managed gpios John Crispin
` (4 preceding siblings ...)
2012-02-17 10:32 ` [PATCH 5/6] MIPS: lantiq: convert pci " John Crispin
@ 2012-02-17 10:32 ` John Crispin
5 siblings, 0 replies; 8+ messages in thread
From: John Crispin @ 2012-02-17 10:32 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] 8+ messages in thread