Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | Copyright (C) 2007-2009 STMicroelectronics Ltd |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify it |
| 5 | under the terms and conditions of the GNU General Public License, |
| 6 | version 2, as published by the Free Software Foundation. |
| 7 | |
| 8 | This program is distributed in the hope it will be useful, but WITHOUT |
| 9 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | more details. |
| 12 | |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 13 | The full GNU General Public License is included in this distribution in |
| 14 | the file called "COPYING". |
| 15 | |
| 16 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> |
| 17 | *******************************************************************************/ |
| 18 | |
| 19 | #include <linux/io.h> |
LABBE Corentin | 8a70aec | 2017-02-08 09:31:13 +0100 | [diff] [blame] | 20 | #include <linux/iopoll.h> |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 21 | #include "common.h" |
| 22 | #include "dwmac_dma.h" |
| 23 | |
Giuseppe CAVALLARO | cffb13f | 2012-05-13 22:18:41 +0000 | [diff] [blame] | 24 | #define GMAC_HI_REG_AE 0x80000000 |
| 25 | |
Giuseppe Cavallaro | 495db27 | 2016-02-29 14:27:27 +0100 | [diff] [blame] | 26 | int dwmac_dma_reset(void __iomem *ioaddr) |
| 27 | { |
| 28 | u32 value = readl(ioaddr + DMA_BUS_MODE); |
LABBE Corentin | 8a70aec | 2017-02-08 09:31:13 +0100 | [diff] [blame] | 29 | int err; |
Giuseppe Cavallaro | 495db27 | 2016-02-29 14:27:27 +0100 | [diff] [blame] | 30 | |
| 31 | /* DMA SW reset */ |
| 32 | value |= DMA_BUS_MODE_SFT_RESET; |
| 33 | writel(value, ioaddr + DMA_BUS_MODE); |
Giuseppe Cavallaro | 495db27 | 2016-02-29 14:27:27 +0100 | [diff] [blame] | 34 | |
LABBE Corentin | 8a70aec | 2017-02-08 09:31:13 +0100 | [diff] [blame] | 35 | err = readl_poll_timeout(ioaddr + DMA_BUS_MODE, value, |
| 36 | !(value & DMA_BUS_MODE_SFT_RESET), |
| 37 | 100000, 10000); |
| 38 | if (err) |
Giuseppe Cavallaro | 495db27 | 2016-02-29 14:27:27 +0100 | [diff] [blame] | 39 | return -EBUSY; |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 44 | /* CSR1 enables the transmit DMA to check for new descriptor */ |
Giuseppe CAVALLARO | ad01b7d | 2010-08-23 20:40:42 +0000 | [diff] [blame] | 45 | void dwmac_enable_dma_transmission(void __iomem *ioaddr) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 46 | { |
| 47 | writel(1, ioaddr + DMA_XMT_POLL_DEMAND); |
| 48 | } |
| 49 | |
Joao Pinto | 4f513ec | 2017-03-15 11:04:46 +0000 | [diff] [blame] | 50 | void dwmac_enable_dma_irq(void __iomem *ioaddr, u32 chan) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 51 | { |
| 52 | writel(DMA_INTR_DEFAULT_MASK, ioaddr + DMA_INTR_ENA); |
| 53 | } |
| 54 | |
Joao Pinto | 4f513ec | 2017-03-15 11:04:46 +0000 | [diff] [blame] | 55 | void dwmac_disable_dma_irq(void __iomem *ioaddr, u32 chan) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 56 | { |
| 57 | writel(0, ioaddr + DMA_INTR_ENA); |
| 58 | } |
| 59 | |
Joao Pinto | ae4f0d4 | 2017-03-15 11:04:47 +0000 | [diff] [blame] | 60 | void dwmac_dma_start_tx(void __iomem *ioaddr, u32 chan) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 61 | { |
| 62 | u32 value = readl(ioaddr + DMA_CONTROL); |
| 63 | value |= DMA_CONTROL_ST; |
| 64 | writel(value, ioaddr + DMA_CONTROL); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Joao Pinto | ae4f0d4 | 2017-03-15 11:04:47 +0000 | [diff] [blame] | 67 | void dwmac_dma_stop_tx(void __iomem *ioaddr, u32 chan) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 68 | { |
| 69 | u32 value = readl(ioaddr + DMA_CONTROL); |
| 70 | value &= ~DMA_CONTROL_ST; |
| 71 | writel(value, ioaddr + DMA_CONTROL); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Joao Pinto | ae4f0d4 | 2017-03-15 11:04:47 +0000 | [diff] [blame] | 74 | void dwmac_dma_start_rx(void __iomem *ioaddr, u32 chan) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 75 | { |
| 76 | u32 value = readl(ioaddr + DMA_CONTROL); |
| 77 | value |= DMA_CONTROL_SR; |
| 78 | writel(value, ioaddr + DMA_CONTROL); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Joao Pinto | ae4f0d4 | 2017-03-15 11:04:47 +0000 | [diff] [blame] | 81 | void dwmac_dma_stop_rx(void __iomem *ioaddr, u32 chan) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 82 | { |
| 83 | u32 value = readl(ioaddr + DMA_CONTROL); |
| 84 | value &= ~DMA_CONTROL_SR; |
| 85 | writel(value, ioaddr + DMA_CONTROL); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | #ifdef DWMAC_DMA_DEBUG |
| 89 | static void show_tx_process_state(unsigned int status) |
| 90 | { |
| 91 | unsigned int state; |
| 92 | state = (status & DMA_STATUS_TS_MASK) >> DMA_STATUS_TS_SHIFT; |
| 93 | |
| 94 | switch (state) { |
| 95 | case 0: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 96 | pr_debug("- TX (Stopped): Reset or Stop command\n"); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 97 | break; |
| 98 | case 1: |
LABBE Corentin | 8d45e42 | 2017-02-08 09:31:08 +0100 | [diff] [blame] | 99 | pr_debug("- TX (Running): Fetching the Tx desc\n"); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 100 | break; |
| 101 | case 2: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 102 | pr_debug("- TX (Running): Waiting for end of tx\n"); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 103 | break; |
| 104 | case 3: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 105 | pr_debug("- TX (Running): Reading the data " |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 106 | "and queuing the data into the Tx buf\n"); |
| 107 | break; |
| 108 | case 6: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 109 | pr_debug("- TX (Suspended): Tx Buff Underflow " |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 110 | "or an unavailable Transmit descriptor\n"); |
| 111 | break; |
| 112 | case 7: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 113 | pr_debug("- TX (Running): Closing Tx descriptor\n"); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 114 | break; |
| 115 | default: |
| 116 | break; |
| 117 | } |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | static void show_rx_process_state(unsigned int status) |
| 121 | { |
| 122 | unsigned int state; |
| 123 | state = (status & DMA_STATUS_RS_MASK) >> DMA_STATUS_RS_SHIFT; |
| 124 | |
| 125 | switch (state) { |
| 126 | case 0: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 127 | pr_debug("- RX (Stopped): Reset or Stop command\n"); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 128 | break; |
| 129 | case 1: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 130 | pr_debug("- RX (Running): Fetching the Rx desc\n"); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 131 | break; |
| 132 | case 2: |
LABBE Corentin | 8d45e42 | 2017-02-08 09:31:08 +0100 | [diff] [blame] | 133 | pr_debug("- RX (Running): Checking for end of pkt\n"); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 134 | break; |
| 135 | case 3: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 136 | pr_debug("- RX (Running): Waiting for Rx pkt\n"); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 137 | break; |
| 138 | case 4: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 139 | pr_debug("- RX (Suspended): Unavailable Rx buf\n"); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 140 | break; |
| 141 | case 5: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 142 | pr_debug("- RX (Running): Closing Rx descriptor\n"); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 143 | break; |
| 144 | case 6: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 145 | pr_debug("- RX(Running): Flushing the current frame" |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 146 | " from the Rx buf\n"); |
| 147 | break; |
| 148 | case 7: |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 149 | pr_debug("- RX (Running): Queuing the Rx frame" |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 150 | " from the Rx buf into memory\n"); |
| 151 | break; |
| 152 | default: |
| 153 | break; |
| 154 | } |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 155 | } |
| 156 | #endif |
| 157 | |
Giuseppe CAVALLARO | ad01b7d | 2010-08-23 20:40:42 +0000 | [diff] [blame] | 158 | int dwmac_dma_interrupt(void __iomem *ioaddr, |
Joao Pinto | d62a107 | 2017-03-15 11:04:49 +0000 | [diff] [blame] | 159 | struct stmmac_extra_stats *x, u32 chan) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 160 | { |
| 161 | int ret = 0; |
| 162 | /* read the status register (CSR5) */ |
| 163 | u32 intr_status = readl(ioaddr + DMA_STATUS); |
| 164 | |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 165 | #ifdef DWMAC_DMA_DEBUG |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 166 | /* Enable it to monitor DMA rx/tx status in case of critical problems */ |
| 167 | pr_debug("%s: [CSR5: 0x%08x]\n", __func__, intr_status); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 168 | show_tx_process_state(intr_status); |
| 169 | show_rx_process_state(intr_status); |
| 170 | #endif |
| 171 | /* ABNORMAL interrupts */ |
| 172 | if (unlikely(intr_status & DMA_STATUS_AIS)) { |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 173 | if (unlikely(intr_status & DMA_STATUS_UNF)) { |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 174 | ret = tx_hard_error_bump_tc; |
| 175 | x->tx_undeflow_irq++; |
| 176 | } |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 177 | if (unlikely(intr_status & DMA_STATUS_TJT)) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 178 | x->tx_jabber_irq++; |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 179 | |
| 180 | if (unlikely(intr_status & DMA_STATUS_OVF)) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 181 | x->rx_overflow_irq++; |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 182 | |
| 183 | if (unlikely(intr_status & DMA_STATUS_RU)) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 184 | x->rx_buf_unav_irq++; |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 185 | if (unlikely(intr_status & DMA_STATUS_RPS)) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 186 | x->rx_process_stopped_irq++; |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 187 | if (unlikely(intr_status & DMA_STATUS_RWT)) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 188 | x->rx_watchdog_irq++; |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 189 | if (unlikely(intr_status & DMA_STATUS_ETI)) |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 190 | x->tx_early_irq++; |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 191 | if (unlikely(intr_status & DMA_STATUS_TPS)) { |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 192 | x->tx_process_stopped_irq++; |
| 193 | ret = tx_hard_error; |
| 194 | } |
| 195 | if (unlikely(intr_status & DMA_STATUS_FBI)) { |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 196 | x->fatal_bus_error_irq++; |
| 197 | ret = tx_hard_error; |
| 198 | } |
| 199 | } |
| 200 | /* TX/RX NORMAL interrupts */ |
Giuseppe CAVALLARO | 62a2ab9 | 2012-11-25 23:10:43 +0000 | [diff] [blame] | 201 | if (likely(intr_status & DMA_STATUS_NIS)) { |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 202 | x->normal_irq_n++; |
Giuseppe CAVALLARO | 62a2ab9 | 2012-11-25 23:10:43 +0000 | [diff] [blame] | 203 | if (likely(intr_status & DMA_STATUS_RI)) { |
| 204 | u32 value = readl(ioaddr + DMA_INTR_ENA); |
| 205 | /* to schedule NAPI on real RIE event. */ |
| 206 | if (likely(value & DMA_INTR_ENA_RIE)) { |
| 207 | x->rx_normal_irq_n++; |
| 208 | ret |= handle_rx; |
| 209 | } |
| 210 | } |
| 211 | if (likely(intr_status & DMA_STATUS_TI)) { |
| 212 | x->tx_normal_irq_n++; |
Giuseppe CAVALLARO | 9125cdd | 2012-11-25 23:10:42 +0000 | [diff] [blame] | 213 | ret |= handle_tx; |
Giuseppe CAVALLARO | 62a2ab9 | 2012-11-25 23:10:43 +0000 | [diff] [blame] | 214 | } |
| 215 | if (unlikely(intr_status & DMA_STATUS_ERI)) |
| 216 | x->rx_early_irq++; |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 217 | } |
| 218 | /* Optional hardware blocks, interrupts should be disabled */ |
| 219 | if (unlikely(intr_status & |
| 220 | (DMA_STATUS_GPI | DMA_STATUS_GMI | DMA_STATUS_GLI))) |
Giuseppe CAVALLARO | 83d7af6 | 2013-07-02 14:12:36 +0200 | [diff] [blame] | 221 | pr_warn("%s: unexpected status %08x\n", __func__, intr_status); |
Giuseppe CAVALLARO | 62a2ab9 | 2012-11-25 23:10:43 +0000 | [diff] [blame] | 222 | |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 223 | /* Clear the interrupt by writing a logic 1 to the CSR5[15-0] */ |
| 224 | writel((intr_status & 0x1ffff), ioaddr + DMA_STATUS); |
| 225 | |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 226 | return ret; |
| 227 | } |
| 228 | |
Giuseppe CAVALLARO | ad01b7d | 2010-08-23 20:40:42 +0000 | [diff] [blame] | 229 | void dwmac_dma_flush_tx_fifo(void __iomem *ioaddr) |
Giuseppe CAVALLARO | 688911c | 2010-04-13 20:21:13 +0000 | [diff] [blame] | 230 | { |
| 231 | u32 csr6 = readl(ioaddr + DMA_CONTROL); |
| 232 | writel((csr6 | DMA_CONTROL_FTF), ioaddr + DMA_CONTROL); |
| 233 | |
| 234 | do {} while ((readl(ioaddr + DMA_CONTROL) & DMA_CONTROL_FTF)); |
| 235 | } |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 236 | |
Giuseppe CAVALLARO | ad01b7d | 2010-08-23 20:40:42 +0000 | [diff] [blame] | 237 | void stmmac_set_mac_addr(void __iomem *ioaddr, u8 addr[6], |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 238 | unsigned int high, unsigned int low) |
| 239 | { |
| 240 | unsigned long data; |
| 241 | |
| 242 | data = (addr[5] << 8) | addr[4]; |
LABBE Corentin | 8d45e42 | 2017-02-08 09:31:08 +0100 | [diff] [blame] | 243 | /* For MAC Addr registers we have to set the Address Enable (AE) |
Giuseppe CAVALLARO | cffb13f | 2012-05-13 22:18:41 +0000 | [diff] [blame] | 244 | * bit that has no effect on the High Reg 0 where the bit 31 (MO) |
| 245 | * is RO. |
| 246 | */ |
| 247 | writel(data | GMAC_HI_REG_AE, ioaddr + high); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 248 | data = (addr[3] << 24) | (addr[2] << 16) | (addr[1] << 8) | addr[0]; |
| 249 | writel(data, ioaddr + low); |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 250 | } |
| 251 | |
Giuseppe CAVALLARO | bfab27a | 2011-12-21 03:58:19 +0000 | [diff] [blame] | 252 | /* Enable disable MAC RX/TX */ |
| 253 | void stmmac_set_mac(void __iomem *ioaddr, bool enable) |
| 254 | { |
| 255 | u32 value = readl(ioaddr + MAC_CTRL_REG); |
| 256 | |
| 257 | if (enable) |
LABBE Corentin | 2808922 | 2017-02-08 09:31:06 +0100 | [diff] [blame] | 258 | value |= MAC_ENABLE_RX | MAC_ENABLE_TX; |
Giuseppe CAVALLARO | bfab27a | 2011-12-21 03:58:19 +0000 | [diff] [blame] | 259 | else |
LABBE Corentin | 2808922 | 2017-02-08 09:31:06 +0100 | [diff] [blame] | 260 | value &= ~(MAC_ENABLE_TX | MAC_ENABLE_RX); |
Giuseppe CAVALLARO | bfab27a | 2011-12-21 03:58:19 +0000 | [diff] [blame] | 261 | |
| 262 | writel(value, ioaddr + MAC_CTRL_REG); |
| 263 | } |
| 264 | |
Giuseppe CAVALLARO | ad01b7d | 2010-08-23 20:40:42 +0000 | [diff] [blame] | 265 | void stmmac_get_mac_addr(void __iomem *ioaddr, unsigned char *addr, |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 266 | unsigned int high, unsigned int low) |
| 267 | { |
| 268 | unsigned int hi_addr, lo_addr; |
| 269 | |
| 270 | /* Read the MAC address from the hardware */ |
| 271 | hi_addr = readl(ioaddr + high); |
| 272 | lo_addr = readl(ioaddr + low); |
| 273 | |
| 274 | /* Extract the MAC address from the high and low words */ |
| 275 | addr[0] = lo_addr & 0xff; |
| 276 | addr[1] = (lo_addr >> 8) & 0xff; |
| 277 | addr[2] = (lo_addr >> 16) & 0xff; |
| 278 | addr[3] = (lo_addr >> 24) & 0xff; |
| 279 | addr[4] = hi_addr & 0xff; |
| 280 | addr[5] = (hi_addr >> 8) & 0xff; |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 281 | } |
| 282 | |