Commit 54e6d7be authored by David S. Miller's avatar David S. Miller

Merge branch 'DSA-DPAA'

Madalin Bucur says:

====================
adapt DPAA drivers for DSA

Junote Cai reported that he was not able to get a DSA setup involving the
DPAA/FMAN driver to work and narrowed it down to of_find_net_device_by_node()
call in DSA setup. The initial attempt to fix this by adding of_node to the
platform device results in a second, failed, probing of the FMan MAC driver
against the new platform device created for the DPAA Ethernet driver.
Solve these issues by removing the of_node pointer from the platform device
and changing the net_dev dev to the of_device dev to ensure the DSA init
will be able to find the DPAA net_dev using of_find_net_device_by_node().
Several changes were required to enable this solution: refactoring the
adjust_link (also resulted in lesser, cleaner code) and renaming the fman
kernel modules to keep the legacy udev rules happy.

Changes in v2:

 - fix issue on error path in "dpaa_eth: change device used" patch
 - cleanup the dpaa_eth_probe() error paths

Changes in v3:

 - remove obsolete comment in moved code
 - add explanation for module rename
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 2dc7c1fe f1851a69
...@@ -385,34 +385,19 @@ static int dpaa_setup_tc(struct net_device *net_dev, enum tc_setup_type type, ...@@ -385,34 +385,19 @@ static int dpaa_setup_tc(struct net_device *net_dev, enum tc_setup_type type,
static struct mac_device *dpaa_mac_dev_get(struct platform_device *pdev) static struct mac_device *dpaa_mac_dev_get(struct platform_device *pdev)
{ {
struct platform_device *of_dev;
struct dpaa_eth_data *eth_data; struct dpaa_eth_data *eth_data;
struct device *dpaa_dev, *dev; struct device *dpaa_dev;
struct device_node *mac_node;
struct mac_device *mac_dev; struct mac_device *mac_dev;
dpaa_dev = &pdev->dev; dpaa_dev = &pdev->dev;
eth_data = dpaa_dev->platform_data; eth_data = dpaa_dev->platform_data;
if (!eth_data) if (!eth_data) {
dev_err(dpaa_dev, "eth_data missing\n");
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
mac_node = eth_data->mac_node;
of_dev = of_find_device_by_node(mac_node);
if (!of_dev) {
dev_err(dpaa_dev, "of_find_device_by_node(%pOF) failed\n",
mac_node);
of_node_put(mac_node);
return ERR_PTR(-EINVAL);
} }
of_node_put(mac_node); mac_dev = eth_data->mac_dev;
dev = &of_dev->dev;
mac_dev = dev_get_drvdata(dev);
if (!mac_dev) { if (!mac_dev) {
dev_err(dpaa_dev, "dev_get_drvdata(%s) failed\n", dev_err(dpaa_dev, "mac_dev missing\n");
dev_name(dev));
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -2435,6 +2420,44 @@ static void dpaa_eth_napi_disable(struct dpaa_priv *priv) ...@@ -2435,6 +2420,44 @@ static void dpaa_eth_napi_disable(struct dpaa_priv *priv)
} }
} }
static void dpaa_adjust_link(struct net_device *net_dev)
{
struct mac_device *mac_dev;
struct dpaa_priv *priv;
priv = netdev_priv(net_dev);
mac_dev = priv->mac_dev;
mac_dev->adjust_link(mac_dev);
}
static int dpaa_phy_init(struct net_device *net_dev)
{
struct mac_device *mac_dev;
struct phy_device *phy_dev;
struct dpaa_priv *priv;
priv = netdev_priv(net_dev);
mac_dev = priv->mac_dev;
phy_dev = of_phy_connect(net_dev, mac_dev->phy_node,
&dpaa_adjust_link, 0,
mac_dev->phy_if);
if (!phy_dev) {
netif_err(priv, ifup, net_dev, "init_phy() failed\n");
return -ENODEV;
}
/* Remove any features not supported by the controller */
phy_dev->supported &= mac_dev->if_support;
phy_dev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause);
phy_dev->advertising = phy_dev->supported;
mac_dev->phy_dev = phy_dev;
net_dev->phydev = phy_dev;
return 0;
}
static int dpaa_open(struct net_device *net_dev) static int dpaa_open(struct net_device *net_dev)
{ {
struct mac_device *mac_dev; struct mac_device *mac_dev;
...@@ -2445,12 +2468,8 @@ static int dpaa_open(struct net_device *net_dev) ...@@ -2445,12 +2468,8 @@ static int dpaa_open(struct net_device *net_dev)
mac_dev = priv->mac_dev; mac_dev = priv->mac_dev;
dpaa_eth_napi_enable(priv); dpaa_eth_napi_enable(priv);
net_dev->phydev = mac_dev->init_phy(net_dev, priv->mac_dev); if (dpaa_phy_init(net_dev))
if (!net_dev->phydev) {
netif_err(priv, ifup, net_dev, "init_phy() failed\n");
err = -ENODEV;
goto phy_init_failed; goto phy_init_failed;
}
for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) { for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
err = fman_port_enable(mac_dev->port[i]); err = fman_port_enable(mac_dev->port[i]);
...@@ -2658,7 +2677,13 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2658,7 +2677,13 @@ static int dpaa_eth_probe(struct platform_device *pdev)
int err = 0, i, channel; int err = 0, i, channel;
struct device *dev; struct device *dev;
dev = &pdev->dev; /* device used for DMA mapping */
dev = pdev->dev.parent;
err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(40));
if (err) {
dev_err(dev, "dma_coerce_mask_and_coherent() failed\n");
return err;
}
/* Allocate this early, so we can store relevant information in /* Allocate this early, so we can store relevant information in
* the private area * the private area
...@@ -2666,7 +2691,7 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2666,7 +2691,7 @@ static int dpaa_eth_probe(struct platform_device *pdev)
net_dev = alloc_etherdev_mq(sizeof(*priv), DPAA_ETH_TXQ_NUM); net_dev = alloc_etherdev_mq(sizeof(*priv), DPAA_ETH_TXQ_NUM);
if (!net_dev) { if (!net_dev) {
dev_err(dev, "alloc_etherdev_mq() failed\n"); dev_err(dev, "alloc_etherdev_mq() failed\n");
goto alloc_etherdev_mq_failed; return -ENOMEM;
} }
/* Do this here, so we can be verbose early */ /* Do this here, so we can be verbose early */
...@@ -2682,7 +2707,7 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2682,7 +2707,7 @@ static int dpaa_eth_probe(struct platform_device *pdev)
if (IS_ERR(mac_dev)) { if (IS_ERR(mac_dev)) {
dev_err(dev, "dpaa_mac_dev_get() failed\n"); dev_err(dev, "dpaa_mac_dev_get() failed\n");
err = PTR_ERR(mac_dev); err = PTR_ERR(mac_dev);
goto mac_probe_failed; goto free_netdev;
} }
/* If fsl_fm_max_frm is set to a higher value than the all-common 1500, /* If fsl_fm_max_frm is set to a higher value than the all-common 1500,
...@@ -2700,21 +2725,13 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2700,21 +2725,13 @@ static int dpaa_eth_probe(struct platform_device *pdev)
priv->buf_layout[RX].priv_data_size = DPAA_RX_PRIV_DATA_SIZE; /* Rx */ priv->buf_layout[RX].priv_data_size = DPAA_RX_PRIV_DATA_SIZE; /* Rx */
priv->buf_layout[TX].priv_data_size = DPAA_TX_PRIV_DATA_SIZE; /* Tx */ priv->buf_layout[TX].priv_data_size = DPAA_TX_PRIV_DATA_SIZE; /* Tx */
/* device used for DMA mapping */
set_dma_ops(dev, get_dma_ops(&pdev->dev));
err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(40));
if (err) {
dev_err(dev, "dma_coerce_mask_and_coherent() failed\n");
goto dev_mask_failed;
}
/* bp init */ /* bp init */
for (i = 0; i < DPAA_BPS_NUM; i++) { for (i = 0; i < DPAA_BPS_NUM; i++) {
int err; int err;
dpaa_bps[i] = dpaa_bp_alloc(dev); dpaa_bps[i] = dpaa_bp_alloc(dev);
if (IS_ERR(dpaa_bps[i])) if (IS_ERR(dpaa_bps[i]))
return PTR_ERR(dpaa_bps[i]); goto free_dpaa_bps;
/* the raw size of the buffers used for reception */ /* the raw size of the buffers used for reception */
dpaa_bps[i]->raw_size = bpool_buffer_raw_size(i, DPAA_BPS_NUM); dpaa_bps[i]->raw_size = bpool_buffer_raw_size(i, DPAA_BPS_NUM);
/* avoid runtime computations by keeping the usable size here */ /* avoid runtime computations by keeping the usable size here */
...@@ -2722,11 +2739,8 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2722,11 +2739,8 @@ static int dpaa_eth_probe(struct platform_device *pdev)
dpaa_bps[i]->dev = dev; dpaa_bps[i]->dev = dev;
err = dpaa_bp_alloc_pool(dpaa_bps[i]); err = dpaa_bp_alloc_pool(dpaa_bps[i]);
if (err < 0) { if (err < 0)
dpaa_bps_free(priv); goto free_dpaa_bps;
priv->dpaa_bps[i] = NULL;
goto bp_create_failed;
}
priv->dpaa_bps[i] = dpaa_bps[i]; priv->dpaa_bps[i] = dpaa_bps[i];
} }
...@@ -2737,7 +2751,7 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2737,7 +2751,7 @@ static int dpaa_eth_probe(struct platform_device *pdev)
err = dpaa_alloc_all_fqs(dev, &priv->dpaa_fq_list, &port_fqs); err = dpaa_alloc_all_fqs(dev, &priv->dpaa_fq_list, &port_fqs);
if (err < 0) { if (err < 0) {
dev_err(dev, "dpaa_alloc_all_fqs() failed\n"); dev_err(dev, "dpaa_alloc_all_fqs() failed\n");
goto fq_probe_failed; goto free_dpaa_bps;
} }
priv->mac_dev = mac_dev; priv->mac_dev = mac_dev;
...@@ -2746,7 +2760,7 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2746,7 +2760,7 @@ static int dpaa_eth_probe(struct platform_device *pdev)
if (channel < 0) { if (channel < 0) {
dev_err(dev, "dpaa_get_channel() failed\n"); dev_err(dev, "dpaa_get_channel() failed\n");
err = channel; err = channel;
goto get_channel_failed; goto free_dpaa_bps;
} }
priv->channel = (u16)channel; priv->channel = (u16)channel;
...@@ -2766,20 +2780,20 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2766,20 +2780,20 @@ static int dpaa_eth_probe(struct platform_device *pdev)
err = dpaa_eth_cgr_init(priv); err = dpaa_eth_cgr_init(priv);
if (err < 0) { if (err < 0) {
dev_err(dev, "Error initializing CGR\n"); dev_err(dev, "Error initializing CGR\n");
goto tx_cgr_init_failed; goto free_dpaa_bps;
} }
err = dpaa_ingress_cgr_init(priv); err = dpaa_ingress_cgr_init(priv);
if (err < 0) { if (err < 0) {
dev_err(dev, "Error initializing ingress CGR\n"); dev_err(dev, "Error initializing ingress CGR\n");
goto rx_cgr_init_failed; goto delete_egress_cgr;
} }
/* Add the FQs to the interface, and make them active */ /* Add the FQs to the interface, and make them active */
list_for_each_entry_safe(dpaa_fq, tmp, &priv->dpaa_fq_list, list) { list_for_each_entry_safe(dpaa_fq, tmp, &priv->dpaa_fq_list, list) {
err = dpaa_fq_init(dpaa_fq, false); err = dpaa_fq_init(dpaa_fq, false);
if (err < 0) if (err < 0)
goto fq_alloc_failed; goto free_dpaa_fqs;
} }
priv->tx_headroom = dpaa_get_headroom(&priv->buf_layout[TX]); priv->tx_headroom = dpaa_get_headroom(&priv->buf_layout[TX]);
...@@ -2789,7 +2803,7 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2789,7 +2803,7 @@ static int dpaa_eth_probe(struct platform_device *pdev)
err = dpaa_eth_init_ports(mac_dev, dpaa_bps, DPAA_BPS_NUM, &port_fqs, err = dpaa_eth_init_ports(mac_dev, dpaa_bps, DPAA_BPS_NUM, &port_fqs,
&priv->buf_layout[0], dev); &priv->buf_layout[0], dev);
if (err) if (err)
goto init_ports_failed; goto free_dpaa_fqs;
/* Rx traffic distribution based on keygen hashing defaults to on */ /* Rx traffic distribution based on keygen hashing defaults to on */
priv->keygen_in_use = true; priv->keygen_in_use = true;
...@@ -2798,7 +2812,7 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2798,7 +2812,7 @@ static int dpaa_eth_probe(struct platform_device *pdev)
if (!priv->percpu_priv) { if (!priv->percpu_priv) {
dev_err(dev, "devm_alloc_percpu() failed\n"); dev_err(dev, "devm_alloc_percpu() failed\n");
err = -ENOMEM; err = -ENOMEM;
goto alloc_percpu_failed; goto free_dpaa_fqs;
} }
for_each_possible_cpu(i) { for_each_possible_cpu(i) {
percpu_priv = per_cpu_ptr(priv->percpu_priv, i); percpu_priv = per_cpu_ptr(priv->percpu_priv, i);
...@@ -2811,11 +2825,11 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2811,11 +2825,11 @@ static int dpaa_eth_probe(struct platform_device *pdev)
/* Initialize NAPI */ /* Initialize NAPI */
err = dpaa_napi_add(net_dev); err = dpaa_napi_add(net_dev);
if (err < 0) if (err < 0)
goto napi_add_failed; goto delete_dpaa_napi;
err = dpaa_netdev_init(net_dev, &dpaa_ops, tx_timeout); err = dpaa_netdev_init(net_dev, &dpaa_ops, tx_timeout);
if (err < 0) if (err < 0)
goto netdev_init_failed; goto delete_dpaa_napi;
dpaa_eth_sysfs_init(&net_dev->dev); dpaa_eth_sysfs_init(&net_dev->dev);
...@@ -2824,32 +2838,21 @@ static int dpaa_eth_probe(struct platform_device *pdev) ...@@ -2824,32 +2838,21 @@ static int dpaa_eth_probe(struct platform_device *pdev)
return 0; return 0;
netdev_init_failed: delete_dpaa_napi:
napi_add_failed:
dpaa_napi_del(net_dev); dpaa_napi_del(net_dev);
alloc_percpu_failed: free_dpaa_fqs:
init_ports_failed:
dpaa_fq_free(dev, &priv->dpaa_fq_list); dpaa_fq_free(dev, &priv->dpaa_fq_list);
fq_alloc_failed:
qman_delete_cgr_safe(&priv->ingress_cgr); qman_delete_cgr_safe(&priv->ingress_cgr);
qman_release_cgrid(priv->ingress_cgr.cgrid); qman_release_cgrid(priv->ingress_cgr.cgrid);
rx_cgr_init_failed: delete_egress_cgr:
qman_delete_cgr_safe(&priv->cgr_data.cgr); qman_delete_cgr_safe(&priv->cgr_data.cgr);
qman_release_cgrid(priv->cgr_data.cgr.cgrid); qman_release_cgrid(priv->cgr_data.cgr.cgrid);
tx_cgr_init_failed: free_dpaa_bps:
get_channel_failed:
dpaa_bps_free(priv); dpaa_bps_free(priv);
bp_create_failed: free_netdev:
fq_probe_failed:
dev_mask_failed:
mac_probe_failed:
dev_set_drvdata(dev, NULL); dev_set_drvdata(dev, NULL);
free_netdev(net_dev); free_netdev(net_dev);
alloc_etherdev_mq_failed:
for (i = 0; i < DPAA_BPS_NUM && dpaa_bps[i]; i++) {
if (atomic_read(&dpaa_bps[i]->refs) == 0)
devm_kfree(dev, dpaa_bps[i]);
}
return err; return err;
} }
......
subdir-ccflags-y += -I$(srctree)/drivers/net/ethernet/freescale/fman subdir-ccflags-y += -I$(srctree)/drivers/net/ethernet/freescale/fman
obj-$(CONFIG_FSL_FMAN) += fsl_fman.o obj-$(CONFIG_FSL_FMAN) += fsl_dpaa_fman.o
obj-$(CONFIG_FSL_FMAN) += fsl_fman_port.o obj-$(CONFIG_FSL_FMAN) += fsl_dpaa_fman_port.o
obj-$(CONFIG_FSL_FMAN) += fsl_mac.o obj-$(CONFIG_FSL_FMAN) += fsl_dpaa_mac.o
fsl_fman-objs := fman_muram.o fman.o fman_sp.o fman_keygen.o fsl_dpaa_fman-objs := fman_muram.o fman.o fman_sp.o fman_keygen.o
fsl_fman_port-objs := fman_port.o fsl_dpaa_fman_port-objs := fman_port.o
fsl_mac-objs:= mac.o fman_dtsec.o fman_memac.o fman_tgec.o fsl_dpaa_mac-objs:= mac.o fman_dtsec.o fman_memac.o fman_tgec.o
...@@ -57,9 +57,7 @@ struct mac_priv_s { ...@@ -57,9 +57,7 @@ struct mac_priv_s {
struct device *dev; struct device *dev;
void __iomem *vaddr; void __iomem *vaddr;
u8 cell_index; u8 cell_index;
phy_interface_t phy_if;
struct fman *fman; struct fman *fman;
struct device_node *phy_node;
struct device_node *internal_phy_node; struct device_node *internal_phy_node;
/* List of multicast addresses */ /* List of multicast addresses */
struct list_head mc_addr_list; struct list_head mc_addr_list;
...@@ -106,7 +104,7 @@ static void set_fman_mac_params(struct mac_device *mac_dev, ...@@ -106,7 +104,7 @@ static void set_fman_mac_params(struct mac_device *mac_dev,
resource_size(mac_dev->res)); resource_size(mac_dev->res));
memcpy(&params->addr, mac_dev->addr, sizeof(mac_dev->addr)); memcpy(&params->addr, mac_dev->addr, sizeof(mac_dev->addr));
params->max_speed = priv->max_speed; params->max_speed = priv->max_speed;
params->phy_if = priv->phy_if; params->phy_if = mac_dev->phy_if;
params->basex_if = false; params->basex_if = false;
params->mac_id = priv->cell_index; params->mac_id = priv->cell_index;
params->fm = (void *)priv->fman; params->fm = (void *)priv->fman;
...@@ -419,15 +417,12 @@ void fman_get_pause_cfg(struct mac_device *mac_dev, bool *rx_pause, ...@@ -419,15 +417,12 @@ void fman_get_pause_cfg(struct mac_device *mac_dev, bool *rx_pause,
} }
EXPORT_SYMBOL(fman_get_pause_cfg); EXPORT_SYMBOL(fman_get_pause_cfg);
static void adjust_link_void(struct net_device *net_dev) static void adjust_link_void(struct mac_device *mac_dev)
{ {
} }
static void adjust_link_dtsec(struct net_device *net_dev) static void adjust_link_dtsec(struct mac_device *mac_dev)
{ {
struct device *dev = net_dev->dev.parent;
struct dpaa_eth_data *eth_data = dev->platform_data;
struct mac_device *mac_dev = eth_data->mac_dev;
struct phy_device *phy_dev = mac_dev->phy_dev; struct phy_device *phy_dev = mac_dev->phy_dev;
struct fman_mac *fman_mac; struct fman_mac *fman_mac;
bool rx_pause, tx_pause; bool rx_pause, tx_pause;
...@@ -444,14 +439,12 @@ static void adjust_link_dtsec(struct net_device *net_dev) ...@@ -444,14 +439,12 @@ static void adjust_link_dtsec(struct net_device *net_dev)
fman_get_pause_cfg(mac_dev, &rx_pause, &tx_pause); fman_get_pause_cfg(mac_dev, &rx_pause, &tx_pause);
err = fman_set_mac_active_pause(mac_dev, rx_pause, tx_pause); err = fman_set_mac_active_pause(mac_dev, rx_pause, tx_pause);
if (err < 0) if (err < 0)
netdev_err(net_dev, "fman_set_mac_active_pause() = %d\n", err); dev_err(mac_dev->priv->dev, "fman_set_mac_active_pause() = %d\n",
err);
} }
static void adjust_link_memac(struct net_device *net_dev) static void adjust_link_memac(struct mac_device *mac_dev)
{ {
struct device *dev = net_dev->dev.parent;
struct dpaa_eth_data *eth_data = dev->platform_data;
struct mac_device *mac_dev = eth_data->mac_dev;
struct phy_device *phy_dev = mac_dev->phy_dev; struct phy_device *phy_dev = mac_dev->phy_dev;
struct fman_mac *fman_mac; struct fman_mac *fman_mac;
bool rx_pause, tx_pause; bool rx_pause, tx_pause;
...@@ -463,60 +456,12 @@ static void adjust_link_memac(struct net_device *net_dev) ...@@ -463,60 +456,12 @@ static void adjust_link_memac(struct net_device *net_dev)
fman_get_pause_cfg(mac_dev, &rx_pause, &tx_pause); fman_get_pause_cfg(mac_dev, &rx_pause, &tx_pause);
err = fman_set_mac_active_pause(mac_dev, rx_pause, tx_pause); err = fman_set_mac_active_pause(mac_dev, rx_pause, tx_pause);
if (err < 0) if (err < 0)
netdev_err(net_dev, "fman_set_mac_active_pause() = %d\n", err); dev_err(mac_dev->priv->dev, "fman_set_mac_active_pause() = %d\n",
} err);
/* Initializes driver's PHY state, and attaches to the PHY.
* Returns 0 on success.
*/
static struct phy_device *init_phy(struct net_device *net_dev,
struct mac_device *mac_dev,
void (*adj_lnk)(struct net_device *))
{
struct phy_device *phy_dev;
struct mac_priv_s *priv = mac_dev->priv;
phy_dev = of_phy_connect(net_dev, priv->phy_node, adj_lnk, 0,
priv->phy_if);
if (!phy_dev) {
netdev_err(net_dev, "Could not connect to PHY\n");
return NULL;
}
/* Remove any features not supported by the controller */
phy_dev->supported &= mac_dev->if_support;
/* Enable the symmetric and asymmetric PAUSE frame advertisements,
* as most of the PHY drivers do not enable them by default.
*/
phy_dev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause);
phy_dev->advertising = phy_dev->supported;
mac_dev->phy_dev = phy_dev;
return phy_dev;
}
static struct phy_device *dtsec_init_phy(struct net_device *net_dev,
struct mac_device *mac_dev)
{
return init_phy(net_dev, mac_dev, &adjust_link_dtsec);
}
static struct phy_device *tgec_init_phy(struct net_device *net_dev,
struct mac_device *mac_dev)
{
return init_phy(net_dev, mac_dev, adjust_link_void);
}
static struct phy_device *memac_init_phy(struct net_device *net_dev,
struct mac_device *mac_dev)
{
return init_phy(net_dev, mac_dev, &adjust_link_memac);
} }
static void setup_dtsec(struct mac_device *mac_dev) static void setup_dtsec(struct mac_device *mac_dev)
{ {
mac_dev->init_phy = dtsec_init_phy;
mac_dev->init = dtsec_initialization; mac_dev->init = dtsec_initialization;
mac_dev->set_promisc = dtsec_set_promiscuous; mac_dev->set_promisc = dtsec_set_promiscuous;
mac_dev->change_addr = dtsec_modify_mac_address; mac_dev->change_addr = dtsec_modify_mac_address;
...@@ -528,14 +473,13 @@ static void setup_dtsec(struct mac_device *mac_dev) ...@@ -528,14 +473,13 @@ static void setup_dtsec(struct mac_device *mac_dev)
mac_dev->set_multi = set_multi; mac_dev->set_multi = set_multi;
mac_dev->start = start; mac_dev->start = start;
mac_dev->stop = stop; mac_dev->stop = stop;
mac_dev->adjust_link = adjust_link_dtsec;
mac_dev->priv->enable = dtsec_enable; mac_dev->priv->enable = dtsec_enable;
mac_dev->priv->disable = dtsec_disable; mac_dev->priv->disable = dtsec_disable;
} }
static void setup_tgec(struct mac_device *mac_dev) static void setup_tgec(struct mac_device *mac_dev)
{ {
mac_dev->init_phy = tgec_init_phy;
mac_dev->init = tgec_initialization; mac_dev->init = tgec_initialization;
mac_dev->set_promisc = tgec_set_promiscuous; mac_dev->set_promisc = tgec_set_promiscuous;
mac_dev->change_addr = tgec_modify_mac_address; mac_dev->change_addr = tgec_modify_mac_address;
...@@ -547,14 +491,13 @@ static void setup_tgec(struct mac_device *mac_dev) ...@@ -547,14 +491,13 @@ static void setup_tgec(struct mac_device *mac_dev)
mac_dev->set_multi = set_multi; mac_dev->set_multi = set_multi;
mac_dev->start = start; mac_dev->start = start;
mac_dev->stop = stop; mac_dev->stop = stop;
mac_dev->adjust_link = adjust_link_void;
mac_dev->priv->enable = tgec_enable; mac_dev->priv->enable = tgec_enable;
mac_dev->priv->disable = tgec_disable; mac_dev->priv->disable = tgec_disable;
} }
static void setup_memac(struct mac_device *mac_dev) static void setup_memac(struct mac_device *mac_dev)
{ {
mac_dev->init_phy = memac_init_phy;
mac_dev->init = memac_initialization; mac_dev->init = memac_initialization;
mac_dev->set_promisc = memac_set_promiscuous; mac_dev->set_promisc = memac_set_promiscuous;
mac_dev->change_addr = memac_modify_mac_address; mac_dev->change_addr = memac_modify_mac_address;
...@@ -566,7 +509,7 @@ static void setup_memac(struct mac_device *mac_dev) ...@@ -566,7 +509,7 @@ static void setup_memac(struct mac_device *mac_dev)
mac_dev->set_multi = set_multi; mac_dev->set_multi = set_multi;
mac_dev->start = start; mac_dev->start = start;
mac_dev->stop = stop; mac_dev->stop = stop;
mac_dev->adjust_link = adjust_link_memac;
mac_dev->priv->enable = memac_enable; mac_dev->priv->enable = memac_enable;
mac_dev->priv->disable = memac_disable; mac_dev->priv->disable = memac_disable;
} }
...@@ -599,8 +542,7 @@ static const u16 phy2speed[] = { ...@@ -599,8 +542,7 @@ static const u16 phy2speed[] = {
}; };
static struct platform_device *dpaa_eth_add_device(int fman_id, static struct platform_device *dpaa_eth_add_device(int fman_id,
struct mac_device *mac_dev, struct mac_device *mac_dev)
struct device_node *node)
{ {
struct platform_device *pdev; struct platform_device *pdev;
struct dpaa_eth_data data; struct dpaa_eth_data data;
...@@ -613,17 +555,14 @@ static struct platform_device *dpaa_eth_add_device(int fman_id, ...@@ -613,17 +555,14 @@ static struct platform_device *dpaa_eth_add_device(int fman_id,
data.mac_dev = mac_dev; data.mac_dev = mac_dev;
data.mac_hw_id = priv->cell_index; data.mac_hw_id = priv->cell_index;
data.fman_hw_id = fman_id; data.fman_hw_id = fman_id;
data.mac_node = node;
mutex_lock(&eth_lock); mutex_lock(&eth_lock);
pdev = platform_device_alloc("dpaa-ethernet", dpaa_eth_dev_cnt); pdev = platform_device_alloc("dpaa-ethernet", dpaa_eth_dev_cnt);
if (!pdev) { if (!pdev) {
ret = -ENOMEM; ret = -ENOMEM;
goto no_mem; goto no_mem;
} }
pdev->dev.of_node = node;
pdev->dev.parent = priv->dev; pdev->dev.parent = priv->dev;
set_dma_ops(&pdev->dev, get_dma_ops(priv->dev)); set_dma_ops(&pdev->dev, get_dma_ops(priv->dev));
...@@ -706,9 +645,6 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -706,9 +645,6 @@ static int mac_probe(struct platform_device *_of_dev)
goto _return; goto _return;
} }
/* Register mac_dev */
dev_set_drvdata(dev, mac_dev);
INIT_LIST_HEAD(&priv->mc_addr_list); INIT_LIST_HEAD(&priv->mc_addr_list);
/* Get the FM node */ /* Get the FM node */
...@@ -717,7 +653,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -717,7 +653,7 @@ static int mac_probe(struct platform_device *_of_dev)
dev_err(dev, "of_get_parent(%pOF) failed\n", dev_err(dev, "of_get_parent(%pOF) failed\n",
mac_node); mac_node);
err = -EINVAL; err = -EINVAL;
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
of_dev = of_find_device_by_node(dev_node); of_dev = of_find_device_by_node(dev_node);
...@@ -751,7 +687,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -751,7 +687,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err < 0) { if (err < 0) {
dev_err(dev, "of_address_to_resource(%pOF) = %d\n", dev_err(dev, "of_address_to_resource(%pOF) = %d\n",
mac_node, err); mac_node, err);
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
mac_dev->res = __devm_request_region(dev, mac_dev->res = __devm_request_region(dev,
...@@ -761,7 +697,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -761,7 +697,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!mac_dev->res) { if (!mac_dev->res) {
dev_err(dev, "__devm_request_mem_region(mac) failed\n"); dev_err(dev, "__devm_request_mem_region(mac) failed\n");
err = -EBUSY; err = -EBUSY;
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
priv->vaddr = devm_ioremap(dev, mac_dev->res->start, priv->vaddr = devm_ioremap(dev, mac_dev->res->start,
...@@ -769,7 +705,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -769,7 +705,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!priv->vaddr) { if (!priv->vaddr) {
dev_err(dev, "devm_ioremap() failed\n"); dev_err(dev, "devm_ioremap() failed\n");
err = -EIO; err = -EIO;
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
if (!of_device_is_available(mac_node)) { if (!of_device_is_available(mac_node)) {
...@@ -786,7 +722,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -786,7 +722,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err) { if (err) {
dev_err(dev, "failed to read cell-index for %pOF\n", mac_node); dev_err(dev, "failed to read cell-index for %pOF\n", mac_node);
err = -EINVAL; err = -EINVAL;
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
priv->cell_index = (u8)val; priv->cell_index = (u8)val;
...@@ -795,7 +731,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -795,7 +731,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!mac_addr) { if (!mac_addr) {
dev_err(dev, "of_get_mac_address(%pOF) failed\n", mac_node); dev_err(dev, "of_get_mac_address(%pOF) failed\n", mac_node);
err = -EINVAL; err = -EINVAL;
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
memcpy(mac_dev->addr, mac_addr, sizeof(mac_dev->addr)); memcpy(mac_dev->addr, mac_addr, sizeof(mac_dev->addr));
...@@ -805,14 +741,14 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -805,14 +741,14 @@ static int mac_probe(struct platform_device *_of_dev)
dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n", dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n",
mac_node); mac_node);
err = nph; err = nph;
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
if (nph != ARRAY_SIZE(mac_dev->port)) { if (nph != ARRAY_SIZE(mac_dev->port)) {
dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n", dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n",
mac_node); mac_node);
err = -EINVAL; err = -EINVAL;
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) { for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
...@@ -851,13 +787,13 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -851,13 +787,13 @@ static int mac_probe(struct platform_device *_of_dev)
mac_node); mac_node);
phy_if = PHY_INTERFACE_MODE_SGMII; phy_if = PHY_INTERFACE_MODE_SGMII;
} }
priv->phy_if = phy_if; mac_dev->phy_if = phy_if;
priv->speed = phy2speed[priv->phy_if]; priv->speed = phy2speed[mac_dev->phy_if];
priv->max_speed = priv->speed; priv->max_speed = priv->speed;
mac_dev->if_support = DTSEC_SUPPORTED; mac_dev->if_support = DTSEC_SUPPORTED;
/* We don't support half-duplex in SGMII mode */ /* We don't support half-duplex in SGMII mode */
if (priv->phy_if == PHY_INTERFACE_MODE_SGMII) if (mac_dev->phy_if == PHY_INTERFACE_MODE_SGMII)
mac_dev->if_support &= ~(SUPPORTED_10baseT_Half | mac_dev->if_support &= ~(SUPPORTED_10baseT_Half |
SUPPORTED_100baseT_Half); SUPPORTED_100baseT_Half);
...@@ -866,30 +802,30 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -866,30 +802,30 @@ static int mac_probe(struct platform_device *_of_dev)
mac_dev->if_support |= SUPPORTED_1000baseT_Full; mac_dev->if_support |= SUPPORTED_1000baseT_Full;
/* The 10G interface only supports one mode */ /* The 10G interface only supports one mode */
if (priv->phy_if == PHY_INTERFACE_MODE_XGMII) if (mac_dev->phy_if == PHY_INTERFACE_MODE_XGMII)
mac_dev->if_support = SUPPORTED_10000baseT_Full; mac_dev->if_support = SUPPORTED_10000baseT_Full;
/* Get the rest of the PHY information */ /* Get the rest of the PHY information */
priv->phy_node = of_parse_phandle(mac_node, "phy-handle", 0); mac_dev->phy_node = of_parse_phandle(mac_node, "phy-handle", 0);
if (!priv->phy_node && of_phy_is_fixed_link(mac_node)) { if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) {
struct phy_device *phy; struct phy_device *phy;
err = of_phy_register_fixed_link(mac_node); err = of_phy_register_fixed_link(mac_node);
if (err) if (err)
goto _return_dev_set_drvdata; goto _return_of_get_parent;
priv->fixed_link = kzalloc(sizeof(*priv->fixed_link), priv->fixed_link = kzalloc(sizeof(*priv->fixed_link),
GFP_KERNEL); GFP_KERNEL);
if (!priv->fixed_link) { if (!priv->fixed_link) {
err = -ENOMEM; err = -ENOMEM;
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
priv->phy_node = of_node_get(mac_node); mac_dev->phy_node = of_node_get(mac_node);
phy = of_phy_find_device(priv->phy_node); phy = of_phy_find_device(mac_dev->phy_node);
if (!phy) { if (!phy) {
err = -EINVAL; err = -EINVAL;
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
priv->fixed_link->link = phy->link; priv->fixed_link->link = phy->link;
...@@ -904,8 +840,8 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -904,8 +840,8 @@ static int mac_probe(struct platform_device *_of_dev)
err = mac_dev->init(mac_dev); err = mac_dev->init(mac_dev);
if (err < 0) { if (err < 0) {
dev_err(dev, "mac_dev->init() = %d\n", err); dev_err(dev, "mac_dev->init() = %d\n", err);
of_node_put(priv->phy_node); of_node_put(mac_dev->phy_node);
goto _return_dev_set_drvdata; goto _return_of_get_parent;
} }
/* pause frame autonegotiation enabled */ /* pause frame autonegotiation enabled */
...@@ -926,7 +862,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -926,7 +862,7 @@ static int mac_probe(struct platform_device *_of_dev)
mac_dev->addr[0], mac_dev->addr[1], mac_dev->addr[2], mac_dev->addr[0], mac_dev->addr[1], mac_dev->addr[2],
mac_dev->addr[3], mac_dev->addr[4], mac_dev->addr[5]); mac_dev->addr[3], mac_dev->addr[4], mac_dev->addr[5]);
priv->eth_dev = dpaa_eth_add_device(fman_id, mac_dev, mac_node); priv->eth_dev = dpaa_eth_add_device(fman_id, mac_dev);
if (IS_ERR(priv->eth_dev)) { if (IS_ERR(priv->eth_dev)) {
dev_err(dev, "failed to add Ethernet platform device for MAC %d\n", dev_err(dev, "failed to add Ethernet platform device for MAC %d\n",
priv->cell_index); priv->cell_index);
...@@ -937,9 +873,8 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -937,9 +873,8 @@ static int mac_probe(struct platform_device *_of_dev)
_return_of_node_put: _return_of_node_put:
of_node_put(dev_node); of_node_put(dev_node);
_return_dev_set_drvdata: _return_of_get_parent:
kfree(priv->fixed_link); kfree(priv->fixed_link);
dev_set_drvdata(dev, NULL);
_return: _return:
return err; return err;
} }
......
...@@ -50,6 +50,8 @@ struct mac_device { ...@@ -50,6 +50,8 @@ struct mac_device {
struct fman_port *port[2]; struct fman_port *port[2];
u32 if_support; u32 if_support;
struct phy_device *phy_dev; struct phy_device *phy_dev;
phy_interface_t phy_if;
struct device_node *phy_node;
bool autoneg_pause; bool autoneg_pause;
bool rx_pause_req; bool rx_pause_req;
...@@ -58,11 +60,10 @@ struct mac_device { ...@@ -58,11 +60,10 @@ struct mac_device {
bool tx_pause_active; bool tx_pause_active;
bool promisc; bool promisc;
struct phy_device *(*init_phy)(struct net_device *net_dev,
struct mac_device *mac_dev);
int (*init)(struct mac_device *mac_dev); int (*init)(struct mac_device *mac_dev);
int (*start)(struct mac_device *mac_dev); int (*start)(struct mac_device *mac_dev);
int (*stop)(struct mac_device *mac_dev); int (*stop)(struct mac_device *mac_dev);
void (*adjust_link)(struct mac_device *mac_dev);
int (*set_promisc)(struct fman_mac *mac_dev, bool enable); int (*set_promisc)(struct fman_mac *mac_dev, bool enable);
int (*change_addr)(struct fman_mac *mac_dev, enet_addr_t *enet_addr); int (*change_addr)(struct fman_mac *mac_dev, enet_addr_t *enet_addr);
int (*set_multi)(struct net_device *net_dev, int (*set_multi)(struct net_device *net_dev,
...@@ -82,7 +83,6 @@ struct mac_device { ...@@ -82,7 +83,6 @@ struct mac_device {
}; };
struct dpaa_eth_data { struct dpaa_eth_data {
struct device_node *mac_node;
struct mac_device *mac_dev; struct mac_device *mac_dev;
int mac_hw_id; int mac_hw_id;
int fman_hw_id; int fman_hw_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment