nslu2-setup.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * arch/arm/mach-ixp4xx/nslu2-setup.c
  3. *
  4. * NSLU2 board-setup
  5. *
  6. * based ixdp425-setup.c:
  7. * Copyright (C) 2003-2004 MontaVista Software, Inc.
  8. *
  9. * Author: Mark Rakes <mrakes at mac.com>
  10. * Author: Rod Whitby <rod@whitby.id.au>
  11. * Maintainers: http://www.nslu2-linux.org/
  12. *
  13. * Fixed missing init_time in MACHINE_START kas11 10/22/04
  14. * Changed to conform to new style __init ixdp425 kas11 10/22/04
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/serial.h>
  18. #include <linux/serial_8250.h>
  19. #include <linux/leds.h>
  20. #include <linux/i2c-gpio.h>
  21. #include <asm/mach-types.h>
  22. #include <asm/mach/arch.h>
  23. #include <asm/mach/flash.h>
  24. #include <asm/mach/time.h>
  25. static struct flash_platform_data nslu2_flash_data = {
  26. .map_name = "cfi_probe",
  27. .width = 2,
  28. };
  29. static struct resource nslu2_flash_resource = {
  30. .flags = IORESOURCE_MEM,
  31. };
  32. static struct platform_device nslu2_flash = {
  33. .name = "IXP4XX-Flash",
  34. .id = 0,
  35. .dev.platform_data = &nslu2_flash_data,
  36. .num_resources = 1,
  37. .resource = &nslu2_flash_resource,
  38. };
  39. static struct i2c_gpio_platform_data nslu2_i2c_gpio_data = {
  40. .sda_pin = NSLU2_SDA_PIN,
  41. .scl_pin = NSLU2_SCL_PIN,
  42. };
  43. #ifdef CONFIG_LEDS_IXP4XX
  44. static struct resource nslu2_led_resources[] = {
  45. {
  46. .name = "ready", /* green led */
  47. .start = NSLU2_LED_GRN_GPIO,
  48. .end = NSLU2_LED_GRN_GPIO,
  49. .flags = IXP4XX_GPIO_HIGH,
  50. },
  51. {
  52. .name = "status", /* red led */
  53. .start = NSLU2_LED_RED_GPIO,
  54. .end = NSLU2_LED_RED_GPIO,
  55. .flags = IXP4XX_GPIO_HIGH,
  56. },
  57. {
  58. .name = "disk-1",
  59. .start = NSLU2_LED_DISK1_GPIO,
  60. .end = NSLU2_LED_DISK1_GPIO,
  61. .flags = IXP4XX_GPIO_LOW,
  62. },
  63. {
  64. .name = "disk-2",
  65. .start = NSLU2_LED_DISK2_GPIO,
  66. .end = NSLU2_LED_DISK2_GPIO,
  67. .flags = IXP4XX_GPIO_LOW,
  68. },
  69. };
  70. static struct platform_device nslu2_leds = {
  71. .name = "IXP4XX-GPIO-LED",
  72. .id = -1,
  73. .num_resources = ARRAY_SIZE(nslu2_led_resources),
  74. .resource = nslu2_led_resources,
  75. };
  76. #endif
  77. static struct platform_device nslu2_i2c_gpio = {
  78. .name = "i2c-gpio",
  79. .id = 0,
  80. .dev = {
  81. .platform_data = &nslu2_i2c_gpio_data,
  82. },
  83. };
  84. static struct platform_device nslu2_beeper = {
  85. .name = "ixp4xx-beeper",
  86. .id = NSLU2_GPIO_BUZZ,
  87. .num_resources = 0,
  88. };
  89. static struct resource nslu2_uart_resources[] = {
  90. {
  91. .start = IXP4XX_UART1_BASE_PHYS,
  92. .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
  93. .flags = IORESOURCE_MEM,
  94. },
  95. {
  96. .start = IXP4XX_UART2_BASE_PHYS,
  97. .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
  98. .flags = IORESOURCE_MEM,
  99. }
  100. };
  101. static struct plat_serial8250_port nslu2_uart_data[] = {
  102. {
  103. .mapbase = IXP4XX_UART1_BASE_PHYS,
  104. .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
  105. .irq = IRQ_IXP4XX_UART1,
  106. .flags = UPF_BOOT_AUTOCONF,
  107. .iotype = UPIO_MEM,
  108. .regshift = 2,
  109. .uartclk = IXP4XX_UART_XTAL,
  110. },
  111. {
  112. .mapbase = IXP4XX_UART2_BASE_PHYS,
  113. .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
  114. .irq = IRQ_IXP4XX_UART2,
  115. .flags = UPF_BOOT_AUTOCONF,
  116. .iotype = UPIO_MEM,
  117. .regshift = 2,
  118. .uartclk = IXP4XX_UART_XTAL,
  119. },
  120. { }
  121. };
  122. static struct platform_device nslu2_uart = {
  123. .name = "serial8250",
  124. .id = PLAT8250_DEV_PLATFORM,
  125. .dev.platform_data = nslu2_uart_data,
  126. .num_resources = 2,
  127. .resource = nslu2_uart_resources,
  128. };
  129. static struct platform_device *nslu2_devices[] __initdata = {
  130. &nslu2_i2c_gpio,
  131. &nslu2_flash,
  132. &nslu2_beeper,
  133. #ifdef CONFIG_LEDS_IXP4XX
  134. &nslu2_leds,
  135. #endif
  136. };
  137. static void nslu2_power_off(void)
  138. {
  139. /* This causes the box to drop the power and go dead. */
  140. /* enable the pwr cntl gpio */
  141. gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT);
  142. /* do the deed */
  143. gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
  144. }
  145. static void __init nslu2_timer_init(void)
  146. {
  147. /* The xtal on this machine is non-standard. */
  148. ixp4xx_timer_freq = NSLU2_FREQ;
  149. /* Call standard timer_init function. */
  150. ixp4xx_timer_init();
  151. }
  152. static struct sys_timer nslu2_timer = {
  153. .init = nslu2_timer_init,
  154. };
  155. static void __init nslu2_init(void)
  156. {
  157. ixp4xx_sys_init();
  158. nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
  159. nslu2_flash_resource.end =
  160. IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
  161. pm_power_off = nslu2_power_off;
  162. /*
  163. * This is only useful on a modified machine, but it is valuable
  164. * to have it first in order to see debug messages, and so that
  165. * it does *not* get removed if platform_add_devices fails!
  166. */
  167. (void)platform_device_register(&nslu2_uart);
  168. platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
  169. }
  170. MACHINE_START(NSLU2, "Linksys NSLU2")
  171. /* Maintainer: www.nslu2-linux.org */
  172. .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
  173. .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
  174. .boot_params = 0x00000100,
  175. .map_io = ixp4xx_map_io,
  176. .init_irq = ixp4xx_init_irq,
  177. .timer = &nslu2_timer,
  178. .init_machine = nslu2_init,
  179. MACHINE_END