dns323-setup.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. /*
  2. * arch/arm/mach-orion5x/dns323-setup.c
  3. *
  4. * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as
  8. * published by the Free Software Foundation; either version 2 of the
  9. * License, or (at your option) any later version.
  10. *
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/pci.h>
  16. #include <linux/irq.h>
  17. #include <linux/mtd/physmap.h>
  18. #include <linux/mv643xx_eth.h>
  19. #include <linux/leds.h>
  20. #include <linux/gpio_keys.h>
  21. #include <linux/input.h>
  22. #include <linux/i2c.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/gpio.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/pci.h>
  27. #include <mach/orion5x.h>
  28. #include "common.h"
  29. #include "mpp.h"
  30. #define DNS323_GPIO_LED_RIGHT_AMBER 1
  31. #define DNS323_GPIO_LED_LEFT_AMBER 2
  32. #define DNS323_GPIO_LED_POWER 5
  33. #define DNS323_GPIO_OVERTEMP 6
  34. #define DNS323_GPIO_RTC 7
  35. #define DNS323_GPIO_POWER_OFF 8
  36. #define DNS323_GPIO_KEY_POWER 9
  37. #define DNS323_GPIO_KEY_RESET 10
  38. /****************************************************************************
  39. * PCI setup
  40. */
  41. static int __init dns323_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  42. {
  43. int irq;
  44. /*
  45. * Check for devices with hard-wired IRQs.
  46. */
  47. irq = orion5x_pci_map_irq(dev, slot, pin);
  48. if (irq != -1)
  49. return irq;
  50. return -1;
  51. }
  52. static struct hw_pci dns323_pci __initdata = {
  53. .nr_controllers = 2,
  54. .swizzle = pci_std_swizzle,
  55. .setup = orion5x_pci_sys_setup,
  56. .scan = orion5x_pci_sys_scan_bus,
  57. .map_irq = dns323_pci_map_irq,
  58. };
  59. static int __init dns323_pci_init(void)
  60. {
  61. if (machine_is_dns323())
  62. pci_common_init(&dns323_pci);
  63. return 0;
  64. }
  65. subsys_initcall(dns323_pci_init);
  66. /****************************************************************************
  67. * Ethernet
  68. */
  69. static struct mv643xx_eth_platform_data dns323_eth_data = {
  70. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  71. };
  72. /****************************************************************************
  73. * 8MiB NOR flash (Spansion S29GL064M90TFIR4)
  74. *
  75. * Layout as used by D-Link:
  76. * 0x00000000-0x00010000 : "MTD1"
  77. * 0x00010000-0x00020000 : "MTD2"
  78. * 0x00020000-0x001a0000 : "Linux Kernel"
  79. * 0x001a0000-0x007d0000 : "File System"
  80. * 0x007d0000-0x00800000 : "u-boot"
  81. */
  82. #define DNS323_NOR_BOOT_BASE 0xf4000000
  83. #define DNS323_NOR_BOOT_SIZE SZ_8M
  84. static struct mtd_partition dns323_partitions[] = {
  85. {
  86. .name = "MTD1",
  87. .size = 0x00010000,
  88. .offset = 0,
  89. }, {
  90. .name = "MTD2",
  91. .size = 0x00010000,
  92. .offset = 0x00010000,
  93. }, {
  94. .name = "Linux Kernel",
  95. .size = 0x00180000,
  96. .offset = 0x00020000,
  97. }, {
  98. .name = "File System",
  99. .size = 0x00630000,
  100. .offset = 0x001A0000,
  101. }, {
  102. .name = "u-boot",
  103. .size = 0x00030000,
  104. .offset = 0x007d0000,
  105. },
  106. };
  107. static struct physmap_flash_data dns323_nor_flash_data = {
  108. .width = 1,
  109. .parts = dns323_partitions,
  110. .nr_parts = ARRAY_SIZE(dns323_partitions)
  111. };
  112. static struct resource dns323_nor_flash_resource = {
  113. .flags = IORESOURCE_MEM,
  114. .start = DNS323_NOR_BOOT_BASE,
  115. .end = DNS323_NOR_BOOT_BASE + DNS323_NOR_BOOT_SIZE - 1,
  116. };
  117. static struct platform_device dns323_nor_flash = {
  118. .name = "physmap-flash",
  119. .id = 0,
  120. .dev = {
  121. .platform_data = &dns323_nor_flash_data,
  122. },
  123. .resource = &dns323_nor_flash_resource,
  124. .num_resources = 1,
  125. };
  126. /****************************************************************************
  127. * GPIO LEDs (simple - doesn't use hardware blinking support)
  128. */
  129. static struct gpio_led dns323_leds[] = {
  130. {
  131. .name = "power:blue",
  132. .gpio = DNS323_GPIO_LED_POWER,
  133. .active_low = 1,
  134. }, {
  135. .name = "right:amber",
  136. .gpio = DNS323_GPIO_LED_RIGHT_AMBER,
  137. .active_low = 1,
  138. }, {
  139. .name = "left:amber",
  140. .gpio = DNS323_GPIO_LED_LEFT_AMBER,
  141. .active_low = 1,
  142. },
  143. };
  144. static struct gpio_led_platform_data dns323_led_data = {
  145. .num_leds = ARRAY_SIZE(dns323_leds),
  146. .leds = dns323_leds,
  147. };
  148. static struct platform_device dns323_gpio_leds = {
  149. .name = "leds-gpio",
  150. .id = -1,
  151. .dev = {
  152. .platform_data = &dns323_led_data,
  153. },
  154. };
  155. /****************************************************************************
  156. * GPIO Attached Keys
  157. */
  158. static struct gpio_keys_button dns323_buttons[] = {
  159. {
  160. .code = KEY_RESTART,
  161. .gpio = DNS323_GPIO_KEY_RESET,
  162. .desc = "Reset Button",
  163. .active_low = 1,
  164. }, {
  165. .code = KEY_POWER,
  166. .gpio = DNS323_GPIO_KEY_POWER,
  167. .desc = "Power Button",
  168. .active_low = 1,
  169. },
  170. };
  171. static struct gpio_keys_platform_data dns323_button_data = {
  172. .buttons = dns323_buttons,
  173. .nbuttons = ARRAY_SIZE(dns323_buttons),
  174. };
  175. static struct platform_device dns323_button_device = {
  176. .name = "gpio-keys",
  177. .id = -1,
  178. .num_resources = 0,
  179. .dev = {
  180. .platform_data = &dns323_button_data,
  181. },
  182. };
  183. /****************************************************************************
  184. * General Setup
  185. */
  186. static struct orion5x_mpp_mode dns323_mpp_modes[] __initdata = {
  187. { 0, MPP_PCIE_RST_OUTn },
  188. { 1, MPP_GPIO }, /* right amber LED (sata ch0) */
  189. { 2, MPP_GPIO }, /* left amber LED (sata ch1) */
  190. { 3, MPP_UNUSED },
  191. { 4, MPP_GPIO }, /* power button LED */
  192. { 5, MPP_GPIO }, /* power button LED */
  193. { 6, MPP_GPIO }, /* GMT G751-2f overtemp */
  194. { 7, MPP_GPIO }, /* M41T80 nIRQ/OUT/SQW */
  195. { 8, MPP_GPIO }, /* triggers power off */
  196. { 9, MPP_GPIO }, /* power button switch */
  197. { 10, MPP_GPIO }, /* reset button switch */
  198. { 11, MPP_UNUSED },
  199. { 12, MPP_UNUSED },
  200. { 13, MPP_UNUSED },
  201. { 14, MPP_UNUSED },
  202. { 15, MPP_UNUSED },
  203. { 16, MPP_UNUSED },
  204. { 17, MPP_UNUSED },
  205. { 18, MPP_UNUSED },
  206. { 19, MPP_UNUSED },
  207. { -1 },
  208. };
  209. /*
  210. * On the DNS-323 the following devices are attached via I2C:
  211. *
  212. * i2c addr | chip | description
  213. * 0x3e | GMT G760Af | fan speed PWM controller
  214. * 0x48 | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible)
  215. * 0x68 | ST M41T80 | RTC w/ alarm
  216. */
  217. static struct i2c_board_info __initdata dns323_i2c_devices[] = {
  218. {
  219. I2C_BOARD_INFO("g760a", 0x3e),
  220. }, {
  221. I2C_BOARD_INFO("lm75", 0x48),
  222. }, {
  223. I2C_BOARD_INFO("m41t80", 0x68),
  224. },
  225. };
  226. /* DNS-323 specific power off method */
  227. static void dns323_power_off(void)
  228. {
  229. pr_info("%s: triggering power-off...\n", __func__);
  230. gpio_set_value(DNS323_GPIO_POWER_OFF, 1);
  231. }
  232. static void __init dns323_init(void)
  233. {
  234. /* Setup basic Orion functions. Need to be called early. */
  235. orion5x_init();
  236. orion5x_mpp_conf(dns323_mpp_modes);
  237. writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */
  238. /*
  239. * Configure peripherals.
  240. */
  241. orion5x_ehci0_init();
  242. orion5x_eth_init(&dns323_eth_data);
  243. orion5x_i2c_init();
  244. orion5x_uart0_init();
  245. /* setup flash mapping
  246. * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
  247. */
  248. orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE, DNS323_NOR_BOOT_SIZE);
  249. platform_device_register(&dns323_nor_flash);
  250. platform_device_register(&dns323_gpio_leds);
  251. platform_device_register(&dns323_button_device);
  252. i2c_register_board_info(0, dns323_i2c_devices,
  253. ARRAY_SIZE(dns323_i2c_devices));
  254. /* register dns323 specific power-off method */
  255. if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
  256. gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
  257. pr_err("DNS323: failed to setup power-off GPIO\n");
  258. pm_power_off = dns323_power_off;
  259. }
  260. /* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */
  261. MACHINE_START(DNS323, "D-Link DNS-323")
  262. /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
  263. .phys_io = ORION5X_REGS_PHYS_BASE,
  264. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  265. .boot_params = 0x00000100,
  266. .init_machine = dns323_init,
  267. .map_io = orion5x_map_io,
  268. .init_irq = orion5x_init_irq,
  269. .timer = &orion5x_timer,
  270. .fixup = tag_fixup_mem32,
  271. MACHINE_END