mv88e6xxx.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * net/dsa/mv88e6xxx.h - Marvell 88e6xxx switch chip support
  3. * Copyright (c) 2008 Marvell Semiconductor
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. */
  10. #ifndef __MV88E6XXX_H
  11. #define __MV88E6XXX_H
  12. #define REG_PORT(p) (0x10 + (p))
  13. #define REG_GLOBAL 0x1b
  14. #define REG_GLOBAL2 0x1c
  15. struct mv88e6xxx_priv_state {
  16. /* When using multi-chip addressing, this mutex protects
  17. * access to the indirect access registers. (In single-chip
  18. * mode, this mutex is effectively useless.)
  19. */
  20. struct mutex smi_mutex;
  21. #ifdef CONFIG_NET_DSA_MV88E6XXX_NEED_PPU
  22. /* Handles automatic disabling and re-enabling of the PHY
  23. * polling unit.
  24. */
  25. struct mutex ppu_mutex;
  26. int ppu_disabled;
  27. struct work_struct ppu_work;
  28. struct timer_list ppu_timer;
  29. #endif
  30. /* This mutex serialises access to the statistics unit.
  31. * Hold this mutex over snapshot + dump sequences.
  32. */
  33. struct mutex stats_mutex;
  34. /* This mutex serializes phy access for chips with
  35. * indirect phy addressing. It is unused for chips
  36. * with direct phy access.
  37. */
  38. struct mutex phy_mutex;
  39. /* This mutex serializes eeprom access for chips with
  40. * eeprom support.
  41. */
  42. struct mutex eeprom_mutex;
  43. int id; /* switch product id */
  44. };
  45. struct mv88e6xxx_hw_stat {
  46. char string[ETH_GSTRING_LEN];
  47. int sizeof_stat;
  48. int reg;
  49. };
  50. int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg);
  51. int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg);
  52. int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr,
  53. int reg, u16 val);
  54. int mv88e6xxx_reg_write(struct dsa_switch *ds, int addr, int reg, u16 val);
  55. int mv88e6xxx_config_prio(struct dsa_switch *ds);
  56. int mv88e6xxx_set_addr_direct(struct dsa_switch *ds, u8 *addr);
  57. int mv88e6xxx_set_addr_indirect(struct dsa_switch *ds, u8 *addr);
  58. int mv88e6xxx_phy_read(struct dsa_switch *ds, int addr, int regnum);
  59. int mv88e6xxx_phy_write(struct dsa_switch *ds, int addr, int regnum, u16 val);
  60. void mv88e6xxx_ppu_state_init(struct dsa_switch *ds);
  61. int mv88e6xxx_phy_read_ppu(struct dsa_switch *ds, int addr, int regnum);
  62. int mv88e6xxx_phy_write_ppu(struct dsa_switch *ds, int addr,
  63. int regnum, u16 val);
  64. void mv88e6xxx_poll_link(struct dsa_switch *ds);
  65. void mv88e6xxx_get_strings(struct dsa_switch *ds,
  66. int nr_stats, struct mv88e6xxx_hw_stat *stats,
  67. int port, uint8_t *data);
  68. void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds,
  69. int nr_stats, struct mv88e6xxx_hw_stat *stats,
  70. int port, uint64_t *data);
  71. int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port);
  72. void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
  73. struct ethtool_regs *regs, void *_p);
  74. int mv88e6xxx_get_temp(struct dsa_switch *ds, int *temp);
  75. extern struct dsa_switch_driver mv88e6131_switch_driver;
  76. extern struct dsa_switch_driver mv88e6123_61_65_switch_driver;
  77. extern struct dsa_switch_driver mv88e6352_switch_driver;
  78. extern struct dsa_switch_driver mv88e6171_switch_driver;
  79. #define REG_READ(addr, reg) \
  80. ({ \
  81. int __ret; \
  82. \
  83. __ret = mv88e6xxx_reg_read(ds, addr, reg); \
  84. if (__ret < 0) \
  85. return __ret; \
  86. __ret; \
  87. })
  88. #define REG_WRITE(addr, reg, val) \
  89. ({ \
  90. int __ret; \
  91. \
  92. __ret = mv88e6xxx_reg_write(ds, addr, reg, val); \
  93. if (__ret < 0) \
  94. return __ret; \
  95. })
  96. #endif