board-perseus2.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-omap1/board-perseus2.c
  4. *
  5. * Modified from board-generic.c
  6. *
  7. * Original OMAP730 support by Jean Pihet <[email protected]>
  8. * Updated for 2.6 by Kevin Hilman <[email protected]>
  9. */
  10. #include <linux/gpio.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/delay.h>
  15. #include <linux/mtd/mtd.h>
  16. #include <linux/mtd/platnand.h>
  17. #include <linux/mtd/physmap.h>
  18. #include <linux/input.h>
  19. #include <linux/smc91x.h>
  20. #include <linux/omapfb.h>
  21. #include <linux/platform_data/keypad-omap.h>
  22. #include <linux/soc/ti/omap1-io.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/map.h>
  26. #include "tc.h"
  27. #include "mux.h"
  28. #include "flash.h"
  29. #include "hardware.h"
  30. #include "iomap.h"
  31. #include "common.h"
  32. #include "fpga.h"
  33. static const unsigned int p2_keymap[] = {
  34. KEY(0, 0, KEY_UP),
  35. KEY(1, 0, KEY_RIGHT),
  36. KEY(2, 0, KEY_LEFT),
  37. KEY(3, 0, KEY_DOWN),
  38. KEY(4, 0, KEY_ENTER),
  39. KEY(0, 1, KEY_F10),
  40. KEY(1, 1, KEY_SEND),
  41. KEY(2, 1, KEY_END),
  42. KEY(3, 1, KEY_VOLUMEDOWN),
  43. KEY(4, 1, KEY_VOLUMEUP),
  44. KEY(5, 1, KEY_RECORD),
  45. KEY(0, 2, KEY_F9),
  46. KEY(1, 2, KEY_3),
  47. KEY(2, 2, KEY_6),
  48. KEY(3, 2, KEY_9),
  49. KEY(4, 2, KEY_KPDOT),
  50. KEY(0, 3, KEY_BACK),
  51. KEY(1, 3, KEY_2),
  52. KEY(2, 3, KEY_5),
  53. KEY(3, 3, KEY_8),
  54. KEY(4, 3, KEY_0),
  55. KEY(5, 3, KEY_KPSLASH),
  56. KEY(0, 4, KEY_HOME),
  57. KEY(1, 4, KEY_1),
  58. KEY(2, 4, KEY_4),
  59. KEY(3, 4, KEY_7),
  60. KEY(4, 4, KEY_KPASTERISK),
  61. KEY(5, 4, KEY_POWER),
  62. };
  63. static struct smc91x_platdata smc91x_info = {
  64. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  65. .leda = RPC_LED_100_10,
  66. .ledb = RPC_LED_TX_RX,
  67. };
  68. static struct resource smc91x_resources[] = {
  69. [0] = {
  70. .start = H2P2_DBG_FPGA_ETHR_START, /* Physical */
  71. .end = H2P2_DBG_FPGA_ETHR_START + 0xf,
  72. .flags = IORESOURCE_MEM,
  73. },
  74. [1] = {
  75. .start = INT_7XX_MPU_EXT_NIRQ,
  76. .end = 0,
  77. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  78. },
  79. };
  80. static struct mtd_partition nor_partitions[] = {
  81. /* bootloader (U-Boot, etc) in first sector */
  82. {
  83. .name = "bootloader",
  84. .offset = 0,
  85. .size = SZ_128K,
  86. .mask_flags = MTD_WRITEABLE, /* force read-only */
  87. },
  88. /* bootloader params in the next sector */
  89. {
  90. .name = "params",
  91. .offset = MTDPART_OFS_APPEND,
  92. .size = SZ_128K,
  93. .mask_flags = 0,
  94. },
  95. /* kernel */
  96. {
  97. .name = "kernel",
  98. .offset = MTDPART_OFS_APPEND,
  99. .size = SZ_2M,
  100. .mask_flags = 0
  101. },
  102. /* rest of flash is a file system */
  103. {
  104. .name = "rootfs",
  105. .offset = MTDPART_OFS_APPEND,
  106. .size = MTDPART_SIZ_FULL,
  107. .mask_flags = 0
  108. },
  109. };
  110. static struct physmap_flash_data nor_data = {
  111. .width = 2,
  112. .set_vpp = omap1_set_vpp,
  113. .parts = nor_partitions,
  114. .nr_parts = ARRAY_SIZE(nor_partitions),
  115. };
  116. static struct resource nor_resource = {
  117. .start = OMAP_CS0_PHYS,
  118. .end = OMAP_CS0_PHYS + SZ_32M - 1,
  119. .flags = IORESOURCE_MEM,
  120. };
  121. static struct platform_device nor_device = {
  122. .name = "physmap-flash",
  123. .id = 0,
  124. .dev = {
  125. .platform_data = &nor_data,
  126. },
  127. .num_resources = 1,
  128. .resource = &nor_resource,
  129. };
  130. #define P2_NAND_RB_GPIO_PIN 62
  131. static int nand_dev_ready(struct nand_chip *chip)
  132. {
  133. return gpio_get_value(P2_NAND_RB_GPIO_PIN);
  134. }
  135. static struct platform_nand_data nand_data = {
  136. .chip = {
  137. .nr_chips = 1,
  138. .chip_offset = 0,
  139. .options = NAND_SAMSUNG_LP_OPTIONS,
  140. },
  141. .ctrl = {
  142. .cmd_ctrl = omap1_nand_cmd_ctl,
  143. .dev_ready = nand_dev_ready,
  144. },
  145. };
  146. static struct resource nand_resource = {
  147. .start = OMAP_CS3_PHYS,
  148. .end = OMAP_CS3_PHYS + SZ_4K - 1,
  149. .flags = IORESOURCE_MEM,
  150. };
  151. static struct platform_device nand_device = {
  152. .name = "gen_nand",
  153. .id = 0,
  154. .dev = {
  155. .platform_data = &nand_data,
  156. },
  157. .num_resources = 1,
  158. .resource = &nand_resource,
  159. };
  160. static struct platform_device smc91x_device = {
  161. .name = "smc91x",
  162. .id = 0,
  163. .dev = {
  164. .platform_data = &smc91x_info,
  165. },
  166. .num_resources = ARRAY_SIZE(smc91x_resources),
  167. .resource = smc91x_resources,
  168. };
  169. static struct resource kp_resources[] = {
  170. [0] = {
  171. .start = INT_7XX_MPUIO_KEYPAD,
  172. .end = INT_7XX_MPUIO_KEYPAD,
  173. .flags = IORESOURCE_IRQ,
  174. },
  175. };
  176. static const struct matrix_keymap_data p2_keymap_data = {
  177. .keymap = p2_keymap,
  178. .keymap_size = ARRAY_SIZE(p2_keymap),
  179. };
  180. static struct omap_kp_platform_data kp_data = {
  181. .rows = 8,
  182. .cols = 8,
  183. .keymap_data = &p2_keymap_data,
  184. .delay = 4,
  185. .dbounce = true,
  186. };
  187. static struct platform_device kp_device = {
  188. .name = "omap-keypad",
  189. .id = -1,
  190. .dev = {
  191. .platform_data = &kp_data,
  192. },
  193. .num_resources = ARRAY_SIZE(kp_resources),
  194. .resource = kp_resources,
  195. };
  196. static struct platform_device *devices[] __initdata = {
  197. &nor_device,
  198. &nand_device,
  199. &smc91x_device,
  200. &kp_device,
  201. };
  202. static const struct omap_lcd_config perseus2_lcd_config __initconst = {
  203. .ctrl_name = "internal",
  204. };
  205. static void __init perseus2_init_smc91x(void)
  206. {
  207. __raw_writeb(1, H2P2_DBG_FPGA_LAN_RESET);
  208. mdelay(50);
  209. __raw_writeb(__raw_readb(H2P2_DBG_FPGA_LAN_RESET) & ~1,
  210. H2P2_DBG_FPGA_LAN_RESET);
  211. mdelay(50);
  212. }
  213. static void __init omap_perseus2_init(void)
  214. {
  215. /* Early, board-dependent init */
  216. /*
  217. * Hold GSM Reset until needed
  218. */
  219. omap_writew(omap_readw(OMAP7XX_DSP_M_CTL) & ~1, OMAP7XX_DSP_M_CTL);
  220. /*
  221. * UARTs -> done automagically by 8250 driver
  222. */
  223. /*
  224. * CSx timings, GPIO Mux ... setup
  225. */
  226. /* Flash: CS0 timings setup */
  227. omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_0);
  228. omap_writel(0x00000088, OMAP7XX_FLASH_ACFG_0);
  229. /*
  230. * Ethernet support through the debug board
  231. * CS1 timings setup
  232. */
  233. omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_1);
  234. omap_writel(0x00000000, OMAP7XX_FLASH_ACFG_1);
  235. /*
  236. * Configure MPU_EXT_NIRQ IO in IO_CONF9 register,
  237. * It is used as the Ethernet controller interrupt
  238. */
  239. omap_writel(omap_readl(OMAP7XX_IO_CONF_9) & 0x1FFFFFFF,
  240. OMAP7XX_IO_CONF_9);
  241. perseus2_init_smc91x();
  242. BUG_ON(gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0);
  243. gpio_direction_input(P2_NAND_RB_GPIO_PIN);
  244. omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
  245. omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
  246. /* Mux pins for keypad */
  247. omap_cfg_reg(E2_7XX_KBR0);
  248. omap_cfg_reg(J7_7XX_KBR1);
  249. omap_cfg_reg(E1_7XX_KBR2);
  250. omap_cfg_reg(F3_7XX_KBR3);
  251. omap_cfg_reg(D2_7XX_KBR4);
  252. omap_cfg_reg(C2_7XX_KBC0);
  253. omap_cfg_reg(D3_7XX_KBC1);
  254. omap_cfg_reg(E4_7XX_KBC2);
  255. omap_cfg_reg(F4_7XX_KBC3);
  256. omap_cfg_reg(E3_7XX_KBC4);
  257. if (IS_ENABLED(CONFIG_SPI_OMAP_UWIRE)) {
  258. /* configure pins: MPU_UW_nSCS1, MPU_UW_SDO, MPU_UW_SCLK */
  259. int val = omap_readl(OMAP7XX_IO_CONF_9) & ~0x00EEE000;
  260. omap_writel(val | 0x00AAA000, OMAP7XX_IO_CONF_9);
  261. }
  262. platform_add_devices(devices, ARRAY_SIZE(devices));
  263. omap_serial_init();
  264. omap_register_i2c_bus(1, 100, NULL, 0);
  265. omapfb_set_lcd_config(&perseus2_lcd_config);
  266. }
  267. /* Only FPGA needs to be mapped here. All others are done with ioremap */
  268. static struct map_desc omap_perseus2_io_desc[] __initdata = {
  269. {
  270. .virtual = H2P2_DBG_FPGA_BASE,
  271. .pfn = __phys_to_pfn(H2P2_DBG_FPGA_START),
  272. .length = H2P2_DBG_FPGA_SIZE,
  273. .type = MT_DEVICE
  274. }
  275. };
  276. static void __init omap_perseus2_map_io(void)
  277. {
  278. omap7xx_map_io();
  279. iotable_init(omap_perseus2_io_desc,
  280. ARRAY_SIZE(omap_perseus2_io_desc));
  281. }
  282. MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2")
  283. /* Maintainer: Kevin Hilman <[email protected]> */
  284. .atag_offset = 0x100,
  285. .map_io = omap_perseus2_map_io,
  286. .init_early = omap1_init_early,
  287. .init_irq = omap1_init_irq,
  288. .handle_irq = omap1_handle_irq,
  289. .init_machine = omap_perseus2_init,
  290. .init_late = omap1_init_late,
  291. .init_time = omap1_timer_init,
  292. .restart = omap1_restart,
  293. MACHINE_END