pinctrl-dove.c 28 KB

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