sx150x.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. /* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. * 02110-1301, USA.
  16. */
  17. #include <linux/gpio.h>
  18. #include <linux/i2c.h>
  19. #include <linux/init.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/irq.h>
  22. #include <linux/module.h>
  23. #include <linux/mutex.h>
  24. #include <linux/slab.h>
  25. #include <linux/workqueue.h>
  26. #include <linux/i2c/sx150x.h>
  27. #define NO_UPDATE_PENDING -1
  28. struct sx150x_device_data {
  29. u8 reg_pullup;
  30. u8 reg_pulldn;
  31. u8 reg_drain;
  32. u8 reg_polarity;
  33. u8 reg_dir;
  34. u8 reg_data;
  35. u8 reg_irq_mask;
  36. u8 reg_irq_src;
  37. u8 reg_sense;
  38. u8 reg_clock;
  39. u8 reg_misc;
  40. u8 reg_reset;
  41. u8 ngpios;
  42. };
  43. struct sx150x_chip {
  44. struct gpio_chip gpio_chip;
  45. struct i2c_client *client;
  46. const struct sx150x_device_data *dev_cfg;
  47. int irq_summary;
  48. int irq_base;
  49. int irq_update;
  50. u32 irq_sense;
  51. u32 irq_masked;
  52. u32 dev_sense;
  53. u32 dev_masked;
  54. struct irq_chip irq_chip;
  55. struct mutex lock;
  56. };
  57. static const struct sx150x_device_data sx150x_devices[] = {
  58. [0] = { /* sx1508q */
  59. .reg_pullup = 0x03,
  60. .reg_pulldn = 0x04,
  61. .reg_drain = 0x05,
  62. .reg_polarity = 0x06,
  63. .reg_dir = 0x07,
  64. .reg_data = 0x08,
  65. .reg_irq_mask = 0x09,
  66. .reg_irq_src = 0x0c,
  67. .reg_sense = 0x0b,
  68. .reg_clock = 0x0f,
  69. .reg_misc = 0x10,
  70. .reg_reset = 0x7d,
  71. .ngpios = 8
  72. },
  73. [1] = { /* sx1509q */
  74. .reg_pullup = 0x07,
  75. .reg_pulldn = 0x09,
  76. .reg_drain = 0x0b,
  77. .reg_polarity = 0x0d,
  78. .reg_dir = 0x0f,
  79. .reg_data = 0x11,
  80. .reg_irq_mask = 0x13,
  81. .reg_irq_src = 0x19,
  82. .reg_sense = 0x17,
  83. .reg_clock = 0x1e,
  84. .reg_misc = 0x1f,
  85. .reg_reset = 0x7d,
  86. .ngpios = 16
  87. },
  88. };
  89. static const struct i2c_device_id sx150x_id[] = {
  90. {"sx1508q", 0},
  91. {"sx1509q", 1},
  92. {}
  93. };
  94. MODULE_DEVICE_TABLE(i2c, sx150x_id);
  95. static s32 sx150x_i2c_write(struct i2c_client *client, u8 reg, u8 val)
  96. {
  97. s32 err = i2c_smbus_write_byte_data(client, reg, val);
  98. if (err < 0)
  99. dev_warn(&client->dev,
  100. "i2c write fail: can't write %02x to %02x: %d\n",
  101. val, reg, err);
  102. return err;
  103. }
  104. static s32 sx150x_i2c_read(struct i2c_client *client, u8 reg, u8 *val)
  105. {
  106. s32 err = i2c_smbus_read_byte_data(client, reg);
  107. if (err >= 0)
  108. *val = err;
  109. else
  110. dev_warn(&client->dev,
  111. "i2c read fail: can't read from %02x: %d\n",
  112. reg, err);
  113. return err;
  114. }
  115. static inline bool offset_is_oscio(struct sx150x_chip *chip, unsigned offset)
  116. {
  117. return (chip->dev_cfg->ngpios == offset);
  118. }
  119. /*
  120. * These utility functions solve the common problem of locating and setting
  121. * configuration bits. Configuration bits are grouped into registers
  122. * whose indexes increase downwards. For example, with eight-bit registers,
  123. * sixteen gpios would have their config bits grouped in the following order:
  124. * REGISTER N-1 [ f e d c b a 9 8 ]
  125. * N [ 7 6 5 4 3 2 1 0 ]
  126. *
  127. * For multi-bit configurations, the pattern gets wider:
  128. * REGISTER N-3 [ f f e e d d c c ]
  129. * N-2 [ b b a a 9 9 8 8 ]
  130. * N-1 [ 7 7 6 6 5 5 4 4 ]
  131. * N [ 3 3 2 2 1 1 0 0 ]
  132. *
  133. * Given the address of the starting register 'N', the index of the gpio
  134. * whose configuration we seek to change, and the width in bits of that
  135. * configuration, these functions allow us to locate the correct
  136. * register and mask the correct bits.
  137. */
  138. static inline void sx150x_find_cfg(u8 offset, u8 width,
  139. u8 *reg, u8 *mask, u8 *shift)
  140. {
  141. *reg -= offset * width / 8;
  142. *mask = (1 << width) - 1;
  143. *shift = (offset * width) % 8;
  144. *mask <<= *shift;
  145. }
  146. static s32 sx150x_write_cfg(struct sx150x_chip *chip,
  147. u8 offset, u8 width, u8 reg, u8 val)
  148. {
  149. u8 mask;
  150. u8 data;
  151. u8 shift;
  152. s32 err;
  153. sx150x_find_cfg(offset, width, &reg, &mask, &shift);
  154. err = sx150x_i2c_read(chip->client, reg, &data);
  155. if (err < 0)
  156. return err;
  157. data &= ~mask;
  158. data |= (val << shift) & mask;
  159. return sx150x_i2c_write(chip->client, reg, data);
  160. }
  161. static int sx150x_get_io(struct sx150x_chip *chip, unsigned offset)
  162. {
  163. u8 reg = chip->dev_cfg->reg_data;
  164. u8 mask;
  165. u8 data;
  166. u8 shift;
  167. s32 err;
  168. sx150x_find_cfg(offset, 1, &reg, &mask, &shift);
  169. err = sx150x_i2c_read(chip->client, reg, &data);
  170. if (err >= 0)
  171. err = (data & mask) != 0 ? 1 : 0;
  172. return err;
  173. }
  174. static void sx150x_set_oscio(struct sx150x_chip *chip, int val)
  175. {
  176. sx150x_i2c_write(chip->client,
  177. chip->dev_cfg->reg_clock,
  178. (val ? 0x1f : 0x10));
  179. }
  180. static void sx150x_set_io(struct sx150x_chip *chip, unsigned offset, int val)
  181. {
  182. sx150x_write_cfg(chip,
  183. offset,
  184. 1,
  185. chip->dev_cfg->reg_data,
  186. (val ? 1 : 0));
  187. }
  188. static int sx150x_io_input(struct sx150x_chip *chip, unsigned offset)
  189. {
  190. return sx150x_write_cfg(chip,
  191. offset,
  192. 1,
  193. chip->dev_cfg->reg_dir,
  194. 1);
  195. }
  196. static int sx150x_io_output(struct sx150x_chip *chip, unsigned offset, int val)
  197. {
  198. int err;
  199. err = sx150x_write_cfg(chip,
  200. offset,
  201. 1,
  202. chip->dev_cfg->reg_data,
  203. (val ? 1 : 0));
  204. if (err >= 0)
  205. err = sx150x_write_cfg(chip,
  206. offset,
  207. 1,
  208. chip->dev_cfg->reg_dir,
  209. 0);
  210. return err;
  211. }
  212. static int sx150x_gpio_get(struct gpio_chip *gc, unsigned offset)
  213. {
  214. struct sx150x_chip *chip;
  215. int status = -EINVAL;
  216. chip = container_of(gc, struct sx150x_chip, gpio_chip);
  217. if (!offset_is_oscio(chip, offset)) {
  218. mutex_lock(&chip->lock);
  219. status = sx150x_get_io(chip, offset);
  220. mutex_unlock(&chip->lock);
  221. }
  222. return status;
  223. }
  224. static void sx150x_gpio_set(struct gpio_chip *gc, unsigned offset, int val)
  225. {
  226. struct sx150x_chip *chip;
  227. chip = container_of(gc, struct sx150x_chip, gpio_chip);
  228. mutex_lock(&chip->lock);
  229. if (offset_is_oscio(chip, offset))
  230. sx150x_set_oscio(chip, val);
  231. else
  232. sx150x_set_io(chip, offset, val);
  233. mutex_unlock(&chip->lock);
  234. }
  235. static int sx150x_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
  236. {
  237. struct sx150x_chip *chip;
  238. int status = -EINVAL;
  239. chip = container_of(gc, struct sx150x_chip, gpio_chip);
  240. if (!offset_is_oscio(chip, offset)) {
  241. mutex_lock(&chip->lock);
  242. status = sx150x_io_input(chip, offset);
  243. mutex_unlock(&chip->lock);
  244. }
  245. return status;
  246. }
  247. static int sx150x_gpio_direction_output(struct gpio_chip *gc,
  248. unsigned offset,
  249. int val)
  250. {
  251. struct sx150x_chip *chip;
  252. int status = 0;
  253. chip = container_of(gc, struct sx150x_chip, gpio_chip);
  254. if (!offset_is_oscio(chip, offset)) {
  255. mutex_lock(&chip->lock);
  256. status = sx150x_io_output(chip, offset, val);
  257. mutex_unlock(&chip->lock);
  258. }
  259. return status;
  260. }
  261. static int sx150x_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
  262. {
  263. struct sx150x_chip *chip;
  264. chip = container_of(gc, struct sx150x_chip, gpio_chip);
  265. if (offset >= chip->dev_cfg->ngpios)
  266. return -EINVAL;
  267. if (chip->irq_base < 0)
  268. return -EINVAL;
  269. return chip->irq_base + offset;
  270. }
  271. static void sx150x_irq_mask(struct irq_data *d)
  272. {
  273. struct irq_chip *ic = irq_data_get_irq_chip(d);
  274. struct sx150x_chip *chip;
  275. unsigned n;
  276. chip = container_of(ic, struct sx150x_chip, irq_chip);
  277. n = d->irq - chip->irq_base;
  278. chip->irq_masked |= (1 << n);
  279. chip->irq_update = n;
  280. }
  281. static void sx150x_irq_unmask(struct irq_data *d)
  282. {
  283. struct irq_chip *ic = irq_data_get_irq_chip(d);
  284. struct sx150x_chip *chip;
  285. unsigned n;
  286. chip = container_of(ic, struct sx150x_chip, irq_chip);
  287. n = d->irq - chip->irq_base;
  288. chip->irq_masked &= ~(1 << n);
  289. chip->irq_update = n;
  290. }
  291. static int sx150x_irq_set_type(struct irq_data *d, unsigned int flow_type)
  292. {
  293. struct irq_chip *ic = irq_data_get_irq_chip(d);
  294. struct sx150x_chip *chip;
  295. unsigned n, val = 0;
  296. if (flow_type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW))
  297. return -EINVAL;
  298. chip = container_of(ic, struct sx150x_chip, irq_chip);
  299. n = d->irq - chip->irq_base;
  300. if (flow_type & IRQ_TYPE_EDGE_RISING)
  301. val |= 0x1;
  302. if (flow_type & IRQ_TYPE_EDGE_FALLING)
  303. val |= 0x2;
  304. chip->irq_sense &= ~(3UL << (n * 2));
  305. chip->irq_sense |= val << (n * 2);
  306. chip->irq_update = n;
  307. return 0;
  308. }
  309. static irqreturn_t sx150x_irq_thread_fn(int irq, void *dev_id)
  310. {
  311. struct sx150x_chip *chip = (struct sx150x_chip *)dev_id;
  312. unsigned nhandled = 0;
  313. unsigned sub_irq;
  314. unsigned n;
  315. s32 err;
  316. u8 val;
  317. int i;
  318. for (i = (chip->dev_cfg->ngpios / 8) - 1; i >= 0; --i) {
  319. err = sx150x_i2c_read(chip->client,
  320. chip->dev_cfg->reg_irq_src - i,
  321. &val);
  322. if (err < 0)
  323. continue;
  324. sx150x_i2c_write(chip->client,
  325. chip->dev_cfg->reg_irq_src - i,
  326. val);
  327. for (n = 0; n < 8; ++n) {
  328. if (val & (1 << n)) {
  329. sub_irq = chip->irq_base + (i * 8) + n;
  330. handle_nested_irq(sub_irq);
  331. ++nhandled;
  332. }
  333. }
  334. }
  335. return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
  336. }
  337. static void sx150x_irq_bus_lock(struct irq_data *d)
  338. {
  339. struct irq_chip *ic = irq_data_get_irq_chip(d);
  340. struct sx150x_chip *chip;
  341. chip = container_of(ic, struct sx150x_chip, irq_chip);
  342. mutex_lock(&chip->lock);
  343. }
  344. static void sx150x_irq_bus_sync_unlock(struct irq_data *d)
  345. {
  346. struct irq_chip *ic = irq_data_get_irq_chip(d);
  347. struct sx150x_chip *chip;
  348. unsigned n;
  349. chip = container_of(ic, struct sx150x_chip, irq_chip);
  350. if (chip->irq_update == NO_UPDATE_PENDING)
  351. goto out;
  352. n = chip->irq_update;
  353. chip->irq_update = NO_UPDATE_PENDING;
  354. /* Avoid updates if nothing changed */
  355. if (chip->dev_sense == chip->irq_sense &&
  356. chip->dev_sense == chip->irq_masked)
  357. goto out;
  358. chip->dev_sense = chip->irq_sense;
  359. chip->dev_masked = chip->irq_masked;
  360. if (chip->irq_masked & (1 << n)) {
  361. sx150x_write_cfg(chip, n, 1, chip->dev_cfg->reg_irq_mask, 1);
  362. sx150x_write_cfg(chip, n, 2, chip->dev_cfg->reg_sense, 0);
  363. } else {
  364. sx150x_write_cfg(chip, n, 1, chip->dev_cfg->reg_irq_mask, 0);
  365. sx150x_write_cfg(chip, n, 2, chip->dev_cfg->reg_sense,
  366. chip->irq_sense >> (n * 2));
  367. }
  368. out:
  369. mutex_unlock(&chip->lock);
  370. }
  371. static void sx150x_init_chip(struct sx150x_chip *chip,
  372. struct i2c_client *client,
  373. kernel_ulong_t driver_data,
  374. struct sx150x_platform_data *pdata)
  375. {
  376. mutex_init(&chip->lock);
  377. chip->client = client;
  378. chip->dev_cfg = &sx150x_devices[driver_data];
  379. chip->gpio_chip.label = client->name;
  380. chip->gpio_chip.direction_input = sx150x_gpio_direction_input;
  381. chip->gpio_chip.direction_output = sx150x_gpio_direction_output;
  382. chip->gpio_chip.get = sx150x_gpio_get;
  383. chip->gpio_chip.set = sx150x_gpio_set;
  384. chip->gpio_chip.to_irq = sx150x_gpio_to_irq;
  385. chip->gpio_chip.base = pdata->gpio_base;
  386. chip->gpio_chip.can_sleep = 1;
  387. chip->gpio_chip.ngpio = chip->dev_cfg->ngpios;
  388. if (pdata->oscio_is_gpo)
  389. ++chip->gpio_chip.ngpio;
  390. chip->irq_chip.name = client->name;
  391. chip->irq_chip.irq_mask = sx150x_irq_mask;
  392. chip->irq_chip.irq_unmask = sx150x_irq_unmask;
  393. chip->irq_chip.irq_set_type = sx150x_irq_set_type;
  394. chip->irq_chip.irq_bus_lock = sx150x_irq_bus_lock;
  395. chip->irq_chip.irq_bus_sync_unlock = sx150x_irq_bus_sync_unlock;
  396. chip->irq_summary = -1;
  397. chip->irq_base = -1;
  398. chip->irq_masked = ~0;
  399. chip->irq_sense = 0;
  400. chip->dev_masked = ~0;
  401. chip->dev_sense = 0;
  402. chip->irq_update = NO_UPDATE_PENDING;
  403. }
  404. static int sx150x_init_io(struct sx150x_chip *chip, u8 base, u16 cfg)
  405. {
  406. int err = 0;
  407. unsigned n;
  408. for (n = 0; err >= 0 && n < (chip->dev_cfg->ngpios / 8); ++n)
  409. err = sx150x_i2c_write(chip->client, base - n, cfg >> (n * 8));
  410. return err;
  411. }
  412. static int sx150x_reset(struct sx150x_chip *chip)
  413. {
  414. int err;
  415. err = i2c_smbus_write_byte_data(chip->client,
  416. chip->dev_cfg->reg_reset,
  417. 0x12);
  418. if (err < 0)
  419. return err;
  420. err = i2c_smbus_write_byte_data(chip->client,
  421. chip->dev_cfg->reg_reset,
  422. 0x34);
  423. return err;
  424. }
  425. static int sx150x_init_hw(struct sx150x_chip *chip,
  426. struct sx150x_platform_data *pdata)
  427. {
  428. int err = 0;
  429. if (pdata->reset_during_probe) {
  430. err = sx150x_reset(chip);
  431. if (err < 0)
  432. return err;
  433. }
  434. err = sx150x_i2c_write(chip->client,
  435. chip->dev_cfg->reg_misc,
  436. 0x01);
  437. if (err < 0)
  438. return err;
  439. err = sx150x_init_io(chip, chip->dev_cfg->reg_pullup,
  440. pdata->io_pullup_ena);
  441. if (err < 0)
  442. return err;
  443. err = sx150x_init_io(chip, chip->dev_cfg->reg_pulldn,
  444. pdata->io_pulldn_ena);
  445. if (err < 0)
  446. return err;
  447. err = sx150x_init_io(chip, chip->dev_cfg->reg_drain,
  448. pdata->io_open_drain_ena);
  449. if (err < 0)
  450. return err;
  451. err = sx150x_init_io(chip, chip->dev_cfg->reg_polarity,
  452. pdata->io_polarity);
  453. if (err < 0)
  454. return err;
  455. if (pdata->oscio_is_gpo)
  456. sx150x_set_oscio(chip, 0);
  457. return err;
  458. }
  459. static int sx150x_install_irq_chip(struct sx150x_chip *chip,
  460. int irq_summary,
  461. int irq_base)
  462. {
  463. int err;
  464. unsigned n;
  465. unsigned irq;
  466. chip->irq_summary = irq_summary;
  467. chip->irq_base = irq_base;
  468. for (n = 0; n < chip->dev_cfg->ngpios; ++n) {
  469. irq = irq_base + n;
  470. irq_set_chip_and_handler(irq, &chip->irq_chip, handle_edge_irq);
  471. irq_set_nested_thread(irq, 1);
  472. #ifdef CONFIG_ARM
  473. set_irq_flags(irq, IRQF_VALID);
  474. #else
  475. irq_set_noprobe(irq);
  476. #endif
  477. }
  478. err = request_threaded_irq(irq_summary,
  479. NULL,
  480. sx150x_irq_thread_fn,
  481. IRQF_SHARED | IRQF_TRIGGER_FALLING,
  482. chip->irq_chip.name,
  483. chip);
  484. if (err < 0) {
  485. chip->irq_summary = -1;
  486. chip->irq_base = -1;
  487. }
  488. return err;
  489. }
  490. static void sx150x_remove_irq_chip(struct sx150x_chip *chip)
  491. {
  492. unsigned n;
  493. unsigned irq;
  494. free_irq(chip->irq_summary, chip);
  495. for (n = 0; n < chip->dev_cfg->ngpios; ++n) {
  496. irq = chip->irq_base + n;
  497. irq_set_chip_and_handler(irq, NULL, NULL);
  498. }
  499. }
  500. static int __devinit sx150x_probe(struct i2c_client *client,
  501. const struct i2c_device_id *id)
  502. {
  503. static const u32 i2c_funcs = I2C_FUNC_SMBUS_BYTE_DATA |
  504. I2C_FUNC_SMBUS_WRITE_WORD_DATA;
  505. struct sx150x_platform_data *pdata;
  506. struct sx150x_chip *chip;
  507. int rc;
  508. pdata = client->dev.platform_data;
  509. if (!pdata)
  510. return -EINVAL;
  511. if (!i2c_check_functionality(client->adapter, i2c_funcs))
  512. return -ENOSYS;
  513. chip = kzalloc(sizeof(struct sx150x_chip), GFP_KERNEL);
  514. if (!chip)
  515. return -ENOMEM;
  516. sx150x_init_chip(chip, client, id->driver_data, pdata);
  517. rc = sx150x_init_hw(chip, pdata);
  518. if (rc < 0)
  519. goto probe_fail_pre_gpiochip_add;
  520. rc = gpiochip_add(&chip->gpio_chip);
  521. if (rc < 0)
  522. goto probe_fail_pre_gpiochip_add;
  523. if (pdata->irq_summary >= 0) {
  524. rc = sx150x_install_irq_chip(chip,
  525. pdata->irq_summary,
  526. pdata->irq_base);
  527. if (rc < 0)
  528. goto probe_fail_post_gpiochip_add;
  529. }
  530. i2c_set_clientdata(client, chip);
  531. return 0;
  532. probe_fail_post_gpiochip_add:
  533. WARN_ON(gpiochip_remove(&chip->gpio_chip) < 0);
  534. probe_fail_pre_gpiochip_add:
  535. kfree(chip);
  536. return rc;
  537. }
  538. static int __devexit sx150x_remove(struct i2c_client *client)
  539. {
  540. struct sx150x_chip *chip;
  541. int rc;
  542. chip = i2c_get_clientdata(client);
  543. rc = gpiochip_remove(&chip->gpio_chip);
  544. if (rc < 0)
  545. return rc;
  546. if (chip->irq_summary >= 0)
  547. sx150x_remove_irq_chip(chip);
  548. kfree(chip);
  549. return 0;
  550. }
  551. static struct i2c_driver sx150x_driver = {
  552. .driver = {
  553. .name = "sx150x",
  554. .owner = THIS_MODULE
  555. },
  556. .probe = sx150x_probe,
  557. .remove = __devexit_p(sx150x_remove),
  558. .id_table = sx150x_id,
  559. };
  560. static int __init sx150x_init(void)
  561. {
  562. return i2c_add_driver(&sx150x_driver);
  563. }
  564. subsys_initcall(sx150x_init);
  565. static void __exit sx150x_exit(void)
  566. {
  567. return i2c_del_driver(&sx150x_driver);
  568. }
  569. module_exit(sx150x_exit);
  570. MODULE_AUTHOR("Gregory Bean <gbean@codeaurora.org>");
  571. MODULE_DESCRIPTION("Driver for Semtech SX150X I2C GPIO Expanders");
  572. MODULE_LICENSE("GPL v2");
  573. MODULE_ALIAS("i2c:sx150x");