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 (pdata
->phy_if_mode
) {
594 case PHY_INTERFACE_MODE_MII
:
595 pdata
->mii_if
= MII0_CTRL_IF_MII
;
597 case PHY_INTERFACE_MODE_GMII
:
598 pdata
->mii_if
= MII0_CTRL_IF_GMII
;
600 case PHY_INTERFACE_MODE_RGMII
:
601 pdata
->mii_if
= MII0_CTRL_IF_RGMII
;
603 case PHY_INTERFACE_MODE_RMII
:
604 pdata
->mii_if
= MII0_CTRL_IF_RMII
;
611 switch (pdata
->phy_if_mode
) {
612 case PHY_INTERFACE_MODE_RMII
:
613 pdata
->mii_if
= MII1_CTRL_IF_RMII
;
615 case PHY_INTERFACE_MODE_RGMII
:
616 pdata
->mii_if
= MII1_CTRL_IF_RGMII
;
627 static int ar71xx_eth_instance __initdata
;
628 void __init
ar71xx_add_device_eth(unsigned int id
)
630 struct platform_device
*pdev
;
631 struct ag71xx_platform_data
*pdata
;
635 printk(KERN_ERR
"ar71xx: invalid ethernet id %d\n", id
);
639 ar71xx_init_eth_pll_data(id
);
642 pdev
= &ar71xx_eth0_device
;
644 pdev
= &ar71xx_eth1_device
;
646 pdata
= pdev
->dev
.platform_data
;
648 err
= ar71xx_setup_phy_if_mode(id
, pdata
);
651 "ar71xx: invalid PHY interface mode for GE%u\n", id
);
655 switch (ar71xx_soc
) {
656 case AR71XX_SOC_AR7130
:
657 pdata
->ddr_flush
= id
? ar71xx_ddr_flush_ge1
658 : ar71xx_ddr_flush_ge0
;
659 pdata
->set_pll
= id
? ar71xx_set_pll_ge1
660 : ar71xx_set_pll_ge0
;
663 case AR71XX_SOC_AR7141
:
664 case AR71XX_SOC_AR7161
:
665 pdata
->ddr_flush
= id
? ar71xx_ddr_flush_ge1
666 : ar71xx_ddr_flush_ge0
;
667 pdata
->set_pll
= id
? ar71xx_set_pll_ge1
668 : ar71xx_set_pll_ge0
;
672 case AR71XX_SOC_AR7242
:
673 ar71xx_eth0_data
.reset_bit
|= AR724X_RESET_GE0_MDIO
|
674 RESET_MODULE_GE0_PHY
;
675 ar71xx_eth1_data
.reset_bit
|= AR724X_RESET_GE1_MDIO
|
676 RESET_MODULE_GE1_PHY
;
677 pdata
->ddr_flush
= id
? ar724x_ddr_flush_ge1
678 : ar724x_ddr_flush_ge0
;
679 pdata
->set_pll
= id
? ar724x_set_pll_ge1
680 : ar7242_set_pll_ge0
;
682 pdata
->is_ar724x
= 1;
684 if (!pdata
->fifo_cfg1
)
685 pdata
->fifo_cfg1
= 0x0010ffff;
686 if (!pdata
->fifo_cfg2
)
687 pdata
->fifo_cfg2
= 0x015500aa;
688 if (!pdata
->fifo_cfg3
)
689 pdata
->fifo_cfg3
= 0x01f00140;
692 case AR71XX_SOC_AR7241
:
693 ar71xx_eth0_data
.reset_bit
|= AR724X_RESET_GE0_MDIO
;
694 ar71xx_eth1_data
.reset_bit
|= AR724X_RESET_GE1_MDIO
;
696 case AR71XX_SOC_AR7240
:
697 ar71xx_eth0_data
.reset_bit
|= RESET_MODULE_GE0_PHY
;
698 ar71xx_eth1_data
.reset_bit
|= RESET_MODULE_GE1_PHY
;
699 pdata
->ddr_flush
= id
? ar724x_ddr_flush_ge1
700 : ar724x_ddr_flush_ge0
;
701 pdata
->set_pll
= id
? ar724x_set_pll_ge1
702 : ar724x_set_pll_ge0
;
703 pdata
->is_ar724x
= 1;
704 if (ar71xx_soc
== AR71XX_SOC_AR7240
)
705 pdata
->is_ar7240
= 1;
707 if (!pdata
->fifo_cfg1
)
708 pdata
->fifo_cfg1
= 0x0010ffff;
709 if (!pdata
->fifo_cfg2
)
710 pdata
->fifo_cfg2
= 0x015500aa;
711 if (!pdata
->fifo_cfg3
)
712 pdata
->fifo_cfg3
= 0x01f00140;
715 case AR71XX_SOC_AR9130
:
716 pdata
->ddr_flush
= id
? ar91xx_ddr_flush_ge1
717 : ar91xx_ddr_flush_ge0
;
718 pdata
->set_pll
= id
? ar91xx_set_pll_ge1
719 : ar91xx_set_pll_ge0
;
720 pdata
->is_ar91xx
= 1;
723 case AR71XX_SOC_AR9132
:
724 pdata
->ddr_flush
= id
? ar91xx_ddr_flush_ge1
725 : ar91xx_ddr_flush_ge0
;
726 pdata
->set_pll
= id
? ar91xx_set_pll_ge1
727 : ar91xx_set_pll_ge0
;
728 pdata
->is_ar91xx
= 1;
732 case AR71XX_SOC_AR9330
:
733 case AR71XX_SOC_AR9331
:
734 ar71xx_eth0_data
.reset_bit
= AR933X_RESET_GE0_MAC
|
735 AR933X_RESET_GE0_MDIO
;
736 ar71xx_eth1_data
.reset_bit
= AR933X_RESET_GE1_MAC
|
737 AR933X_RESET_GE1_MDIO
;
738 pdata
->ddr_flush
= id
? ar933x_ddr_flush_ge1
739 : ar933x_ddr_flush_ge0
;
740 pdata
->set_pll
= id
? ar933x_set_pll_ge1
741 : ar933x_set_pll_ge0
;
743 pdata
->is_ar724x
= 1;
745 if (!pdata
->fifo_cfg1
)
746 pdata
->fifo_cfg1
= 0x0010ffff;
747 if (!pdata
->fifo_cfg2
)
748 pdata
->fifo_cfg2
= 0x015500aa;
749 if (!pdata
->fifo_cfg3
)
750 pdata
->fifo_cfg3
= 0x01f00140;
753 case AR71XX_SOC_AR9341
:
754 case AR71XX_SOC_AR9342
:
755 case AR71XX_SOC_AR9344
:
756 ar71xx_eth0_data
.reset_bit
= AR934X_RESET_GE0_MAC
|
757 AR934X_RESET_GE0_MDIO
;
758 ar71xx_eth1_data
.reset_bit
= AR934X_RESET_GE1_MAC
|
759 AR934X_RESET_GE1_MDIO
;
760 pdata
->ddr_flush
= id
? ar934x_ddr_flush_ge1
761 : ar934x_ddr_flush_ge0
;
762 pdata
->set_pll
= id
? ar934x_set_pll_ge1
763 : ar934x_set_pll_ge0
;
765 pdata
->is_ar724x
= 1;
767 if (!pdata
->fifo_cfg1
)
768 pdata
->fifo_cfg1
= 0x0010ffff;
769 if (!pdata
->fifo_cfg2
)
770 pdata
->fifo_cfg2
= 0x015500aa;
771 if (!pdata
->fifo_cfg3
)
772 pdata
->fifo_cfg3
= 0x01f00140;
779 switch (pdata
->phy_if_mode
) {
780 case PHY_INTERFACE_MODE_GMII
:
781 case PHY_INTERFACE_MODE_RGMII
:
782 if (!pdata
->has_gbit
) {
783 printk(KERN_ERR
"ar71xx: no gbit available on eth%d\n",
792 if (!is_valid_ether_addr(pdata
->mac_addr
)) {
793 random_ether_addr(pdata
->mac_addr
);
795 "ar71xx: using random MAC address for eth%d\n",
796 ar71xx_eth_instance
);
799 if (pdata
->mii_bus_dev
== NULL
) {
800 switch (ar71xx_soc
) {
801 case AR71XX_SOC_AR9341
:
802 case AR71XX_SOC_AR9342
:
803 case AR71XX_SOC_AR9344
:
805 pdata
->mii_bus_dev
= &ar71xx_mdio0_device
.dev
;
807 pdata
->mii_bus_dev
= &ar71xx_mdio1_device
.dev
;
810 case AR71XX_SOC_AR7241
:
811 case AR71XX_SOC_AR9330
:
812 case AR71XX_SOC_AR9331
:
813 pdata
->mii_bus_dev
= &ar71xx_mdio1_device
.dev
;
817 pdata
->mii_bus_dev
= &ar71xx_mdio0_device
.dev
;
822 /* Reset the device */
823 ar71xx_device_stop(pdata
->reset_bit
);
826 ar71xx_device_start(pdata
->reset_bit
);
829 platform_device_register(pdev
);
830 ar71xx_eth_instance
++;
833 static struct resource ar71xx_spi_resources
[] = {
835 .start
= AR71XX_SPI_BASE
,
836 .end
= AR71XX_SPI_BASE
+ AR71XX_SPI_SIZE
- 1,
837 .flags
= IORESOURCE_MEM
,
841 static struct platform_device ar71xx_spi_device
= {
842 .name
= "ar71xx-spi",
844 .resource
= ar71xx_spi_resources
,
845 .num_resources
= ARRAY_SIZE(ar71xx_spi_resources
),
848 void __init
ar71xx_add_device_spi(struct ar71xx_spi_platform_data
*pdata
,
849 struct spi_board_info
const *info
,
852 spi_register_board_info(info
, n
);
853 ar71xx_spi_device
.dev
.platform_data
= pdata
;
854 platform_device_register(&ar71xx_spi_device
);
857 void __init
ar71xx_add_device_wdt(void)
859 platform_device_register_simple("ar71xx-wdt", -1, NULL
, 0);
862 void __init
ar71xx_set_mac_base(unsigned char *mac
)
864 memcpy(ar71xx_mac_base
, mac
, ETH_ALEN
);
867 void __init
ar71xx_parse_mac_addr(char *mac_str
)
872 t
= sscanf(mac_str
, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
873 &tmp
[0], &tmp
[1], &tmp
[2], &tmp
[3], &tmp
[4], &tmp
[5]);
876 t
= sscanf(mac_str
, "%02hhx.%02hhx.%02hhx.%02hhx.%02hhx.%02hhx",
877 &tmp
[0], &tmp
[1], &tmp
[2], &tmp
[3], &tmp
[4], &tmp
[5]);
880 ar71xx_set_mac_base(tmp
);
882 printk(KERN_DEBUG
"ar71xx: failed to parse mac address "
883 "\"%s\"\n", mac_str
);
886 static int __init
ar71xx_ethaddr_setup(char *str
)
888 ar71xx_parse_mac_addr(str
);
891 __setup("ethaddr=", ar71xx_ethaddr_setup
);
893 static int __init
ar71xx_kmac_setup(char *str
)
895 ar71xx_parse_mac_addr(str
);
898 __setup("kmac=", ar71xx_kmac_setup
);
900 void __init
ar71xx_init_mac(unsigned char *dst
, const unsigned char *src
,
905 if (!is_valid_ether_addr(src
)) {
906 memset(dst
, '\0', ETH_ALEN
);
910 t
= (((u32
) src
[3]) << 16) + (((u32
) src
[4]) << 8) + ((u32
) src
[5]);
916 dst
[3] = (t
>> 16) & 0xff;
917 dst
[4] = (t
>> 8) & 0xff;