mv88e6xxx.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /*
  17. * When using multi-chip addressing, this mutex protects
  18. * access to the indirect access registers. (In single-chip
  19. * mode, this mutex is effectively useless.)
  20. */
  21. struct mutex smi_mutex;
  22. /*
  23. * This mutex serialises access to the statistics unit.
  24. * Hold this mutex over snapshot + dump sequences.
  25. */
  26. struct mutex stats_mutex;
  27. };
  28. struct mv88e6xxx_hw_stat {
  29. char string[ETH_GSTRING_LEN];
  30. int sizeof_stat;
  31. int reg;
  32. };
  33. int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg);
  34. int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg);
  35. int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr,
  36. int reg, u16 val);
  37. int mv88e6xxx_reg_write(struct dsa_switch *ds, int addr, int reg, u16 val);
  38. int mv88e6xxx_config_prio(struct dsa_switch *ds);
  39. int mv88e6xxx_set_addr_indirect(struct dsa_switch *ds, u8 *addr);
  40. int mv88e6xxx_phy_read(struct dsa_switch *ds, int addr, int regnum);
  41. int mv88e6xxx_phy_write(struct dsa_switch *ds, int addr, int regnum, u16 val);
  42. void mv88e6xxx_poll_link(struct dsa_switch *ds);
  43. void mv88e6xxx_get_strings(struct dsa_switch *ds,
  44. int nr_stats, struct mv88e6xxx_hw_stat *stats,
  45. int port, uint8_t *data);
  46. void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds,
  47. int nr_stats, struct mv88e6xxx_hw_stat *stats,
  48. int port, uint64_t *data);
  49. #define REG_READ(addr, reg) \
  50. ({ \
  51. int __ret; \
  52. \
  53. __ret = mv88e6xxx_reg_read(ds, addr, reg); \
  54. if (__ret < 0) \
  55. return __ret; \
  56. __ret; \
  57. })
  58. #define REG_WRITE(addr, reg, val) \
  59. ({ \
  60. int __ret; \
  61. \
  62. __ret = mv88e6xxx_reg_write(ds, addr, reg, val); \
  63. if (__ret < 0) \
  64. return __ret; \
  65. })
  66. #endif