ixdp425-setup.c 7.2 KB

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