htc-i2cpld.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. /*
  2. * htc-i2cpld.c
  3. * Chip driver for an unknown CPLD chip found on omap850 HTC devices like
  4. * the HTC Wizard and HTC Herald.
  5. * The cpld is located on the i2c bus and acts as an input/output GPIO
  6. * extender.
  7. *
  8. * Copyright (C) 2009 Cory Maccarrone <darkstar6262@gmail.com>
  9. *
  10. * Based on work done in the linwizard project
  11. * Copyright (C) 2008-2009 Angelo Arrifano <miknix@gmail.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. */
  27. #include <linux/kernel.h>
  28. #include <linux/init.h>
  29. #include <linux/module.h>
  30. #include <linux/interrupt.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/i2c.h>
  33. #include <linux/irq.h>
  34. #include <linux/spinlock.h>
  35. #include <linux/htcpld.h>
  36. #include <linux/gpio.h>
  37. #include <linux/slab.h>
  38. struct htcpld_chip {
  39. spinlock_t lock;
  40. /* chip info */
  41. u8 reset;
  42. u8 addr;
  43. struct device *dev;
  44. struct i2c_client *client;
  45. /* Output details */
  46. u8 cache_out;
  47. struct gpio_chip chip_out;
  48. /* Input details */
  49. u8 cache_in;
  50. struct gpio_chip chip_in;
  51. u16 irqs_enabled;
  52. uint irq_start;
  53. int nirqs;
  54. unsigned int flow_type;
  55. /*
  56. * Work structure to allow for setting values outside of any
  57. * possible interrupt context
  58. */
  59. struct work_struct set_val_work;
  60. };
  61. struct htcpld_data {
  62. /* irq info */
  63. u16 irqs_enabled;
  64. uint irq_start;
  65. int nirqs;
  66. uint chained_irq;
  67. unsigned int int_reset_gpio_hi;
  68. unsigned int int_reset_gpio_lo;
  69. /* htcpld info */
  70. struct htcpld_chip *chip;
  71. unsigned int nchips;
  72. };
  73. /* There does not appear to be a way to proactively mask interrupts
  74. * on the htcpld chip itself. So, we simply ignore interrupts that
  75. * aren't desired. */
  76. static void htcpld_mask(struct irq_data *data)
  77. {
  78. struct htcpld_chip *chip = irq_data_get_irq_chip_data(data);
  79. chip->irqs_enabled &= ~(1 << (data->irq - chip->irq_start));
  80. pr_debug("HTCPLD mask %d %04x\n", data->irq, chip->irqs_enabled);
  81. }
  82. static void htcpld_unmask(struct irq_data *data)
  83. {
  84. struct htcpld_chip *chip = irq_data_get_irq_chip_data(data);
  85. chip->irqs_enabled |= 1 << (data->irq - chip->irq_start);
  86. pr_debug("HTCPLD unmask %d %04x\n", data->irq, chip->irqs_enabled);
  87. }
  88. static int htcpld_set_type(struct irq_data *data, unsigned int flags)
  89. {
  90. struct htcpld_chip *chip = irq_data_get_irq_chip_data(data);
  91. if (flags & ~IRQ_TYPE_SENSE_MASK)
  92. return -EINVAL;
  93. /* We only allow edge triggering */
  94. if (flags & (IRQ_TYPE_LEVEL_LOW|IRQ_TYPE_LEVEL_HIGH))
  95. return -EINVAL;
  96. chip->flow_type = flags;
  97. return 0;
  98. }
  99. static struct irq_chip htcpld_muxed_chip = {
  100. .name = "htcpld",
  101. .irq_mask = htcpld_mask,
  102. .irq_unmask = htcpld_unmask,
  103. .irq_set_type = htcpld_set_type,
  104. };
  105. /* To properly dispatch IRQ events, we need to read from the
  106. * chip. This is an I2C action that could possibly sleep
  107. * (which is bad in interrupt context) -- so we use a threaded
  108. * interrupt handler to get around that.
  109. */
  110. static irqreturn_t htcpld_handler(int irq, void *dev)
  111. {
  112. struct htcpld_data *htcpld = dev;
  113. unsigned int i;
  114. unsigned long flags;
  115. int irqpin;
  116. if (!htcpld) {
  117. pr_debug("htcpld is null in ISR\n");
  118. return IRQ_HANDLED;
  119. }
  120. /*
  121. * For each chip, do a read of the chip and trigger any interrupts
  122. * desired. The interrupts will be triggered from LSB to MSB (i.e.
  123. * bit 0 first, then bit 1, etc.)
  124. *
  125. * For chips that have no interrupt range specified, just skip 'em.
  126. */
  127. for (i = 0; i < htcpld->nchips; i++) {
  128. struct htcpld_chip *chip = &htcpld->chip[i];
  129. struct i2c_client *client;
  130. int val;
  131. unsigned long uval, old_val;
  132. if (!chip) {
  133. pr_debug("chip %d is null in ISR\n", i);
  134. continue;
  135. }
  136. if (chip->nirqs == 0)
  137. continue;
  138. client = chip->client;
  139. if (!client) {
  140. pr_debug("client %d is null in ISR\n", i);
  141. continue;
  142. }
  143. /* Scan the chip */
  144. val = i2c_smbus_read_byte_data(client, chip->cache_out);
  145. if (val < 0) {
  146. /* Throw a warning and skip this chip */
  147. dev_warn(chip->dev, "Unable to read from chip: %d\n",
  148. val);
  149. continue;
  150. }
  151. uval = (unsigned long)val;
  152. spin_lock_irqsave(&chip->lock, flags);
  153. /* Save away the old value so we can compare it */
  154. old_val = chip->cache_in;
  155. /* Write the new value */
  156. chip->cache_in = uval;
  157. spin_unlock_irqrestore(&chip->lock, flags);
  158. /*
  159. * For each bit in the data (starting at bit 0), trigger
  160. * associated interrupts.
  161. */
  162. for (irqpin = 0; irqpin < chip->nirqs; irqpin++) {
  163. unsigned oldb, newb, type = chip->flow_type;
  164. irq = chip->irq_start + irqpin;
  165. /* Run the IRQ handler, but only if the bit value
  166. * changed, and the proper flags are set */
  167. oldb = (old_val >> irqpin) & 1;
  168. newb = (uval >> irqpin) & 1;
  169. if ((!oldb && newb && (type & IRQ_TYPE_EDGE_RISING)) ||
  170. (oldb && !newb && (type & IRQ_TYPE_EDGE_FALLING))) {
  171. pr_debug("fire IRQ %d\n", irqpin);
  172. generic_handle_irq(irq);
  173. }
  174. }
  175. }
  176. /*
  177. * In order to continue receiving interrupts, the int_reset_gpio must
  178. * be asserted.
  179. */
  180. if (htcpld->int_reset_gpio_hi)
  181. gpio_set_value(htcpld->int_reset_gpio_hi, 1);
  182. if (htcpld->int_reset_gpio_lo)
  183. gpio_set_value(htcpld->int_reset_gpio_lo, 0);
  184. return IRQ_HANDLED;
  185. }
  186. /*
  187. * The GPIO set routines can be called from interrupt context, especially if,
  188. * for example they're attached to the led-gpio framework and a trigger is
  189. * enabled. As such, we declared work above in the htcpld_chip structure,
  190. * and that work is scheduled in the set routine. The kernel can then run
  191. * the I2C functions, which will sleep, in process context.
  192. */
  193. static void htcpld_chip_set(struct gpio_chip *chip, unsigned offset, int val)
  194. {
  195. struct i2c_client *client;
  196. struct htcpld_chip *chip_data =
  197. container_of(chip, struct htcpld_chip, chip_out);
  198. unsigned long flags;
  199. client = chip_data->client;
  200. if (!client)
  201. return;
  202. spin_lock_irqsave(&chip_data->lock, flags);
  203. if (val)
  204. chip_data->cache_out |= (1 << offset);
  205. else
  206. chip_data->cache_out &= ~(1 << offset);
  207. spin_unlock_irqrestore(&chip_data->lock, flags);
  208. schedule_work(&(chip_data->set_val_work));
  209. }
  210. static void htcpld_chip_set_ni(struct work_struct *work)
  211. {
  212. struct htcpld_chip *chip_data;
  213. struct i2c_client *client;
  214. chip_data = container_of(work, struct htcpld_chip, set_val_work);
  215. client = chip_data->client;
  216. i2c_smbus_read_byte_data(client, chip_data->cache_out);
  217. }
  218. static int htcpld_chip_get(struct gpio_chip *chip, unsigned offset)
  219. {
  220. struct htcpld_chip *chip_data;
  221. u8 cache;
  222. if (!strncmp(chip->label, "htcpld-out", 10)) {
  223. chip_data = container_of(chip, struct htcpld_chip, chip_out);
  224. cache = chip_data->cache_out;
  225. } else if (!strncmp(chip->label, "htcpld-in", 9)) {
  226. chip_data = container_of(chip, struct htcpld_chip, chip_in);
  227. cache = chip_data->cache_in;
  228. } else
  229. return -EINVAL;
  230. return (cache >> offset) & 1;
  231. }
  232. static int htcpld_direction_output(struct gpio_chip *chip,
  233. unsigned offset, int value)
  234. {
  235. htcpld_chip_set(chip, offset, value);
  236. return 0;
  237. }
  238. static int htcpld_direction_input(struct gpio_chip *chip,
  239. unsigned offset)
  240. {
  241. /*
  242. * No-op: this function can only be called on the input chip.
  243. * We do however make sure the offset is within range.
  244. */
  245. return (offset < chip->ngpio) ? 0 : -EINVAL;
  246. }
  247. static int htcpld_chip_to_irq(struct gpio_chip *chip, unsigned offset)
  248. {
  249. struct htcpld_chip *chip_data;
  250. chip_data = container_of(chip, struct htcpld_chip, chip_in);
  251. if (offset < chip_data->nirqs)
  252. return chip_data->irq_start + offset;
  253. else
  254. return -EINVAL;
  255. }
  256. static void htcpld_chip_reset(struct i2c_client *client)
  257. {
  258. struct htcpld_chip *chip_data = i2c_get_clientdata(client);
  259. if (!chip_data)
  260. return;
  261. i2c_smbus_read_byte_data(
  262. client, (chip_data->cache_out = chip_data->reset));
  263. }
  264. static int htcpld_setup_chip_irq(
  265. struct platform_device *pdev,
  266. int chip_index)
  267. {
  268. struct htcpld_data *htcpld;
  269. struct htcpld_chip *chip;
  270. unsigned int irq, irq_end;
  271. /* Get the platform and driver data */
  272. htcpld = platform_get_drvdata(pdev);
  273. chip = &htcpld->chip[chip_index];
  274. /* Setup irq handlers */
  275. irq_end = chip->irq_start + chip->nirqs;
  276. for (irq = chip->irq_start; irq < irq_end; irq++) {
  277. irq_set_chip_and_handler(irq, &htcpld_muxed_chip,
  278. handle_simple_irq);
  279. irq_set_chip_data(irq, chip);
  280. irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE);
  281. }
  282. return 0;
  283. }
  284. static int htcpld_register_chip_i2c(
  285. struct platform_device *pdev,
  286. int chip_index)
  287. {
  288. struct htcpld_data *htcpld;
  289. struct device *dev = &pdev->dev;
  290. struct htcpld_core_platform_data *pdata;
  291. struct htcpld_chip *chip;
  292. struct htcpld_chip_platform_data *plat_chip_data;
  293. struct i2c_adapter *adapter;
  294. struct i2c_client *client;
  295. struct i2c_board_info info;
  296. /* Get the platform and driver data */
  297. pdata = dev_get_platdata(dev);
  298. htcpld = platform_get_drvdata(pdev);
  299. chip = &htcpld->chip[chip_index];
  300. plat_chip_data = &pdata->chip[chip_index];
  301. adapter = i2c_get_adapter(pdata->i2c_adapter_id);
  302. if (!adapter) {
  303. /* Eek, no such I2C adapter! Bail out. */
  304. dev_warn(dev, "Chip at i2c address 0x%x: Invalid i2c adapter %d\n",
  305. plat_chip_data->addr, pdata->i2c_adapter_id);
  306. return -ENODEV;
  307. }
  308. if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
  309. dev_warn(dev, "i2c adapter %d non-functional\n",
  310. pdata->i2c_adapter_id);
  311. return -EINVAL;
  312. }
  313. memset(&info, 0, sizeof(struct i2c_board_info));
  314. info.addr = plat_chip_data->addr;
  315. strlcpy(info.type, "htcpld-chip", I2C_NAME_SIZE);
  316. info.platform_data = chip;
  317. /* Add the I2C device. This calls the probe() function. */
  318. client = i2c_new_device(adapter, &info);
  319. if (!client) {
  320. /* I2C device registration failed, contineu with the next */
  321. dev_warn(dev, "Unable to add I2C device for 0x%x\n",
  322. plat_chip_data->addr);
  323. return -ENODEV;
  324. }
  325. i2c_set_clientdata(client, chip);
  326. snprintf(client->name, I2C_NAME_SIZE, "Chip_0x%x", client->addr);
  327. chip->client = client;
  328. /* Reset the chip */
  329. htcpld_chip_reset(client);
  330. chip->cache_in = i2c_smbus_read_byte_data(client, chip->cache_out);
  331. return 0;
  332. }
  333. static void htcpld_unregister_chip_i2c(
  334. struct platform_device *pdev,
  335. int chip_index)
  336. {
  337. struct htcpld_data *htcpld;
  338. struct htcpld_chip *chip;
  339. /* Get the platform and driver data */
  340. htcpld = platform_get_drvdata(pdev);
  341. chip = &htcpld->chip[chip_index];
  342. if (chip->client)
  343. i2c_unregister_device(chip->client);
  344. }
  345. static int htcpld_register_chip_gpio(
  346. struct platform_device *pdev,
  347. int chip_index)
  348. {
  349. struct htcpld_data *htcpld;
  350. struct device *dev = &pdev->dev;
  351. struct htcpld_core_platform_data *pdata;
  352. struct htcpld_chip *chip;
  353. struct htcpld_chip_platform_data *plat_chip_data;
  354. struct gpio_chip *gpio_chip;
  355. int ret = 0;
  356. /* Get the platform and driver data */
  357. pdata = dev_get_platdata(dev);
  358. htcpld = platform_get_drvdata(pdev);
  359. chip = &htcpld->chip[chip_index];
  360. plat_chip_data = &pdata->chip[chip_index];
  361. /* Setup the GPIO chips */
  362. gpio_chip = &(chip->chip_out);
  363. gpio_chip->label = "htcpld-out";
  364. gpio_chip->dev = dev;
  365. gpio_chip->owner = THIS_MODULE;
  366. gpio_chip->get = htcpld_chip_get;
  367. gpio_chip->set = htcpld_chip_set;
  368. gpio_chip->direction_input = NULL;
  369. gpio_chip->direction_output = htcpld_direction_output;
  370. gpio_chip->base = plat_chip_data->gpio_out_base;
  371. gpio_chip->ngpio = plat_chip_data->num_gpios;
  372. gpio_chip = &(chip->chip_in);
  373. gpio_chip->label = "htcpld-in";
  374. gpio_chip->dev = dev;
  375. gpio_chip->owner = THIS_MODULE;
  376. gpio_chip->get = htcpld_chip_get;
  377. gpio_chip->set = NULL;
  378. gpio_chip->direction_input = htcpld_direction_input;
  379. gpio_chip->direction_output = NULL;
  380. gpio_chip->to_irq = htcpld_chip_to_irq;
  381. gpio_chip->base = plat_chip_data->gpio_in_base;
  382. gpio_chip->ngpio = plat_chip_data->num_gpios;
  383. /* Add the GPIO chips */
  384. ret = gpiochip_add(&(chip->chip_out));
  385. if (ret) {
  386. dev_warn(dev, "Unable to register output GPIOs for 0x%x: %d\n",
  387. plat_chip_data->addr, ret);
  388. return ret;
  389. }
  390. ret = gpiochip_add(&(chip->chip_in));
  391. if (ret) {
  392. dev_warn(dev, "Unable to register input GPIOs for 0x%x: %d\n",
  393. plat_chip_data->addr, ret);
  394. gpiochip_remove(&(chip->chip_out));
  395. return ret;
  396. }
  397. return 0;
  398. }
  399. static int htcpld_setup_chips(struct platform_device *pdev)
  400. {
  401. struct htcpld_data *htcpld;
  402. struct device *dev = &pdev->dev;
  403. struct htcpld_core_platform_data *pdata;
  404. int i;
  405. /* Get the platform and driver data */
  406. pdata = dev_get_platdata(dev);
  407. htcpld = platform_get_drvdata(pdev);
  408. /* Setup each chip's output GPIOs */
  409. htcpld->nchips = pdata->num_chip;
  410. htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips,
  411. GFP_KERNEL);
  412. if (!htcpld->chip) {
  413. dev_warn(dev, "Unable to allocate memory for chips\n");
  414. return -ENOMEM;
  415. }
  416. /* Add the chips as best we can */
  417. for (i = 0; i < htcpld->nchips; i++) {
  418. int ret;
  419. /* Setup the HTCPLD chips */
  420. htcpld->chip[i].reset = pdata->chip[i].reset;
  421. htcpld->chip[i].cache_out = pdata->chip[i].reset;
  422. htcpld->chip[i].cache_in = 0;
  423. htcpld->chip[i].dev = dev;
  424. htcpld->chip[i].irq_start = pdata->chip[i].irq_base;
  425. htcpld->chip[i].nirqs = pdata->chip[i].num_irqs;
  426. INIT_WORK(&(htcpld->chip[i].set_val_work), &htcpld_chip_set_ni);
  427. spin_lock_init(&(htcpld->chip[i].lock));
  428. /* Setup the interrupts for the chip */
  429. if (htcpld->chained_irq) {
  430. ret = htcpld_setup_chip_irq(pdev, i);
  431. if (ret)
  432. continue;
  433. }
  434. /* Register the chip with I2C */
  435. ret = htcpld_register_chip_i2c(pdev, i);
  436. if (ret)
  437. continue;
  438. /* Register the chips with the GPIO subsystem */
  439. ret = htcpld_register_chip_gpio(pdev, i);
  440. if (ret) {
  441. /* Unregister the chip from i2c and continue */
  442. htcpld_unregister_chip_i2c(pdev, i);
  443. continue;
  444. }
  445. dev_info(dev, "Registered chip at 0x%x\n", pdata->chip[i].addr);
  446. }
  447. return 0;
  448. }
  449. static int htcpld_core_probe(struct platform_device *pdev)
  450. {
  451. struct htcpld_data *htcpld;
  452. struct device *dev = &pdev->dev;
  453. struct htcpld_core_platform_data *pdata;
  454. struct resource *res;
  455. int ret = 0;
  456. if (!dev)
  457. return -ENODEV;
  458. pdata = dev_get_platdata(dev);
  459. if (!pdata) {
  460. dev_warn(dev, "Platform data not found for htcpld core!\n");
  461. return -ENXIO;
  462. }
  463. htcpld = devm_kzalloc(dev, sizeof(struct htcpld_data), GFP_KERNEL);
  464. if (!htcpld)
  465. return -ENOMEM;
  466. /* Find chained irq */
  467. res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  468. if (res) {
  469. int flags;
  470. htcpld->chained_irq = res->start;
  471. /* Setup the chained interrupt handler */
  472. flags = IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
  473. IRQF_ONESHOT;
  474. ret = request_threaded_irq(htcpld->chained_irq,
  475. NULL, htcpld_handler,
  476. flags, pdev->name, htcpld);
  477. if (ret) {
  478. dev_warn(dev, "Unable to setup chained irq handler: %d\n", ret);
  479. return ret;
  480. } else
  481. device_init_wakeup(dev, 0);
  482. }
  483. /* Set the driver data */
  484. platform_set_drvdata(pdev, htcpld);
  485. /* Setup the htcpld chips */
  486. ret = htcpld_setup_chips(pdev);
  487. if (ret)
  488. return ret;
  489. /* Request the GPIO(s) for the int reset and set them up */
  490. if (pdata->int_reset_gpio_hi) {
  491. ret = gpio_request(pdata->int_reset_gpio_hi, "htcpld-core");
  492. if (ret) {
  493. /*
  494. * If it failed, that sucks, but we can probably
  495. * continue on without it.
  496. */
  497. dev_warn(dev, "Unable to request int_reset_gpio_hi -- interrupts may not work\n");
  498. htcpld->int_reset_gpio_hi = 0;
  499. } else {
  500. htcpld->int_reset_gpio_hi = pdata->int_reset_gpio_hi;
  501. gpio_set_value(htcpld->int_reset_gpio_hi, 1);
  502. }
  503. }
  504. if (pdata->int_reset_gpio_lo) {
  505. ret = gpio_request(pdata->int_reset_gpio_lo, "htcpld-core");
  506. if (ret) {
  507. /*
  508. * If it failed, that sucks, but we can probably
  509. * continue on without it.
  510. */
  511. dev_warn(dev, "Unable to request int_reset_gpio_lo -- interrupts may not work\n");
  512. htcpld->int_reset_gpio_lo = 0;
  513. } else {
  514. htcpld->int_reset_gpio_lo = pdata->int_reset_gpio_lo;
  515. gpio_set_value(htcpld->int_reset_gpio_lo, 0);
  516. }
  517. }
  518. dev_info(dev, "Initialized successfully\n");
  519. return 0;
  520. }
  521. /* The I2C Driver -- used internally */
  522. static const struct i2c_device_id htcpld_chip_id[] = {
  523. { "htcpld-chip", 0 },
  524. { }
  525. };
  526. MODULE_DEVICE_TABLE(i2c, htcpld_chip_id);
  527. static struct i2c_driver htcpld_chip_driver = {
  528. .driver = {
  529. .name = "htcpld-chip",
  530. },
  531. .id_table = htcpld_chip_id,
  532. };
  533. /* The Core Driver */
  534. static struct platform_driver htcpld_core_driver = {
  535. .driver = {
  536. .name = "i2c-htcpld",
  537. },
  538. };
  539. static int __init htcpld_core_init(void)
  540. {
  541. int ret;
  542. /* Register the I2C Chip driver */
  543. ret = i2c_add_driver(&htcpld_chip_driver);
  544. if (ret)
  545. return ret;
  546. /* Probe for our chips */
  547. return platform_driver_probe(&htcpld_core_driver, htcpld_core_probe);
  548. }
  549. static void __exit htcpld_core_exit(void)
  550. {
  551. i2c_del_driver(&htcpld_chip_driver);
  552. platform_driver_unregister(&htcpld_core_driver);
  553. }
  554. module_init(htcpld_core_init);
  555. module_exit(htcpld_core_exit);
  556. MODULE_AUTHOR("Cory Maccarrone <darkstar6262@gmail.com>");
  557. MODULE_DESCRIPTION("I2C HTC PLD Driver");
  558. MODULE_LICENSE("GPL");