2 * Atheros AR71xx SoC platform devices
4 * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
5 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
6 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
8 * Parts of this file are based on Atheros 2.6.15 BSP
9 * Parts of this file are based on Atheros 2.6.31 BSP
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published
13 * by the Free Software Foundation.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/delay.h>
19 #include <linux/etherdevice.h>
20 #include <linux/platform_device.h>
21 #include <linux/serial_8250.h>
23 #include <asm/mach-ar71xx/ar71xx.h>
24 #include <asm/mach-ar71xx/ar933x_uart_platform.h>
28 unsigned char ar71xx_mac_base[ETH_ALEN] __initdata;
30 static struct resource ar71xx_uart_resources[] = {
32 .start = AR71XX_UART_BASE,
33 .end = AR71XX_UART_BASE + AR71XX_UART_SIZE - 1,
34 .flags = IORESOURCE_MEM,
38 #define AR71XX_UART_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP)
39 static struct plat_serial8250_port ar71xx_uart_data[] = {
41 .mapbase = AR71XX_UART_BASE,
42 .irq = AR71XX_MISC_IRQ_UART,
43 .flags = AR71XX_UART_FLAGS,
47 /* terminating entry */
51 static struct platform_device ar71xx_uart_device = {
53 .id = PLAT8250_DEV_PLATFORM,
54 .resource = ar71xx_uart_resources,
55 .num_resources = ARRAY_SIZE(ar71xx_uart_resources),
57 .platform_data = ar71xx_uart_data
61 static struct resource ar933x_uart_resources[] = {
63 .start = AR933X_UART_BASE,
64 .end = AR933X_UART_BASE + AR71XX_UART_SIZE - 1,
65 .flags = IORESOURCE_MEM,
68 .start = AR71XX_MISC_IRQ_UART,
69 .end = AR71XX_MISC_IRQ_UART,
70 .flags = IORESOURCE_IRQ,
74 static struct ar933x_uart_platform_data ar933x_uart_data;
75 static struct platform_device ar933x_uart_device = {
76 .name = "ar933x-uart",
78 .resource = ar933x_uart_resources,
79 .num_resources = ARRAY_SIZE(ar933x_uart_resources),
81 .platform_data = &ar933x_uart_data,
85 void __init ar71xx_add_device_uart(void)
87 struct platform_device *pdev;
90 case AR71XX_SOC_AR7130:
91 case AR71XX_SOC_AR7141:
92 case AR71XX_SOC_AR7161:
93 case AR71XX_SOC_AR7240:
94 case AR71XX_SOC_AR7241:
95 case AR71XX_SOC_AR7242:
96 case AR71XX_SOC_AR9130:
97 case AR71XX_SOC_AR9132:
98 pdev = &ar71xx_uart_device;
99 ar71xx_uart_data[0].uartclk = ar71xx_ahb_freq;
102 case AR71XX_SOC_AR9330:
103 case AR71XX_SOC_AR9331:
104 pdev = &ar933x_uart_device;
105 ar933x_uart_data.uartclk = ar71xx_ref_freq;
108 case AR71XX_SOC_AR9341:
109 case AR71XX_SOC_AR9342:
110 case AR71XX_SOC_AR9344:
111 pdev = &ar71xx_uart_device;
112 ar71xx_uart_data[0].uartclk = ar71xx_ref_freq;
119 platform_device_register(pdev);
122 static struct resource ar71xx_mdio0_resources[] = {
125 .flags = IORESOURCE_MEM,
126 .start = AR71XX_GE0_BASE,
127 .end = AR71XX_GE0_BASE + 0x200 - 1,
131 static struct ag71xx_mdio_platform_data ar71xx_mdio0_data;
133 struct platform_device ar71xx_mdio0_device = {
134 .name = "ag71xx-mdio",
136 .resource = ar71xx_mdio0_resources,
137 .num_resources = ARRAY_SIZE(ar71xx_mdio0_resources),
139 .platform_data = &ar71xx_mdio0_data,
143 static struct resource ar71xx_mdio1_resources[] = {
146 .flags = IORESOURCE_MEM,
147 .start = AR71XX_GE1_BASE,
148 .end = AR71XX_GE1_BASE + 0x200 - 1,
152 static struct ag71xx_mdio_platform_data ar71xx_mdio1_data;
154 struct platform_device ar71xx_mdio1_device = {
155 .name = "ag71xx-mdio",
157 .resource = ar71xx_mdio1_resources,
158 .num_resources = ARRAY_SIZE(ar71xx_mdio1_resources),
160 .platform_data = &ar71xx_mdio1_data,
164 static void ar71xx_set_pll(u32 cfg_reg, u32 pll_reg, u32 pll_val, u32 shift)
169 base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
171 t = __raw_readl(base + cfg_reg);
174 __raw_writel(t, base + cfg_reg);
177 __raw_writel(pll_val, base + pll_reg);
180 __raw_writel(t, base + cfg_reg);
184 __raw_writel(t, base + cfg_reg);
187 printk(KERN_DEBUG "ar71xx: pll_reg %#x: %#x\n",
188 (unsigned int)(base + pll_reg), __raw_readl(base + pll_reg));
193 void __init ar71xx_add_device_mdio(unsigned int id, u32 phy_mask)
195 struct platform_device *mdio_dev;
196 struct ag71xx_mdio_platform_data *mdio_data;
199 if (ar71xx_soc == AR71XX_SOC_AR9341 ||
200 ar71xx_soc == AR71XX_SOC_AR9342 ||
201 ar71xx_soc == AR71XX_SOC_AR9344)
207 printk(KERN_ERR "ar71xx: invalid MDIO id %u\n", id);
211 switch (ar71xx_soc) {
212 case AR71XX_SOC_AR7241:
213 case AR71XX_SOC_AR9330:
214 case AR71XX_SOC_AR9331:
215 mdio_dev = &ar71xx_mdio1_device;
216 mdio_data = &ar71xx_mdio1_data;
219 case AR71XX_SOC_AR9341:
220 case AR71XX_SOC_AR9342:
221 case AR71XX_SOC_AR9344:
223 mdio_dev = &ar71xx_mdio0_device;
224 mdio_data = &ar71xx_mdio0_data;
226 mdio_dev = &ar71xx_mdio1_device;
227 mdio_data = &ar71xx_mdio1_data;
231 case AR71XX_SOC_AR7242:
232 ar71xx_set_pll(AR71XX_PLL_REG_SEC_CONFIG,
233 AR7242_PLL_REG_ETH0_INT_CLOCK, 0x62000000,
234 AR71XX_ETH0_PLL_SHIFT);
237 mdio_dev = &ar71xx_mdio0_device;
238 mdio_data = &ar71xx_mdio0_data;
242 mdio_data->phy_mask = phy_mask;
244 switch (ar71xx_soc) {
245 case AR71XX_SOC_AR7240:
246 case AR71XX_SOC_AR7241:
247 case AR71XX_SOC_AR9330:
248 case AR71XX_SOC_AR9331:
249 mdio_data->is_ar7240 = 1;
252 case AR71XX_SOC_AR9341:
253 case AR71XX_SOC_AR9342:
254 case AR71XX_SOC_AR9344:
256 mdio_data->is_ar7240 = 1;
263 platform_device_register(mdio_dev);
266 struct ar71xx_eth_pll_data ar71xx_eth0_pll_data;
267 struct ar71xx_eth_pll_data ar71xx_eth1_pll_data;
269 static u32 ar71xx_get_eth_pll(unsigned int mac, int speed)
271 struct ar71xx_eth_pll_data *pll_data;
276 pll_data = &ar71xx_eth0_pll_data;
279 pll_data = &ar71xx_eth1_pll_data;
287 pll_val = pll_data->pll_10;
290 pll_val = pll_data->pll_100;
293 pll_val = pll_data->pll_1000;
302 static void ar71xx_set_pll_ge0(int speed)
304 u32 val = ar71xx_get_eth_pll(0, speed);
306 ar71xx_set_pll(AR71XX_PLL_REG_SEC_CONFIG, AR71XX_PLL_REG_ETH0_INT_CLOCK,
307 val, AR71XX_ETH0_PLL_SHIFT);
310 static void ar71xx_set_pll_ge1(int speed)
312 u32 val = ar71xx_get_eth_pll(1, speed);
314 ar71xx_set_pll(AR71XX_PLL_REG_SEC_CONFIG, AR71XX_PLL_REG_ETH1_INT_CLOCK,
315 val, AR71XX_ETH1_PLL_SHIFT);
318 static void ar724x_set_pll_ge0(int speed)
323 static void ar724x_set_pll_ge1(int speed)
328 static void ar7242_set_pll_ge0(int speed)
330 u32 val = ar71xx_get_eth_pll(0, speed);
333 base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
334 __raw_writel(val, base + AR7242_PLL_REG_ETH0_INT_CLOCK);
338 static void ar91xx_set_pll_ge0(int speed)
340 u32 val = ar71xx_get_eth_pll(0, speed);
342 ar71xx_set_pll(AR91XX_PLL_REG_ETH_CONFIG, AR91XX_PLL_REG_ETH0_INT_CLOCK,
343 val, AR91XX_ETH0_PLL_SHIFT);
346 static void ar91xx_set_pll_ge1(int speed)
348 u32 val = ar71xx_get_eth_pll(1, speed);
350 ar71xx_set_pll(AR91XX_PLL_REG_ETH_CONFIG, AR91XX_PLL_REG_ETH1_INT_CLOCK,
351 val, AR91XX_ETH1_PLL_SHIFT);
354 static void ar933x_set_pll_ge0(int speed)
359 static void ar933x_set_pll_ge1(int speed)
364 static void ar934x_set_pll_ge0(int speed)
369 static void ar934x_set_pll_ge1(int speed)
374 static void ar71xx_ddr_flush_ge0(void)
376 ar71xx_ddr_flush(AR71XX_DDR_REG_FLUSH_GE0);
379 static void ar71xx_ddr_flush_ge1(void)
381 ar71xx_ddr_flush(AR71XX_DDR_REG_FLUSH_GE1);
384 static void ar724x_ddr_flush_ge0(void)
386 ar71xx_ddr_flush(AR724X_DDR_REG_FLUSH_GE0);
389 static void ar724x_ddr_flush_ge1(void)
391 ar71xx_ddr_flush(AR724X_DDR_REG_FLUSH_GE1);
394 static void ar91xx_ddr_flush_ge0(void)
396 ar71xx_ddr_flush(AR91XX_DDR_REG_FLUSH_GE0);
399 static void ar91xx_ddr_flush_ge1(void)
401 ar71xx_ddr_flush(AR91XX_DDR_REG_FLUSH_GE1);
404 static void ar933x_ddr_flush_ge0(void)
406 ar71xx_ddr_flush(AR933X_DDR_REG_FLUSH_GE0);
409 static void ar933x_ddr_flush_ge1(void)
411 ar71xx_ddr_flush(AR933X_DDR_REG_FLUSH_GE1);
414 static void ar934x_ddr_flush_ge0(void)
416 ar71xx_ddr_flush(AR934X_DDR_REG_FLUSH_GE0);
419 static void ar934x_ddr_flush_ge1(void)
421 ar71xx_ddr_flush(AR934X_DDR_REG_FLUSH_GE1);
424 static struct resource ar71xx_eth0_resources[] = {
427 .flags = IORESOURCE_MEM,
428 .start = AR71XX_GE0_BASE,
429 .end = AR71XX_GE0_BASE + 0x200 - 1,
432 .flags = IORESOURCE_MEM,
433 .start = AR71XX_MII_BASE + MII_REG_MII0_CTRL,
434 .end = AR71XX_MII_BASE + MII_REG_MII0_CTRL + 3,
437 .flags = IORESOURCE_IRQ,
438 .start = AR71XX_CPU_IRQ_GE0,
439 .end = AR71XX_CPU_IRQ_GE0,
443 struct ag71xx_platform_data ar71xx_eth0_data = {
444 .reset_bit = RESET_MODULE_GE0_MAC,
447 struct platform_device ar71xx_eth0_device = {
450 .resource = ar71xx_eth0_resources,
451 .num_resources = ARRAY_SIZE(ar71xx_eth0_resources),
453 .platform_data = &ar71xx_eth0_data,
457 static struct resource ar71xx_eth1_resources[] = {
460 .flags = IORESOURCE_MEM,
461 .start = AR71XX_GE1_BASE,
462 .end = AR71XX_GE1_BASE + 0x200 - 1,
465 .flags = IORESOURCE_MEM,
466 .start = AR71XX_MII_BASE + MII_REG_MII1_CTRL,
467 .end = AR71XX_MII_BASE + MII_REG_MII1_CTRL + 3,
470 .flags = IORESOURCE_IRQ,
471 .start = AR71XX_CPU_IRQ_GE1,
472 .end = AR71XX_CPU_IRQ_GE1,
476 struct ag71xx_platform_data ar71xx_eth1_data = {
477 .reset_bit = RESET_MODULE_GE1_MAC,
480 struct platform_device ar71xx_eth1_device = {
483 .resource = ar71xx_eth1_resources,
484 .num_resources = ARRAY_SIZE(ar71xx_eth1_resources),
486 .platform_data = &ar71xx_eth1_data,
490 #define AR71XX_PLL_VAL_1000 0x00110000
491 #define AR71XX_PLL_VAL_100 0x00001099
492 #define AR71XX_PLL_VAL_10 0x00991099
494 #define AR724X_PLL_VAL_1000 0x00110000
495 #define AR724X_PLL_VAL_100 0x00001099
496 #define AR724X_PLL_VAL_10 0x00991099
498 #define AR7242_PLL_VAL_1000 0x16000000
499 #define AR7242_PLL_VAL_100 0x00000101
500 #define AR7242_PLL_VAL_10 0x00001616
502 #define AR91XX_PLL_VAL_1000 0x1a000000
503 #define AR91XX_PLL_VAL_100 0x13000a44
504 #define AR91XX_PLL_VAL_10 0x00441099
506 #define AR933X_PLL_VAL_1000 0x00110000
507 #define AR933X_PLL_VAL_100 0x00001099
508 #define AR933X_PLL_VAL_10 0x00991099
510 #define AR934X_PLL_VAL_1000 0x00110000
511 #define AR934X_PLL_VAL_100 0x00001099
512 #define AR934X_PLL_VAL_10 0x00991099
514 static void __init ar71xx_init_eth_pll_data(unsigned int id)
516 struct ar71xx_eth_pll_data *pll_data;
517 u32 pll_10, pll_100, pll_1000;
521 pll_data = &ar71xx_eth0_pll_data;
524 pll_data = &ar71xx_eth1_pll_data;
530 switch (ar71xx_soc) {
531 case AR71XX_SOC_AR7130:
532 case AR71XX_SOC_AR7141:
533 case AR71XX_SOC_AR7161:
534 pll_10 = AR71XX_PLL_VAL_10;
535 pll_100 = AR71XX_PLL_VAL_100;
536 pll_1000 = AR71XX_PLL_VAL_1000;
539 case AR71XX_SOC_AR7240:
540 case AR71XX_SOC_AR7241:
541 pll_10 = AR724X_PLL_VAL_10;
542 pll_100 = AR724X_PLL_VAL_100;
543 pll_1000 = AR724X_PLL_VAL_1000;
546 case AR71XX_SOC_AR7242:
547 pll_10 = AR7242_PLL_VAL_10;
548 pll_100 = AR7242_PLL_VAL_100;
549 pll_1000 = AR7242_PLL_VAL_1000;
552 case AR71XX_SOC_AR9130:
553 case AR71XX_SOC_AR9132:
554 pll_10 = AR91XX_PLL_VAL_10;
555 pll_100 = AR91XX_PLL_VAL_100;
556 pll_1000 = AR91XX_PLL_VAL_1000;
559 case AR71XX_SOC_AR9330:
560 case AR71XX_SOC_AR9331:
561 pll_10 = AR933X_PLL_VAL_10;
562 pll_100 = AR933X_PLL_VAL_100;
563 pll_1000 = AR933X_PLL_VAL_1000;
566 case AR71XX_SOC_AR9341:
567 case AR71XX_SOC_AR9342:
568 case AR71XX_SOC_AR9344:
569 pll_10 = AR934X_PLL_VAL_10;
570 pll_100 = AR934X_PLL_VAL_100;
571 pll_1000 = AR934X_PLL_VAL_1000;
578 if (!pll_data->pll_10)
579 pll_data->pll_10 = pll_10;
581 if (!pll_data->pll_100)
582 pll_data->pll_100 = pll_100;
584 if (!pll_data->pll_1000)
585 pll_data->pll_1000 = pll_1000;
588 static int __init ar71xx_setup_phy_if_mode(unsigned int id,
589 struct ag71xx_platform_data *pdata)
593 switch (ar71xx_soc) {
594 case AR71XX_SOC_AR7130:
595 case AR71XX_SOC_AR7141:
596 case AR71XX_SOC_AR7161:
597 case AR71XX_SOC_AR9130:
598 case AR71XX_SOC_AR9132:
599 switch (pdata->phy_if_mode) {
600 case PHY_INTERFACE_MODE_MII:
601 pdata->mii_if = MII0_CTRL_IF_MII;
603 case PHY_INTERFACE_MODE_GMII:
604 pdata->mii_if = MII0_CTRL_IF_GMII;
606 case PHY_INTERFACE_MODE_RGMII:
607 pdata->mii_if = MII0_CTRL_IF_RGMII;
609 case PHY_INTERFACE_MODE_RMII:
610 pdata->mii_if = MII0_CTRL_IF_RMII;
617 case AR71XX_SOC_AR7240:
618 case AR71XX_SOC_AR7241:
619 case AR71XX_SOC_AR9330:
620 case AR71XX_SOC_AR9331:
621 pdata->phy_if_mode = PHY_INTERFACE_MODE_MII;
624 case AR71XX_SOC_AR7242:
627 case AR71XX_SOC_AR9341:
628 case AR71XX_SOC_AR9342:
629 case AR71XX_SOC_AR9344:
630 switch (pdata->phy_if_mode) {
631 case PHY_INTERFACE_MODE_MII:
632 case PHY_INTERFACE_MODE_GMII:
633 case PHY_INTERFACE_MODE_RGMII:
634 case PHY_INTERFACE_MODE_RMII:
646 switch (ar71xx_soc) {
647 case AR71XX_SOC_AR7130:
648 case AR71XX_SOC_AR7141:
649 case AR71XX_SOC_AR7161:
650 case AR71XX_SOC_AR9130:
651 case AR71XX_SOC_AR9132:
652 switch (pdata->phy_if_mode) {
653 case PHY_INTERFACE_MODE_RMII:
654 pdata->mii_if = MII1_CTRL_IF_RMII;
656 case PHY_INTERFACE_MODE_RGMII:
657 pdata->mii_if = MII1_CTRL_IF_RGMII;
664 case AR71XX_SOC_AR7240:
665 case AR71XX_SOC_AR7241:
666 case AR71XX_SOC_AR9330:
667 case AR71XX_SOC_AR9331:
668 pdata->phy_if_mode = PHY_INTERFACE_MODE_GMII;
671 case AR71XX_SOC_AR7242:
674 case AR71XX_SOC_AR9341:
675 case AR71XX_SOC_AR9342:
676 case AR71XX_SOC_AR9344:
677 switch (pdata->phy_if_mode) {
678 case PHY_INTERFACE_MODE_MII:
679 case PHY_INTERFACE_MODE_GMII:
695 static int ar71xx_eth_instance __initdata;
696 void __init ar71xx_add_device_eth(unsigned int id)
698 struct platform_device *pdev;
699 struct ag71xx_platform_data *pdata;
703 printk(KERN_ERR "ar71xx: invalid ethernet id %d\n", id);
707 ar71xx_init_eth_pll_data(id);
710 pdev = &ar71xx_eth0_device;
712 pdev = &ar71xx_eth1_device;
714 pdata = pdev->dev.platform_data;
716 err = ar71xx_setup_phy_if_mode(id, pdata);
719 "ar71xx: invalid PHY interface mode for GE%u\n", id);
723 switch (ar71xx_soc) {
724 case AR71XX_SOC_AR7130:
725 pdata->ddr_flush = id ? ar71xx_ddr_flush_ge1
726 : ar71xx_ddr_flush_ge0;
727 pdata->set_pll = id ? ar71xx_set_pll_ge1
728 : ar71xx_set_pll_ge0;
731 case AR71XX_SOC_AR7141:
732 case AR71XX_SOC_AR7161:
733 pdata->ddr_flush = id ? ar71xx_ddr_flush_ge1
734 : ar71xx_ddr_flush_ge0;
735 pdata->set_pll = id ? ar71xx_set_pll_ge1
736 : ar71xx_set_pll_ge0;
740 case AR71XX_SOC_AR7242:
741 ar71xx_eth0_data.reset_bit |= AR724X_RESET_GE0_MDIO |
742 RESET_MODULE_GE0_PHY;
743 ar71xx_eth1_data.reset_bit |= AR724X_RESET_GE1_MDIO |
744 RESET_MODULE_GE1_PHY;
745 pdata->ddr_flush = id ? ar724x_ddr_flush_ge1
746 : ar724x_ddr_flush_ge0;
747 pdata->set_pll = id ? ar724x_set_pll_ge1
748 : ar7242_set_pll_ge0;
750 pdata->is_ar724x = 1;
752 if (!pdata->fifo_cfg1)
753 pdata->fifo_cfg1 = 0x0010ffff;
754 if (!pdata->fifo_cfg2)
755 pdata->fifo_cfg2 = 0x015500aa;
756 if (!pdata->fifo_cfg3)
757 pdata->fifo_cfg3 = 0x01f00140;
760 case AR71XX_SOC_AR7241:
761 ar71xx_eth0_data.reset_bit |= AR724X_RESET_GE0_MDIO;
762 ar71xx_eth1_data.reset_bit |= AR724X_RESET_GE1_MDIO;
764 case AR71XX_SOC_AR7240:
765 ar71xx_eth0_data.reset_bit |= RESET_MODULE_GE0_PHY;
766 ar71xx_eth1_data.reset_bit |= RESET_MODULE_GE1_PHY;
767 pdata->ddr_flush = id ? ar724x_ddr_flush_ge1
768 : ar724x_ddr_flush_ge0;
769 pdata->set_pll = id ? ar724x_set_pll_ge1
770 : ar724x_set_pll_ge0;
771 pdata->is_ar724x = 1;
772 if (ar71xx_soc == AR71XX_SOC_AR7240)
773 pdata->is_ar7240 = 1;
775 if (!pdata->fifo_cfg1)
776 pdata->fifo_cfg1 = 0x0010ffff;
777 if (!pdata->fifo_cfg2)
778 pdata->fifo_cfg2 = 0x015500aa;
779 if (!pdata->fifo_cfg3)
780 pdata->fifo_cfg3 = 0x01f00140;
783 case AR71XX_SOC_AR9130:
784 pdata->ddr_flush = id ? ar91xx_ddr_flush_ge1
785 : ar91xx_ddr_flush_ge0;
786 pdata->set_pll = id ? ar91xx_set_pll_ge1
787 : ar91xx_set_pll_ge0;
788 pdata->is_ar91xx = 1;
791 case AR71XX_SOC_AR9132:
792 pdata->ddr_flush = id ? ar91xx_ddr_flush_ge1
793 : ar91xx_ddr_flush_ge0;
794 pdata->set_pll = id ? ar91xx_set_pll_ge1
795 : ar91xx_set_pll_ge0;
796 pdata->is_ar91xx = 1;
800 case AR71XX_SOC_AR9330:
801 case AR71XX_SOC_AR9331:
802 ar71xx_eth0_data.reset_bit = AR933X_RESET_GE0_MAC |
803 AR933X_RESET_GE0_MDIO;
804 ar71xx_eth1_data.reset_bit = AR933X_RESET_GE1_MAC |
805 AR933X_RESET_GE1_MDIO;
806 pdata->ddr_flush = id ? ar933x_ddr_flush_ge1
807 : ar933x_ddr_flush_ge0;
808 pdata->set_pll = id ? ar933x_set_pll_ge1
809 : ar933x_set_pll_ge0;
811 pdata->is_ar724x = 1;
813 if (!pdata->fifo_cfg1)
814 pdata->fifo_cfg1 = 0x0010ffff;
815 if (!pdata->fifo_cfg2)
816 pdata->fifo_cfg2 = 0x015500aa;
817 if (!pdata->fifo_cfg3)
818 pdata->fifo_cfg3 = 0x01f00140;
821 case AR71XX_SOC_AR9341:
822 case AR71XX_SOC_AR9342:
823 case AR71XX_SOC_AR9344:
824 ar71xx_eth0_data.reset_bit = AR934X_RESET_GE0_MAC |
825 AR934X_RESET_GE0_MDIO;
826 ar71xx_eth1_data.reset_bit = AR934X_RESET_GE1_MAC |
827 AR934X_RESET_GE1_MDIO;
828 pdata->ddr_flush = id ? ar934x_ddr_flush_ge1
829 : ar934x_ddr_flush_ge0;
830 pdata->set_pll = id ? ar934x_set_pll_ge1
831 : ar934x_set_pll_ge0;
833 pdata->is_ar724x = 1;
835 if (!pdata->fifo_cfg1)
836 pdata->fifo_cfg1 = 0x0010ffff;
837 if (!pdata->fifo_cfg2)
838 pdata->fifo_cfg2 = 0x015500aa;
839 if (!pdata->fifo_cfg3)
840 pdata->fifo_cfg3 = 0x01f00140;
847 switch (pdata->phy_if_mode) {
848 case PHY_INTERFACE_MODE_GMII:
849 case PHY_INTERFACE_MODE_RGMII:
850 if (!pdata->has_gbit) {
851 printk(KERN_ERR "ar71xx: no gbit available on eth%d\n",
860 if (!is_valid_ether_addr(pdata->mac_addr)) {
861 random_ether_addr(pdata->mac_addr);
863 "ar71xx: using random MAC address for eth%d\n",
864 ar71xx_eth_instance);
867 if (pdata->mii_bus_dev == NULL) {
868 switch (ar71xx_soc) {
869 case AR71XX_SOC_AR9341:
870 case AR71XX_SOC_AR9342:
871 case AR71XX_SOC_AR9344:
873 pdata->mii_bus_dev = &ar71xx_mdio0_device.dev;
875 pdata->mii_bus_dev = &ar71xx_mdio1_device.dev;
878 case AR71XX_SOC_AR7241:
879 case AR71XX_SOC_AR9330:
880 case AR71XX_SOC_AR9331:
881 pdata->mii_bus_dev = &ar71xx_mdio1_device.dev;
885 pdata->mii_bus_dev = &ar71xx_mdio0_device.dev;
890 /* Reset the device */
891 ar71xx_device_stop(pdata->reset_bit);
894 ar71xx_device_start(pdata->reset_bit);
897 platform_device_register(pdev);
898 ar71xx_eth_instance++;
901 static struct resource ar71xx_spi_resources[] = {
903 .start = AR71XX_SPI_BASE,
904 .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
905 .flags = IORESOURCE_MEM,
909 static struct platform_device ar71xx_spi_device = {
910 .name = "ar71xx-spi",
912 .resource = ar71xx_spi_resources,
913 .num_resources = ARRAY_SIZE(ar71xx_spi_resources),
916 void __init ar71xx_add_device_spi(struct ar71xx_spi_platform_data *pdata,
917 struct spi_board_info const *info,
920 spi_register_board_info(info, n);
921 ar71xx_spi_device.dev.platform_data = pdata;
922 platform_device_register(&ar71xx_spi_device);
925 void __init ar71xx_add_device_wdt(void)
927 platform_device_register_simple("ar71xx-wdt", -1, NULL, 0);
930 void __init ar71xx_set_mac_base(unsigned char *mac)
932 memcpy(ar71xx_mac_base, mac, ETH_ALEN);
935 void __init ar71xx_parse_mac_addr(char *mac_str)
940 t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
941 &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
944 t = sscanf(mac_str, "%02hhx.%02hhx.%02hhx.%02hhx.%02hhx.%02hhx",
945 &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
948 ar71xx_set_mac_base(tmp);
950 printk(KERN_DEBUG "ar71xx: failed to parse mac address "
951 "\"%s\"\n", mac_str);
954 static int __init ar71xx_ethaddr_setup(char *str)
956 ar71xx_parse_mac_addr(str);
959 __setup("ethaddr=", ar71xx_ethaddr_setup);
961 static int __init ar71xx_kmac_setup(char *str)
963 ar71xx_parse_mac_addr(str);
966 __setup("kmac=", ar71xx_kmac_setup);
968 void __init ar71xx_init_mac(unsigned char *dst, const unsigned char *src,
973 if (!is_valid_ether_addr(src)) {
974 memset(dst, '\0', ETH_ALEN);
978 t = (((u32) src[3]) << 16) + (((u32) src[4]) << 8) + ((u32) src[5]);
984 dst[3] = (t >> 16) & 0xff;
985 dst[4] = (t >> 8) & 0xff;