ar71xx: add preliminary support for Mikrotik RB2011L
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-rb2011.c
1 /*
2 * MikroTik RouterBOARD 2011 support
3 *
4 * Copyright (C) 2012 Stijn Tintel <stijn@linux-ipv6.be>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11 #include <linux/phy.h>
12 #include <linux/platform_device.h>
13 #include <linux/ar8216_platform.h>
14
15 #include <asm/mach-ath79/ar71xx_regs.h>
16
17 #include "common.h"
18 #include "dev-eth.h"
19 #include "dev-m25p80.h"
20 #include "machtypes.h"
21
22 static struct ar8327_pad_cfg rb2011_ar8327_pad0_cfg = {
23 .mode = AR8327_PAD_MAC_RGMII,
24 .txclk_delay_en = true,
25 .rxclk_delay_en = true,
26 .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
27 .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
28 };
29
30 static struct ar8327_platform_data rb2011_ar8327_data = {
31 .pad0_cfg = &rb2011_ar8327_pad0_cfg,
32 .cpuport_cfg = {
33 .force_link = 1,
34 .speed = AR8327_PORT_SPEED_1000,
35 .duplex = 1,
36 .txpause = 1,
37 .rxpause = 1,
38 }
39 };
40
41 static struct mdio_board_info rb2011_mdio0_info[] = {
42 {
43 .bus_id = "ag71xx-mdio.0",
44 .phy_addr = 0,
45 .platform_data = &rb2011_ar8327_data,
46 },
47 };
48
49 static void __init rb2011_gmac_setup(void)
50 {
51 void __iomem *base;
52 u32 t;
53
54 base = ioremap(AR934X_GMAC_BASE, AR934X_GMAC_SIZE);
55
56 t = __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
57 t &= ~(AR934X_ETH_CFG_RGMII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0 |
58 AR934X_ETH_CFG_GMII_GMAC0 | AR934X_ETH_CFG_SW_ONLY_MODE);
59 t |= AR934X_ETH_CFG_RGMII_GMAC0 | AR934X_ETH_CFG_SW_ONLY_MODE;
60
61 __raw_writel(t, base + AR934X_GMAC_REG_ETH_CFG);
62
63 iounmap(base);
64 }
65
66 static void __init rb2011_setup(void)
67 {
68 ath79_register_m25p80(NULL);
69
70 rb2011_gmac_setup();
71
72 ath79_register_mdio(1, 0x0);
73 ath79_register_mdio(0, 0x0);
74
75 mdiobus_register_board_info(rb2011_mdio0_info,
76 ARRAY_SIZE(rb2011_mdio0_info));
77
78 /* GMAC0 is connected to an ar8327 switch */
79 ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
80 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
81 ath79_eth0_data.phy_mask = BIT(0);
82 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
83 ath79_eth0_pll_data.pll_1000 = 0x06000000;
84
85 ath79_register_eth(0);
86
87 /* GMAC1 is connected to the internal switch */
88 ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 5);
89 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
90 ath79_eth1_data.speed = SPEED_1000;
91 ath79_eth1_data.duplex = DUPLEX_FULL;
92
93 ath79_register_eth(1);
94 }
95
96 MIPS_MACHINE(ATH79_MACH_RB_2011L, "2011L", "MikroTik RouterBOARD 2011L",
97 rb2011_setup);