dsmg600-setup.c 4.5 KB

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