nslu2-setup.c 4.7 KB

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