littleton.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-pxa/littleton.c
  4. *
  5. * Support for the Marvell Littleton Development Platform.
  6. *
  7. * Author: Jason Chagas (largely modified code)
  8. * Created: Nov 20, 2006
  9. * Copyright: (C) Copyright 2006 Marvell International Ltd.
  10. *
  11. * 2007-11-22 modified to align with latest kernel
  12. * eric miao <[email protected]>
  13. */
  14. #include <linux/init.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/delay.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/clk.h>
  19. #include <linux/gpio/machine.h>
  20. #include <linux/spi/spi.h>
  21. #include <linux/spi/pxa2xx_spi.h>
  22. #include <linux/smc91x.h>
  23. #include <linux/i2c.h>
  24. #include <linux/leds.h>
  25. #include <linux/mfd/da903x.h>
  26. #include <linux/platform_data/max732x.h>
  27. #include <linux/platform_data/i2c-pxa.h>
  28. #include <asm/types.h>
  29. #include <asm/setup.h>
  30. #include <asm/memory.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/irq.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <asm/mach/irq.h>
  36. #include "pxa300.h"
  37. #include "devices.h"
  38. #include <linux/platform_data/video-pxafb.h>
  39. #include <linux/platform_data/mmc-pxamci.h>
  40. #include <linux/platform_data/keypad-pxa27x.h>
  41. #include "littleton.h"
  42. #include <linux/platform_data/mtd-nand-pxa3xx.h>
  43. #include "generic.h"
  44. /* Littleton MFP configurations */
  45. static mfp_cfg_t littleton_mfp_cfg[] __initdata = {
  46. /* LCD */
  47. GPIO54_LCD_LDD_0,
  48. GPIO55_LCD_LDD_1,
  49. GPIO56_LCD_LDD_2,
  50. GPIO57_LCD_LDD_3,
  51. GPIO58_LCD_LDD_4,
  52. GPIO59_LCD_LDD_5,
  53. GPIO60_LCD_LDD_6,
  54. GPIO61_LCD_LDD_7,
  55. GPIO62_LCD_LDD_8,
  56. GPIO63_LCD_LDD_9,
  57. GPIO64_LCD_LDD_10,
  58. GPIO65_LCD_LDD_11,
  59. GPIO66_LCD_LDD_12,
  60. GPIO67_LCD_LDD_13,
  61. GPIO68_LCD_LDD_14,
  62. GPIO69_LCD_LDD_15,
  63. GPIO70_LCD_LDD_16,
  64. GPIO71_LCD_LDD_17,
  65. GPIO72_LCD_FCLK,
  66. GPIO73_LCD_LCLK,
  67. GPIO74_LCD_PCLK,
  68. GPIO75_LCD_BIAS,
  69. /* SSP2 */
  70. GPIO25_SSP2_SCLK,
  71. GPIO27_SSP2_TXD,
  72. GPIO17_GPIO, /* SFRM as chip-select */
  73. /* Debug Ethernet */
  74. GPIO90_GPIO,
  75. /* Keypad */
  76. GPIO107_KP_DKIN_0,
  77. GPIO108_KP_DKIN_1,
  78. GPIO115_KP_MKIN_0,
  79. GPIO116_KP_MKIN_1,
  80. GPIO117_KP_MKIN_2,
  81. GPIO118_KP_MKIN_3,
  82. GPIO119_KP_MKIN_4,
  83. GPIO120_KP_MKIN_5,
  84. GPIO121_KP_MKOUT_0,
  85. GPIO122_KP_MKOUT_1,
  86. GPIO123_KP_MKOUT_2,
  87. GPIO124_KP_MKOUT_3,
  88. GPIO125_KP_MKOUT_4,
  89. /* MMC1 */
  90. GPIO3_MMC1_DAT0,
  91. GPIO4_MMC1_DAT1,
  92. GPIO5_MMC1_DAT2,
  93. GPIO6_MMC1_DAT3,
  94. GPIO7_MMC1_CLK,
  95. GPIO8_MMC1_CMD,
  96. GPIO15_GPIO, /* card detect */
  97. /* UART3 */
  98. GPIO107_UART3_CTS,
  99. GPIO108_UART3_RTS,
  100. GPIO109_UART3_TXD,
  101. GPIO110_UART3_RXD,
  102. };
  103. static struct resource smc91x_resources[] = {
  104. [0] = {
  105. .start = (LITTLETON_ETH_PHYS + 0x300),
  106. .end = (LITTLETON_ETH_PHYS + 0xfffff),
  107. .flags = IORESOURCE_MEM,
  108. },
  109. [1] = {
  110. .start = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO90)),
  111. .end = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO90)),
  112. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  113. }
  114. };
  115. static struct smc91x_platdata littleton_smc91x_info = {
  116. .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
  117. SMC91X_NOWAIT | SMC91X_USE_DMA,
  118. };
  119. static struct platform_device smc91x_device = {
  120. .name = "smc91x",
  121. .id = 0,
  122. .num_resources = ARRAY_SIZE(smc91x_resources),
  123. .resource = smc91x_resources,
  124. .dev = {
  125. .platform_data = &littleton_smc91x_info,
  126. },
  127. };
  128. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  129. static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
  130. [0] = {
  131. /* VGA */
  132. .pixclock = 38250,
  133. .xres = 480,
  134. .yres = 640,
  135. .bpp = 16,
  136. .hsync_len = 8,
  137. .left_margin = 8,
  138. .right_margin = 24,
  139. .vsync_len = 2,
  140. .upper_margin = 2,
  141. .lower_margin = 4,
  142. .sync = 0,
  143. },
  144. [1] = {
  145. /* QVGA */
  146. .pixclock = 153000,
  147. .xres = 240,
  148. .yres = 320,
  149. .bpp = 16,
  150. .hsync_len = 8,
  151. .left_margin = 8,
  152. .right_margin = 88,
  153. .vsync_len = 2,
  154. .upper_margin = 2,
  155. .lower_margin = 2,
  156. .sync = 0,
  157. },
  158. };
  159. static struct pxafb_mach_info littleton_lcd_info = {
  160. .modes = tpo_tdo24mtea1_modes,
  161. .num_modes = 2,
  162. .lcd_conn = LCD_COLOR_TFT_16BPP,
  163. };
  164. static void __init littleton_init_lcd(void)
  165. {
  166. pxa_set_fb_info(NULL, &littleton_lcd_info);
  167. }
  168. #else
  169. static inline void littleton_init_lcd(void) {};
  170. #endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */
  171. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  172. static struct pxa2xx_spi_controller littleton_spi_info = {
  173. .num_chipselect = 1,
  174. };
  175. static struct pxa2xx_spi_chip littleton_tdo24m_chip = {
  176. .rx_threshold = 1,
  177. .tx_threshold = 1,
  178. };
  179. static struct spi_board_info littleton_spi_devices[] __initdata = {
  180. {
  181. .modalias = "tdo24m",
  182. .max_speed_hz = 1000000,
  183. .bus_num = 2,
  184. .chip_select = 0,
  185. .controller_data= &littleton_tdo24m_chip,
  186. },
  187. };
  188. static struct gpiod_lookup_table littleton_spi_gpio_table = {
  189. .dev_id = "spi2",
  190. .table = {
  191. GPIO_LOOKUP_IDX("gpio-pxa", LITTLETON_GPIO_LCD_CS, "cs", 0, GPIO_ACTIVE_LOW),
  192. { },
  193. },
  194. };
  195. static void __init littleton_init_spi(void)
  196. {
  197. gpiod_add_lookup_table(&littleton_spi_gpio_table);
  198. pxa2xx_set_spi_info(2, &littleton_spi_info);
  199. spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices));
  200. }
  201. #else
  202. static inline void littleton_init_spi(void) {}
  203. #endif
  204. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  205. static const unsigned int littleton_matrix_key_map[] = {
  206. /* KEY(row, col, key_code) */
  207. KEY(1, 3, KEY_0), KEY(0, 0, KEY_1), KEY(1, 0, KEY_2), KEY(2, 0, KEY_3),
  208. KEY(0, 1, KEY_4), KEY(1, 1, KEY_5), KEY(2, 1, KEY_6), KEY(0, 2, KEY_7),
  209. KEY(1, 2, KEY_8), KEY(2, 2, KEY_9),
  210. KEY(0, 3, KEY_KPASTERISK), /* * */
  211. KEY(2, 3, KEY_KPDOT), /* # */
  212. KEY(5, 4, KEY_ENTER),
  213. KEY(5, 0, KEY_UP),
  214. KEY(5, 1, KEY_DOWN),
  215. KEY(5, 2, KEY_LEFT),
  216. KEY(5, 3, KEY_RIGHT),
  217. KEY(3, 2, KEY_HOME),
  218. KEY(4, 1, KEY_END),
  219. KEY(3, 3, KEY_BACK),
  220. KEY(4, 0, KEY_SEND),
  221. KEY(4, 2, KEY_VOLUMEUP),
  222. KEY(4, 3, KEY_VOLUMEDOWN),
  223. KEY(3, 0, KEY_F22), /* soft1 */
  224. KEY(3, 1, KEY_F23), /* soft2 */
  225. };
  226. static struct matrix_keymap_data littleton_matrix_keymap_data = {
  227. .keymap = littleton_matrix_key_map,
  228. .keymap_size = ARRAY_SIZE(littleton_matrix_key_map),
  229. };
  230. static struct pxa27x_keypad_platform_data littleton_keypad_info = {
  231. .matrix_key_rows = 6,
  232. .matrix_key_cols = 5,
  233. .matrix_keymap_data = &littleton_matrix_keymap_data,
  234. .enable_rotary0 = 1,
  235. .rotary0_up_key = KEY_UP,
  236. .rotary0_down_key = KEY_DOWN,
  237. .debounce_interval = 30,
  238. };
  239. static void __init littleton_init_keypad(void)
  240. {
  241. pxa_set_keypad_info(&littleton_keypad_info);
  242. }
  243. #else
  244. static inline void littleton_init_keypad(void) {}
  245. #endif
  246. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  247. static struct pxamci_platform_data littleton_mci_platform_data = {
  248. .detect_delay_ms = 200,
  249. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  250. };
  251. static struct gpiod_lookup_table littleton_mci_gpio_table = {
  252. .dev_id = "pxa2xx-mci.0",
  253. .table = {
  254. /* Card detect on MFP (gpio-pxa) GPIO 15 */
  255. GPIO_LOOKUP("gpio-pxa", MFP_PIN_GPIO15,
  256. "cd", GPIO_ACTIVE_LOW),
  257. { },
  258. },
  259. };
  260. static void __init littleton_init_mmc(void)
  261. {
  262. gpiod_add_lookup_table(&littleton_mci_gpio_table);
  263. pxa_set_mci_info(&littleton_mci_platform_data);
  264. }
  265. #else
  266. static inline void littleton_init_mmc(void) {}
  267. #endif
  268. #if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
  269. static struct mtd_partition littleton_nand_partitions[] = {
  270. [0] = {
  271. .name = "Bootloader",
  272. .offset = 0,
  273. .size = 0x060000,
  274. .mask_flags = MTD_WRITEABLE, /* force read-only */
  275. },
  276. [1] = {
  277. .name = "Kernel",
  278. .offset = 0x060000,
  279. .size = 0x200000,
  280. .mask_flags = MTD_WRITEABLE, /* force read-only */
  281. },
  282. [2] = {
  283. .name = "Filesystem",
  284. .offset = 0x0260000,
  285. .size = 0x3000000, /* 48M - rootfs */
  286. },
  287. [3] = {
  288. .name = "MassStorage",
  289. .offset = 0x3260000,
  290. .size = 0x3d40000,
  291. },
  292. [4] = {
  293. .name = "BBT",
  294. .offset = 0x6FA0000,
  295. .size = 0x80000,
  296. .mask_flags = MTD_WRITEABLE, /* force read-only */
  297. },
  298. /* NOTE: we reserve some blocks at the end of the NAND flash for
  299. * bad block management, and the max number of relocation blocks
  300. * differs on different platforms. Please take care with it when
  301. * defining the partition table.
  302. */
  303. };
  304. static struct pxa3xx_nand_platform_data littleton_nand_info = {
  305. .parts = littleton_nand_partitions,
  306. .nr_parts = ARRAY_SIZE(littleton_nand_partitions),
  307. };
  308. static void __init littleton_init_nand(void)
  309. {
  310. pxa3xx_set_nand_info(&littleton_nand_info);
  311. }
  312. #else
  313. static inline void littleton_init_nand(void) {}
  314. #endif /* IS_ENABLED(CONFIG_MTD_NAND_MARVELL) */
  315. #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
  316. static struct led_info littleton_da9034_leds[] = {
  317. [0] = {
  318. .name = "littleton:keypad1",
  319. .flags = DA9034_LED_RAMP,
  320. },
  321. [1] = {
  322. .name = "littleton:keypad2",
  323. .flags = DA9034_LED_RAMP,
  324. },
  325. [2] = {
  326. .name = "littleton:vibra",
  327. .flags = 0,
  328. },
  329. };
  330. static struct da9034_touch_pdata littleton_da9034_touch = {
  331. .x_inverted = 1,
  332. .interval_ms = 20,
  333. };
  334. static struct da903x_subdev_info littleton_da9034_subdevs[] = {
  335. {
  336. .name = "da903x-led",
  337. .id = DA9034_ID_LED_1,
  338. .platform_data = &littleton_da9034_leds[0],
  339. }, {
  340. .name = "da903x-led",
  341. .id = DA9034_ID_LED_2,
  342. .platform_data = &littleton_da9034_leds[1],
  343. }, {
  344. .name = "da903x-led",
  345. .id = DA9034_ID_VIBRA,
  346. .platform_data = &littleton_da9034_leds[2],
  347. }, {
  348. .name = "da903x-backlight",
  349. .id = DA9034_ID_WLED,
  350. }, {
  351. .name = "da9034-touch",
  352. .id = DA9034_ID_TOUCH,
  353. .platform_data = &littleton_da9034_touch,
  354. },
  355. };
  356. static struct da903x_platform_data littleton_da9034_info = {
  357. .num_subdevs = ARRAY_SIZE(littleton_da9034_subdevs),
  358. .subdevs = littleton_da9034_subdevs,
  359. };
  360. static struct max732x_platform_data littleton_max7320_info = {
  361. .gpio_base = EXT0_GPIO_BASE,
  362. };
  363. static struct i2c_board_info littleton_i2c_info[] = {
  364. [0] = {
  365. .type = "da9034",
  366. .addr = 0x34,
  367. .platform_data = &littleton_da9034_info,
  368. .irq = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO18)),
  369. },
  370. [1] = {
  371. .type = "max7320",
  372. .addr = 0x50,
  373. .platform_data = &littleton_max7320_info,
  374. },
  375. };
  376. static void __init littleton_init_i2c(void)
  377. {
  378. pxa_set_i2c_info(NULL);
  379. i2c_register_board_info(0, ARRAY_AND_SIZE(littleton_i2c_info));
  380. }
  381. #else
  382. static inline void littleton_init_i2c(void) {}
  383. #endif /* CONFIG_I2C_PXA || CONFIG_I2C_PXA_MODULE */
  384. static void __init littleton_init(void)
  385. {
  386. /* initialize MFP configurations */
  387. pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg));
  388. pxa_set_ffuart_info(NULL);
  389. pxa_set_btuart_info(NULL);
  390. pxa_set_stuart_info(NULL);
  391. /*
  392. * Note: we depend bootloader set the correct
  393. * value to MSC register for SMC91x.
  394. */
  395. platform_device_register(&smc91x_device);
  396. littleton_init_spi();
  397. littleton_init_i2c();
  398. littleton_init_mmc();
  399. littleton_init_lcd();
  400. littleton_init_keypad();
  401. littleton_init_nand();
  402. }
  403. MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)")
  404. .atag_offset = 0x100,
  405. .map_io = pxa3xx_map_io,
  406. .nr_irqs = LITTLETON_NR_IRQS,
  407. .init_irq = pxa3xx_init_irq,
  408. .handle_irq = pxa3xx_handle_irq,
  409. .init_time = pxa_timer_init,
  410. .init_machine = littleton_init,
  411. .restart = pxa_restart,
  412. MACHINE_END