pinctrl-spear300.c 17 KB

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