blob: c933b486d9dd3cdc2618b53f403a998a92e7728d [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
2 * Marimba TSADC driver.
3 *
Duy Truong790f06d2013-02-13 16:38:12 -08004 * Copyright (c) 2009-2010, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#include <linux/module.h>
18#include <linux/platform_device.h>
19#include <linux/err.h>
20#include <linux/interrupt.h>
21#include <linux/clk.h>
22#include <linux/mfd/marimba.h>
23#include <linux/mfd/marimba-tsadc.h>
24#include <linux/pm.h>
25#include <linux/slab.h>
26
27#if defined(CONFIG_HAS_EARLYSUSPEND)
28#include <linux/earlysuspend.h>
29#endif
30
31/* marimba configuration block: TS_CTL0 */
32#define TS_CTL0 0xFF
33#define TS_CTL0_RESET BIT(0)
34#define TS_CTL0_CLK_EN BIT(1)
35#define TS_CTL0_XO_EN BIT(2)
36#define TS_CTL0_EOC_EN BIT(3)
37#define TS_CTL0_PENIRQ_EN BIT(4)
38
39/* TSADC registers */
40#define SSBI_PRESET 0x00
41#define TSHK_DIG_CONFIG 0x4F
42#define TSHK_INTF_CONFIG 0x50
43#define TSHK_SETUP 0x51
44 #define TSHK_SETUP_EN_ADC BIT(0)
45 #define TSHK_SETUP_EN_PIRQ BIT(7)
46#define TSHK_PARAM 0x52
47#define TSHK_DATA_RD 0x53
48#define TSHK_STATUS 0x54
49#define TSHK_SETUP2 0x55
50#define TSHK_RSV1 0x56
51 #define TSHK_RSV1_PRECHARGE_EN BIT(0)
52#define TSHK_COMMAND 0x57
53#define TSHK_PARAM2 0x58
54 #define TSHK_INPUT_CLK_MASK 0x3F
55 #define TSHK_SAMPLE_PRD_MASK 0xC7
56 #define TSHK_INPUT_CLK_SHIFT 0x6
57 #define TSHK_SAMPLE_PRD_SHIFT 0x3
58#define TSHK_PARAM3 0x59
59 #define TSHK_PARAM3_MODE_MASK 0xFC
60 #define TSHK_PARAM3_PRE_CHG_SHIFT (5)
61 #define TSHK_PARAM3_STABIZ_SHIFT (2)
62 #define TSHK_STABLE_TIME_MASK 0xE3
63 #define TSHK_PRECHG_TIME_MASK 0x1F
64#define TSHK_PARAM4 0x5A
65#define TSHK_RSV2 0x5B
66#define TSHK_RSV3 0x5C
67#define TSHK_RSV4 0x5D
68#define TSHK_RSV5 0x5E
69
70struct marimba_tsadc_client {
71 unsigned int is_ts;
72 struct platform_device *pdev;
73};
74
75struct marimba_tsadc {
76 struct marimba *marimba;
77 struct device *dev;
78 struct marimba_tsadc_platform_data *pdata;
79 struct clk *codec_ssbi;
80 struct device *child_tssc;
81 bool clk_enabled;
82#if defined(CONFIG_HAS_EARLYSUSPEND)
83 struct early_suspend early_suspend;
84#endif
85};
86
87static struct marimba_tsadc *tsadc_dev;
88
89static int marimba_write_u8(struct marimba_tsadc *tsadc, u8 reg, u8 data)
90{
91 int rc;
92
93 tsadc->marimba->mod_id = MARIMBA_SLAVE_ID_MARIMBA;
94 rc = marimba_write(tsadc->marimba, reg, &data, 1);
95
96 if (!rc)
97 dev_warn(tsadc->dev, "Error writing marimba reg %X - ret %X\n",
98 reg, data);
99 return 0;
100}
101
102static int marimba_tsadc_write(struct marimba_tsadc *tsadc, u8 reg, u8 data)
103{
104 int rc;
105
106 tsadc->marimba->mod_id = MARIMBA_ID_TSADC;
107
108 rc = marimba_ssbi_write(tsadc->marimba, reg, &data, 1);
109 if (!rc)
110 dev_warn(tsadc->dev, "Error writing marimba reg %X - ret %X\n",
111 reg, data);
112 return rc;
113}
114
115static int marimba_tsadc_shutdown(struct marimba_tsadc *tsadc)
116{
117 u8 val;
118 int rc;
119
120 /* force reset */
121 val = TS_CTL0_XO_EN | TS_CTL0_EOC_EN | TS_CTL0_PENIRQ_EN |
122 TS_CTL0_CLK_EN;
123 rc = marimba_write_u8(tsadc, TS_CTL0, val);
124 if (rc < 0)
125 return rc;
126
127 /* disable xo, clock */
128 val = TS_CTL0_PENIRQ_EN | TS_CTL0_EOC_EN;
129 rc = marimba_write_u8(tsadc, TS_CTL0, val);
130 if (rc < 0)
131 return rc;
132
133 /* de-vote S2 1.3v */
134 if (tsadc->pdata->level_vote)
135 /* REVISIT: Ignore error for level_vote(0) for now*/
136 tsadc->pdata->level_vote(0);
137
138 return 0;
139}
140
141static int marimba_tsadc_startup(struct marimba_tsadc *tsadc)
142{
143 u8 val;
144 int rc = 0;
145
146 /* vote for S2 1.3v */
147 if (tsadc->pdata->level_vote) {
148 rc = tsadc->pdata->level_vote(1);
149 if (rc < 0)
150 return rc;
151 }
152
153 /* disable XO, clock and output enables */
154 rc = marimba_write_u8(tsadc, TS_CTL0, 0x00);
155 if (rc < 0)
156 goto fail_marimba_write;
157
158 /* Enable output enables */
159 val = TS_CTL0_XO_EN | TS_CTL0_EOC_EN | TS_CTL0_PENIRQ_EN;
160 rc = marimba_write_u8(tsadc, TS_CTL0, val);
161 if (rc < 0)
162 goto fail_marimba_write;
163
164 /* Enable clock */
165 val = val | TS_CTL0_CLK_EN;
166 rc = marimba_write_u8(tsadc, TS_CTL0, val);
167 if (rc < 0)
168 goto fail_marimba_write;
169
170 /* remove reset */
171 val = val | TS_CTL0_RESET;
172 rc = marimba_write_u8(tsadc, TS_CTL0, val);
173 if (rc < 0)
174 goto fail_marimba_write;
175
176 return 0;
177
178fail_marimba_write:
179 if (tsadc->pdata->level_vote)
180 /* REVISIT: Ignore error for level_vote(0) for now*/
181 tsadc->pdata->level_vote(0);
182 return rc;
183}
184
185
186static int marimba_tsadc_configure(struct marimba_tsadc *tsadc)
187{
188 u8 rsv1 = 0, setup = 0, i, count = 0;
189 u8 param2 = 0, param3 = 0;
190 unsigned long val;
191 int rc;
192
193 rc = marimba_tsadc_write(tsadc, SSBI_PRESET, 0x00);
194 if (rc < 0)
195 return rc;
196
197 if (!tsadc->pdata)
198 return -EINVAL;
199
200 /* Configure RSV1 register*/
201 if (tsadc->pdata->tsadc_prechg_en == true)
202 rsv1 |= TSHK_RSV1_PRECHARGE_EN;
203 else
204 rsv1 &= ~TSHK_RSV1_PRECHARGE_EN;
205
206 /* Set RSV1 register*/
207 rc = marimba_tsadc_write(tsadc, TSHK_RSV1, rsv1);
208 if (rc < 0)
209 return rc;
210
211 /* Configure PARAM2 register */
212 /* Input clk */
213 val = tsadc->pdata->params2.input_clk_khz;
214 param2 &= TSHK_INPUT_CLK_MASK;
215 val /= 600;
216 if (val >= 1 && val <= 8 && !(val & (val - 1))) {
217 /* Input clk can be .6, 1.2, 2.4, 4.8Mhz */
218 if (val % 4 != 0)
219 param2 = (4 - (val % 4)) << TSHK_INPUT_CLK_SHIFT;
220 else
221 param2 = ((val / 4) - 1) << TSHK_INPUT_CLK_SHIFT;
222 } else /* Configure the default clk 2.4Mhz */
223 param2 = 0x00 << TSHK_INPUT_CLK_SHIFT;
224
225 /* Sample period */
226 param2 &= TSHK_SAMPLE_PRD_MASK;
227 param2 |= tsadc->pdata->params2.sample_prd << TSHK_SAMPLE_PRD_SHIFT;
228
229 /* Write PARAM2 register */
230 rc = marimba_tsadc_write(tsadc, TSHK_PARAM2, param2);
231 if (rc < 0)
232 return rc;
233
234 /* REVISIT: If Precharge time, stabilization time > 409.6us */
235 /* Configure PARAM3 register */
236 val = tsadc->pdata->params3.prechg_time_nsecs;
237 param3 &= TSHK_PRECHG_TIME_MASK;
238 val /= 6400;
239 if (val >= 1 && val <= 64 && !(val & (val - 1))) {
240 count = 0;
241 while ((val = val >> 1) != 0)
242 count++;
243 param3 |= count << TSHK_PARAM3_PRE_CHG_SHIFT;
244 } else /* Set default value if the input is wrong */
245 param3 |= 0x00 << TSHK_PARAM3_PRE_CHG_SHIFT;
246
247 val = tsadc->pdata->params3.stable_time_nsecs;
248 param3 &= TSHK_STABLE_TIME_MASK;
249 val /= 6400;
250 if (val >= 1 && val <= 64 && !(val & (val - 1))) {
251 count = 0;
252 while ((val = val >> 1) != 0)
253 count++;
254 param3 |= count << TSHK_PARAM3_STABIZ_SHIFT;
255 } else /* Set default value if the input is wrong */
256 param3 |= 0x00 << TSHK_PARAM3_STABIZ_SHIFT;
257
258 /* Get TSADC mode */
259 val = tsadc->pdata->params3.tsadc_test_mode;
260 param3 &= TSHK_PARAM3_MODE_MASK;
261 if (val == 0)
262 param3 |= 0x00;
263 else
264 for (i = 0; i < 3 ; i++) {
265 if (((val + i) % 39322) == 0) {
266 param3 |= (i + 1);
267 break;
268 }
269 }
270 if (i == 3) /* Set to normal mode if input is wrong */
271 param3 |= 0x00;
272
273 rc = marimba_tsadc_write(tsadc, TSHK_PARAM3, param3);
274 if (rc < 0)
275 return rc;
276
277 /* Configure TSHK SETUP Register */
278 if (tsadc->pdata->setup.pen_irq_en == true)
279 setup |= TSHK_SETUP_EN_PIRQ;
280 else
281 setup &= ~TSHK_SETUP_EN_PIRQ;
282
283 if (tsadc->pdata->setup.tsadc_en == true)
284 setup |= TSHK_SETUP_EN_ADC;
285 else
286 setup &= ~TSHK_SETUP_EN_ADC;
287
288 /* Enable signals to ADC, pen irq assertion */
289 rc = marimba_tsadc_write(tsadc, TSHK_SETUP, setup);
290 if (rc < 0)
291 return rc;
292
293 return 0;
294}
295
296int marimba_tsadc_start(struct marimba_tsadc_client *client)
297{
298 int rc = 0;
299
300 if (!client) {
301 pr_err("%s: Not a valid client\n", __func__);
302 return -ENODEV;
303 }
304
305 if (!tsadc_dev) {
306 dev_err(&client->pdev->dev,
307 "%s: No tsadc device available\n", __func__);
308 return -ENODEV;
309 }
310
311 /* REVISIT - add locks */
312 if (client->is_ts) {
313 rc = marimba_tsadc_startup(tsadc_dev);
314 if (rc < 0)
315 goto fail_tsadc_startup;
316 rc = marimba_tsadc_configure(tsadc_dev);
317 if (rc < 0)
318 goto fail_tsadc_conf;
319 }
320
321 return 0;
322fail_tsadc_conf:
323 marimba_tsadc_shutdown(tsadc_dev);
324fail_tsadc_startup:
325 return rc;
326}
327EXPORT_SYMBOL(marimba_tsadc_start);
328
329struct marimba_tsadc_client *
330marimba_tsadc_register(struct platform_device *pdev, unsigned int is_ts)
331{
332 struct marimba_tsadc_client *client;
333
334 if (!pdev) {
335 pr_err("%s: valid platform device pointer please\n", __func__);
336 return ERR_PTR(-EINVAL);
337 }
338
339 if (!is_ts) {
340 dev_err(&pdev->dev, "%s: only TS right now\n", __func__);
341 return ERR_PTR(-EINVAL);
342 }
343
344 if (!tsadc_dev) {
345 dev_err(&pdev->dev,
346 "%s: No tsadc device available\n", __func__);
347 return ERR_PTR(-ENODEV);
348 }
349
350 client = kzalloc(sizeof *client, GFP_KERNEL);
351 if (!client)
352 return ERR_PTR(-ENOMEM);
353
354 client->pdev = pdev;
355 client->is_ts = is_ts;
356
357 return client;
358}
359EXPORT_SYMBOL(marimba_tsadc_register);
360
361void marimba_tsadc_unregister(struct marimba_tsadc_client *client)
362{
363 if (client->is_ts)
364 marimba_tsadc_shutdown(tsadc_dev);
365 kfree(client);
366}
367EXPORT_SYMBOL(marimba_tsadc_unregister);
368
369static struct resource resources_tssc[] = {
370 {
371 .start = 0xAD300000,
372 .end = 0xAD300000 + SZ_4K - 1,
373 .name = "tssc",
374 .flags = IORESOURCE_MEM,
375 },
376 {
377 .start = 55,
378 .end = 55,
379 .name = "tssc1",
380 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
381 },
382 {
383 .start = 56,
384 .end = 56,
385 .name = "tssc2",
386 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
387 },
388};
389
390static struct device *
391marimba_add_tssc_subdev(struct device *parent, const char *name, int num,
392 struct resource *resources, int num_resources,
393 void *pdata, int pdata_len)
394{
395 struct platform_device *pdev;
396 int status;
397
398 pdev = platform_device_alloc(name, num);
399 if (!pdev) {
400 dev_dbg(parent, "can't alloc dev\n");
401 status = -ENOMEM;
402 goto err;
403 }
404
405 pdev->dev.parent = parent;
406
407 if (pdata) {
408 status = platform_device_add_data(pdev, pdata, pdata_len);
409 if (status < 0) {
410 dev_dbg(&pdev->dev, "can't add platform_data\n");
411 goto err;
412 }
413 }
414
415 status = platform_device_add_resources(pdev, resources, num_resources);
416 if (status < 0) {
417 dev_dbg(&pdev->dev, "can't add resources\n");
418 goto err;
419 }
420
421 status = platform_device_add(pdev);
422
423err:
424 if (status < 0) {
425 platform_device_put(pdev);
426 dev_err(parent, "can't add %s dev\n", name);
427 return ERR_PTR(status);
428 }
429 return &pdev->dev;
430}
431
432#ifdef CONFIG_PM
433static int
434marimba_tsadc_suspend(struct device *dev)
435{
436 int rc = 0, ret = 0;
437 struct marimba_tsadc *tsadc = dev_get_drvdata(dev);
438
439 if (tsadc->clk_enabled == true) {
Vikram Mulukutlafd5aba12012-06-01 15:01:34 -0700440 clk_disable_unprepare(tsadc->codec_ssbi);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700441 tsadc->clk_enabled = false;
442 }
443
444 if (!(device_may_wakeup(dev) &&
445 device_may_wakeup(tsadc->child_tssc))) {
446 rc = marimba_tsadc_shutdown(tsadc);
447 if (rc < 0) {
448 pr_err("%s: Unable to shutdown TSADC\n", __func__);
449 goto fail_shutdown;
450 }
451
452 if (tsadc->pdata->marimba_tsadc_power) {
453 rc = tsadc->pdata->marimba_tsadc_power(0);
454 if (rc < 0)
455 goto fail_tsadc_power;
456 }
457 }
458 return rc;
459
460fail_tsadc_power:
461 marimba_tsadc_startup(tsadc_dev);
462 marimba_tsadc_configure(tsadc_dev);
463fail_shutdown:
464 if (tsadc->clk_enabled == false) {
Vikram Mulukutlafd5aba12012-06-01 15:01:34 -0700465 ret = clk_prepare_enable(tsadc->codec_ssbi);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700466 if (ret == 0)
467 tsadc->clk_enabled = true;
468 }
469 return rc;
470}
471
472static int marimba_tsadc_resume(struct device *dev)
473{
474 int rc = 0;
475 struct marimba_tsadc *tsadc = dev_get_drvdata(dev);
476
477 if (tsadc->clk_enabled == false) {
Vikram Mulukutlafd5aba12012-06-01 15:01:34 -0700478 rc = clk_prepare_enable(tsadc->codec_ssbi);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700479 if (rc != 0) {
480 pr_err("%s: Clk enable failed\n", __func__);
481 return rc;
482 }
483 tsadc->clk_enabled = true;
484 }
485
486 if (!(device_may_wakeup(dev) &&
487 device_may_wakeup(tsadc->child_tssc))) {
488 if (tsadc->pdata->marimba_tsadc_power) {
489 rc = tsadc->pdata->marimba_tsadc_power(1);
490 if (rc) {
491 pr_err("%s: Unable to power on TSADC \n",
492 __func__);
493 goto fail_tsadc_power;
494 }
495 }
496
497 rc = marimba_tsadc_startup(tsadc_dev);
498 if (rc < 0) {
499 pr_err("%s: Unable to startup TSADC\n", __func__);
500 goto fail_tsadc_startup;
501 }
502
503 rc = marimba_tsadc_configure(tsadc_dev);
504 if (rc < 0) {
505 pr_err("%s: Unable to configure TSADC\n", __func__);
506 goto fail_tsadc_configure;
507 }
508 }
509 return rc;
510
511fail_tsadc_configure:
512 marimba_tsadc_shutdown(tsadc_dev);
513fail_tsadc_startup:
514 if (tsadc->pdata->marimba_tsadc_power)
515 tsadc->pdata->marimba_tsadc_power(0);
516fail_tsadc_power:
517 if (tsadc->clk_enabled == true) {
Vikram Mulukutlafd5aba12012-06-01 15:01:34 -0700518 clk_disable_unprepare(tsadc->codec_ssbi);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700519 tsadc->clk_enabled = false;
520 }
521 return rc;
522}
523
524static struct dev_pm_ops tsadc_pm_ops = {
525#ifndef CONFIG_HAS_EARLYSUSPEND
526 .suspend = marimba_tsadc_suspend,
527 .resume = marimba_tsadc_resume,
528#endif
529};
530#endif
531
532#ifdef CONFIG_HAS_EARLYSUSPEND
533static void marimba_tsadc_early_suspend(struct early_suspend *h)
534{
535 struct marimba_tsadc *tsadc = container_of(h, struct marimba_tsadc,
536 early_suspend);
537
538 marimba_tsadc_suspend(tsadc->dev);
539}
540
541static void marimba_tsadc_late_resume(struct early_suspend *h)
542{
543 struct marimba_tsadc *tsadc = container_of(h, struct marimba_tsadc,
544 early_suspend);
545
546 marimba_tsadc_resume(tsadc->dev);
547}
548#endif
549
550static int __devinit marimba_tsadc_probe(struct platform_device *pdev)
551{
552 struct marimba *marimba = platform_get_drvdata(pdev);
553 struct marimba_tsadc *tsadc;
554 struct marimba_tsadc_platform_data *pdata = pdev->dev.platform_data;
555 int rc = 0;
556 struct device *child;
557
558 printk("%s\n", __func__);
559
560 if (!pdata) {
561 dev_dbg(&pdev->dev, "no tsadc platform data?\n");
562 return -EINVAL;
563 }
564
565 tsadc = kzalloc(sizeof *tsadc, GFP_KERNEL);
566 if (!tsadc)
567 return -ENOMEM;
568
569 tsadc->marimba = marimba;
570 tsadc->dev = &pdev->dev;
571 tsadc->pdata = pdata;
572
573 platform_set_drvdata(pdev, tsadc);
574
575 if (tsadc->pdata->init) {
576 rc = tsadc->pdata->init();
577 if (rc < 0)
578 goto fail_tsadc_init;
579 }
580
581 if (tsadc->pdata->marimba_tsadc_power) {
582 rc = tsadc->pdata->marimba_tsadc_power(1);
583 if (rc) {
584 pr_err("%s: Unable to power up TSADC \n", __func__);
585 goto fail_tsadc_power;
586 }
587 }
588
589 tsadc->codec_ssbi = clk_get(NULL, "codec_ssbi_clk");
590 if (IS_ERR(tsadc->codec_ssbi)) {
591 rc = PTR_ERR(tsadc->codec_ssbi);
592 goto fail_clk_get;
593 }
Vikram Mulukutlafd5aba12012-06-01 15:01:34 -0700594 rc = clk_prepare_enable(tsadc->codec_ssbi);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700595 if (rc != 0)
596 goto fail_clk_enable;
597
598 tsadc->clk_enabled = true;
599
600 child = marimba_add_tssc_subdev(&pdev->dev, "msm_touchscreen", -1,
601 resources_tssc, ARRAY_SIZE(resources_tssc),
602 pdata->tssc_data, sizeof(*pdata->tssc_data));
603
604 if (IS_ERR(child)) {
605 rc = PTR_ERR(child);
606 goto fail_add_subdev;
607 }
608
609 tsadc->child_tssc = child;
610 platform_set_drvdata(pdev, tsadc);
611
612#ifdef CONFIG_HAS_EARLYSUSPEND
613 tsadc->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN +
614 TSADC_SUSPEND_LEVEL;
615 tsadc->early_suspend.suspend = marimba_tsadc_early_suspend;
616 tsadc->early_suspend.resume = marimba_tsadc_late_resume;
617 register_early_suspend(&tsadc->early_suspend);
618#endif
619
620 tsadc_dev = tsadc;
621 device_init_wakeup(&pdev->dev, pdata->can_wakeup);
622
623 return rc;
624
625fail_add_subdev:
Vikram Mulukutlafd5aba12012-06-01 15:01:34 -0700626 clk_disable_unprepare(tsadc->codec_ssbi);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700627
628fail_clk_enable:
629 clk_put(tsadc->codec_ssbi);
630
631fail_clk_get:
632 if (tsadc->pdata->marimba_tsadc_power)
633 rc = tsadc->pdata->marimba_tsadc_power(0);
634fail_tsadc_power:
635 if (tsadc->pdata->exit)
636 rc = tsadc->pdata->exit();
637fail_tsadc_init:
638 kfree(tsadc);
639 return rc;
640}
641
642static int __devexit marimba_tsadc_remove(struct platform_device *pdev)
643{
644 int rc = 0;
645 struct marimba_tsadc *tsadc = platform_get_drvdata(pdev);
646
647 device_init_wakeup(&pdev->dev, 0);
648
649 if (tsadc->clk_enabled == true)
Vikram Mulukutlafd5aba12012-06-01 15:01:34 -0700650 clk_disable_unprepare(tsadc->codec_ssbi);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700651
652 clk_put(tsadc->codec_ssbi);
653
654 if (tsadc->pdata->exit)
655 rc = tsadc->pdata->exit();
656
657 if (tsadc->pdata->marimba_tsadc_power)
658 rc = tsadc->pdata->marimba_tsadc_power(0);
659
660#ifdef CONFIG_HAS_EARLYSUSPEND
661 unregister_early_suspend(&tsadc->early_suspend);
662#endif
663
664 platform_set_drvdata(pdev, NULL);
665 kfree(tsadc);
666 return rc;
667}
668
669static struct platform_driver tsadc_driver = {
670 .probe = marimba_tsadc_probe,
671 .remove = __devexit_p(marimba_tsadc_remove),
672 .driver = {
673 .name = "marimba_tsadc",
674 .owner = THIS_MODULE,
675#ifdef CONFIG_PM
676 .pm = &tsadc_pm_ops,
677#endif
678 },
679};
680
681static int __init marimba_tsadc_init(void)
682{
683 return platform_driver_register(&tsadc_driver);
684}
685device_initcall(marimba_tsadc_init);
686
687static void __exit marimba_tsadc_exit(void)
688{
689 return platform_driver_unregister(&tsadc_driver);
690}
691module_exit(marimba_tsadc_exit);
692
693MODULE_DESCRIPTION("Marimba TSADC driver");
694MODULE_VERSION("0.1");
695MODULE_LICENSE("GPL v2");
696MODULE_ALIAS("platform:marimba_tsadc");