brcm63xx: use a lookup for bcmcia's ready gpio
authorJonas Gorski <jogo@openwrt.org>
Wed, 25 Mar 2015 15:37:38 +0000 (15:37 +0000)
committerJonas Gorski <jogo@openwrt.org>
Wed, 25 Mar 2015 15:37:38 +0000 (15:37 +0000)
Should fix pcmcia on BCM6348 and BCM6358 after switching to DT-probed
gpio controllers.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
SVN-Revision: 44995

target/linux/brcm63xx/patches-3.14/379-MIPS-BCM63XX-provide-a-gpio-lookup-for-the-pcmcia-re.patch [new file with mode: 0644]
target/linux/brcm63xx/patches-3.14/380-pcmcia-bcm63xx_pmcia-use-the-new-named-gpio.patch [new file with mode: 0644]
target/linux/brcm63xx/patches-3.18/379-MIPS-BCM63XX-provide-a-gpio-lookup-for-the-pcmcia-re.patch [new file with mode: 0644]
target/linux/brcm63xx/patches-3.18/380-pcmcia-bcm63xx_pmcia-use-the-new-named-gpio.patch [new file with mode: 0644]

diff --git a/target/linux/brcm63xx/patches-3.14/379-MIPS-BCM63XX-provide-a-gpio-lookup-for-the-pcmcia-re.patch b/target/linux/brcm63xx/patches-3.14/379-MIPS-BCM63XX-provide-a-gpio-lookup-for-the-pcmcia-re.patch
new file mode 100644 (file)
index 0000000..dcf7d61
--- /dev/null
@@ -0,0 +1,59 @@
+From 1647cccc871bf43876c3df9852869680880d054c Mon Sep 17 00:00:00 2001
+From: Jonas Gorski <jogo@openwrt.org>
+Date: Wed, 25 Mar 2015 13:52:02 +0100
+Subject: [PATCH 1/2] MIPS: BCM63XX: provide a gpio lookup for the pcmcia
+ ready gpio
+
+To prepare for a time when gpiobases don't need to be fixed anymore.
+
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ arch/mips/bcm63xx/dev-pcmcia.c |   13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+--- a/arch/mips/bcm63xx/dev-pcmcia.c
++++ b/arch/mips/bcm63xx/dev-pcmcia.c
+@@ -10,6 +10,7 @@
+ #include <linux/kernel.h>
+ #include <asm/bootinfo.h>
+ #include <linux/platform_device.h>
++#include <linux/gpio/driver.h>
+ #include <bcm63xx_cs.h>
+ #include <bcm63xx_cpu.h>
+ #include <bcm63xx_dev_pcmcia.h>
+@@ -101,6 +102,14 @@ static const struct {
+       },
+ };
++static struct gpiod_lookup_table pcmcia_gpios_table = {
++      .dev_id = "bcm63xx_pcmcia.0",
++      .table = {
++              GPIO_LOOKUP("bcm63xx-gpio.0", 0, "ready", GPIO_ACTIVE_HIGH),
++              { },
++      },
++};
++
+ int __init bcm63xx_pcmcia_register(void)
+ {
+       int ret, i;
+@@ -112,16 +121,20 @@ int __init bcm63xx_pcmcia_register(void)
+       switch (bcm63xx_get_cpu_id()) {
+       case BCM6348_CPU_ID:
+               pd.ready_gpio = 22;
++              pcmcia_gpios_table.table[0].chip_hwnum = 22;
+               break;
+       case BCM6358_CPU_ID:
+               pd.ready_gpio = 18;
++              pcmcia_gpios_table.table[0].chip_hwnum = 18;
+               break;
+       default:
+               return -ENODEV;
+       }
++      gpiod_add_lookup_table(&pcmcia_gpios_table);
++
+       pcmcia_resources[0].start = bcm63xx_regset_address(RSET_PCMCIA);
+       pcmcia_resources[0].end = pcmcia_resources[0].start +
+               RSET_PCMCIA_SIZE - 1;
diff --git a/target/linux/brcm63xx/patches-3.14/380-pcmcia-bcm63xx_pmcia-use-the-new-named-gpio.patch b/target/linux/brcm63xx/patches-3.14/380-pcmcia-bcm63xx_pmcia-use-the-new-named-gpio.patch
new file mode 100644 (file)
index 0000000..524ca1a
--- /dev/null
@@ -0,0 +1,59 @@
+From c4e04f1c54928a49b227a5420d38b18226838775 Mon Sep 17 00:00:00 2001
+From: Jonas Gorski <jogo@openwrt.org>
+Date: Wed, 25 Mar 2015 13:54:56 +0100
+Subject: [PATCH 2/2] pcmcia: bcm63xx_pmcia: use the new named gpio
+
+Use the new named gpio instead of relying on the hardware gpio numbers
+matching the virtual gpio numbers.
+
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ drivers/pcmcia/bcm63xx_pcmcia.c |    9 ++++++++-
+ drivers/pcmcia/bcm63xx_pcmcia.h |    4 ++++
+ 2 files changed, 12 insertions(+), 1 deletion(-)
+
+--- a/drivers/pcmcia/bcm63xx_pcmcia.c
++++ b/drivers/pcmcia/bcm63xx_pcmcia.c
+@@ -237,7 +237,7 @@ static unsigned int __get_socket_status(
+               stat |= SS_XVCARD;
+       stat |= SS_POWERON;
+-      if (gpio_get_value(skt->pd->ready_gpio))
++      if (gpiod_get_value(skt->ready_gpio))
+               stat |= SS_READY;
+       return stat;
+@@ -373,6 +373,13 @@ static int bcm63xx_drv_pcmcia_probe(stru
+               goto err;
+       }
++      /* get ready gpio */
++      skt->ready_gpio = devm_gpiod_get(&pdev->dev, "ready", GPIOD_IN);
++      if (IS_ERR(skt->ready_gpio)) {
++              ret = PTR_ERR(skt->ready_gpio);
++              goto err;
++      }
++
+       /* resources are static */
+       sock->resource_ops = &pccard_static_ops;
+       sock->ops = &bcm63xx_pcmcia_operations;
+--- a/drivers/pcmcia/bcm63xx_pcmcia.h
++++ b/drivers/pcmcia/bcm63xx_pcmcia.h
+@@ -3,6 +3,7 @@
+ #include <linux/types.h>
+ #include <linux/timer.h>
++#include <linux/gpio/consumer.h>
+ #include <pcmcia/ss.h>
+ #include <bcm63xx_dev_pcmcia.h>
+@@ -55,6 +56,9 @@ struct bcm63xx_pcmcia_socket {
+       /* base address of io memory */
+       void __iomem *io_base;
++
++      /* ready gpio */
++      struct gpio_desc *ready_gpio;
+ };
+ #endif /* BCM63XX_PCMCIA_H_ */
diff --git a/target/linux/brcm63xx/patches-3.18/379-MIPS-BCM63XX-provide-a-gpio-lookup-for-the-pcmcia-re.patch b/target/linux/brcm63xx/patches-3.18/379-MIPS-BCM63XX-provide-a-gpio-lookup-for-the-pcmcia-re.patch
new file mode 100644 (file)
index 0000000..b571999
--- /dev/null
@@ -0,0 +1,59 @@
+From 1647cccc871bf43876c3df9852869680880d054c Mon Sep 17 00:00:00 2001
+From: Jonas Gorski <jogo@openwrt.org>
+Date: Wed, 25 Mar 2015 13:52:02 +0100
+Subject: [PATCH 1/2] MIPS: BCM63XX: provide a gpio lookup for the pcmcia
+ ready gpio
+
+To prepare for a time when gpiobases don't need to be fixed anymore.
+
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ arch/mips/bcm63xx/dev-pcmcia.c |   13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+--- a/arch/mips/bcm63xx/dev-pcmcia.c
++++ b/arch/mips/bcm63xx/dev-pcmcia.c
+@@ -10,6 +10,7 @@
+ #include <linux/kernel.h>
+ #include <asm/bootinfo.h>
+ #include <linux/platform_device.h>
++#include <linux/gpio/machine.h>
+ #include <bcm63xx_cs.h>
+ #include <bcm63xx_cpu.h>
+ #include <bcm63xx_dev_pcmcia.h>
+@@ -101,6 +102,14 @@ static const struct {
+       },
+ };
++static struct gpiod_lookup_table pcmcia_gpios_table = {
++      .dev_id = "bcm63xx_pcmcia.0",
++      .table = {
++              GPIO_LOOKUP("bcm63xx-gpio.0", 0, "ready", GPIO_ACTIVE_HIGH),
++              { },
++      },
++};
++
+ int __init bcm63xx_pcmcia_register(void)
+ {
+       int ret, i;
+@@ -112,16 +121,20 @@ int __init bcm63xx_pcmcia_register(void)
+       switch (bcm63xx_get_cpu_id()) {
+       case BCM6348_CPU_ID:
+               pd.ready_gpio = 22;
++              pcmcia_gpios_table.table[0].chip_hwnum = 22;
+               break;
+       case BCM6358_CPU_ID:
+               pd.ready_gpio = 18;
++              pcmcia_gpios_table.table[0].chip_hwnum = 18;
+               break;
+       default:
+               return -ENODEV;
+       }
++      gpiod_add_lookup_table(&pcmcia_gpios_table);
++
+       pcmcia_resources[0].start = bcm63xx_regset_address(RSET_PCMCIA);
+       pcmcia_resources[0].end = pcmcia_resources[0].start +
+               RSET_PCMCIA_SIZE - 1;
diff --git a/target/linux/brcm63xx/patches-3.18/380-pcmcia-bcm63xx_pmcia-use-the-new-named-gpio.patch b/target/linux/brcm63xx/patches-3.18/380-pcmcia-bcm63xx_pmcia-use-the-new-named-gpio.patch
new file mode 100644 (file)
index 0000000..524ca1a
--- /dev/null
@@ -0,0 +1,59 @@
+From c4e04f1c54928a49b227a5420d38b18226838775 Mon Sep 17 00:00:00 2001
+From: Jonas Gorski <jogo@openwrt.org>
+Date: Wed, 25 Mar 2015 13:54:56 +0100
+Subject: [PATCH 2/2] pcmcia: bcm63xx_pmcia: use the new named gpio
+
+Use the new named gpio instead of relying on the hardware gpio numbers
+matching the virtual gpio numbers.
+
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ drivers/pcmcia/bcm63xx_pcmcia.c |    9 ++++++++-
+ drivers/pcmcia/bcm63xx_pcmcia.h |    4 ++++
+ 2 files changed, 12 insertions(+), 1 deletion(-)
+
+--- a/drivers/pcmcia/bcm63xx_pcmcia.c
++++ b/drivers/pcmcia/bcm63xx_pcmcia.c
+@@ -237,7 +237,7 @@ static unsigned int __get_socket_status(
+               stat |= SS_XVCARD;
+       stat |= SS_POWERON;
+-      if (gpio_get_value(skt->pd->ready_gpio))
++      if (gpiod_get_value(skt->ready_gpio))
+               stat |= SS_READY;
+       return stat;
+@@ -373,6 +373,13 @@ static int bcm63xx_drv_pcmcia_probe(stru
+               goto err;
+       }
++      /* get ready gpio */
++      skt->ready_gpio = devm_gpiod_get(&pdev->dev, "ready", GPIOD_IN);
++      if (IS_ERR(skt->ready_gpio)) {
++              ret = PTR_ERR(skt->ready_gpio);
++              goto err;
++      }
++
+       /* resources are static */
+       sock->resource_ops = &pccard_static_ops;
+       sock->ops = &bcm63xx_pcmcia_operations;
+--- a/drivers/pcmcia/bcm63xx_pcmcia.h
++++ b/drivers/pcmcia/bcm63xx_pcmcia.h
+@@ -3,6 +3,7 @@
+ #include <linux/types.h>
+ #include <linux/timer.h>
++#include <linux/gpio/consumer.h>
+ #include <pcmcia/ss.h>
+ #include <bcm63xx_dev_pcmcia.h>
+@@ -55,6 +56,9 @@ struct bcm63xx_pcmcia_socket {
+       /* base address of io memory */
+       void __iomem *io_base;
++
++      /* ready gpio */
++      struct gpio_desc *ready_gpio;
+ };
+ #endif /* BCM63XX_PCMCIA_H_ */