ixdp425-setup.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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/slab.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 <asm/types.h>
  22. #include <asm/setup.h>
  23. #include <asm/memory.h>
  24. #include <asm/hardware.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/flash.h>
  29. #include <asm/delay.h>
  30. static struct flash_platform_data ixdp425_flash_data = {
  31. .map_name = "cfi_probe",
  32. .width = 2,
  33. };
  34. static struct resource ixdp425_flash_resource = {
  35. .flags = IORESOURCE_MEM,
  36. };
  37. static struct platform_device ixdp425_flash = {
  38. .name = "IXP4XX-Flash",
  39. .id = 0,
  40. .dev = {
  41. .platform_data = &ixdp425_flash_data,
  42. },
  43. .num_resources = 1,
  44. .resource = &ixdp425_flash_resource,
  45. };
  46. #if defined(CONFIG_MTD_NAND_PLATFORM) || \
  47. defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  48. #ifdef CONFIG_MTD_PARTITIONS
  49. const char *part_probes[] = { "cmdlinepart", NULL };
  50. static struct mtd_partition ixdp425_partitions[] = {
  51. {
  52. .name = "ixp400 NAND FS 0",
  53. .offset = 0,
  54. .size = SZ_8M
  55. }, {
  56. .name = "ixp400 NAND FS 1",
  57. .offset = MTDPART_OFS_APPEND,
  58. .size = MTDPART_SIZ_FULL
  59. },
  60. };
  61. #endif
  62. static void
  63. ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  64. {
  65. struct nand_chip *this = mtd->priv;
  66. int offset = (int)this->priv;
  67. if (ctrl & NAND_CTRL_CHANGE) {
  68. if (ctrl & NAND_NCE) {
  69. gpio_line_set(IXDP425_NAND_NCE_PIN, IXP4XX_GPIO_LOW);
  70. udelay(5);
  71. } else
  72. gpio_line_set(IXDP425_NAND_NCE_PIN, IXP4XX_GPIO_HIGH);
  73. offset = (ctrl & NAND_CLE) ? IXDP425_NAND_CMD_BYTE : 0;
  74. offset |= (ctrl & NAND_ALE) ? IXDP425_NAND_ADDR_BYTE : 0;
  75. this->priv = (void *)offset;
  76. }
  77. if (cmd != NAND_CMD_NONE)
  78. writeb(cmd, this->IO_ADDR_W + offset);
  79. }
  80. static struct platform_nand_data ixdp425_flash_nand_data = {
  81. .chip = {
  82. .chip_delay = 30,
  83. .options = NAND_NO_AUTOINCR,
  84. #ifdef CONFIG_MTD_PARTITIONS
  85. .part_probe_types = part_probes,
  86. .partitions = ixdp425_partitions,
  87. .nr_partitions = ARRAY_SIZE(ixdp425_partitions),
  88. #endif
  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 ixp4xx_i2c_pins ixdp425_i2c_gpio_pins = {
  108. .sda_pin = IXDP425_SDA_PIN,
  109. .scl_pin = IXDP425_SCL_PIN,
  110. };
  111. static struct platform_device ixdp425_i2c_controller = {
  112. .name = "IXP4XX-I2C",
  113. .id = 0,
  114. .dev = {
  115. .platform_data = &ixdp425_i2c_gpio_pins,
  116. },
  117. .num_resources = 0
  118. };
  119. static struct resource ixdp425_uart_resources[] = {
  120. {
  121. .start = IXP4XX_UART1_BASE_PHYS,
  122. .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
  123. .flags = IORESOURCE_MEM
  124. },
  125. {
  126. .start = IXP4XX_UART2_BASE_PHYS,
  127. .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
  128. .flags = IORESOURCE_MEM
  129. }
  130. };
  131. static struct plat_serial8250_port ixdp425_uart_data[] = {
  132. {
  133. .mapbase = IXP4XX_UART1_BASE_PHYS,
  134. .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
  135. .irq = IRQ_IXP4XX_UART1,
  136. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  137. .iotype = UPIO_MEM,
  138. .regshift = 2,
  139. .uartclk = IXP4XX_UART_XTAL,
  140. },
  141. {
  142. .mapbase = IXP4XX_UART2_BASE_PHYS,
  143. .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
  144. .irq = IRQ_IXP4XX_UART2,
  145. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  146. .iotype = UPIO_MEM,
  147. .regshift = 2,
  148. .uartclk = IXP4XX_UART_XTAL,
  149. },
  150. { },
  151. };
  152. static struct platform_device ixdp425_uart = {
  153. .name = "serial8250",
  154. .id = PLAT8250_DEV_PLATFORM,
  155. .dev.platform_data = ixdp425_uart_data,
  156. .num_resources = 2,
  157. .resource = ixdp425_uart_resources
  158. };
  159. static struct platform_device *ixdp425_devices[] __initdata = {
  160. &ixdp425_i2c_controller,
  161. &ixdp425_flash,
  162. #if defined(CONFIG_MTD_NAND_PLATFORM) || \
  163. defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  164. &ixdp425_flash_nand,
  165. #endif
  166. &ixdp425_uart
  167. };
  168. static void __init ixdp425_init(void)
  169. {
  170. ixp4xx_sys_init();
  171. ixdp425_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
  172. ixdp425_flash_resource.end =
  173. IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
  174. #if defined(CONFIG_MTD_NAND_PLATFORM) || \
  175. defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  176. ixdp425_flash_nand_resource.start = IXP4XX_EXP_BUS_BASE(3),
  177. ixdp425_flash_nand_resource.end = IXP4XX_EXP_BUS_BASE(3) + 0x10 - 1;
  178. gpio_line_config(IXDP425_NAND_NCE_PIN, IXP4XX_GPIO_OUT);
  179. /* Configure expansion bus for NAND Flash */
  180. *IXP4XX_EXP_CS3 = IXP4XX_EXP_BUS_CS_EN |
  181. IXP4XX_EXP_BUS_STROBE_T(1) | /* extend by 1 clock */
  182. IXP4XX_EXP_BUS_CYCLES(0) | /* Intel cycles */
  183. IXP4XX_EXP_BUS_SIZE(0) | /* 512bytes addr space*/
  184. IXP4XX_EXP_BUS_WR_EN |
  185. IXP4XX_EXP_BUS_BYTE_EN; /* 8 bit data bus */
  186. #endif
  187. if (cpu_is_ixp43x()) {
  188. ixdp425_uart.num_resources = 1;
  189. ixdp425_uart_data[1].flags = 0;
  190. }
  191. platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
  192. }
  193. #ifdef CONFIG_ARCH_IXDP425
  194. MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
  195. /* Maintainer: MontaVista Software, Inc. */
  196. .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
  197. .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
  198. .map_io = ixp4xx_map_io,
  199. .init_irq = ixp4xx_init_irq,
  200. .timer = &ixp4xx_timer,
  201. .boot_params = 0x0100,
  202. .init_machine = ixdp425_init,
  203. MACHINE_END
  204. #endif
  205. #ifdef CONFIG_MACH_IXDP465
  206. MACHINE_START(IXDP465, "Intel IXDP465 Development Platform")
  207. /* Maintainer: MontaVista Software, Inc. */
  208. .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
  209. .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
  210. .map_io = ixp4xx_map_io,
  211. .init_irq = ixp4xx_init_irq,
  212. .timer = &ixp4xx_timer,
  213. .boot_params = 0x0100,
  214. .init_machine = ixdp425_init,
  215. MACHINE_END
  216. #endif
  217. #ifdef CONFIG_ARCH_PRPMC1100
  218. MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform")
  219. /* Maintainer: MontaVista Software, Inc. */
  220. .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
  221. .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
  222. .map_io = ixp4xx_map_io,
  223. .init_irq = ixp4xx_init_irq,
  224. .timer = &ixp4xx_timer,
  225. .boot_params = 0x0100,
  226. .init_machine = ixdp425_init,
  227. MACHINE_END
  228. #endif
  229. #ifdef CONFIG_MACH_KIXRP435
  230. MACHINE_START(KIXRP435, "Intel KIXRP435 Reference Platform")
  231. /* Maintainer: MontaVista Software, Inc. */
  232. .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
  233. .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
  234. .map_io = ixp4xx_map_io,
  235. .init_irq = ixp4xx_init_irq,
  236. .timer = &ixp4xx_timer,
  237. .boot_params = 0x0100,
  238. .init_machine = ixdp425_init,
  239. MACHINE_END
  240. #endif