pinctrl-sx150x.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. /*
  2. * Copyright (c) 2016, BayLibre, SAS. All rights reserved.
  3. * Author: Neil Armstrong <narmstrong@baylibre.com>
  4. *
  5. * Copyright (c) 2010, Code Aurora Forum. All rights reserved.
  6. *
  7. * Driver for Semtech SX150X I2C GPIO Expanders
  8. * The handling of the 4-bit chips (SX1501/SX1504/SX1507) is untested.
  9. *
  10. * Author: Gregory Bean <gbean@codeaurora.org>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 and
  14. * only version 2 as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. */
  21. #include <linux/regmap.h>
  22. #include <linux/i2c.h>
  23. #include <linux/init.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/irq.h>
  26. #include <linux/mutex.h>
  27. #include <linux/slab.h>
  28. #include <linux/of.h>
  29. #include <linux/of_device.h>
  30. #include <linux/gpio/driver.h>
  31. #include <linux/pinctrl/pinconf.h>
  32. #include <linux/pinctrl/pinctrl.h>
  33. #include <linux/pinctrl/pinmux.h>
  34. #include <linux/pinctrl/pinconf-generic.h>
  35. #include "core.h"
  36. #include "pinconf.h"
  37. #include "pinctrl-utils.h"
  38. /* The chip models of sx150x */
  39. enum {
  40. SX150X_123 = 0,
  41. SX150X_456,
  42. SX150X_789,
  43. };
  44. enum {
  45. SX150X_789_REG_MISC_AUTOCLEAR_OFF = 1 << 0,
  46. SX150X_MAX_REGISTER = 0xad,
  47. SX150X_IRQ_TYPE_EDGE_RISING = 0x1,
  48. SX150X_IRQ_TYPE_EDGE_FALLING = 0x2,
  49. SX150X_789_RESET_KEY1 = 0x12,
  50. SX150X_789_RESET_KEY2 = 0x34,
  51. };
  52. struct sx150x_123_pri {
  53. u8 reg_pld_mode;
  54. u8 reg_pld_table0;
  55. u8 reg_pld_table1;
  56. u8 reg_pld_table2;
  57. u8 reg_pld_table3;
  58. u8 reg_pld_table4;
  59. u8 reg_advanced;
  60. };
  61. struct sx150x_456_pri {
  62. u8 reg_pld_mode;
  63. u8 reg_pld_table0;
  64. u8 reg_pld_table1;
  65. u8 reg_pld_table2;
  66. u8 reg_pld_table3;
  67. u8 reg_pld_table4;
  68. u8 reg_advanced;
  69. };
  70. struct sx150x_789_pri {
  71. u8 reg_drain;
  72. u8 reg_polarity;
  73. u8 reg_clock;
  74. u8 reg_misc;
  75. u8 reg_reset;
  76. u8 ngpios;
  77. };
  78. struct sx150x_device_data {
  79. u8 model;
  80. u8 reg_pullup;
  81. u8 reg_pulldn;
  82. u8 reg_dir;
  83. u8 reg_data;
  84. u8 reg_irq_mask;
  85. u8 reg_irq_src;
  86. u8 reg_sense;
  87. u8 ngpios;
  88. union {
  89. struct sx150x_123_pri x123;
  90. struct sx150x_456_pri x456;
  91. struct sx150x_789_pri x789;
  92. } pri;
  93. const struct pinctrl_pin_desc *pins;
  94. unsigned int npins;
  95. };
  96. struct sx150x_pinctrl {
  97. struct device *dev;
  98. struct i2c_client *client;
  99. struct pinctrl_dev *pctldev;
  100. struct pinctrl_desc pinctrl_desc;
  101. struct gpio_chip gpio;
  102. struct irq_chip irq_chip;
  103. struct regmap *regmap;
  104. struct {
  105. u32 sense;
  106. u32 masked;
  107. } irq;
  108. struct mutex lock;
  109. const struct sx150x_device_data *data;
  110. };
  111. static const struct pinctrl_pin_desc sx150x_4_pins[] = {
  112. PINCTRL_PIN(0, "gpio0"),
  113. PINCTRL_PIN(1, "gpio1"),
  114. PINCTRL_PIN(2, "gpio2"),
  115. PINCTRL_PIN(3, "gpio3"),
  116. PINCTRL_PIN(4, "oscio"),
  117. };
  118. static const struct pinctrl_pin_desc sx150x_8_pins[] = {
  119. PINCTRL_PIN(0, "gpio0"),
  120. PINCTRL_PIN(1, "gpio1"),
  121. PINCTRL_PIN(2, "gpio2"),
  122. PINCTRL_PIN(3, "gpio3"),
  123. PINCTRL_PIN(4, "gpio4"),
  124. PINCTRL_PIN(5, "gpio5"),
  125. PINCTRL_PIN(6, "gpio6"),
  126. PINCTRL_PIN(7, "gpio7"),
  127. PINCTRL_PIN(8, "oscio"),
  128. };
  129. static const struct pinctrl_pin_desc sx150x_16_pins[] = {
  130. PINCTRL_PIN(0, "gpio0"),
  131. PINCTRL_PIN(1, "gpio1"),
  132. PINCTRL_PIN(2, "gpio2"),
  133. PINCTRL_PIN(3, "gpio3"),
  134. PINCTRL_PIN(4, "gpio4"),
  135. PINCTRL_PIN(5, "gpio5"),
  136. PINCTRL_PIN(6, "gpio6"),
  137. PINCTRL_PIN(7, "gpio7"),
  138. PINCTRL_PIN(8, "gpio8"),
  139. PINCTRL_PIN(9, "gpio9"),
  140. PINCTRL_PIN(10, "gpio10"),
  141. PINCTRL_PIN(11, "gpio11"),
  142. PINCTRL_PIN(12, "gpio12"),
  143. PINCTRL_PIN(13, "gpio13"),
  144. PINCTRL_PIN(14, "gpio14"),
  145. PINCTRL_PIN(15, "gpio15"),
  146. PINCTRL_PIN(16, "oscio"),
  147. };
  148. static const struct sx150x_device_data sx1501q_device_data = {
  149. .model = SX150X_123,
  150. .reg_pullup = 0x02,
  151. .reg_pulldn = 0x03,
  152. .reg_dir = 0x01,
  153. .reg_data = 0x00,
  154. .reg_irq_mask = 0x05,
  155. .reg_irq_src = 0x08,
  156. .reg_sense = 0x07,
  157. .pri.x123 = {
  158. .reg_pld_mode = 0x10,
  159. .reg_pld_table0 = 0x11,
  160. .reg_pld_table2 = 0x13,
  161. .reg_advanced = 0xad,
  162. },
  163. .ngpios = 4,
  164. .pins = sx150x_4_pins,
  165. .npins = 4, /* oscio not available */
  166. };
  167. static const struct sx150x_device_data sx1502q_device_data = {
  168. .model = SX150X_123,
  169. .reg_pullup = 0x02,
  170. .reg_pulldn = 0x03,
  171. .reg_dir = 0x01,
  172. .reg_data = 0x00,
  173. .reg_irq_mask = 0x05,
  174. .reg_irq_src = 0x08,
  175. .reg_sense = 0x06,
  176. .pri.x123 = {
  177. .reg_pld_mode = 0x10,
  178. .reg_pld_table0 = 0x11,
  179. .reg_pld_table1 = 0x12,
  180. .reg_pld_table2 = 0x13,
  181. .reg_pld_table3 = 0x14,
  182. .reg_pld_table4 = 0x15,
  183. .reg_advanced = 0xad,
  184. },
  185. .ngpios = 8,
  186. .pins = sx150x_8_pins,
  187. .npins = 8, /* oscio not available */
  188. };
  189. static const struct sx150x_device_data sx1503q_device_data = {
  190. .model = SX150X_123,
  191. .reg_pullup = 0x04,
  192. .reg_pulldn = 0x06,
  193. .reg_dir = 0x02,
  194. .reg_data = 0x00,
  195. .reg_irq_mask = 0x08,
  196. .reg_irq_src = 0x0e,
  197. .reg_sense = 0x0a,
  198. .pri.x123 = {
  199. .reg_pld_mode = 0x20,
  200. .reg_pld_table0 = 0x22,
  201. .reg_pld_table1 = 0x24,
  202. .reg_pld_table2 = 0x26,
  203. .reg_pld_table3 = 0x28,
  204. .reg_pld_table4 = 0x2a,
  205. .reg_advanced = 0xad,
  206. },
  207. .ngpios = 16,
  208. .pins = sx150x_16_pins,
  209. .npins = 16, /* oscio not available */
  210. };
  211. static const struct sx150x_device_data sx1504q_device_data = {
  212. .model = SX150X_456,
  213. .reg_pullup = 0x02,
  214. .reg_pulldn = 0x03,
  215. .reg_dir = 0x01,
  216. .reg_data = 0x00,
  217. .reg_irq_mask = 0x05,
  218. .reg_irq_src = 0x08,
  219. .reg_sense = 0x07,
  220. .pri.x456 = {
  221. .reg_pld_mode = 0x10,
  222. .reg_pld_table0 = 0x11,
  223. .reg_pld_table2 = 0x13,
  224. },
  225. .ngpios = 4,
  226. .pins = sx150x_4_pins,
  227. .npins = 4, /* oscio not available */
  228. };
  229. static const struct sx150x_device_data sx1505q_device_data = {
  230. .model = SX150X_456,
  231. .reg_pullup = 0x02,
  232. .reg_pulldn = 0x03,
  233. .reg_dir = 0x01,
  234. .reg_data = 0x00,
  235. .reg_irq_mask = 0x05,
  236. .reg_irq_src = 0x08,
  237. .reg_sense = 0x06,
  238. .pri.x456 = {
  239. .reg_pld_mode = 0x10,
  240. .reg_pld_table0 = 0x11,
  241. .reg_pld_table1 = 0x12,
  242. .reg_pld_table2 = 0x13,
  243. .reg_pld_table3 = 0x14,
  244. .reg_pld_table4 = 0x15,
  245. },
  246. .ngpios = 8,
  247. .pins = sx150x_8_pins,
  248. .npins = 8, /* oscio not available */
  249. };
  250. static const struct sx150x_device_data sx1506q_device_data = {
  251. .model = SX150X_456,
  252. .reg_pullup = 0x04,
  253. .reg_pulldn = 0x06,
  254. .reg_dir = 0x02,
  255. .reg_data = 0x00,
  256. .reg_irq_mask = 0x08,
  257. .reg_irq_src = 0x0e,
  258. .reg_sense = 0x0a,
  259. .pri.x456 = {
  260. .reg_pld_mode = 0x20,
  261. .reg_pld_table0 = 0x22,
  262. .reg_pld_table1 = 0x24,
  263. .reg_pld_table2 = 0x26,
  264. .reg_pld_table3 = 0x28,
  265. .reg_pld_table4 = 0x2a,
  266. .reg_advanced = 0xad,
  267. },
  268. .ngpios = 16,
  269. .pins = sx150x_16_pins,
  270. .npins = 16, /* oscio not available */
  271. };
  272. static const struct sx150x_device_data sx1507q_device_data = {
  273. .model = SX150X_789,
  274. .reg_pullup = 0x03,
  275. .reg_pulldn = 0x04,
  276. .reg_dir = 0x07,
  277. .reg_data = 0x08,
  278. .reg_irq_mask = 0x09,
  279. .reg_irq_src = 0x0b,
  280. .reg_sense = 0x0a,
  281. .pri.x789 = {
  282. .reg_drain = 0x05,
  283. .reg_polarity = 0x06,
  284. .reg_clock = 0x0d,
  285. .reg_misc = 0x0e,
  286. .reg_reset = 0x7d,
  287. },
  288. .ngpios = 4,
  289. .pins = sx150x_4_pins,
  290. .npins = ARRAY_SIZE(sx150x_4_pins),
  291. };
  292. static const struct sx150x_device_data sx1508q_device_data = {
  293. .model = SX150X_789,
  294. .reg_pullup = 0x03,
  295. .reg_pulldn = 0x04,
  296. .reg_dir = 0x07,
  297. .reg_data = 0x08,
  298. .reg_irq_mask = 0x09,
  299. .reg_irq_src = 0x0c,
  300. .reg_sense = 0x0a,
  301. .pri.x789 = {
  302. .reg_drain = 0x05,
  303. .reg_polarity = 0x06,
  304. .reg_clock = 0x0f,
  305. .reg_misc = 0x10,
  306. .reg_reset = 0x7d,
  307. },
  308. .ngpios = 8,
  309. .pins = sx150x_8_pins,
  310. .npins = ARRAY_SIZE(sx150x_8_pins),
  311. };
  312. static const struct sx150x_device_data sx1509q_device_data = {
  313. .model = SX150X_789,
  314. .reg_pullup = 0x06,
  315. .reg_pulldn = 0x08,
  316. .reg_dir = 0x0e,
  317. .reg_data = 0x10,
  318. .reg_irq_mask = 0x12,
  319. .reg_irq_src = 0x18,
  320. .reg_sense = 0x14,
  321. .pri.x789 = {
  322. .reg_drain = 0x0a,
  323. .reg_polarity = 0x0c,
  324. .reg_clock = 0x1e,
  325. .reg_misc = 0x1f,
  326. .reg_reset = 0x7d,
  327. },
  328. .ngpios = 16,
  329. .pins = sx150x_16_pins,
  330. .npins = ARRAY_SIZE(sx150x_16_pins),
  331. };
  332. static int sx150x_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
  333. {
  334. return 0;
  335. }
  336. static const char *sx150x_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
  337. unsigned int group)
  338. {
  339. return NULL;
  340. }
  341. static int sx150x_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
  342. unsigned int group,
  343. const unsigned int **pins,
  344. unsigned int *num_pins)
  345. {
  346. return -ENOTSUPP;
  347. }
  348. static const struct pinctrl_ops sx150x_pinctrl_ops = {
  349. .get_groups_count = sx150x_pinctrl_get_groups_count,
  350. .get_group_name = sx150x_pinctrl_get_group_name,
  351. .get_group_pins = sx150x_pinctrl_get_group_pins,
  352. #ifdef CONFIG_OF
  353. .dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
  354. .dt_free_map = pinctrl_utils_free_map,
  355. #endif
  356. };
  357. static bool sx150x_pin_is_oscio(struct sx150x_pinctrl *pctl, unsigned int pin)
  358. {
  359. if (pin >= pctl->data->npins)
  360. return false;
  361. /* OSCIO pin is only present in 789 devices */
  362. if (pctl->data->model != SX150X_789)
  363. return false;
  364. return !strcmp(pctl->data->pins[pin].name, "oscio");
  365. }
  366. static int sx150x_gpio_get_direction(struct gpio_chip *chip,
  367. unsigned int offset)
  368. {
  369. struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
  370. unsigned int value;
  371. int ret;
  372. if (sx150x_pin_is_oscio(pctl, offset))
  373. return false;
  374. ret = regmap_read(pctl->regmap, pctl->data->reg_dir, &value);
  375. if (ret < 0)
  376. return ret;
  377. return !!(value & BIT(offset));
  378. }
  379. static int sx150x_gpio_get(struct gpio_chip *chip, unsigned int offset)
  380. {
  381. struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
  382. unsigned int value;
  383. int ret;
  384. if (sx150x_pin_is_oscio(pctl, offset))
  385. return -EINVAL;
  386. ret = regmap_read(pctl->regmap, pctl->data->reg_data, &value);
  387. if (ret < 0)
  388. return ret;
  389. return !!(value & BIT(offset));
  390. }
  391. static int sx150x_gpio_set_single_ended(struct gpio_chip *chip,
  392. unsigned int offset,
  393. enum single_ended_mode mode)
  394. {
  395. struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
  396. int ret;
  397. switch (mode) {
  398. case LINE_MODE_PUSH_PULL:
  399. if (pctl->data->model != SX150X_789 ||
  400. sx150x_pin_is_oscio(pctl, offset))
  401. return 0;
  402. ret = regmap_write_bits(pctl->regmap,
  403. pctl->data->pri.x789.reg_drain,
  404. BIT(offset), 0);
  405. break;
  406. case LINE_MODE_OPEN_DRAIN:
  407. if (pctl->data->model != SX150X_789 ||
  408. sx150x_pin_is_oscio(pctl, offset))
  409. return -ENOTSUPP;
  410. ret = regmap_write_bits(pctl->regmap,
  411. pctl->data->pri.x789.reg_drain,
  412. BIT(offset), BIT(offset));
  413. break;
  414. default:
  415. ret = -ENOTSUPP;
  416. break;
  417. }
  418. return ret;
  419. }
  420. static int __sx150x_gpio_set(struct sx150x_pinctrl *pctl, unsigned int offset,
  421. int value)
  422. {
  423. return regmap_write_bits(pctl->regmap, pctl->data->reg_data,
  424. BIT(offset), value ? BIT(offset) : 0);
  425. }
  426. static int sx150x_gpio_oscio_set(struct sx150x_pinctrl *pctl,
  427. int value)
  428. {
  429. return regmap_write(pctl->regmap,
  430. pctl->data->pri.x789.reg_clock,
  431. (value ? 0x1f : 0x10));
  432. }
  433. static void sx150x_gpio_set(struct gpio_chip *chip, unsigned int offset,
  434. int value)
  435. {
  436. struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
  437. if (sx150x_pin_is_oscio(pctl, offset))
  438. sx150x_gpio_oscio_set(pctl, value);
  439. else
  440. __sx150x_gpio_set(pctl, offset, value);
  441. }
  442. static void sx150x_gpio_set_multiple(struct gpio_chip *chip,
  443. unsigned long *mask,
  444. unsigned long *bits)
  445. {
  446. struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
  447. regmap_write_bits(pctl->regmap, pctl->data->reg_data, *mask, *bits);
  448. }
  449. static int sx150x_gpio_direction_input(struct gpio_chip *chip,
  450. unsigned int offset)
  451. {
  452. struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
  453. if (sx150x_pin_is_oscio(pctl, offset))
  454. return -EINVAL;
  455. return regmap_write_bits(pctl->regmap,
  456. pctl->data->reg_dir,
  457. BIT(offset), BIT(offset));
  458. }
  459. static int sx150x_gpio_direction_output(struct gpio_chip *chip,
  460. unsigned int offset, int value)
  461. {
  462. struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
  463. int ret;
  464. if (sx150x_pin_is_oscio(pctl, offset))
  465. return sx150x_gpio_oscio_set(pctl, value);
  466. ret = __sx150x_gpio_set(pctl, offset, value);
  467. if (ret < 0)
  468. return ret;
  469. return regmap_write_bits(pctl->regmap,
  470. pctl->data->reg_dir,
  471. BIT(offset), 0);
  472. }
  473. static void sx150x_irq_mask(struct irq_data *d)
  474. {
  475. struct sx150x_pinctrl *pctl =
  476. gpiochip_get_data(irq_data_get_irq_chip_data(d));
  477. unsigned int n = d->hwirq;
  478. pctl->irq.masked |= BIT(n);
  479. }
  480. static void sx150x_irq_unmask(struct irq_data *d)
  481. {
  482. struct sx150x_pinctrl *pctl =
  483. gpiochip_get_data(irq_data_get_irq_chip_data(d));
  484. unsigned int n = d->hwirq;
  485. pctl->irq.masked &= ~BIT(n);
  486. }
  487. static void sx150x_irq_set_sense(struct sx150x_pinctrl *pctl,
  488. unsigned int line, unsigned int sense)
  489. {
  490. /*
  491. * Every interrupt line is represented by two bits shifted
  492. * proportionally to the line number
  493. */
  494. const unsigned int n = line * 2;
  495. const unsigned int mask = ~((SX150X_IRQ_TYPE_EDGE_RISING |
  496. SX150X_IRQ_TYPE_EDGE_FALLING) << n);
  497. pctl->irq.sense &= mask;
  498. pctl->irq.sense |= sense << n;
  499. }
  500. static int sx150x_irq_set_type(struct irq_data *d, unsigned int flow_type)
  501. {
  502. struct sx150x_pinctrl *pctl =
  503. gpiochip_get_data(irq_data_get_irq_chip_data(d));
  504. unsigned int n, val = 0;
  505. if (flow_type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW))
  506. return -EINVAL;
  507. n = d->hwirq;
  508. if (flow_type & IRQ_TYPE_EDGE_RISING)
  509. val |= SX150X_IRQ_TYPE_EDGE_RISING;
  510. if (flow_type & IRQ_TYPE_EDGE_FALLING)
  511. val |= SX150X_IRQ_TYPE_EDGE_FALLING;
  512. sx150x_irq_set_sense(pctl, n, val);
  513. return 0;
  514. }
  515. static irqreturn_t sx150x_irq_thread_fn(int irq, void *dev_id)
  516. {
  517. struct sx150x_pinctrl *pctl = (struct sx150x_pinctrl *)dev_id;
  518. unsigned long n, status;
  519. unsigned int val;
  520. int err;
  521. err = regmap_read(pctl->regmap, pctl->data->reg_irq_src, &val);
  522. if (err < 0)
  523. return IRQ_NONE;
  524. err = regmap_write(pctl->regmap, pctl->data->reg_irq_src, val);
  525. if (err < 0)
  526. return IRQ_NONE;
  527. status = val;
  528. for_each_set_bit(n, &status, pctl->data->ngpios)
  529. handle_nested_irq(irq_find_mapping(pctl->gpio.irqdomain, n));
  530. return IRQ_HANDLED;
  531. }
  532. static void sx150x_irq_bus_lock(struct irq_data *d)
  533. {
  534. struct sx150x_pinctrl *pctl =
  535. gpiochip_get_data(irq_data_get_irq_chip_data(d));
  536. mutex_lock(&pctl->lock);
  537. }
  538. static void sx150x_irq_bus_sync_unlock(struct irq_data *d)
  539. {
  540. struct sx150x_pinctrl *pctl =
  541. gpiochip_get_data(irq_data_get_irq_chip_data(d));
  542. regmap_write(pctl->regmap, pctl->data->reg_irq_mask, pctl->irq.masked);
  543. regmap_write(pctl->regmap, pctl->data->reg_sense, pctl->irq.sense);
  544. mutex_unlock(&pctl->lock);
  545. }
  546. static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
  547. unsigned long *config)
  548. {
  549. struct sx150x_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  550. unsigned int param = pinconf_to_config_param(*config);
  551. int ret;
  552. u32 arg;
  553. unsigned int data;
  554. if (sx150x_pin_is_oscio(pctl, pin)) {
  555. switch (param) {
  556. case PIN_CONFIG_DRIVE_PUSH_PULL:
  557. case PIN_CONFIG_OUTPUT:
  558. ret = regmap_read(pctl->regmap,
  559. pctl->data->pri.x789.reg_clock,
  560. &data);
  561. if (ret < 0)
  562. return ret;
  563. if (param == PIN_CONFIG_DRIVE_PUSH_PULL)
  564. arg = (data & 0x1f) ? 1 : 0;
  565. else {
  566. if ((data & 0x1f) == 0x1f)
  567. arg = 1;
  568. else if ((data & 0x1f) == 0x10)
  569. arg = 0;
  570. else
  571. return -EINVAL;
  572. }
  573. break;
  574. default:
  575. return -ENOTSUPP;
  576. }
  577. goto out;
  578. }
  579. switch (param) {
  580. case PIN_CONFIG_BIAS_PULL_DOWN:
  581. ret = regmap_read(pctl->regmap,
  582. pctl->data->reg_pulldn,
  583. &data);
  584. data &= BIT(pin);
  585. if (ret < 0)
  586. return ret;
  587. if (!ret)
  588. return -EINVAL;
  589. arg = 1;
  590. break;
  591. case PIN_CONFIG_BIAS_PULL_UP:
  592. ret = regmap_read(pctl->regmap,
  593. pctl->data->reg_pullup,
  594. &data);
  595. data &= BIT(pin);
  596. if (ret < 0)
  597. return ret;
  598. if (!ret)
  599. return -EINVAL;
  600. arg = 1;
  601. break;
  602. case PIN_CONFIG_DRIVE_OPEN_DRAIN:
  603. if (pctl->data->model != SX150X_789)
  604. return -ENOTSUPP;
  605. ret = regmap_read(pctl->regmap,
  606. pctl->data->pri.x789.reg_drain,
  607. &data);
  608. data &= BIT(pin);
  609. if (ret < 0)
  610. return ret;
  611. if (!data)
  612. return -EINVAL;
  613. arg = 1;
  614. break;
  615. case PIN_CONFIG_DRIVE_PUSH_PULL:
  616. if (pctl->data->model != SX150X_789)
  617. arg = true;
  618. else {
  619. ret = regmap_read(pctl->regmap,
  620. pctl->data->pri.x789.reg_drain,
  621. &data);
  622. data &= BIT(pin);
  623. if (ret < 0)
  624. return ret;
  625. if (data)
  626. return -EINVAL;
  627. arg = 1;
  628. }
  629. break;
  630. case PIN_CONFIG_OUTPUT:
  631. ret = sx150x_gpio_get_direction(&pctl->gpio, pin);
  632. if (ret < 0)
  633. return ret;
  634. if (ret)
  635. return -EINVAL;
  636. ret = sx150x_gpio_get(&pctl->gpio, pin);
  637. if (ret < 0)
  638. return ret;
  639. arg = ret;
  640. break;
  641. default:
  642. return -ENOTSUPP;
  643. }
  644. out:
  645. *config = pinconf_to_config_packed(param, arg);
  646. return 0;
  647. }
  648. static int sx150x_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
  649. unsigned long *configs, unsigned int num_configs)
  650. {
  651. struct sx150x_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  652. enum pin_config_param param;
  653. u32 arg;
  654. int i;
  655. int ret;
  656. for (i = 0; i < num_configs; i++) {
  657. param = pinconf_to_config_param(configs[i]);
  658. arg = pinconf_to_config_argument(configs[i]);
  659. if (sx150x_pin_is_oscio(pctl, pin)) {
  660. if (param == PIN_CONFIG_OUTPUT) {
  661. ret = sx150x_gpio_direction_output(&pctl->gpio,
  662. pin, arg);
  663. if (ret < 0)
  664. return ret;
  665. continue;
  666. } else
  667. return -ENOTSUPP;
  668. }
  669. switch (param) {
  670. case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
  671. case PIN_CONFIG_BIAS_DISABLE:
  672. ret = regmap_write_bits(pctl->regmap,
  673. pctl->data->reg_pulldn,
  674. BIT(pin), 0);
  675. if (ret < 0)
  676. return ret;
  677. ret = regmap_write_bits(pctl->regmap,
  678. pctl->data->reg_pullup,
  679. BIT(pin), 0);
  680. if (ret < 0)
  681. return ret;
  682. break;
  683. case PIN_CONFIG_BIAS_PULL_UP:
  684. ret = regmap_write_bits(pctl->regmap,
  685. pctl->data->reg_pullup,
  686. BIT(pin), BIT(pin));
  687. if (ret < 0)
  688. return ret;
  689. break;
  690. case PIN_CONFIG_BIAS_PULL_DOWN:
  691. ret = regmap_write_bits(pctl->regmap,
  692. pctl->data->reg_pulldn,
  693. BIT(pin), BIT(pin));
  694. if (ret < 0)
  695. return ret;
  696. break;
  697. case PIN_CONFIG_DRIVE_OPEN_DRAIN:
  698. ret = sx150x_gpio_set_single_ended(&pctl->gpio,
  699. pin, LINE_MODE_OPEN_DRAIN);
  700. if (ret < 0)
  701. return ret;
  702. break;
  703. case PIN_CONFIG_DRIVE_PUSH_PULL:
  704. ret = sx150x_gpio_set_single_ended(&pctl->gpio,
  705. pin, LINE_MODE_PUSH_PULL);
  706. if (ret < 0)
  707. return ret;
  708. break;
  709. case PIN_CONFIG_OUTPUT:
  710. ret = sx150x_gpio_direction_output(&pctl->gpio,
  711. pin, arg);
  712. if (ret < 0)
  713. return ret;
  714. break;
  715. default:
  716. return -ENOTSUPP;
  717. }
  718. } /* for each config */
  719. return 0;
  720. }
  721. static const struct pinconf_ops sx150x_pinconf_ops = {
  722. .pin_config_get = sx150x_pinconf_get,
  723. .pin_config_set = sx150x_pinconf_set,
  724. .is_generic = true,
  725. };
  726. static const struct i2c_device_id sx150x_id[] = {
  727. {"sx1501q", (kernel_ulong_t) &sx1501q_device_data },
  728. {"sx1502q", (kernel_ulong_t) &sx1502q_device_data },
  729. {"sx1503q", (kernel_ulong_t) &sx1503q_device_data },
  730. {"sx1504q", (kernel_ulong_t) &sx1504q_device_data },
  731. {"sx1505q", (kernel_ulong_t) &sx1505q_device_data },
  732. {"sx1506q", (kernel_ulong_t) &sx1506q_device_data },
  733. {"sx1507q", (kernel_ulong_t) &sx1507q_device_data },
  734. {"sx1508q", (kernel_ulong_t) &sx1508q_device_data },
  735. {"sx1509q", (kernel_ulong_t) &sx1509q_device_data },
  736. {}
  737. };
  738. static const struct of_device_id sx150x_of_match[] = {
  739. { .compatible = "semtech,sx1501q", .data = &sx1501q_device_data },
  740. { .compatible = "semtech,sx1502q", .data = &sx1502q_device_data },
  741. { .compatible = "semtech,sx1503q", .data = &sx1503q_device_data },
  742. { .compatible = "semtech,sx1504q", .data = &sx1504q_device_data },
  743. { .compatible = "semtech,sx1505q", .data = &sx1505q_device_data },
  744. { .compatible = "semtech,sx1506q", .data = &sx1506q_device_data },
  745. { .compatible = "semtech,sx1507q", .data = &sx1507q_device_data },
  746. { .compatible = "semtech,sx1508q", .data = &sx1508q_device_data },
  747. { .compatible = "semtech,sx1509q", .data = &sx1509q_device_data },
  748. {},
  749. };
  750. static int sx150x_reset(struct sx150x_pinctrl *pctl)
  751. {
  752. int err;
  753. err = i2c_smbus_write_byte_data(pctl->client,
  754. pctl->data->pri.x789.reg_reset,
  755. SX150X_789_RESET_KEY1);
  756. if (err < 0)
  757. return err;
  758. err = i2c_smbus_write_byte_data(pctl->client,
  759. pctl->data->pri.x789.reg_reset,
  760. SX150X_789_RESET_KEY2);
  761. return err;
  762. }
  763. static int sx150x_init_misc(struct sx150x_pinctrl *pctl)
  764. {
  765. u8 reg, value;
  766. switch (pctl->data->model) {
  767. case SX150X_789:
  768. reg = pctl->data->pri.x789.reg_misc;
  769. value = SX150X_789_REG_MISC_AUTOCLEAR_OFF;
  770. break;
  771. case SX150X_456:
  772. reg = pctl->data->pri.x456.reg_advanced;
  773. value = 0x00;
  774. /*
  775. * Only SX1506 has RegAdvanced, SX1504/5 are expected
  776. * to initialize this offset to zero
  777. */
  778. if (!reg)
  779. return 0;
  780. break;
  781. case SX150X_123:
  782. reg = pctl->data->pri.x123.reg_advanced;
  783. value = 0x00;
  784. break;
  785. default:
  786. WARN(1, "Unknown chip model %d\n", pctl->data->model);
  787. return -EINVAL;
  788. }
  789. return regmap_write(pctl->regmap, reg, value);
  790. }
  791. static int sx150x_init_hw(struct sx150x_pinctrl *pctl)
  792. {
  793. const u8 reg[] = {
  794. [SX150X_789] = pctl->data->pri.x789.reg_polarity,
  795. [SX150X_456] = pctl->data->pri.x456.reg_pld_mode,
  796. [SX150X_123] = pctl->data->pri.x123.reg_pld_mode,
  797. };
  798. int err;
  799. if (pctl->data->model == SX150X_789 &&
  800. of_property_read_bool(pctl->dev->of_node, "semtech,probe-reset")) {
  801. err = sx150x_reset(pctl);
  802. if (err < 0)
  803. return err;
  804. }
  805. err = sx150x_init_misc(pctl);
  806. if (err < 0)
  807. return err;
  808. /* Set all pins to work in normal mode */
  809. return regmap_write(pctl->regmap, reg[pctl->data->model], 0);
  810. }
  811. static int sx150x_regmap_reg_width(struct sx150x_pinctrl *pctl,
  812. unsigned int reg)
  813. {
  814. const struct sx150x_device_data *data = pctl->data;
  815. if (reg == data->reg_sense) {
  816. /*
  817. * RegSense packs two bits of configuration per GPIO,
  818. * so we'd need to read twice as many bits as there
  819. * are GPIO in our chip
  820. */
  821. return 2 * data->ngpios;
  822. } else if ((data->model == SX150X_789 &&
  823. (reg == data->pri.x789.reg_misc ||
  824. reg == data->pri.x789.reg_clock ||
  825. reg == data->pri.x789.reg_reset))
  826. ||
  827. (data->model == SX150X_123 &&
  828. reg == data->pri.x123.reg_advanced)
  829. ||
  830. (data->model == SX150X_456 &&
  831. data->pri.x456.reg_advanced &&
  832. reg == data->pri.x456.reg_advanced)) {
  833. return 8;
  834. } else {
  835. return data->ngpios;
  836. }
  837. }
  838. static unsigned int sx150x_maybe_swizzle(struct sx150x_pinctrl *pctl,
  839. unsigned int reg, unsigned int val)
  840. {
  841. unsigned int a, b;
  842. const struct sx150x_device_data *data = pctl->data;
  843. /*
  844. * Whereas SX1509 presents RegSense in a simple layout as such:
  845. * reg [ f f e e d d c c ]
  846. * reg + 1 [ b b a a 9 9 8 8 ]
  847. * reg + 2 [ 7 7 6 6 5 5 4 4 ]
  848. * reg + 3 [ 3 3 2 2 1 1 0 0 ]
  849. *
  850. * SX1503 and SX1506 deviate from that data layout, instead storing
  851. * their contents as follows:
  852. *
  853. * reg [ f f e e d d c c ]
  854. * reg + 1 [ 7 7 6 6 5 5 4 4 ]
  855. * reg + 2 [ b b a a 9 9 8 8 ]
  856. * reg + 3 [ 3 3 2 2 1 1 0 0 ]
  857. *
  858. * so, taking that into account, we swap two
  859. * inner bytes of a 4-byte result
  860. */
  861. if (reg == data->reg_sense &&
  862. data->ngpios == 16 &&
  863. (data->model == SX150X_123 ||
  864. data->model == SX150X_456)) {
  865. a = val & 0x00ff0000;
  866. b = val & 0x0000ff00;
  867. val &= 0xff0000ff;
  868. val |= b << 8;
  869. val |= a >> 8;
  870. }
  871. return val;
  872. }
  873. /*
  874. * In order to mask the differences between 16 and 8 bit expander
  875. * devices we set up a sligthly ficticious regmap that pretends to be
  876. * a set of 32-bit (to accomodate RegSenseLow/RegSenseHigh
  877. * pair/quartet) registers and transparently reconstructs those
  878. * registers via multiple I2C/SMBus reads
  879. *
  880. * This way the rest of the driver code, interfacing with the chip via
  881. * regmap API, can work assuming that each GPIO pin is represented by
  882. * a group of bits at an offset proportional to GPIO number within a
  883. * given register.
  884. */
  885. static int sx150x_regmap_reg_read(void *context, unsigned int reg,
  886. unsigned int *result)
  887. {
  888. int ret, n;
  889. struct sx150x_pinctrl *pctl = context;
  890. struct i2c_client *i2c = pctl->client;
  891. const int width = sx150x_regmap_reg_width(pctl, reg);
  892. unsigned int idx, val;
  893. /*
  894. * There are four potential cases covered by this function:
  895. *
  896. * 1) 8-pin chip, single configuration bit register
  897. *
  898. * This is trivial the code below just needs to read:
  899. * reg [ 7 6 5 4 3 2 1 0 ]
  900. *
  901. * 2) 8-pin chip, double configuration bit register (RegSense)
  902. *
  903. * The read will be done as follows:
  904. * reg [ 7 7 6 6 5 5 4 4 ]
  905. * reg + 1 [ 3 3 2 2 1 1 0 0 ]
  906. *
  907. * 3) 16-pin chip, single configuration bit register
  908. *
  909. * The read will be done as follows:
  910. * reg [ f e d c b a 9 8 ]
  911. * reg + 1 [ 7 6 5 4 3 2 1 0 ]
  912. *
  913. * 4) 16-pin chip, double configuration bit register (RegSense)
  914. *
  915. * The read will be done as follows:
  916. * reg [ f f e e d d c c ]
  917. * reg + 1 [ b b a a 9 9 8 8 ]
  918. * reg + 2 [ 7 7 6 6 5 5 4 4 ]
  919. * reg + 3 [ 3 3 2 2 1 1 0 0 ]
  920. */
  921. for (n = width, val = 0, idx = reg; n > 0; n -= 8, idx++) {
  922. val <<= 8;
  923. ret = i2c_smbus_read_byte_data(i2c, idx);
  924. if (ret < 0)
  925. return ret;
  926. val |= ret;
  927. }
  928. *result = sx150x_maybe_swizzle(pctl, reg, val);
  929. return 0;
  930. }
  931. static int sx150x_regmap_reg_write(void *context, unsigned int reg,
  932. unsigned int val)
  933. {
  934. int ret, n;
  935. struct sx150x_pinctrl *pctl = context;
  936. struct i2c_client *i2c = pctl->client;
  937. const int width = sx150x_regmap_reg_width(pctl, reg);
  938. val = sx150x_maybe_swizzle(pctl, reg, val);
  939. n = (width - 1) & ~7;
  940. do {
  941. const u8 byte = (val >> n) & 0xff;
  942. ret = i2c_smbus_write_byte_data(i2c, reg, byte);
  943. if (ret < 0)
  944. return ret;
  945. reg++;
  946. n -= 8;
  947. } while (n >= 0);
  948. return 0;
  949. }
  950. static bool sx150x_reg_volatile(struct device *dev, unsigned int reg)
  951. {
  952. struct sx150x_pinctrl *pctl = i2c_get_clientdata(to_i2c_client(dev));
  953. return reg == pctl->data->reg_irq_src || reg == pctl->data->reg_data;
  954. }
  955. const struct regmap_config sx150x_regmap_config = {
  956. .reg_bits = 8,
  957. .val_bits = 32,
  958. .cache_type = REGCACHE_RBTREE,
  959. .reg_read = sx150x_regmap_reg_read,
  960. .reg_write = sx150x_regmap_reg_write,
  961. .max_register = SX150X_MAX_REGISTER,
  962. .volatile_reg = sx150x_reg_volatile,
  963. };
  964. static int sx150x_probe(struct i2c_client *client,
  965. const struct i2c_device_id *id)
  966. {
  967. static const u32 i2c_funcs = I2C_FUNC_SMBUS_BYTE_DATA |
  968. I2C_FUNC_SMBUS_WRITE_WORD_DATA;
  969. struct device *dev = &client->dev;
  970. struct sx150x_pinctrl *pctl;
  971. int ret;
  972. if (!i2c_check_functionality(client->adapter, i2c_funcs))
  973. return -ENOSYS;
  974. pctl = devm_kzalloc(dev, sizeof(*pctl), GFP_KERNEL);
  975. if (!pctl)
  976. return -ENOMEM;
  977. i2c_set_clientdata(client, pctl);
  978. pctl->dev = dev;
  979. pctl->client = client;
  980. if (dev->of_node)
  981. pctl->data = of_device_get_match_data(dev);
  982. else
  983. pctl->data = (struct sx150x_device_data *)id->driver_data;
  984. if (!pctl->data)
  985. return -EINVAL;
  986. pctl->regmap = devm_regmap_init(dev, NULL, pctl,
  987. &sx150x_regmap_config);
  988. if (IS_ERR(pctl->regmap)) {
  989. ret = PTR_ERR(pctl->regmap);
  990. dev_err(dev, "Failed to allocate register map: %d\n",
  991. ret);
  992. return ret;
  993. }
  994. mutex_init(&pctl->lock);
  995. ret = sx150x_init_hw(pctl);
  996. if (ret)
  997. return ret;
  998. /* Register GPIO controller */
  999. pctl->gpio.label = devm_kstrdup(dev, client->name, GFP_KERNEL);
  1000. pctl->gpio.base = -1;
  1001. pctl->gpio.ngpio = pctl->data->npins;
  1002. pctl->gpio.get_direction = sx150x_gpio_get_direction;
  1003. pctl->gpio.direction_input = sx150x_gpio_direction_input;
  1004. pctl->gpio.direction_output = sx150x_gpio_direction_output;
  1005. pctl->gpio.get = sx150x_gpio_get;
  1006. pctl->gpio.set = sx150x_gpio_set;
  1007. pctl->gpio.set_single_ended = sx150x_gpio_set_single_ended;
  1008. pctl->gpio.parent = dev;
  1009. #ifdef CONFIG_OF_GPIO
  1010. pctl->gpio.of_node = dev->of_node;
  1011. #endif
  1012. pctl->gpio.can_sleep = true;
  1013. /*
  1014. * Setting multiple pins is not safe when all pins are not
  1015. * handled by the same regmap register. The oscio pin (present
  1016. * on the SX150X_789 chips) lives in its own register, so
  1017. * would require locking that is not in place at this time.
  1018. */
  1019. if (pctl->data->model != SX150X_789)
  1020. pctl->gpio.set_multiple = sx150x_gpio_set_multiple;
  1021. ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
  1022. if (ret)
  1023. return ret;
  1024. /* Add Interrupt support if an irq is specified */
  1025. if (client->irq > 0) {
  1026. pctl->irq_chip.name = devm_kstrdup(dev, client->name,
  1027. GFP_KERNEL);
  1028. pctl->irq_chip.irq_mask = sx150x_irq_mask;
  1029. pctl->irq_chip.irq_unmask = sx150x_irq_unmask;
  1030. pctl->irq_chip.irq_set_type = sx150x_irq_set_type;
  1031. pctl->irq_chip.irq_bus_lock = sx150x_irq_bus_lock;
  1032. pctl->irq_chip.irq_bus_sync_unlock = sx150x_irq_bus_sync_unlock;
  1033. pctl->irq.masked = ~0;
  1034. pctl->irq.sense = 0;
  1035. /*
  1036. * Because sx150x_irq_threaded_fn invokes all of the
  1037. * nested interrrupt handlers via handle_nested_irq,
  1038. * any "handler" passed to gpiochip_irqchip_add()
  1039. * below is going to be ignored, so the choice of the
  1040. * function does not matter that much.
  1041. *
  1042. * We set it to handle_bad_irq to avoid confusion,
  1043. * plus it will be instantly noticeable if it is ever
  1044. * called (should not happen)
  1045. */
  1046. ret = gpiochip_irqchip_add_nested(&pctl->gpio,
  1047. &pctl->irq_chip, 0,
  1048. handle_bad_irq, IRQ_TYPE_NONE);
  1049. if (ret) {
  1050. dev_err(dev, "could not connect irqchip to gpiochip\n");
  1051. return ret;
  1052. }
  1053. ret = devm_request_threaded_irq(dev, client->irq, NULL,
  1054. sx150x_irq_thread_fn,
  1055. IRQF_ONESHOT | IRQF_SHARED |
  1056. IRQF_TRIGGER_FALLING,
  1057. pctl->irq_chip.name, pctl);
  1058. if (ret < 0)
  1059. return ret;
  1060. gpiochip_set_nested_irqchip(&pctl->gpio,
  1061. &pctl->irq_chip,
  1062. client->irq);
  1063. }
  1064. /* Pinctrl_desc */
  1065. pctl->pinctrl_desc.name = "sx150x-pinctrl";
  1066. pctl->pinctrl_desc.pctlops = &sx150x_pinctrl_ops;
  1067. pctl->pinctrl_desc.confops = &sx150x_pinconf_ops;
  1068. pctl->pinctrl_desc.pins = pctl->data->pins;
  1069. pctl->pinctrl_desc.npins = pctl->data->npins;
  1070. pctl->pinctrl_desc.owner = THIS_MODULE;
  1071. pctl->pctldev = pinctrl_register(&pctl->pinctrl_desc, dev, pctl);
  1072. if (IS_ERR(pctl->pctldev)) {
  1073. dev_err(dev, "Failed to register pinctrl device\n");
  1074. return PTR_ERR(pctl->pctldev);
  1075. }
  1076. return 0;
  1077. }
  1078. static struct i2c_driver sx150x_driver = {
  1079. .driver = {
  1080. .name = "sx150x-pinctrl",
  1081. .of_match_table = of_match_ptr(sx150x_of_match),
  1082. },
  1083. .probe = sx150x_probe,
  1084. .id_table = sx150x_id,
  1085. };
  1086. static int __init sx150x_init(void)
  1087. {
  1088. return i2c_add_driver(&sx150x_driver);
  1089. }
  1090. subsys_initcall(sx150x_init);