cpsw.c (56fdb2e04697c06b0af421cece0f360087af9cd1) cpsw.c (0ba517b18aac0ed747b0f0716ca87cedaa8e5491)
1/*
2 * Texas Instruments Ethernet Switch Driver
3 *
4 * Copyright (C) 2012 Texas Instruments
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.

--- 19 unchanged lines hidden (view full) ---

28#include <linux/phy.h>
29#include <linux/workqueue.h>
30#include <linux/delay.h>
31#include <linux/pm_runtime.h>
32#include <linux/of.h>
33#include <linux/of_net.h>
34#include <linux/of_device.h>
35#include <linux/if_vlan.h>
1/*
2 * Texas Instruments Ethernet Switch Driver
3 *
4 * Copyright (C) 2012 Texas Instruments
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.

--- 19 unchanged lines hidden (view full) ---

28#include <linux/phy.h>
29#include <linux/workqueue.h>
30#include <linux/delay.h>
31#include <linux/pm_runtime.h>
32#include <linux/of.h>
33#include <linux/of_net.h>
34#include <linux/of_device.h>
35#include <linux/if_vlan.h>
36#include <linux/mfd/syscon.h>
37#include <linux/regmap.h>
36
37#include <linux/pinctrl/consumer.h>
38
39#include "cpsw.h"
40#include "cpsw_ale.h"
41#include "cpts.h"
42#include "davinci_cpdma.h"
43

--- 1827 unchanged lines hidden (view full) ---

1871 struct cpsw_slave_data *data = priv->data.slave_data + slave_num;
1872
1873 slave->data = data;
1874 slave->regs = regs + slave_reg_ofs;
1875 slave->sliver = regs + sliver_reg_ofs;
1876 slave->port_vlan = data->dual_emac_res_vlan;
1877}
1878
38
39#include <linux/pinctrl/consumer.h>
40
41#include "cpsw.h"
42#include "cpsw_ale.h"
43#include "cpts.h"
44#include "davinci_cpdma.h"
45

--- 1827 unchanged lines hidden (view full) ---

1873 struct cpsw_slave_data *data = priv->data.slave_data + slave_num;
1874
1875 slave->data = data;
1876 slave->regs = regs + slave_reg_ofs;
1877 slave->sliver = regs + sliver_reg_ofs;
1878 slave->port_vlan = data->dual_emac_res_vlan;
1879}
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,
1880 struct platform_device *pdev)
1881{
1882 struct device_node *node = pdev->dev.of_node;
1883 struct device_node *slave_node;
1884 int i = 0, ret;
1885 u32 prop;
1886

--- 96 unchanged lines hidden (view full) ---

1983 if (!mdio) {
1984 dev_err(&pdev->dev, "Missing mdio platform device\n");
1985 return -EINVAL;
1986 }
1987 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
1988 PHY_ID_FMT, mdio->name, phyid);
1989
1990 mac_addr = of_get_mac_address(slave_node);
1911static int cpsw_probe_dt(struct cpsw_platform_data *data,
1912 struct platform_device *pdev)
1913{
1914 struct device_node *node = pdev->dev.of_node;
1915 struct device_node *slave_node;
1916 int i = 0, ret;
1917 u32 prop;
1918

--- 96 unchanged lines hidden (view full) ---

2015 if (!mdio) {
2016 dev_err(&pdev->dev, "Missing mdio platform device\n");
2017 return -EINVAL;
2018 }
2019 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
2020 PHY_ID_FMT, mdio->name, phyid);
2021
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
1994 slave_data->phy_if = of_get_phy_mode(slave_node);
1995 if (slave_data->phy_if < 0) {
1996 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
1997 i);
1998 return slave_data->phy_if;
1999 }
2000

--- 464 unchanged lines hidden ---
2033
2034 slave_data->phy_if = of_get_phy_mode(slave_node);
2035 if (slave_data->phy_if < 0) {
2036 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
2037 i);
2038 return slave_data->phy_if;
2039 }
2040

--- 464 unchanged lines hidden ---