dns323-setup.c 18 KB

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