adm6996.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * ADM6996 switch driver
  3. *
  4. * Copyright (c) 2008 Felix Fietkau <[email protected]>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License v2 as published by the
  8. * Free Software Foundation
  9. */
  10. #ifndef __ADM6996_H
  11. #define __ADM6996_H
  12. #define ADM_PHY_PORTS 5
  13. #define ADM_CPU_PORT 5
  14. #define ADM_WAN_PORT 0 /* FIXME: dynamic ? */
  15. enum admreg {
  16. ADM_EEPROM_BASE = 0x0,
  17. ADM_P0_CFG = ADM_EEPROM_BASE + 1,
  18. ADM_P1_CFG = ADM_EEPROM_BASE + 3,
  19. ADM_P2_CFG = ADM_EEPROM_BASE + 5,
  20. ADM_P3_CFG = ADM_EEPROM_BASE + 7,
  21. ADM_P4_CFG = ADM_EEPROM_BASE + 8,
  22. ADM_P5_CFG = ADM_EEPROM_BASE + 9,
  23. ADM_EEPROM_EXT_BASE = 0x40,
  24. ADM_COUNTER_BASE = 0xa0,
  25. ADM_SIG0 = ADM_COUNTER_BASE + 0,
  26. ADM_SIG1 = ADM_COUNTER_BASE + 1,
  27. ADM_PHY_BASE = 0x200,
  28. #define ADM_PHY_PORT(n) (ADM_PHY_BASE + (0x20 * n))
  29. };
  30. /* Chip identification patterns */
  31. #define ADM_SIG0_MASK 0xfff0
  32. #define ADM_SIG0_VAL 0x1020
  33. #define ADM_SIG1_MASK 0xffff
  34. #define ADM_SIG1_VAL 0x0007
  35. enum {
  36. ADM_PHYCFG_COLTST = (1 << 7), /* Enable collision test */
  37. ADM_PHYCFG_DPLX = (1 << 8), /* Enable full duplex */
  38. ADM_PHYCFG_ANEN_RST = (1 << 9), /* Restart auto negotiation (self clear) */
  39. ADM_PHYCFG_ISO = (1 << 10), /* Isolate PHY */
  40. ADM_PHYCFG_PDN = (1 << 11), /* Power down PHY */
  41. ADM_PHYCFG_ANEN = (1 << 12), /* Enable auto negotiation */
  42. ADM_PHYCFG_SPEED_100 = (1 << 13), /* Enable 100 Mbit/s */
  43. ADM_PHYCFG_LPBK = (1 << 14), /* Enable loopback operation */
  44. ADM_PHYCFG_RST = (1 << 15), /* Reset the port (self clear) */
  45. ADM_PHYCFG_INIT = (
  46. ADM_PHYCFG_RST |
  47. ADM_PHYCFG_SPEED_100 |
  48. ADM_PHYCFG_ANEN |
  49. ADM_PHYCFG_ANEN_RST
  50. )
  51. };
  52. enum {
  53. ADM_PORTCFG_FC = (1 << 0), /* Enable 802.x flow control */
  54. ADM_PORTCFG_AN = (1 << 1), /* Enable auto-negotiation */
  55. ADM_PORTCFG_SPEED_100 = (1 << 2), /* Enable 100 Mbit/s */
  56. ADM_PORTCFG_DPLX = (1 << 3), /* Enable full duplex */
  57. ADM_PORTCFG_OT = (1 << 4), /* Output tagged packets */
  58. ADM_PORTCFG_PD = (1 << 5), /* Port disable */
  59. ADM_PORTCFG_TV_PRIO = (1 << 6), /* 0 = VLAN based priority
  60. * 1 = TOS based priority */
  61. ADM_PORTCFG_PPE = (1 << 7), /* Port based priority enable */
  62. ADM_PORTCFG_PP_S = (1 << 8), /* Port based priority, 2 bits */
  63. ADM_PORTCFG_PVID_BASE = (1 << 10), /* Primary VLAN id, 4 bits */
  64. ADM_PORTCFG_FSE = (1 << 14), /* Fx select enable */
  65. ADM_PORTCFG_CAM = (1 << 15), /* Crossover Auto MDIX */
  66. ADM_PORTCFG_INIT = (
  67. ADM_PORTCFG_FC |
  68. ADM_PORTCFG_AN |
  69. ADM_PORTCFG_SPEED_100 |
  70. ADM_PORTCFG_DPLX |
  71. ADM_PORTCFG_CAM
  72. ),
  73. ADM_PORTCFG_CPU = (
  74. ADM_PORTCFG_FC |
  75. ADM_PORTCFG_SPEED_100 |
  76. ADM_PORTCFG_OT |
  77. ADM_PORTCFG_DPLX
  78. ),
  79. };
  80. #define ADM_PORTCFG_PPID(N) ((n & 0x3) << 8)
  81. #define ADM_PORTCFG_PVID(n) ((n & 0xf) << 10)
  82. static const u8 adm_portcfg[] = {
  83. [0] = ADM_P0_CFG,
  84. [1] = ADM_P1_CFG,
  85. [2] = ADM_P2_CFG,
  86. [3] = ADM_P3_CFG,
  87. [4] = ADM_P4_CFG,
  88. [5] = ADM_P5_CFG,
  89. };
  90. /*
  91. * Split the register address in phy id and register
  92. * it will get combined again by the mdio bus op
  93. */
  94. #define PHYADDR(_reg) ((_reg >> 5) & 0xff), (_reg & 0x1f)
  95. #endif