dns323-setup.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. /*
  2. * arch/arm/mach-orion5x/dns323-setup.c
  3. *
  4. * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
  5. *
  6. * Support for HW Rev C1:
  7. *
  8. * Copyright (C) 2010 Benjamin Herrenschmidt <benh@kernel.crashing.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU Lesser General Public License as
  12. * published by the Free Software Foundation; either version 2 of the
  13. * License, or (at your option) any later version.
  14. *
  15. */
  16. #include <linux/gpio.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/delay.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/pci.h>
  22. #include <linux/irq.h>
  23. #include <linux/mtd/physmap.h>
  24. #include <linux/mv643xx_eth.h>
  25. #include <linux/leds.h>
  26. #include <linux/gpio_keys.h>
  27. #include <linux/input.h>
  28. #include <linux/i2c.h>
  29. #include <linux/ata_platform.h>
  30. #include <linux/phy.h>
  31. #include <linux/marvell_phy.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/pci.h>
  35. #include <asm/system_info.h>
  36. #include <plat/orion-gpio.h>
  37. #include "orion5x.h"
  38. #include "common.h"
  39. #include "mpp.h"
  40. /* Rev A1 and B1 */
  41. #define DNS323_GPIO_LED_RIGHT_AMBER 1
  42. #define DNS323_GPIO_LED_LEFT_AMBER 2
  43. #define DNS323_GPIO_SYSTEM_UP 3
  44. #define DNS323_GPIO_LED_POWER1 4
  45. #define DNS323_GPIO_LED_POWER2 5
  46. #define DNS323_GPIO_OVERTEMP 6
  47. #define DNS323_GPIO_RTC 7
  48. #define DNS323_GPIO_POWER_OFF 8
  49. #define DNS323_GPIO_KEY_POWER 9
  50. #define DNS323_GPIO_KEY_RESET 10
  51. /* Rev C1 */
  52. #define DNS323C_GPIO_KEY_POWER 1
  53. #define DNS323C_GPIO_POWER_OFF 2
  54. #define DNS323C_GPIO_LED_RIGHT_AMBER 8
  55. #define DNS323C_GPIO_LED_LEFT_AMBER 9
  56. #define DNS323C_GPIO_LED_POWER 17
  57. #define DNS323C_GPIO_FAN_BIT1 18
  58. #define DNS323C_GPIO_FAN_BIT0 19
  59. /* Exposed to userspace, do not change */
  60. enum {
  61. DNS323_REV_A1, /* 0 */
  62. DNS323_REV_B1, /* 1 */
  63. DNS323_REV_C1, /* 2 */
  64. };
  65. /****************************************************************************
  66. * PCI setup
  67. */
  68. static int __init dns323_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  69. {
  70. int irq;
  71. /*
  72. * Check for devices with hard-wired IRQs.
  73. */
  74. irq = orion5x_pci_map_irq(dev, slot, pin);
  75. if (irq != -1)
  76. return irq;
  77. return -1;
  78. }
  79. static struct hw_pci dns323_pci __initdata = {
  80. .nr_controllers = 2,
  81. .setup = orion5x_pci_sys_setup,
  82. .scan = orion5x_pci_sys_scan_bus,
  83. .map_irq = dns323_pci_map_irq,
  84. };
  85. static int __init dns323_pci_init(void)
  86. {
  87. /* Rev B1 and C1 doesn't really use its PCI bus, and initialising PCI
  88. * gets in the way of initialising the SATA controller.
  89. */
  90. if (machine_is_dns323() && system_rev == DNS323_REV_A1)
  91. pci_common_init(&dns323_pci);
  92. return 0;
  93. }
  94. subsys_initcall(dns323_pci_init);
  95. /****************************************************************************
  96. * 8MiB NOR flash (Spansion S29GL064M90TFIR4)
  97. *
  98. * Layout as used by D-Link:
  99. * 0x00000000-0x00010000 : "MTD1"
  100. * 0x00010000-0x00020000 : "MTD2"
  101. * 0x00020000-0x001a0000 : "Linux Kernel"
  102. * 0x001a0000-0x007d0000 : "File System"
  103. * 0x007d0000-0x00800000 : "u-boot"
  104. */
  105. #define DNS323_NOR_BOOT_BASE 0xf4000000
  106. #define DNS323_NOR_BOOT_SIZE SZ_8M
  107. static struct mtd_partition dns323_partitions[] = {
  108. {
  109. .name = "MTD1",
  110. .size = 0x00010000,
  111. .offset = 0,
  112. }, {
  113. .name = "MTD2",
  114. .size = 0x00010000,
  115. .offset = 0x00010000,
  116. }, {
  117. .name = "Linux Kernel",
  118. .size = 0x00180000,
  119. .offset = 0x00020000,
  120. }, {
  121. .name = "File System",
  122. .size = 0x00630000,
  123. .offset = 0x001A0000,
  124. }, {
  125. .name = "u-boot",
  126. .size = 0x00030000,
  127. .offset = 0x007d0000,
  128. },
  129. };
  130. static struct physmap_flash_data dns323_nor_flash_data = {
  131. .width = 1,
  132. .parts = dns323_partitions,
  133. .nr_parts = ARRAY_SIZE(dns323_partitions)
  134. };
  135. static struct resource dns323_nor_flash_resource = {
  136. .flags = IORESOURCE_MEM,
  137. .start = DNS323_NOR_BOOT_BASE,
  138. .end = DNS323_NOR_BOOT_BASE + DNS323_NOR_BOOT_SIZE - 1,
  139. };
  140. static struct platform_device dns323_nor_flash = {
  141. .name = "physmap-flash",
  142. .id = 0,
  143. .dev = {
  144. .platform_data = &dns323_nor_flash_data,
  145. },
  146. .resource = &dns323_nor_flash_resource,
  147. .num_resources = 1,
  148. };
  149. /****************************************************************************
  150. * Ethernet
  151. */
  152. static struct mv643xx_eth_platform_data dns323_eth_data = {
  153. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  154. };
  155. static int __init dns323_read_mac_addr(void)
  156. {
  157. u_int8_t addr[6];
  158. void __iomem *mac_page;
  159. /* MAC address is stored as a regular ol' string in /dev/mtdblock4
  160. * (0x007d0000-0x00800000) starting at offset 196480 (0x2ff80).
  161. */
  162. mac_page = ioremap(DNS323_NOR_BOOT_BASE + 0x7d0000 + 196480, 1024);
  163. if (!mac_page)
  164. return -ENOMEM;
  165. if (!mac_pton((__force const char *) mac_page, addr))
  166. goto error_fail;
  167. iounmap(mac_page);
  168. printk("DNS-323: Found ethernet MAC address: %pM\n", addr);
  169. memcpy(dns323_eth_data.mac_addr, addr, 6);
  170. return 0;
  171. error_fail:
  172. iounmap(mac_page);
  173. return -EINVAL;
  174. }
  175. /****************************************************************************
  176. * GPIO LEDs (simple - doesn't use hardware blinking support)
  177. */
  178. static struct gpio_led dns323ab_leds[] = {
  179. {
  180. .name = "power:blue",
  181. .gpio = DNS323_GPIO_LED_POWER2,
  182. .default_trigger = "default-on",
  183. }, {
  184. .name = "right:amber",
  185. .gpio = DNS323_GPIO_LED_RIGHT_AMBER,
  186. .active_low = 1,
  187. }, {
  188. .name = "left:amber",
  189. .gpio = DNS323_GPIO_LED_LEFT_AMBER,
  190. .active_low = 1,
  191. },
  192. };
  193. static struct gpio_led dns323c_leds[] = {
  194. {
  195. .name = "power:blue",
  196. .gpio = DNS323C_GPIO_LED_POWER,
  197. .default_trigger = "timer",
  198. .active_low = 1,
  199. }, {
  200. .name = "right:amber",
  201. .gpio = DNS323C_GPIO_LED_RIGHT_AMBER,
  202. .active_low = 1,
  203. }, {
  204. .name = "left:amber",
  205. .gpio = DNS323C_GPIO_LED_LEFT_AMBER,
  206. .active_low = 1,
  207. },
  208. };
  209. static struct gpio_led_platform_data dns323ab_led_data = {
  210. .num_leds = ARRAY_SIZE(dns323ab_leds),
  211. .leds = dns323ab_leds,
  212. .gpio_blink_set = orion_gpio_led_blink_set,
  213. };
  214. static struct gpio_led_platform_data dns323c_led_data = {
  215. .num_leds = ARRAY_SIZE(dns323c_leds),
  216. .leds = dns323c_leds,
  217. .gpio_blink_set = orion_gpio_led_blink_set,
  218. };
  219. static struct platform_device dns323_gpio_leds = {
  220. .name = "leds-gpio",
  221. .id = -1,
  222. .dev = {
  223. .platform_data = &dns323ab_led_data,
  224. },
  225. };
  226. /****************************************************************************
  227. * GPIO Attached Keys
  228. */
  229. static struct gpio_keys_button dns323ab_buttons[] = {
  230. {
  231. .code = KEY_RESTART,
  232. .gpio = DNS323_GPIO_KEY_RESET,
  233. .desc = "Reset Button",
  234. .active_low = 1,
  235. }, {
  236. .code = KEY_POWER,
  237. .gpio = DNS323_GPIO_KEY_POWER,
  238. .desc = "Power Button",
  239. .active_low = 1,
  240. },
  241. };
  242. static struct gpio_keys_platform_data dns323ab_button_data = {
  243. .buttons = dns323ab_buttons,
  244. .nbuttons = ARRAY_SIZE(dns323ab_buttons),
  245. };
  246. static struct gpio_keys_button dns323c_buttons[] = {
  247. {
  248. .code = KEY_POWER,
  249. .gpio = DNS323C_GPIO_KEY_POWER,
  250. .desc = "Power Button",
  251. .active_low = 1,
  252. },
  253. };
  254. static struct gpio_keys_platform_data dns323c_button_data = {
  255. .buttons = dns323c_buttons,
  256. .nbuttons = ARRAY_SIZE(dns323c_buttons),
  257. };
  258. static struct platform_device dns323_button_device = {
  259. .name = "gpio-keys",
  260. .id = -1,
  261. .num_resources = 0,
  262. .dev = {
  263. .platform_data = &dns323ab_button_data,
  264. },
  265. };
  266. /*****************************************************************************
  267. * SATA
  268. */
  269. static struct mv_sata_platform_data dns323_sata_data = {
  270. .n_ports = 2,
  271. };
  272. /****************************************************************************
  273. * General Setup
  274. */
  275. static unsigned int dns323a_mpp_modes[] __initdata = {
  276. MPP0_PCIE_RST_OUTn,
  277. MPP1_GPIO, /* right amber LED (sata ch0) */
  278. MPP2_GPIO, /* left amber LED (sata ch1) */
  279. MPP3_UNUSED,
  280. MPP4_GPIO, /* power button LED */
  281. MPP5_GPIO, /* power button LED */
  282. MPP6_GPIO, /* GMT G751-2f overtemp */
  283. MPP7_GPIO, /* M41T80 nIRQ/OUT/SQW */
  284. MPP8_GPIO, /* triggers power off */
  285. MPP9_GPIO, /* power button switch */
  286. MPP10_GPIO, /* reset button switch */
  287. MPP11_UNUSED,
  288. MPP12_UNUSED,
  289. MPP13_UNUSED,
  290. MPP14_UNUSED,
  291. MPP15_UNUSED,
  292. MPP16_UNUSED,
  293. MPP17_UNUSED,
  294. MPP18_UNUSED,
  295. MPP19_UNUSED,
  296. 0,
  297. };
  298. static unsigned int dns323b_mpp_modes[] __initdata = {
  299. MPP0_UNUSED,
  300. MPP1_GPIO, /* right amber LED (sata ch0) */
  301. MPP2_GPIO, /* left amber LED (sata ch1) */
  302. MPP3_GPIO, /* system up flag */
  303. MPP4_GPIO, /* power button LED */
  304. MPP5_GPIO, /* power button LED */
  305. MPP6_GPIO, /* GMT G751-2f overtemp */
  306. MPP7_GPIO, /* M41T80 nIRQ/OUT/SQW */
  307. MPP8_GPIO, /* triggers power off */
  308. MPP9_GPIO, /* power button switch */
  309. MPP10_GPIO, /* reset button switch */
  310. MPP11_UNUSED,
  311. MPP12_SATA_LED,
  312. MPP13_SATA_LED,
  313. MPP14_SATA_LED,
  314. MPP15_SATA_LED,
  315. MPP16_UNUSED,
  316. MPP17_UNUSED,
  317. MPP18_UNUSED,
  318. MPP19_UNUSED,
  319. 0,
  320. };
  321. static unsigned int dns323c_mpp_modes[] __initdata = {
  322. MPP0_GPIO, /* ? input */
  323. MPP1_GPIO, /* input power switch (0 = pressed) */
  324. MPP2_GPIO, /* output power off */
  325. MPP3_UNUSED, /* ? output */
  326. MPP4_UNUSED, /* ? output */
  327. MPP5_UNUSED, /* ? output */
  328. MPP6_UNUSED, /* ? output */
  329. MPP7_UNUSED, /* ? output */
  330. MPP8_GPIO, /* i/o right amber LED */
  331. MPP9_GPIO, /* i/o left amber LED */
  332. MPP10_GPIO, /* input */
  333. MPP11_UNUSED,
  334. MPP12_SATA_LED,
  335. MPP13_SATA_LED,
  336. MPP14_SATA_LED,
  337. MPP15_SATA_LED,
  338. MPP16_UNUSED,
  339. MPP17_GPIO, /* power button LED */
  340. MPP18_GPIO, /* fan speed bit 0 */
  341. MPP19_GPIO, /* fan speed bit 1 */
  342. 0,
  343. };
  344. /* Rev C1 Fan speed notes:
  345. *
  346. * The fan is controlled by 2 GPIOs on this board. The settings
  347. * of the bits is as follow:
  348. *
  349. * GPIO 18 GPIO 19 Fan
  350. *
  351. * 0 0 stopped
  352. * 0 1 low speed
  353. * 1 0 high speed
  354. * 1 1 don't do that (*)
  355. *
  356. * (*) I think the two bits control two feed-in resistors into a fixed
  357. * PWN circuit, setting both bits will basically go a 'bit' faster
  358. * than high speed, but d-link doesn't do it and you may get out of
  359. * HW spec so don't do it.
  360. */
  361. /*
  362. * On the DNS-323 A1 and B1 the following devices are attached via I2C:
  363. *
  364. * i2c addr | chip | description
  365. * 0x3e | GMT G760Af | fan speed PWM controller
  366. * 0x48 | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible)
  367. * 0x68 | ST M41T80 | RTC w/ alarm
  368. */
  369. static struct i2c_board_info __initdata dns323ab_i2c_devices[] = {
  370. {
  371. I2C_BOARD_INFO("g760a", 0x3e),
  372. }, {
  373. I2C_BOARD_INFO("lm75", 0x48),
  374. }, {
  375. I2C_BOARD_INFO("m41t80", 0x68),
  376. },
  377. };
  378. /*
  379. * On the DNS-323 C1 the following devices are attached via I2C:
  380. *
  381. * i2c addr | chip | description
  382. * 0x48 | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible)
  383. * 0x68 | ST M41T80 | RTC w/ alarm
  384. */
  385. static struct i2c_board_info __initdata dns323c_i2c_devices[] = {
  386. {
  387. I2C_BOARD_INFO("lm75", 0x48),
  388. }, {
  389. I2C_BOARD_INFO("m41t80", 0x68),
  390. },
  391. };
  392. /* DNS-323 rev. A specific power off method */
  393. static void dns323a_power_off(void)
  394. {
  395. pr_info("DNS-323: Triggering power-off...\n");
  396. gpio_set_value(DNS323_GPIO_POWER_OFF, 1);
  397. }
  398. /* DNS-323 rev B specific power off method */
  399. static void dns323b_power_off(void)
  400. {
  401. pr_info("DNS-323: Triggering power-off...\n");
  402. /* Pin has to be changed to 1 and back to 0 to do actual power off. */
  403. gpio_set_value(DNS323_GPIO_POWER_OFF, 1);
  404. mdelay(100);
  405. gpio_set_value(DNS323_GPIO_POWER_OFF, 0);
  406. }
  407. /* DNS-323 rev. C specific power off method */
  408. static void dns323c_power_off(void)
  409. {
  410. pr_info("DNS-323: Triggering power-off...\n");
  411. gpio_set_value(DNS323C_GPIO_POWER_OFF, 1);
  412. }
  413. static int dns323c_phy_fixup(struct phy_device *phy)
  414. {
  415. phy->dev_flags |= MARVELL_PHY_M1118_DNS323_LEDS;
  416. return 0;
  417. }
  418. static int __init dns323_identify_rev(void)
  419. {
  420. u32 dev, rev, i, reg;
  421. pr_debug("DNS-323: Identifying board ... \n");
  422. /* Rev A1 has a 5181 */
  423. orion5x_pcie_id(&dev, &rev);
  424. if (dev == MV88F5181_DEV_ID) {
  425. pr_debug("DNS-323: 5181 found, board is A1\n");
  426. return DNS323_REV_A1;
  427. }
  428. pr_debug("DNS-323: 5182 found, board is B1 or C1, checking PHY...\n");
  429. /* Rev B1 and C1 both have 5182, let's poke at the eth PHY. This is
  430. * a bit gross but we want to do that without links into the eth
  431. * driver so let's poke at it directly. We default to rev B1 in
  432. * case the accesses fail
  433. */
  434. #define ETH_SMI_REG (ORION5X_ETH_VIRT_BASE + 0x2000 + 0x004)
  435. #define SMI_BUSY 0x10000000
  436. #define SMI_READ_VALID 0x08000000
  437. #define SMI_OPCODE_READ 0x04000000
  438. #define SMI_OPCODE_WRITE 0x00000000
  439. for (i = 0; i < 1000; i++) {
  440. reg = readl(ETH_SMI_REG);
  441. if (!(reg & SMI_BUSY))
  442. break;
  443. }
  444. if (i >= 1000) {
  445. pr_warn("DNS-323: Timeout accessing PHY, assuming rev B1\n");
  446. return DNS323_REV_B1;
  447. }
  448. writel((3 << 21) /* phy ID reg */ |
  449. (8 << 16) /* phy addr */ |
  450. SMI_OPCODE_READ, ETH_SMI_REG);
  451. for (i = 0; i < 1000; i++) {
  452. reg = readl(ETH_SMI_REG);
  453. if (reg & SMI_READ_VALID)
  454. break;
  455. }
  456. if (i >= 1000) {
  457. pr_warn("DNS-323: Timeout reading PHY, assuming rev B1\n");
  458. return DNS323_REV_B1;
  459. }
  460. pr_debug("DNS-323: Ethernet PHY ID 0x%x\n", reg & 0xffff);
  461. /* Note: the Marvell tools mask the ID with 0x3f0 before comparison
  462. * but I don't see that making a difference here, at least with
  463. * any known Marvell PHY ID
  464. */
  465. switch(reg & 0xfff0) {
  466. case 0x0cc0: /* MV88E1111 */
  467. return DNS323_REV_B1;
  468. case 0x0e10: /* MV88E1118 */
  469. return DNS323_REV_C1;
  470. default:
  471. pr_warn("DNS-323: Unknown PHY ID 0x%04x, assuming rev B1\n",
  472. reg & 0xffff);
  473. }
  474. return DNS323_REV_B1;
  475. }
  476. static void __init dns323_init(void)
  477. {
  478. /* Setup basic Orion functions. Need to be called early. */
  479. orion5x_init();
  480. /* Identify revision */
  481. system_rev = dns323_identify_rev();
  482. pr_info("DNS-323: Identified HW revision %c1\n", 'A' + system_rev);
  483. /* Just to be tricky, the 5182 has a completely different
  484. * set of MPP modes to the 5181.
  485. */
  486. switch(system_rev) {
  487. case DNS323_REV_A1:
  488. orion5x_mpp_conf(dns323a_mpp_modes);
  489. writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */
  490. break;
  491. case DNS323_REV_B1:
  492. orion5x_mpp_conf(dns323b_mpp_modes);
  493. break;
  494. case DNS323_REV_C1:
  495. orion5x_mpp_conf(dns323c_mpp_modes);
  496. break;
  497. }
  498. /* setup flash mapping
  499. * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
  500. */
  501. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
  502. ORION_MBUS_DEVBUS_BOOT_ATTR,
  503. DNS323_NOR_BOOT_BASE,
  504. DNS323_NOR_BOOT_SIZE);
  505. platform_device_register(&dns323_nor_flash);
  506. /* Sort out LEDs, Buttons and i2c devices */
  507. switch(system_rev) {
  508. case DNS323_REV_A1:
  509. /* The 5181 power LED is active low and requires
  510. * DNS323_GPIO_LED_POWER1 to also be low.
  511. */
  512. dns323ab_leds[0].active_low = 1;
  513. gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable");
  514. gpio_direction_output(DNS323_GPIO_LED_POWER1, 0);
  515. /* Fall through */
  516. case DNS323_REV_B1:
  517. i2c_register_board_info(0, dns323ab_i2c_devices,
  518. ARRAY_SIZE(dns323ab_i2c_devices));
  519. break;
  520. case DNS323_REV_C1:
  521. /* Hookup LEDs & Buttons */
  522. dns323_gpio_leds.dev.platform_data = &dns323c_led_data;
  523. dns323_button_device.dev.platform_data = &dns323c_button_data;
  524. /* Hookup i2c devices and fan driver */
  525. i2c_register_board_info(0, dns323c_i2c_devices,
  526. ARRAY_SIZE(dns323c_i2c_devices));
  527. platform_device_register_simple("dns323c-fan", 0, NULL, 0);
  528. /* Register fixup for the PHY LEDs */
  529. if (!IS_BUILTIN(CONFIG_PHYLIB))
  530. break;
  531. phy_register_fixup_for_uid(MARVELL_PHY_ID_88E1118,
  532. MARVELL_PHY_ID_MASK,
  533. dns323c_phy_fixup);
  534. }
  535. platform_device_register(&dns323_gpio_leds);
  536. platform_device_register(&dns323_button_device);
  537. /*
  538. * Configure peripherals.
  539. */
  540. if (dns323_read_mac_addr() < 0)
  541. printk("DNS-323: Failed to read MAC address\n");
  542. orion5x_ehci0_init();
  543. orion5x_eth_init(&dns323_eth_data);
  544. orion5x_i2c_init();
  545. orion5x_uart0_init();
  546. /* Remaining GPIOs */
  547. switch(system_rev) {
  548. case DNS323_REV_A1:
  549. /* Poweroff GPIO */
  550. if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
  551. gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
  552. pr_err("DNS-323: failed to setup power-off GPIO\n");
  553. pm_power_off = dns323a_power_off;
  554. break;
  555. case DNS323_REV_B1:
  556. /* 5182 built-in SATA init */
  557. orion5x_sata_init(&dns323_sata_data);
  558. /* The DNS323 rev B1 has flag to indicate the system is up.
  559. * Without this flag set, power LED will flash and cannot be
  560. * controlled via leds-gpio.
  561. */
  562. if (gpio_request(DNS323_GPIO_SYSTEM_UP, "SYS_READY") == 0)
  563. gpio_direction_output(DNS323_GPIO_SYSTEM_UP, 1);
  564. /* Poweroff GPIO */
  565. if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
  566. gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
  567. pr_err("DNS-323: failed to setup power-off GPIO\n");
  568. pm_power_off = dns323b_power_off;
  569. break;
  570. case DNS323_REV_C1:
  571. /* 5182 built-in SATA init */
  572. orion5x_sata_init(&dns323_sata_data);
  573. /* Poweroff GPIO */
  574. if (gpio_request(DNS323C_GPIO_POWER_OFF, "POWEROFF") != 0 ||
  575. gpio_direction_output(DNS323C_GPIO_POWER_OFF, 0) != 0)
  576. pr_err("DNS-323: failed to setup power-off GPIO\n");
  577. pm_power_off = dns323c_power_off;
  578. /* Now, -this- should theorically be done by the sata_mv driver
  579. * once I figure out what's going on there. Maybe the behaviour
  580. * of the LEDs should be somewhat passed via the platform_data.
  581. * for now, just whack the register and make the LEDs happy
  582. *
  583. * Note: AFAIK, rev B1 needs the same treatement but I'll let
  584. * somebody else test it.
  585. */
  586. writel(0x5, ORION5X_SATA_VIRT_BASE + 0x2c);
  587. break;
  588. }
  589. }
  590. /* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */
  591. MACHINE_START(DNS323, "D-Link DNS-323")
  592. /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
  593. .atag_offset = 0x100,
  594. .nr_irqs = ORION5X_NR_IRQS,
  595. .init_machine = dns323_init,
  596. .map_io = orion5x_map_io,
  597. .init_early = orion5x_init_early,
  598. .init_irq = orion5x_init_irq,
  599. .init_time = orion5x_timer_init,
  600. .fixup = tag_fixup_mem32,
  601. .restart = orion5x_restart,
  602. MACHINE_END