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