mdio.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * mdio.h - mdio related definitions and declarations;
  11. *
  12. *--------------------------------------------------------------------*/
  13. #ifndef MDIO_HEADER
  14. #define MDIO_HEADER
  15. /*====================================================================*
  16. * constants and macros;
  17. *--------------------------------------------------------------------*/
  18. #define MDIO_VERBOSE (1 << 0)
  19. #define MDIO_SILENCE (1 << 1)
  20. #define MDIO16_USE(x) (((x) & 0x0001) << 0)
  21. #define MDIO16_RSVD(x) (((x) & 0x001F) << 1)
  22. #define MDIO16_CNT(x) (((x) & 0x03FF) << 6)
  23. #define MDIO16_START(use,rsvd,cnt) (MDIO16_USE (use) | MDIO16_RSVD (rsvd) | MDIO16_CNT (cnt))
  24. #define MDIO16_SRT(x) (((x) & 0x0003) << 0)
  25. #define MDIO16_OP(x) (((x) & 0x0003) << 2)
  26. #define MDIO16_PHY(x) (((x) & 0x001F) << 4)
  27. #define MDIO16_REG(x) (((x) & 0x001F) << 9)
  28. #define MDIO16_TA(x) (((x) & 0x0003) << 14)
  29. #define MDIO16_INSTR(srt,op,phy,reg,ta) (MDIO16_SRT (srt) | MDIO16_OP (op) | MDIO16_PHY (phy) | MDIO16_REG (reg) | MDIO16_TA (ta))
  30. #define MDIO32_HI_ADDR_SHIFT 9
  31. #define MDIO32_LO_ADDR_SHIFT 1
  32. #define MDIO32_HI_ADDR_MASK (0x000003FF << MDIO32_HI_ADDR_SHIFT)
  33. #define MDIO32_LO_ADDR_MASK 0x000001FC
  34. #define MDIO32_CODE_SHIFT 3
  35. #define MDIO32_CODE_MASK (0x03 << CODE_SHIFT)
  36. #define MDIO32_CODE_HI_ADDR 0x03
  37. #define MDIO32_CODE_LO_ADDR 0x02
  38. #define MDIO32_HI_ADDR(a) ((a & MDIO32_HI_ADDR_MASK) >> MDIO32_HI_ADDR_SHIFT)
  39. #define MDIO32_LO_ADDR(a) ((a & MDIO32_LO_ADDR_MASK) >> MDIO32_LO_ADDR_SHIFT)
  40. #define MDIO32_INSTR(addr, data, mask) MDIO16_INSTR (1, 1, (MDIO32_CODE_HI_ADDR << MDIO32_CODE_SHIFT), 0x00, 2), MDIO32_HI_ADDR (addr), 0xFFFF, MDIO16_INSTR (1, 1, (MDIO32_CODE_LO_ADDR << MDIO32_CODE_SHIFT) | ((MDIO32_LO_ADDR (addr) & 0xE0) >> 5), MDIO32_LO_ADDR (addr) & 0x1F, 2), (data & 0x0000FFFF), mask & 0x0000FFFF, MDIO16_INSTR (1, 1, (MDIO32_CODE_LO_ADDR << MDIO32_CODE_SHIFT) | ((MDIO32_LO_ADDR (addr) & 0xE0) >> 5), (MDIO32_LO_ADDR (addr) & 0x1F) | 0x01, 2), (data & 0xFFFF0000) >> 16, (mask & 0xFFFF0000) >> 16
  41. /*====================================================================*
  42. *
  43. *--------------------------------------------------------------------*/
  44. #endif