aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ibm_newemac/core.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ibm_newemac/core.h')
-rw-r--r--drivers/net/ibm_newemac/core.h85
1 files changed, 83 insertions, 2 deletions
diff --git a/drivers/net/ibm_newemac/core.h b/drivers/net/ibm_newemac/core.h
index 1683db9870a..6545e69d12c 100644
--- a/drivers/net/ibm_newemac/core.h
+++ b/drivers/net/ibm_newemac/core.h
@@ -33,8 +33,8 @@
33#include <linux/netdevice.h> 33#include <linux/netdevice.h>
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <linux/of_platform.h>
36 37
37#include <asm/of_platform.h>
38#include <asm/io.h> 38#include <asm/io.h>
39#include <asm/dcr.h> 39#include <asm/dcr.h>
40 40
@@ -235,6 +235,10 @@ struct emac_instance {
235 u32 fifo_entry_size; 235 u32 fifo_entry_size;
236 u32 mal_burst_size; /* move to MAL ? */ 236 u32 mal_burst_size; /* move to MAL ? */
237 237
238 /* IAHT and GAHT filter parameterization */
239 u32 xaht_slots_shift;
240 u32 xaht_width_shift;
241
238 /* Descriptor management 242 /* Descriptor management
239 */ 243 */
240 struct mal_descriptor *tx_desc; 244 struct mal_descriptor *tx_desc;
@@ -309,6 +313,10 @@ struct emac_instance {
309 * Set if we need phy clock workaround for 440ep or 440gr 313 * Set if we need phy clock workaround for 440ep or 440gr
310 */ 314 */
311#define EMAC_FTR_440EP_PHY_CLK_FIX 0x00000100 315#define EMAC_FTR_440EP_PHY_CLK_FIX 0x00000100
316/*
317 * The 405EX and 460EX contain the EMAC4SYNC core
318 */
319#define EMAC_FTR_EMAC4SYNC 0x00000200
312 320
313 321
314/* Right now, we don't quite handle the always/possible masks on the 322/* Right now, we don't quite handle the always/possible masks on the
@@ -320,7 +328,8 @@ enum {
320 328
321 EMAC_FTRS_POSSIBLE = 329 EMAC_FTRS_POSSIBLE =
322#ifdef CONFIG_IBM_NEW_EMAC_EMAC4 330#ifdef CONFIG_IBM_NEW_EMAC_EMAC4
323 EMAC_FTR_EMAC4 | EMAC_FTR_HAS_NEW_STACR | 331 EMAC_FTR_EMAC4 | EMAC_FTR_EMAC4SYNC |
332 EMAC_FTR_HAS_NEW_STACR |
324 EMAC_FTR_STACR_OC_INVERT | EMAC_FTR_440GX_PHY_CLK_FIX | 333 EMAC_FTR_STACR_OC_INVERT | EMAC_FTR_440GX_PHY_CLK_FIX |
325#endif 334#endif
326#ifdef CONFIG_IBM_NEW_EMAC_TAH 335#ifdef CONFIG_IBM_NEW_EMAC_TAH
@@ -342,6 +351,71 @@ static inline int emac_has_feature(struct emac_instance *dev,
342 (EMAC_FTRS_POSSIBLE & dev->features & feature); 351 (EMAC_FTRS_POSSIBLE & dev->features & feature);
343} 352}
344 353
354/*
355 * Various instances of the EMAC core have varying 1) number of
356 * address match slots, 2) width of the registers for handling address
357 * match slots, 3) number of registers for handling address match
358 * slots and 4) base offset for those registers.
359 *
360 * These macros and inlines handle these differences based on
361 * parameters supplied by the device structure which are, in turn,
362 * initialized based on the "compatible" entry in the device tree.
363 */
364
365#define EMAC4_XAHT_SLOTS_SHIFT 6
366#define EMAC4_XAHT_WIDTH_SHIFT 4
367
368#define EMAC4SYNC_XAHT_SLOTS_SHIFT 8
369#define EMAC4SYNC_XAHT_WIDTH_SHIFT 5
370
371#define EMAC_XAHT_SLOTS(dev) (1 << (dev)->xaht_slots_shift)
372#define EMAC_XAHT_WIDTH(dev) (1 << (dev)->xaht_width_shift)
373#define EMAC_XAHT_REGS(dev) (1 << ((dev)->xaht_slots_shift - \
374 (dev)->xaht_width_shift))
375
376#define EMAC_XAHT_CRC_TO_SLOT(dev, crc) \
377 ((EMAC_XAHT_SLOTS(dev) - 1) - \
378 ((crc) >> ((sizeof (u32) * BITS_PER_BYTE) - \
379 (dev)->xaht_slots_shift)))
380
381#define EMAC_XAHT_SLOT_TO_REG(dev, slot) \
382 ((slot) >> (dev)->xaht_width_shift)
383
384#define EMAC_XAHT_SLOT_TO_MASK(dev, slot) \
385 ((u32)(1 << (EMAC_XAHT_WIDTH(dev) - 1)) >> \
386 ((slot) & (u32)(EMAC_XAHT_WIDTH(dev) - 1)))
387
388static inline u32 *emac_xaht_base(struct emac_instance *dev)
389{
390 struct emac_regs __iomem *p = dev->emacp;
391 int offset;
392
393 /* The first IAHT entry always is the base of the block of
394 * IAHT and GAHT registers.
395 */
396 if (emac_has_feature(dev, EMAC_FTR_EMAC4SYNC))
397 offset = offsetof(struct emac_regs, u1.emac4sync.iaht1);
398 else
399 offset = offsetof(struct emac_regs, u0.emac4.iaht1);
400
401 return ((u32 *)((ptrdiff_t)p + offset));
402}
403
404static inline u32 *emac_gaht_base(struct emac_instance *dev)
405{
406 /* GAHT registers always come after an identical number of
407 * IAHT registers.
408 */
409 return (emac_xaht_base(dev) + EMAC_XAHT_REGS(dev));
410}
411
412static inline u32 *emac_iaht_base(struct emac_instance *dev)
413{
414 /* IAHT registers always come before an identical number of
415 * GAHT registers.
416 */
417 return (emac_xaht_base(dev));
418}
345 419
346/* Ethtool get_regs complex data. 420/* Ethtool get_regs complex data.
347 * We want to get not just EMAC registers, but also MAL, ZMII, RGMII, TAH 421 * We want to get not just EMAC registers, but also MAL, ZMII, RGMII, TAH
@@ -366,4 +440,11 @@ struct emac_ethtool_regs_subhdr {
366 u32 index; 440 u32 index;
367}; 441};
368 442
443#define EMAC_ETHTOOL_REGS_VER 0
444#define EMAC_ETHTOOL_REGS_SIZE(dev) ((dev)->rsrc_regs.end - \
445 (dev)->rsrc_regs.start + 1)
446#define EMAC4_ETHTOOL_REGS_VER 1
447#define EMAC4_ETHTOOL_REGS_SIZE(dev) ((dev)->rsrc_regs.end - \
448 (dev)->rsrc_regs.start + 1)
449
369#endif /* __IBM_NEWEMAC_CORE_H */ 450#endif /* __IBM_NEWEMAC_CORE_H */