pinctrl-spmi-gpio.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. /*
  2. * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/gpio.h>
  14. #include <linux/module.h>
  15. #include <linux/of.h>
  16. #include <linux/of_irq.h>
  17. #include <linux/pinctrl/pinconf-generic.h>
  18. #include <linux/pinctrl/pinconf.h>
  19. #include <linux/pinctrl/pinmux.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/regmap.h>
  22. #include <linux/slab.h>
  23. #include <linux/types.h>
  24. #include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
  25. #include "../core.h"
  26. #include "../pinctrl-utils.h"
  27. #define PMIC_GPIO_ADDRESS_RANGE 0x100
  28. /* type and subtype registers base address offsets */
  29. #define PMIC_GPIO_REG_TYPE 0x4
  30. #define PMIC_GPIO_REG_SUBTYPE 0x5
  31. /* GPIO peripheral type and subtype out_values */
  32. #define PMIC_GPIO_TYPE 0x10
  33. #define PMIC_GPIO_SUBTYPE_GPIO_4CH 0x1
  34. #define PMIC_GPIO_SUBTYPE_GPIOC_4CH 0x5
  35. #define PMIC_GPIO_SUBTYPE_GPIO_8CH 0x9
  36. #define PMIC_GPIO_SUBTYPE_GPIOC_8CH 0xd
  37. #define PMIC_GPIO_SUBTYPE_GPIO_LV 0x10
  38. #define PMIC_GPIO_SUBTYPE_GPIO_MV 0x11
  39. #define PMIC_MPP_REG_RT_STS 0x10
  40. #define PMIC_MPP_REG_RT_STS_VAL_MASK 0x1
  41. /* control register base address offsets */
  42. #define PMIC_GPIO_REG_MODE_CTL 0x40
  43. #define PMIC_GPIO_REG_DIG_VIN_CTL 0x41
  44. #define PMIC_GPIO_REG_DIG_PULL_CTL 0x42
  45. #define PMIC_GPIO_REG_LV_MV_DIG_OUT_SOURCE_CTL 0x44
  46. #define PMIC_GPIO_REG_DIG_IN_CTL 0x43
  47. #define PMIC_GPIO_REG_DIG_OUT_CTL 0x45
  48. #define PMIC_GPIO_REG_EN_CTL 0x46
  49. #define PMIC_GPIO_REG_LV_MV_ANA_PASS_THRU_SEL 0x4A
  50. /* PMIC_GPIO_REG_MODE_CTL */
  51. #define PMIC_GPIO_REG_MODE_VALUE_SHIFT 0x1
  52. #define PMIC_GPIO_REG_MODE_FUNCTION_SHIFT 1
  53. #define PMIC_GPIO_REG_MODE_FUNCTION_MASK 0x7
  54. #define PMIC_GPIO_REG_MODE_DIR_SHIFT 4
  55. #define PMIC_GPIO_REG_MODE_DIR_MASK 0x7
  56. #define PMIC_GPIO_MODE_DIGITAL_INPUT 0
  57. #define PMIC_GPIO_MODE_DIGITAL_OUTPUT 1
  58. #define PMIC_GPIO_MODE_DIGITAL_INPUT_OUTPUT 2
  59. #define PMIC_GPIO_MODE_ANALOG_PASS_THRU 3
  60. #define PMIC_GPIO_REG_LV_MV_MODE_DIR_MASK 0x3
  61. /* PMIC_GPIO_REG_DIG_VIN_CTL */
  62. #define PMIC_GPIO_REG_VIN_SHIFT 0
  63. #define PMIC_GPIO_REG_VIN_MASK 0x7
  64. /* PMIC_GPIO_REG_DIG_PULL_CTL */
  65. #define PMIC_GPIO_REG_PULL_SHIFT 0
  66. #define PMIC_GPIO_REG_PULL_MASK 0x7
  67. #define PMIC_GPIO_PULL_DOWN 4
  68. #define PMIC_GPIO_PULL_DISABLE 5
  69. /* PMIC_GPIO_REG_LV_MV_DIG_OUT_SOURCE_CTL for LV/MV */
  70. #define PMIC_GPIO_LV_MV_OUTPUT_INVERT 0x80
  71. #define PMIC_GPIO_LV_MV_OUTPUT_INVERT_SHIFT 7
  72. #define PMIC_GPIO_LV_MV_OUTPUT_SOURCE_SEL_MASK 0xF
  73. /* PMIC_GPIO_REG_DIG_IN_CTL */
  74. #define PMIC_GPIO_LV_MV_DIG_IN_DTEST_EN 0x80
  75. #define PMIC_GPIO_LV_MV_DIG_IN_DTEST_SEL_MASK 0x7
  76. #define PMIC_GPIO_DIG_IN_DTEST_SEL_MASK 0xf
  77. /* PMIC_GPIO_REG_DIG_OUT_CTL */
  78. #define PMIC_GPIO_REG_OUT_STRENGTH_SHIFT 0
  79. #define PMIC_GPIO_REG_OUT_STRENGTH_MASK 0x3
  80. #define PMIC_GPIO_REG_OUT_TYPE_SHIFT 4
  81. #define PMIC_GPIO_REG_OUT_TYPE_MASK 0x3
  82. /*
  83. * Output type - indicates pin should be configured as push-pull,
  84. * open drain or open source.
  85. */
  86. #define PMIC_GPIO_OUT_BUF_CMOS 0
  87. #define PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS 1
  88. #define PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS 2
  89. /* PMIC_GPIO_REG_EN_CTL */
  90. #define PMIC_GPIO_REG_MASTER_EN_SHIFT 7
  91. #define PMIC_GPIO_PHYSICAL_OFFSET 1
  92. /* PMIC_GPIO_REG_LV_MV_ANA_PASS_THRU_SEL */
  93. #define PMIC_GPIO_LV_MV_ANA_MUX_SEL_MASK 0x3
  94. /* Qualcomm specific pin configurations */
  95. #define PMIC_GPIO_CONF_PULL_UP (PIN_CONFIG_END + 1)
  96. #define PMIC_GPIO_CONF_STRENGTH (PIN_CONFIG_END + 2)
  97. #define PMIC_GPIO_CONF_ATEST (PIN_CONFIG_END + 3)
  98. #define PMIC_GPIO_CONF_ANALOG_PASS (PIN_CONFIG_END + 4)
  99. #define PMIC_GPIO_CONF_DTEST_BUFFER (PIN_CONFIG_END + 5)
  100. /* The index of each function in pmic_gpio_functions[] array */
  101. enum pmic_gpio_func_index {
  102. PMIC_GPIO_FUNC_INDEX_NORMAL,
  103. PMIC_GPIO_FUNC_INDEX_PAIRED,
  104. PMIC_GPIO_FUNC_INDEX_FUNC1,
  105. PMIC_GPIO_FUNC_INDEX_FUNC2,
  106. PMIC_GPIO_FUNC_INDEX_FUNC3,
  107. PMIC_GPIO_FUNC_INDEX_FUNC4,
  108. PMIC_GPIO_FUNC_INDEX_DTEST1,
  109. PMIC_GPIO_FUNC_INDEX_DTEST2,
  110. PMIC_GPIO_FUNC_INDEX_DTEST3,
  111. PMIC_GPIO_FUNC_INDEX_DTEST4,
  112. };
  113. /**
  114. * struct pmic_gpio_pad - keep current GPIO settings
  115. * @base: Address base in SPMI device.
  116. * @irq: IRQ number which this GPIO generate.
  117. * @is_enabled: Set to false when GPIO should be put in high Z state.
  118. * @out_value: Cached pin output value
  119. * @have_buffer: Set to true if GPIO output could be configured in push-pull,
  120. * open-drain or open-source mode.
  121. * @output_enabled: Set to true if GPIO output logic is enabled.
  122. * @input_enabled: Set to true if GPIO input buffer logic is enabled.
  123. * @analog_pass: Set to true if GPIO is in analog-pass-through mode.
  124. * @lv_mv_type: Set to true if GPIO subtype is GPIO_LV(0x10) or GPIO_MV(0x11).
  125. * @num_sources: Number of power-sources supported by this GPIO.
  126. * @power_source: Current power-source used.
  127. * @buffer_type: Push-pull, open-drain or open-source.
  128. * @pullup: Constant current which flow trough GPIO output buffer.
  129. * @strength: No, Low, Medium, High
  130. * @function: See pmic_gpio_functions[]
  131. * @atest: the ATEST selection for GPIO analog-pass-through mode
  132. * @dtest_buffer: the DTEST buffer selection for digital input mode.
  133. */
  134. struct pmic_gpio_pad {
  135. u16 base;
  136. int irq;
  137. bool is_enabled;
  138. bool out_value;
  139. bool have_buffer;
  140. bool output_enabled;
  141. bool input_enabled;
  142. bool analog_pass;
  143. bool lv_mv_type;
  144. unsigned int num_sources;
  145. unsigned int power_source;
  146. unsigned int buffer_type;
  147. unsigned int pullup;
  148. unsigned int strength;
  149. unsigned int function;
  150. unsigned int atest;
  151. unsigned int dtest_buffer;
  152. };
  153. struct pmic_gpio_state {
  154. struct device *dev;
  155. struct regmap *map;
  156. struct pinctrl_dev *ctrl;
  157. struct gpio_chip chip;
  158. };
  159. static const struct pinconf_generic_params pmic_gpio_bindings[] = {
  160. {"qcom,pull-up-strength", PMIC_GPIO_CONF_PULL_UP, 0},
  161. {"qcom,drive-strength", PMIC_GPIO_CONF_STRENGTH, 0},
  162. {"qcom,atest", PMIC_GPIO_CONF_ATEST, 0},
  163. {"qcom,analog-pass", PMIC_GPIO_CONF_ANALOG_PASS, 0},
  164. {"qcom,dtest-buffer", PMIC_GPIO_CONF_DTEST_BUFFER, 0},
  165. };
  166. #ifdef CONFIG_DEBUG_FS
  167. static const struct pin_config_item pmic_conf_items[ARRAY_SIZE(pmic_gpio_bindings)] = {
  168. PCONFDUMP(PMIC_GPIO_CONF_PULL_UP, "pull up strength", NULL, true),
  169. PCONFDUMP(PMIC_GPIO_CONF_STRENGTH, "drive-strength", NULL, true),
  170. PCONFDUMP(PMIC_GPIO_CONF_ATEST, "atest", NULL, true),
  171. PCONFDUMP(PMIC_GPIO_CONF_ANALOG_PASS, "analog-pass", NULL, true),
  172. PCONFDUMP(PMIC_GPIO_CONF_DTEST_BUFFER, "dtest-buffer", NULL, true),
  173. };
  174. #endif
  175. static const char *const pmic_gpio_groups[] = {
  176. "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7", "gpio8",
  177. "gpio9", "gpio10", "gpio11", "gpio12", "gpio13", "gpio14", "gpio15",
  178. "gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21", "gpio22",
  179. "gpio23", "gpio24", "gpio25", "gpio26", "gpio27", "gpio28", "gpio29",
  180. "gpio30", "gpio31", "gpio32", "gpio33", "gpio34", "gpio35", "gpio36",
  181. };
  182. static const char *const pmic_gpio_functions[] = {
  183. [PMIC_GPIO_FUNC_INDEX_NORMAL] = PMIC_GPIO_FUNC_NORMAL,
  184. [PMIC_GPIO_FUNC_INDEX_PAIRED] = PMIC_GPIO_FUNC_PAIRED,
  185. [PMIC_GPIO_FUNC_INDEX_FUNC1] = PMIC_GPIO_FUNC_FUNC1,
  186. [PMIC_GPIO_FUNC_INDEX_FUNC2] = PMIC_GPIO_FUNC_FUNC2,
  187. [PMIC_GPIO_FUNC_INDEX_FUNC3] = PMIC_GPIO_FUNC_FUNC3,
  188. [PMIC_GPIO_FUNC_INDEX_FUNC4] = PMIC_GPIO_FUNC_FUNC4,
  189. [PMIC_GPIO_FUNC_INDEX_DTEST1] = PMIC_GPIO_FUNC_DTEST1,
  190. [PMIC_GPIO_FUNC_INDEX_DTEST2] = PMIC_GPIO_FUNC_DTEST2,
  191. [PMIC_GPIO_FUNC_INDEX_DTEST3] = PMIC_GPIO_FUNC_DTEST3,
  192. [PMIC_GPIO_FUNC_INDEX_DTEST4] = PMIC_GPIO_FUNC_DTEST4,
  193. };
  194. static int pmic_gpio_read(struct pmic_gpio_state *state,
  195. struct pmic_gpio_pad *pad, unsigned int addr)
  196. {
  197. unsigned int val;
  198. int ret;
  199. ret = regmap_read(state->map, pad->base + addr, &val);
  200. if (ret < 0)
  201. dev_err(state->dev, "read 0x%x failed\n", addr);
  202. else
  203. ret = val;
  204. return ret;
  205. }
  206. static int pmic_gpio_write(struct pmic_gpio_state *state,
  207. struct pmic_gpio_pad *pad, unsigned int addr,
  208. unsigned int val)
  209. {
  210. int ret;
  211. ret = regmap_write(state->map, pad->base + addr, val);
  212. if (ret < 0)
  213. dev_err(state->dev, "write 0x%x failed\n", addr);
  214. return ret;
  215. }
  216. static int pmic_gpio_get_groups_count(struct pinctrl_dev *pctldev)
  217. {
  218. /* Every PIN is a group */
  219. return pctldev->desc->npins;
  220. }
  221. static const char *pmic_gpio_get_group_name(struct pinctrl_dev *pctldev,
  222. unsigned pin)
  223. {
  224. return pctldev->desc->pins[pin].name;
  225. }
  226. static int pmic_gpio_get_group_pins(struct pinctrl_dev *pctldev, unsigned pin,
  227. const unsigned **pins, unsigned *num_pins)
  228. {
  229. *pins = &pctldev->desc->pins[pin].number;
  230. *num_pins = 1;
  231. return 0;
  232. }
  233. static const struct pinctrl_ops pmic_gpio_pinctrl_ops = {
  234. .get_groups_count = pmic_gpio_get_groups_count,
  235. .get_group_name = pmic_gpio_get_group_name,
  236. .get_group_pins = pmic_gpio_get_group_pins,
  237. .dt_node_to_map = pinconf_generic_dt_node_to_map_group,
  238. .dt_free_map = pinctrl_utils_free_map,
  239. };
  240. static int pmic_gpio_get_functions_count(struct pinctrl_dev *pctldev)
  241. {
  242. return ARRAY_SIZE(pmic_gpio_functions);
  243. }
  244. static const char *pmic_gpio_get_function_name(struct pinctrl_dev *pctldev,
  245. unsigned function)
  246. {
  247. return pmic_gpio_functions[function];
  248. }
  249. static int pmic_gpio_get_function_groups(struct pinctrl_dev *pctldev,
  250. unsigned function,
  251. const char *const **groups,
  252. unsigned *const num_qgroups)
  253. {
  254. *groups = pmic_gpio_groups;
  255. *num_qgroups = pctldev->desc->npins;
  256. return 0;
  257. }
  258. static int pmic_gpio_set_mux(struct pinctrl_dev *pctldev, unsigned function,
  259. unsigned pin)
  260. {
  261. struct pmic_gpio_state *state = pinctrl_dev_get_drvdata(pctldev);
  262. struct pmic_gpio_pad *pad;
  263. unsigned int val;
  264. int ret;
  265. if (function > PMIC_GPIO_FUNC_INDEX_DTEST4) {
  266. pr_err("function: %d is not defined\n", function);
  267. return -EINVAL;
  268. }
  269. pad = pctldev->desc->pins[pin].drv_data;
  270. /*
  271. * Non-LV/MV subtypes only support 2 special functions,
  272. * offsetting the dtestx function values by 2
  273. */
  274. if (!pad->lv_mv_type) {
  275. if (function == PMIC_GPIO_FUNC_INDEX_FUNC3 ||
  276. function == PMIC_GPIO_FUNC_INDEX_FUNC4) {
  277. pr_err("LV/MV subtype doesn't have func3/func4\n");
  278. return -EINVAL;
  279. }
  280. if (function >= PMIC_GPIO_FUNC_INDEX_DTEST1)
  281. function -= (PMIC_GPIO_FUNC_INDEX_DTEST1 -
  282. PMIC_GPIO_FUNC_INDEX_FUNC3);
  283. }
  284. pad->function = function;
  285. if (pad->analog_pass)
  286. val = PMIC_GPIO_MODE_ANALOG_PASS_THRU;
  287. else if (pad->output_enabled && pad->input_enabled)
  288. val = PMIC_GPIO_MODE_DIGITAL_INPUT_OUTPUT;
  289. else if (pad->output_enabled)
  290. val = PMIC_GPIO_MODE_DIGITAL_OUTPUT;
  291. else
  292. val = PMIC_GPIO_MODE_DIGITAL_INPUT;
  293. if (pad->lv_mv_type) {
  294. ret = pmic_gpio_write(state, pad,
  295. PMIC_GPIO_REG_MODE_CTL, val);
  296. if (ret < 0)
  297. return ret;
  298. val = pad->atest - 1;
  299. ret = pmic_gpio_write(state, pad,
  300. PMIC_GPIO_REG_LV_MV_ANA_PASS_THRU_SEL, val);
  301. if (ret < 0)
  302. return ret;
  303. val = pad->out_value
  304. << PMIC_GPIO_LV_MV_OUTPUT_INVERT_SHIFT;
  305. val |= pad->function
  306. & PMIC_GPIO_LV_MV_OUTPUT_SOURCE_SEL_MASK;
  307. ret = pmic_gpio_write(state, pad,
  308. PMIC_GPIO_REG_LV_MV_DIG_OUT_SOURCE_CTL, val);
  309. if (ret < 0)
  310. return ret;
  311. } else {
  312. val = val << PMIC_GPIO_REG_MODE_DIR_SHIFT;
  313. val |= pad->function << PMIC_GPIO_REG_MODE_FUNCTION_SHIFT;
  314. val |= pad->out_value & PMIC_GPIO_REG_MODE_VALUE_SHIFT;
  315. ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_MODE_CTL, val);
  316. if (ret < 0)
  317. return ret;
  318. }
  319. val = pad->is_enabled << PMIC_GPIO_REG_MASTER_EN_SHIFT;
  320. return pmic_gpio_write(state, pad, PMIC_GPIO_REG_EN_CTL, val);
  321. }
  322. static const struct pinmux_ops pmic_gpio_pinmux_ops = {
  323. .get_functions_count = pmic_gpio_get_functions_count,
  324. .get_function_name = pmic_gpio_get_function_name,
  325. .get_function_groups = pmic_gpio_get_function_groups,
  326. .set_mux = pmic_gpio_set_mux,
  327. };
  328. static int pmic_gpio_config_get(struct pinctrl_dev *pctldev,
  329. unsigned int pin, unsigned long *config)
  330. {
  331. unsigned param = pinconf_to_config_param(*config);
  332. struct pmic_gpio_pad *pad;
  333. unsigned arg;
  334. pad = pctldev->desc->pins[pin].drv_data;
  335. switch (param) {
  336. case PIN_CONFIG_DRIVE_PUSH_PULL:
  337. arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_CMOS;
  338. break;
  339. case PIN_CONFIG_DRIVE_OPEN_DRAIN:
  340. arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS;
  341. break;
  342. case PIN_CONFIG_DRIVE_OPEN_SOURCE:
  343. arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS;
  344. break;
  345. case PIN_CONFIG_BIAS_PULL_DOWN:
  346. arg = pad->pullup == PMIC_GPIO_PULL_DOWN;
  347. break;
  348. case PIN_CONFIG_BIAS_DISABLE:
  349. arg = pad->pullup = PMIC_GPIO_PULL_DISABLE;
  350. break;
  351. case PIN_CONFIG_BIAS_PULL_UP:
  352. arg = pad->pullup == PMIC_GPIO_PULL_UP_30;
  353. break;
  354. case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
  355. arg = !pad->is_enabled;
  356. break;
  357. case PIN_CONFIG_POWER_SOURCE:
  358. arg = pad->power_source;
  359. break;
  360. case PIN_CONFIG_INPUT_ENABLE:
  361. arg = pad->input_enabled;
  362. break;
  363. case PIN_CONFIG_OUTPUT:
  364. arg = pad->out_value;
  365. break;
  366. case PMIC_GPIO_CONF_PULL_UP:
  367. arg = pad->pullup;
  368. break;
  369. case PMIC_GPIO_CONF_STRENGTH:
  370. arg = pad->strength;
  371. break;
  372. case PMIC_GPIO_CONF_ATEST:
  373. arg = pad->atest;
  374. break;
  375. case PMIC_GPIO_CONF_ANALOG_PASS:
  376. arg = pad->analog_pass;
  377. break;
  378. case PMIC_GPIO_CONF_DTEST_BUFFER:
  379. arg = pad->dtest_buffer;
  380. break;
  381. default:
  382. return -EINVAL;
  383. }
  384. *config = pinconf_to_config_packed(param, arg);
  385. return 0;
  386. }
  387. static int pmic_gpio_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
  388. unsigned long *configs, unsigned nconfs)
  389. {
  390. struct pmic_gpio_state *state = pinctrl_dev_get_drvdata(pctldev);
  391. struct pmic_gpio_pad *pad;
  392. unsigned param, arg;
  393. unsigned int val;
  394. int i, ret;
  395. pad = pctldev->desc->pins[pin].drv_data;
  396. pad->is_enabled = true;
  397. for (i = 0; i < nconfs; i++) {
  398. param = pinconf_to_config_param(configs[i]);
  399. arg = pinconf_to_config_argument(configs[i]);
  400. switch (param) {
  401. case PIN_CONFIG_DRIVE_PUSH_PULL:
  402. pad->buffer_type = PMIC_GPIO_OUT_BUF_CMOS;
  403. break;
  404. case PIN_CONFIG_DRIVE_OPEN_DRAIN:
  405. if (!pad->have_buffer)
  406. return -EINVAL;
  407. pad->buffer_type = PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS;
  408. break;
  409. case PIN_CONFIG_DRIVE_OPEN_SOURCE:
  410. if (!pad->have_buffer)
  411. return -EINVAL;
  412. pad->buffer_type = PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS;
  413. break;
  414. case PIN_CONFIG_BIAS_DISABLE:
  415. pad->pullup = PMIC_GPIO_PULL_DISABLE;
  416. break;
  417. case PIN_CONFIG_BIAS_PULL_UP:
  418. pad->pullup = PMIC_GPIO_PULL_UP_30;
  419. break;
  420. case PIN_CONFIG_BIAS_PULL_DOWN:
  421. if (arg)
  422. pad->pullup = PMIC_GPIO_PULL_DOWN;
  423. else
  424. pad->pullup = PMIC_GPIO_PULL_DISABLE;
  425. break;
  426. case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
  427. pad->is_enabled = false;
  428. break;
  429. case PIN_CONFIG_POWER_SOURCE:
  430. if (arg >= pad->num_sources)
  431. return -EINVAL;
  432. pad->power_source = arg;
  433. break;
  434. case PIN_CONFIG_INPUT_ENABLE:
  435. pad->input_enabled = arg ? true : false;
  436. break;
  437. case PIN_CONFIG_OUTPUT:
  438. pad->output_enabled = true;
  439. pad->out_value = arg;
  440. break;
  441. case PMIC_GPIO_CONF_PULL_UP:
  442. if (arg > PMIC_GPIO_PULL_UP_1P5_30)
  443. return -EINVAL;
  444. pad->pullup = arg;
  445. break;
  446. case PMIC_GPIO_CONF_STRENGTH:
  447. if (arg > PMIC_GPIO_STRENGTH_LOW)
  448. return -EINVAL;
  449. pad->strength = arg;
  450. break;
  451. case PMIC_GPIO_CONF_ATEST:
  452. if (!pad->lv_mv_type || arg > 4)
  453. return -EINVAL;
  454. pad->atest = arg;
  455. break;
  456. case PMIC_GPIO_CONF_ANALOG_PASS:
  457. if (!pad->lv_mv_type)
  458. return -EINVAL;
  459. pad->analog_pass = true;
  460. break;
  461. case PMIC_GPIO_CONF_DTEST_BUFFER:
  462. if (arg > 4)
  463. return -EINVAL;
  464. pad->dtest_buffer = arg;
  465. break;
  466. default:
  467. return -EINVAL;
  468. }
  469. }
  470. val = pad->power_source << PMIC_GPIO_REG_VIN_SHIFT;
  471. ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_VIN_CTL, val);
  472. if (ret < 0)
  473. return ret;
  474. val = pad->pullup << PMIC_GPIO_REG_PULL_SHIFT;
  475. ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_PULL_CTL, val);
  476. if (ret < 0)
  477. return ret;
  478. val = pad->buffer_type << PMIC_GPIO_REG_OUT_TYPE_SHIFT;
  479. val |= pad->strength << PMIC_GPIO_REG_OUT_STRENGTH_SHIFT;
  480. ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_OUT_CTL, val);
  481. if (ret < 0)
  482. return ret;
  483. if (pad->dtest_buffer == 0) {
  484. val = 0;
  485. } else {
  486. if (pad->lv_mv_type) {
  487. val = pad->dtest_buffer - 1;
  488. val |= PMIC_GPIO_LV_MV_DIG_IN_DTEST_EN;
  489. } else {
  490. val = BIT(pad->dtest_buffer - 1);
  491. }
  492. }
  493. ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_IN_CTL, val);
  494. if (ret < 0)
  495. return ret;
  496. if (pad->analog_pass)
  497. val = PMIC_GPIO_MODE_ANALOG_PASS_THRU;
  498. else if (pad->output_enabled && pad->input_enabled)
  499. val = PMIC_GPIO_MODE_DIGITAL_INPUT_OUTPUT;
  500. else if (pad->output_enabled)
  501. val = PMIC_GPIO_MODE_DIGITAL_OUTPUT;
  502. else
  503. val = PMIC_GPIO_MODE_DIGITAL_INPUT;
  504. if (pad->lv_mv_type) {
  505. ret = pmic_gpio_write(state, pad,
  506. PMIC_GPIO_REG_MODE_CTL, val);
  507. if (ret < 0)
  508. return ret;
  509. val = pad->atest - 1;
  510. ret = pmic_gpio_write(state, pad,
  511. PMIC_GPIO_REG_LV_MV_ANA_PASS_THRU_SEL, val);
  512. if (ret < 0)
  513. return ret;
  514. val = pad->out_value
  515. << PMIC_GPIO_LV_MV_OUTPUT_INVERT_SHIFT;
  516. val |= pad->function
  517. & PMIC_GPIO_LV_MV_OUTPUT_SOURCE_SEL_MASK;
  518. ret = pmic_gpio_write(state, pad,
  519. PMIC_GPIO_REG_LV_MV_DIG_OUT_SOURCE_CTL, val);
  520. if (ret < 0)
  521. return ret;
  522. } else {
  523. val = val << PMIC_GPIO_REG_MODE_DIR_SHIFT;
  524. val |= pad->function << PMIC_GPIO_REG_MODE_FUNCTION_SHIFT;
  525. val |= pad->out_value & PMIC_GPIO_REG_MODE_VALUE_SHIFT;
  526. ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_MODE_CTL, val);
  527. if (ret < 0)
  528. return ret;
  529. }
  530. val = pad->is_enabled << PMIC_GPIO_REG_MASTER_EN_SHIFT;
  531. ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_EN_CTL, val);
  532. return ret;
  533. }
  534. static void pmic_gpio_config_dbg_show(struct pinctrl_dev *pctldev,
  535. struct seq_file *s, unsigned pin)
  536. {
  537. struct pmic_gpio_state *state = pinctrl_dev_get_drvdata(pctldev);
  538. struct pmic_gpio_pad *pad;
  539. int ret, val, function;
  540. static const char *const biases[] = {
  541. "pull-up 30uA", "pull-up 1.5uA", "pull-up 31.5uA",
  542. "pull-up 1.5uA + 30uA boost", "pull-down 10uA", "no pull"
  543. };
  544. static const char *const buffer_types[] = {
  545. "push-pull", "open-drain", "open-source"
  546. };
  547. static const char *const strengths[] = {
  548. "no", "high", "medium", "low"
  549. };
  550. pad = pctldev->desc->pins[pin].drv_data;
  551. seq_printf(s, " gpio%-2d:", pin + PMIC_GPIO_PHYSICAL_OFFSET);
  552. val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_EN_CTL);
  553. if (val < 0 || !(val >> PMIC_GPIO_REG_MASTER_EN_SHIFT)) {
  554. seq_puts(s, " ---");
  555. } else {
  556. if (pad->input_enabled) {
  557. ret = pmic_gpio_read(state, pad, PMIC_MPP_REG_RT_STS);
  558. if (ret < 0)
  559. return;
  560. ret &= PMIC_MPP_REG_RT_STS_VAL_MASK;
  561. pad->out_value = ret;
  562. }
  563. /*
  564. * For the non-LV/MV subtypes only 2 special functions are
  565. * available, offsetting the dtest function values by 2.
  566. */
  567. function = pad->function;
  568. if (!pad->lv_mv_type &&
  569. pad->function >= PMIC_GPIO_FUNC_INDEX_FUNC3)
  570. function += PMIC_GPIO_FUNC_INDEX_DTEST1 -
  571. PMIC_GPIO_FUNC_INDEX_FUNC3;
  572. if (pad->analog_pass)
  573. seq_puts(s, " analog-pass");
  574. else
  575. seq_printf(s, " %-4s",
  576. pad->output_enabled ? "out" : "in");
  577. seq_printf(s, " %-7s", pmic_gpio_functions[function]);
  578. seq_printf(s, " vin-%d", pad->power_source);
  579. seq_printf(s, " %-27s", biases[pad->pullup]);
  580. seq_printf(s, " %-10s", buffer_types[pad->buffer_type]);
  581. seq_printf(s, " %-4s", pad->out_value ? "high" : "low");
  582. seq_printf(s, " %-7s", strengths[pad->strength]);
  583. seq_printf(s, " atest-%d", pad->atest);
  584. seq_printf(s, " dtest-%d", pad->dtest_buffer);
  585. }
  586. }
  587. static const struct pinconf_ops pmic_gpio_pinconf_ops = {
  588. .is_generic = true,
  589. .pin_config_group_get = pmic_gpio_config_get,
  590. .pin_config_group_set = pmic_gpio_config_set,
  591. .pin_config_group_dbg_show = pmic_gpio_config_dbg_show,
  592. };
  593. static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
  594. {
  595. struct pmic_gpio_state *state = gpiochip_get_data(chip);
  596. unsigned long config;
  597. config = pinconf_to_config_packed(PIN_CONFIG_INPUT_ENABLE, 1);
  598. return pmic_gpio_config_set(state->ctrl, pin, &config, 1);
  599. }
  600. static int pmic_gpio_direction_output(struct gpio_chip *chip,
  601. unsigned pin, int val)
  602. {
  603. struct pmic_gpio_state *state = gpiochip_get_data(chip);
  604. unsigned long config;
  605. config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, val);
  606. return pmic_gpio_config_set(state->ctrl, pin, &config, 1);
  607. }
  608. static int pmic_gpio_get(struct gpio_chip *chip, unsigned pin)
  609. {
  610. struct pmic_gpio_state *state = gpiochip_get_data(chip);
  611. struct pmic_gpio_pad *pad;
  612. int ret;
  613. pad = state->ctrl->desc->pins[pin].drv_data;
  614. if (!pad->is_enabled)
  615. return -EINVAL;
  616. if (pad->input_enabled) {
  617. ret = pmic_gpio_read(state, pad, PMIC_MPP_REG_RT_STS);
  618. if (ret < 0)
  619. return ret;
  620. pad->out_value = ret & PMIC_MPP_REG_RT_STS_VAL_MASK;
  621. }
  622. return !!pad->out_value;
  623. }
  624. static void pmic_gpio_set(struct gpio_chip *chip, unsigned pin, int value)
  625. {
  626. struct pmic_gpio_state *state = gpiochip_get_data(chip);
  627. unsigned long config;
  628. config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, value);
  629. pmic_gpio_config_set(state->ctrl, pin, &config, 1);
  630. }
  631. static int pmic_gpio_of_xlate(struct gpio_chip *chip,
  632. const struct of_phandle_args *gpio_desc,
  633. u32 *flags)
  634. {
  635. if (chip->of_gpio_n_cells < 2)
  636. return -EINVAL;
  637. if (flags)
  638. *flags = gpio_desc->args[1];
  639. return gpio_desc->args[0] - PMIC_GPIO_PHYSICAL_OFFSET;
  640. }
  641. static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned pin)
  642. {
  643. struct pmic_gpio_state *state = gpiochip_get_data(chip);
  644. struct pmic_gpio_pad *pad;
  645. pad = state->ctrl->desc->pins[pin].drv_data;
  646. return pad->irq;
  647. }
  648. static void pmic_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
  649. {
  650. struct pmic_gpio_state *state = gpiochip_get_data(chip);
  651. unsigned i;
  652. for (i = 0; i < chip->ngpio; i++) {
  653. pmic_gpio_config_dbg_show(state->ctrl, s, i);
  654. seq_puts(s, "\n");
  655. }
  656. }
  657. static const struct gpio_chip pmic_gpio_gpio_template = {
  658. .direction_input = pmic_gpio_direction_input,
  659. .direction_output = pmic_gpio_direction_output,
  660. .get = pmic_gpio_get,
  661. .set = pmic_gpio_set,
  662. .request = gpiochip_generic_request,
  663. .free = gpiochip_generic_free,
  664. .of_xlate = pmic_gpio_of_xlate,
  665. .to_irq = pmic_gpio_to_irq,
  666. .dbg_show = pmic_gpio_dbg_show,
  667. };
  668. static int pmic_gpio_populate(struct pmic_gpio_state *state,
  669. struct pmic_gpio_pad *pad)
  670. {
  671. int type, subtype, val, dir;
  672. type = pmic_gpio_read(state, pad, PMIC_GPIO_REG_TYPE);
  673. if (type < 0)
  674. return type;
  675. if (type != PMIC_GPIO_TYPE) {
  676. dev_err(state->dev, "incorrect block type 0x%x at 0x%x\n",
  677. type, pad->base);
  678. return -ENODEV;
  679. }
  680. subtype = pmic_gpio_read(state, pad, PMIC_GPIO_REG_SUBTYPE);
  681. if (subtype < 0)
  682. return subtype;
  683. switch (subtype) {
  684. case PMIC_GPIO_SUBTYPE_GPIO_4CH:
  685. pad->have_buffer = true;
  686. case PMIC_GPIO_SUBTYPE_GPIOC_4CH:
  687. pad->num_sources = 4;
  688. break;
  689. case PMIC_GPIO_SUBTYPE_GPIO_8CH:
  690. pad->have_buffer = true;
  691. case PMIC_GPIO_SUBTYPE_GPIOC_8CH:
  692. pad->num_sources = 8;
  693. break;
  694. case PMIC_GPIO_SUBTYPE_GPIO_LV:
  695. pad->num_sources = 1;
  696. pad->have_buffer = true;
  697. pad->lv_mv_type = true;
  698. break;
  699. case PMIC_GPIO_SUBTYPE_GPIO_MV:
  700. pad->num_sources = 2;
  701. pad->have_buffer = true;
  702. pad->lv_mv_type = true;
  703. break;
  704. default:
  705. dev_err(state->dev, "unknown GPIO type 0x%x\n", subtype);
  706. return -ENODEV;
  707. }
  708. if (pad->lv_mv_type) {
  709. val = pmic_gpio_read(state, pad,
  710. PMIC_GPIO_REG_LV_MV_DIG_OUT_SOURCE_CTL);
  711. if (val < 0)
  712. return val;
  713. pad->out_value = !!(val & PMIC_GPIO_LV_MV_OUTPUT_INVERT);
  714. pad->function = val & PMIC_GPIO_LV_MV_OUTPUT_SOURCE_SEL_MASK;
  715. val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_MODE_CTL);
  716. if (val < 0)
  717. return val;
  718. dir = val & PMIC_GPIO_REG_LV_MV_MODE_DIR_MASK;
  719. } else {
  720. val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_MODE_CTL);
  721. if (val < 0)
  722. return val;
  723. pad->out_value = val & PMIC_GPIO_REG_MODE_VALUE_SHIFT;
  724. dir = val >> PMIC_GPIO_REG_MODE_DIR_SHIFT;
  725. dir &= PMIC_GPIO_REG_MODE_DIR_MASK;
  726. pad->function = val >> PMIC_GPIO_REG_MODE_FUNCTION_SHIFT;
  727. pad->function &= PMIC_GPIO_REG_MODE_FUNCTION_MASK;
  728. }
  729. switch (dir) {
  730. case PMIC_GPIO_MODE_DIGITAL_INPUT:
  731. pad->input_enabled = true;
  732. pad->output_enabled = false;
  733. break;
  734. case PMIC_GPIO_MODE_DIGITAL_OUTPUT:
  735. pad->input_enabled = false;
  736. pad->output_enabled = true;
  737. break;
  738. case PMIC_GPIO_MODE_DIGITAL_INPUT_OUTPUT:
  739. pad->input_enabled = true;
  740. pad->output_enabled = true;
  741. break;
  742. case PMIC_GPIO_MODE_ANALOG_PASS_THRU:
  743. if (!pad->lv_mv_type)
  744. return -ENODEV;
  745. pad->analog_pass = true;
  746. break;
  747. default:
  748. dev_err(state->dev, "unknown GPIO direction\n");
  749. return -ENODEV;
  750. }
  751. val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_VIN_CTL);
  752. if (val < 0)
  753. return val;
  754. pad->power_source = val >> PMIC_GPIO_REG_VIN_SHIFT;
  755. pad->power_source &= PMIC_GPIO_REG_VIN_MASK;
  756. val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_PULL_CTL);
  757. if (val < 0)
  758. return val;
  759. pad->pullup = val >> PMIC_GPIO_REG_PULL_SHIFT;
  760. pad->pullup &= PMIC_GPIO_REG_PULL_MASK;
  761. val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_IN_CTL);
  762. if (val < 0)
  763. return val;
  764. if (pad->lv_mv_type && (val & PMIC_GPIO_LV_MV_DIG_IN_DTEST_EN))
  765. pad->dtest_buffer =
  766. (val & PMIC_GPIO_LV_MV_DIG_IN_DTEST_SEL_MASK) + 1;
  767. else if (!pad->lv_mv_type)
  768. pad->dtest_buffer = ffs(val);
  769. else
  770. pad->dtest_buffer = 0;
  771. val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_OUT_CTL);
  772. if (val < 0)
  773. return val;
  774. pad->strength = val >> PMIC_GPIO_REG_OUT_STRENGTH_SHIFT;
  775. pad->strength &= PMIC_GPIO_REG_OUT_STRENGTH_MASK;
  776. pad->buffer_type = val >> PMIC_GPIO_REG_OUT_TYPE_SHIFT;
  777. pad->buffer_type &= PMIC_GPIO_REG_OUT_TYPE_MASK;
  778. if (pad->lv_mv_type) {
  779. val = pmic_gpio_read(state, pad,
  780. PMIC_GPIO_REG_LV_MV_ANA_PASS_THRU_SEL);
  781. if (val < 0)
  782. return val;
  783. pad->atest = (val & PMIC_GPIO_LV_MV_ANA_MUX_SEL_MASK) + 1;
  784. }
  785. /* Pin could be disabled with PIN_CONFIG_BIAS_HIGH_IMPEDANCE */
  786. pad->is_enabled = true;
  787. return 0;
  788. }
  789. static int pmic_gpio_probe(struct platform_device *pdev)
  790. {
  791. struct device *dev = &pdev->dev;
  792. struct pinctrl_pin_desc *pindesc;
  793. struct pinctrl_desc *pctrldesc;
  794. struct pmic_gpio_pad *pad, *pads;
  795. struct pmic_gpio_state *state;
  796. int ret, npins, i;
  797. u32 reg;
  798. ret = of_property_read_u32(dev->of_node, "reg", &reg);
  799. if (ret < 0) {
  800. dev_err(dev, "missing base address");
  801. return ret;
  802. }
  803. npins = platform_irq_count(pdev);
  804. if (!npins)
  805. return -EINVAL;
  806. if (npins < 0)
  807. return npins;
  808. BUG_ON(npins > ARRAY_SIZE(pmic_gpio_groups));
  809. state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL);
  810. if (!state)
  811. return -ENOMEM;
  812. platform_set_drvdata(pdev, state);
  813. state->dev = &pdev->dev;
  814. state->map = dev_get_regmap(dev->parent, NULL);
  815. pindesc = devm_kcalloc(dev, npins, sizeof(*pindesc), GFP_KERNEL);
  816. if (!pindesc)
  817. return -ENOMEM;
  818. pads = devm_kcalloc(dev, npins, sizeof(*pads), GFP_KERNEL);
  819. if (!pads)
  820. return -ENOMEM;
  821. pctrldesc = devm_kzalloc(dev, sizeof(*pctrldesc), GFP_KERNEL);
  822. if (!pctrldesc)
  823. return -ENOMEM;
  824. pctrldesc->pctlops = &pmic_gpio_pinctrl_ops;
  825. pctrldesc->pmxops = &pmic_gpio_pinmux_ops;
  826. pctrldesc->confops = &pmic_gpio_pinconf_ops;
  827. pctrldesc->owner = THIS_MODULE;
  828. pctrldesc->name = dev_name(dev);
  829. pctrldesc->pins = pindesc;
  830. pctrldesc->npins = npins;
  831. pctrldesc->num_custom_params = ARRAY_SIZE(pmic_gpio_bindings);
  832. pctrldesc->custom_params = pmic_gpio_bindings;
  833. #ifdef CONFIG_DEBUG_FS
  834. pctrldesc->custom_conf_items = pmic_conf_items;
  835. #endif
  836. for (i = 0; i < npins; i++, pindesc++) {
  837. pad = &pads[i];
  838. pindesc->drv_data = pad;
  839. pindesc->number = i;
  840. pindesc->name = pmic_gpio_groups[i];
  841. pad->irq = platform_get_irq(pdev, i);
  842. if (pad->irq < 0)
  843. return pad->irq;
  844. pad->base = reg + i * PMIC_GPIO_ADDRESS_RANGE;
  845. ret = pmic_gpio_populate(state, pad);
  846. if (ret < 0)
  847. return ret;
  848. }
  849. state->chip = pmic_gpio_gpio_template;
  850. state->chip.parent = dev;
  851. state->chip.base = -1;
  852. state->chip.ngpio = npins;
  853. state->chip.label = dev_name(dev);
  854. state->chip.of_gpio_n_cells = 2;
  855. state->chip.can_sleep = false;
  856. state->ctrl = devm_pinctrl_register(dev, pctrldesc, state);
  857. if (IS_ERR(state->ctrl))
  858. return PTR_ERR(state->ctrl);
  859. ret = gpiochip_add_data(&state->chip, state);
  860. if (ret) {
  861. dev_err(state->dev, "can't add gpio chip\n");
  862. return ret;
  863. }
  864. ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins);
  865. if (ret) {
  866. dev_err(dev, "failed to add pin range\n");
  867. goto err_range;
  868. }
  869. return 0;
  870. err_range:
  871. gpiochip_remove(&state->chip);
  872. return ret;
  873. }
  874. static int pmic_gpio_remove(struct platform_device *pdev)
  875. {
  876. struct pmic_gpio_state *state = platform_get_drvdata(pdev);
  877. gpiochip_remove(&state->chip);
  878. return 0;
  879. }
  880. static const struct of_device_id pmic_gpio_of_match[] = {
  881. { .compatible = "qcom,pm8916-gpio" }, /* 4 GPIO's */
  882. { .compatible = "qcom,pm8941-gpio" }, /* 36 GPIO's */
  883. { .compatible = "qcom,pm8994-gpio" }, /* 22 GPIO's */
  884. { .compatible = "qcom,pmi8994-gpio" }, /* 10 GPIO's */
  885. { .compatible = "qcom,pma8084-gpio" }, /* 22 GPIO's */
  886. { .compatible = "qcom,spmi-gpio" }, /* Generic */
  887. { },
  888. };
  889. MODULE_DEVICE_TABLE(of, pmic_gpio_of_match);
  890. static struct platform_driver pmic_gpio_driver = {
  891. .driver = {
  892. .name = "qcom-spmi-gpio",
  893. .of_match_table = pmic_gpio_of_match,
  894. },
  895. .probe = pmic_gpio_probe,
  896. .remove = pmic_gpio_remove,
  897. };
  898. module_platform_driver(pmic_gpio_driver);
  899. MODULE_AUTHOR("Ivan T. Ivanov <iivanov@mm-sol.com>");
  900. MODULE_DESCRIPTION("Qualcomm SPMI PMIC GPIO pin control driver");
  901. MODULE_ALIAS("platform:qcom-spmi-gpio");
  902. MODULE_LICENSE("GPL v2");