blob: 8411985af9ff89addd5ae0cc04ff365842961c5d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-sa1100/neponset.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 */
Russell King9590e8982012-01-24 22:36:47 +00004#include <linux/err.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <linux/ioport.h>
Russell Kingced8d212012-01-24 22:22:18 +00007#include <linux/irq.h>
Russell King92e617d2012-01-24 22:13:00 +00008#include <linux/kernel.h>
Russell Kingae14c2e2012-01-24 22:10:02 +00009#include <linux/module.h>
Russell King6920b5a2012-09-21 10:18:58 +010010#include <linux/platform_data/sa11x0-serial.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010011#include <linux/platform_device.h>
Russell King51f93392012-01-24 23:29:47 +000012#include <linux/pm.h>
Russell King92e617d2012-01-24 22:13:00 +000013#include <linux/serial_core.h>
Russell Kingae14c2e2012-01-24 22:10:02 +000014#include <linux/slab.h>
Arnd Bergmannb70661c2015-02-25 16:31:57 +010015#include <linux/smc91x.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/mach-types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/mach/map.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/hardware/sa1111.h>
20#include <asm/sizes.h>
21
Russell King92e617d2012-01-24 22:13:00 +000022#include <mach/hardware.h>
23#include <mach/assabet.h>
24#include <mach/neponset.h>
Rob Herringf314f332012-02-24 00:06:51 +010025#include <mach/irqs.h>
Russell King92e617d2012-01-24 22:13:00 +000026
Russell Kingced8d212012-01-24 22:22:18 +000027#define NEP_IRQ_SMC91X 0
28#define NEP_IRQ_USAR 1
29#define NEP_IRQ_SA1111 2
30#define NEP_IRQ_NR 3
31
Russell Kingf942b0f2012-01-29 11:19:06 +000032#define WHOAMI 0x00
33#define LEDS 0x10
34#define SWPK 0x20
35#define IRR 0x24
36#define KP_Y_IN 0x80
37#define KP_X_OUT 0x90
38#define NCR_0 0xa0
39#define MDM_CTL_0 0xb0
40#define MDM_CTL_1 0xb4
41#define AUD_CTL 0xc0
42
43#define IRR_ETHERNET (1 << 0)
44#define IRR_USAR (1 << 1)
45#define IRR_SA1111 (1 << 2)
46
47#define MDM_CTL0_RTS1 (1 << 0)
48#define MDM_CTL0_DTR1 (1 << 1)
49#define MDM_CTL0_RTS2 (1 << 2)
50#define MDM_CTL0_DTR2 (1 << 3)
51
52#define MDM_CTL1_CTS1 (1 << 0)
53#define MDM_CTL1_DSR1 (1 << 1)
54#define MDM_CTL1_DCD1 (1 << 2)
55#define MDM_CTL1_CTS2 (1 << 3)
56#define MDM_CTL1_DSR2 (1 << 4)
57#define MDM_CTL1_DCD2 (1 << 5)
58
59#define AUD_SEL_1341 (1 << 0)
60#define AUD_MUTE_1341 (1 << 1)
61
Russell Kingbab50a32012-01-26 11:50:23 +000062extern void sa1110_mb_disable(void);
63
Russell Kingae14c2e2012-01-24 22:10:02 +000064struct neponset_drvdata {
Russell Kingf942b0f2012-01-29 11:19:06 +000065 void __iomem *base;
Russell King9590e8982012-01-24 22:36:47 +000066 struct platform_device *sa1111;
67 struct platform_device *smc91x;
Russell Kingced8d212012-01-24 22:22:18 +000068 unsigned irq_base;
Russell Kingae14c2e2012-01-24 22:10:02 +000069#ifdef CONFIG_PM_SLEEP
70 u32 ncr0;
71 u32 mdm_ctl_0;
72#endif
73};
74
Russell Kingf942b0f2012-01-29 11:19:06 +000075static void __iomem *nep_base;
76
Russell King6ad1b612012-01-16 09:31:47 +000077void neponset_ncr_frob(unsigned int mask, unsigned int val)
78{
Russell Kingf942b0f2012-01-29 11:19:06 +000079 void __iomem *base = nep_base;
Russell King6ad1b612012-01-16 09:31:47 +000080
Russell Kingf942b0f2012-01-29 11:19:06 +000081 if (base) {
82 unsigned long flags;
83 unsigned v;
84
85 local_irq_save(flags);
86 v = readb_relaxed(base + NCR_0);
87 writeb_relaxed((v & ~mask) | val, base + NCR_0);
88 local_irq_restore(flags);
89 } else {
90 WARN(1, "nep_base unset\n");
91 }
Russell King6ad1b612012-01-16 09:31:47 +000092}
Russell Kingef0c1482012-05-25 08:41:53 +010093EXPORT_SYMBOL(neponset_ncr_frob);
Russell King6ad1b612012-01-16 09:31:47 +000094
Linus Torvalds1da177e2005-04-16 15:20:36 -070095static void neponset_set_mctrl(struct uart_port *port, u_int mctrl)
96{
Russell Kingf942b0f2012-01-29 11:19:06 +000097 void __iomem *base = nep_base;
98 u_int mdm_ctl0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
Russell Kingf942b0f2012-01-29 11:19:06 +0000100 if (!base)
101 return;
102
103 mdm_ctl0 = readb_relaxed(base + MDM_CTL_0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 if (port->mapbase == _Ser1UTCR0) {
105 if (mctrl & TIOCM_RTS)
106 mdm_ctl0 &= ~MDM_CTL0_RTS2;
107 else
108 mdm_ctl0 |= MDM_CTL0_RTS2;
109
110 if (mctrl & TIOCM_DTR)
111 mdm_ctl0 &= ~MDM_CTL0_DTR2;
112 else
113 mdm_ctl0 |= MDM_CTL0_DTR2;
114 } else if (port->mapbase == _Ser3UTCR0) {
115 if (mctrl & TIOCM_RTS)
116 mdm_ctl0 &= ~MDM_CTL0_RTS1;
117 else
118 mdm_ctl0 |= MDM_CTL0_RTS1;
119
120 if (mctrl & TIOCM_DTR)
121 mdm_ctl0 &= ~MDM_CTL0_DTR1;
122 else
123 mdm_ctl0 |= MDM_CTL0_DTR1;
124 }
125
Russell Kingf942b0f2012-01-29 11:19:06 +0000126 writeb_relaxed(mdm_ctl0, base + MDM_CTL_0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127}
128
129static u_int neponset_get_mctrl(struct uart_port *port)
130{
Russell Kingf942b0f2012-01-29 11:19:06 +0000131 void __iomem *base = nep_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
Russell Kingf942b0f2012-01-29 11:19:06 +0000133 u_int mdm_ctl1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
Russell Kingf942b0f2012-01-29 11:19:06 +0000135 if (!base)
136 return ret;
137
138 mdm_ctl1 = readb_relaxed(base + MDM_CTL_1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 if (port->mapbase == _Ser1UTCR0) {
140 if (mdm_ctl1 & MDM_CTL1_DCD2)
141 ret &= ~TIOCM_CD;
142 if (mdm_ctl1 & MDM_CTL1_CTS2)
143 ret &= ~TIOCM_CTS;
144 if (mdm_ctl1 & MDM_CTL1_DSR2)
145 ret &= ~TIOCM_DSR;
146 } else if (port->mapbase == _Ser3UTCR0) {
147 if (mdm_ctl1 & MDM_CTL1_DCD1)
148 ret &= ~TIOCM_CD;
149 if (mdm_ctl1 & MDM_CTL1_CTS1)
150 ret &= ~TIOCM_CTS;
151 if (mdm_ctl1 & MDM_CTL1_DSR1)
152 ret &= ~TIOCM_DSR;
153 }
154
155 return ret;
156}
157
Greg Kroah-Hartman351a1022012-12-21 14:02:24 -0800158static struct sa1100_port_fns neponset_port_fns = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 .set_mctrl = neponset_set_mctrl,
160 .get_mctrl = neponset_get_mctrl,
161};
162
Russell King71045522012-01-16 00:17:41 +0000163/*
Russell King92e617d2012-01-24 22:13:00 +0000164 * Install handler for Neponset IRQ. Note that we have to loop here
165 * since the ETHERNET and USAR IRQs are level based, and we need to
166 * ensure that the IRQ signal is deasserted before returning. This
167 * is rather unfortunate.
168 */
Thomas Gleixnerbd0b9ac2015-09-14 10:42:37 +0200169static void neponset_irq_handler(struct irq_desc *desc)
Russell King92e617d2012-01-24 22:13:00 +0000170{
Russell Kingced8d212012-01-24 22:22:18 +0000171 struct neponset_drvdata *d = irq_desc_get_handler_data(desc);
Russell King92e617d2012-01-24 22:13:00 +0000172 unsigned int irr;
173
174 while (1) {
175 /*
176 * Acknowledge the parent IRQ.
177 */
178 desc->irq_data.chip->irq_ack(&desc->irq_data);
179
180 /*
181 * Read the interrupt reason register. Let's have all
182 * active IRQ bits high. Note: there is a typo in the
183 * Neponset user's guide for the SA1111 IRR level.
184 */
Russell Kingf942b0f2012-01-29 11:19:06 +0000185 irr = readb_relaxed(d->base + IRR);
186 irr ^= IRR_ETHERNET | IRR_USAR;
Russell King92e617d2012-01-24 22:13:00 +0000187
188 if ((irr & (IRR_ETHERNET | IRR_USAR | IRR_SA1111)) == 0)
189 break;
190
191 /*
192 * Since there is no individual mask, we have to
193 * mask the parent IRQ. This is safe, since we'll
194 * recheck the register for any pending IRQs.
195 */
196 if (irr & (IRR_ETHERNET | IRR_USAR)) {
197 desc->irq_data.chip->irq_mask(&desc->irq_data);
198
199 /*
200 * Ack the interrupt now to prevent re-entering
201 * this neponset handler. Again, this is safe
202 * since we'll check the IRR register prior to
203 * leaving.
204 */
205 desc->irq_data.chip->irq_ack(&desc->irq_data);
206
Russell Kingced8d212012-01-24 22:22:18 +0000207 if (irr & IRR_ETHERNET)
208 generic_handle_irq(d->irq_base + NEP_IRQ_SMC91X);
Russell King92e617d2012-01-24 22:13:00 +0000209
Russell Kingced8d212012-01-24 22:22:18 +0000210 if (irr & IRR_USAR)
211 generic_handle_irq(d->irq_base + NEP_IRQ_USAR);
Russell King92e617d2012-01-24 22:13:00 +0000212
213 desc->irq_data.chip->irq_unmask(&desc->irq_data);
214 }
215
Russell Kingced8d212012-01-24 22:22:18 +0000216 if (irr & IRR_SA1111)
217 generic_handle_irq(d->irq_base + NEP_IRQ_SA1111);
Russell King92e617d2012-01-24 22:13:00 +0000218 }
219}
220
Russell Kingced8d212012-01-24 22:22:18 +0000221/* Yes, we really do not have any kind of masking or unmasking */
Russell King71045522012-01-16 00:17:41 +0000222static void nochip_noop(struct irq_data *irq)
223{
224}
225
226static struct irq_chip nochip = {
227 .name = "neponset",
228 .irq_ack = nochip_noop,
229 .irq_mask = nochip_noop,
230 .irq_unmask = nochip_noop,
231};
232
Russell King92e617d2012-01-24 22:13:00 +0000233static struct sa1111_platform_data sa1111_info = {
Russell King07be45f2012-01-26 13:34:21 +0000234 .disable_devs = SA1111_DEVID_PS2_MSE,
Russell King92e617d2012-01-24 22:13:00 +0000235};
236
Greg Kroah-Hartman351a1022012-12-21 14:02:24 -0800237static int neponset_probe(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238{
Russell Kingae14c2e2012-01-24 22:10:02 +0000239 struct neponset_drvdata *d;
Russell Kingf942b0f2012-01-29 11:19:06 +0000240 struct resource *nep_res, *sa1111_res, *smc91x_res;
Russell Kingced8d212012-01-24 22:22:18 +0000241 struct resource sa1111_resources[] = {
242 DEFINE_RES_MEM(0x40000000, SZ_8K),
243 { .flags = IORESOURCE_IRQ },
244 };
Russell King9590e8982012-01-24 22:36:47 +0000245 struct platform_device_info sa1111_devinfo = {
246 .parent = &dev->dev,
247 .name = "sa1111",
248 .id = 0,
249 .res = sa1111_resources,
250 .num_res = ARRAY_SIZE(sa1111_resources),
251 .data = &sa1111_info,
252 .size_data = sizeof(sa1111_info),
253 .dma_mask = 0xffffffffUL,
254 };
Russell Kingced8d212012-01-24 22:22:18 +0000255 struct resource smc91x_resources[] = {
256 DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS,
257 0x02000000, "smc91x-regs"),
258 DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS + 0x02000000,
259 0x02000000, "smc91x-attrib"),
260 { .flags = IORESOURCE_IRQ },
261 };
Arnd Bergmannb70661c2015-02-25 16:31:57 +0100262 struct smc91x_platdata smc91x_platdata = {
263 .flags = SMC91X_USE_8BIT | SMC91X_IO_SHIFT_2 | SMC91X_NOWAIT,
264 };
Russell King9590e8982012-01-24 22:36:47 +0000265 struct platform_device_info smc91x_devinfo = {
266 .parent = &dev->dev,
267 .name = "smc91x",
268 .id = 0,
269 .res = smc91x_resources,
270 .num_res = ARRAY_SIZE(smc91x_resources),
Arnd Bergmann04b91702015-03-04 23:39:18 +0100271 .data = &smc91x_platdata,
272 .size_data = sizeof(smc91x_platdata),
Russell King9590e8982012-01-24 22:36:47 +0000273 };
Russell Kingb6bdfcf2012-01-24 23:05:08 +0000274 int ret, irq;
275
Russell Kingf942b0f2012-01-29 11:19:06 +0000276 if (nep_base)
277 return -EBUSY;
278
Russell Kingb6bdfcf2012-01-24 23:05:08 +0000279 irq = ret = platform_get_irq(dev, 0);
280 if (ret < 0)
281 goto err_alloc;
Russell Kingae14c2e2012-01-24 22:10:02 +0000282
Russell Kingf942b0f2012-01-29 11:19:06 +0000283 nep_res = platform_get_resource(dev, IORESOURCE_MEM, 0);
Russell Kingd2e539a2012-01-24 23:17:37 +0000284 smc91x_res = platform_get_resource(dev, IORESOURCE_MEM, 1);
285 sa1111_res = platform_get_resource(dev, IORESOURCE_MEM, 2);
Russell Kingf942b0f2012-01-29 11:19:06 +0000286 if (!nep_res || !smc91x_res || !sa1111_res) {
Russell Kingd2e539a2012-01-24 23:17:37 +0000287 ret = -ENXIO;
288 goto err_alloc;
289 }
290
Russell Kingae14c2e2012-01-24 22:10:02 +0000291 d = kzalloc(sizeof(*d), GFP_KERNEL);
292 if (!d) {
293 ret = -ENOMEM;
294 goto err_alloc;
295 }
296
Russell Kingf942b0f2012-01-29 11:19:06 +0000297 d->base = ioremap(nep_res->start, SZ_4K);
298 if (!d->base) {
299 ret = -ENOMEM;
300 goto err_ioremap;
301 }
302
303 if (readb_relaxed(d->base + WHOAMI) != 0x11) {
304 dev_warn(&dev->dev, "Neponset board detected, but wrong ID: %02x\n",
305 readb_relaxed(d->base + WHOAMI));
306 ret = -ENODEV;
307 goto err_id;
308 }
309
Russell Kingced8d212012-01-24 22:22:18 +0000310 ret = irq_alloc_descs(-1, IRQ_BOARD_START, NEP_IRQ_NR, -1);
311 if (ret <= 0) {
312 dev_err(&dev->dev, "unable to allocate %u irqs: %d\n",
313 NEP_IRQ_NR, ret);
314 if (ret == 0)
315 ret = -ENOMEM;
316 goto err_irq_alloc;
317 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
Russell Kingced8d212012-01-24 22:22:18 +0000319 d->irq_base = ret;
320
321 irq_set_chip_and_handler(d->irq_base + NEP_IRQ_SMC91X, &nochip,
322 handle_simple_irq);
Rob Herringe8d36d52015-07-27 15:55:13 -0500323 irq_clear_status_flags(d->irq_base + NEP_IRQ_SMC91X, IRQ_NOREQUEST | IRQ_NOPROBE);
Russell Kingced8d212012-01-24 22:22:18 +0000324 irq_set_chip_and_handler(d->irq_base + NEP_IRQ_USAR, &nochip,
325 handle_simple_irq);
Rob Herringe8d36d52015-07-27 15:55:13 -0500326 irq_clear_status_flags(d->irq_base + NEP_IRQ_USAR, IRQ_NOREQUEST | IRQ_NOPROBE);
Russell Kingced8d212012-01-24 22:22:18 +0000327 irq_set_chip(d->irq_base + NEP_IRQ_SA1111, &nochip);
328
Russell Kingb6bdfcf2012-01-24 23:05:08 +0000329 irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
Russell King056c0ac2015-06-16 23:06:25 +0100330 irq_set_chained_handler_and_data(irq, neponset_irq_handler, d);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331
332 /*
Russell Kingced8d212012-01-24 22:22:18 +0000333 * We would set IRQ_GPIO25 to be a wake-up IRQ, but unfortunately
334 * something on the Neponset activates this IRQ on sleep (eth?)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 */
336#if 0
Russell Kingb6bdfcf2012-01-24 23:05:08 +0000337 enable_irq_wake(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338#endif
339
Russell Kingced8d212012-01-24 22:22:18 +0000340 dev_info(&dev->dev, "Neponset daughter board, providing IRQ%u-%u\n",
341 d->irq_base, d->irq_base + NEP_IRQ_NR - 1);
Russell Kingf942b0f2012-01-29 11:19:06 +0000342 nep_base = d->base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Russell Kingced8d212012-01-24 22:22:18 +0000344 sa1100_register_uart_fns(&neponset_port_fns);
345
Russell Kingbab50a32012-01-26 11:50:23 +0000346 /* Ensure that the memory bus request/grant signals are setup */
347 sa1110_mb_disable();
348
Russell Kingced8d212012-01-24 22:22:18 +0000349 /* Disable GPIO 0/1 drivers so the buttons work on the Assabet */
Russell Kingf942b0f2012-01-29 11:19:06 +0000350 writeb_relaxed(NCR_GP01_OFF, d->base + NCR_0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
Russell Kingd2e539a2012-01-24 23:17:37 +0000352 sa1111_resources[0].parent = sa1111_res;
Russell Kingced8d212012-01-24 22:22:18 +0000353 sa1111_resources[1].start = d->irq_base + NEP_IRQ_SA1111;
354 sa1111_resources[1].end = d->irq_base + NEP_IRQ_SA1111;
Russell King9590e8982012-01-24 22:36:47 +0000355 d->sa1111 = platform_device_register_full(&sa1111_devinfo);
Russell Kingced8d212012-01-24 22:22:18 +0000356
Russell Kingd2e539a2012-01-24 23:17:37 +0000357 smc91x_resources[0].parent = smc91x_res;
358 smc91x_resources[1].parent = smc91x_res;
Russell Kingced8d212012-01-24 22:22:18 +0000359 smc91x_resources[2].start = d->irq_base + NEP_IRQ_SMC91X;
360 smc91x_resources[2].end = d->irq_base + NEP_IRQ_SMC91X;
Russell King9590e8982012-01-24 22:36:47 +0000361 d->smc91x = platform_device_register_full(&smc91x_devinfo);
362
Russell Kingae14c2e2012-01-24 22:10:02 +0000363 platform_set_drvdata(dev, d);
364
365 return 0;
366
Russell Kingced8d212012-01-24 22:22:18 +0000367 err_irq_alloc:
Russell Kingf942b0f2012-01-29 11:19:06 +0000368 err_id:
369 iounmap(d->base);
370 err_ioremap:
Russell Kingced8d212012-01-24 22:22:18 +0000371 kfree(d);
Russell Kingae14c2e2012-01-24 22:10:02 +0000372 err_alloc:
373 return ret;
374}
375
Greg Kroah-Hartman351a1022012-12-21 14:02:24 -0800376static int neponset_remove(struct platform_device *dev)
Russell Kingae14c2e2012-01-24 22:10:02 +0000377{
378 struct neponset_drvdata *d = platform_get_drvdata(dev);
Russell Kingb6bdfcf2012-01-24 23:05:08 +0000379 int irq = platform_get_irq(dev, 0);
Russell Kingae14c2e2012-01-24 22:10:02 +0000380
Russell King9590e8982012-01-24 22:36:47 +0000381 if (!IS_ERR(d->sa1111))
382 platform_device_unregister(d->sa1111);
383 if (!IS_ERR(d->smc91x))
384 platform_device_unregister(d->smc91x);
Russell Kingb6bdfcf2012-01-24 23:05:08 +0000385 irq_set_chained_handler(irq, NULL);
Russell Kingced8d212012-01-24 22:22:18 +0000386 irq_free_descs(d->irq_base, NEP_IRQ_NR);
Russell Kingf942b0f2012-01-29 11:19:06 +0000387 nep_base = NULL;
388 iounmap(d->base);
Russell Kingae14c2e2012-01-24 22:10:02 +0000389 kfree(d);
390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 return 0;
392}
393
Russell King51f93392012-01-24 23:29:47 +0000394#ifdef CONFIG_PM_SLEEP
395static int neponset_suspend(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396{
Russell King51f93392012-01-24 23:29:47 +0000397 struct neponset_drvdata *d = dev_get_drvdata(dev);
Russell Kingae14c2e2012-01-24 22:10:02 +0000398
Russell Kingf942b0f2012-01-29 11:19:06 +0000399 d->ncr0 = readb_relaxed(d->base + NCR_0);
400 d->mdm_ctl_0 = readb_relaxed(d->base + MDM_CTL_0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
402 return 0;
403}
404
Russell King51f93392012-01-24 23:29:47 +0000405static int neponset_resume(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406{
Russell King51f93392012-01-24 23:29:47 +0000407 struct neponset_drvdata *d = dev_get_drvdata(dev);
Russell Kingae14c2e2012-01-24 22:10:02 +0000408
Russell Kingf942b0f2012-01-29 11:19:06 +0000409 writeb_relaxed(d->ncr0, d->base + NCR_0);
410 writeb_relaxed(d->mdm_ctl_0, d->base + MDM_CTL_0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411
412 return 0;
413}
414
Russell King51f93392012-01-24 23:29:47 +0000415static const struct dev_pm_ops neponset_pm_ops = {
416 .suspend_noirq = neponset_suspend,
417 .resume_noirq = neponset_resume,
418 .freeze_noirq = neponset_suspend,
419 .restore_noirq = neponset_resume,
420};
421#define PM_OPS &neponset_pm_ops
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422#else
Russell King51f93392012-01-24 23:29:47 +0000423#define PM_OPS NULL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424#endif
425
Russell King3ae5eae2005-11-09 22:32:44 +0000426static struct platform_driver neponset_device_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 .probe = neponset_probe,
Greg Kroah-Hartman351a1022012-12-21 14:02:24 -0800428 .remove = neponset_remove,
Russell King3ae5eae2005-11-09 22:32:44 +0000429 .driver = {
430 .name = "neponset",
Russell King51f93392012-01-24 23:29:47 +0000431 .pm = PM_OPS,
Russell King3ae5eae2005-11-09 22:32:44 +0000432 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433};
434
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435static int __init neponset_init(void)
436{
Russell Kingbab50a32012-01-26 11:50:23 +0000437 return platform_driver_register(&neponset_device_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438}
439
440subsys_initcall(neponset_init);