nslu2-setup.c 4.4 KB

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