dns323-setup.c 18 KB

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