dsmg600-setup.c 4.5 KB

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