htc-i2cpld.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  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. int ret = 0;
  272. /* Get the platform and driver data */
  273. htcpld = platform_get_drvdata(pdev);
  274. chip = &htcpld->chip[chip_index];
  275. /* Setup irq handlers */
  276. irq_end = chip->irq_start + chip->nirqs;
  277. for (irq = chip->irq_start; irq < irq_end; irq++) {
  278. irq_set_chip_and_handler(irq, &htcpld_muxed_chip,
  279. handle_simple_irq);
  280. irq_set_chip_data(irq, chip);
  281. irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE);
  282. }
  283. return ret;
  284. }
  285. static int htcpld_register_chip_i2c(
  286. struct platform_device *pdev,
  287. int chip_index)
  288. {
  289. struct htcpld_data *htcpld;
  290. struct device *dev = &pdev->dev;
  291. struct htcpld_core_platform_data *pdata;
  292. struct htcpld_chip *chip;
  293. struct htcpld_chip_platform_data *plat_chip_data;
  294. struct i2c_adapter *adapter;
  295. struct i2c_client *client;
  296. struct i2c_board_info info;
  297. /* Get the platform and driver data */
  298. pdata = dev_get_platdata(dev);
  299. htcpld = platform_get_drvdata(pdev);
  300. chip = &htcpld->chip[chip_index];
  301. plat_chip_data = &pdata->chip[chip_index];
  302. adapter = i2c_get_adapter(pdata->i2c_adapter_id);
  303. if (!adapter) {
  304. /* Eek, no such I2C adapter! Bail out. */
  305. dev_warn(dev, "Chip at i2c address 0x%x: Invalid i2c adapter %d\n",
  306. plat_chip_data->addr, pdata->i2c_adapter_id);
  307. return -ENODEV;
  308. }
  309. if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
  310. dev_warn(dev, "i2c adapter %d non-functional\n",
  311. pdata->i2c_adapter_id);
  312. return -EINVAL;
  313. }
  314. memset(&info, 0, sizeof(struct i2c_board_info));
  315. info.addr = plat_chip_data->addr;
  316. strlcpy(info.type, "htcpld-chip", I2C_NAME_SIZE);
  317. info.platform_data = chip;
  318. /* Add the I2C device. This calls the probe() function. */
  319. client = i2c_new_device(adapter, &info);
  320. if (!client) {
  321. /* I2C device registration failed, contineu with the next */
  322. dev_warn(dev, "Unable to add I2C device for 0x%x\n",
  323. plat_chip_data->addr);
  324. return -ENODEV;
  325. }
  326. i2c_set_clientdata(client, chip);
  327. snprintf(client->name, I2C_NAME_SIZE, "Chip_0x%x", client->addr);
  328. chip->client = client;
  329. /* Reset the chip */
  330. htcpld_chip_reset(client);
  331. chip->cache_in = i2c_smbus_read_byte_data(client, chip->cache_out);
  332. return 0;
  333. }
  334. static void htcpld_unregister_chip_i2c(
  335. struct platform_device *pdev,
  336. int chip_index)
  337. {
  338. struct htcpld_data *htcpld;
  339. struct htcpld_chip *chip;
  340. /* Get the platform and driver data */
  341. htcpld = platform_get_drvdata(pdev);
  342. chip = &htcpld->chip[chip_index];
  343. if (chip->client)
  344. i2c_unregister_device(chip->client);
  345. }
  346. static int htcpld_register_chip_gpio(
  347. struct platform_device *pdev,
  348. int chip_index)
  349. {
  350. struct htcpld_data *htcpld;
  351. struct device *dev = &pdev->dev;
  352. struct htcpld_core_platform_data *pdata;
  353. struct htcpld_chip *chip;
  354. struct htcpld_chip_platform_data *plat_chip_data;
  355. struct gpio_chip *gpio_chip;
  356. int ret = 0;
  357. /* Get the platform and driver data */
  358. pdata = dev_get_platdata(dev);
  359. htcpld = platform_get_drvdata(pdev);
  360. chip = &htcpld->chip[chip_index];
  361. plat_chip_data = &pdata->chip[chip_index];
  362. /* Setup the GPIO chips */
  363. gpio_chip = &(chip->chip_out);
  364. gpio_chip->label = "htcpld-out";
  365. gpio_chip->dev = dev;
  366. gpio_chip->owner = THIS_MODULE;
  367. gpio_chip->get = htcpld_chip_get;
  368. gpio_chip->set = htcpld_chip_set;
  369. gpio_chip->direction_input = NULL;
  370. gpio_chip->direction_output = htcpld_direction_output;
  371. gpio_chip->base = plat_chip_data->gpio_out_base;
  372. gpio_chip->ngpio = plat_chip_data->num_gpios;
  373. gpio_chip = &(chip->chip_in);
  374. gpio_chip->label = "htcpld-in";
  375. gpio_chip->dev = dev;
  376. gpio_chip->owner = THIS_MODULE;
  377. gpio_chip->get = htcpld_chip_get;
  378. gpio_chip->set = NULL;
  379. gpio_chip->direction_input = htcpld_direction_input;
  380. gpio_chip->direction_output = NULL;
  381. gpio_chip->to_irq = htcpld_chip_to_irq;
  382. gpio_chip->base = plat_chip_data->gpio_in_base;
  383. gpio_chip->ngpio = plat_chip_data->num_gpios;
  384. /* Add the GPIO chips */
  385. ret = gpiochip_add(&(chip->chip_out));
  386. if (ret) {
  387. dev_warn(dev, "Unable to register output GPIOs for 0x%x: %d\n",
  388. plat_chip_data->addr, ret);
  389. return ret;
  390. }
  391. ret = gpiochip_add(&(chip->chip_in));
  392. if (ret) {
  393. dev_warn(dev, "Unable to register input GPIOs for 0x%x: %d\n",
  394. plat_chip_data->addr, ret);
  395. gpiochip_remove(&(chip->chip_out));
  396. return ret;
  397. }
  398. return 0;
  399. }
  400. static int htcpld_setup_chips(struct platform_device *pdev)
  401. {
  402. struct htcpld_data *htcpld;
  403. struct device *dev = &pdev->dev;
  404. struct htcpld_core_platform_data *pdata;
  405. int i;
  406. /* Get the platform and driver data */
  407. pdata = dev_get_platdata(dev);
  408. htcpld = platform_get_drvdata(pdev);
  409. /* Setup each chip's output GPIOs */
  410. htcpld->nchips = pdata->num_chip;
  411. htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips,
  412. GFP_KERNEL);
  413. if (!htcpld->chip) {
  414. dev_warn(dev, "Unable to allocate memory for chips\n");
  415. return -ENOMEM;
  416. }
  417. /* Add the chips as best we can */
  418. for (i = 0; i < htcpld->nchips; i++) {
  419. int ret;
  420. /* Setup the HTCPLD chips */
  421. htcpld->chip[i].reset = pdata->chip[i].reset;
  422. htcpld->chip[i].cache_out = pdata->chip[i].reset;
  423. htcpld->chip[i].cache_in = 0;
  424. htcpld->chip[i].dev = dev;
  425. htcpld->chip[i].irq_start = pdata->chip[i].irq_base;
  426. htcpld->chip[i].nirqs = pdata->chip[i].num_irqs;
  427. INIT_WORK(&(htcpld->chip[i].set_val_work), &htcpld_chip_set_ni);
  428. spin_lock_init(&(htcpld->chip[i].lock));
  429. /* Setup the interrupts for the chip */
  430. if (htcpld->chained_irq) {
  431. ret = htcpld_setup_chip_irq(pdev, i);
  432. if (ret)
  433. continue;
  434. }
  435. /* Register the chip with I2C */
  436. ret = htcpld_register_chip_i2c(pdev, i);
  437. if (ret)
  438. continue;
  439. /* Register the chips with the GPIO subsystem */
  440. ret = htcpld_register_chip_gpio(pdev, i);
  441. if (ret) {
  442. /* Unregister the chip from i2c and continue */
  443. htcpld_unregister_chip_i2c(pdev, i);
  444. continue;
  445. }
  446. dev_info(dev, "Registered chip at 0x%x\n", pdata->chip[i].addr);
  447. }
  448. return 0;
  449. }
  450. static int htcpld_core_probe(struct platform_device *pdev)
  451. {
  452. struct htcpld_data *htcpld;
  453. struct device *dev = &pdev->dev;
  454. struct htcpld_core_platform_data *pdata;
  455. struct resource *res;
  456. int ret = 0;
  457. if (!dev)
  458. return -ENODEV;
  459. pdata = dev_get_platdata(dev);
  460. if (!pdata) {
  461. dev_warn(dev, "Platform data not found for htcpld core!\n");
  462. return -ENXIO;
  463. }
  464. htcpld = devm_kzalloc(dev, sizeof(struct htcpld_data), GFP_KERNEL);
  465. if (!htcpld)
  466. return -ENOMEM;
  467. /* Find chained irq */
  468. res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  469. if (res) {
  470. int flags;
  471. htcpld->chained_irq = res->start;
  472. /* Setup the chained interrupt handler */
  473. flags = IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
  474. IRQF_ONESHOT;
  475. ret = request_threaded_irq(htcpld->chained_irq,
  476. NULL, htcpld_handler,
  477. flags, pdev->name, htcpld);
  478. if (ret) {
  479. dev_warn(dev, "Unable to setup chained irq handler: %d\n", ret);
  480. return ret;
  481. } else
  482. device_init_wakeup(dev, 0);
  483. }
  484. /* Set the driver data */
  485. platform_set_drvdata(pdev, htcpld);
  486. /* Setup the htcpld chips */
  487. ret = htcpld_setup_chips(pdev);
  488. if (ret)
  489. return ret;
  490. /* Request the GPIO(s) for the int reset and set them up */
  491. if (pdata->int_reset_gpio_hi) {
  492. ret = gpio_request(pdata->int_reset_gpio_hi, "htcpld-core");
  493. if (ret) {
  494. /*
  495. * If it failed, that sucks, but we can probably
  496. * continue on without it.
  497. */
  498. dev_warn(dev, "Unable to request int_reset_gpio_hi -- interrupts may not work\n");
  499. htcpld->int_reset_gpio_hi = 0;
  500. } else {
  501. htcpld->int_reset_gpio_hi = pdata->int_reset_gpio_hi;
  502. gpio_set_value(htcpld->int_reset_gpio_hi, 1);
  503. }
  504. }
  505. if (pdata->int_reset_gpio_lo) {
  506. ret = gpio_request(pdata->int_reset_gpio_lo, "htcpld-core");
  507. if (ret) {
  508. /*
  509. * If it failed, that sucks, but we can probably
  510. * continue on without it.
  511. */
  512. dev_warn(dev, "Unable to request int_reset_gpio_lo -- interrupts may not work\n");
  513. htcpld->int_reset_gpio_lo = 0;
  514. } else {
  515. htcpld->int_reset_gpio_lo = pdata->int_reset_gpio_lo;
  516. gpio_set_value(htcpld->int_reset_gpio_lo, 0);
  517. }
  518. }
  519. dev_info(dev, "Initialized successfully\n");
  520. return 0;
  521. }
  522. /* The I2C Driver -- used internally */
  523. static const struct i2c_device_id htcpld_chip_id[] = {
  524. { "htcpld-chip", 0 },
  525. { }
  526. };
  527. MODULE_DEVICE_TABLE(i2c, htcpld_chip_id);
  528. static struct i2c_driver htcpld_chip_driver = {
  529. .driver = {
  530. .name = "htcpld-chip",
  531. },
  532. .id_table = htcpld_chip_id,
  533. };
  534. /* The Core Driver */
  535. static struct platform_driver htcpld_core_driver = {
  536. .driver = {
  537. .name = "i2c-htcpld",
  538. },
  539. };
  540. static int __init htcpld_core_init(void)
  541. {
  542. int ret;
  543. /* Register the I2C Chip driver */
  544. ret = i2c_add_driver(&htcpld_chip_driver);
  545. if (ret)
  546. return ret;
  547. /* Probe for our chips */
  548. return platform_driver_probe(&htcpld_core_driver, htcpld_core_probe);
  549. }
  550. static void __exit htcpld_core_exit(void)
  551. {
  552. i2c_del_driver(&htcpld_chip_driver);
  553. platform_driver_unregister(&htcpld_core_driver);
  554. }
  555. module_init(htcpld_core_init);
  556. module_exit(htcpld_core_exit);
  557. MODULE_AUTHOR("Cory Maccarrone <darkstar6262@gmail.com>");
  558. MODULE_DESCRIPTION("I2C HTC PLD Driver");
  559. MODULE_LICENSE("GPL");