pinctrl-dove.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  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/module.h>
  15. #include <linux/bitops.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/clk.h>
  18. #include <linux/of.h>
  19. #include <linux/of_device.h>
  20. #include <linux/mfd/syscon.h>
  21. #include <linux/pinctrl/pinctrl.h>
  22. #include <linux/regmap.h>
  23. #include "pinctrl-mvebu.h"
  24. /* Internal registers can be configured at any 1 MiB aligned address */
  25. #define INT_REGS_MASK ~(SZ_1M - 1)
  26. #define MPP4_REGS_OFFS 0xd0440
  27. #define PMU_REGS_OFFS 0xd802c
  28. #define GC_REGS_OFFS 0xe802c
  29. /* MPP Base registers */
  30. #define PMU_MPP_GENERAL_CTRL 0x10
  31. #define AU0_AC97_SEL BIT(16)
  32. /* MPP Control 4 register */
  33. #define SPI_GPIO_SEL BIT(5)
  34. #define UART1_GPIO_SEL BIT(4)
  35. #define AU1_GPIO_SEL BIT(3)
  36. #define CAM_GPIO_SEL BIT(2)
  37. #define SD1_GPIO_SEL BIT(1)
  38. #define SD0_GPIO_SEL BIT(0)
  39. /* PMU Signal Select registers */
  40. #define PMU_SIGNAL_SELECT_0 0x00
  41. #define PMU_SIGNAL_SELECT_1 0x04
  42. /* Global Config regmap registers */
  43. #define GLOBAL_CONFIG_1 0x00
  44. #define TWSI_ENABLE_OPTION1 BIT(7)
  45. #define GLOBAL_CONFIG_2 0x04
  46. #define TWSI_ENABLE_OPTION2 BIT(20)
  47. #define TWSI_ENABLE_OPTION3 BIT(21)
  48. #define TWSI_OPTION3_GPIO BIT(22)
  49. #define SSP_CTRL_STATUS_1 0x08
  50. #define SSP_ON_AU1 BIT(0)
  51. #define MPP_GENERAL_CONFIG 0x10
  52. #define AU1_SPDIFO_GPIO_EN BIT(1)
  53. #define NAND_GPIO_EN BIT(0)
  54. #define CONFIG_PMU BIT(4)
  55. static void __iomem *mpp_base;
  56. static void __iomem *mpp4_base;
  57. static void __iomem *pmu_base;
  58. static struct regmap *gconfmap;
  59. static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config)
  60. {
  61. return default_mpp_ctrl_get(mpp_base, pid, config);
  62. }
  63. static int dove_mpp_ctrl_set(unsigned pid, unsigned long config)
  64. {
  65. return default_mpp_ctrl_set(mpp_base, pid, config);
  66. }
  67. static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config)
  68. {
  69. unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
  70. unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
  71. unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
  72. unsigned long func;
  73. if ((pmu & BIT(pid)) == 0)
  74. return default_mpp_ctrl_get(mpp_base, pid, config);
  75. func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
  76. *config = (func >> shift) & MVEBU_MPP_MASK;
  77. *config |= CONFIG_PMU;
  78. return 0;
  79. }
  80. static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config)
  81. {
  82. unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
  83. unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
  84. unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
  85. unsigned long func;
  86. if ((config & CONFIG_PMU) == 0) {
  87. writel(pmu & ~BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL);
  88. return default_mpp_ctrl_set(mpp_base, pid, config);
  89. }
  90. writel(pmu | BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL);
  91. func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
  92. func &= ~(MVEBU_MPP_MASK << shift);
  93. func |= (config & MVEBU_MPP_MASK) << shift;
  94. writel(func, pmu_base + PMU_SIGNAL_SELECT_0 + off);
  95. return 0;
  96. }
  97. static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config)
  98. {
  99. unsigned long mpp4 = readl(mpp4_base);
  100. unsigned long mask;
  101. switch (pid) {
  102. case 24: /* mpp_camera */
  103. mask = CAM_GPIO_SEL;
  104. break;
  105. case 40: /* mpp_sdio0 */
  106. mask = SD0_GPIO_SEL;
  107. break;
  108. case 46: /* mpp_sdio1 */
  109. mask = SD1_GPIO_SEL;
  110. break;
  111. case 58: /* mpp_spi0 */
  112. mask = SPI_GPIO_SEL;
  113. break;
  114. case 62: /* mpp_uart1 */
  115. mask = UART1_GPIO_SEL;
  116. break;
  117. default:
  118. return -EINVAL;
  119. }
  120. *config = ((mpp4 & mask) != 0);
  121. return 0;
  122. }
  123. static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config)
  124. {
  125. unsigned long mpp4 = readl(mpp4_base);
  126. unsigned long mask;
  127. switch (pid) {
  128. case 24: /* mpp_camera */
  129. mask = CAM_GPIO_SEL;
  130. break;
  131. case 40: /* mpp_sdio0 */
  132. mask = SD0_GPIO_SEL;
  133. break;
  134. case 46: /* mpp_sdio1 */
  135. mask = SD1_GPIO_SEL;
  136. break;
  137. case 58: /* mpp_spi0 */
  138. mask = SPI_GPIO_SEL;
  139. break;
  140. case 62: /* mpp_uart1 */
  141. mask = UART1_GPIO_SEL;
  142. break;
  143. default:
  144. return -EINVAL;
  145. }
  146. mpp4 &= ~mask;
  147. if (config)
  148. mpp4 |= mask;
  149. writel(mpp4, mpp4_base);
  150. return 0;
  151. }
  152. static int dove_nand_ctrl_get(unsigned pid, unsigned long *config)
  153. {
  154. unsigned int gmpp;
  155. regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp);
  156. *config = ((gmpp & NAND_GPIO_EN) != 0);
  157. return 0;
  158. }
  159. static int dove_nand_ctrl_set(unsigned pid, unsigned long config)
  160. {
  161. regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG,
  162. NAND_GPIO_EN,
  163. (config) ? NAND_GPIO_EN : 0);
  164. return 0;
  165. }
  166. static int dove_audio0_ctrl_get(unsigned pid, unsigned long *config)
  167. {
  168. unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
  169. *config = ((pmu & AU0_AC97_SEL) != 0);
  170. return 0;
  171. }
  172. static int dove_audio0_ctrl_set(unsigned pid, unsigned long config)
  173. {
  174. unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
  175. pmu &= ~AU0_AC97_SEL;
  176. if (config)
  177. pmu |= AU0_AC97_SEL;
  178. writel(pmu, mpp_base + PMU_MPP_GENERAL_CTRL);
  179. return 0;
  180. }
  181. static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config)
  182. {
  183. unsigned int mpp4 = readl(mpp4_base);
  184. unsigned int sspc1;
  185. unsigned int gmpp;
  186. unsigned int gcfg2;
  187. regmap_read(gconfmap, SSP_CTRL_STATUS_1, &sspc1);
  188. regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp);
  189. regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2);
  190. *config = 0;
  191. if (mpp4 & AU1_GPIO_SEL)
  192. *config |= BIT(3);
  193. if (sspc1 & SSP_ON_AU1)
  194. *config |= BIT(2);
  195. if (gmpp & AU1_SPDIFO_GPIO_EN)
  196. *config |= BIT(1);
  197. if (gcfg2 & TWSI_OPTION3_GPIO)
  198. *config |= BIT(0);
  199. /* SSP/TWSI only if I2S1 not set*/
  200. if ((*config & BIT(3)) == 0)
  201. *config &= ~(BIT(2) | BIT(0));
  202. /* TWSI only if SPDIFO not set*/
  203. if ((*config & BIT(1)) == 0)
  204. *config &= ~BIT(0);
  205. return 0;
  206. }
  207. static int dove_audio1_ctrl_set(unsigned pid, 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(unsigned pid)
  231. {
  232. unsigned long config;
  233. dove_audio1_ctrl_get(pid, &config);
  234. switch (config) {
  235. case 0x02: /* i2s1 : gpio[56:57] */
  236. case 0x0e: /* ssp : gpio[56:57] */
  237. if (pid >= 56)
  238. return 0;
  239. return -ENOTSUPP;
  240. case 0x08: /* spdifo : gpio[52:55] */
  241. case 0x0b: /* twsi : gpio[52:55] */
  242. if (pid <= 55)
  243. return 0;
  244. return -ENOTSUPP;
  245. case 0x0a: /* all gpio */
  246. return 0;
  247. /* 0x00 : i2s1/spdifo : no gpio */
  248. /* 0x0c : ssp/spdifo : no gpio */
  249. /* 0x0f : ssp/twsi : no gpio */
  250. }
  251. return -ENOTSUPP;
  252. }
  253. /* mpp[52:57] has gpio pins capable of in and out */
  254. static int dove_audio1_ctrl_gpio_dir(unsigned pid, bool input)
  255. {
  256. if (pid < 52 || pid > 57)
  257. return -ENOTSUPP;
  258. return 0;
  259. }
  260. static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config)
  261. {
  262. unsigned int gcfg1;
  263. unsigned int gcfg2;
  264. regmap_read(gconfmap, GLOBAL_CONFIG_1, &gcfg1);
  265. regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2);
  266. *config = 0;
  267. if (gcfg1 & TWSI_ENABLE_OPTION1)
  268. *config = 1;
  269. else if (gcfg2 & TWSI_ENABLE_OPTION2)
  270. *config = 2;
  271. else if (gcfg2 & TWSI_ENABLE_OPTION3)
  272. *config = 3;
  273. return 0;
  274. }
  275. static int dove_twsi_ctrl_set(unsigned pid, 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 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, dove_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. pdev->dev.platform_data = (void *)match->data;
  707. /*
  708. * General MPP Configuration Register is part of pdma registers.
  709. * grab clk to make sure it is ticking.
  710. */
  711. clk = devm_clk_get(&pdev->dev, NULL);
  712. if (IS_ERR(clk)) {
  713. dev_err(&pdev->dev, "Unable to get pdma clock");
  714. return PTR_ERR(clk);
  715. }
  716. clk_prepare_enable(clk);
  717. mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  718. mpp_base = devm_ioremap_resource(&pdev->dev, mpp_res);
  719. if (IS_ERR(mpp_base))
  720. return PTR_ERR(mpp_base);
  721. /* prepare fallback resource */
  722. memcpy(&fb_res, mpp_res, sizeof(struct resource));
  723. fb_res.start = 0;
  724. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  725. if (!res) {
  726. dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n");
  727. adjust_resource(&fb_res,
  728. (mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4);
  729. res = &fb_res;
  730. }
  731. mpp4_base = devm_ioremap_resource(&pdev->dev, res);
  732. if (IS_ERR(mpp4_base))
  733. return PTR_ERR(mpp4_base);
  734. res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
  735. if (!res) {
  736. dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n");
  737. adjust_resource(&fb_res,
  738. (mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8);
  739. res = &fb_res;
  740. }
  741. pmu_base = devm_ioremap_resource(&pdev->dev, res);
  742. if (IS_ERR(pmu_base))
  743. return PTR_ERR(pmu_base);
  744. gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config");
  745. if (IS_ERR(gconfmap)) {
  746. void __iomem *gc_base;
  747. dev_warn(&pdev->dev, "falling back to hardcoded global registers\n");
  748. adjust_resource(&fb_res,
  749. (mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14);
  750. gc_base = devm_ioremap_resource(&pdev->dev, &fb_res);
  751. if (IS_ERR(gc_base))
  752. return PTR_ERR(gc_base);
  753. gconfmap = devm_regmap_init_mmio(&pdev->dev,
  754. gc_base, &gc_regmap_config);
  755. if (IS_ERR(gconfmap))
  756. return PTR_ERR(gconfmap);
  757. }
  758. /* Warn on any missing DT resource */
  759. if (fb_res.start)
  760. dev_warn(&pdev->dev, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n");
  761. return mvebu_pinctrl_probe(pdev);
  762. }
  763. static int dove_pinctrl_remove(struct platform_device *pdev)
  764. {
  765. if (!IS_ERR(clk))
  766. clk_disable_unprepare(clk);
  767. return 0;
  768. }
  769. static struct platform_driver dove_pinctrl_driver = {
  770. .driver = {
  771. .name = "dove-pinctrl",
  772. .of_match_table = dove_pinctrl_of_match,
  773. },
  774. .probe = dove_pinctrl_probe,
  775. .remove = dove_pinctrl_remove,
  776. };
  777. module_platform_driver(dove_pinctrl_driver);
  778. MODULE_AUTHOR("Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>");
  779. MODULE_DESCRIPTION("Marvell Dove pinctrl driver");
  780. MODULE_LICENSE("GPL v2");