|
@@ -202,7 +202,6 @@ static void stmmac_adjust_link(struct net_device *dev)
|
|
|
{
|
|
|
struct stmmac_priv *priv = netdev_priv(dev);
|
|
|
struct phy_device *phydev = priv->phydev;
|
|
|
- unsigned long ioaddr = dev->base_addr;
|
|
|
unsigned long flags;
|
|
|
int new_state = 0;
|
|
|
unsigned int fc = priv->flow_ctrl, pause_time = priv->pause;
|
|
@@ -215,7 +214,7 @@ static void stmmac_adjust_link(struct net_device *dev)
|
|
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
|
if (phydev->link) {
|
|
|
- u32 ctrl = readl(ioaddr + MAC_CTRL_REG);
|
|
|
+ u32 ctrl = readl(priv->ioaddr + MAC_CTRL_REG);
|
|
|
|
|
|
/* Now we make sure that we can be in full duplex mode.
|
|
|
* If not, we operate in half-duplex mode. */
|
|
@@ -229,7 +228,7 @@ static void stmmac_adjust_link(struct net_device *dev)
|
|
|
}
|
|
|
/* Flow Control operation */
|
|
|
if (phydev->pause)
|
|
|
- priv->hw->mac->flow_ctrl(ioaddr, phydev->duplex,
|
|
|
+ priv->hw->mac->flow_ctrl(priv->ioaddr, phydev->duplex,
|
|
|
fc, pause_time);
|
|
|
|
|
|
if (phydev->speed != priv->speed) {
|
|
@@ -268,7 +267,7 @@ static void stmmac_adjust_link(struct net_device *dev)
|
|
|
priv->speed = phydev->speed;
|
|
|
}
|
|
|
|
|
|
- writel(ctrl, ioaddr + MAC_CTRL_REG);
|
|
|
+ writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
|
|
|
|
|
|
if (!priv->oldlink) {
|
|
|
new_state = 1;
|
|
@@ -345,7 +344,7 @@ static int stmmac_init_phy(struct net_device *dev)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static inline void stmmac_mac_enable_rx(unsigned long ioaddr)
|
|
|
+static inline void stmmac_mac_enable_rx(void __iomem *ioaddr)
|
|
|
{
|
|
|
u32 value = readl(ioaddr + MAC_CTRL_REG);
|
|
|
value |= MAC_RNABLE_RX;
|
|
@@ -353,7 +352,7 @@ static inline void stmmac_mac_enable_rx(unsigned long ioaddr)
|
|
|
writel(value, ioaddr + MAC_CTRL_REG);
|
|
|
}
|
|
|
|
|
|
-static inline void stmmac_mac_enable_tx(unsigned long ioaddr)
|
|
|
+static inline void stmmac_mac_enable_tx(void __iomem *ioaddr)
|
|
|
{
|
|
|
u32 value = readl(ioaddr + MAC_CTRL_REG);
|
|
|
value |= MAC_ENABLE_TX;
|
|
@@ -361,14 +360,14 @@ static inline void stmmac_mac_enable_tx(unsigned long ioaddr)
|
|
|
writel(value, ioaddr + MAC_CTRL_REG);
|
|
|
}
|
|
|
|
|
|
-static inline void stmmac_mac_disable_rx(unsigned long ioaddr)
|
|
|
+static inline void stmmac_mac_disable_rx(void __iomem *ioaddr)
|
|
|
{
|
|
|
u32 value = readl(ioaddr + MAC_CTRL_REG);
|
|
|
value &= ~MAC_RNABLE_RX;
|
|
|
writel(value, ioaddr + MAC_CTRL_REG);
|
|
|
}
|
|
|
|
|
|
-static inline void stmmac_mac_disable_tx(unsigned long ioaddr)
|
|
|
+static inline void stmmac_mac_disable_tx(void __iomem *ioaddr)
|
|
|
{
|
|
|
u32 value = readl(ioaddr + MAC_CTRL_REG);
|
|
|
value &= ~MAC_ENABLE_TX;
|
|
@@ -577,17 +576,17 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
|
|
|
{
|
|
|
if (!priv->is_gmac) {
|
|
|
/* MAC 10/100 */
|
|
|
- priv->hw->dma->dma_mode(priv->dev->base_addr, tc, 0);
|
|
|
+ priv->hw->dma->dma_mode(priv->ioaddr, tc, 0);
|
|
|
priv->tx_coe = NO_HW_CSUM;
|
|
|
} else {
|
|
|
if ((priv->dev->mtu <= ETH_DATA_LEN) && (tx_coe)) {
|
|
|
- priv->hw->dma->dma_mode(priv->dev->base_addr,
|
|
|
+ priv->hw->dma->dma_mode(priv->ioaddr,
|
|
|
SF_DMA_MODE, SF_DMA_MODE);
|
|
|
tc = SF_DMA_MODE;
|
|
|
priv->tx_coe = HW_CSUM;
|
|
|
} else {
|
|
|
/* Checksum computation is performed in software. */
|
|
|
- priv->hw->dma->dma_mode(priv->dev->base_addr, tc,
|
|
|
+ priv->hw->dma->dma_mode(priv->ioaddr, tc,
|
|
|
SF_DMA_MODE);
|
|
|
priv->tx_coe = NO_HW_CSUM;
|
|
|
}
|
|
@@ -603,7 +602,6 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
|
|
|
static void stmmac_tx(struct stmmac_priv *priv)
|
|
|
{
|
|
|
unsigned int txsize = priv->dma_tx_size;
|
|
|
- unsigned long ioaddr = priv->dev->base_addr;
|
|
|
|
|
|
while (priv->dirty_tx != priv->cur_tx) {
|
|
|
int last;
|
|
@@ -621,7 +619,7 @@ static void stmmac_tx(struct stmmac_priv *priv)
|
|
|
int tx_error =
|
|
|
priv->hw->desc->tx_status(&priv->dev->stats,
|
|
|
&priv->xstats, p,
|
|
|
- ioaddr);
|
|
|
+ priv->ioaddr);
|
|
|
if (likely(tx_error == 0)) {
|
|
|
priv->dev->stats.tx_packets++;
|
|
|
priv->xstats.tx_pkt_n++;
|
|
@@ -677,7 +675,7 @@ static inline void stmmac_enable_irq(struct stmmac_priv *priv)
|
|
|
priv->tm->timer_start(tmrate);
|
|
|
else
|
|
|
#endif
|
|
|
- priv->hw->dma->enable_dma_irq(priv->dev->base_addr);
|
|
|
+ priv->hw->dma->enable_dma_irq(priv->ioaddr);
|
|
|
}
|
|
|
|
|
|
static inline void stmmac_disable_irq(struct stmmac_priv *priv)
|
|
@@ -687,7 +685,7 @@ static inline void stmmac_disable_irq(struct stmmac_priv *priv)
|
|
|
priv->tm->timer_stop();
|
|
|
else
|
|
|
#endif
|
|
|
- priv->hw->dma->disable_dma_irq(priv->dev->base_addr);
|
|
|
+ priv->hw->dma->disable_dma_irq(priv->ioaddr);
|
|
|
}
|
|
|
|
|
|
static int stmmac_has_work(struct stmmac_priv *priv)
|
|
@@ -742,14 +740,15 @@ static void stmmac_no_timer_stopped(void)
|
|
|
*/
|
|
|
static void stmmac_tx_err(struct stmmac_priv *priv)
|
|
|
{
|
|
|
+
|
|
|
netif_stop_queue(priv->dev);
|
|
|
|
|
|
- priv->hw->dma->stop_tx(priv->dev->base_addr);
|
|
|
+ priv->hw->dma->stop_tx(priv->ioaddr);
|
|
|
dma_free_tx_skbufs(priv);
|
|
|
priv->hw->desc->init_tx_desc(priv->dma_tx, priv->dma_tx_size);
|
|
|
priv->dirty_tx = 0;
|
|
|
priv->cur_tx = 0;
|
|
|
- priv->hw->dma->start_tx(priv->dev->base_addr);
|
|
|
+ priv->hw->dma->start_tx(priv->ioaddr);
|
|
|
|
|
|
priv->dev->stats.tx_errors++;
|
|
|
netif_wake_queue(priv->dev);
|
|
@@ -758,11 +757,9 @@ static void stmmac_tx_err(struct stmmac_priv *priv)
|
|
|
|
|
|
static void stmmac_dma_interrupt(struct stmmac_priv *priv)
|
|
|
{
|
|
|
- unsigned long ioaddr = priv->dev->base_addr;
|
|
|
int status;
|
|
|
|
|
|
- status = priv->hw->dma->dma_interrupt(priv->dev->base_addr,
|
|
|
- &priv->xstats);
|
|
|
+ status = priv->hw->dma->dma_interrupt(priv->ioaddr, &priv->xstats);
|
|
|
if (likely(status == handle_tx_rx))
|
|
|
_stmmac_schedule(priv);
|
|
|
|
|
@@ -770,7 +767,7 @@ static void stmmac_dma_interrupt(struct stmmac_priv *priv)
|
|
|
/* Try to bump up the dma threshold on this failure */
|
|
|
if (unlikely(tc != SF_DMA_MODE) && (tc <= 256)) {
|
|
|
tc += 64;
|
|
|
- priv->hw->dma->dma_mode(ioaddr, tc, SF_DMA_MODE);
|
|
|
+ priv->hw->dma->dma_mode(priv->ioaddr, tc, SF_DMA_MODE);
|
|
|
priv->xstats.threshold = tc;
|
|
|
}
|
|
|
stmmac_tx_err(priv);
|
|
@@ -790,7 +787,6 @@ static void stmmac_dma_interrupt(struct stmmac_priv *priv)
|
|
|
static int stmmac_open(struct net_device *dev)
|
|
|
{
|
|
|
struct stmmac_priv *priv = netdev_priv(dev);
|
|
|
- unsigned long ioaddr = dev->base_addr;
|
|
|
int ret;
|
|
|
|
|
|
/* Check that the MAC address is valid. If its not, refuse
|
|
@@ -846,7 +842,8 @@ static int stmmac_open(struct net_device *dev)
|
|
|
init_dma_desc_rings(dev);
|
|
|
|
|
|
/* DMA initialization and SW reset */
|
|
|
- if (unlikely(priv->hw->dma->init(ioaddr, priv->pbl, priv->dma_tx_phy,
|
|
|
+ if (unlikely(priv->hw->dma->init(priv->ioaddr, priv->pbl,
|
|
|
+ priv->dma_tx_phy,
|
|
|
priv->dma_rx_phy) < 0)) {
|
|
|
|
|
|
pr_err("%s: DMA initialization failed\n", __func__);
|
|
@@ -854,22 +851,22 @@ static int stmmac_open(struct net_device *dev)
|
|
|
}
|
|
|
|
|
|
/* Copy the MAC addr into the HW */
|
|
|
- priv->hw->mac->set_umac_addr(ioaddr, dev->dev_addr, 0);
|
|
|
+ priv->hw->mac->set_umac_addr(priv->ioaddr, dev->dev_addr, 0);
|
|
|
/* If required, perform hw setup of the bus. */
|
|
|
if (priv->bus_setup)
|
|
|
- priv->bus_setup(ioaddr);
|
|
|
+ priv->bus_setup(priv->ioaddr);
|
|
|
/* Initialize the MAC Core */
|
|
|
- priv->hw->mac->core_init(ioaddr);
|
|
|
+ priv->hw->mac->core_init(priv->ioaddr);
|
|
|
|
|
|
priv->shutdown = 0;
|
|
|
|
|
|
/* Initialise the MMC (if present) to disable all interrupts. */
|
|
|
- writel(0xffffffff, ioaddr + MMC_HIGH_INTR_MASK);
|
|
|
- writel(0xffffffff, ioaddr + MMC_LOW_INTR_MASK);
|
|
|
+ writel(0xffffffff, priv->ioaddr + MMC_HIGH_INTR_MASK);
|
|
|
+ writel(0xffffffff, priv->ioaddr + MMC_LOW_INTR_MASK);
|
|
|
|
|
|
/* Enable the MAC Rx/Tx */
|
|
|
- stmmac_mac_enable_rx(ioaddr);
|
|
|
- stmmac_mac_enable_tx(ioaddr);
|
|
|
+ stmmac_mac_enable_rx(priv->ioaddr);
|
|
|
+ stmmac_mac_enable_tx(priv->ioaddr);
|
|
|
|
|
|
/* Set the HW DMA mode and the COE */
|
|
|
stmmac_dma_operation_mode(priv);
|
|
@@ -880,16 +877,16 @@ static int stmmac_open(struct net_device *dev)
|
|
|
|
|
|
/* Start the ball rolling... */
|
|
|
DBG(probe, DEBUG, "%s: DMA RX/TX processes started...\n", dev->name);
|
|
|
- priv->hw->dma->start_tx(ioaddr);
|
|
|
- priv->hw->dma->start_rx(ioaddr);
|
|
|
+ priv->hw->dma->start_tx(priv->ioaddr);
|
|
|
+ priv->hw->dma->start_rx(priv->ioaddr);
|
|
|
|
|
|
#ifdef CONFIG_STMMAC_TIMER
|
|
|
priv->tm->timer_start(tmrate);
|
|
|
#endif
|
|
|
/* Dump DMA/MAC registers */
|
|
|
if (netif_msg_hw(priv)) {
|
|
|
- priv->hw->mac->dump_regs(ioaddr);
|
|
|
- priv->hw->dma->dump_regs(ioaddr);
|
|
|
+ priv->hw->mac->dump_regs(priv->ioaddr);
|
|
|
+ priv->hw->dma->dump_regs(priv->ioaddr);
|
|
|
}
|
|
|
|
|
|
if (priv->phydev)
|
|
@@ -933,15 +930,15 @@ static int stmmac_release(struct net_device *dev)
|
|
|
free_irq(dev->irq, dev);
|
|
|
|
|
|
/* Stop TX/RX DMA and clear the descriptors */
|
|
|
- priv->hw->dma->stop_tx(dev->base_addr);
|
|
|
- priv->hw->dma->stop_rx(dev->base_addr);
|
|
|
+ priv->hw->dma->stop_tx(priv->ioaddr);
|
|
|
+ priv->hw->dma->stop_rx(priv->ioaddr);
|
|
|
|
|
|
/* Release and free the Rx/Tx resources */
|
|
|
free_dma_desc_resources(priv);
|
|
|
|
|
|
/* Disable the MAC core */
|
|
|
- stmmac_mac_disable_tx(dev->base_addr);
|
|
|
- stmmac_mac_disable_rx(dev->base_addr);
|
|
|
+ stmmac_mac_disable_tx(priv->ioaddr);
|
|
|
+ stmmac_mac_disable_rx(priv->ioaddr);
|
|
|
|
|
|
netif_carrier_off(dev);
|
|
|
|
|
@@ -1143,7 +1140,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
|
|
dev->stats.tx_bytes += skb->len;
|
|
|
|
|
|
- priv->hw->dma->enable_dma_transmission(dev->base_addr);
|
|
|
+ priv->hw->dma->enable_dma_transmission(priv->ioaddr);
|
|
|
|
|
|
return NETDEV_TX_OK;
|
|
|
}
|
|
@@ -1408,11 +1405,9 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)
|
|
|
return IRQ_NONE;
|
|
|
}
|
|
|
|
|
|
- if (priv->is_gmac) {
|
|
|
- unsigned long ioaddr = dev->base_addr;
|
|
|
+ if (priv->is_gmac)
|
|
|
/* To handle GMAC own interrupts */
|
|
|
- priv->hw->mac->host_irq_status(ioaddr);
|
|
|
- }
|
|
|
+ priv->hw->mac->host_irq_status((void __iomem *) dev->base_addr);
|
|
|
|
|
|
stmmac_dma_interrupt(priv);
|
|
|
|
|
@@ -1525,7 +1520,8 @@ static int stmmac_probe(struct net_device *dev)
|
|
|
netif_napi_add(dev, &priv->napi, stmmac_poll, 64);
|
|
|
|
|
|
/* Get the MAC address */
|
|
|
- priv->hw->mac->get_umac_addr(dev->base_addr, dev->dev_addr, 0);
|
|
|
+ priv->hw->mac->get_umac_addr((void __iomem *) dev->base_addr,
|
|
|
+ dev->dev_addr, 0);
|
|
|
|
|
|
if (!is_valid_ether_addr(dev->dev_addr))
|
|
|
pr_warning("\tno valid MAC address;"
|
|
@@ -1555,14 +1551,13 @@ static int stmmac_probe(struct net_device *dev)
|
|
|
static int stmmac_mac_device_setup(struct net_device *dev)
|
|
|
{
|
|
|
struct stmmac_priv *priv = netdev_priv(dev);
|
|
|
- unsigned long ioaddr = dev->base_addr;
|
|
|
|
|
|
struct mac_device_info *device;
|
|
|
|
|
|
if (priv->is_gmac)
|
|
|
- device = dwmac1000_setup(ioaddr);
|
|
|
+ device = dwmac1000_setup(priv->ioaddr);
|
|
|
else
|
|
|
- device = dwmac100_setup(ioaddr);
|
|
|
+ device = dwmac100_setup(priv->ioaddr);
|
|
|
|
|
|
if (!device)
|
|
|
return -ENOMEM;
|
|
@@ -1656,7 +1651,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
|
|
|
{
|
|
|
int ret = 0;
|
|
|
struct resource *res;
|
|
|
- unsigned int *addr = NULL;
|
|
|
+ void __iomem *addr = NULL;
|
|
|
struct net_device *ndev = NULL;
|
|
|
struct stmmac_priv *priv;
|
|
|
struct plat_stmmacenet_data *plat_dat;
|
|
@@ -1711,6 +1706,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
|
|
|
priv->pbl = plat_dat->pbl; /* TLI */
|
|
|
priv->is_gmac = plat_dat->has_gmac; /* GMAC is on board */
|
|
|
priv->enh_desc = plat_dat->enh_desc;
|
|
|
+ priv->ioaddr = addr;
|
|
|
|
|
|
platform_set_drvdata(pdev, ndev);
|
|
|
|
|
@@ -1782,11 +1778,11 @@ static int stmmac_dvr_remove(struct platform_device *pdev)
|
|
|
|
|
|
pr_info("%s:\n\tremoving driver", __func__);
|
|
|
|
|
|
- priv->hw->dma->stop_rx(ndev->base_addr);
|
|
|
- priv->hw->dma->stop_tx(ndev->base_addr);
|
|
|
+ priv->hw->dma->stop_rx(priv->ioaddr);
|
|
|
+ priv->hw->dma->stop_tx(priv->ioaddr);
|
|
|
|
|
|
- stmmac_mac_disable_rx(ndev->base_addr);
|
|
|
- stmmac_mac_disable_tx(ndev->base_addr);
|
|
|
+ stmmac_mac_disable_rx(priv->ioaddr);
|
|
|
+ stmmac_mac_disable_tx(priv->ioaddr);
|
|
|
|
|
|
netif_carrier_off(ndev);
|
|
|
|
|
@@ -1795,7 +1791,7 @@ static int stmmac_dvr_remove(struct platform_device *pdev)
|
|
|
platform_set_drvdata(pdev, NULL);
|
|
|
unregister_netdev(ndev);
|
|
|
|
|
|
- iounmap((void *)ndev->base_addr);
|
|
|
+ iounmap((void *)priv->ioaddr);
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
release_mem_region(res->start, resource_size(res));
|
|
|
|
|
@@ -1830,22 +1826,21 @@ static int stmmac_suspend(struct platform_device *pdev, pm_message_t state)
|
|
|
napi_disable(&priv->napi);
|
|
|
|
|
|
/* Stop TX/RX DMA */
|
|
|
- priv->hw->dma->stop_tx(dev->base_addr);
|
|
|
- priv->hw->dma->stop_rx(dev->base_addr);
|
|
|
+ priv->hw->dma->stop_tx(priv->ioaddr);
|
|
|
+ priv->hw->dma->stop_rx(priv->ioaddr);
|
|
|
/* Clear the Rx/Tx descriptors */
|
|
|
priv->hw->desc->init_rx_desc(priv->dma_rx, priv->dma_rx_size,
|
|
|
dis_ic);
|
|
|
priv->hw->desc->init_tx_desc(priv->dma_tx, priv->dma_tx_size);
|
|
|
|
|
|
- stmmac_mac_disable_tx(dev->base_addr);
|
|
|
+ stmmac_mac_disable_tx(priv->ioaddr);
|
|
|
|
|
|
if (device_may_wakeup(&(pdev->dev))) {
|
|
|
/* Enable Power down mode by programming the PMT regs */
|
|
|
if (priv->wolenabled == PMT_SUPPORTED)
|
|
|
- priv->hw->mac->pmt(dev->base_addr,
|
|
|
- priv->wolopts);
|
|
|
+ priv->hw->mac->pmt(priv->ioaddr, priv->wolopts);
|
|
|
} else {
|
|
|
- stmmac_mac_disable_rx(dev->base_addr);
|
|
|
+ stmmac_mac_disable_rx(priv->ioaddr);
|
|
|
}
|
|
|
} else {
|
|
|
priv->shutdown = 1;
|
|
@@ -1863,7 +1858,6 @@ static int stmmac_resume(struct platform_device *pdev)
|
|
|
{
|
|
|
struct net_device *dev = platform_get_drvdata(pdev);
|
|
|
struct stmmac_priv *priv = netdev_priv(dev);
|
|
|
- unsigned long ioaddr = dev->base_addr;
|
|
|
|
|
|
if (!netif_running(dev))
|
|
|
return 0;
|
|
@@ -1884,15 +1878,15 @@ static int stmmac_resume(struct platform_device *pdev)
|
|
|
* from another devices (e.g. serial console). */
|
|
|
if (device_may_wakeup(&(pdev->dev)))
|
|
|
if (priv->wolenabled == PMT_SUPPORTED)
|
|
|
- priv->hw->mac->pmt(dev->base_addr, 0);
|
|
|
+ priv->hw->mac->pmt(priv->ioaddr, 0);
|
|
|
|
|
|
netif_device_attach(dev);
|
|
|
|
|
|
/* Enable the MAC and DMA */
|
|
|
- stmmac_mac_enable_rx(ioaddr);
|
|
|
- stmmac_mac_enable_tx(ioaddr);
|
|
|
- priv->hw->dma->start_tx(ioaddr);
|
|
|
- priv->hw->dma->start_rx(ioaddr);
|
|
|
+ stmmac_mac_enable_rx(priv->ioaddr);
|
|
|
+ stmmac_mac_enable_tx(priv->ioaddr);
|
|
|
+ priv->hw->dma->start_tx(priv->ioaddr);
|
|
|
+ priv->hw->dma->start_rx(priv->ioaddr);
|
|
|
|
|
|
#ifdef CONFIG_STMMAC_TIMER
|
|
|
priv->tm->timer_start(tmrate);
|