2011-12-21 03:58:19 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
This contains the functions to handle the platform driver.
|
|
|
|
|
|
|
|
Copyright (C) 2007-2011 STMicroelectronics Ltd
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms and conditions of the GNU General Public License,
|
|
|
|
version 2, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
more details.
|
|
|
|
|
|
|
|
The full GNU General Public License is included in this distribution in
|
|
|
|
the file called "COPYING".
|
|
|
|
|
|
|
|
Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#include <linux/platform_device.h>
|
2015-05-01 01:47:42 +00:00
|
|
|
#include <linux/module.h>
|
2011-12-21 03:58:19 +00:00
|
|
|
#include <linux/io.h>
|
2012-03-13 04:56:37 +00:00
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/of_net.h>
|
2014-01-17 13:24:46 +00:00
|
|
|
#include <linux/of_device.h>
|
2015-05-27 18:02:47 +00:00
|
|
|
#include <linux/of_mdio.h>
|
2014-11-07 14:46:42 +00:00
|
|
|
|
2011-12-21 03:58:19 +00:00
|
|
|
#include "stmmac.h"
|
2014-11-07 14:46:42 +00:00
|
|
|
#include "stmmac_platform.h"
|
2011-12-21 03:58:19 +00:00
|
|
|
|
2012-03-13 04:56:37 +00:00
|
|
|
#ifdef CONFIG_OF
|
2014-07-31 20:49:17 +00:00
|
|
|
|
2014-11-18 08:47:01 +00:00
|
|
|
/**
|
|
|
|
* dwmac1000_validate_mcast_bins - validates the number of Multicast filter bins
|
|
|
|
* @mcast_bins: Multicast filtering bins
|
|
|
|
* Description:
|
|
|
|
* this function validates the number of Multicast filtering bins specified
|
2014-07-31 20:49:17 +00:00
|
|
|
* by the configuration through the device tree. The Synopsys GMAC supports
|
|
|
|
* 64 bins, 128 bins, or 256 bins. "bins" refer to the division of CRC
|
|
|
|
* number space. 64 bins correspond to 6 bits of the CRC, 128 corresponds
|
|
|
|
* to 7 bits, and 256 refers to 8 bits of the CRC. Any other setting is
|
|
|
|
* invalid and will cause the filtering algorithm to use Multicast
|
|
|
|
* promiscuous mode.
|
|
|
|
*/
|
|
|
|
static int dwmac1000_validate_mcast_bins(int mcast_bins)
|
|
|
|
{
|
|
|
|
int x = mcast_bins;
|
|
|
|
|
|
|
|
switch (x) {
|
|
|
|
case HASH_TABLE_SIZE:
|
|
|
|
case 128:
|
|
|
|
case 256:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
x = 0;
|
|
|
|
pr_info("Hash table entries set to unexpected value %d",
|
|
|
|
mcast_bins);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2014-11-18 08:47:01 +00:00
|
|
|
/**
|
|
|
|
* dwmac1000_validate_ucast_entries - validate the Unicast address entries
|
|
|
|
* @ucast_entries: number of Unicast address entries
|
|
|
|
* Description:
|
|
|
|
* This function validates the number of Unicast address entries supported
|
2014-07-31 20:49:17 +00:00
|
|
|
* by a particular Synopsys 10/100/1000 controller. The Synopsys controller
|
|
|
|
* supports 1, 32, 64, or 128 Unicast filter entries for it's Unicast filter
|
|
|
|
* logic. This function validates a valid, supported configuration is
|
|
|
|
* selected, and defaults to 1 Unicast address if an unsupported
|
|
|
|
* configuration is selected.
|
|
|
|
*/
|
|
|
|
static int dwmac1000_validate_ucast_entries(int ucast_entries)
|
|
|
|
{
|
|
|
|
int x = ucast_entries;
|
|
|
|
|
|
|
|
switch (x) {
|
|
|
|
case 1:
|
|
|
|
case 32:
|
|
|
|
case 64:
|
|
|
|
case 128:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
x = 1;
|
|
|
|
pr_info("Unicast table entries set to unexpected value %d\n",
|
|
|
|
ucast_entries);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2016-02-29 13:27:28 +00:00
|
|
|
/**
|
|
|
|
* stmmac_axi_setup - parse DT parameters for programming the AXI register
|
|
|
|
* @pdev: platform device
|
|
|
|
* @priv: driver private struct.
|
|
|
|
* Description:
|
|
|
|
* if required, from device-tree the AXI internal register can be tuned
|
|
|
|
* by using platform parameters.
|
|
|
|
*/
|
|
|
|
static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct device_node *np;
|
|
|
|
struct stmmac_axi *axi;
|
|
|
|
|
|
|
|
np = of_parse_phandle(pdev->dev.of_node, "snps,axi-config", 0);
|
|
|
|
if (!np)
|
|
|
|
return NULL;
|
|
|
|
|
2017-03-07 15:27:36 +00:00
|
|
|
axi = devm_kzalloc(&pdev->dev, sizeof(*axi), GFP_KERNEL);
|
2016-08-01 07:02:42 +00:00
|
|
|
if (!axi) {
|
|
|
|
of_node_put(np);
|
2016-02-29 13:27:28 +00:00
|
|
|
return ERR_PTR(-ENOMEM);
|
2016-08-01 07:02:42 +00:00
|
|
|
}
|
2016-02-29 13:27:28 +00:00
|
|
|
|
|
|
|
axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
|
|
|
|
axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
|
|
|
|
axi->axi_kbbe = of_property_read_bool(np, "snps,axi_kbbe");
|
|
|
|
axi->axi_fb = of_property_read_bool(np, "snps,axi_fb");
|
|
|
|
axi->axi_mb = of_property_read_bool(np, "snps,axi_mb");
|
|
|
|
axi->axi_rb = of_property_read_bool(np, "snps,axi_rb");
|
|
|
|
|
2016-12-05 17:12:54 +00:00
|
|
|
if (of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt))
|
|
|
|
axi->axi_wr_osr_lmt = 1;
|
|
|
|
if (of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt))
|
|
|
|
axi->axi_rd_osr_lmt = 1;
|
2016-02-29 13:27:28 +00:00
|
|
|
of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
|
2016-08-01 07:02:42 +00:00
|
|
|
of_node_put(np);
|
2016-02-29 13:27:28 +00:00
|
|
|
|
|
|
|
return axi;
|
|
|
|
}
|
|
|
|
|
2017-03-10 18:24:51 +00:00
|
|
|
/**
|
|
|
|
* stmmac_mtl_setup - parse DT parameters for multiple queues configuration
|
|
|
|
* @pdev: platform device
|
|
|
|
*/
|
|
|
|
static void stmmac_mtl_setup(struct platform_device *pdev,
|
|
|
|
struct plat_stmmacenet_data *plat)
|
|
|
|
{
|
|
|
|
struct device_node *q_node;
|
|
|
|
struct device_node *rx_node;
|
|
|
|
struct device_node *tx_node;
|
|
|
|
u8 queue = 0;
|
|
|
|
|
2017-03-21 15:12:10 +00:00
|
|
|
/* For backwards-compatibility with device trees that don't have any
|
|
|
|
* snps,mtl-rx-config or snps,mtl-tx-config properties, we fall back
|
|
|
|
* to one RX and TX queues each.
|
|
|
|
*/
|
|
|
|
plat->rx_queues_to_use = 1;
|
|
|
|
plat->tx_queues_to_use = 1;
|
|
|
|
|
2017-10-26 09:07:12 +00:00
|
|
|
/* First Queue must always be in DCB mode. As MTL_QUEUE_DCB = 1 we need
|
|
|
|
* to always set this, otherwise Queue will be classified as AVB
|
|
|
|
* (because MTL_QUEUE_AVB = 0).
|
|
|
|
*/
|
|
|
|
plat->rx_queues_cfg[0].mode_to_use = MTL_QUEUE_DCB;
|
|
|
|
plat->tx_queues_cfg[0].mode_to_use = MTL_QUEUE_DCB;
|
|
|
|
|
2017-03-10 18:24:51 +00:00
|
|
|
rx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-rx-config", 0);
|
|
|
|
if (!rx_node)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-tx-config", 0);
|
|
|
|
if (!tx_node) {
|
|
|
|
of_node_put(rx_node);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Processing RX queues common config */
|
|
|
|
if (of_property_read_u8(rx_node, "snps,rx-queues-to-use",
|
|
|
|
&plat->rx_queues_to_use))
|
|
|
|
plat->rx_queues_to_use = 1;
|
|
|
|
|
|
|
|
if (of_property_read_bool(rx_node, "snps,rx-sched-sp"))
|
|
|
|
plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP;
|
|
|
|
else if (of_property_read_bool(rx_node, "snps,rx-sched-wsp"))
|
|
|
|
plat->rx_sched_algorithm = MTL_RX_ALGORITHM_WSP;
|
|
|
|
else
|
|
|
|
plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP;
|
|
|
|
|
|
|
|
/* Processing individual RX queue config */
|
|
|
|
for_each_child_of_node(rx_node, q_node) {
|
|
|
|
if (queue >= plat->rx_queues_to_use)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (of_property_read_bool(q_node, "snps,dcb-algorithm"))
|
2017-03-10 18:24:59 +00:00
|
|
|
plat->rx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
|
2017-03-10 18:24:51 +00:00
|
|
|
else if (of_property_read_bool(q_node, "snps,avb-algorithm"))
|
2017-03-10 18:24:59 +00:00
|
|
|
plat->rx_queues_cfg[queue].mode_to_use = MTL_QUEUE_AVB;
|
2017-03-10 18:24:51 +00:00
|
|
|
else
|
2017-03-10 18:24:59 +00:00
|
|
|
plat->rx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
|
2017-03-10 18:24:51 +00:00
|
|
|
|
|
|
|
if (of_property_read_u8(q_node, "snps,map-to-dma-channel",
|
|
|
|
&plat->rx_queues_cfg[queue].chan))
|
|
|
|
plat->rx_queues_cfg[queue].chan = queue;
|
|
|
|
/* TODO: Dynamic mapping to be included in the future */
|
|
|
|
|
2017-03-17 16:11:06 +00:00
|
|
|
if (of_property_read_u32(q_node, "snps,priority",
|
|
|
|
&plat->rx_queues_cfg[queue].prio)) {
|
|
|
|
plat->rx_queues_cfg[queue].prio = 0;
|
|
|
|
plat->rx_queues_cfg[queue].use_prio = false;
|
|
|
|
} else {
|
|
|
|
plat->rx_queues_cfg[queue].use_prio = true;
|
|
|
|
}
|
|
|
|
|
2017-03-17 16:11:07 +00:00
|
|
|
/* RX queue specific packet type routing */
|
|
|
|
if (of_property_read_bool(q_node, "snps,route-avcp"))
|
|
|
|
plat->rx_queues_cfg[queue].pkt_route = PACKET_AVCPQ;
|
|
|
|
else if (of_property_read_bool(q_node, "snps,route-ptp"))
|
|
|
|
plat->rx_queues_cfg[queue].pkt_route = PACKET_PTPQ;
|
|
|
|
else if (of_property_read_bool(q_node, "snps,route-dcbcp"))
|
|
|
|
plat->rx_queues_cfg[queue].pkt_route = PACKET_DCBCPQ;
|
|
|
|
else if (of_property_read_bool(q_node, "snps,route-up"))
|
|
|
|
plat->rx_queues_cfg[queue].pkt_route = PACKET_UPQ;
|
|
|
|
else if (of_property_read_bool(q_node, "snps,route-multi-broad"))
|
|
|
|
plat->rx_queues_cfg[queue].pkt_route = PACKET_MCBCQ;
|
|
|
|
else
|
|
|
|
plat->rx_queues_cfg[queue].pkt_route = 0x0;
|
|
|
|
|
2017-03-10 18:24:51 +00:00
|
|
|
queue++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Processing TX queues common config */
|
|
|
|
if (of_property_read_u8(tx_node, "snps,tx-queues-to-use",
|
|
|
|
&plat->tx_queues_to_use))
|
|
|
|
plat->tx_queues_to_use = 1;
|
|
|
|
|
|
|
|
if (of_property_read_bool(tx_node, "snps,tx-sched-wrr"))
|
|
|
|
plat->tx_sched_algorithm = MTL_TX_ALGORITHM_WRR;
|
|
|
|
else if (of_property_read_bool(tx_node, "snps,tx-sched-wfq"))
|
|
|
|
plat->tx_sched_algorithm = MTL_TX_ALGORITHM_WFQ;
|
|
|
|
else if (of_property_read_bool(tx_node, "snps,tx-sched-dwrr"))
|
|
|
|
plat->tx_sched_algorithm = MTL_TX_ALGORITHM_DWRR;
|
|
|
|
else if (of_property_read_bool(tx_node, "snps,tx-sched-sp"))
|
|
|
|
plat->tx_sched_algorithm = MTL_TX_ALGORITHM_SP;
|
|
|
|
else
|
|
|
|
plat->tx_sched_algorithm = MTL_TX_ALGORITHM_SP;
|
|
|
|
|
|
|
|
queue = 0;
|
|
|
|
|
|
|
|
/* Processing individual TX queue config */
|
|
|
|
for_each_child_of_node(tx_node, q_node) {
|
|
|
|
if (queue >= plat->tx_queues_to_use)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (of_property_read_u8(q_node, "snps,weight",
|
|
|
|
&plat->tx_queues_cfg[queue].weight))
|
|
|
|
plat->tx_queues_cfg[queue].weight = 0x10 + queue;
|
|
|
|
|
2017-03-10 18:24:59 +00:00
|
|
|
if (of_property_read_bool(q_node, "snps,dcb-algorithm")) {
|
|
|
|
plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
|
|
|
|
} else if (of_property_read_bool(q_node,
|
|
|
|
"snps,avb-algorithm")) {
|
|
|
|
plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_AVB;
|
|
|
|
|
|
|
|
/* Credit Base Shaper parameters used by AVB */
|
|
|
|
if (of_property_read_u32(q_node, "snps,send_slope",
|
|
|
|
&plat->tx_queues_cfg[queue].send_slope))
|
|
|
|
plat->tx_queues_cfg[queue].send_slope = 0x0;
|
|
|
|
if (of_property_read_u32(q_node, "snps,idle_slope",
|
|
|
|
&plat->tx_queues_cfg[queue].idle_slope))
|
|
|
|
plat->tx_queues_cfg[queue].idle_slope = 0x0;
|
|
|
|
if (of_property_read_u32(q_node, "snps,high_credit",
|
|
|
|
&plat->tx_queues_cfg[queue].high_credit))
|
|
|
|
plat->tx_queues_cfg[queue].high_credit = 0x0;
|
|
|
|
if (of_property_read_u32(q_node, "snps,low_credit",
|
|
|
|
&plat->tx_queues_cfg[queue].low_credit))
|
|
|
|
plat->tx_queues_cfg[queue].low_credit = 0x0;
|
|
|
|
} else {
|
|
|
|
plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
|
|
|
|
}
|
|
|
|
|
2017-03-17 16:11:06 +00:00
|
|
|
if (of_property_read_u32(q_node, "snps,priority",
|
|
|
|
&plat->tx_queues_cfg[queue].prio)) {
|
|
|
|
plat->tx_queues_cfg[queue].prio = 0;
|
|
|
|
plat->tx_queues_cfg[queue].use_prio = false;
|
|
|
|
} else {
|
|
|
|
plat->tx_queues_cfg[queue].use_prio = true;
|
|
|
|
}
|
|
|
|
|
2017-03-10 18:24:51 +00:00
|
|
|
queue++;
|
|
|
|
}
|
|
|
|
|
|
|
|
of_node_put(rx_node);
|
|
|
|
of_node_put(tx_node);
|
|
|
|
of_node_put(q_node);
|
|
|
|
}
|
|
|
|
|
2016-04-01 07:07:16 +00:00
|
|
|
/**
|
|
|
|
* stmmac_dt_phy - parse device-tree driver parameters to allocate PHY resources
|
|
|
|
* @plat: driver data platform structure
|
|
|
|
* @np: device tree node
|
|
|
|
* @dev: device pointer
|
|
|
|
* Description:
|
|
|
|
* The mdio bus will be allocated in case of a phy transceiver is on board;
|
|
|
|
* it will be NULL if the fixed-link is configured.
|
|
|
|
* If there is the "snps,dwmac-mdio" sub-node the mdio will be allocated
|
|
|
|
* in any case (for DSA, mdio must be registered even if fixed-link).
|
|
|
|
* The table below sums the supported configurations:
|
|
|
|
* -------------------------------
|
|
|
|
* snps,phy-addr | Y
|
|
|
|
* -------------------------------
|
|
|
|
* phy-handle | Y
|
|
|
|
* -------------------------------
|
|
|
|
* fixed-link | N
|
|
|
|
* -------------------------------
|
|
|
|
* snps,dwmac-mdio |
|
|
|
|
* even if | Y
|
|
|
|
* fixed-link |
|
|
|
|
* -------------------------------
|
|
|
|
*
|
|
|
|
* It returns 0 in case of success otherwise -ENODEV.
|
|
|
|
*/
|
|
|
|
static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
|
|
|
|
struct device_node *np, struct device *dev)
|
|
|
|
{
|
|
|
|
bool mdio = true;
|
2017-05-31 07:18:36 +00:00
|
|
|
static const struct of_device_id need_mdio_ids[] = {
|
|
|
|
{ .compatible = "snps,dwc-qos-ethernet-4.10" },
|
2017-09-21 06:24:27 +00:00
|
|
|
{},
|
2017-05-31 07:18:36 +00:00
|
|
|
};
|
2016-04-01 07:07:16 +00:00
|
|
|
|
|
|
|
/* If phy-handle property is passed from DT, use it as the PHY */
|
|
|
|
plat->phy_node = of_parse_phandle(np, "phy-handle", 0);
|
|
|
|
if (plat->phy_node)
|
|
|
|
dev_dbg(dev, "Found phy-handle subnode\n");
|
|
|
|
|
|
|
|
/* If phy-handle is not specified, check if we have a fixed-phy */
|
|
|
|
if (!plat->phy_node && of_phy_is_fixed_link(np)) {
|
|
|
|
if ((of_phy_register_fixed_link(np) < 0))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
dev_dbg(dev, "Found fixed-link subnode\n");
|
|
|
|
plat->phy_node = of_node_get(np);
|
|
|
|
mdio = false;
|
|
|
|
}
|
|
|
|
|
2017-05-31 07:18:36 +00:00
|
|
|
if (of_match_node(need_mdio_ids, np)) {
|
2017-01-09 12:35:10 +00:00
|
|
|
plat->mdio_node = of_get_child_by_name(np, "mdio");
|
|
|
|
} else {
|
|
|
|
/**
|
|
|
|
* If snps,dwmac-mdio is passed from DT, always register
|
|
|
|
* the MDIO
|
|
|
|
*/
|
|
|
|
for_each_child_of_node(np, plat->mdio_node) {
|
|
|
|
if (of_device_is_compatible(plat->mdio_node,
|
|
|
|
"snps,dwmac-mdio"))
|
2017-01-12 18:46:32 +00:00
|
|
|
break;
|
2017-01-09 12:35:10 +00:00
|
|
|
}
|
2016-04-01 07:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (plat->mdio_node) {
|
|
|
|
dev_dbg(dev, "Found MDIO subnode\n");
|
|
|
|
mdio = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mdio)
|
|
|
|
plat->mdio_bus_data =
|
|
|
|
devm_kzalloc(dev, sizeof(struct stmmac_mdio_bus_data),
|
|
|
|
GFP_KERNEL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-18 08:47:01 +00:00
|
|
|
/**
|
|
|
|
* stmmac_probe_config_dt - parse device-tree driver parameters
|
|
|
|
* @pdev: platform_device structure
|
|
|
|
* @mac: MAC address to use
|
|
|
|
* Description:
|
|
|
|
* this function is to read the driver parameters from device-tree and
|
|
|
|
* set some private fields that will be used by the main at runtime.
|
|
|
|
*/
|
2015-07-16 22:26:09 +00:00
|
|
|
struct plat_stmmacenet_data *
|
2015-07-16 22:26:08 +00:00
|
|
|
stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
|
2012-03-13 04:56:37 +00:00
|
|
|
{
|
|
|
|
struct device_node *np = pdev->dev.of_node;
|
2015-07-16 22:26:06 +00:00
|
|
|
struct plat_stmmacenet_data *plat;
|
2013-07-04 09:35:41 +00:00
|
|
|
struct stmmac_dma_cfg *dma_cfg;
|
2012-03-13 04:56:37 +00:00
|
|
|
|
2015-07-16 22:26:06 +00:00
|
|
|
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
|
|
|
|
if (!plat)
|
2015-07-16 22:26:08 +00:00
|
|
|
return ERR_PTR(-ENOMEM);
|
2015-07-16 22:26:06 +00:00
|
|
|
|
2012-03-13 04:56:37 +00:00
|
|
|
*mac = of_get_mac_address(np);
|
|
|
|
plat->interface = of_get_phy_mode(np);
|
2013-07-04 09:35:41 +00:00
|
|
|
|
2014-01-16 10:51:43 +00:00
|
|
|
/* Get max speed of operation from device tree */
|
|
|
|
if (of_property_read_u32(np, "max-speed", &plat->max_speed))
|
|
|
|
plat->max_speed = -1;
|
|
|
|
|
2013-07-04 09:35:41 +00:00
|
|
|
plat->bus_id = of_alias_get_id(np, "ethernet");
|
|
|
|
if (plat->bus_id < 0)
|
|
|
|
plat->bus_id = 0;
|
|
|
|
|
2014-01-17 13:24:45 +00:00
|
|
|
/* Default to phy auto-detection */
|
|
|
|
plat->phy_addr = -1;
|
|
|
|
|
|
|
|
/* "snps,phy-addr" is not a standard property. Mark it as deprecated
|
|
|
|
* and warn of its use. Remove this when phy node support is added.
|
|
|
|
*/
|
|
|
|
if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0)
|
|
|
|
dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n");
|
2013-07-04 09:35:41 +00:00
|
|
|
|
2016-04-01 07:07:16 +00:00
|
|
|
/* To Configure PHY by using all device-tree supported properties */
|
|
|
|
if (stmmac_dt_phy(plat, np, &pdev->dev))
|
|
|
|
return ERR_PTR(-ENODEV);
|
2014-10-14 06:11:54 +00:00
|
|
|
|
2015-04-15 16:17:40 +00:00
|
|
|
of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size);
|
|
|
|
|
|
|
|
of_property_read_u32(np, "rx-fifo-depth", &plat->rx_fifo_size);
|
|
|
|
|
2014-10-14 06:11:54 +00:00
|
|
|
plat->force_sf_dma_mode =
|
|
|
|
of_property_read_bool(np, "snps,force_sf_dma_mode");
|
2014-01-17 13:24:44 +00:00
|
|
|
|
2017-01-09 12:35:08 +00:00
|
|
|
plat->en_tx_lpi_clockgating =
|
|
|
|
of_property_read_bool(np, "snps,en-tx-lpi-clockgating");
|
|
|
|
|
2014-01-20 11:39:01 +00:00
|
|
|
/* Set the maxmtu to a default of JUMBO_LEN in case the
|
|
|
|
* parameter is not present in the device tree.
|
|
|
|
*/
|
|
|
|
plat->maxmtu = JUMBO_LEN;
|
|
|
|
|
2015-07-16 22:26:06 +00:00
|
|
|
/* Set default value for multicast hash bins */
|
|
|
|
plat->multicast_filter_bins = HASH_TABLE_SIZE;
|
|
|
|
|
|
|
|
/* Set default value for unicast filter entries */
|
|
|
|
plat->unicast_filter_entries = 1;
|
|
|
|
|
2012-03-13 04:56:37 +00:00
|
|
|
/*
|
|
|
|
* Currently only the properties needed on SPEAr600
|
|
|
|
* are provided. All other properties should be added
|
|
|
|
* once needed on other platforms.
|
|
|
|
*/
|
2012-07-18 13:28:26 +00:00
|
|
|
if (of_device_is_compatible(np, "st,spear600-gmac") ||
|
2016-08-29 16:23:40 +00:00
|
|
|
of_device_is_compatible(np, "snps,dwmac-3.50a") ||
|
2012-07-18 13:28:26 +00:00
|
|
|
of_device_is_compatible(np, "snps,dwmac-3.70a") ||
|
|
|
|
of_device_is_compatible(np, "snps,dwmac")) {
|
2014-01-20 11:39:01 +00:00
|
|
|
/* Note that the max-frame-size parameter as defined in the
|
|
|
|
* ePAPR v1.1 spec is defined as max-frame-size, it's
|
|
|
|
* actually used as the IEEE definition of MAC Client
|
|
|
|
* data, or MTU. The ePAPR specification is confusing as
|
|
|
|
* the definition is max-frame-size, but usage examples
|
|
|
|
* are clearly MTUs
|
|
|
|
*/
|
|
|
|
of_property_read_u32(np, "max-frame-size", &plat->maxmtu);
|
2014-07-31 20:49:17 +00:00
|
|
|
of_property_read_u32(np, "snps,multicast-filter-bins",
|
|
|
|
&plat->multicast_filter_bins);
|
|
|
|
of_property_read_u32(np, "snps,perfect-filter-entries",
|
|
|
|
&plat->unicast_filter_entries);
|
|
|
|
plat->unicast_filter_entries = dwmac1000_validate_ucast_entries(
|
|
|
|
plat->unicast_filter_entries);
|
|
|
|
plat->multicast_filter_bins = dwmac1000_validate_mcast_bins(
|
|
|
|
plat->multicast_filter_bins);
|
2012-03-13 04:56:37 +00:00
|
|
|
plat->has_gmac = 1;
|
|
|
|
plat->pmt = 1;
|
|
|
|
}
|
|
|
|
|
2016-04-01 09:37:33 +00:00
|
|
|
if (of_device_is_compatible(np, "snps,dwmac-4.00") ||
|
|
|
|
of_device_is_compatible(np, "snps,dwmac-4.10a")) {
|
|
|
|
plat->has_gmac4 = 1;
|
net: stmmac: stmmac_platform: use correct setup function for gmac4
devicetree binding for stmmac states:
- compatible: Should be "snps,dwmac-<ip_version>", "snps,dwmac"
For backwards compatibility: "st,spear600-gmac" is also supported.
Previously, when specifying "snps,dwmac-4.10a", "snps,dwmac" as your
compatible string, plat_stmmacenet_data would have both has_gmac and
has_gmac4 set.
This would lead to stmmac_hw_init calling dwmac1000_setup rather than
dwmac4_setup, resulting in a non-functional driver.
This happened since the check for has_gmac is done before the check for
has_gmac4. However, the order should not matter, so it does not make sense
to have both set.
If something is valid for both, you should do as the stmmac_interrupt does:
if (priv->plat->has_gmac || priv->plat->has_gmac4) ...
The places where it was obvious that the author actually meant
if (has_gmac || has_gmac4) rather than if (has_gmac) has been updated.
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
Acked-by: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-12-07 12:41:08 +00:00
|
|
|
plat->has_gmac = 0;
|
2016-04-01 09:37:33 +00:00
|
|
|
plat->pmt = 1;
|
|
|
|
plat->tso_en = of_property_read_bool(np, "snps,tso");
|
|
|
|
}
|
|
|
|
|
2013-07-04 09:35:41 +00:00
|
|
|
if (of_device_is_compatible(np, "snps,dwmac-3.610") ||
|
|
|
|
of_device_is_compatible(np, "snps,dwmac-3.710")) {
|
|
|
|
plat->enh_desc = 1;
|
|
|
|
plat->bugged_jumbo = 1;
|
|
|
|
plat->force_sf_dma_mode = 1;
|
|
|
|
}
|
|
|
|
|
net: stmmac: stmmac_platform: fix parsing of DT binding
commit 64c3b252e9fc ("net: stmmac: fixed the pbl setting with DT")
changed the parsing of the DT binding.
Before 64c3b252e9fc, snps,fixed-burst and snps,mixed-burst were parsed
regardless if the property snps,pbl existed or not.
After the commit, fixed burst and mixed burst are only parsed if
snps,pbl exists. Now when snps,aal has been added, it too is only
parsed if snps,pbl exists.
Since the DT binding does not specify that fixed burst, mixed burst
or aal depend on snps,pbl being specified, undo changes introduced
by 64c3b252e9fc.
The issue commit 64c3b252e9fc ("net: stmmac: fixed the pbl setting with
DT") tries to address is solved in another way:
The databook specifies that all values other than
1, 2, 4, 8, 16, or 32 results in undefined behavior,
so snps,pbl = <0> is invalid.
If pbl is 0 after parsing, set pbl to DEFAULT_DMA_PBL.
This handles the case where the property is omitted, and also handles
the case where the property is specified without any data.
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
Acked-by: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-12-07 14:20:05 +00:00
|
|
|
dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!dma_cfg) {
|
|
|
|
stmmac_remove_config_dt(pdev, plat);
|
|
|
|
return ERR_PTR(-ENOMEM);
|
2013-08-24 06:31:43 +00:00
|
|
|
}
|
net: stmmac: stmmac_platform: fix parsing of DT binding
commit 64c3b252e9fc ("net: stmmac: fixed the pbl setting with DT")
changed the parsing of the DT binding.
Before 64c3b252e9fc, snps,fixed-burst and snps,mixed-burst were parsed
regardless if the property snps,pbl existed or not.
After the commit, fixed burst and mixed burst are only parsed if
snps,pbl exists. Now when snps,aal has been added, it too is only
parsed if snps,pbl exists.
Since the DT binding does not specify that fixed burst, mixed burst
or aal depend on snps,pbl being specified, undo changes introduced
by 64c3b252e9fc.
The issue commit 64c3b252e9fc ("net: stmmac: fixed the pbl setting with
DT") tries to address is solved in another way:
The databook specifies that all values other than
1, 2, 4, 8, 16, or 32 results in undefined behavior,
so snps,pbl = <0> is invalid.
If pbl is 0 after parsing, set pbl to DEFAULT_DMA_PBL.
This handles the case where the property is omitted, and also handles
the case where the property is specified without any data.
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
Acked-by: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-12-07 14:20:05 +00:00
|
|
|
plat->dma_cfg = dma_cfg;
|
|
|
|
|
|
|
|
of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl);
|
|
|
|
if (!dma_cfg->pbl)
|
|
|
|
dma_cfg->pbl = DEFAULT_DMA_PBL;
|
net: stmmac: add support for independent DMA pbl for tx/rx
GMAC and newer supports independent programmable burst lengths for
DMA tx/rx. Add new optional devicetree properties representing this.
To be backwards compatible, snps,pbl will still be valid, but
snps,txpbl/snps,rxpbl will override the value in snps,pbl if set.
If the IP is synthesized to use the AXI interface, there is a register
and a matching DT property inside the optional stmmac-axi-config DT node
for controlling burst lengths, named snps,blen.
However, using this register, it is not possible to control tx and rx
independently. Also, this register is not available if the IP was
synthesized with, e.g., the AHB interface.
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
Acked-by: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-12-07 14:20:07 +00:00
|
|
|
of_property_read_u32(np, "snps,txpbl", &dma_cfg->txpbl);
|
|
|
|
of_property_read_u32(np, "snps,rxpbl", &dma_cfg->rxpbl);
|
2016-12-07 14:20:08 +00:00
|
|
|
dma_cfg->pblx8 = !of_property_read_bool(np, "snps,no-pbl-x8");
|
net: stmmac: stmmac_platform: fix parsing of DT binding
commit 64c3b252e9fc ("net: stmmac: fixed the pbl setting with DT")
changed the parsing of the DT binding.
Before 64c3b252e9fc, snps,fixed-burst and snps,mixed-burst were parsed
regardless if the property snps,pbl existed or not.
After the commit, fixed burst and mixed burst are only parsed if
snps,pbl exists. Now when snps,aal has been added, it too is only
parsed if snps,pbl exists.
Since the DT binding does not specify that fixed burst, mixed burst
or aal depend on snps,pbl being specified, undo changes introduced
by 64c3b252e9fc.
The issue commit 64c3b252e9fc ("net: stmmac: fixed the pbl setting with
DT") tries to address is solved in another way:
The databook specifies that all values other than
1, 2, 4, 8, 16, or 32 results in undefined behavior,
so snps,pbl = <0> is invalid.
If pbl is 0 after parsing, set pbl to DEFAULT_DMA_PBL.
This handles the case where the property is omitted, and also handles
the case where the property is specified without any data.
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
Acked-by: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-12-07 14:20:05 +00:00
|
|
|
|
|
|
|
dma_cfg->aal = of_property_read_bool(np, "snps,aal");
|
|
|
|
dma_cfg->fixed_burst = of_property_read_bool(np, "snps,fixed-burst");
|
|
|
|
dma_cfg->mixed_burst = of_property_read_bool(np, "snps,mixed-burst");
|
|
|
|
|
2013-08-28 10:55:39 +00:00
|
|
|
plat->force_thresh_dma_mode = of_property_read_bool(np, "snps,force_thresh_dma_mode");
|
|
|
|
if (plat->force_thresh_dma_mode) {
|
|
|
|
plat->force_sf_dma_mode = 0;
|
|
|
|
pr_warn("force_sf_dma_mode is ignored if force_thresh_dma_mode is set.");
|
2013-09-06 01:01:41 +00:00
|
|
|
}
|
2013-07-04 09:35:41 +00:00
|
|
|
|
2016-06-24 13:16:26 +00:00
|
|
|
of_property_read_u32(np, "snps,ps-speed", &plat->mac_port_sel_speed);
|
|
|
|
|
2016-02-29 13:27:28 +00:00
|
|
|
plat->axi = stmmac_axi_setup(pdev);
|
|
|
|
|
2017-03-10 18:24:51 +00:00
|
|
|
stmmac_mtl_setup(pdev, plat);
|
|
|
|
|
2017-01-09 12:35:09 +00:00
|
|
|
/* clock setup */
|
|
|
|
plat->stmmac_clk = devm_clk_get(&pdev->dev,
|
|
|
|
STMMAC_RESOURCE_NAME);
|
|
|
|
if (IS_ERR(plat->stmmac_clk)) {
|
|
|
|
dev_warn(&pdev->dev, "Cannot get CSR clock\n");
|
|
|
|
plat->stmmac_clk = NULL;
|
|
|
|
}
|
|
|
|
clk_prepare_enable(plat->stmmac_clk);
|
|
|
|
|
|
|
|
plat->pclk = devm_clk_get(&pdev->dev, "pclk");
|
|
|
|
if (IS_ERR(plat->pclk)) {
|
|
|
|
if (PTR_ERR(plat->pclk) == -EPROBE_DEFER)
|
|
|
|
goto error_pclk_get;
|
|
|
|
|
|
|
|
plat->pclk = NULL;
|
|
|
|
}
|
|
|
|
clk_prepare_enable(plat->pclk);
|
|
|
|
|
|
|
|
/* Fall-back to main clock in case of no PTP ref is passed */
|
2017-03-10 16:34:53 +00:00
|
|
|
plat->clk_ptp_ref = devm_clk_get(&pdev->dev, "ptp_ref");
|
2017-01-09 12:35:09 +00:00
|
|
|
if (IS_ERR(plat->clk_ptp_ref)) {
|
|
|
|
plat->clk_ptp_rate = clk_get_rate(plat->stmmac_clk);
|
|
|
|
plat->clk_ptp_ref = NULL;
|
|
|
|
dev_warn(&pdev->dev, "PTP uses main clock\n");
|
|
|
|
} else {
|
|
|
|
plat->clk_ptp_rate = clk_get_rate(plat->clk_ptp_ref);
|
2017-02-02 07:20:12 +00:00
|
|
|
dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate);
|
2017-01-09 12:35:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
plat->stmmac_rst = devm_reset_control_get(&pdev->dev,
|
|
|
|
STMMAC_RESOURCE_NAME);
|
|
|
|
if (IS_ERR(plat->stmmac_rst)) {
|
|
|
|
if (PTR_ERR(plat->stmmac_rst) == -EPROBE_DEFER)
|
|
|
|
goto error_hw_init;
|
|
|
|
|
|
|
|
dev_info(&pdev->dev, "no reset control found\n");
|
|
|
|
plat->stmmac_rst = NULL;
|
|
|
|
}
|
|
|
|
|
2015-07-16 22:26:08 +00:00
|
|
|
return plat;
|
2017-01-09 12:35:09 +00:00
|
|
|
|
|
|
|
error_hw_init:
|
|
|
|
clk_disable_unprepare(plat->pclk);
|
|
|
|
error_pclk_get:
|
|
|
|
clk_disable_unprepare(plat->stmmac_clk);
|
|
|
|
|
|
|
|
return ERR_PTR(-EPROBE_DEFER);
|
2012-03-13 04:56:37 +00:00
|
|
|
}
|
2016-11-30 14:29:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* stmmac_remove_config_dt - undo the effects of stmmac_probe_config_dt()
|
|
|
|
* @pdev: platform_device structure
|
|
|
|
* @plat: driver data platform structure
|
|
|
|
*
|
|
|
|
* Release resources claimed by stmmac_probe_config_dt().
|
|
|
|
*/
|
|
|
|
void stmmac_remove_config_dt(struct platform_device *pdev,
|
|
|
|
struct plat_stmmacenet_data *plat)
|
|
|
|
{
|
|
|
|
struct device_node *np = pdev->dev.of_node;
|
|
|
|
|
|
|
|
if (of_phy_is_fixed_link(np))
|
|
|
|
of_phy_deregister_fixed_link(np);
|
|
|
|
of_node_put(plat->phy_node);
|
2017-01-17 11:23:21 +00:00
|
|
|
of_node_put(plat->mdio_node);
|
2016-11-30 14:29:55 +00:00
|
|
|
}
|
2012-03-13 04:56:37 +00:00
|
|
|
#else
|
2015-07-16 22:26:09 +00:00
|
|
|
struct plat_stmmacenet_data *
|
2015-07-16 22:26:08 +00:00
|
|
|
stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
|
2012-03-13 04:56:37 +00:00
|
|
|
{
|
2017-02-08 08:31:14 +00:00
|
|
|
return ERR_PTR(-EINVAL);
|
2012-03-13 04:56:37 +00:00
|
|
|
}
|
2016-11-30 14:29:55 +00:00
|
|
|
|
|
|
|
void stmmac_remove_config_dt(struct platform_device *pdev,
|
|
|
|
struct plat_stmmacenet_data *plat)
|
|
|
|
{
|
|
|
|
}
|
2012-03-13 04:56:37 +00:00
|
|
|
#endif /* CONFIG_OF */
|
2015-07-16 22:26:09 +00:00
|
|
|
EXPORT_SYMBOL_GPL(stmmac_probe_config_dt);
|
2016-11-30 14:29:55 +00:00
|
|
|
EXPORT_SYMBOL_GPL(stmmac_remove_config_dt);
|
2012-03-13 04:56:37 +00:00
|
|
|
|
2015-07-16 22:26:09 +00:00
|
|
|
int stmmac_get_platform_resources(struct platform_device *pdev,
|
|
|
|
struct stmmac_resources *stmmac_res)
|
2011-12-21 03:58:19 +00:00
|
|
|
{
|
|
|
|
struct resource *res;
|
2015-05-20 18:03:07 +00:00
|
|
|
|
2015-07-16 22:26:07 +00:00
|
|
|
memset(stmmac_res, 0, sizeof(*stmmac_res));
|
2015-03-03 10:46:44 +00:00
|
|
|
|
|
|
|
/* Get IRQ information early to have an ability to ask for deferred
|
|
|
|
* probe if needed before we went too far with resource allocation.
|
|
|
|
*/
|
2015-07-16 22:26:07 +00:00
|
|
|
stmmac_res->irq = platform_get_irq_byname(pdev, "macirq");
|
|
|
|
if (stmmac_res->irq < 0) {
|
|
|
|
if (stmmac_res->irq != -EPROBE_DEFER) {
|
|
|
|
dev_err(&pdev->dev,
|
2015-03-03 10:46:44 +00:00
|
|
|
"MAC IRQ configuration information not found\n");
|
|
|
|
}
|
2015-07-16 22:26:07 +00:00
|
|
|
return stmmac_res->irq;
|
2015-03-03 10:46:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* On some platforms e.g. SPEAr the wake up irq differs from the mac irq
|
|
|
|
* The external wake up irq can be passed through the platform code
|
|
|
|
* named as "eth_wake_irq"
|
|
|
|
*
|
|
|
|
* In case the wake up interrupt is not passed from the platform
|
|
|
|
* so the driver will continue to use the mac irq (ndev->irq)
|
|
|
|
*/
|
2015-07-16 22:26:07 +00:00
|
|
|
stmmac_res->wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq");
|
|
|
|
if (stmmac_res->wol_irq < 0) {
|
|
|
|
if (stmmac_res->wol_irq == -EPROBE_DEFER)
|
2015-03-03 10:46:44 +00:00
|
|
|
return -EPROBE_DEFER;
|
2015-07-16 22:26:07 +00:00
|
|
|
stmmac_res->wol_irq = stmmac_res->irq;
|
2015-03-03 10:46:44 +00:00
|
|
|
}
|
|
|
|
|
2015-07-16 22:26:07 +00:00
|
|
|
stmmac_res->lpi_irq = platform_get_irq_byname(pdev, "eth_lpi");
|
|
|
|
if (stmmac_res->lpi_irq == -EPROBE_DEFER)
|
2015-03-03 10:46:44 +00:00
|
|
|
return -EPROBE_DEFER;
|
2011-12-21 03:58:19 +00:00
|
|
|
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
2015-07-16 22:26:07 +00:00
|
|
|
stmmac_res->addr = devm_ioremap_resource(&pdev->dev, res);
|
|
|
|
|
2015-07-28 22:08:48 +00:00
|
|
|
return PTR_ERR_OR_ZERO(stmmac_res->addr);
|
2015-07-16 22:26:07 +00:00
|
|
|
}
|
2015-07-16 22:26:09 +00:00
|
|
|
EXPORT_SYMBOL_GPL(stmmac_get_platform_resources);
|
2015-07-16 22:26:07 +00:00
|
|
|
|
2011-12-21 03:58:19 +00:00
|
|
|
/**
|
|
|
|
* stmmac_pltfr_remove
|
|
|
|
* @pdev: platform device pointer
|
|
|
|
* Description: this function calls the main to free the net resources
|
|
|
|
* and calls the platforms hook and release the resources (e.g. mem).
|
|
|
|
*/
|
2015-05-14 10:10:58 +00:00
|
|
|
int stmmac_pltfr_remove(struct platform_device *pdev)
|
2011-12-21 03:58:19 +00:00
|
|
|
{
|
|
|
|
struct net_device *ndev = platform_get_drvdata(pdev);
|
|
|
|
struct stmmac_priv *priv = netdev_priv(ndev);
|
2016-11-30 14:29:55 +00:00
|
|
|
struct plat_stmmacenet_data *plat = priv->plat;
|
2016-05-01 20:58:19 +00:00
|
|
|
int ret = stmmac_dvr_remove(&pdev->dev);
|
2011-12-21 03:58:19 +00:00
|
|
|
|
2016-11-30 14:29:55 +00:00
|
|
|
if (plat->exit)
|
|
|
|
plat->exit(pdev, plat->bsp_priv);
|
|
|
|
|
|
|
|
stmmac_remove_config_dt(pdev, plat);
|
2014-01-17 13:24:42 +00:00
|
|
|
|
2011-12-21 03:58:19 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2015-05-14 10:10:58 +00:00
|
|
|
EXPORT_SYMBOL_GPL(stmmac_pltfr_remove);
|
2011-12-21 03:58:19 +00:00
|
|
|
|
2014-11-10 10:38:59 +00:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2014-11-18 08:47:01 +00:00
|
|
|
/**
|
|
|
|
* stmmac_pltfr_suspend
|
|
|
|
* @dev: device pointer
|
|
|
|
* Description: this function is invoked when suspend the driver and it direcly
|
|
|
|
* call the main suspend function and then, if required, on some platform, it
|
|
|
|
* can call an exit helper.
|
|
|
|
*/
|
2011-12-21 03:58:19 +00:00
|
|
|
static int stmmac_pltfr_suspend(struct device *dev)
|
|
|
|
{
|
2012-04-18 19:48:19 +00:00
|
|
|
int ret;
|
2011-12-21 03:58:19 +00:00
|
|
|
struct net_device *ndev = dev_get_drvdata(dev);
|
2014-01-16 10:52:44 +00:00
|
|
|
struct stmmac_priv *priv = netdev_priv(ndev);
|
2012-04-18 19:48:19 +00:00
|
|
|
struct platform_device *pdev = to_platform_device(dev);
|
2011-12-21 03:58:19 +00:00
|
|
|
|
2016-05-01 20:58:19 +00:00
|
|
|
ret = stmmac_suspend(dev);
|
2016-11-05 13:04:52 +00:00
|
|
|
if (priv->plat->exit)
|
2014-01-17 13:24:42 +00:00
|
|
|
priv->plat->exit(pdev, priv->plat->bsp_priv);
|
2012-04-18 19:48:19 +00:00
|
|
|
|
|
|
|
return ret;
|
2011-12-21 03:58:19 +00:00
|
|
|
}
|
|
|
|
|
2014-11-18 08:47:01 +00:00
|
|
|
/**
|
|
|
|
* stmmac_pltfr_resume
|
|
|
|
* @dev: device pointer
|
|
|
|
* Description: this function is invoked when resume the driver before calling
|
|
|
|
* the main resume function, on some platforms, it can call own init helper
|
|
|
|
* if required.
|
|
|
|
*/
|
2014-01-16 10:52:44 +00:00
|
|
|
static int stmmac_pltfr_resume(struct device *dev)
|
2011-12-21 03:58:19 +00:00
|
|
|
{
|
|
|
|
struct net_device *ndev = dev_get_drvdata(dev);
|
2014-01-16 10:52:44 +00:00
|
|
|
struct stmmac_priv *priv = netdev_priv(ndev);
|
2012-04-18 19:48:19 +00:00
|
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
|
|
|
2016-11-05 13:04:52 +00:00
|
|
|
if (priv->plat->init)
|
2014-01-17 13:24:42 +00:00
|
|
|
priv->plat->init(pdev, priv->plat->bsp_priv);
|
2011-12-21 03:58:19 +00:00
|
|
|
|
2016-05-01 20:58:19 +00:00
|
|
|
return stmmac_resume(dev);
|
2011-12-21 03:58:19 +00:00
|
|
|
}
|
2014-11-10 10:38:59 +00:00
|
|
|
#endif /* CONFIG_PM_SLEEP */
|
2011-12-21 03:58:19 +00:00
|
|
|
|
2015-05-14 10:10:58 +00:00
|
|
|
SIMPLE_DEV_PM_OPS(stmmac_pltfr_pm_ops, stmmac_pltfr_suspend,
|
|
|
|
stmmac_pltfr_resume);
|
|
|
|
EXPORT_SYMBOL_GPL(stmmac_pltfr_pm_ops);
|
2015-07-31 17:13:22 +00:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet platform support");
|
|
|
|
MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
|
|
|
|
MODULE_LICENSE("GPL");
|