pinctrl-dove.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. /*
  2. * Marvell Dove pinctrl driver based on mvebu pinctrl core
  3. *
  4. * Author: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #include <linux/err.h>
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/bitops.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/clk.h>
  17. #include <linux/of.h>
  18. #include <linux/of_device.h>
  19. #include <linux/mfd/syscon.h>
  20. #include <linux/pinctrl/pinctrl.h>
  21. #include <linux/regmap.h>
  22. #include "pinctrl-mvebu.h"
  23. /* Internal registers can be configured at any 1 MiB aligned address */
  24. #define INT_REGS_MASK ~(SZ_1M - 1)
  25. #define MPP4_REGS_OFFS 0xd0440
  26. #define PMU_REGS_OFFS 0xd802c
  27. #define GC_REGS_OFFS 0xe802c
  28. /* MPP Base registers */
  29. #define PMU_MPP_GENERAL_CTRL 0x10
  30. #define AU0_AC97_SEL BIT(16)
  31. /* MPP Control 4 register */
  32. #define SPI_GPIO_SEL BIT(5)
  33. #define UART1_GPIO_SEL BIT(4)
  34. #define AU1_GPIO_SEL BIT(3)
  35. #define CAM_GPIO_SEL BIT(2)
  36. #define SD1_GPIO_SEL BIT(1)
  37. #define SD0_GPIO_SEL BIT(0)
  38. /* PMU Signal Select registers */
  39. #define PMU_SIGNAL_SELECT_0 0x00
  40. #define PMU_SIGNAL_SELECT_1 0x04
  41. /* Global Config regmap registers */
  42. #define GLOBAL_CONFIG_1 0x00
  43. #define TWSI_ENABLE_OPTION1 BIT(7)
  44. #define GLOBAL_CONFIG_2 0x04
  45. #define TWSI_ENABLE_OPTION2 BIT(20)
  46. #define TWSI_ENABLE_OPTION3 BIT(21)
  47. #define TWSI_OPTION3_GPIO BIT(22)
  48. #define SSP_CTRL_STATUS_1 0x08
  49. #define SSP_ON_AU1 BIT(0)
  50. #define MPP_GENERAL_CONFIG 0x10
  51. #define AU1_SPDIFO_GPIO_EN BIT(1)
  52. #define NAND_GPIO_EN BIT(0)
  53. #define CONFIG_PMU BIT(4)
  54. static void __iomem *mpp4_base;
  55. static void __iomem *pmu_base;
  56. static struct regmap *gconfmap;
  57. static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl_data *data,
  58. unsigned pid, unsigned long *config)
  59. {
  60. unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
  61. unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
  62. unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL);
  63. unsigned long func;
  64. if ((pmu & BIT(pid)) == 0)
  65. return mvebu_mmio_mpp_ctrl_get(data, pid, config);
  66. func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
  67. *config = (func >> shift) & MVEBU_MPP_MASK;
  68. *config |= CONFIG_PMU;
  69. return 0;
  70. }
  71. static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl_data *data,
  72. unsigned pid, unsigned long config)
  73. {
  74. unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
  75. unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
  76. unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL);
  77. unsigned long func;
  78. if ((config & CONFIG_PMU) == 0) {
  79. writel(pmu & ~BIT(pid), data->base + PMU_MPP_GENERAL_CTRL);
  80. return mvebu_mmio_mpp_ctrl_set(data, pid, config);
  81. }
  82. writel(pmu | BIT(pid), data->base + PMU_MPP_GENERAL_CTRL);
  83. func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
  84. func &= ~(MVEBU_MPP_MASK << shift);
  85. func |= (config & MVEBU_MPP_MASK) << shift;
  86. writel(func, pmu_base + PMU_SIGNAL_SELECT_0 + off);
  87. return 0;
  88. }
  89. static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
  90. unsigned long *config)
  91. {
  92. unsigned long mpp4 = readl(mpp4_base);
  93. unsigned long mask;
  94. switch (pid) {
  95. case 24: /* mpp_camera */
  96. mask = CAM_GPIO_SEL;
  97. break;
  98. case 40: /* mpp_sdio0 */
  99. mask = SD0_GPIO_SEL;
  100. break;
  101. case 46: /* mpp_sdio1 */
  102. mask = SD1_GPIO_SEL;
  103. break;
  104. case 58: /* mpp_spi0 */
  105. mask = SPI_GPIO_SEL;
  106. break;
  107. case 62: /* mpp_uart1 */
  108. mask = UART1_GPIO_SEL;
  109. break;
  110. default:
  111. return -EINVAL;
  112. }
  113. *config = ((mpp4 & mask) != 0);
  114. return 0;
  115. }
  116. static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
  117. unsigned long config)
  118. {
  119. unsigned long mpp4 = readl(mpp4_base);
  120. unsigned long mask;
  121. switch (pid) {
  122. case 24: /* mpp_camera */
  123. mask = CAM_GPIO_SEL;
  124. break;
  125. case 40: /* mpp_sdio0 */
  126. mask = SD0_GPIO_SEL;
  127. break;
  128. case 46: /* mpp_sdio1 */
  129. mask = SD1_GPIO_SEL;
  130. break;
  131. case 58: /* mpp_spi0 */
  132. mask = SPI_GPIO_SEL;
  133. break;
  134. case 62: /* mpp_uart1 */
  135. mask = UART1_GPIO_SEL;
  136. break;
  137. default:
  138. return -EINVAL;
  139. }
  140. mpp4 &= ~mask;
  141. if (config)
  142. mpp4 |= mask;
  143. writel(mpp4, mpp4_base);
  144. return 0;
  145. }
  146. static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
  147. unsigned long *config)
  148. {
  149. unsigned int gmpp;
  150. regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp);
  151. *config = ((gmpp & NAND_GPIO_EN) != 0);
  152. return 0;
  153. }
  154. static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
  155. unsigned long config)
  156. {
  157. regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG,
  158. NAND_GPIO_EN,
  159. (config) ? NAND_GPIO_EN : 0);
  160. return 0;
  161. }
  162. static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
  163. unsigned long *config)
  164. {
  165. unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL);
  166. *config = ((pmu & AU0_AC97_SEL) != 0);
  167. return 0;
  168. }
  169. static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
  170. unsigned long config)
  171. {
  172. unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL);
  173. pmu &= ~AU0_AC97_SEL;
  174. if (config)
  175. pmu |= AU0_AC97_SEL;
  176. writel(pmu, data->base + PMU_MPP_GENERAL_CTRL);
  177. return 0;
  178. }
  179. static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
  180. unsigned long *config)
  181. {
  182. unsigned int mpp4 = readl(mpp4_base);
  183. unsigned int sspc1;
  184. unsigned int gmpp;
  185. unsigned int gcfg2;
  186. regmap_read(gconfmap, SSP_CTRL_STATUS_1, &sspc1);
  187. regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp);
  188. regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2);
  189. *config = 0;
  190. if (mpp4 & AU1_GPIO_SEL)
  191. *config |= BIT(3);
  192. if (sspc1 & SSP_ON_AU1)
  193. *config |= BIT(2);
  194. if (gmpp & AU1_SPDIFO_GPIO_EN)
  195. *config |= BIT(1);
  196. if (gcfg2 & TWSI_OPTION3_GPIO)
  197. *config |= BIT(0);
  198. /* SSP/TWSI only if I2S1 not set*/
  199. if ((*config & BIT(3)) == 0)
  200. *config &= ~(BIT(2) | BIT(0));
  201. /* TWSI only if SPDIFO not set*/
  202. if ((*config & BIT(1)) == 0)
  203. *config &= ~BIT(0);
  204. return 0;
  205. }
  206. static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
  207. unsigned long config)
  208. {
  209. unsigned int mpp4 = readl(mpp4_base);
  210. mpp4 &= ~AU1_GPIO_SEL;
  211. if (config & BIT(3))
  212. mpp4 |= AU1_GPIO_SEL;
  213. writel(mpp4, mpp4_base);
  214. regmap_update_bits(gconfmap, SSP_CTRL_STATUS_1,
  215. SSP_ON_AU1,
  216. (config & BIT(2)) ? SSP_ON_AU1 : 0);
  217. regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG,
  218. AU1_SPDIFO_GPIO_EN,
  219. (config & BIT(1)) ? AU1_SPDIFO_GPIO_EN : 0);
  220. regmap_update_bits(gconfmap, GLOBAL_CONFIG_2,
  221. TWSI_OPTION3_GPIO,
  222. (config & BIT(0)) ? TWSI_OPTION3_GPIO : 0);
  223. return 0;
  224. }
  225. /* mpp[52:57] gpio pins depend heavily on current config;
  226. * gpio_req does not try to mux in gpio capabilities to not
  227. * break other functions. If you require all mpps as gpio
  228. * enforce gpio setting by pinctrl mapping.
  229. */
  230. static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl_data *data,
  231. unsigned pid)
  232. {
  233. unsigned long config;
  234. dove_audio1_ctrl_get(data, pid, &config);
  235. switch (config) {
  236. case 0x02: /* i2s1 : gpio[56:57] */
  237. case 0x0e: /* ssp : gpio[56:57] */
  238. if (pid >= 56)
  239. return 0;
  240. return -ENOTSUPP;
  241. case 0x08: /* spdifo : gpio[52:55] */
  242. case 0x0b: /* twsi : gpio[52:55] */
  243. if (pid <= 55)
  244. return 0;
  245. return -ENOTSUPP;
  246. case 0x0a: /* all gpio */
  247. return 0;
  248. /* 0x00 : i2s1/spdifo : no gpio */
  249. /* 0x0c : ssp/spdifo : no gpio */
  250. /* 0x0f : ssp/twsi : no gpio */
  251. }
  252. return -ENOTSUPP;
  253. }
  254. /* mpp[52:57] has gpio pins capable of in and out */
  255. static int dove_audio1_ctrl_gpio_dir(struct mvebu_mpp_ctrl_data *data,
  256. unsigned pid, bool input)
  257. {
  258. if (pid < 52 || pid > 57)
  259. return -ENOTSUPP;
  260. return 0;
  261. }
  262. static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
  263. unsigned long *config)
  264. {
  265. unsigned int gcfg1;
  266. unsigned int gcfg2;
  267. regmap_read(gconfmap, GLOBAL_CONFIG_1, &gcfg1);
  268. regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2);
  269. *config = 0;
  270. if (gcfg1 & TWSI_ENABLE_OPTION1)
  271. *config = 1;
  272. else if (gcfg2 & TWSI_ENABLE_OPTION2)
  273. *config = 2;
  274. else if (gcfg2 & TWSI_ENABLE_OPTION3)
  275. *config = 3;
  276. return 0;
  277. }
  278. static int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
  279. unsigned long config)
  280. {
  281. unsigned int gcfg1 = 0;
  282. unsigned int gcfg2 = 0;
  283. switch (config) {
  284. case 1:
  285. gcfg1 = TWSI_ENABLE_OPTION1;
  286. break;
  287. case 2:
  288. gcfg2 = TWSI_ENABLE_OPTION2;
  289. break;
  290. case 3:
  291. gcfg2 = TWSI_ENABLE_OPTION3;
  292. break;
  293. }
  294. regmap_update_bits(gconfmap, GLOBAL_CONFIG_1,
  295. TWSI_ENABLE_OPTION1,
  296. gcfg1);
  297. regmap_update_bits(gconfmap, GLOBAL_CONFIG_2,
  298. TWSI_ENABLE_OPTION2 | TWSI_ENABLE_OPTION3,
  299. gcfg2);
  300. return 0;
  301. }
  302. static const struct mvebu_mpp_ctrl dove_mpp_controls[] = {
  303. MPP_FUNC_CTRL(0, 15, NULL, dove_pmu_mpp_ctrl),
  304. MPP_FUNC_CTRL(16, 23, NULL, mvebu_mmio_mpp_ctrl),
  305. MPP_FUNC_CTRL(24, 39, "mpp_camera", dove_mpp4_ctrl),
  306. MPP_FUNC_CTRL(40, 45, "mpp_sdio0", dove_mpp4_ctrl),
  307. MPP_FUNC_CTRL(46, 51, "mpp_sdio1", dove_mpp4_ctrl),
  308. MPP_FUNC_GPIO_CTRL(52, 57, "mpp_audio1", dove_audio1_ctrl),
  309. MPP_FUNC_CTRL(58, 61, "mpp_spi0", dove_mpp4_ctrl),
  310. MPP_FUNC_CTRL(62, 63, "mpp_uart1", dove_mpp4_ctrl),
  311. MPP_FUNC_CTRL(64, 71, "mpp_nand", dove_nand_ctrl),
  312. MPP_FUNC_CTRL(72, 72, "audio0", dove_audio0_ctrl),
  313. MPP_FUNC_CTRL(73, 73, "twsi", dove_twsi_ctrl),
  314. };
  315. static struct mvebu_mpp_mode dove_mpp_modes[] = {
  316. MPP_MODE(0,
  317. MPP_FUNCTION(0x00, "gpio", NULL),
  318. MPP_FUNCTION(0x02, "uart2", "rts"),
  319. MPP_FUNCTION(0x03, "sdio0", "cd"),
  320. MPP_FUNCTION(0x0f, "lcd0", "pwm"),
  321. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  322. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  323. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  324. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  325. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  326. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  327. MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
  328. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  329. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  330. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  331. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  332. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  333. MPP_MODE(1,
  334. MPP_FUNCTION(0x00, "gpio", NULL),
  335. MPP_FUNCTION(0x02, "uart2", "cts"),
  336. MPP_FUNCTION(0x03, "sdio0", "wp"),
  337. MPP_FUNCTION(0x0f, "lcd1", "pwm"),
  338. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  339. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  340. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  341. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  342. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  343. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  344. MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
  345. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  346. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  347. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  348. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  349. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  350. MPP_MODE(2,
  351. MPP_FUNCTION(0x00, "gpio", NULL),
  352. MPP_FUNCTION(0x01, "sata", "prsnt"),
  353. MPP_FUNCTION(0x02, "uart2", "txd"),
  354. MPP_FUNCTION(0x03, "sdio0", "buspwr"),
  355. MPP_FUNCTION(0x04, "uart1", "rts"),
  356. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  357. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  358. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  359. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  360. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  361. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  362. MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
  363. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  364. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  365. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  366. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  367. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  368. MPP_MODE(3,
  369. MPP_FUNCTION(0x00, "gpio", NULL),
  370. MPP_FUNCTION(0x01, "sata", "act"),
  371. MPP_FUNCTION(0x02, "uart2", "rxd"),
  372. MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
  373. MPP_FUNCTION(0x04, "uart1", "cts"),
  374. MPP_FUNCTION(0x0f, "lcd-spi", "cs1"),
  375. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  376. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  377. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  378. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  379. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  380. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  381. MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
  382. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  383. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  384. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  385. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  386. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  387. MPP_MODE(4,
  388. MPP_FUNCTION(0x00, "gpio", NULL),
  389. MPP_FUNCTION(0x02, "uart3", "rts"),
  390. MPP_FUNCTION(0x03, "sdio1", "cd"),
  391. MPP_FUNCTION(0x04, "spi1", "miso"),
  392. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  393. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  394. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  395. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  396. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  397. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  398. MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
  399. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  400. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  401. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  402. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  403. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  404. MPP_MODE(5,
  405. MPP_FUNCTION(0x00, "gpio", NULL),
  406. MPP_FUNCTION(0x02, "uart3", "cts"),
  407. MPP_FUNCTION(0x03, "sdio1", "wp"),
  408. MPP_FUNCTION(0x04, "spi1", "cs"),
  409. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  410. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  411. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  412. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  413. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  414. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  415. MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
  416. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  417. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  418. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  419. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  420. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  421. MPP_MODE(6,
  422. MPP_FUNCTION(0x00, "gpio", NULL),
  423. MPP_FUNCTION(0x02, "uart3", "txd"),
  424. MPP_FUNCTION(0x03, "sdio1", "buspwr"),
  425. MPP_FUNCTION(0x04, "spi1", "mosi"),
  426. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  427. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  428. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  429. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  430. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  431. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  432. MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
  433. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  434. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  435. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  436. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  437. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  438. MPP_MODE(7,
  439. MPP_FUNCTION(0x00, "gpio", NULL),
  440. MPP_FUNCTION(0x02, "uart3", "rxd"),
  441. MPP_FUNCTION(0x03, "sdio1", "ledctrl"),
  442. MPP_FUNCTION(0x04, "spi1", "sck"),
  443. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  444. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  445. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  446. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  447. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  448. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  449. MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
  450. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  451. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  452. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  453. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  454. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  455. MPP_MODE(8,
  456. MPP_FUNCTION(0x00, "gpio", NULL),
  457. MPP_FUNCTION(0x01, "watchdog", "rstout"),
  458. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  459. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  460. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  461. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  462. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  463. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  464. MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
  465. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  466. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  467. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  468. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  469. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  470. MPP_MODE(9,
  471. MPP_FUNCTION(0x00, "gpio", NULL),
  472. MPP_FUNCTION(0x05, "pex1", "clkreq"),
  473. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  474. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  475. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  476. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  477. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  478. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  479. MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
  480. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  481. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  482. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  483. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  484. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  485. MPP_MODE(10,
  486. MPP_FUNCTION(0x00, "gpio", NULL),
  487. MPP_FUNCTION(0x05, "ssp", "sclk"),
  488. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  489. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  490. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  491. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  492. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  493. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  494. MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
  495. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  496. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  497. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  498. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  499. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  500. MPP_MODE(11,
  501. MPP_FUNCTION(0x00, "gpio", NULL),
  502. MPP_FUNCTION(0x01, "sata", "prsnt"),
  503. MPP_FUNCTION(0x02, "sata-1", "act"),
  504. MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
  505. MPP_FUNCTION(0x04, "sdio1", "ledctrl"),
  506. MPP_FUNCTION(0x05, "pex0", "clkreq"),
  507. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  508. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  509. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  510. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  511. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  512. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  513. MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
  514. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  515. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  516. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  517. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  518. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  519. MPP_MODE(12,
  520. MPP_FUNCTION(0x00, "gpio", NULL),
  521. MPP_FUNCTION(0x01, "sata", "act"),
  522. MPP_FUNCTION(0x02, "uart2", "rts"),
  523. MPP_FUNCTION(0x03, "audio0", "extclk"),
  524. MPP_FUNCTION(0x04, "sdio1", "cd"),
  525. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  526. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  527. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  528. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  529. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  530. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  531. MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
  532. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  533. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  534. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  535. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  536. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  537. MPP_MODE(13,
  538. MPP_FUNCTION(0x00, "gpio", NULL),
  539. MPP_FUNCTION(0x02, "uart2", "cts"),
  540. MPP_FUNCTION(0x03, "audio1", "extclk"),
  541. MPP_FUNCTION(0x04, "sdio1", "wp"),
  542. MPP_FUNCTION(0x05, "ssp", "extclk"),
  543. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  544. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  545. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  546. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  547. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  548. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  549. MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
  550. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  551. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  552. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  553. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  554. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  555. MPP_MODE(14,
  556. MPP_FUNCTION(0x00, "gpio", NULL),
  557. MPP_FUNCTION(0x02, "uart2", "txd"),
  558. MPP_FUNCTION(0x04, "sdio1", "buspwr"),
  559. MPP_FUNCTION(0x05, "ssp", "rxd"),
  560. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  561. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  562. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  563. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  564. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  565. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  566. MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
  567. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  568. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  569. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  570. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  571. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  572. MPP_MODE(15,
  573. MPP_FUNCTION(0x00, "gpio", NULL),
  574. MPP_FUNCTION(0x02, "uart2", "rxd"),
  575. MPP_FUNCTION(0x04, "sdio1", "ledctrl"),
  576. MPP_FUNCTION(0x05, "ssp", "sfrm"),
  577. MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
  578. MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
  579. MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
  580. MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
  581. MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
  582. MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
  583. MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
  584. MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
  585. MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
  586. MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
  587. MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
  588. MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
  589. MPP_MODE(16,
  590. MPP_FUNCTION(0x00, "gpio", NULL),
  591. MPP_FUNCTION(0x02, "uart3", "rts"),
  592. MPP_FUNCTION(0x03, "sdio0", "cd"),
  593. MPP_FUNCTION(0x04, "lcd-spi", "cs1"),
  594. MPP_FUNCTION(0x05, "ac97", "sdi1")),
  595. MPP_MODE(17,
  596. MPP_FUNCTION(0x00, "gpio", NULL),
  597. MPP_FUNCTION(0x01, "ac97-1", "sysclko"),
  598. MPP_FUNCTION(0x02, "uart3", "cts"),
  599. MPP_FUNCTION(0x03, "sdio0", "wp"),
  600. MPP_FUNCTION(0x04, "twsi", "sda"),
  601. MPP_FUNCTION(0x05, "ac97", "sdi2")),
  602. MPP_MODE(18,
  603. MPP_FUNCTION(0x00, "gpio", NULL),
  604. MPP_FUNCTION(0x02, "uart3", "txd"),
  605. MPP_FUNCTION(0x03, "sdio0", "buspwr"),
  606. MPP_FUNCTION(0x04, "lcd0", "pwm"),
  607. MPP_FUNCTION(0x05, "ac97", "sdi3")),
  608. MPP_MODE(19,
  609. MPP_FUNCTION(0x00, "gpio", NULL),
  610. MPP_FUNCTION(0x02, "uart3", "rxd"),
  611. MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
  612. MPP_FUNCTION(0x04, "twsi", "sck")),
  613. MPP_MODE(20,
  614. MPP_FUNCTION(0x00, "gpio", NULL),
  615. MPP_FUNCTION(0x01, "ac97", "sysclko"),
  616. MPP_FUNCTION(0x02, "lcd-spi", "miso"),
  617. MPP_FUNCTION(0x03, "sdio1", "cd"),
  618. MPP_FUNCTION(0x05, "sdio0", "cd"),
  619. MPP_FUNCTION(0x06, "spi1", "miso")),
  620. MPP_MODE(21,
  621. MPP_FUNCTION(0x00, "gpio", NULL),
  622. MPP_FUNCTION(0x01, "uart1", "rts"),
  623. MPP_FUNCTION(0x02, "lcd-spi", "cs0"),
  624. MPP_FUNCTION(0x03, "sdio1", "wp"),
  625. MPP_FUNCTION(0x04, "ssp", "sfrm"),
  626. MPP_FUNCTION(0x05, "sdio0", "wp"),
  627. MPP_FUNCTION(0x06, "spi1", "cs")),
  628. MPP_MODE(22,
  629. MPP_FUNCTION(0x00, "gpio", NULL),
  630. MPP_FUNCTION(0x01, "uart1", "cts"),
  631. MPP_FUNCTION(0x02, "lcd-spi", "mosi"),
  632. MPP_FUNCTION(0x03, "sdio1", "buspwr"),
  633. MPP_FUNCTION(0x04, "ssp", "txd"),
  634. MPP_FUNCTION(0x05, "sdio0", "buspwr"),
  635. MPP_FUNCTION(0x06, "spi1", "mosi")),
  636. MPP_MODE(23,
  637. MPP_FUNCTION(0x00, "gpio", NULL),
  638. MPP_FUNCTION(0x02, "lcd-spi", "sck"),
  639. MPP_FUNCTION(0x03, "sdio1", "ledctrl"),
  640. MPP_FUNCTION(0x04, "ssp", "sclk"),
  641. MPP_FUNCTION(0x05, "sdio0", "ledctrl"),
  642. MPP_FUNCTION(0x06, "spi1", "sck")),
  643. MPP_MODE(24,
  644. MPP_FUNCTION(0x00, "camera", NULL),
  645. MPP_FUNCTION(0x01, "gpio", NULL)),
  646. MPP_MODE(40,
  647. MPP_FUNCTION(0x00, "sdio0", NULL),
  648. MPP_FUNCTION(0x01, "gpio", NULL)),
  649. MPP_MODE(46,
  650. MPP_FUNCTION(0x00, "sdio1", NULL),
  651. MPP_FUNCTION(0x01, "gpio", NULL)),
  652. MPP_MODE(52,
  653. MPP_FUNCTION(0x00, "i2s1/spdifo", NULL),
  654. MPP_FUNCTION(0x02, "i2s1", NULL),
  655. MPP_FUNCTION(0x08, "spdifo", NULL),
  656. MPP_FUNCTION(0x0a, "gpio", NULL),
  657. MPP_FUNCTION(0x0b, "twsi", NULL),
  658. MPP_FUNCTION(0x0c, "ssp/spdifo", NULL),
  659. MPP_FUNCTION(0x0e, "ssp", NULL),
  660. MPP_FUNCTION(0x0f, "ssp/twsi", NULL)),
  661. MPP_MODE(58,
  662. MPP_FUNCTION(0x00, "spi0", NULL),
  663. MPP_FUNCTION(0x01, "gpio", NULL)),
  664. MPP_MODE(62,
  665. MPP_FUNCTION(0x00, "uart1", NULL),
  666. MPP_FUNCTION(0x01, "gpio", NULL)),
  667. MPP_MODE(64,
  668. MPP_FUNCTION(0x00, "nand", NULL),
  669. MPP_FUNCTION(0x01, "gpo", NULL)),
  670. MPP_MODE(72,
  671. MPP_FUNCTION(0x00, "i2s", NULL),
  672. MPP_FUNCTION(0x01, "ac97", NULL)),
  673. MPP_MODE(73,
  674. MPP_FUNCTION(0x00, "twsi-none", NULL),
  675. MPP_FUNCTION(0x01, "twsi-opt1", NULL),
  676. MPP_FUNCTION(0x02, "twsi-opt2", NULL),
  677. MPP_FUNCTION(0x03, "twsi-opt3", NULL)),
  678. };
  679. static struct pinctrl_gpio_range dove_mpp_gpio_ranges[] = {
  680. MPP_GPIO_RANGE(0, 0, 0, 32),
  681. MPP_GPIO_RANGE(1, 32, 32, 32),
  682. MPP_GPIO_RANGE(2, 64, 64, 8),
  683. };
  684. static struct mvebu_pinctrl_soc_info dove_pinctrl_info = {
  685. .controls = dove_mpp_controls,
  686. .ncontrols = ARRAY_SIZE(dove_mpp_controls),
  687. .modes = dove_mpp_modes,
  688. .nmodes = ARRAY_SIZE(dove_mpp_modes),
  689. .gpioranges = dove_mpp_gpio_ranges,
  690. .ngpioranges = ARRAY_SIZE(dove_mpp_gpio_ranges),
  691. .variant = 0,
  692. };
  693. static struct clk *clk;
  694. static const struct of_device_id dove_pinctrl_of_match[] = {
  695. { .compatible = "marvell,dove-pinctrl", .data = &dove_pinctrl_info },
  696. { }
  697. };
  698. static const struct regmap_config gc_regmap_config = {
  699. .reg_bits = 32,
  700. .val_bits = 32,
  701. .reg_stride = 4,
  702. .max_register = 5,
  703. };
  704. static int dove_pinctrl_probe(struct platform_device *pdev)
  705. {
  706. struct resource *res, *mpp_res;
  707. struct resource fb_res;
  708. const struct of_device_id *match =
  709. of_match_device(dove_pinctrl_of_match, &pdev->dev);
  710. struct mvebu_mpp_ctrl_data *mpp_data;
  711. void __iomem *base;
  712. int i;
  713. pdev->dev.platform_data = (void *)match->data;
  714. /*
  715. * General MPP Configuration Register is part of pdma registers.
  716. * grab clk to make sure it is ticking.
  717. */
  718. clk = devm_clk_get(&pdev->dev, NULL);
  719. if (IS_ERR(clk)) {
  720. dev_err(&pdev->dev, "Unable to get pdma clock");
  721. return PTR_ERR(clk);
  722. }
  723. clk_prepare_enable(clk);
  724. mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  725. base = devm_ioremap_resource(&pdev->dev, mpp_res);
  726. if (IS_ERR(base))
  727. return PTR_ERR(base);
  728. mpp_data = devm_kcalloc(&pdev->dev, dove_pinctrl_info.ncontrols,
  729. sizeof(*mpp_data), GFP_KERNEL);
  730. if (!mpp_data)
  731. return -ENOMEM;
  732. dove_pinctrl_info.control_data = mpp_data;
  733. for (i = 0; i < ARRAY_SIZE(dove_mpp_controls); i++)
  734. mpp_data[i].base = base;
  735. /* prepare fallback resource */
  736. memcpy(&fb_res, mpp_res, sizeof(struct resource));
  737. fb_res.start = 0;
  738. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  739. if (!res) {
  740. dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n");
  741. adjust_resource(&fb_res,
  742. (mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4);
  743. res = &fb_res;
  744. }
  745. mpp4_base = devm_ioremap_resource(&pdev->dev, res);
  746. if (IS_ERR(mpp4_base))
  747. return PTR_ERR(mpp4_base);
  748. res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
  749. if (!res) {
  750. dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n");
  751. adjust_resource(&fb_res,
  752. (mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8);
  753. res = &fb_res;
  754. }
  755. pmu_base = devm_ioremap_resource(&pdev->dev, res);
  756. if (IS_ERR(pmu_base))
  757. return PTR_ERR(pmu_base);
  758. gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config");
  759. if (IS_ERR(gconfmap)) {
  760. void __iomem *gc_base;
  761. dev_warn(&pdev->dev, "falling back to hardcoded global registers\n");
  762. adjust_resource(&fb_res,
  763. (mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14);
  764. gc_base = devm_ioremap_resource(&pdev->dev, &fb_res);
  765. if (IS_ERR(gc_base))
  766. return PTR_ERR(gc_base);
  767. gconfmap = devm_regmap_init_mmio(&pdev->dev,
  768. gc_base, &gc_regmap_config);
  769. if (IS_ERR(gconfmap))
  770. return PTR_ERR(gconfmap);
  771. }
  772. /* Warn on any missing DT resource */
  773. if (fb_res.start)
  774. dev_warn(&pdev->dev, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n");
  775. return mvebu_pinctrl_probe(pdev);
  776. }
  777. static struct platform_driver dove_pinctrl_driver = {
  778. .driver = {
  779. .name = "dove-pinctrl",
  780. .suppress_bind_attrs = true,
  781. .of_match_table = dove_pinctrl_of_match,
  782. },
  783. .probe = dove_pinctrl_probe,
  784. };
  785. builtin_platform_driver(dove_pinctrl_driver);