dsmg600-setup.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * DSM-G600 board-setup
  3. *
  4. * Copyright (C) 2006 Tower Technologies
  5. * Author: Alessandro Zummo <a.zummo@towertech.it>
  6. *
  7. * based ixdp425-setup.c:
  8. * Copyright (C) 2003-2004 MontaVista Software, Inc.
  9. *
  10. * Author: Alessandro Zummo <a.zummo@towertech.it>
  11. * Maintainers: http://www.nslu2-linux.org/
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/serial.h>
  15. #include <linux/serial_8250.h>
  16. #include <linux/leds.h>
  17. #include <linux/i2c.h>
  18. #include <linux/i2c-gpio.h>
  19. #include <asm/mach-types.h>
  20. #include <asm/mach/arch.h>
  21. #include <asm/mach/flash.h>
  22. #include <asm/mach/time.h>
  23. static struct flash_platform_data dsmg600_flash_data = {
  24. .map_name = "cfi_probe",
  25. .width = 2,
  26. };
  27. static struct resource dsmg600_flash_resource = {
  28. .flags = IORESOURCE_MEM,
  29. };
  30. static struct platform_device dsmg600_flash = {
  31. .name = "IXP4XX-Flash",
  32. .id = 0,
  33. .dev.platform_data = &dsmg600_flash_data,
  34. .num_resources = 1,
  35. .resource = &dsmg600_flash_resource,
  36. };
  37. static struct i2c_gpio_platform_data dsmg600_i2c_gpio_data = {
  38. .sda_pin = DSMG600_SDA_PIN,
  39. .scl_pin = DSMG600_SCL_PIN,
  40. };
  41. static struct platform_device dsmg600_i2c_gpio = {
  42. .name = "i2c-gpio",
  43. .id = 0,
  44. .dev = {
  45. .platform_data = &dsmg600_i2c_gpio_data,
  46. },
  47. };
  48. static struct i2c_board_info __initdata dsmg600_i2c_board_info [] = {
  49. {
  50. I2C_BOARD_INFO("rtc-pcf8563", 0x51),
  51. },
  52. };
  53. static struct gpio_led dsmg600_led_pins[] = {
  54. {
  55. .name = "power",
  56. .gpio = DSMG600_LED_PWR_GPIO,
  57. },
  58. {
  59. .name = "wlan",
  60. .gpio = DSMG600_LED_WLAN_GPIO,
  61. .active_low = true,
  62. },
  63. };
  64. static struct gpio_led_platform_data dsmg600_led_data = {
  65. .num_leds = ARRAY_SIZE(dsmg600_led_pins),
  66. .leds = dsmg600_led_pins,
  67. };
  68. static struct platform_device dsmg600_leds = {
  69. .name = "leds-gpio",
  70. .id = -1,
  71. .dev.platform_data = &dsmg600_led_data,
  72. };
  73. static struct resource dsmg600_uart_resources[] = {
  74. {
  75. .start = IXP4XX_UART1_BASE_PHYS,
  76. .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
  77. .flags = IORESOURCE_MEM,
  78. },
  79. {
  80. .start = IXP4XX_UART2_BASE_PHYS,
  81. .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
  82. .flags = IORESOURCE_MEM,
  83. }
  84. };
  85. static struct plat_serial8250_port dsmg600_uart_data[] = {
  86. {
  87. .mapbase = IXP4XX_UART1_BASE_PHYS,
  88. .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
  89. .irq = IRQ_IXP4XX_UART1,
  90. .flags = UPF_BOOT_AUTOCONF,
  91. .iotype = UPIO_MEM,
  92. .regshift = 2,
  93. .uartclk = IXP4XX_UART_XTAL,
  94. },
  95. {
  96. .mapbase = IXP4XX_UART2_BASE_PHYS,
  97. .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
  98. .irq = IRQ_IXP4XX_UART2,
  99. .flags = UPF_BOOT_AUTOCONF,
  100. .iotype = UPIO_MEM,
  101. .regshift = 2,
  102. .uartclk = IXP4XX_UART_XTAL,
  103. },
  104. { }
  105. };
  106. static struct platform_device dsmg600_uart = {
  107. .name = "serial8250",
  108. .id = PLAT8250_DEV_PLATFORM,
  109. .dev.platform_data = dsmg600_uart_data,
  110. .num_resources = ARRAY_SIZE(dsmg600_uart_resources),
  111. .resource = dsmg600_uart_resources,
  112. };
  113. static struct platform_device *dsmg600_devices[] __initdata = {
  114. &dsmg600_i2c_gpio,
  115. &dsmg600_flash,
  116. &dsmg600_leds,
  117. };
  118. static void dsmg600_power_off(void)
  119. {
  120. /* enable the pwr cntl gpio */
  121. gpio_line_config(DSMG600_PO_GPIO, IXP4XX_GPIO_OUT);
  122. /* poweroff */
  123. gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
  124. }
  125. static void __init dsmg600_timer_init(void)
  126. {
  127. /* The xtal on this machine is non-standard. */
  128. ixp4xx_timer_freq = DSMG600_FREQ;
  129. /* Call standard timer_init function. */
  130. ixp4xx_timer_init();
  131. }
  132. static struct sys_timer dsmg600_timer = {
  133. .init = dsmg600_timer_init,
  134. };
  135. static void __init dsmg600_init(void)
  136. {
  137. ixp4xx_sys_init();
  138. /* Make sure that GPIO14 and GPIO15 are not used as clocks */
  139. *IXP4XX_GPIO_GPCLKR = 0;
  140. dsmg600_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
  141. dsmg600_flash_resource.end =
  142. IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
  143. pm_power_off = dsmg600_power_off;
  144. i2c_register_board_info(0, dsmg600_i2c_board_info,
  145. ARRAY_SIZE(dsmg600_i2c_board_info));
  146. /* The UART is required on the DSM-G600 (Redboot cannot use the
  147. * NIC) -- do it here so that it does *not* get removed if
  148. * platform_add_devices fails!
  149. */
  150. (void)platform_device_register(&dsmg600_uart);
  151. platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
  152. }
  153. MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
  154. /* Maintainer: www.nslu2-linux.org */
  155. .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
  156. .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
  157. .boot_params = 0x00000100,
  158. .map_io = ixp4xx_map_io,
  159. .init_irq = ixp4xx_init_irq,
  160. .timer = &dsmg600_timer,
  161. .init_machine = dsmg600_init,
  162. MACHINE_END