ixdp425-setup.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * arch/arm/mach-ixp4xx/ixdp425-setup.c
  4. *
  5. * IXDP425/IXCDP1100 board-setup
  6. *
  7. * Copyright (C) 2003-2005 MontaVista Software, Inc.
  8. *
  9. * Author: Deepak Saxena <dsaxena@plexity.net>
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/device.h>
  14. #include <linux/serial.h>
  15. #include <linux/tty.h>
  16. #include <linux/serial_8250.h>
  17. #include <linux/gpio/machine.h>
  18. #include <linux/io.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/rawnand.h>
  21. #include <linux/mtd/partitions.h>
  22. #include <linux/delay.h>
  23. #include <linux/gpio.h>
  24. #include <asm/types.h>
  25. #include <asm/setup.h>
  26. #include <asm/memory.h>
  27. #include <mach/hardware.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/irq.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/flash.h>
  32. #define IXDP425_SDA_PIN 7
  33. #define IXDP425_SCL_PIN 6
  34. /* NAND Flash pins */
  35. #define IXDP425_NAND_NCE_PIN 12
  36. #define IXDP425_NAND_CMD_BYTE 0x01
  37. #define IXDP425_NAND_ADDR_BYTE 0x02
  38. static struct flash_platform_data ixdp425_flash_data = {
  39. .map_name = "cfi_probe",
  40. .width = 2,
  41. };
  42. static struct resource ixdp425_flash_resource = {
  43. .flags = IORESOURCE_MEM,
  44. };
  45. static struct platform_device ixdp425_flash = {
  46. .name = "IXP4XX-Flash",
  47. .id = 0,
  48. .dev = {
  49. .platform_data = &ixdp425_flash_data,
  50. },
  51. .num_resources = 1,
  52. .resource = &ixdp425_flash_resource,
  53. };
  54. #if defined(CONFIG_MTD_NAND_PLATFORM) || \
  55. defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  56. static struct mtd_partition ixdp425_partitions[] = {
  57. {
  58. .name = "ixp400 NAND FS 0",
  59. .offset = 0,
  60. .size = SZ_8M
  61. }, {
  62. .name = "ixp400 NAND FS 1",
  63. .offset = MTDPART_OFS_APPEND,
  64. .size = MTDPART_SIZ_FULL
  65. },
  66. };
  67. static void
  68. ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  69. {
  70. struct nand_chip *this = mtd_to_nand(mtd);
  71. int offset = (int)nand_get_controller_data(this);
  72. if (ctrl & NAND_CTRL_CHANGE) {
  73. if (ctrl & NAND_NCE) {
  74. gpio_set_value(IXDP425_NAND_NCE_PIN, 0);
  75. udelay(5);
  76. } else
  77. gpio_set_value(IXDP425_NAND_NCE_PIN, 1);
  78. offset = (ctrl & NAND_CLE) ? IXDP425_NAND_CMD_BYTE : 0;
  79. offset |= (ctrl & NAND_ALE) ? IXDP425_NAND_ADDR_BYTE : 0;
  80. nand_set_controller_data(this, (void *)offset);
  81. }
  82. if (cmd != NAND_CMD_NONE)
  83. writeb(cmd, this->IO_ADDR_W + offset);
  84. }
  85. static struct platform_nand_data ixdp425_flash_nand_data = {
  86. .chip = {
  87. .nr_chips = 1,
  88. .chip_delay = 30,
  89. .partitions = ixdp425_partitions,
  90. .nr_partitions = ARRAY_SIZE(ixdp425_partitions),
  91. },
  92. .ctrl = {
  93. .cmd_ctrl = ixdp425_flash_nand_cmd_ctrl
  94. }
  95. };
  96. static struct resource ixdp425_flash_nand_resource = {
  97. .flags = IORESOURCE_MEM,
  98. };
  99. static struct platform_device ixdp425_flash_nand = {
  100. .name = "gen_nand",
  101. .id = -1,
  102. .dev = {
  103. .platform_data = &ixdp425_flash_nand_data,
  104. },
  105. .num_resources = 1,
  106. .resource = &ixdp425_flash_nand_resource,
  107. };
  108. #endif /* CONFIG_MTD_NAND_PLATFORM */
  109. static struct gpiod_lookup_table ixdp425_i2c_gpiod_table = {
  110. .dev_id = "i2c-gpio.0",
  111. .table = {
  112. GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", IXDP425_SDA_PIN,
  113. NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
  114. GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", IXDP425_SCL_PIN,
  115. NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
  116. },
  117. };
  118. static struct platform_device ixdp425_i2c_gpio = {
  119. .name = "i2c-gpio",
  120. .id = 0,
  121. .dev = {
  122. .platform_data = NULL,
  123. },
  124. };
  125. static struct resource ixdp425_uart_resources[] = {
  126. {
  127. .start = IXP4XX_UART1_BASE_PHYS,
  128. .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
  129. .flags = IORESOURCE_MEM
  130. },
  131. {
  132. .start = IXP4XX_UART2_BASE_PHYS,
  133. .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
  134. .flags = IORESOURCE_MEM
  135. }
  136. };
  137. static struct plat_serial8250_port ixdp425_uart_data[] = {
  138. {
  139. .mapbase = IXP4XX_UART1_BASE_PHYS,
  140. .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
  141. .irq = IRQ_IXP4XX_UART1,
  142. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  143. .iotype = UPIO_MEM,
  144. .regshift = 2,
  145. .uartclk = IXP4XX_UART_XTAL,
  146. },
  147. {
  148. .mapbase = IXP4XX_UART2_BASE_PHYS,
  149. .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
  150. .irq = IRQ_IXP4XX_UART2,
  151. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  152. .iotype = UPIO_MEM,
  153. .regshift = 2,
  154. .uartclk = IXP4XX_UART_XTAL,
  155. },
  156. { },
  157. };
  158. static struct platform_device ixdp425_uart = {
  159. .name = "serial8250",
  160. .id = PLAT8250_DEV_PLATFORM,
  161. .dev.platform_data = ixdp425_uart_data,
  162. .num_resources = 2,
  163. .resource = ixdp425_uart_resources
  164. };
  165. /* Built-in 10/100 Ethernet MAC interfaces */
  166. static struct eth_plat_info ixdp425_plat_eth[] = {
  167. {
  168. .phy = 0,
  169. .rxq = 3,
  170. .txreadyq = 20,
  171. }, {
  172. .phy = 1,
  173. .rxq = 4,
  174. .txreadyq = 21,
  175. }
  176. };
  177. static struct platform_device ixdp425_eth[] = {
  178. {
  179. .name = "ixp4xx_eth",
  180. .id = IXP4XX_ETH_NPEB,
  181. .dev.platform_data = ixdp425_plat_eth,
  182. }, {
  183. .name = "ixp4xx_eth",
  184. .id = IXP4XX_ETH_NPEC,
  185. .dev.platform_data = ixdp425_plat_eth + 1,
  186. }
  187. };
  188. static struct platform_device *ixdp425_devices[] __initdata = {
  189. &ixdp425_i2c_gpio,
  190. &ixdp425_flash,
  191. #if defined(CONFIG_MTD_NAND_PLATFORM) || \
  192. defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  193. &ixdp425_flash_nand,
  194. #endif
  195. &ixdp425_uart,
  196. &ixdp425_eth[0],
  197. &ixdp425_eth[1],
  198. };
  199. static void __init ixdp425_init(void)
  200. {
  201. ixp4xx_sys_init();
  202. ixdp425_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
  203. ixdp425_flash_resource.end =
  204. IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
  205. #if defined(CONFIG_MTD_NAND_PLATFORM) || \
  206. defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  207. ixdp425_flash_nand_resource.start = IXP4XX_EXP_BUS_BASE(3),
  208. ixdp425_flash_nand_resource.end = IXP4XX_EXP_BUS_BASE(3) + 0x10 - 1;
  209. gpio_request(IXDP425_NAND_NCE_PIN, "NAND NCE pin");
  210. gpio_direction_output(IXDP425_NAND_NCE_PIN, 0);
  211. /* Configure expansion bus for NAND Flash */
  212. *IXP4XX_EXP_CS3 = IXP4XX_EXP_BUS_CS_EN |
  213. IXP4XX_EXP_BUS_STROBE_T(1) | /* extend by 1 clock */
  214. IXP4XX_EXP_BUS_CYCLES(0) | /* Intel cycles */
  215. IXP4XX_EXP_BUS_SIZE(0) | /* 512bytes addr space*/
  216. IXP4XX_EXP_BUS_WR_EN |
  217. IXP4XX_EXP_BUS_BYTE_EN; /* 8 bit data bus */
  218. #endif
  219. if (cpu_is_ixp43x()) {
  220. ixdp425_uart.num_resources = 1;
  221. ixdp425_uart_data[1].flags = 0;
  222. }
  223. gpiod_add_lookup_table(&ixdp425_i2c_gpiod_table);
  224. platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
  225. }
  226. #ifdef CONFIG_ARCH_IXDP425
  227. MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
  228. /* Maintainer: MontaVista Software, Inc. */
  229. .map_io = ixp4xx_map_io,
  230. .init_early = ixp4xx_init_early,
  231. .init_irq = ixp4xx_init_irq,
  232. .init_time = ixp4xx_timer_init,
  233. .atag_offset = 0x100,
  234. .init_machine = ixdp425_init,
  235. #if defined(CONFIG_PCI)
  236. .dma_zone_size = SZ_64M,
  237. #endif
  238. .restart = ixp4xx_restart,
  239. MACHINE_END
  240. #endif
  241. #ifdef CONFIG_MACH_IXDP465
  242. MACHINE_START(IXDP465, "Intel IXDP465 Development Platform")
  243. /* Maintainer: MontaVista Software, Inc. */
  244. .map_io = ixp4xx_map_io,
  245. .init_early = ixp4xx_init_early,
  246. .init_irq = ixp4xx_init_irq,
  247. .init_time = ixp4xx_timer_init,
  248. .atag_offset = 0x100,
  249. .init_machine = ixdp425_init,
  250. #if defined(CONFIG_PCI)
  251. .dma_zone_size = SZ_64M,
  252. #endif
  253. MACHINE_END
  254. #endif
  255. #ifdef CONFIG_ARCH_PRPMC1100
  256. MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform")
  257. /* Maintainer: MontaVista Software, Inc. */
  258. .map_io = ixp4xx_map_io,
  259. .init_early = ixp4xx_init_early,
  260. .init_irq = ixp4xx_init_irq,
  261. .init_time = ixp4xx_timer_init,
  262. .atag_offset = 0x100,
  263. .init_machine = ixdp425_init,
  264. #if defined(CONFIG_PCI)
  265. .dma_zone_size = SZ_64M,
  266. #endif
  267. MACHINE_END
  268. #endif
  269. #ifdef CONFIG_MACH_KIXRP435
  270. MACHINE_START(KIXRP435, "Intel KIXRP435 Reference Platform")
  271. /* Maintainer: MontaVista Software, Inc. */
  272. .map_io = ixp4xx_map_io,
  273. .init_early = ixp4xx_init_early,
  274. .init_irq = ixp4xx_init_irq,
  275. .init_time = ixp4xx_timer_init,
  276. .atag_offset = 0x100,
  277. .init_machine = ixdp425_init,
  278. #if defined(CONFIG_PCI)
  279. .dma_zone_size = SZ_64M,
  280. #endif
  281. MACHINE_END
  282. #endif