dns323-setup.c 18 KB

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