chip.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*
  2. * Marvell 88E6xxx Ethernet switch single-chip definition
  3. *
  4. * Copyright (c) 2008 Marvell Semiconductor
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #ifndef _MV88E6XXX_CHIP_H
  12. #define _MV88E6XXX_CHIP_H
  13. #include <linux/if_vlan.h>
  14. #include <linux/irq.h>
  15. #include <linux/gpio/consumer.h>
  16. #include <linux/kthread.h>
  17. #include <linux/phy.h>
  18. #include <linux/ptp_clock_kernel.h>
  19. #include <linux/timecounter.h>
  20. #include <net/dsa.h>
  21. #define SMI_CMD 0x00
  22. #define SMI_CMD_BUSY BIT(15)
  23. #define SMI_CMD_CLAUSE_22 BIT(12)
  24. #define SMI_CMD_OP_22_WRITE ((1 << 10) | SMI_CMD_BUSY | SMI_CMD_CLAUSE_22)
  25. #define SMI_CMD_OP_22_READ ((2 << 10) | SMI_CMD_BUSY | SMI_CMD_CLAUSE_22)
  26. #define SMI_CMD_OP_45_WRITE_ADDR ((0 << 10) | SMI_CMD_BUSY)
  27. #define SMI_CMD_OP_45_WRITE_DATA ((1 << 10) | SMI_CMD_BUSY)
  28. #define SMI_CMD_OP_45_READ_DATA ((2 << 10) | SMI_CMD_BUSY)
  29. #define SMI_CMD_OP_45_READ_DATA_INC ((3 << 10) | SMI_CMD_BUSY)
  30. #define SMI_DATA 0x01
  31. #define MV88E6XXX_N_FID 4096
  32. /* PVT limits for 4-bit port and 5-bit switch */
  33. #define MV88E6XXX_MAX_PVT_SWITCHES 32
  34. #define MV88E6XXX_MAX_PVT_PORTS 16
  35. #define MV88E6XXX_MAX_GPIO 16
  36. enum mv88e6xxx_egress_mode {
  37. MV88E6XXX_EGRESS_MODE_UNMODIFIED,
  38. MV88E6XXX_EGRESS_MODE_UNTAGGED,
  39. MV88E6XXX_EGRESS_MODE_TAGGED,
  40. MV88E6XXX_EGRESS_MODE_ETHERTYPE,
  41. };
  42. enum mv88e6xxx_frame_mode {
  43. MV88E6XXX_FRAME_MODE_NORMAL,
  44. MV88E6XXX_FRAME_MODE_DSA,
  45. MV88E6XXX_FRAME_MODE_PROVIDER,
  46. MV88E6XXX_FRAME_MODE_ETHERTYPE,
  47. };
  48. /* List of supported models */
  49. enum mv88e6xxx_model {
  50. MV88E6085,
  51. MV88E6095,
  52. MV88E6097,
  53. MV88E6123,
  54. MV88E6131,
  55. MV88E6141,
  56. MV88E6161,
  57. MV88E6165,
  58. MV88E6171,
  59. MV88E6172,
  60. MV88E6175,
  61. MV88E6176,
  62. MV88E6185,
  63. MV88E6190,
  64. MV88E6190X,
  65. MV88E6191,
  66. MV88E6240,
  67. MV88E6290,
  68. MV88E6320,
  69. MV88E6321,
  70. MV88E6341,
  71. MV88E6350,
  72. MV88E6351,
  73. MV88E6352,
  74. MV88E6390,
  75. MV88E6390X,
  76. };
  77. enum mv88e6xxx_family {
  78. MV88E6XXX_FAMILY_NONE,
  79. MV88E6XXX_FAMILY_6065, /* 6031 6035 6061 6065 */
  80. MV88E6XXX_FAMILY_6095, /* 6092 6095 */
  81. MV88E6XXX_FAMILY_6097, /* 6046 6085 6096 6097 */
  82. MV88E6XXX_FAMILY_6165, /* 6123 6161 6165 */
  83. MV88E6XXX_FAMILY_6185, /* 6108 6121 6122 6131 6152 6155 6182 6185 */
  84. MV88E6XXX_FAMILY_6320, /* 6320 6321 */
  85. MV88E6XXX_FAMILY_6341, /* 6141 6341 */
  86. MV88E6XXX_FAMILY_6351, /* 6171 6175 6350 6351 */
  87. MV88E6XXX_FAMILY_6352, /* 6172 6176 6240 6352 */
  88. MV88E6XXX_FAMILY_6390, /* 6190 6190X 6191 6290 6390 6390X */
  89. };
  90. struct mv88e6xxx_ops;
  91. struct mv88e6xxx_info {
  92. enum mv88e6xxx_family family;
  93. u16 prod_num;
  94. const char *name;
  95. unsigned int num_databases;
  96. unsigned int num_ports;
  97. unsigned int num_internal_phys;
  98. unsigned int num_gpio;
  99. unsigned int max_vid;
  100. unsigned int port_base_addr;
  101. unsigned int phy_base_addr;
  102. unsigned int global1_addr;
  103. unsigned int global2_addr;
  104. unsigned int age_time_coeff;
  105. unsigned int g1_irqs;
  106. unsigned int g2_irqs;
  107. bool pvt;
  108. /* Multi-chip Addressing Mode.
  109. * Some chips respond to only 2 registers of its own SMI device address
  110. * when it is non-zero, and use indirect access to internal registers.
  111. */
  112. bool multi_chip;
  113. enum dsa_tag_protocol tag_protocol;
  114. /* Mask for FromPort and ToPort value of PortVec used in ATU Move
  115. * operation. 0 means that the ATU Move operation is not supported.
  116. */
  117. u8 atu_move_port_mask;
  118. const struct mv88e6xxx_ops *ops;
  119. /* Supports PTP */
  120. bool ptp_support;
  121. };
  122. struct mv88e6xxx_atu_entry {
  123. u8 state;
  124. bool trunk;
  125. u16 portvec;
  126. u8 mac[ETH_ALEN];
  127. };
  128. struct mv88e6xxx_vtu_entry {
  129. u16 vid;
  130. u16 fid;
  131. u8 sid;
  132. bool valid;
  133. u8 member[DSA_MAX_PORTS];
  134. u8 state[DSA_MAX_PORTS];
  135. };
  136. struct mv88e6xxx_bus_ops;
  137. struct mv88e6xxx_irq_ops;
  138. struct mv88e6xxx_gpio_ops;
  139. struct mv88e6xxx_avb_ops;
  140. struct mv88e6xxx_ptp_ops;
  141. struct mv88e6xxx_irq {
  142. u16 masked;
  143. struct irq_chip chip;
  144. struct irq_domain *domain;
  145. unsigned int nirqs;
  146. };
  147. /* state flags for mv88e6xxx_port_hwtstamp::state */
  148. enum {
  149. MV88E6XXX_HWTSTAMP_ENABLED,
  150. MV88E6XXX_HWTSTAMP_TX_IN_PROGRESS,
  151. };
  152. struct mv88e6xxx_port_hwtstamp {
  153. /* Port index */
  154. int port_id;
  155. /* Timestamping state */
  156. unsigned long state;
  157. /* Resources for receive timestamping */
  158. struct sk_buff_head rx_queue;
  159. struct sk_buff_head rx_queue2;
  160. /* Resources for transmit timestamping */
  161. unsigned long tx_tstamp_start;
  162. struct sk_buff *tx_skb;
  163. u16 tx_seq_id;
  164. /* Current timestamp configuration */
  165. struct hwtstamp_config tstamp_config;
  166. };
  167. struct mv88e6xxx_port {
  168. struct mv88e6xxx_chip *chip;
  169. int port;
  170. u64 serdes_stats[2];
  171. u64 atu_member_violation;
  172. u64 atu_miss_violation;
  173. u64 atu_full_violation;
  174. u64 vtu_member_violation;
  175. u64 vtu_miss_violation;
  176. u8 cmode;
  177. int serdes_irq;
  178. };
  179. struct mv88e6xxx_chip {
  180. const struct mv88e6xxx_info *info;
  181. /* The dsa_switch this private structure is related to */
  182. struct dsa_switch *ds;
  183. /* The device this structure is associated to */
  184. struct device *dev;
  185. /* This mutex protects the access to the switch registers */
  186. struct mutex reg_lock;
  187. /* The MII bus and the address on the bus that is used to
  188. * communication with the switch
  189. */
  190. const struct mv88e6xxx_bus_ops *smi_ops;
  191. struct mii_bus *bus;
  192. int sw_addr;
  193. /* Handles automatic disabling and re-enabling of the PHY
  194. * polling unit.
  195. */
  196. const struct mv88e6xxx_bus_ops *phy_ops;
  197. struct mutex ppu_mutex;
  198. int ppu_disabled;
  199. struct work_struct ppu_work;
  200. struct timer_list ppu_timer;
  201. /* This mutex serialises access to the statistics unit.
  202. * Hold this mutex over snapshot + dump sequences.
  203. */
  204. struct mutex stats_mutex;
  205. /* A switch may have a GPIO line tied to its reset pin. Parse
  206. * this from the device tree, and use it before performing
  207. * switch soft reset.
  208. */
  209. struct gpio_desc *reset;
  210. /* set to size of eeprom if supported by the switch */
  211. u32 eeprom_len;
  212. /* List of mdio busses */
  213. struct list_head mdios;
  214. /* There can be two interrupt controllers, which are chained
  215. * off a GPIO as interrupt source
  216. */
  217. struct mv88e6xxx_irq g1_irq;
  218. struct mv88e6xxx_irq g2_irq;
  219. int irq;
  220. int device_irq;
  221. int watchdog_irq;
  222. int atu_prob_irq;
  223. int vtu_prob_irq;
  224. struct kthread_worker *kworker;
  225. struct kthread_delayed_work irq_poll_work;
  226. /* GPIO resources */
  227. u8 gpio_data[2];
  228. /* This cyclecounter abstracts the switch PTP time.
  229. * reg_lock must be held for any operation that read()s.
  230. */
  231. struct cyclecounter tstamp_cc;
  232. struct timecounter tstamp_tc;
  233. struct delayed_work overflow_work;
  234. struct ptp_clock *ptp_clock;
  235. struct ptp_clock_info ptp_clock_info;
  236. struct delayed_work tai_event_work;
  237. struct ptp_pin_desc pin_config[MV88E6XXX_MAX_GPIO];
  238. u16 trig_config;
  239. u16 evcap_config;
  240. u16 enable_count;
  241. /* Per-port timestamping resources. */
  242. struct mv88e6xxx_port_hwtstamp port_hwtstamp[DSA_MAX_PORTS];
  243. /* Array of port structures. */
  244. struct mv88e6xxx_port ports[DSA_MAX_PORTS];
  245. };
  246. struct mv88e6xxx_bus_ops {
  247. int (*read)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
  248. int (*write)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
  249. };
  250. struct mv88e6xxx_mdio_bus {
  251. struct mii_bus *bus;
  252. struct mv88e6xxx_chip *chip;
  253. struct list_head list;
  254. bool external;
  255. };
  256. struct mv88e6xxx_ops {
  257. /* Switch Setup Errata, called early in the switch setup to
  258. * allow any errata actions to be performed
  259. */
  260. int (*setup_errata)(struct mv88e6xxx_chip *chip);
  261. int (*ieee_pri_map)(struct mv88e6xxx_chip *chip);
  262. int (*ip_pri_map)(struct mv88e6xxx_chip *chip);
  263. /* Ingress Rate Limit unit (IRL) operations */
  264. int (*irl_init_all)(struct mv88e6xxx_chip *chip, int port);
  265. int (*get_eeprom)(struct mv88e6xxx_chip *chip,
  266. struct ethtool_eeprom *eeprom, u8 *data);
  267. int (*set_eeprom)(struct mv88e6xxx_chip *chip,
  268. struct ethtool_eeprom *eeprom, u8 *data);
  269. int (*set_switch_mac)(struct mv88e6xxx_chip *chip, u8 *addr);
  270. int (*phy_read)(struct mv88e6xxx_chip *chip,
  271. struct mii_bus *bus,
  272. int addr, int reg, u16 *val);
  273. int (*phy_write)(struct mv88e6xxx_chip *chip,
  274. struct mii_bus *bus,
  275. int addr, int reg, u16 val);
  276. /* Priority Override Table operations */
  277. int (*pot_clear)(struct mv88e6xxx_chip *chip);
  278. /* PHY Polling Unit (PPU) operations */
  279. int (*ppu_enable)(struct mv88e6xxx_chip *chip);
  280. int (*ppu_disable)(struct mv88e6xxx_chip *chip);
  281. /* Switch Software Reset */
  282. int (*reset)(struct mv88e6xxx_chip *chip);
  283. /* RGMII Receive/Transmit Timing Control
  284. * Add delay on PHY_INTERFACE_MODE_RGMII_*ID, no delay otherwise.
  285. */
  286. int (*port_set_rgmii_delay)(struct mv88e6xxx_chip *chip, int port,
  287. phy_interface_t mode);
  288. #define LINK_FORCED_DOWN 0
  289. #define LINK_FORCED_UP 1
  290. #define LINK_UNFORCED -2
  291. /* Port's MAC link state
  292. * Use LINK_FORCED_UP or LINK_FORCED_DOWN to force link up or down,
  293. * or LINK_UNFORCED for normal link detection.
  294. */
  295. int (*port_set_link)(struct mv88e6xxx_chip *chip, int port, int link);
  296. #define DUPLEX_UNFORCED -2
  297. /* Port's MAC duplex mode
  298. *
  299. * Use DUPLEX_HALF or DUPLEX_FULL to force half or full duplex,
  300. * or DUPLEX_UNFORCED for normal duplex detection.
  301. */
  302. int (*port_set_duplex)(struct mv88e6xxx_chip *chip, int port, int dup);
  303. #define PAUSE_ON 1
  304. #define PAUSE_OFF 0
  305. /* Enable/disable sending Pause */
  306. int (*port_set_pause)(struct mv88e6xxx_chip *chip, int port,
  307. int pause);
  308. #define SPEED_MAX INT_MAX
  309. #define SPEED_UNFORCED -2
  310. /* Port's MAC speed (in Mbps)
  311. *
  312. * Depending on the chip, 10, 100, 200, 1000, 2500, 10000 are valid.
  313. * Use SPEED_UNFORCED for normal detection, SPEED_MAX for max value.
  314. */
  315. int (*port_set_speed)(struct mv88e6xxx_chip *chip, int port, int speed);
  316. int (*port_tag_remap)(struct mv88e6xxx_chip *chip, int port);
  317. int (*port_set_frame_mode)(struct mv88e6xxx_chip *chip, int port,
  318. enum mv88e6xxx_frame_mode mode);
  319. int (*port_set_egress_floods)(struct mv88e6xxx_chip *chip, int port,
  320. bool unicast, bool multicast);
  321. int (*port_set_ether_type)(struct mv88e6xxx_chip *chip, int port,
  322. u16 etype);
  323. int (*port_set_jumbo_size)(struct mv88e6xxx_chip *chip, int port,
  324. size_t size);
  325. int (*port_egress_rate_limiting)(struct mv88e6xxx_chip *chip, int port);
  326. int (*port_pause_limit)(struct mv88e6xxx_chip *chip, int port, u8 in,
  327. u8 out);
  328. int (*port_disable_learn_limit)(struct mv88e6xxx_chip *chip, int port);
  329. int (*port_disable_pri_override)(struct mv88e6xxx_chip *chip, int port);
  330. /* CMODE control what PHY mode the MAC will use, eg. SGMII, RGMII, etc.
  331. * Some chips allow this to be configured on specific ports.
  332. */
  333. int (*port_set_cmode)(struct mv88e6xxx_chip *chip, int port,
  334. phy_interface_t mode);
  335. int (*port_get_cmode)(struct mv88e6xxx_chip *chip, int port, u8 *cmode);
  336. /* Some devices have a per port register indicating what is
  337. * the upstream port this port should forward to.
  338. */
  339. int (*port_set_upstream_port)(struct mv88e6xxx_chip *chip, int port,
  340. int upstream_port);
  341. /* Return the port link state, as required by phylink */
  342. int (*port_link_state)(struct mv88e6xxx_chip *chip, int port,
  343. struct phylink_link_state *state);
  344. /* Snapshot the statistics for a port. The statistics can then
  345. * be read back a leisure but still with a consistent view.
  346. */
  347. int (*stats_snapshot)(struct mv88e6xxx_chip *chip, int port);
  348. /* Set the histogram mode for statistics, when the control registers
  349. * are separated out of the STATS_OP register.
  350. */
  351. int (*stats_set_histogram)(struct mv88e6xxx_chip *chip);
  352. /* Return the number of strings describing statistics */
  353. int (*stats_get_sset_count)(struct mv88e6xxx_chip *chip);
  354. int (*stats_get_strings)(struct mv88e6xxx_chip *chip, uint8_t *data);
  355. int (*stats_get_stats)(struct mv88e6xxx_chip *chip, int port,
  356. uint64_t *data);
  357. int (*set_cpu_port)(struct mv88e6xxx_chip *chip, int port);
  358. int (*set_egress_port)(struct mv88e6xxx_chip *chip, int port);
  359. #define MV88E6XXX_CASCADE_PORT_NONE 0xe
  360. #define MV88E6XXX_CASCADE_PORT_MULTIPLE 0xf
  361. int (*set_cascade_port)(struct mv88e6xxx_chip *chip, int port);
  362. const struct mv88e6xxx_irq_ops *watchdog_ops;
  363. int (*mgmt_rsvd2cpu)(struct mv88e6xxx_chip *chip);
  364. /* Power on/off a SERDES interface */
  365. int (*serdes_power)(struct mv88e6xxx_chip *chip, int port, bool on);
  366. /* SERDES interrupt handling */
  367. int (*serdes_irq_setup)(struct mv88e6xxx_chip *chip, int port);
  368. void (*serdes_irq_free)(struct mv88e6xxx_chip *chip, int port);
  369. /* Statistics from the SERDES interface */
  370. int (*serdes_get_sset_count)(struct mv88e6xxx_chip *chip, int port);
  371. int (*serdes_get_strings)(struct mv88e6xxx_chip *chip, int port,
  372. uint8_t *data);
  373. int (*serdes_get_stats)(struct mv88e6xxx_chip *chip, int port,
  374. uint64_t *data);
  375. /* VLAN Translation Unit operations */
  376. int (*vtu_getnext)(struct mv88e6xxx_chip *chip,
  377. struct mv88e6xxx_vtu_entry *entry);
  378. int (*vtu_loadpurge)(struct mv88e6xxx_chip *chip,
  379. struct mv88e6xxx_vtu_entry *entry);
  380. /* GPIO operations */
  381. const struct mv88e6xxx_gpio_ops *gpio_ops;
  382. /* Interface to the AVB/PTP registers */
  383. const struct mv88e6xxx_avb_ops *avb_ops;
  384. /* Remote Management Unit operations */
  385. int (*rmu_disable)(struct mv88e6xxx_chip *chip);
  386. /* Precision Time Protocol operations */
  387. const struct mv88e6xxx_ptp_ops *ptp_ops;
  388. /* Phylink */
  389. void (*phylink_validate)(struct mv88e6xxx_chip *chip, int port,
  390. unsigned long *mask,
  391. struct phylink_link_state *state);
  392. };
  393. struct mv88e6xxx_irq_ops {
  394. /* Action to be performed when the interrupt happens */
  395. int (*irq_action)(struct mv88e6xxx_chip *chip, int irq);
  396. /* Setup the hardware to generate the interrupt */
  397. int (*irq_setup)(struct mv88e6xxx_chip *chip);
  398. /* Reset the hardware to stop generating the interrupt */
  399. void (*irq_free)(struct mv88e6xxx_chip *chip);
  400. };
  401. struct mv88e6xxx_gpio_ops {
  402. /* Get/set data on GPIO pin */
  403. int (*get_data)(struct mv88e6xxx_chip *chip, unsigned int pin);
  404. int (*set_data)(struct mv88e6xxx_chip *chip, unsigned int pin,
  405. int value);
  406. /* get/set GPIO direction */
  407. int (*get_dir)(struct mv88e6xxx_chip *chip, unsigned int pin);
  408. int (*set_dir)(struct mv88e6xxx_chip *chip, unsigned int pin,
  409. bool input);
  410. /* get/set GPIO pin control */
  411. int (*get_pctl)(struct mv88e6xxx_chip *chip, unsigned int pin,
  412. int *func);
  413. int (*set_pctl)(struct mv88e6xxx_chip *chip, unsigned int pin,
  414. int func);
  415. };
  416. struct mv88e6xxx_avb_ops {
  417. /* Access port-scoped Precision Time Protocol registers */
  418. int (*port_ptp_read)(struct mv88e6xxx_chip *chip, int port, int addr,
  419. u16 *data, int len);
  420. int (*port_ptp_write)(struct mv88e6xxx_chip *chip, int port, int addr,
  421. u16 data);
  422. /* Access global Precision Time Protocol registers */
  423. int (*ptp_read)(struct mv88e6xxx_chip *chip, int addr, u16 *data,
  424. int len);
  425. int (*ptp_write)(struct mv88e6xxx_chip *chip, int addr, u16 data);
  426. /* Access global Time Application Interface registers */
  427. int (*tai_read)(struct mv88e6xxx_chip *chip, int addr, u16 *data,
  428. int len);
  429. int (*tai_write)(struct mv88e6xxx_chip *chip, int addr, u16 data);
  430. };
  431. struct mv88e6xxx_ptp_ops {
  432. u64 (*clock_read)(const struct cyclecounter *cc);
  433. int (*ptp_enable)(struct ptp_clock_info *ptp,
  434. struct ptp_clock_request *rq, int on);
  435. int (*ptp_verify)(struct ptp_clock_info *ptp, unsigned int pin,
  436. enum ptp_pin_function func, unsigned int chan);
  437. void (*event_work)(struct work_struct *ugly);
  438. int (*port_enable)(struct mv88e6xxx_chip *chip, int port);
  439. int (*port_disable)(struct mv88e6xxx_chip *chip, int port);
  440. int (*global_enable)(struct mv88e6xxx_chip *chip);
  441. int (*global_disable)(struct mv88e6xxx_chip *chip);
  442. int n_ext_ts;
  443. int arr0_sts_reg;
  444. int arr1_sts_reg;
  445. int dep_sts_reg;
  446. u32 rx_filters;
  447. };
  448. #define STATS_TYPE_PORT BIT(0)
  449. #define STATS_TYPE_BANK0 BIT(1)
  450. #define STATS_TYPE_BANK1 BIT(2)
  451. struct mv88e6xxx_hw_stat {
  452. char string[ETH_GSTRING_LEN];
  453. size_t size;
  454. int reg;
  455. int type;
  456. };
  457. static inline bool mv88e6xxx_has_pvt(struct mv88e6xxx_chip *chip)
  458. {
  459. return chip->info->pvt;
  460. }
  461. static inline unsigned int mv88e6xxx_num_databases(struct mv88e6xxx_chip *chip)
  462. {
  463. return chip->info->num_databases;
  464. }
  465. static inline unsigned int mv88e6xxx_num_ports(struct mv88e6xxx_chip *chip)
  466. {
  467. return chip->info->num_ports;
  468. }
  469. static inline u16 mv88e6xxx_port_mask(struct mv88e6xxx_chip *chip)
  470. {
  471. return GENMASK(mv88e6xxx_num_ports(chip) - 1, 0);
  472. }
  473. static inline unsigned int mv88e6xxx_num_gpio(struct mv88e6xxx_chip *chip)
  474. {
  475. return chip->info->num_gpio;
  476. }
  477. int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
  478. int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
  479. int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg,
  480. u16 update);
  481. int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask);
  482. struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip);
  483. #endif /* _MV88E6XXX_CHIP_H */