dsmg600-setup.c 4.4 KB

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