pinctrl-spear300.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. /*
  2. * Driver for the ST Microelectronics SPEAr300 pinmux
  3. *
  4. * Copyright (C) 2012 ST Microelectronics
  5. * Viresh Kumar <[email protected]>
  6. *
  7. * This file is licensed under the terms of the GNU General Public
  8. * License version 2. This program is licensed "as is" without any
  9. * warranty of any kind, whether express or implied.
  10. */
  11. #include <linux/err.h>
  12. #include <linux/init.h>
  13. #include <linux/of_device.h>
  14. #include <linux/platform_device.h>
  15. #include "pinctrl-spear3xx.h"
  16. #define DRIVER_NAME "spear300-pinmux"
  17. /* addresses */
  18. #define PMX_CONFIG_REG 0x00
  19. #define MODE_CONFIG_REG 0x04
  20. /* modes */
  21. #define NAND_MODE (1 << 0)
  22. #define NOR_MODE (1 << 1)
  23. #define PHOTO_FRAME_MODE (1 << 2)
  24. #define LEND_IP_PHONE_MODE (1 << 3)
  25. #define HEND_IP_PHONE_MODE (1 << 4)
  26. #define LEND_WIFI_PHONE_MODE (1 << 5)
  27. #define HEND_WIFI_PHONE_MODE (1 << 6)
  28. #define ATA_PABX_WI2S_MODE (1 << 7)
  29. #define ATA_PABX_I2S_MODE (1 << 8)
  30. #define CAML_LCDW_MODE (1 << 9)
  31. #define CAMU_LCD_MODE (1 << 10)
  32. #define CAMU_WLCD_MODE (1 << 11)
  33. #define CAML_LCD_MODE (1 << 12)
  34. static struct spear_pmx_mode pmx_mode_nand = {
  35. .name = "nand",
  36. .mode = NAND_MODE,
  37. .reg = MODE_CONFIG_REG,
  38. .mask = 0x0000000F,
  39. .val = 0x00,
  40. };
  41. static struct spear_pmx_mode pmx_mode_nor = {
  42. .name = "nor",
  43. .mode = NOR_MODE,
  44. .reg = MODE_CONFIG_REG,
  45. .mask = 0x0000000F,
  46. .val = 0x01,
  47. };
  48. static struct spear_pmx_mode pmx_mode_photo_frame = {
  49. .name = "photo frame mode",
  50. .mode = PHOTO_FRAME_MODE,
  51. .reg = MODE_CONFIG_REG,
  52. .mask = 0x0000000F,
  53. .val = 0x02,
  54. };
  55. static struct spear_pmx_mode pmx_mode_lend_ip_phone = {
  56. .name = "lend ip phone mode",
  57. .mode = LEND_IP_PHONE_MODE,
  58. .reg = MODE_CONFIG_REG,
  59. .mask = 0x0000000F,
  60. .val = 0x03,
  61. };
  62. static struct spear_pmx_mode pmx_mode_hend_ip_phone = {
  63. .name = "hend ip phone mode",
  64. .mode = HEND_IP_PHONE_MODE,
  65. .reg = MODE_CONFIG_REG,
  66. .mask = 0x0000000F,
  67. .val = 0x04,
  68. };
  69. static struct spear_pmx_mode pmx_mode_lend_wifi_phone = {
  70. .name = "lend wifi phone mode",
  71. .mode = LEND_WIFI_PHONE_MODE,
  72. .reg = MODE_CONFIG_REG,
  73. .mask = 0x0000000F,
  74. .val = 0x05,
  75. };
  76. static struct spear_pmx_mode pmx_mode_hend_wifi_phone = {
  77. .name = "hend wifi phone mode",
  78. .mode = HEND_WIFI_PHONE_MODE,
  79. .reg = MODE_CONFIG_REG,
  80. .mask = 0x0000000F,
  81. .val = 0x06,
  82. };
  83. static struct spear_pmx_mode pmx_mode_ata_pabx_wi2s = {
  84. .name = "ata pabx wi2s mode",
  85. .mode = ATA_PABX_WI2S_MODE,
  86. .reg = MODE_CONFIG_REG,
  87. .mask = 0x0000000F,
  88. .val = 0x07,
  89. };
  90. static struct spear_pmx_mode pmx_mode_ata_pabx_i2s = {
  91. .name = "ata pabx i2s mode",
  92. .mode = ATA_PABX_I2S_MODE,
  93. .reg = MODE_CONFIG_REG,
  94. .mask = 0x0000000F,
  95. .val = 0x08,
  96. };
  97. static struct spear_pmx_mode pmx_mode_caml_lcdw = {
  98. .name = "caml lcdw mode",
  99. .mode = CAML_LCDW_MODE,
  100. .reg = MODE_CONFIG_REG,
  101. .mask = 0x0000000F,
  102. .val = 0x0C,
  103. };
  104. static struct spear_pmx_mode pmx_mode_camu_lcd = {
  105. .name = "camu lcd mode",
  106. .mode = CAMU_LCD_MODE,
  107. .reg = MODE_CONFIG_REG,
  108. .mask = 0x0000000F,
  109. .val = 0x0D,
  110. };
  111. static struct spear_pmx_mode pmx_mode_camu_wlcd = {
  112. .name = "camu wlcd mode",
  113. .mode = CAMU_WLCD_MODE,
  114. .reg = MODE_CONFIG_REG,
  115. .mask = 0x0000000F,
  116. .val = 0xE,
  117. };
  118. static struct spear_pmx_mode pmx_mode_caml_lcd = {
  119. .name = "caml lcd mode",
  120. .mode = CAML_LCD_MODE,
  121. .reg = MODE_CONFIG_REG,
  122. .mask = 0x0000000F,
  123. .val = 0x0F,
  124. };
  125. static struct spear_pmx_mode *spear300_pmx_modes[] = {
  126. &pmx_mode_nand,
  127. &pmx_mode_nor,
  128. &pmx_mode_photo_frame,
  129. &pmx_mode_lend_ip_phone,
  130. &pmx_mode_hend_ip_phone,
  131. &pmx_mode_lend_wifi_phone,
  132. &pmx_mode_hend_wifi_phone,
  133. &pmx_mode_ata_pabx_wi2s,
  134. &pmx_mode_ata_pabx_i2s,
  135. &pmx_mode_caml_lcdw,
  136. &pmx_mode_camu_lcd,
  137. &pmx_mode_camu_wlcd,
  138. &pmx_mode_caml_lcd,
  139. };
  140. /* fsmc_2chips_pins */
  141. static const unsigned fsmc_2chips_pins[] = { 1, 97 };
  142. static struct spear_muxreg fsmc_2chips_muxreg[] = {
  143. {
  144. .reg = PMX_CONFIG_REG,
  145. .mask = PMX_FIRDA_MASK,
  146. .val = 0,
  147. },
  148. };
  149. static struct spear_modemux fsmc_2chips_modemux[] = {
  150. {
  151. .modes = NAND_MODE | NOR_MODE | PHOTO_FRAME_MODE |
  152. ATA_PABX_WI2S_MODE | ATA_PABX_I2S_MODE,
  153. .muxregs = fsmc_2chips_muxreg,
  154. .nmuxregs = ARRAY_SIZE(fsmc_2chips_muxreg),
  155. },
  156. };
  157. static struct spear_pingroup fsmc_2chips_pingroup = {
  158. .name = "fsmc_2chips_grp",
  159. .pins = fsmc_2chips_pins,
  160. .npins = ARRAY_SIZE(fsmc_2chips_pins),
  161. .modemuxs = fsmc_2chips_modemux,
  162. .nmodemuxs = ARRAY_SIZE(fsmc_2chips_modemux),
  163. };
  164. /* fsmc_4chips_pins */
  165. static const unsigned fsmc_4chips_pins[] = { 1, 2, 3, 97 };
  166. static struct spear_muxreg fsmc_4chips_muxreg[] = {
  167. {
  168. .reg = PMX_CONFIG_REG,
  169. .mask = PMX_FIRDA_MASK | PMX_UART0_MASK,
  170. .val = 0,
  171. },
  172. };
  173. static struct spear_modemux fsmc_4chips_modemux[] = {
  174. {
  175. .modes = NAND_MODE | NOR_MODE | PHOTO_FRAME_MODE |
  176. ATA_PABX_WI2S_MODE | ATA_PABX_I2S_MODE,
  177. .muxregs = fsmc_4chips_muxreg,
  178. .nmuxregs = ARRAY_SIZE(fsmc_4chips_muxreg),
  179. },
  180. };
  181. static struct spear_pingroup fsmc_4chips_pingroup = {
  182. .name = "fsmc_4chips_grp",
  183. .pins = fsmc_4chips_pins,
  184. .npins = ARRAY_SIZE(fsmc_4chips_pins),
  185. .modemuxs = fsmc_4chips_modemux,
  186. .nmodemuxs = ARRAY_SIZE(fsmc_4chips_modemux),
  187. };
  188. static const char *const fsmc_grps[] = { "fsmc_2chips_grp", "fsmc_4chips_grp"
  189. };
  190. static struct spear_function fsmc_function = {
  191. .name = "fsmc",
  192. .groups = fsmc_grps,
  193. .ngroups = ARRAY_SIZE(fsmc_grps),
  194. };
  195. /* clcd_lcdmode_pins */
  196. static const unsigned clcd_lcdmode_pins[] = { 49, 50 };
  197. static struct spear_muxreg clcd_lcdmode_muxreg[] = {
  198. {
  199. .reg = PMX_CONFIG_REG,
  200. .mask = PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK,
  201. .val = 0,
  202. },
  203. };
  204. static struct spear_modemux clcd_lcdmode_modemux[] = {
  205. {
  206. .modes = HEND_IP_PHONE_MODE | HEND_WIFI_PHONE_MODE |
  207. CAMU_LCD_MODE | CAML_LCD_MODE,
  208. .muxregs = clcd_lcdmode_muxreg,
  209. .nmuxregs = ARRAY_SIZE(clcd_lcdmode_muxreg),
  210. },
  211. };
  212. static struct spear_pingroup clcd_lcdmode_pingroup = {
  213. .name = "clcd_lcdmode_grp",
  214. .pins = clcd_lcdmode_pins,
  215. .npins = ARRAY_SIZE(clcd_lcdmode_pins),
  216. .modemuxs = clcd_lcdmode_modemux,
  217. .nmodemuxs = ARRAY_SIZE(clcd_lcdmode_modemux),
  218. };
  219. /* clcd_pfmode_pins */
  220. static const unsigned clcd_pfmode_pins[] = { 47, 48, 49, 50 };
  221. static struct spear_muxreg clcd_pfmode_muxreg[] = {
  222. {
  223. .reg = PMX_CONFIG_REG,
  224. .mask = PMX_TIMER_2_3_MASK,
  225. .val = 0,
  226. },
  227. };
  228. static struct spear_modemux clcd_pfmode_modemux[] = {
  229. {
  230. .modes = PHOTO_FRAME_MODE,
  231. .muxregs = clcd_pfmode_muxreg,
  232. .nmuxregs = ARRAY_SIZE(clcd_pfmode_muxreg),
  233. },
  234. };
  235. static struct spear_pingroup clcd_pfmode_pingroup = {
  236. .name = "clcd_pfmode_grp",
  237. .pins = clcd_pfmode_pins,
  238. .npins = ARRAY_SIZE(clcd_pfmode_pins),
  239. .modemuxs = clcd_pfmode_modemux,
  240. .nmodemuxs = ARRAY_SIZE(clcd_pfmode_modemux),
  241. };
  242. static const char *const clcd_grps[] = { "clcd_lcdmode_grp", "clcd_pfmode_grp"
  243. };
  244. static struct spear_function clcd_function = {
  245. .name = "clcd",
  246. .groups = clcd_grps,
  247. .ngroups = ARRAY_SIZE(clcd_grps),
  248. };
  249. /* tdm_pins */
  250. static const unsigned tdm_pins[] = { 34, 35, 36, 37, 38 };
  251. static struct spear_muxreg tdm_muxreg[] = {
  252. {
  253. .reg = PMX_CONFIG_REG,
  254. .mask = PMX_UART0_MODEM_MASK | PMX_SSP_CS_MASK,
  255. .val = 0,
  256. },
  257. };
  258. static struct spear_modemux tdm_modemux[] = {
  259. {
  260. .modes = PHOTO_FRAME_MODE | LEND_IP_PHONE_MODE |
  261. HEND_IP_PHONE_MODE | LEND_WIFI_PHONE_MODE
  262. | HEND_WIFI_PHONE_MODE | ATA_PABX_WI2S_MODE
  263. | ATA_PABX_I2S_MODE | CAML_LCDW_MODE | CAMU_LCD_MODE
  264. | CAMU_WLCD_MODE | CAML_LCD_MODE,
  265. .muxregs = tdm_muxreg,
  266. .nmuxregs = ARRAY_SIZE(tdm_muxreg),
  267. },
  268. };
  269. static struct spear_pingroup tdm_pingroup = {
  270. .name = "tdm_grp",
  271. .pins = tdm_pins,
  272. .npins = ARRAY_SIZE(tdm_pins),
  273. .modemuxs = tdm_modemux,
  274. .nmodemuxs = ARRAY_SIZE(tdm_modemux),
  275. };
  276. static const char *const tdm_grps[] = { "tdm_grp" };
  277. static struct spear_function tdm_function = {
  278. .name = "tdm",
  279. .groups = tdm_grps,
  280. .ngroups = ARRAY_SIZE(tdm_grps),
  281. };
  282. /* i2c_clk_pins */
  283. static const unsigned i2c_clk_pins[] = { 45, 46, 47, 48 };
  284. static struct spear_muxreg i2c_clk_muxreg[] = {
  285. {
  286. .reg = PMX_CONFIG_REG,
  287. .mask = PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK,
  288. .val = 0,
  289. },
  290. };
  291. static struct spear_modemux i2c_clk_modemux[] = {
  292. {
  293. .modes = LEND_IP_PHONE_MODE | HEND_IP_PHONE_MODE |
  294. LEND_WIFI_PHONE_MODE | HEND_WIFI_PHONE_MODE |
  295. ATA_PABX_WI2S_MODE | ATA_PABX_I2S_MODE | CAML_LCDW_MODE
  296. | CAML_LCD_MODE,
  297. .muxregs = i2c_clk_muxreg,
  298. .nmuxregs = ARRAY_SIZE(i2c_clk_muxreg),
  299. },
  300. };
  301. static struct spear_pingroup i2c_clk_pingroup = {
  302. .name = "i2c_clk_grp_grp",
  303. .pins = i2c_clk_pins,
  304. .npins = ARRAY_SIZE(i2c_clk_pins),
  305. .modemuxs = i2c_clk_modemux,
  306. .nmodemuxs = ARRAY_SIZE(i2c_clk_modemux),
  307. };
  308. static const char *const i2c_grps[] = { "i2c_clk_grp" };
  309. static struct spear_function i2c_function = {
  310. .name = "i2c1",
  311. .groups = i2c_grps,
  312. .ngroups = ARRAY_SIZE(i2c_grps),
  313. };
  314. /* caml_pins */
  315. static const unsigned caml_pins[] = { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 };
  316. static struct spear_muxreg caml_muxreg[] = {
  317. {
  318. .reg = PMX_CONFIG_REG,
  319. .mask = PMX_MII_MASK,
  320. .val = 0,
  321. },
  322. };
  323. static struct spear_modemux caml_modemux[] = {
  324. {
  325. .modes = CAML_LCDW_MODE | CAML_LCD_MODE,
  326. .muxregs = caml_muxreg,
  327. .nmuxregs = ARRAY_SIZE(caml_muxreg),
  328. },
  329. };
  330. static struct spear_pingroup caml_pingroup = {
  331. .name = "caml_grp",
  332. .pins = caml_pins,
  333. .npins = ARRAY_SIZE(caml_pins),
  334. .modemuxs = caml_modemux,
  335. .nmodemuxs = ARRAY_SIZE(caml_modemux),
  336. };
  337. /* camu_pins */
  338. static const unsigned camu_pins[] = { 16, 17, 18, 19, 20, 21, 45, 46, 47, 48 };
  339. static struct spear_muxreg camu_muxreg[] = {
  340. {
  341. .reg = PMX_CONFIG_REG,
  342. .mask = PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK | PMX_MII_MASK,
  343. .val = 0,
  344. },
  345. };
  346. static struct spear_modemux camu_modemux[] = {
  347. {
  348. .modes = CAMU_LCD_MODE | CAMU_WLCD_MODE,
  349. .muxregs = camu_muxreg,
  350. .nmuxregs = ARRAY_SIZE(camu_muxreg),
  351. },
  352. };
  353. static struct spear_pingroup camu_pingroup = {
  354. .name = "camu_grp",
  355. .pins = camu_pins,
  356. .npins = ARRAY_SIZE(camu_pins),
  357. .modemuxs = camu_modemux,
  358. .nmodemuxs = ARRAY_SIZE(camu_modemux),
  359. };
  360. static const char *const cam_grps[] = { "caml_grp", "camu_grp" };
  361. static struct spear_function cam_function = {
  362. .name = "cam",
  363. .groups = cam_grps,
  364. .ngroups = ARRAY_SIZE(cam_grps),
  365. };
  366. /* dac_pins */
  367. static const unsigned dac_pins[] = { 43, 44 };
  368. static struct spear_muxreg dac_muxreg[] = {
  369. {
  370. .reg = PMX_CONFIG_REG,
  371. .mask = PMX_TIMER_0_1_MASK,
  372. .val = 0,
  373. },
  374. };
  375. static struct spear_modemux dac_modemux[] = {
  376. {
  377. .modes = ATA_PABX_I2S_MODE | CAML_LCDW_MODE | CAMU_LCD_MODE
  378. | CAMU_WLCD_MODE | CAML_LCD_MODE,
  379. .muxregs = dac_muxreg,
  380. .nmuxregs = ARRAY_SIZE(dac_muxreg),
  381. },
  382. };
  383. static struct spear_pingroup dac_pingroup = {
  384. .name = "dac_grp",
  385. .pins = dac_pins,
  386. .npins = ARRAY_SIZE(dac_pins),
  387. .modemuxs = dac_modemux,
  388. .nmodemuxs = ARRAY_SIZE(dac_modemux),
  389. };
  390. static const char *const dac_grps[] = { "dac_grp" };
  391. static struct spear_function dac_function = {
  392. .name = "dac",
  393. .groups = dac_grps,
  394. .ngroups = ARRAY_SIZE(dac_grps),
  395. };
  396. /* i2s_pins */
  397. static const unsigned i2s_pins[] = { 39, 40, 41, 42 };
  398. static struct spear_muxreg i2s_muxreg[] = {
  399. {
  400. .reg = PMX_CONFIG_REG,
  401. .mask = PMX_UART0_MODEM_MASK,
  402. .val = 0,
  403. },
  404. };
  405. static struct spear_modemux i2s_modemux[] = {
  406. {
  407. .modes = LEND_IP_PHONE_MODE | HEND_IP_PHONE_MODE
  408. | LEND_WIFI_PHONE_MODE | HEND_WIFI_PHONE_MODE |
  409. ATA_PABX_I2S_MODE | CAML_LCDW_MODE | CAMU_LCD_MODE
  410. | CAMU_WLCD_MODE | CAML_LCD_MODE,
  411. .muxregs = i2s_muxreg,
  412. .nmuxregs = ARRAY_SIZE(i2s_muxreg),
  413. },
  414. };
  415. static struct spear_pingroup i2s_pingroup = {
  416. .name = "i2s_grp",
  417. .pins = i2s_pins,
  418. .npins = ARRAY_SIZE(i2s_pins),
  419. .modemuxs = i2s_modemux,
  420. .nmodemuxs = ARRAY_SIZE(i2s_modemux),
  421. };
  422. static const char *const i2s_grps[] = { "i2s_grp" };
  423. static struct spear_function i2s_function = {
  424. .name = "i2s",
  425. .groups = i2s_grps,
  426. .ngroups = ARRAY_SIZE(i2s_grps),
  427. };
  428. /* sdhci_4bit_pins */
  429. static const unsigned sdhci_4bit_pins[] = { 28, 29, 30, 31, 32, 33 };
  430. static struct spear_muxreg sdhci_4bit_muxreg[] = {
  431. {
  432. .reg = PMX_CONFIG_REG,
  433. .mask = PMX_GPIO_PIN0_MASK | PMX_GPIO_PIN1_MASK |
  434. PMX_GPIO_PIN2_MASK | PMX_GPIO_PIN3_MASK |
  435. PMX_GPIO_PIN4_MASK | PMX_GPIO_PIN5_MASK,
  436. .val = 0,
  437. },
  438. };
  439. static struct spear_modemux sdhci_4bit_modemux[] = {
  440. {
  441. .modes = PHOTO_FRAME_MODE | LEND_IP_PHONE_MODE |
  442. HEND_IP_PHONE_MODE | LEND_WIFI_PHONE_MODE |
  443. HEND_WIFI_PHONE_MODE | CAML_LCDW_MODE | CAMU_LCD_MODE |
  444. CAMU_WLCD_MODE | CAML_LCD_MODE | ATA_PABX_WI2S_MODE,
  445. .muxregs = sdhci_4bit_muxreg,
  446. .nmuxregs = ARRAY_SIZE(sdhci_4bit_muxreg),
  447. },
  448. };
  449. static struct spear_pingroup sdhci_4bit_pingroup = {
  450. .name = "sdhci_4bit_grp",
  451. .pins = sdhci_4bit_pins,
  452. .npins = ARRAY_SIZE(sdhci_4bit_pins),
  453. .modemuxs = sdhci_4bit_modemux,
  454. .nmodemuxs = ARRAY_SIZE(sdhci_4bit_modemux),
  455. };
  456. /* sdhci_8bit_pins */
  457. static const unsigned sdhci_8bit_pins[] = { 24, 25, 26, 27, 28, 29, 30, 31, 32,
  458. 33 };
  459. static struct spear_muxreg sdhci_8bit_muxreg[] = {
  460. {
  461. .reg = PMX_CONFIG_REG,
  462. .mask = PMX_GPIO_PIN0_MASK | PMX_GPIO_PIN1_MASK |
  463. PMX_GPIO_PIN2_MASK | PMX_GPIO_PIN3_MASK |
  464. PMX_GPIO_PIN4_MASK | PMX_GPIO_PIN5_MASK | PMX_MII_MASK,
  465. .val = 0,
  466. },
  467. };
  468. static struct spear_modemux sdhci_8bit_modemux[] = {
  469. {
  470. .modes = PHOTO_FRAME_MODE | LEND_IP_PHONE_MODE |
  471. HEND_IP_PHONE_MODE | LEND_WIFI_PHONE_MODE |
  472. HEND_WIFI_PHONE_MODE | CAML_LCDW_MODE | CAMU_LCD_MODE |
  473. CAMU_WLCD_MODE | CAML_LCD_MODE,
  474. .muxregs = sdhci_8bit_muxreg,
  475. .nmuxregs = ARRAY_SIZE(sdhci_8bit_muxreg),
  476. },
  477. };
  478. static struct spear_pingroup sdhci_8bit_pingroup = {
  479. .name = "sdhci_8bit_grp",
  480. .pins = sdhci_8bit_pins,
  481. .npins = ARRAY_SIZE(sdhci_8bit_pins),
  482. .modemuxs = sdhci_8bit_modemux,
  483. .nmodemuxs = ARRAY_SIZE(sdhci_8bit_modemux),
  484. };
  485. static const char *const sdhci_grps[] = { "sdhci_4bit_grp", "sdhci_8bit_grp" };
  486. static struct spear_function sdhci_function = {
  487. .name = "sdhci",
  488. .groups = sdhci_grps,
  489. .ngroups = ARRAY_SIZE(sdhci_grps),
  490. };
  491. /* gpio1_0_to_3_pins */
  492. static const unsigned gpio1_0_to_3_pins[] = { 39, 40, 41, 42 };
  493. static struct spear_muxreg gpio1_0_to_3_muxreg[] = {
  494. {
  495. .reg = PMX_CONFIG_REG,
  496. .mask = PMX_UART0_MODEM_MASK,
  497. .val = 0,
  498. },
  499. };
  500. static struct spear_modemux gpio1_0_to_3_modemux[] = {
  501. {
  502. .modes = PHOTO_FRAME_MODE,
  503. .muxregs = gpio1_0_to_3_muxreg,
  504. .nmuxregs = ARRAY_SIZE(gpio1_0_to_3_muxreg),
  505. },
  506. };
  507. static struct spear_pingroup gpio1_0_to_3_pingroup = {
  508. .name = "gpio1_0_to_3_grp",
  509. .pins = gpio1_0_to_3_pins,
  510. .npins = ARRAY_SIZE(gpio1_0_to_3_pins),
  511. .modemuxs = gpio1_0_to_3_modemux,
  512. .nmodemuxs = ARRAY_SIZE(gpio1_0_to_3_modemux),
  513. };
  514. /* gpio1_4_to_7_pins */
  515. static const unsigned gpio1_4_to_7_pins[] = { 43, 44, 45, 46 };
  516. static struct spear_muxreg gpio1_4_to_7_muxreg[] = {
  517. {
  518. .reg = PMX_CONFIG_REG,
  519. .mask = PMX_TIMER_0_1_MASK | PMX_TIMER_2_3_MASK,
  520. .val = 0,
  521. },
  522. };
  523. static struct spear_modemux gpio1_4_to_7_modemux[] = {
  524. {
  525. .modes = PHOTO_FRAME_MODE,
  526. .muxregs = gpio1_4_to_7_muxreg,
  527. .nmuxregs = ARRAY_SIZE(gpio1_4_to_7_muxreg),
  528. },
  529. };
  530. static struct spear_pingroup gpio1_4_to_7_pingroup = {
  531. .name = "gpio1_4_to_7_grp",
  532. .pins = gpio1_4_to_7_pins,
  533. .npins = ARRAY_SIZE(gpio1_4_to_7_pins),
  534. .modemuxs = gpio1_4_to_7_modemux,
  535. .nmodemuxs = ARRAY_SIZE(gpio1_4_to_7_modemux),
  536. };
  537. static const char *const gpio1_grps[] = { "gpio1_0_to_3_grp", "gpio1_4_to_7_grp"
  538. };
  539. static struct spear_function gpio1_function = {
  540. .name = "gpio1",
  541. .groups = gpio1_grps,
  542. .ngroups = ARRAY_SIZE(gpio1_grps),
  543. };
  544. /* pingroups */
  545. static struct spear_pingroup *spear300_pingroups[] = {
  546. SPEAR3XX_COMMON_PINGROUPS,
  547. &fsmc_2chips_pingroup,
  548. &fsmc_4chips_pingroup,
  549. &clcd_lcdmode_pingroup,
  550. &clcd_pfmode_pingroup,
  551. &tdm_pingroup,
  552. &i2c_clk_pingroup,
  553. &caml_pingroup,
  554. &camu_pingroup,
  555. &dac_pingroup,
  556. &i2s_pingroup,
  557. &sdhci_4bit_pingroup,
  558. &sdhci_8bit_pingroup,
  559. &gpio1_0_to_3_pingroup,
  560. &gpio1_4_to_7_pingroup,
  561. };
  562. /* functions */
  563. static struct spear_function *spear300_functions[] = {
  564. SPEAR3XX_COMMON_FUNCTIONS,
  565. &fsmc_function,
  566. &clcd_function,
  567. &tdm_function,
  568. &i2c_function,
  569. &cam_function,
  570. &dac_function,
  571. &i2s_function,
  572. &sdhci_function,
  573. &gpio1_function,
  574. };
  575. static const struct of_device_id spear300_pinctrl_of_match[] = {
  576. {
  577. .compatible = "st,spear300-pinmux",
  578. },
  579. {},
  580. };
  581. static int spear300_pinctrl_probe(struct platform_device *pdev)
  582. {
  583. spear3xx_machdata.groups = spear300_pingroups;
  584. spear3xx_machdata.ngroups = ARRAY_SIZE(spear300_pingroups);
  585. spear3xx_machdata.functions = spear300_functions;
  586. spear3xx_machdata.nfunctions = ARRAY_SIZE(spear300_functions);
  587. spear3xx_machdata.gpio_pingroups = NULL;
  588. spear3xx_machdata.ngpio_pingroups = 0;
  589. spear3xx_machdata.modes_supported = true;
  590. spear3xx_machdata.pmx_modes = spear300_pmx_modes;
  591. spear3xx_machdata.npmx_modes = ARRAY_SIZE(spear300_pmx_modes);
  592. pmx_init_addr(&spear3xx_machdata, PMX_CONFIG_REG);
  593. return spear_pinctrl_probe(pdev, &spear3xx_machdata);
  594. }
  595. static struct platform_driver spear300_pinctrl_driver = {
  596. .driver = {
  597. .name = DRIVER_NAME,
  598. .of_match_table = spear300_pinctrl_of_match,
  599. },
  600. .probe = spear300_pinctrl_probe,
  601. };
  602. static int __init spear300_pinctrl_init(void)
  603. {
  604. return platform_driver_register(&spear300_pinctrl_driver);
  605. }
  606. arch_initcall(spear300_pinctrl_init);