Grygorii Strashko | 39b014a | 2018-10-31 16:21:42 -0500 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 2 | /* |
| 3 | * CPSW Ethernet Switch Driver |
| 4 | * |
Grygorii Strashko | 39b014a | 2018-10-31 16:21:42 -0500 | [diff] [blame] | 5 | * Copyright (C) 2010-2018 Texas Instruments Incorporated - http://www.ti.com/ |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | #include <net.h> |
| 11 | #include <miiphy.h> |
| 12 | #include <malloc.h> |
| 13 | #include <net.h> |
| 14 | #include <netdev.h> |
| 15 | #include <cpsw.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 16 | #include <linux/errno.h> |
Vignesh R | 8e9473d | 2016-08-02 10:14:27 +0530 | [diff] [blame] | 17 | #include <asm/gpio.h> |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 18 | #include <asm/io.h> |
| 19 | #include <phy.h> |
Tom Rini | 8eb48ff | 2013-03-14 11:15:25 +0000 | [diff] [blame] | 20 | #include <asm/arch/cpu.h> |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 21 | #include <dm.h> |
| 22 | |
Grygorii Strashko | eae545a | 2018-10-31 16:21:44 -0500 | [diff] [blame] | 23 | #include "cpsw_mdio.h" |
| 24 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 25 | #define BITMASK(bits) (BIT(bits) - 1) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 26 | #define NUM_DESCS (PKTBUFSRX * 2) |
| 27 | #define PKT_MIN 60 |
| 28 | #define PKT_MAX (1500 + 14 + 4 + 4) |
| 29 | #define CLEAR_BIT 1 |
| 30 | #define GIGABITEN BIT(7) |
| 31 | #define FULLDUPLEXEN BIT(0) |
| 32 | #define MIIEN BIT(15) |
Grygorii Strashko | 63bba7e | 2019-09-19 11:16:37 +0300 | [diff] [blame] | 33 | #define CTL_EXT_EN BIT(18) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 34 | /* DMA Registers */ |
| 35 | #define CPDMA_TXCONTROL 0x004 |
| 36 | #define CPDMA_RXCONTROL 0x014 |
| 37 | #define CPDMA_SOFTRESET 0x01c |
| 38 | #define CPDMA_RXFREE 0x0e0 |
| 39 | #define CPDMA_TXHDP_VER1 0x100 |
| 40 | #define CPDMA_TXHDP_VER2 0x200 |
| 41 | #define CPDMA_RXHDP_VER1 0x120 |
| 42 | #define CPDMA_RXHDP_VER2 0x220 |
| 43 | #define CPDMA_TXCP_VER1 0x140 |
| 44 | #define CPDMA_TXCP_VER2 0x240 |
| 45 | #define CPDMA_RXCP_VER1 0x160 |
| 46 | #define CPDMA_RXCP_VER2 0x260 |
| 47 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 48 | /* Descriptor mode bits */ |
| 49 | #define CPDMA_DESC_SOP BIT(31) |
| 50 | #define CPDMA_DESC_EOP BIT(30) |
| 51 | #define CPDMA_DESC_OWNER BIT(29) |
| 52 | #define CPDMA_DESC_EOQ BIT(28) |
| 53 | |
| 54 | /* |
| 55 | * This timeout definition is a worst-case ultra defensive measure against |
| 56 | * unexpected controller lock ups. Ideally, we should never ever hit this |
| 57 | * scenario in practice. |
| 58 | */ |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 59 | #define CPDMA_TIMEOUT 100 /* msecs */ |
| 60 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 61 | struct cpsw_regs { |
| 62 | u32 id_ver; |
| 63 | u32 control; |
| 64 | u32 soft_reset; |
| 65 | u32 stat_port_en; |
| 66 | u32 ptype; |
| 67 | }; |
| 68 | |
| 69 | struct cpsw_slave_regs { |
| 70 | u32 max_blks; |
| 71 | u32 blk_cnt; |
| 72 | u32 flow_thresh; |
| 73 | u32 port_vlan; |
| 74 | u32 tx_pri_map; |
Matt Porter | 1ef0e87 | 2013-03-20 05:38:12 +0000 | [diff] [blame] | 75 | #ifdef CONFIG_AM33XX |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 76 | u32 gap_thresh; |
Matt Porter | 1ef0e87 | 2013-03-20 05:38:12 +0000 | [diff] [blame] | 77 | #elif defined(CONFIG_TI814X) |
| 78 | u32 ts_ctl; |
| 79 | u32 ts_seq_ltype; |
| 80 | u32 ts_vlan; |
| 81 | #endif |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 82 | u32 sa_lo; |
| 83 | u32 sa_hi; |
| 84 | }; |
| 85 | |
| 86 | struct cpsw_host_regs { |
| 87 | u32 max_blks; |
| 88 | u32 blk_cnt; |
| 89 | u32 flow_thresh; |
| 90 | u32 port_vlan; |
| 91 | u32 tx_pri_map; |
| 92 | u32 cpdma_tx_pri_map; |
| 93 | u32 cpdma_rx_chan_map; |
| 94 | }; |
| 95 | |
| 96 | struct cpsw_sliver_regs { |
| 97 | u32 id_ver; |
| 98 | u32 mac_control; |
| 99 | u32 mac_status; |
| 100 | u32 soft_reset; |
| 101 | u32 rx_maxlen; |
| 102 | u32 __reserved_0; |
| 103 | u32 rx_pause; |
| 104 | u32 tx_pause; |
| 105 | u32 __reserved_1; |
| 106 | u32 rx_pri_map; |
| 107 | }; |
| 108 | |
| 109 | #define ALE_ENTRY_BITS 68 |
| 110 | #define ALE_ENTRY_WORDS DIV_ROUND_UP(ALE_ENTRY_BITS, 32) |
| 111 | |
| 112 | /* ALE Registers */ |
| 113 | #define ALE_CONTROL 0x08 |
| 114 | #define ALE_UNKNOWNVLAN 0x18 |
| 115 | #define ALE_TABLE_CONTROL 0x20 |
| 116 | #define ALE_TABLE 0x34 |
| 117 | #define ALE_PORTCTL 0x40 |
| 118 | |
| 119 | #define ALE_TABLE_WRITE BIT(31) |
| 120 | |
| 121 | #define ALE_TYPE_FREE 0 |
| 122 | #define ALE_TYPE_ADDR 1 |
| 123 | #define ALE_TYPE_VLAN 2 |
| 124 | #define ALE_TYPE_VLAN_ADDR 3 |
| 125 | |
| 126 | #define ALE_UCAST_PERSISTANT 0 |
| 127 | #define ALE_UCAST_UNTOUCHED 1 |
| 128 | #define ALE_UCAST_OUI 2 |
| 129 | #define ALE_UCAST_TOUCHED 3 |
| 130 | |
| 131 | #define ALE_MCAST_FWD 0 |
| 132 | #define ALE_MCAST_BLOCK_LEARN_FWD 1 |
| 133 | #define ALE_MCAST_FWD_LEARN 2 |
| 134 | #define ALE_MCAST_FWD_2 3 |
| 135 | |
| 136 | enum cpsw_ale_port_state { |
| 137 | ALE_PORT_STATE_DISABLE = 0x00, |
| 138 | ALE_PORT_STATE_BLOCK = 0x01, |
| 139 | ALE_PORT_STATE_LEARN = 0x02, |
| 140 | ALE_PORT_STATE_FORWARD = 0x03, |
| 141 | }; |
| 142 | |
| 143 | /* ALE unicast entry flags - passed into cpsw_ale_add_ucast() */ |
| 144 | #define ALE_SECURE 1 |
| 145 | #define ALE_BLOCKED 2 |
| 146 | |
| 147 | struct cpsw_slave { |
| 148 | struct cpsw_slave_regs *regs; |
| 149 | struct cpsw_sliver_regs *sliver; |
| 150 | int slave_num; |
| 151 | u32 mac_control; |
| 152 | struct cpsw_slave_data *data; |
| 153 | }; |
| 154 | |
| 155 | struct cpdma_desc { |
| 156 | /* hardware fields */ |
| 157 | u32 hw_next; |
| 158 | u32 hw_buffer; |
| 159 | u32 hw_len; |
| 160 | u32 hw_mode; |
| 161 | /* software fields */ |
| 162 | u32 sw_buffer; |
| 163 | u32 sw_len; |
| 164 | }; |
| 165 | |
| 166 | struct cpdma_chan { |
| 167 | struct cpdma_desc *head, *tail; |
| 168 | void *hdp, *cp, *rxfree; |
| 169 | }; |
| 170 | |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 171 | /* AM33xx SoC specific definitions for the CONTROL port */ |
| 172 | #define AM33XX_GMII_SEL_MODE_MII 0 |
| 173 | #define AM33XX_GMII_SEL_MODE_RMII 1 |
| 174 | #define AM33XX_GMII_SEL_MODE_RGMII 2 |
| 175 | |
| 176 | #define AM33XX_GMII_SEL_RGMII1_IDMODE BIT(4) |
| 177 | #define AM33XX_GMII_SEL_RGMII2_IDMODE BIT(5) |
| 178 | #define AM33XX_GMII_SEL_RMII1_IO_CLK_EN BIT(6) |
| 179 | #define AM33XX_GMII_SEL_RMII2_IO_CLK_EN BIT(7) |
| 180 | |
| 181 | #define GMII_SEL_MODE_MASK 0x3 |
| 182 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 183 | #define desc_write(desc, fld, val) __raw_writel((u32)(val), &(desc)->fld) |
| 184 | #define desc_read(desc, fld) __raw_readl(&(desc)->fld) |
| 185 | #define desc_read_ptr(desc, fld) ((void *)__raw_readl(&(desc)->fld)) |
| 186 | |
| 187 | #define chan_write(chan, fld, val) __raw_writel((u32)(val), (chan)->fld) |
| 188 | #define chan_read(chan, fld) __raw_readl((chan)->fld) |
| 189 | #define chan_read_ptr(chan, fld) ((void *)__raw_readl((chan)->fld)) |
| 190 | |
Mugunthan V N | 33e073e | 2014-05-22 14:37:10 +0530 | [diff] [blame] | 191 | #define for_active_slave(slave, priv) \ |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 192 | slave = (priv)->slaves + ((priv)->data)->active_slave; if (slave) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 193 | #define for_each_slave(slave, priv) \ |
| 194 | for (slave = (priv)->slaves; slave != (priv)->slaves + \ |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 195 | ((priv)->data)->slaves; slave++) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 196 | |
| 197 | struct cpsw_priv { |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 198 | #ifdef CONFIG_DM_ETH |
| 199 | struct udevice *dev; |
| 200 | #else |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 201 | struct eth_device *dev; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 202 | #endif |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 203 | struct cpsw_platform_data *data; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 204 | int host_port; |
| 205 | |
| 206 | struct cpsw_regs *regs; |
| 207 | void *dma_regs; |
| 208 | struct cpsw_host_regs *host_port_regs; |
| 209 | void *ale_regs; |
| 210 | |
| 211 | struct cpdma_desc *descs; |
| 212 | struct cpdma_desc *desc_free; |
| 213 | struct cpdma_chan rx_chan, tx_chan; |
| 214 | |
| 215 | struct cpsw_slave *slaves; |
| 216 | struct phy_device *phydev; |
| 217 | struct mii_dev *bus; |
Mugunthan V N | c3fdab4 | 2013-02-19 21:34:44 +0000 | [diff] [blame] | 218 | |
Mugunthan V N | c3fdab4 | 2013-02-19 21:34:44 +0000 | [diff] [blame] | 219 | u32 phy_mask; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 220 | }; |
| 221 | |
| 222 | static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits) |
| 223 | { |
| 224 | int idx; |
| 225 | |
| 226 | idx = start / 32; |
| 227 | start -= idx * 32; |
| 228 | idx = 2 - idx; /* flip */ |
| 229 | return (ale_entry[idx] >> start) & BITMASK(bits); |
| 230 | } |
| 231 | |
| 232 | static inline void cpsw_ale_set_field(u32 *ale_entry, u32 start, u32 bits, |
| 233 | u32 value) |
| 234 | { |
| 235 | int idx; |
| 236 | |
| 237 | value &= BITMASK(bits); |
| 238 | idx = start / 32; |
| 239 | start -= idx * 32; |
| 240 | idx = 2 - idx; /* flip */ |
| 241 | ale_entry[idx] &= ~(BITMASK(bits) << start); |
| 242 | ale_entry[idx] |= (value << start); |
| 243 | } |
| 244 | |
| 245 | #define DEFINE_ALE_FIELD(name, start, bits) \ |
| 246 | static inline int cpsw_ale_get_##name(u32 *ale_entry) \ |
| 247 | { \ |
| 248 | return cpsw_ale_get_field(ale_entry, start, bits); \ |
| 249 | } \ |
| 250 | static inline void cpsw_ale_set_##name(u32 *ale_entry, u32 value) \ |
| 251 | { \ |
| 252 | cpsw_ale_set_field(ale_entry, start, bits, value); \ |
| 253 | } |
| 254 | |
| 255 | DEFINE_ALE_FIELD(entry_type, 60, 2) |
| 256 | DEFINE_ALE_FIELD(mcast_state, 62, 2) |
| 257 | DEFINE_ALE_FIELD(port_mask, 66, 3) |
| 258 | DEFINE_ALE_FIELD(ucast_type, 62, 2) |
| 259 | DEFINE_ALE_FIELD(port_num, 66, 2) |
| 260 | DEFINE_ALE_FIELD(blocked, 65, 1) |
| 261 | DEFINE_ALE_FIELD(secure, 64, 1) |
| 262 | DEFINE_ALE_FIELD(mcast, 40, 1) |
| 263 | |
| 264 | /* The MAC address field in the ALE entry cannot be macroized as above */ |
| 265 | static inline void cpsw_ale_get_addr(u32 *ale_entry, u8 *addr) |
| 266 | { |
| 267 | int i; |
| 268 | |
| 269 | for (i = 0; i < 6; i++) |
| 270 | addr[i] = cpsw_ale_get_field(ale_entry, 40 - 8*i, 8); |
| 271 | } |
| 272 | |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 273 | static inline void cpsw_ale_set_addr(u32 *ale_entry, const u8 *addr) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 274 | { |
| 275 | int i; |
| 276 | |
| 277 | for (i = 0; i < 6; i++) |
| 278 | cpsw_ale_set_field(ale_entry, 40 - 8*i, 8, addr[i]); |
| 279 | } |
| 280 | |
| 281 | static int cpsw_ale_read(struct cpsw_priv *priv, int idx, u32 *ale_entry) |
| 282 | { |
| 283 | int i; |
| 284 | |
| 285 | __raw_writel(idx, priv->ale_regs + ALE_TABLE_CONTROL); |
| 286 | |
| 287 | for (i = 0; i < ALE_ENTRY_WORDS; i++) |
| 288 | ale_entry[i] = __raw_readl(priv->ale_regs + ALE_TABLE + 4 * i); |
| 289 | |
| 290 | return idx; |
| 291 | } |
| 292 | |
| 293 | static int cpsw_ale_write(struct cpsw_priv *priv, int idx, u32 *ale_entry) |
| 294 | { |
| 295 | int i; |
| 296 | |
| 297 | for (i = 0; i < ALE_ENTRY_WORDS; i++) |
| 298 | __raw_writel(ale_entry[i], priv->ale_regs + ALE_TABLE + 4 * i); |
| 299 | |
| 300 | __raw_writel(idx | ALE_TABLE_WRITE, priv->ale_regs + ALE_TABLE_CONTROL); |
| 301 | |
| 302 | return idx; |
| 303 | } |
| 304 | |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 305 | static int cpsw_ale_match_addr(struct cpsw_priv *priv, const u8 *addr) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 306 | { |
| 307 | u32 ale_entry[ALE_ENTRY_WORDS]; |
| 308 | int type, idx; |
| 309 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 310 | for (idx = 0; idx < priv->data->ale_entries; idx++) { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 311 | u8 entry_addr[6]; |
| 312 | |
| 313 | cpsw_ale_read(priv, idx, ale_entry); |
| 314 | type = cpsw_ale_get_entry_type(ale_entry); |
| 315 | if (type != ALE_TYPE_ADDR && type != ALE_TYPE_VLAN_ADDR) |
| 316 | continue; |
| 317 | cpsw_ale_get_addr(ale_entry, entry_addr); |
| 318 | if (memcmp(entry_addr, addr, 6) == 0) |
| 319 | return idx; |
| 320 | } |
| 321 | return -ENOENT; |
| 322 | } |
| 323 | |
| 324 | static int cpsw_ale_match_free(struct cpsw_priv *priv) |
| 325 | { |
| 326 | u32 ale_entry[ALE_ENTRY_WORDS]; |
| 327 | int type, idx; |
| 328 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 329 | for (idx = 0; idx < priv->data->ale_entries; idx++) { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 330 | cpsw_ale_read(priv, idx, ale_entry); |
| 331 | type = cpsw_ale_get_entry_type(ale_entry); |
| 332 | if (type == ALE_TYPE_FREE) |
| 333 | return idx; |
| 334 | } |
| 335 | return -ENOENT; |
| 336 | } |
| 337 | |
| 338 | static int cpsw_ale_find_ageable(struct cpsw_priv *priv) |
| 339 | { |
| 340 | u32 ale_entry[ALE_ENTRY_WORDS]; |
| 341 | int type, idx; |
| 342 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 343 | for (idx = 0; idx < priv->data->ale_entries; idx++) { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 344 | cpsw_ale_read(priv, idx, ale_entry); |
| 345 | type = cpsw_ale_get_entry_type(ale_entry); |
| 346 | if (type != ALE_TYPE_ADDR && type != ALE_TYPE_VLAN_ADDR) |
| 347 | continue; |
| 348 | if (cpsw_ale_get_mcast(ale_entry)) |
| 349 | continue; |
| 350 | type = cpsw_ale_get_ucast_type(ale_entry); |
| 351 | if (type != ALE_UCAST_PERSISTANT && |
| 352 | type != ALE_UCAST_OUI) |
| 353 | return idx; |
| 354 | } |
| 355 | return -ENOENT; |
| 356 | } |
| 357 | |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 358 | static int cpsw_ale_add_ucast(struct cpsw_priv *priv, const u8 *addr, |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 359 | int port, int flags) |
| 360 | { |
| 361 | u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0}; |
| 362 | int idx; |
| 363 | |
| 364 | cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_ADDR); |
| 365 | cpsw_ale_set_addr(ale_entry, addr); |
| 366 | cpsw_ale_set_ucast_type(ale_entry, ALE_UCAST_PERSISTANT); |
| 367 | cpsw_ale_set_secure(ale_entry, (flags & ALE_SECURE) ? 1 : 0); |
| 368 | cpsw_ale_set_blocked(ale_entry, (flags & ALE_BLOCKED) ? 1 : 0); |
| 369 | cpsw_ale_set_port_num(ale_entry, port); |
| 370 | |
| 371 | idx = cpsw_ale_match_addr(priv, addr); |
| 372 | if (idx < 0) |
| 373 | idx = cpsw_ale_match_free(priv); |
| 374 | if (idx < 0) |
| 375 | idx = cpsw_ale_find_ageable(priv); |
| 376 | if (idx < 0) |
| 377 | return -ENOMEM; |
| 378 | |
| 379 | cpsw_ale_write(priv, idx, ale_entry); |
| 380 | return 0; |
| 381 | } |
| 382 | |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 383 | static int cpsw_ale_add_mcast(struct cpsw_priv *priv, const u8 *addr, |
| 384 | int port_mask) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 385 | { |
| 386 | u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0}; |
| 387 | int idx, mask; |
| 388 | |
| 389 | idx = cpsw_ale_match_addr(priv, addr); |
| 390 | if (idx >= 0) |
| 391 | cpsw_ale_read(priv, idx, ale_entry); |
| 392 | |
| 393 | cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_ADDR); |
| 394 | cpsw_ale_set_addr(ale_entry, addr); |
| 395 | cpsw_ale_set_mcast_state(ale_entry, ALE_MCAST_FWD_2); |
| 396 | |
| 397 | mask = cpsw_ale_get_port_mask(ale_entry); |
| 398 | port_mask |= mask; |
| 399 | cpsw_ale_set_port_mask(ale_entry, port_mask); |
| 400 | |
| 401 | if (idx < 0) |
| 402 | idx = cpsw_ale_match_free(priv); |
| 403 | if (idx < 0) |
| 404 | idx = cpsw_ale_find_ageable(priv); |
| 405 | if (idx < 0) |
| 406 | return -ENOMEM; |
| 407 | |
| 408 | cpsw_ale_write(priv, idx, ale_entry); |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | static inline void cpsw_ale_control(struct cpsw_priv *priv, int bit, int val) |
| 413 | { |
| 414 | u32 tmp, mask = BIT(bit); |
| 415 | |
| 416 | tmp = __raw_readl(priv->ale_regs + ALE_CONTROL); |
| 417 | tmp &= ~mask; |
| 418 | tmp |= val ? mask : 0; |
| 419 | __raw_writel(tmp, priv->ale_regs + ALE_CONTROL); |
| 420 | } |
| 421 | |
| 422 | #define cpsw_ale_enable(priv, val) cpsw_ale_control(priv, 31, val) |
| 423 | #define cpsw_ale_clear(priv, val) cpsw_ale_control(priv, 30, val) |
| 424 | #define cpsw_ale_vlan_aware(priv, val) cpsw_ale_control(priv, 2, val) |
| 425 | |
| 426 | static inline void cpsw_ale_port_state(struct cpsw_priv *priv, int port, |
| 427 | int val) |
| 428 | { |
| 429 | int offset = ALE_PORTCTL + 4 * port; |
| 430 | u32 tmp, mask = 0x3; |
| 431 | |
| 432 | tmp = __raw_readl(priv->ale_regs + offset); |
| 433 | tmp &= ~mask; |
| 434 | tmp |= val & mask; |
| 435 | __raw_writel(tmp, priv->ale_regs + offset); |
| 436 | } |
| 437 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 438 | /* Set a self-clearing bit in a register, and wait for it to clear */ |
| 439 | static inline void setbit_and_wait_for_clear32(void *addr) |
| 440 | { |
| 441 | __raw_writel(CLEAR_BIT, addr); |
| 442 | while (__raw_readl(addr) & CLEAR_BIT) |
| 443 | ; |
| 444 | } |
| 445 | |
| 446 | #define mac_hi(mac) (((mac)[0] << 0) | ((mac)[1] << 8) | \ |
| 447 | ((mac)[2] << 16) | ((mac)[3] << 24)) |
| 448 | #define mac_lo(mac) (((mac)[4] << 0) | ((mac)[5] << 8)) |
| 449 | |
| 450 | static void cpsw_set_slave_mac(struct cpsw_slave *slave, |
| 451 | struct cpsw_priv *priv) |
| 452 | { |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 453 | #ifdef CONFIG_DM_ETH |
| 454 | struct eth_pdata *pdata = dev_get_platdata(priv->dev); |
| 455 | |
| 456 | writel(mac_hi(pdata->enetaddr), &slave->regs->sa_hi); |
| 457 | writel(mac_lo(pdata->enetaddr), &slave->regs->sa_lo); |
| 458 | #else |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 459 | __raw_writel(mac_hi(priv->dev->enetaddr), &slave->regs->sa_hi); |
| 460 | __raw_writel(mac_lo(priv->dev->enetaddr), &slave->regs->sa_lo); |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 461 | #endif |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 462 | } |
| 463 | |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 464 | static int cpsw_slave_update_link(struct cpsw_slave *slave, |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 465 | struct cpsw_priv *priv, int *link) |
| 466 | { |
Heiko Schocher | ef66003 | 2013-09-05 11:50:41 +0200 | [diff] [blame] | 467 | struct phy_device *phy; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 468 | u32 mac_control = 0; |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 469 | int ret = -ENODEV; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 470 | |
Heiko Schocher | ef66003 | 2013-09-05 11:50:41 +0200 | [diff] [blame] | 471 | phy = priv->phydev; |
Heiko Schocher | ef66003 | 2013-09-05 11:50:41 +0200 | [diff] [blame] | 472 | if (!phy) |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 473 | goto out; |
| 474 | |
| 475 | ret = phy_startup(phy); |
| 476 | if (ret) |
| 477 | goto out; |
Heiko Schocher | ef66003 | 2013-09-05 11:50:41 +0200 | [diff] [blame] | 478 | |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 479 | if (link) |
| 480 | *link = phy->link; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 481 | |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 482 | if (phy->link) { /* link up */ |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 483 | mac_control = priv->data->mac_control; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 484 | if (phy->speed == 1000) |
| 485 | mac_control |= GIGABITEN; |
| 486 | if (phy->duplex == DUPLEX_FULL) |
| 487 | mac_control |= FULLDUPLEXEN; |
| 488 | if (phy->speed == 100) |
| 489 | mac_control |= MIIEN; |
Grygorii Strashko | 63bba7e | 2019-09-19 11:16:37 +0300 | [diff] [blame] | 490 | if (phy->speed == 10 && phy_interface_is_rgmii(phy)) |
| 491 | mac_control |= CTL_EXT_EN; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | if (mac_control == slave->mac_control) |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 495 | goto out; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 496 | |
| 497 | if (mac_control) { |
| 498 | printf("link up on port %d, speed %d, %s duplex\n", |
| 499 | slave->slave_num, phy->speed, |
| 500 | (phy->duplex == DUPLEX_FULL) ? "full" : "half"); |
| 501 | } else { |
| 502 | printf("link down on port %d\n", slave->slave_num); |
| 503 | } |
| 504 | |
| 505 | __raw_writel(mac_control, &slave->sliver->mac_control); |
| 506 | slave->mac_control = mac_control; |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 507 | |
| 508 | out: |
| 509 | return ret; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | static int cpsw_update_link(struct cpsw_priv *priv) |
| 513 | { |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 514 | int ret = -ENODEV; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 515 | struct cpsw_slave *slave; |
| 516 | |
Mugunthan V N | 33e073e | 2014-05-22 14:37:10 +0530 | [diff] [blame] | 517 | for_active_slave(slave, priv) |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 518 | ret = cpsw_slave_update_link(slave, priv, NULL); |
Mugunthan V N | c3fdab4 | 2013-02-19 21:34:44 +0000 | [diff] [blame] | 519 | |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 520 | return ret; |
Mugunthan V N | c3fdab4 | 2013-02-19 21:34:44 +0000 | [diff] [blame] | 521 | } |
| 522 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 523 | static inline u32 cpsw_get_slave_port(struct cpsw_priv *priv, u32 slave_num) |
| 524 | { |
| 525 | if (priv->host_port == 0) |
| 526 | return slave_num + 1; |
| 527 | else |
| 528 | return slave_num; |
| 529 | } |
| 530 | |
| 531 | static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv) |
| 532 | { |
| 533 | u32 slave_port; |
| 534 | |
| 535 | setbit_and_wait_for_clear32(&slave->sliver->soft_reset); |
| 536 | |
| 537 | /* setup priority mapping */ |
| 538 | __raw_writel(0x76543210, &slave->sliver->rx_pri_map); |
| 539 | __raw_writel(0x33221100, &slave->regs->tx_pri_map); |
| 540 | |
| 541 | /* setup max packet size, and mac address */ |
| 542 | __raw_writel(PKT_MAX, &slave->sliver->rx_maxlen); |
| 543 | cpsw_set_slave_mac(slave, priv); |
| 544 | |
| 545 | slave->mac_control = 0; /* no link yet */ |
| 546 | |
| 547 | /* enable forwarding */ |
| 548 | slave_port = cpsw_get_slave_port(priv, slave->slave_num); |
| 549 | cpsw_ale_port_state(priv, slave_port, ALE_PORT_STATE_FORWARD); |
| 550 | |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 551 | cpsw_ale_add_mcast(priv, net_bcast_ethaddr, 1 << slave_port); |
Mugunthan V N | c3fdab4 | 2013-02-19 21:34:44 +0000 | [diff] [blame] | 552 | |
Mugunthan V N | 4944f37 | 2014-02-18 07:31:52 -0500 | [diff] [blame] | 553 | priv->phy_mask |= 1 << slave->data->phy_addr; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | static struct cpdma_desc *cpdma_desc_alloc(struct cpsw_priv *priv) |
| 557 | { |
| 558 | struct cpdma_desc *desc = priv->desc_free; |
| 559 | |
| 560 | if (desc) |
| 561 | priv->desc_free = desc_read_ptr(desc, hw_next); |
| 562 | return desc; |
| 563 | } |
| 564 | |
| 565 | static void cpdma_desc_free(struct cpsw_priv *priv, struct cpdma_desc *desc) |
| 566 | { |
| 567 | if (desc) { |
| 568 | desc_write(desc, hw_next, priv->desc_free); |
| 569 | priv->desc_free = desc; |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | static int cpdma_submit(struct cpsw_priv *priv, struct cpdma_chan *chan, |
| 574 | void *buffer, int len) |
| 575 | { |
| 576 | struct cpdma_desc *desc, *prev; |
| 577 | u32 mode; |
| 578 | |
| 579 | desc = cpdma_desc_alloc(priv); |
| 580 | if (!desc) |
| 581 | return -ENOMEM; |
| 582 | |
| 583 | if (len < PKT_MIN) |
| 584 | len = PKT_MIN; |
| 585 | |
| 586 | mode = CPDMA_DESC_OWNER | CPDMA_DESC_SOP | CPDMA_DESC_EOP; |
| 587 | |
| 588 | desc_write(desc, hw_next, 0); |
| 589 | desc_write(desc, hw_buffer, buffer); |
| 590 | desc_write(desc, hw_len, len); |
| 591 | desc_write(desc, hw_mode, mode | len); |
| 592 | desc_write(desc, sw_buffer, buffer); |
| 593 | desc_write(desc, sw_len, len); |
| 594 | |
| 595 | if (!chan->head) { |
| 596 | /* simple case - first packet enqueued */ |
| 597 | chan->head = desc; |
| 598 | chan->tail = desc; |
| 599 | chan_write(chan, hdp, desc); |
| 600 | goto done; |
| 601 | } |
| 602 | |
| 603 | /* not the first packet - enqueue at the tail */ |
| 604 | prev = chan->tail; |
| 605 | desc_write(prev, hw_next, desc); |
| 606 | chan->tail = desc; |
| 607 | |
| 608 | /* next check if EOQ has been triggered already */ |
| 609 | if (desc_read(prev, hw_mode) & CPDMA_DESC_EOQ) |
| 610 | chan_write(chan, hdp, desc); |
| 611 | |
| 612 | done: |
| 613 | if (chan->rxfree) |
| 614 | chan_write(chan, rxfree, 1); |
| 615 | return 0; |
| 616 | } |
| 617 | |
| 618 | static int cpdma_process(struct cpsw_priv *priv, struct cpdma_chan *chan, |
| 619 | void **buffer, int *len) |
| 620 | { |
| 621 | struct cpdma_desc *desc = chan->head; |
| 622 | u32 status; |
| 623 | |
| 624 | if (!desc) |
| 625 | return -ENOENT; |
| 626 | |
| 627 | status = desc_read(desc, hw_mode); |
| 628 | |
| 629 | if (len) |
| 630 | *len = status & 0x7ff; |
| 631 | |
| 632 | if (buffer) |
| 633 | *buffer = desc_read_ptr(desc, sw_buffer); |
| 634 | |
| 635 | if (status & CPDMA_DESC_OWNER) { |
| 636 | if (chan_read(chan, hdp) == 0) { |
| 637 | if (desc_read(desc, hw_mode) & CPDMA_DESC_OWNER) |
| 638 | chan_write(chan, hdp, desc); |
| 639 | } |
| 640 | |
| 641 | return -EBUSY; |
| 642 | } |
| 643 | |
| 644 | chan->head = desc_read_ptr(desc, hw_next); |
| 645 | chan_write(chan, cp, desc); |
| 646 | |
| 647 | cpdma_desc_free(priv, desc); |
| 648 | return 0; |
| 649 | } |
| 650 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 651 | static int _cpsw_init(struct cpsw_priv *priv, u8 *enetaddr) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 652 | { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 653 | struct cpsw_slave *slave; |
| 654 | int i, ret; |
| 655 | |
| 656 | /* soft reset the controller and initialize priv */ |
| 657 | setbit_and_wait_for_clear32(&priv->regs->soft_reset); |
| 658 | |
| 659 | /* initialize and reset the address lookup engine */ |
| 660 | cpsw_ale_enable(priv, 1); |
| 661 | cpsw_ale_clear(priv, 1); |
| 662 | cpsw_ale_vlan_aware(priv, 0); /* vlan unaware mode */ |
| 663 | |
| 664 | /* setup host port priority mapping */ |
| 665 | __raw_writel(0x76543210, &priv->host_port_regs->cpdma_tx_pri_map); |
| 666 | __raw_writel(0, &priv->host_port_regs->cpdma_rx_chan_map); |
| 667 | |
| 668 | /* disable priority elevation and enable statistics on all ports */ |
| 669 | __raw_writel(0, &priv->regs->ptype); |
| 670 | |
| 671 | /* enable statistics collection only on the host port */ |
| 672 | __raw_writel(BIT(priv->host_port), &priv->regs->stat_port_en); |
Mugunthan V N | 2782f3e | 2013-07-08 16:04:38 +0530 | [diff] [blame] | 673 | __raw_writel(0x7, &priv->regs->stat_port_en); |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 674 | |
| 675 | cpsw_ale_port_state(priv, priv->host_port, ALE_PORT_STATE_FORWARD); |
| 676 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 677 | cpsw_ale_add_ucast(priv, enetaddr, priv->host_port, ALE_SECURE); |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 678 | cpsw_ale_add_mcast(priv, net_bcast_ethaddr, 1 << priv->host_port); |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 679 | |
Mugunthan V N | 33e073e | 2014-05-22 14:37:10 +0530 | [diff] [blame] | 680 | for_active_slave(slave, priv) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 681 | cpsw_slave_init(slave, priv); |
| 682 | |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 683 | ret = cpsw_update_link(priv); |
| 684 | if (ret) |
| 685 | goto out; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 686 | |
| 687 | /* init descriptor pool */ |
| 688 | for (i = 0; i < NUM_DESCS; i++) { |
| 689 | desc_write(&priv->descs[i], hw_next, |
| 690 | (i == (NUM_DESCS - 1)) ? 0 : &priv->descs[i+1]); |
| 691 | } |
| 692 | priv->desc_free = &priv->descs[0]; |
| 693 | |
| 694 | /* initialize channels */ |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 695 | if (priv->data->version == CPSW_CTRL_VERSION_2) { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 696 | memset(&priv->rx_chan, 0, sizeof(struct cpdma_chan)); |
| 697 | priv->rx_chan.hdp = priv->dma_regs + CPDMA_RXHDP_VER2; |
| 698 | priv->rx_chan.cp = priv->dma_regs + CPDMA_RXCP_VER2; |
| 699 | priv->rx_chan.rxfree = priv->dma_regs + CPDMA_RXFREE; |
| 700 | |
| 701 | memset(&priv->tx_chan, 0, sizeof(struct cpdma_chan)); |
| 702 | priv->tx_chan.hdp = priv->dma_regs + CPDMA_TXHDP_VER2; |
| 703 | priv->tx_chan.cp = priv->dma_regs + CPDMA_TXCP_VER2; |
| 704 | } else { |
| 705 | memset(&priv->rx_chan, 0, sizeof(struct cpdma_chan)); |
| 706 | priv->rx_chan.hdp = priv->dma_regs + CPDMA_RXHDP_VER1; |
| 707 | priv->rx_chan.cp = priv->dma_regs + CPDMA_RXCP_VER1; |
| 708 | priv->rx_chan.rxfree = priv->dma_regs + CPDMA_RXFREE; |
| 709 | |
| 710 | memset(&priv->tx_chan, 0, sizeof(struct cpdma_chan)); |
| 711 | priv->tx_chan.hdp = priv->dma_regs + CPDMA_TXHDP_VER1; |
| 712 | priv->tx_chan.cp = priv->dma_regs + CPDMA_TXCP_VER1; |
| 713 | } |
| 714 | |
| 715 | /* clear dma state */ |
| 716 | setbit_and_wait_for_clear32(priv->dma_regs + CPDMA_SOFTRESET); |
| 717 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 718 | if (priv->data->version == CPSW_CTRL_VERSION_2) { |
| 719 | for (i = 0; i < priv->data->channels; i++) { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 720 | __raw_writel(0, priv->dma_regs + CPDMA_RXHDP_VER2 + 4 |
| 721 | * i); |
| 722 | __raw_writel(0, priv->dma_regs + CPDMA_RXFREE + 4 |
| 723 | * i); |
| 724 | __raw_writel(0, priv->dma_regs + CPDMA_RXCP_VER2 + 4 |
| 725 | * i); |
| 726 | __raw_writel(0, priv->dma_regs + CPDMA_TXHDP_VER2 + 4 |
| 727 | * i); |
| 728 | __raw_writel(0, priv->dma_regs + CPDMA_TXCP_VER2 + 4 |
| 729 | * i); |
| 730 | } |
| 731 | } else { |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 732 | for (i = 0; i < priv->data->channels; i++) { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 733 | __raw_writel(0, priv->dma_regs + CPDMA_RXHDP_VER1 + 4 |
| 734 | * i); |
| 735 | __raw_writel(0, priv->dma_regs + CPDMA_RXFREE + 4 |
| 736 | * i); |
| 737 | __raw_writel(0, priv->dma_regs + CPDMA_RXCP_VER1 + 4 |
| 738 | * i); |
| 739 | __raw_writel(0, priv->dma_regs + CPDMA_TXHDP_VER1 + 4 |
| 740 | * i); |
| 741 | __raw_writel(0, priv->dma_regs + CPDMA_TXCP_VER1 + 4 |
| 742 | * i); |
| 743 | |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | __raw_writel(1, priv->dma_regs + CPDMA_TXCONTROL); |
| 748 | __raw_writel(1, priv->dma_regs + CPDMA_RXCONTROL); |
| 749 | |
| 750 | /* submit rx descs */ |
| 751 | for (i = 0; i < PKTBUFSRX; i++) { |
Joe Hershberger | 9f09a36 | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 752 | ret = cpdma_submit(priv, &priv->rx_chan, net_rx_packets[i], |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 753 | PKTSIZE); |
| 754 | if (ret < 0) { |
| 755 | printf("error %d submitting rx desc\n", ret); |
| 756 | break; |
| 757 | } |
| 758 | } |
| 759 | |
Sekhar Nori | b598885 | 2017-05-08 20:49:56 +0530 | [diff] [blame] | 760 | out: |
| 761 | return ret; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 762 | } |
| 763 | |
Alex Kiernan | e210e98 | 2018-05-12 07:30:02 +0000 | [diff] [blame] | 764 | static int cpsw_reap_completed_packets(struct cpsw_priv *priv) |
| 765 | { |
| 766 | int timeout = CPDMA_TIMEOUT; |
| 767 | |
| 768 | /* reap completed packets */ |
| 769 | while (timeout-- && |
| 770 | (cpdma_process(priv, &priv->tx_chan, NULL, NULL) >= 0)) |
| 771 | ; |
| 772 | |
| 773 | return timeout; |
| 774 | } |
| 775 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 776 | static void _cpsw_halt(struct cpsw_priv *priv) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 777 | { |
Alex Kiernan | e210e98 | 2018-05-12 07:30:02 +0000 | [diff] [blame] | 778 | cpsw_reap_completed_packets(priv); |
| 779 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 780 | writel(0, priv->dma_regs + CPDMA_TXCONTROL); |
| 781 | writel(0, priv->dma_regs + CPDMA_RXCONTROL); |
| 782 | |
| 783 | /* soft reset the controller and initialize priv */ |
| 784 | setbit_and_wait_for_clear32(&priv->regs->soft_reset); |
| 785 | |
| 786 | /* clear dma state */ |
| 787 | setbit_and_wait_for_clear32(priv->dma_regs + CPDMA_SOFTRESET); |
| 788 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 789 | } |
| 790 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 791 | static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 792 | { |
Alex Kiernan | e210e98 | 2018-05-12 07:30:02 +0000 | [diff] [blame] | 793 | int timeout; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 794 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 795 | flush_dcache_range((unsigned long)packet, |
Lokesh Vutla | f9f4ced | 2016-08-11 13:00:59 +0530 | [diff] [blame] | 796 | (unsigned long)packet + ALIGN(length, PKTALIGN)); |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 797 | |
Alex Kiernan | e210e98 | 2018-05-12 07:30:02 +0000 | [diff] [blame] | 798 | timeout = cpsw_reap_completed_packets(priv); |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 799 | if (timeout == -1) { |
| 800 | printf("cpdma_process timeout\n"); |
| 801 | return -ETIMEDOUT; |
| 802 | } |
| 803 | |
| 804 | return cpdma_submit(priv, &priv->tx_chan, packet, length); |
| 805 | } |
| 806 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 807 | static int _cpsw_recv(struct cpsw_priv *priv, uchar **pkt) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 808 | { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 809 | void *buffer; |
| 810 | int len; |
Heinrich Schuchardt | 71bb8dd | 2018-03-18 11:24:38 +0100 | [diff] [blame] | 811 | int ret; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 812 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 813 | ret = cpdma_process(priv, &priv->rx_chan, &buffer, &len); |
| 814 | if (ret < 0) |
| 815 | return ret; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 816 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 817 | invalidate_dcache_range((unsigned long)buffer, |
| 818 | (unsigned long)buffer + PKTSIZE_ALIGN); |
| 819 | *pkt = buffer; |
| 820 | |
| 821 | return len; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | static void cpsw_slave_setup(struct cpsw_slave *slave, int slave_num, |
| 825 | struct cpsw_priv *priv) |
| 826 | { |
| 827 | void *regs = priv->regs; |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 828 | struct cpsw_slave_data *data = priv->data->slave_data + slave_num; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 829 | slave->slave_num = slave_num; |
| 830 | slave->data = data; |
| 831 | slave->regs = regs + data->slave_reg_ofs; |
| 832 | slave->sliver = regs + data->sliver_reg_ofs; |
| 833 | } |
| 834 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 835 | static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 836 | { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 837 | struct phy_device *phydev; |
Ilya Ledvich | a1635f0 | 2014-03-12 11:26:30 +0200 | [diff] [blame] | 838 | u32 supported = PHY_GBIT_FEATURES; |
Grygorii Strashko | e32ed8c | 2019-09-19 11:16:39 +0300 | [diff] [blame] | 839 | int ret; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 840 | |
Yegor Yefremov | 062bbac | 2012-11-26 04:03:16 +0000 | [diff] [blame] | 841 | phydev = phy_connect(priv->bus, |
Mugunthan V N | 4944f37 | 2014-02-18 07:31:52 -0500 | [diff] [blame] | 842 | slave->data->phy_addr, |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 843 | priv->dev, |
Yegor Yefremov | 062bbac | 2012-11-26 04:03:16 +0000 | [diff] [blame] | 844 | slave->data->phy_if); |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 845 | |
Heiko Schocher | ef66003 | 2013-09-05 11:50:41 +0200 | [diff] [blame] | 846 | if (!phydev) |
| 847 | return -1; |
| 848 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 849 | phydev->supported &= supported; |
Grygorii Strashko | e32ed8c | 2019-09-19 11:16:39 +0300 | [diff] [blame] | 850 | if (slave->data->max_speed) { |
| 851 | ret = phy_set_supported(phydev, slave->data->max_speed); |
| 852 | if (ret) |
| 853 | return ret; |
| 854 | dev_dbg(priv->dev, "Port %u speed forced to %uMbit\n", |
| 855 | slave->slave_num + 1, slave->data->max_speed); |
| 856 | } |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 857 | phydev->advertising = phydev->supported; |
| 858 | |
Dan Murphy | 4b7b24e | 2016-05-02 15:45:56 -0500 | [diff] [blame] | 859 | #ifdef CONFIG_DM_ETH |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 860 | if (ofnode_valid(slave->data->phy_of_handle)) |
| 861 | phydev->node = slave->data->phy_of_handle; |
Dan Murphy | 4b7b24e | 2016-05-02 15:45:56 -0500 | [diff] [blame] | 862 | #endif |
| 863 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 864 | priv->phydev = phydev; |
| 865 | phy_config(phydev); |
| 866 | |
| 867 | return 1; |
| 868 | } |
| 869 | |
Sekhar Nori | cfc5cc8 | 2018-08-23 17:11:29 +0530 | [diff] [blame] | 870 | static void cpsw_phy_addr_update(struct cpsw_priv *priv) |
| 871 | { |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 872 | struct cpsw_platform_data *data = priv->data; |
Grygorii Strashko | eae545a | 2018-10-31 16:21:44 -0500 | [diff] [blame] | 873 | u16 alive = cpsw_mdio_get_alive(priv->bus); |
Sekhar Nori | cfc5cc8 | 2018-08-23 17:11:29 +0530 | [diff] [blame] | 874 | int active = data->active_slave; |
| 875 | int new_addr = ffs(alive) - 1; |
| 876 | |
| 877 | /* |
| 878 | * If there is only one phy alive and its address does not match |
| 879 | * that of active slave, then phy address can safely be updated. |
| 880 | */ |
| 881 | if (hweight16(alive) == 1 && |
| 882 | data->slave_data[active].phy_addr != new_addr) { |
| 883 | printf("Updated phy address for CPSW#%d, old: %d, new: %d\n", |
| 884 | active, data->slave_data[active].phy_addr, new_addr); |
| 885 | data->slave_data[active].phy_addr = new_addr; |
| 886 | } |
| 887 | } |
| 888 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 889 | int _cpsw_register(struct cpsw_priv *priv) |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 890 | { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 891 | struct cpsw_slave *slave; |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 892 | struct cpsw_platform_data *data = priv->data; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 893 | void *regs = (void *)data->cpsw_base; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 894 | |
| 895 | priv->slaves = malloc(sizeof(struct cpsw_slave) * data->slaves); |
| 896 | if (!priv->slaves) { |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 897 | return -ENOMEM; |
| 898 | } |
| 899 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 900 | priv->host_port = data->host_port_num; |
| 901 | priv->regs = regs; |
| 902 | priv->host_port_regs = regs + data->host_port_reg_ofs; |
| 903 | priv->dma_regs = regs + data->cpdma_reg_ofs; |
| 904 | priv->ale_regs = regs + data->ale_reg_ofs; |
Mugunthan V N | ff55987 | 2013-07-08 16:04:37 +0530 | [diff] [blame] | 905 | priv->descs = (void *)regs + data->bd_ram_ofs; |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 906 | |
| 907 | int idx = 0; |
| 908 | |
| 909 | for_each_slave(slave, priv) { |
| 910 | cpsw_slave_setup(slave, idx, priv); |
| 911 | idx = idx + 1; |
| 912 | } |
| 913 | |
Grygorii Strashko | eae545a | 2018-10-31 16:21:44 -0500 | [diff] [blame] | 914 | priv->bus = cpsw_mdio_init(priv->dev->name, data->mdio_base, 0, 0); |
| 915 | if (!priv->bus) |
| 916 | return -EFAULT; |
Sekhar Nori | cfc5cc8 | 2018-08-23 17:11:29 +0530 | [diff] [blame] | 917 | |
| 918 | cpsw_phy_addr_update(priv); |
| 919 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 920 | for_active_slave(slave, priv) |
| 921 | cpsw_phy_init(priv, slave); |
| 922 | |
| 923 | return 0; |
| 924 | } |
| 925 | |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 926 | #ifndef CONFIG_DM_ETH |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 927 | static int cpsw_init(struct eth_device *dev, bd_t *bis) |
| 928 | { |
| 929 | struct cpsw_priv *priv = dev->priv; |
| 930 | |
| 931 | return _cpsw_init(priv, dev->enetaddr); |
| 932 | } |
| 933 | |
| 934 | static void cpsw_halt(struct eth_device *dev) |
| 935 | { |
| 936 | struct cpsw_priv *priv = dev->priv; |
| 937 | |
| 938 | return _cpsw_halt(priv); |
| 939 | } |
| 940 | |
| 941 | static int cpsw_send(struct eth_device *dev, void *packet, int length) |
| 942 | { |
| 943 | struct cpsw_priv *priv = dev->priv; |
| 944 | |
| 945 | return _cpsw_send(priv, packet, length); |
| 946 | } |
| 947 | |
| 948 | static int cpsw_recv(struct eth_device *dev) |
| 949 | { |
| 950 | struct cpsw_priv *priv = dev->priv; |
| 951 | uchar *pkt = NULL; |
| 952 | int len; |
| 953 | |
| 954 | len = _cpsw_recv(priv, &pkt); |
| 955 | |
| 956 | if (len > 0) { |
| 957 | net_process_received_packet(pkt, len); |
| 958 | cpdma_submit(priv, &priv->rx_chan, pkt, PKTSIZE); |
| 959 | } |
| 960 | |
| 961 | return len; |
| 962 | } |
| 963 | |
| 964 | int cpsw_register(struct cpsw_platform_data *data) |
| 965 | { |
| 966 | struct cpsw_priv *priv; |
| 967 | struct eth_device *dev; |
| 968 | int ret; |
| 969 | |
| 970 | dev = calloc(sizeof(*dev), 1); |
| 971 | if (!dev) |
| 972 | return -ENOMEM; |
| 973 | |
| 974 | priv = calloc(sizeof(*priv), 1); |
| 975 | if (!priv) { |
| 976 | free(dev); |
| 977 | return -ENOMEM; |
| 978 | } |
| 979 | |
| 980 | priv->dev = dev; |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 981 | priv->data = data; |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 982 | |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 983 | strcpy(dev->name, "cpsw"); |
| 984 | dev->iobase = 0; |
| 985 | dev->init = cpsw_init; |
| 986 | dev->halt = cpsw_halt; |
| 987 | dev->send = cpsw_send; |
| 988 | dev->recv = cpsw_recv; |
| 989 | dev->priv = priv; |
| 990 | |
| 991 | eth_register(dev); |
| 992 | |
Mugunthan V N | 6af98c5 | 2015-09-07 14:22:20 +0530 | [diff] [blame] | 993 | ret = _cpsw_register(priv); |
| 994 | if (ret < 0) { |
| 995 | eth_unregister(dev); |
| 996 | free(dev); |
| 997 | free(priv); |
| 998 | return ret; |
| 999 | } |
Cyril Chemparathy | 464adc8 | 2012-07-24 12:22:16 +0000 | [diff] [blame] | 1000 | |
| 1001 | return 1; |
| 1002 | } |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1003 | #else |
| 1004 | static int cpsw_eth_start(struct udevice *dev) |
| 1005 | { |
| 1006 | struct eth_pdata *pdata = dev_get_platdata(dev); |
| 1007 | struct cpsw_priv *priv = dev_get_priv(dev); |
| 1008 | |
| 1009 | return _cpsw_init(priv, pdata->enetaddr); |
| 1010 | } |
| 1011 | |
| 1012 | static int cpsw_eth_send(struct udevice *dev, void *packet, int length) |
| 1013 | { |
| 1014 | struct cpsw_priv *priv = dev_get_priv(dev); |
| 1015 | |
| 1016 | return _cpsw_send(priv, packet, length); |
| 1017 | } |
| 1018 | |
| 1019 | static int cpsw_eth_recv(struct udevice *dev, int flags, uchar **packetp) |
| 1020 | { |
| 1021 | struct cpsw_priv *priv = dev_get_priv(dev); |
| 1022 | |
| 1023 | return _cpsw_recv(priv, packetp); |
| 1024 | } |
| 1025 | |
| 1026 | static int cpsw_eth_free_pkt(struct udevice *dev, uchar *packet, |
| 1027 | int length) |
| 1028 | { |
| 1029 | struct cpsw_priv *priv = dev_get_priv(dev); |
| 1030 | |
| 1031 | return cpdma_submit(priv, &priv->rx_chan, packet, PKTSIZE); |
| 1032 | } |
| 1033 | |
| 1034 | static void cpsw_eth_stop(struct udevice *dev) |
| 1035 | { |
| 1036 | struct cpsw_priv *priv = dev_get_priv(dev); |
| 1037 | |
| 1038 | return _cpsw_halt(priv); |
| 1039 | } |
| 1040 | |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1041 | static const struct eth_ops cpsw_eth_ops = { |
| 1042 | .start = cpsw_eth_start, |
| 1043 | .send = cpsw_eth_send, |
| 1044 | .recv = cpsw_eth_recv, |
| 1045 | .free_pkt = cpsw_eth_free_pkt, |
| 1046 | .stop = cpsw_eth_stop, |
| 1047 | }; |
| 1048 | |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1049 | static void cpsw_gmii_sel_am3352(struct cpsw_priv *priv, |
| 1050 | phy_interface_t phy_mode) |
| 1051 | { |
| 1052 | u32 reg; |
| 1053 | u32 mask; |
| 1054 | u32 mode = 0; |
| 1055 | bool rgmii_id = false; |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1056 | int slave = priv->data->active_slave; |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1057 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1058 | reg = readl(priv->data->gmii_sel); |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1059 | |
| 1060 | switch (phy_mode) { |
| 1061 | case PHY_INTERFACE_MODE_RMII: |
| 1062 | mode = AM33XX_GMII_SEL_MODE_RMII; |
| 1063 | break; |
| 1064 | |
| 1065 | case PHY_INTERFACE_MODE_RGMII: |
Grygorii Strashko | 40b346d | 2019-09-19 11:16:40 +0300 | [diff] [blame] | 1066 | case PHY_INTERFACE_MODE_RGMII_RXID: |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1067 | mode = AM33XX_GMII_SEL_MODE_RGMII; |
| 1068 | break; |
| 1069 | case PHY_INTERFACE_MODE_RGMII_ID: |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1070 | case PHY_INTERFACE_MODE_RGMII_TXID: |
| 1071 | mode = AM33XX_GMII_SEL_MODE_RGMII; |
| 1072 | rgmii_id = true; |
| 1073 | break; |
| 1074 | |
| 1075 | case PHY_INTERFACE_MODE_MII: |
| 1076 | default: |
| 1077 | mode = AM33XX_GMII_SEL_MODE_MII; |
| 1078 | break; |
| 1079 | }; |
| 1080 | |
| 1081 | mask = GMII_SEL_MODE_MASK << (slave * 2) | BIT(slave + 6); |
| 1082 | mode <<= slave * 2; |
| 1083 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1084 | if (priv->data->rmii_clock_external) { |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1085 | if (slave == 0) |
| 1086 | mode |= AM33XX_GMII_SEL_RMII1_IO_CLK_EN; |
| 1087 | else |
| 1088 | mode |= AM33XX_GMII_SEL_RMII2_IO_CLK_EN; |
| 1089 | } |
| 1090 | |
| 1091 | if (rgmii_id) { |
| 1092 | if (slave == 0) |
| 1093 | mode |= AM33XX_GMII_SEL_RGMII1_IDMODE; |
| 1094 | else |
| 1095 | mode |= AM33XX_GMII_SEL_RGMII2_IDMODE; |
| 1096 | } |
| 1097 | |
| 1098 | reg &= ~mask; |
| 1099 | reg |= mode; |
| 1100 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1101 | writel(reg, priv->data->gmii_sel); |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1102 | } |
| 1103 | |
| 1104 | static void cpsw_gmii_sel_dra7xx(struct cpsw_priv *priv, |
| 1105 | phy_interface_t phy_mode) |
| 1106 | { |
| 1107 | u32 reg; |
| 1108 | u32 mask; |
| 1109 | u32 mode = 0; |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1110 | int slave = priv->data->active_slave; |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1111 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1112 | reg = readl(priv->data->gmii_sel); |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1113 | |
| 1114 | switch (phy_mode) { |
| 1115 | case PHY_INTERFACE_MODE_RMII: |
| 1116 | mode = AM33XX_GMII_SEL_MODE_RMII; |
| 1117 | break; |
| 1118 | |
| 1119 | case PHY_INTERFACE_MODE_RGMII: |
| 1120 | case PHY_INTERFACE_MODE_RGMII_ID: |
| 1121 | case PHY_INTERFACE_MODE_RGMII_RXID: |
| 1122 | case PHY_INTERFACE_MODE_RGMII_TXID: |
| 1123 | mode = AM33XX_GMII_SEL_MODE_RGMII; |
| 1124 | break; |
| 1125 | |
| 1126 | case PHY_INTERFACE_MODE_MII: |
| 1127 | default: |
| 1128 | mode = AM33XX_GMII_SEL_MODE_MII; |
| 1129 | break; |
| 1130 | }; |
| 1131 | |
| 1132 | switch (slave) { |
| 1133 | case 0: |
| 1134 | mask = GMII_SEL_MODE_MASK; |
| 1135 | break; |
| 1136 | case 1: |
| 1137 | mask = GMII_SEL_MODE_MASK << 4; |
| 1138 | mode <<= 4; |
| 1139 | break; |
| 1140 | default: |
| 1141 | dev_err(priv->dev, "invalid slave number...\n"); |
| 1142 | return; |
| 1143 | } |
| 1144 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1145 | if (priv->data->rmii_clock_external) |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1146 | dev_err(priv->dev, "RMII External clock is not supported\n"); |
| 1147 | |
| 1148 | reg &= ~mask; |
| 1149 | reg |= mode; |
| 1150 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1151 | writel(reg, priv->data->gmii_sel); |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1152 | } |
| 1153 | |
| 1154 | static void cpsw_phy_sel(struct cpsw_priv *priv, const char *compat, |
| 1155 | phy_interface_t phy_mode) |
| 1156 | { |
| 1157 | if (!strcmp(compat, "ti,am3352-cpsw-phy-sel")) |
| 1158 | cpsw_gmii_sel_am3352(priv, phy_mode); |
| 1159 | if (!strcmp(compat, "ti,am43xx-cpsw-phy-sel")) |
| 1160 | cpsw_gmii_sel_am3352(priv, phy_mode); |
| 1161 | else if (!strcmp(compat, "ti,dra7xx-cpsw-phy-sel")) |
| 1162 | cpsw_gmii_sel_dra7xx(priv, phy_mode); |
| 1163 | } |
| 1164 | |
Faiz Abbas | 5b5dc0f | 2019-03-18 13:54:32 +0530 | [diff] [blame] | 1165 | static int cpsw_eth_probe(struct udevice *dev) |
| 1166 | { |
| 1167 | struct cpsw_priv *priv = dev_get_priv(dev); |
| 1168 | struct eth_pdata *pdata = dev_get_platdata(dev); |
| 1169 | |
| 1170 | priv->dev = dev; |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1171 | priv->data = pdata->priv_pdata; |
Faiz Abbas | 8ecdffe | 2019-03-18 13:54:34 +0530 | [diff] [blame] | 1172 | ti_cm_get_macid(dev, priv->data, pdata->enetaddr); |
Faiz Abbas | 5b5dc0f | 2019-03-18 13:54:32 +0530 | [diff] [blame] | 1173 | /* Select phy interface in control module */ |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1174 | cpsw_phy_sel(priv, priv->data->phy_sel_compat, |
Faiz Abbas | 5b5dc0f | 2019-03-18 13:54:32 +0530 | [diff] [blame] | 1175 | pdata->phy_interface); |
| 1176 | |
| 1177 | return _cpsw_register(priv); |
| 1178 | } |
| 1179 | |
Faiz Abbas | 687e80e | 2019-03-18 13:54:35 +0530 | [diff] [blame] | 1180 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1181 | static void cpsw_eth_of_parse_slave(struct cpsw_platform_data *data, |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1182 | int slave_index, ofnode subnode) |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1183 | { |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1184 | struct ofnode_phandle_args out_args; |
| 1185 | struct cpsw_slave_data *slave_data; |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1186 | const char *phy_mode; |
| 1187 | u32 phy_id[2]; |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1188 | int ret; |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1189 | |
| 1190 | slave_data = &data->slave_data[slave_index]; |
| 1191 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1192 | phy_mode = ofnode_read_string(subnode, "phy-mode"); |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1193 | if (phy_mode) |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1194 | slave_data->phy_if = phy_get_interface_by_name(phy_mode); |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1195 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1196 | ret = ofnode_parse_phandle_with_args(subnode, "phy-handle", |
| 1197 | NULL, 0, 0, &out_args); |
| 1198 | if (!ret) { |
| 1199 | slave_data->phy_of_handle = out_args.node; |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1200 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1201 | ret = ofnode_read_s32(slave_data->phy_of_handle, "reg", |
| 1202 | &slave_data->phy_addr); |
| 1203 | if (ret) |
| 1204 | printf("error: phy addr not found in dt\n"); |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1205 | } else { |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1206 | ret = ofnode_read_u32_array(subnode, "phy_id", phy_id, 2); |
| 1207 | if (ret) |
| 1208 | printf("error: phy_id read failed\n"); |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1209 | } |
Grygorii Strashko | e32ed8c | 2019-09-19 11:16:39 +0300 | [diff] [blame] | 1210 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1211 | slave_data->max_speed = ofnode_read_s32_default(subnode, |
| 1212 | "max-speed", 0); |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1213 | } |
| 1214 | |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1215 | static int cpsw_eth_ofdata_to_platdata(struct udevice *dev) |
| 1216 | { |
| 1217 | struct eth_pdata *pdata = dev_get_platdata(dev); |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1218 | struct cpsw_platform_data *data; |
Vignesh R | 8e9473d | 2016-08-02 10:14:27 +0530 | [diff] [blame] | 1219 | struct gpio_desc *mode_gpios; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1220 | int slave_index = 0; |
Vignesh R | 8e9473d | 2016-08-02 10:14:27 +0530 | [diff] [blame] | 1221 | int num_mode_gpios; |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1222 | ofnode subnode; |
Mugunthan V N | 9e55635 | 2016-04-28 15:36:07 +0530 | [diff] [blame] | 1223 | int ret; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1224 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1225 | data = calloc(1, sizeof(struct cpsw_platform_data)); |
| 1226 | pdata->priv_pdata = data; |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1227 | pdata->iobase = dev_read_addr(dev); |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1228 | data->version = CPSW_CTRL_VERSION_2; |
| 1229 | data->bd_ram_ofs = CPSW_BD_OFFSET; |
| 1230 | data->ale_reg_ofs = CPSW_ALE_OFFSET; |
| 1231 | data->cpdma_reg_ofs = CPSW_CPDMA_OFFSET; |
| 1232 | data->mdio_div = CPSW_MDIO_DIV; |
| 1233 | data->host_port_reg_ofs = CPSW_HOST_PORT_OFFSET, |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1234 | |
| 1235 | pdata->phy_interface = -1; |
| 1236 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1237 | data->cpsw_base = pdata->iobase; |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1238 | |
| 1239 | ret = dev_read_s32(dev, "cpdma_channels", &data->channels); |
| 1240 | if (ret) { |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1241 | printf("error: cpdma_channels not found in dt\n"); |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1242 | return ret; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1243 | } |
| 1244 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1245 | ret = dev_read_s32(dev, "slaves", &data->slaves); |
| 1246 | if (ret) { |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1247 | printf("error: slaves not found in dt\n"); |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1248 | return ret; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1249 | } |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1250 | data->slave_data = malloc(sizeof(struct cpsw_slave_data) * |
| 1251 | data->slaves); |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1252 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1253 | ret = dev_read_s32(dev, "ale_entries", &data->ale_entries); |
| 1254 | if (ret) { |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1255 | printf("error: ale_entries not found in dt\n"); |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1256 | return ret; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1257 | } |
| 1258 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1259 | ret = dev_read_u32(dev, "bd_ram_size", &data->bd_ram_ofs); |
| 1260 | if (ret) { |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1261 | printf("error: bd_ram_size not found in dt\n"); |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1262 | return ret; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1263 | } |
| 1264 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1265 | ret = dev_read_u32(dev, "mac_control", &data->mac_control); |
| 1266 | if (ret) { |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1267 | printf("error: ale_entries not found in dt\n"); |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1268 | return ret; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1269 | } |
| 1270 | |
Vignesh R | 8e9473d | 2016-08-02 10:14:27 +0530 | [diff] [blame] | 1271 | num_mode_gpios = gpio_get_list_count(dev, "mode-gpios"); |
| 1272 | if (num_mode_gpios > 0) { |
| 1273 | mode_gpios = malloc(sizeof(struct gpio_desc) * |
| 1274 | num_mode_gpios); |
| 1275 | gpio_request_list_by_name(dev, "mode-gpios", mode_gpios, |
| 1276 | num_mode_gpios, GPIOD_IS_OUT); |
| 1277 | free(mode_gpios); |
| 1278 | } |
| 1279 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1280 | data->active_slave = dev_read_u32_default(dev, "active_slave", 0); |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1281 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1282 | ofnode_for_each_subnode(subnode, dev_ofnode(dev)) { |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1283 | const char *name; |
| 1284 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1285 | name = ofnode_get_name(subnode); |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1286 | if (!strncmp(name, "mdio", 4)) { |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1287 | data->mdio_base = ofnode_get_addr(subnode); |
| 1288 | if (data->mdio_base == FDT_ADDR_T_NONE) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 1289 | pr_err("Not able to get MDIO address space\n"); |
Mugunthan V N | 77f7bc7 | 2016-04-28 15:36:06 +0530 | [diff] [blame] | 1290 | return -ENOENT; |
| 1291 | } |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1292 | } |
| 1293 | |
| 1294 | if (!strncmp(name, "slave", 5)) { |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1295 | if (slave_index >= data->slaves) |
Mugunthan V N | 13a27fd | 2016-04-28 15:36:04 +0530 | [diff] [blame] | 1296 | continue; |
Dan Murphy | 4b7b24e | 2016-05-02 15:45:56 -0500 | [diff] [blame] | 1297 | |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1298 | cpsw_eth_of_parse_slave(data, slave_index, subnode); |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1299 | slave_index++; |
| 1300 | } |
| 1301 | |
| 1302 | if (!strncmp(name, "cpsw-phy-sel", 12)) { |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1303 | data->gmii_sel = ofnode_get_addr(subnode); |
Mugunthan V N | 77f7bc7 | 2016-04-28 15:36:06 +0530 | [diff] [blame] | 1304 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1305 | if (data->gmii_sel == FDT_ADDR_T_NONE) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 1306 | pr_err("Not able to get gmii_sel reg address\n"); |
Mugunthan V N | 77f7bc7 | 2016-04-28 15:36:06 +0530 | [diff] [blame] | 1307 | return -ENOENT; |
| 1308 | } |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1309 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1310 | if (ofnode_read_bool(subnode, "rmii-clock-ext")) |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1311 | data->rmii_clock_external = true; |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1312 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1313 | data->phy_sel_compat = ofnode_read_string(subnode, |
| 1314 | "compatible"); |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1315 | if (!data->phy_sel_compat) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 1316 | pr_err("Not able to get gmii_sel compatible\n"); |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1317 | return -ENOENT; |
| 1318 | } |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1319 | } |
| 1320 | } |
| 1321 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1322 | data->slave_data[0].slave_reg_ofs = CPSW_SLAVE0_OFFSET; |
| 1323 | data->slave_data[0].sliver_reg_ofs = CPSW_SLIVER0_OFFSET; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1324 | |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1325 | if (data->slaves == 2) { |
| 1326 | data->slave_data[1].slave_reg_ofs = CPSW_SLAVE1_OFFSET; |
| 1327 | data->slave_data[1].sliver_reg_ofs = CPSW_SLIVER1_OFFSET; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1328 | } |
| 1329 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1330 | ret = ti_cm_get_macid_addr(dev, data->active_slave, data); |
Mugunthan V N | 9e55635 | 2016-04-28 15:36:07 +0530 | [diff] [blame] | 1331 | if (ret < 0) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 1332 | pr_err("cpsw read efuse mac failed\n"); |
Mugunthan V N | 9e55635 | 2016-04-28 15:36:07 +0530 | [diff] [blame] | 1333 | return ret; |
| 1334 | } |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1335 | |
Grygorii Strashko | 133dd1c | 2019-09-19 11:16:42 +0300 | [diff] [blame] | 1336 | pdata->phy_interface = data->slave_data[data->active_slave].phy_if; |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1337 | if (pdata->phy_interface == -1) { |
Grygorii Strashko | 68e313e | 2019-09-19 11:16:38 +0300 | [diff] [blame] | 1338 | debug("%s: Invalid PHY interface '%s'\n", __func__, |
| 1339 | phy_string_for_interface(pdata->phy_interface)); |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1340 | return -EINVAL; |
| 1341 | } |
Mugunthan V N | 4d5fdb6 | 2016-10-13 19:33:38 +0530 | [diff] [blame] | 1342 | |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1343 | return 0; |
| 1344 | } |
| 1345 | |
Faiz Abbas | 687e80e | 2019-03-18 13:54:35 +0530 | [diff] [blame] | 1346 | static const struct udevice_id cpsw_eth_ids[] = { |
| 1347 | { .compatible = "ti,cpsw" }, |
| 1348 | { .compatible = "ti,am335x-cpsw" }, |
| 1349 | { } |
| 1350 | }; |
| 1351 | #endif |
| 1352 | |
Sekhar Nori | cfc5cc8 | 2018-08-23 17:11:29 +0530 | [diff] [blame] | 1353 | int cpsw_get_slave_phy_addr(struct udevice *dev, int slave) |
| 1354 | { |
| 1355 | struct cpsw_priv *priv = dev_get_priv(dev); |
Faiz Abbas | 5e3d77f | 2019-03-18 13:54:33 +0530 | [diff] [blame] | 1356 | struct cpsw_platform_data *data = priv->data; |
Sekhar Nori | cfc5cc8 | 2018-08-23 17:11:29 +0530 | [diff] [blame] | 1357 | |
| 1358 | return data->slave_data[slave].phy_addr; |
| 1359 | } |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1360 | |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1361 | U_BOOT_DRIVER(eth_cpsw) = { |
| 1362 | .name = "eth_cpsw", |
| 1363 | .id = UCLASS_ETH, |
Faiz Abbas | 687e80e | 2019-03-18 13:54:35 +0530 | [diff] [blame] | 1364 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1365 | .of_match = cpsw_eth_ids, |
| 1366 | .ofdata_to_platdata = cpsw_eth_ofdata_to_platdata, |
Faiz Abbas | 687e80e | 2019-03-18 13:54:35 +0530 | [diff] [blame] | 1367 | .platdata_auto_alloc_size = sizeof(struct eth_pdata), |
| 1368 | #endif |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1369 | .probe = cpsw_eth_probe, |
| 1370 | .ops = &cpsw_eth_ops, |
| 1371 | .priv_auto_alloc_size = sizeof(struct cpsw_priv), |
Faiz Abbas | d852b94 | 2019-03-18 13:54:36 +0530 | [diff] [blame] | 1372 | .flags = DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_PRE_RELOC, |
Mugunthan V N | 7ae228c | 2015-09-07 14:22:21 +0530 | [diff] [blame] | 1373 | }; |
| 1374 | #endif /* CONFIG_DM_ETH */ |