aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-29 21:27:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-29 21:27:19 -0400
commit7e5b2db77b05746613516599c916a8cc2e321077 (patch)
treec3ec333ff7b77bcc8e456a3a3d19bf20f5c651b8 /drivers/gpio
parent227d1e4319ffd8729781941d92f4ae4d85beecd9 (diff)
parentc819baf31f5f91fbb06b2c93de2d5b8c8d096f3f (diff)
Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
Pull MIPS updates from Ralf Baechle: "The whole series has been sitting in -next for quite a while with no complaints. The last change to the series was before the weekend the removal of an SPI patch which Grant - even though previously acked by himself - appeared to raise objections. So I removed it until the situation is clarified. Other than that all the patches have the acks from their respective maintainers, all MIPS and x86 defconfigs are building fine and I'm not aware of any problems introduced by this series. Among the key features for this patch series is a sizable patchset for Lantiq which among other things introduces support for Lantiq's flagship product, the FALCON SOC. It also means that the opensource developers behind this patchset have overtaken Lantiq's competing inhouse development team that was working behind closed doors. Less noteworthy the ath79 patchset which adds support for a few more chip variants, cleanups and fixes. Finally the usual dose of tweaking of generic code." Fix up trivial conflicts in arch/mips/lantiq/xway/gpio_{ebu,stp}.c where printk spelling fixes clashed with file move and eventual removal of the printk. * 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: (81 commits) MIPS: lantiq: remove orphaned code MIPS: Remove all -Wall and almost all -Werror usage from arch/mips. MIPS: lantiq: implement support for FALCON soc MTD: MIPS: lantiq: verify that the NOR interface is available on falcon soc MTD: MIPS: lantiq: implement OF support watchdog: MIPS: lantiq: implement OF support and minor fixes SERIAL: MIPS: lantiq: implement OF support GPIO: MIPS: lantiq: convert gpio-stp-xway to OF GPIO: MIPS: lantiq: convert gpio-mm-lantiq to OF and of_mm_gpio GPIO: MIPS: lantiq: move gpio-stp and gpio-ebu to the subsystem folder MIPS: pci: convert lantiq driver to OF MIPS: lantiq: convert dma to platform driver MIPS: lantiq: implement support for clkdev api MIPS: lantiq: drop ltq_gpio_request() and gpio_to_irq() OF: MIPS: lantiq: implement irq_domain support OF: MIPS: lantiq: implement OF support MIPS: lantiq: drop mips_machine support OF: PCI: const usage needed by MIPS MIPS: Cavium: Remove smp_reserve_lock. MIPS: Move cache setup to setup_arch(). ...
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.c158
-rw-r--r--drivers/gpio/gpio-stp-xway.c301
4 files changed, 479 insertions, 0 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 0356099ae040..c4067d0141f7 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -114,6 +114,14 @@ config GPIO_EP93XX
114 depends on ARCH_EP93XX 114 depends on ARCH_EP93XX
115 select GPIO_GENERIC 115 select GPIO_GENERIC
116 116
117config GPIO_MM_LANTIQ
118 bool "Lantiq Memory mapped GPIOs"
119 depends on LANTIQ && SOC_XWAY
120 help
121 This enables support for memory mapped GPIOs on the External Bus Unit
122 (EBU) found on Lantiq SoCs. The gpios are output only as they are
123 created by attaching a 16bit latch to the bus.
124
117config GPIO_MPC5200 125config GPIO_MPC5200
118 def_bool y 126 def_bool y
119 depends on PPC_MPC52xx 127 depends on PPC_MPC52xx
@@ -358,6 +366,16 @@ config GPIO_STMPE
358 This enables support for the GPIOs found on the STMPE I/O 366 This enables support for the GPIOs found on the STMPE I/O
359 Expanders. 367 Expanders.
360 368
369config GPIO_STP_XWAY
370 bool "XWAY STP GPIOs"
371 depends on SOC_XWAY
372 help
373 This enables support for the Serial To Parallel (STP) unit found on
374 XWAY SoC. The STP allows the SoC to drive a shift registers cascade,
375 that can be up to 24 bit. This peripheral is aimed at driving leds.
376 Some of the gpios/leds can be auto updated by the soc with dsl and
377 phy status.
378
361config GPIO_TC3589X 379config GPIO_TC3589X
362 bool "TC3589X GPIOs" 380 bool "TC3589X GPIOs"
363 depends on MFD_TC3589X 381 depends on MFD_TC3589X
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index fde36e5e3537..0f55662002c3 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o
33obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o 33obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o
34obj-$(CONFIG_GPIO_MCP23S08) += gpio-mcp23s08.o 34obj-$(CONFIG_GPIO_MCP23S08) += gpio-mcp23s08.o
35obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o 35obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o
36obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o
36obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o 37obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o
37obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o 38obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o
38obj-$(CONFIG_GPIO_MSIC) += gpio-msic.o 39obj-$(CONFIG_GPIO_MSIC) += gpio-msic.o
@@ -54,6 +55,7 @@ obj-$(CONFIG_GPIO_SCH) += gpio-sch.o
54obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o 55obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o
55obj-$(CONFIG_GPIO_STA2X11) += gpio-sta2x11.o 56obj-$(CONFIG_GPIO_STA2X11) += gpio-sta2x11.o
56obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o 57obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o
58obj-$(CONFIG_GPIO_STP_XWAY) += gpio-stp-xway.o
57obj-$(CONFIG_GPIO_SX150X) += gpio-sx150x.o 59obj-$(CONFIG_GPIO_SX150X) += gpio-sx150x.o
58obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o 60obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o
59obj-$(CONFIG_ARCH_TEGRA) += gpio-tegra.o 61obj-$(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..2983dfbd0668
--- /dev/null
+++ b/drivers/gpio/gpio-mm-lantiq.c
@@ -0,0 +1,158 @@
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) 2012 John Crispin <blogic@openwrt.org>
7 */
8
9#include <linux/init.h>
10#include <linux/module.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/of.h>
16#include <linux/of_gpio.h>
17#include <linux/io.h>
18#include <linux/slab.h>
19
20#include <lantiq_soc.h>
21
22/*
23 * By attaching hardware latches to the EBU it is possible to create output
24 * only gpios. This driver configures a special memory address, which when
25 * written to outputs 16 bit to the latches.
26 */
27
28#define LTQ_EBU_BUSCON 0x1e7ff /* 16 bit access, slowest timing */
29#define LTQ_EBU_WP 0x80000000 /* write protect bit */
30
31struct ltq_mm {
32 struct of_mm_gpio_chip mmchip;
33 u16 shadow; /* shadow the latches state */
34};
35
36/**
37 * ltq_mm_apply() - write the shadow value to the ebu address.
38 * @chip: Pointer to our private data structure.
39 *
40 * Write the shadow value to the EBU to set the gpios. We need to set the
41 * global EBU lock to make sure that PCI/MTD dont break.
42 */
43static void ltq_mm_apply(struct ltq_mm *chip)
44{
45 unsigned long flags;
46
47 spin_lock_irqsave(&ebu_lock, flags);
48 ltq_ebu_w32(LTQ_EBU_BUSCON, LTQ_EBU_BUSCON1);
49 __raw_writew(chip->shadow, chip->mmchip.regs);
50 ltq_ebu_w32(LTQ_EBU_BUSCON | LTQ_EBU_WP, LTQ_EBU_BUSCON1);
51 spin_unlock_irqrestore(&ebu_lock, flags);
52}
53
54/**
55 * ltq_mm_set() - gpio_chip->set - set gpios.
56 * @gc: Pointer to gpio_chip device structure.
57 * @gpio: GPIO signal number.
58 * @val: Value to be written to specified signal.
59 *
60 * Set the shadow value and call ltq_mm_apply.
61 */
62static void ltq_mm_set(struct gpio_chip *gc, unsigned offset, int value)
63{
64 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
65 struct ltq_mm *chip =
66 container_of(mm_gc, struct ltq_mm, mmchip);
67
68 if (value)
69 chip->shadow |= (1 << offset);
70 else
71 chip->shadow &= ~(1 << offset);
72 ltq_mm_apply(chip);
73}
74
75/**
76 * ltq_mm_dir_out() - gpio_chip->dir_out - set gpio direction.
77 * @gc: Pointer to gpio_chip device structure.
78 * @gpio: GPIO signal number.
79 * @val: Value to be written to specified signal.
80 *
81 * Same as ltq_mm_set, always returns 0.
82 */
83static int ltq_mm_dir_out(struct gpio_chip *gc, unsigned offset, int value)
84{
85 ltq_mm_set(gc, offset, value);
86
87 return 0;
88}
89
90/**
91 * ltq_mm_save_regs() - Set initial values of GPIO pins
92 * @mm_gc: pointer to memory mapped GPIO chip structure
93 */
94static void ltq_mm_save_regs(struct of_mm_gpio_chip *mm_gc)
95{
96 struct ltq_mm *chip =
97 container_of(mm_gc, struct ltq_mm, mmchip);
98
99 /* tell the ebu controller which memory address we will be using */
100 ltq_ebu_w32(CPHYSADDR(chip->mmchip.regs) | 0x1, LTQ_EBU_ADDRSEL1);
101
102 ltq_mm_apply(chip);
103}
104
105static int ltq_mm_probe(struct platform_device *pdev)
106{
107 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
108 struct ltq_mm *chip;
109 const __be32 *shadow;
110 int ret = 0;
111
112 if (!res) {
113 dev_err(&pdev->dev, "failed to get memory resource\n");
114 return -ENOENT;
115 }
116
117 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
118 if (!chip)
119 return -ENOMEM;
120
121 chip->mmchip.gc.ngpio = 16;
122 chip->mmchip.gc.label = "gpio-mm-ltq";
123 chip->mmchip.gc.direction_output = ltq_mm_dir_out;
124 chip->mmchip.gc.set = ltq_mm_set;
125 chip->mmchip.save_regs = ltq_mm_save_regs;
126
127 /* store the shadow value if one was passed by the devicetree */
128 shadow = of_get_property(pdev->dev.of_node, "lantiq,shadow", NULL);
129 if (shadow)
130 chip->shadow = be32_to_cpu(*shadow);
131
132 ret = of_mm_gpiochip_add(pdev->dev.of_node, &chip->mmchip);
133 if (ret)
134 kfree(chip);
135 return ret;
136}
137
138static const struct of_device_id ltq_mm_match[] = {
139 { .compatible = "lantiq,gpio-mm" },
140 {},
141};
142MODULE_DEVICE_TABLE(of, ltq_mm_match);
143
144static struct platform_driver ltq_mm_driver = {
145 .probe = ltq_mm_probe,
146 .driver = {
147 .name = "gpio-mm-ltq",
148 .owner = THIS_MODULE,
149 .of_match_table = ltq_mm_match,
150 },
151};
152
153static int __init ltq_mm_init(void)
154{
155 return platform_driver_register(&ltq_mm_driver);
156}
157
158subsys_initcall(ltq_mm_init);
diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c
new file mode 100644
index 000000000000..e35096bf3cfb
--- /dev/null
+++ b/drivers/gpio/gpio-stp-xway.c
@@ -0,0 +1,301 @@
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) 2012 John Crispin <blogic@openwrt.org>
7 *
8 */
9
10#include <linux/slab.h>
11#include <linux/init.h>
12#include <linux/module.h>
13#include <linux/types.h>
14#include <linux/of_platform.h>
15#include <linux/mutex.h>
16#include <linux/gpio.h>
17#include <linux/io.h>
18#include <linux/of_gpio.h>
19#include <linux/clk.h>
20#include <linux/err.h>
21
22#include <lantiq_soc.h>
23
24/*
25 * The Serial To Parallel (STP) is found on MIPS based Lantiq socs. It is a
26 * peripheral controller used to drive external shift register cascades. At most
27 * 3 groups of 8 bits can be driven. The hardware is able to allow the DSL modem
28 * to drive the 2 LSBs of the cascade automatically.
29 */
30
31/* control register 0 */
32#define XWAY_STP_CON0 0x00
33/* control register 1 */
34#define XWAY_STP_CON1 0x04
35/* data register 0 */
36#define XWAY_STP_CPU0 0x08
37/* data register 1 */
38#define XWAY_STP_CPU1 0x0C
39/* access register */
40#define XWAY_STP_AR 0x10
41
42/* software or hardware update select bit */
43#define XWAY_STP_CON_SWU BIT(31)
44
45/* automatic update rates */
46#define XWAY_STP_2HZ 0
47#define XWAY_STP_4HZ BIT(23)
48#define XWAY_STP_8HZ BIT(24)
49#define XWAY_STP_10HZ (BIT(24) | BIT(23))
50#define XWAY_STP_SPEED_MASK (0xf << 23)
51
52/* clock source for automatic update */
53#define XWAY_STP_UPD_FPI BIT(31)
54#define XWAY_STP_UPD_MASK (BIT(31) | BIT(30))
55
56/* let the adsl core drive the 2 LSBs */
57#define XWAY_STP_ADSL_SHIFT 24
58#define XWAY_STP_ADSL_MASK 0x3
59
60/* 2 groups of 3 bits can be driven by the phys */
61#define XWAY_STP_PHY_MASK 0x3
62#define XWAY_STP_PHY1_SHIFT 27
63#define XWAY_STP_PHY2_SHIFT 15
64
65/* STP has 3 groups of 8 bits */
66#define XWAY_STP_GROUP0 BIT(0)
67#define XWAY_STP_GROUP1 BIT(1)
68#define XWAY_STP_GROUP2 BIT(2)
69#define XWAY_STP_GROUP_MASK (0x7)
70
71/* Edge configuration bits */
72#define XWAY_STP_FALLING BIT(26)
73#define XWAY_STP_EDGE_MASK BIT(26)
74
75#define xway_stp_r32(m, reg) __raw_readl(m + reg)
76#define xway_stp_w32(m, val, reg) __raw_writel(val, m + reg)
77#define xway_stp_w32_mask(m, clear, set, reg) \
78 ltq_w32((ltq_r32(m + reg) & ~(clear)) | (set), \
79 m + reg)
80
81struct xway_stp {
82 struct gpio_chip gc;
83 void __iomem *virt;
84 u32 edge; /* rising or falling edge triggered shift register */
85 u16 shadow; /* shadow the shift registers state */
86 u8 groups; /* we can drive 1-3 groups of 8bit each */
87 u8 dsl; /* the 2 LSBs can be driven by the dsl core */
88 u8 phy1; /* 3 bits can be driven by phy1 */
89 u8 phy2; /* 3 bits can be driven by phy2 */
90 u8 reserved; /* mask out the hw driven bits in gpio_request */
91};
92
93/**
94 * xway_stp_set() - gpio_chip->set - set gpios.
95 * @gc: Pointer to gpio_chip device structure.
96 * @gpio: GPIO signal number.
97 * @val: Value to be written to specified signal.
98 *
99 * Set the shadow value and call ltq_ebu_apply.
100 */
101static void xway_stp_set(struct gpio_chip *gc, unsigned gpio, int val)
102{
103 struct xway_stp *chip =
104 container_of(gc, struct xway_stp, gc);
105
106 if (val)
107 chip->shadow |= BIT(gpio);
108 else
109 chip->shadow &= ~BIT(gpio);
110 xway_stp_w32(chip->virt, chip->shadow, XWAY_STP_CPU0);
111 xway_stp_w32_mask(chip->virt, 0, XWAY_STP_CON_SWU, XWAY_STP_CON0);
112}
113
114/**
115 * xway_stp_dir_out() - gpio_chip->dir_out - set gpio direction.
116 * @gc: Pointer to gpio_chip device structure.
117 * @gpio: GPIO signal number.
118 * @val: Value to be written to specified signal.
119 *
120 * Same as xway_stp_set, always returns 0.
121 */
122static int xway_stp_dir_out(struct gpio_chip *gc, unsigned gpio, int val)
123{
124 xway_stp_set(gc, gpio, val);
125
126 return 0;
127}
128
129/**
130 * xway_stp_request() - gpio_chip->request
131 * @gc: Pointer to gpio_chip device structure.
132 * @gpio: GPIO signal number.
133 *
134 * We mask out the HW driven pins
135 */
136static int xway_stp_request(struct gpio_chip *gc, unsigned gpio)
137{
138 struct xway_stp *chip =
139 container_of(gc, struct xway_stp, gc);
140
141 if ((gpio < 8) && (chip->reserved & BIT(gpio))) {
142 dev_err(gc->dev, "GPIO %d is driven by hardware\n", gpio);
143 return -ENODEV;
144 }
145
146 return 0;
147}
148
149/**
150 * xway_stp_hw_init() - Configure the STP unit and enable the clock gate
151 * @virt: pointer to the remapped register range
152 */
153static int xway_stp_hw_init(struct xway_stp *chip)
154{
155 /* sane defaults */
156 xway_stp_w32(chip->virt, 0, XWAY_STP_AR);
157 xway_stp_w32(chip->virt, 0, XWAY_STP_CPU0);
158 xway_stp_w32(chip->virt, 0, XWAY_STP_CPU1);
159 xway_stp_w32(chip->virt, XWAY_STP_CON_SWU, XWAY_STP_CON0);
160 xway_stp_w32(chip->virt, 0, XWAY_STP_CON1);
161
162 /* apply edge trigger settings for the shift register */
163 xway_stp_w32_mask(chip->virt, XWAY_STP_EDGE_MASK,
164 chip->edge, XWAY_STP_CON0);
165
166 /* apply led group settings */
167 xway_stp_w32_mask(chip->virt, XWAY_STP_GROUP_MASK,
168 chip->groups, XWAY_STP_CON1);
169
170 /* tell the hardware which pins are controlled by the dsl modem */
171 xway_stp_w32_mask(chip->virt,
172 XWAY_STP_ADSL_MASK << XWAY_STP_ADSL_SHIFT,
173 chip->dsl << XWAY_STP_ADSL_SHIFT,
174 XWAY_STP_CON0);
175
176 /* tell the hardware which pins are controlled by the phys */
177 xway_stp_w32_mask(chip->virt,
178 XWAY_STP_PHY_MASK << XWAY_STP_PHY1_SHIFT,
179 chip->phy1 << XWAY_STP_PHY1_SHIFT,
180 XWAY_STP_CON0);
181 xway_stp_w32_mask(chip->virt,
182 XWAY_STP_PHY_MASK << XWAY_STP_PHY2_SHIFT,
183 chip->phy2 << XWAY_STP_PHY2_SHIFT,
184 XWAY_STP_CON1);
185
186 /* mask out the hw driven bits in gpio_request */
187 chip->reserved = (chip->phy2 << 5) | (chip->phy1 << 2) | chip->dsl;
188
189 /*
190 * if we have pins that are driven by hw, we need to tell the stp what
191 * clock to use as a timer.
192 */
193 if (chip->reserved)
194 xway_stp_w32_mask(chip->virt, XWAY_STP_UPD_MASK,
195 XWAY_STP_UPD_FPI, XWAY_STP_CON1);
196
197 return 0;
198}
199
200static int __devinit xway_stp_probe(struct platform_device *pdev)
201{
202 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
203 const __be32 *shadow, *groups, *dsl, *phy;
204 struct xway_stp *chip;
205 struct clk *clk;
206 int ret = 0;
207
208 if (!res) {
209 dev_err(&pdev->dev, "failed to request STP resource\n");
210 return -ENOENT;
211 }
212
213 chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
214 if (!chip)
215 return -ENOMEM;
216
217 chip->virt = devm_request_and_ioremap(&pdev->dev, res);
218 if (!chip->virt) {
219 dev_err(&pdev->dev, "failed to remap STP memory\n");
220 return -ENOMEM;
221 }
222 chip->gc.dev = &pdev->dev;
223 chip->gc.label = "stp-xway";
224 chip->gc.direction_output = xway_stp_dir_out;
225 chip->gc.set = xway_stp_set;
226 chip->gc.request = xway_stp_request;
227 chip->gc.base = -1;
228 chip->gc.owner = THIS_MODULE;
229
230 /* store the shadow value if one was passed by the devicetree */
231 shadow = of_get_property(pdev->dev.of_node, "lantiq,shadow", NULL);
232 if (shadow)
233 chip->shadow = be32_to_cpu(*shadow);
234
235 /* find out which gpio groups should be enabled */
236 groups = of_get_property(pdev->dev.of_node, "lantiq,groups", NULL);
237 if (groups)
238 chip->groups = be32_to_cpu(*groups) & XWAY_STP_GROUP_MASK;
239 else
240 chip->groups = XWAY_STP_GROUP0;
241 chip->gc.ngpio = fls(chip->groups) * 8;
242
243 /* find out which gpios are controlled by the dsl core */
244 dsl = of_get_property(pdev->dev.of_node, "lantiq,dsl", NULL);
245 if (dsl)
246 chip->dsl = be32_to_cpu(*dsl) & XWAY_STP_ADSL_MASK;
247
248 /* find out which gpios are controlled by the phys */
249 if (of_machine_is_compatible("lantiq,ar9") ||
250 of_machine_is_compatible("lantiq,gr9") ||
251 of_machine_is_compatible("lantiq,vr9")) {
252 phy = of_get_property(pdev->dev.of_node, "lantiq,phy1", NULL);
253 if (phy)
254 chip->phy1 = be32_to_cpu(*phy) & XWAY_STP_PHY_MASK;
255 phy = of_get_property(pdev->dev.of_node, "lantiq,phy2", NULL);
256 if (phy)
257 chip->phy2 = be32_to_cpu(*phy) & XWAY_STP_PHY_MASK;
258 }
259
260 /* check which edge trigger we should use, default to a falling edge */
261 if (!of_find_property(pdev->dev.of_node, "lantiq,rising", NULL))
262 chip->edge = XWAY_STP_FALLING;
263
264 clk = clk_get(&pdev->dev, NULL);
265 if (IS_ERR(clk)) {
266 dev_err(&pdev->dev, "Failed to get clock\n");
267 return PTR_ERR(clk);
268 }
269 clk_enable(clk);
270
271 ret = xway_stp_hw_init(chip);
272 if (!ret)
273 ret = gpiochip_add(&chip->gc);
274
275 if (!ret)
276 dev_info(&pdev->dev, "Init done\n");
277
278 return ret;
279}
280
281static const struct of_device_id xway_stp_match[] = {
282 { .compatible = "lantiq,gpio-stp-xway" },
283 {},
284};
285MODULE_DEVICE_TABLE(of, xway_stp_match);
286
287static struct platform_driver xway_stp_driver = {
288 .probe = xway_stp_probe,
289 .driver = {
290 .name = "gpio-stp-xway",
291 .owner = THIS_MODULE,
292 .of_match_table = xway_stp_match,
293 },
294};
295
296int __init xway_stp_init(void)
297{
298 return platform_driver_register(&xway_stp_driver);
299}
300
301subsys_initcall(xway_stp_init);