nslu2-setup.c 4.7 KB

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