aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2012-05-11 12:48:39 -0400
committerRalf Baechle <ralf@linux-mips.org>2012-05-21 09:31:52 -0400
commit5238f7bc356670ba702057c7de7f07909133f788 (patch)
tree44b2b896a3101e63a1d7497a60efc339e50b1dfa /drivers/gpio
parent57c8cb8f242988b8048a7058cd1edde025c6f232 (diff)
GPIO: MIPS: lantiq: move gpio-stp and gpio-ebu to the subsystem folder
Move the 2 drivers from arch/mips/lantiq/xway/ to the subsystem and make them buildable. The following 2 patches will convert the drivers to OF. Signed-off-by: John Crispin <blogic@openwrt.org> Cc: linux-kernel@vger.kernel.org Cc: linux-mips@linux-mips.org Acked-by: Grant Likely <grant.likely@secretlab.ca> Patchwork: https://patchwork.linux-mips.org/patch/3838/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/Kconfig18
-rw-r--r--drivers/gpio/Makefile2
-rw-r--r--drivers/gpio/gpio-mm-lantiq.c126
-rw-r--r--drivers/gpio/gpio-stp-xway.c152
4 files changed, 298 insertions, 0 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index e03653d69357..8fae07935cd1 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -96,6 +96,14 @@ config GPIO_EP93XX
96 depends on ARCH_EP93XX 96 depends on ARCH_EP93XX
97 select GPIO_GENERIC 97 select GPIO_GENERIC
98 98
99config GPIO_MM_LANTIQ
100 bool "Lantiq Memory mapped GPIOs"
101 depends on LANTIQ && SOC_XWAY
102 help
103 This enables support for memory mapped GPIOs on the External Bus Unit
104 (EBU) found on Lantiq SoCs. The gpios are output only as they are
105 created by attaching a 16bit latch to the bus.
106
99config GPIO_MPC5200 107config GPIO_MPC5200
100 def_bool y 108 def_bool y
101 depends on PPC_MPC52xx 109 depends on PPC_MPC52xx
@@ -306,6 +314,16 @@ config GPIO_STMPE
306 This enables support for the GPIOs found on the STMPE I/O 314 This enables support for the GPIOs found on the STMPE I/O
307 Expanders. 315 Expanders.
308 316
317config GPIO_STP_XWAY
318 bool "XWAY STP GPIOs"
319 depends on SOC_XWAY
320 help
321 This enables support for the Serial To Parallel (STP) unit found on
322 XWAY SoC. The STP allows the SoC to drive a shift registers cascade,
323 that can be up to 24 bit. This peripheral is aimed at driving leds.
324 Some of the gpios/leds can be auto updated by the soc with dsl and
325 phy status.
326
309config GPIO_TC3589X 327config GPIO_TC3589X
310 bool "TC3589X GPIOs" 328 bool "TC3589X GPIOs"
311 depends on MFD_TC3589X 329 depends on MFD_TC3589X
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 007f54bd0081..ed1c96db404b 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o
30obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o 30obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o
31obj-$(CONFIG_GPIO_MCP23S08) += gpio-mcp23s08.o 31obj-$(CONFIG_GPIO_MCP23S08) += gpio-mcp23s08.o
32obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o 32obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o
33obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o
33obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o 34obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o
34obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o 35obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o
35obj-$(CONFIG_GPIO_MSM_V1) += gpio-msm-v1.o 36obj-$(CONFIG_GPIO_MSM_V1) += gpio-msm-v1.o
@@ -49,6 +50,7 @@ obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o
49obj-$(CONFIG_GPIO_SCH) += gpio-sch.o 50obj-$(CONFIG_GPIO_SCH) += gpio-sch.o
50obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o 51obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o
51obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o 52obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o
53obj-$(CONFIG_GPIO_STP_XWAY) += gpio-stp-xway.o
52obj-$(CONFIG_GPIO_SX150X) += gpio-sx150x.o 54obj-$(CONFIG_GPIO_SX150X) += gpio-sx150x.o
53obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o 55obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o
54obj-$(CONFIG_ARCH_TEGRA) += gpio-tegra.o 56obj-$(CONFIG_ARCH_TEGRA) += gpio-tegra.o
diff --git a/drivers/gpio/gpio-mm-lantiq.c b/drivers/gpio/gpio-mm-lantiq.c
new file mode 100644
index 000000000000..b91c7f17f10f
--- /dev/null
+++ b/drivers/gpio/gpio-mm-lantiq.c
@@ -0,0 +1,126 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License version 2 as published
4 * by the Free Software Foundation.
5 *
6 * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
7 */
8
9#include <linux/init.h>
10#include <linux/export.h>
11#include <linux/types.h>
12#include <linux/platform_device.h>
13#include <linux/mutex.h>
14#include <linux/gpio.h>
15#include <linux/io.h>
16
17#include <lantiq_soc.h>
18
19/*
20 * By attaching hardware latches to the EBU it is possible to create output
21 * only gpios. This driver configures a special memory address, which when
22 * written to outputs 16 bit to the latches.
23 */
24
25#define LTQ_EBU_BUSCON 0x1e7ff /* 16 bit access, slowest timing */
26#define LTQ_EBU_WP 0x80000000 /* write protect bit */
27
28/* we keep a shadow value of the last value written to the ebu */
29static int ltq_ebu_gpio_shadow = 0x0;
30static void __iomem *ltq_ebu_gpio_membase;
31
32static void ltq_ebu_apply(void)
33{
34 unsigned long flags;
35
36 spin_lock_irqsave(&ebu_lock, flags);
37 ltq_ebu_w32(LTQ_EBU_BUSCON, LTQ_EBU_BUSCON1);
38 *((__u16 *)ltq_ebu_gpio_membase) = ltq_ebu_gpio_shadow;
39 ltq_ebu_w32(LTQ_EBU_BUSCON | LTQ_EBU_WP, LTQ_EBU_BUSCON1);
40 spin_unlock_irqrestore(&ebu_lock, flags);
41}
42
43static void ltq_ebu_set(struct gpio_chip *chip, unsigned offset, int value)
44{
45 if (value)
46 ltq_ebu_gpio_shadow |= (1 << offset);
47 else
48 ltq_ebu_gpio_shadow &= ~(1 << offset);
49 ltq_ebu_apply();
50}
51
52static int ltq_ebu_direction_output(struct gpio_chip *chip, unsigned offset,
53 int value)
54{
55 ltq_ebu_set(chip, offset, value);
56
57 return 0;
58}
59
60static struct gpio_chip ltq_ebu_chip = {
61 .label = "ltq_ebu",
62 .direction_output = ltq_ebu_direction_output,
63 .set = ltq_ebu_set,
64 .base = 72,
65 .ngpio = 16,
66 .can_sleep = 1,
67 .owner = THIS_MODULE,
68};
69
70static int ltq_ebu_probe(struct platform_device *pdev)
71{
72 int ret = 0;
73 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
74
75 if (!res) {
76 dev_err(&pdev->dev, "failed to get memory resource\n");
77 return -ENOENT;
78 }
79
80 res = devm_request_mem_region(&pdev->dev, res->start,
81 resource_size(res), dev_name(&pdev->dev));
82 if (!res) {
83 dev_err(&pdev->dev, "failed to request memory resource\n");
84 return -EBUSY;
85 }
86
87 ltq_ebu_gpio_membase = devm_ioremap_nocache(&pdev->dev, res->start,
88 resource_size(res));
89 if (!ltq_ebu_gpio_membase) {
90 dev_err(&pdev->dev, "Failed to ioremap mem region\n");
91 return -ENOMEM;
92 }
93
94 /* grab the default shadow value passed form the platform code */
95 ltq_ebu_gpio_shadow = (unsigned int) pdev->dev.platform_data;
96
97 /* tell the ebu controller which memory address we will be using */
98 ltq_ebu_w32(pdev->resource->start | 0x1, LTQ_EBU_ADDRSEL1);
99
100 /* write protect the region */
101 ltq_ebu_w32(LTQ_EBU_BUSCON | LTQ_EBU_WP, LTQ_EBU_BUSCON1);
102
103 ret = gpiochip_add(&ltq_ebu_chip);
104 if (!ret)
105 ltq_ebu_apply();
106 return ret;
107}
108
109static struct platform_driver ltq_ebu_driver = {
110 .probe = ltq_ebu_probe,
111 .driver = {
112 .name = "ltq_ebu",
113 .owner = THIS_MODULE,
114 },
115};
116
117static int __init ltq_ebu_init(void)
118{
119 int ret = platform_driver_register(&ltq_ebu_driver);
120
121 if (ret)
122 pr_info("ltq_ebu : Error registering platfom driver!");
123 return ret;
124}
125
126postcore_initcall(ltq_ebu_init);
diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c
new file mode 100644
index 000000000000..d674f1be237d
--- /dev/null
+++ b/drivers/gpio/gpio-stp-xway.c
@@ -0,0 +1,152 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License version 2 as published
4 * by the Free Software Foundation.
5 *
6 * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
7 *
8 */
9
10#include <linux/slab.h>
11#include <linux/init.h>
12#include <linux/export.h>
13#include <linux/types.h>
14#include <linux/platform_device.h>
15#include <linux/mutex.h>
16#include <linux/io.h>
17#include <linux/gpio.h>
18
19#include <lantiq_soc.h>
20
21#define LTQ_STP_CON0 0x00
22#define LTQ_STP_CON1 0x04
23#define LTQ_STP_CPU0 0x08
24#define LTQ_STP_CPU1 0x0C
25#define LTQ_STP_AR 0x10
26
27#define LTQ_STP_CON_SWU (1 << 31)
28#define LTQ_STP_2HZ 0
29#define LTQ_STP_4HZ (1 << 23)
30#define LTQ_STP_8HZ (2 << 23)
31#define LTQ_STP_10HZ (3 << 23)
32#define LTQ_STP_SPEED_MASK (0xf << 23)
33#define LTQ_STP_UPD_FPI (1 << 31)
34#define LTQ_STP_UPD_MASK (3 << 30)
35#define LTQ_STP_ADSL_SRC (3 << 24)
36
37#define LTQ_STP_GROUP0 (1 << 0)
38
39#define LTQ_STP_RISING 0
40#define LTQ_STP_FALLING (1 << 26)
41#define LTQ_STP_EDGE_MASK (1 << 26)
42
43#define ltq_stp_r32(reg) __raw_readl(ltq_stp_membase + reg)
44#define ltq_stp_w32(val, reg) __raw_writel(val, ltq_stp_membase + reg)
45#define ltq_stp_w32_mask(clear, set, reg) \
46 ltq_w32((ltq_r32(ltq_stp_membase + reg) & ~(clear)) | (set), \
47 ltq_stp_membase + (reg))
48
49static int ltq_stp_shadow = 0xffff;
50static void __iomem *ltq_stp_membase;
51
52static void ltq_stp_set(struct gpio_chip *chip, unsigned offset, int value)
53{
54 if (value)
55 ltq_stp_shadow |= (1 << offset);
56 else
57 ltq_stp_shadow &= ~(1 << offset);
58 ltq_stp_w32(ltq_stp_shadow, LTQ_STP_CPU0);
59}
60
61static int ltq_stp_direction_output(struct gpio_chip *chip, unsigned offset,
62 int value)
63{
64 ltq_stp_set(chip, offset, value);
65
66 return 0;
67}
68
69static struct gpio_chip ltq_stp_chip = {
70 .label = "ltq_stp",
71 .direction_output = ltq_stp_direction_output,
72 .set = ltq_stp_set,
73 .base = 48,
74 .ngpio = 24,
75 .can_sleep = 1,
76 .owner = THIS_MODULE,
77};
78
79static int ltq_stp_hw_init(void)
80{
81 /* sane defaults */
82 ltq_stp_w32(0, LTQ_STP_AR);
83 ltq_stp_w32(0, LTQ_STP_CPU0);
84 ltq_stp_w32(0, LTQ_STP_CPU1);
85 ltq_stp_w32(LTQ_STP_CON_SWU, LTQ_STP_CON0);
86 ltq_stp_w32(0, LTQ_STP_CON1);
87
88 /* rising or falling edge */
89 ltq_stp_w32_mask(LTQ_STP_EDGE_MASK, LTQ_STP_FALLING, LTQ_STP_CON0);
90
91 /* per default stp 15-0 are set */
92 ltq_stp_w32_mask(0, LTQ_STP_GROUP0, LTQ_STP_CON1);
93
94 /* stp are update periodically by the FPI bus */
95 ltq_stp_w32_mask(LTQ_STP_UPD_MASK, LTQ_STP_UPD_FPI, LTQ_STP_CON1);
96
97 /* set stp update speed */
98 ltq_stp_w32_mask(LTQ_STP_SPEED_MASK, LTQ_STP_8HZ, LTQ_STP_CON1);
99
100 /* tell the hardware that pin (led) 0 and 1 are controlled
101 * by the dsl arc
102 */
103 ltq_stp_w32_mask(0, LTQ_STP_ADSL_SRC, LTQ_STP_CON0);
104
105 ltq_pmu_enable(PMU_LED);
106 return 0;
107}
108
109static int __devinit ltq_stp_probe(struct platform_device *pdev)
110{
111 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
112 int ret = 0;
113
114 if (!res)
115 return -ENOENT;
116 res = devm_request_mem_region(&pdev->dev, res->start,
117 resource_size(res), dev_name(&pdev->dev));
118 if (!res) {
119 dev_err(&pdev->dev, "failed to request STP memory\n");
120 return -EBUSY;
121 }
122 ltq_stp_membase = devm_ioremap_nocache(&pdev->dev, res->start,
123 resource_size(res));
124 if (!ltq_stp_membase) {
125 dev_err(&pdev->dev, "failed to remap STP memory\n");
126 return -ENOMEM;
127 }
128 ret = gpiochip_add(&ltq_stp_chip);
129 if (!ret)
130 ret = ltq_stp_hw_init();
131
132 return ret;
133}
134
135static struct platform_driver ltq_stp_driver = {
136 .probe = ltq_stp_probe,
137 .driver = {
138 .name = "ltq_stp",
139 .owner = THIS_MODULE,
140 },
141};
142
143int __init ltq_stp_init(void)
144{
145 int ret = platform_driver_register(&ltq_stp_driver);
146
147 if (ret)
148 pr_info("ltq_stp: error registering platfom driver");
149 return ret;
150}
151
152postcore_initcall(ltq_stp_init);