aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Pargmann <mpa@pengutronix.de>2014-09-29 02:53:17 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-30 01:30:43 -0400
commit0ba517b18aac0ed747b0f0716ca87cedaa8e5491 (patch)
tree10a9589527dbc58271740f8cdab67ce9b3bcbc36
parent56fdb2e04697c06b0af421cece0f360087af9cd1 (diff)
net: cpsw: Add am33xx MACID readout
This patch adds a function to get the MACIDs from the am33xx SoC control module registers which hold unique vendor MACIDs. This is only used if of_get_mac_address() fails to get a valid mac address. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Reviewed-by: Wolfram Sang <wsa@the-dreams.de> Tested-by: Steven Rostedt <rostedt@goodmis.org> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--Documentation/devicetree/bindings/net/cpsw.txt4
-rw-r--r--drivers/net/ethernet/ti/Kconfig2
-rw-r--r--drivers/net/ethernet/ti/cpsw.c42
3 files changed, 47 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt
index 107caf174a0e..33fe8462edf4 100644
--- a/Documentation/devicetree/bindings/net/cpsw.txt
+++ b/Documentation/devicetree/bindings/net/cpsw.txt
@@ -24,6 +24,8 @@ Optional properties:
24- ti,hwmods : Must be "cpgmac0" 24- ti,hwmods : Must be "cpgmac0"
25- no_bd_ram : Must be 0 or 1 25- no_bd_ram : Must be 0 or 1
26- dual_emac : Specifies Switch to act as Dual EMAC 26- dual_emac : Specifies Switch to act as Dual EMAC
27- syscon : Phandle to the system control device node, which is
28 the control module device of the am33x
27 29
28Slave Properties: 30Slave Properties:
29Required properties: 31Required properties:
@@ -57,6 +59,7 @@ Examples:
57 active_slave = <0>; 59 active_slave = <0>;
58 cpts_clock_mult = <0x80000000>; 60 cpts_clock_mult = <0x80000000>;
59 cpts_clock_shift = <29>; 61 cpts_clock_shift = <29>;
62 syscon = <&cm>;
60 cpsw_emac0: slave@0 { 63 cpsw_emac0: slave@0 {
61 phy_id = <&davinci_mdio>, <0>; 64 phy_id = <&davinci_mdio>, <0>;
62 phy-mode = "rgmii-txid"; 65 phy-mode = "rgmii-txid";
@@ -85,6 +88,7 @@ Examples:
85 active_slave = <0>; 88 active_slave = <0>;
86 cpts_clock_mult = <0x80000000>; 89 cpts_clock_mult = <0x80000000>;
87 cpts_clock_shift = <29>; 90 cpts_clock_shift = <29>;
91 syscon = <&cm>;
88 cpsw_emac0: slave@0 { 92 cpsw_emac0: slave@0 {
89 phy_id = <&davinci_mdio>, <0>; 93 phy_id = <&davinci_mdio>, <0>;
90 phy-mode = "rgmii-txid"; 94 phy-mode = "rgmii-txid";
diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
index 1769700a6070..5d8cb7956113 100644
--- a/drivers/net/ethernet/ti/Kconfig
+++ b/drivers/net/ethernet/ti/Kconfig
@@ -62,6 +62,8 @@ config TI_CPSW
62 select TI_DAVINCI_CPDMA 62 select TI_DAVINCI_CPDMA
63 select TI_DAVINCI_MDIO 63 select TI_DAVINCI_MDIO
64 select TI_CPSW_PHY_SEL 64 select TI_CPSW_PHY_SEL
65 select MFD_SYSCON
66 select REGMAP
65 ---help--- 67 ---help---
66 This driver supports TI's CPSW Ethernet Switch. 68 This driver supports TI's CPSW Ethernet Switch.
67 69
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index d2988aeb6682..ab167dc49ce4 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -33,6 +33,8 @@
33#include <linux/of_net.h> 33#include <linux/of_net.h>
34#include <linux/of_device.h> 34#include <linux/of_device.h>
35#include <linux/if_vlan.h> 35#include <linux/if_vlan.h>
36#include <linux/mfd/syscon.h>
37#include <linux/regmap.h>
36 38
37#include <linux/pinctrl/consumer.h> 39#include <linux/pinctrl/consumer.h>
38 40
@@ -1876,6 +1878,36 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv,
1876 slave->port_vlan = data->dual_emac_res_vlan; 1878 slave->port_vlan = data->dual_emac_res_vlan;
1877} 1879}
1878 1880
1881#define AM33XX_CTRL_MAC_LO_REG(id) (0x630 + 0x8 * id)
1882#define AM33XX_CTRL_MAC_HI_REG(id) (0x630 + 0x8 * id + 0x4)
1883
1884static int cpsw_am33xx_cm_get_macid(struct device *dev, int slave,
1885 u8 *mac_addr)
1886{
1887 u32 macid_lo;
1888 u32 macid_hi;
1889 struct regmap *syscon;
1890
1891 syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
1892 if (IS_ERR(syscon)) {
1893 if (PTR_ERR(syscon) == -ENODEV)
1894 return 0;
1895 return PTR_ERR(syscon);
1896 }
1897
1898 regmap_read(syscon, AM33XX_CTRL_MAC_LO_REG(slave), &macid_lo);
1899 regmap_read(syscon, AM33XX_CTRL_MAC_HI_REG(slave), &macid_hi);
1900
1901 mac_addr[5] = (macid_lo >> 8) & 0xff;
1902 mac_addr[4] = macid_lo & 0xff;
1903 mac_addr[3] = (macid_hi >> 24) & 0xff;
1904 mac_addr[2] = (macid_hi >> 16) & 0xff;
1905 mac_addr[1] = (macid_hi >> 8) & 0xff;
1906 mac_addr[0] = macid_hi & 0xff;
1907
1908 return 0;
1909}
1910
1879static int cpsw_probe_dt(struct cpsw_platform_data *data, 1911static int cpsw_probe_dt(struct cpsw_platform_data *data,
1880 struct platform_device *pdev) 1912 struct platform_device *pdev)
1881{ 1913{
@@ -1988,8 +2020,16 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
1988 PHY_ID_FMT, mdio->name, phyid); 2020 PHY_ID_FMT, mdio->name, phyid);
1989 2021
1990 mac_addr = of_get_mac_address(slave_node); 2022 mac_addr = of_get_mac_address(slave_node);
1991 if (mac_addr) 2023 if (mac_addr) {
1992 memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN); 2024 memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN);
2025 } else {
2026 if (of_machine_is_compatible("ti,am33xx")) {
2027 ret = cpsw_am33xx_cm_get_macid(&pdev->dev, i,
2028 slave_data->mac_addr);
2029 if (ret)
2030 return ret;
2031 }
2032 }
1993 2033
1994 slave_data->phy_if = of_get_phy_mode(slave_node); 2034 slave_data->phy_if = of_get_phy_mode(slave_node);
1995 if (slave_data->phy_if < 0) { 2035 if (slave_data->phy_if < 0) {