ocelot.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
  2. /*
  3. * Microsemi Ocelot Switch driver
  4. *
  5. * Copyright (c) 2017 Microsemi Corporation
  6. */
  7. #ifndef _MSCC_OCELOT_H_
  8. #define _MSCC_OCELOT_H_
  9. #include <linux/bitops.h>
  10. #include <linux/etherdevice.h>
  11. #include <linux/if_vlan.h>
  12. #include <linux/net_tstamp.h>
  13. #include <linux/phy.h>
  14. #include <linux/phy/phy.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/ptp_clock_kernel.h>
  17. #include <linux/regmap.h>
  18. #include "ocelot_ana.h"
  19. #include "ocelot_dev.h"
  20. #include "ocelot_qsys.h"
  21. #include "ocelot_rew.h"
  22. #include "ocelot_sys.h"
  23. #include "ocelot_qs.h"
  24. #include "ocelot_tc.h"
  25. #include "ocelot_ptp.h"
  26. #define PGID_AGGR 64
  27. #define PGID_SRC 80
  28. /* Reserved PGIDs */
  29. #define PGID_CPU (PGID_AGGR - 5)
  30. #define PGID_UC (PGID_AGGR - 4)
  31. #define PGID_MC (PGID_AGGR - 3)
  32. #define PGID_MCIPV4 (PGID_AGGR - 2)
  33. #define PGID_MCIPV6 (PGID_AGGR - 1)
  34. #define OCELOT_BUFFER_CELL_SZ 60
  35. #define OCELOT_STATS_CHECK_DELAY (2 * HZ)
  36. #define OCELOT_PTP_QUEUE_SZ 128
  37. #define IFH_LEN 4
  38. struct frame_info {
  39. u32 len;
  40. u16 port;
  41. u16 vid;
  42. u8 tag_type;
  43. u16 rew_op;
  44. u32 timestamp; /* rew_val */
  45. };
  46. #define IFH_INJ_BYPASS BIT(31)
  47. #define IFH_INJ_POP_CNT_DISABLE (3 << 28)
  48. #define IFH_TAG_TYPE_C 0
  49. #define IFH_TAG_TYPE_S 1
  50. #define IFH_REW_OP_NOOP 0x0
  51. #define IFH_REW_OP_DSCP 0x1
  52. #define IFH_REW_OP_ONE_STEP_PTP 0x2
  53. #define IFH_REW_OP_TWO_STEP_PTP 0x3
  54. #define IFH_REW_OP_ORIGIN_PTP 0x5
  55. #define OCELOT_SPEED_2500 0
  56. #define OCELOT_SPEED_1000 1
  57. #define OCELOT_SPEED_100 2
  58. #define OCELOT_SPEED_10 3
  59. #define TARGET_OFFSET 24
  60. #define REG_MASK GENMASK(TARGET_OFFSET - 1, 0)
  61. #define REG(reg, offset) [reg & REG_MASK] = offset
  62. enum ocelot_target {
  63. ANA = 1,
  64. QS,
  65. QSYS,
  66. REW,
  67. SYS,
  68. S2,
  69. HSIO,
  70. PTP,
  71. TARGET_MAX,
  72. };
  73. enum ocelot_reg {
  74. ANA_ADVLEARN = ANA << TARGET_OFFSET,
  75. ANA_VLANMASK,
  76. ANA_PORT_B_DOMAIN,
  77. ANA_ANAGEFIL,
  78. ANA_ANEVENTS,
  79. ANA_STORMLIMIT_BURST,
  80. ANA_STORMLIMIT_CFG,
  81. ANA_ISOLATED_PORTS,
  82. ANA_COMMUNITY_PORTS,
  83. ANA_AUTOAGE,
  84. ANA_MACTOPTIONS,
  85. ANA_LEARNDISC,
  86. ANA_AGENCTRL,
  87. ANA_MIRRORPORTS,
  88. ANA_EMIRRORPORTS,
  89. ANA_FLOODING,
  90. ANA_FLOODING_IPMC,
  91. ANA_SFLOW_CFG,
  92. ANA_PORT_MODE,
  93. ANA_CUT_THRU_CFG,
  94. ANA_PGID_PGID,
  95. ANA_TABLES_ANMOVED,
  96. ANA_TABLES_MACHDATA,
  97. ANA_TABLES_MACLDATA,
  98. ANA_TABLES_STREAMDATA,
  99. ANA_TABLES_MACACCESS,
  100. ANA_TABLES_MACTINDX,
  101. ANA_TABLES_VLANACCESS,
  102. ANA_TABLES_VLANTIDX,
  103. ANA_TABLES_ISDXACCESS,
  104. ANA_TABLES_ISDXTIDX,
  105. ANA_TABLES_ENTRYLIM,
  106. ANA_TABLES_PTP_ID_HIGH,
  107. ANA_TABLES_PTP_ID_LOW,
  108. ANA_TABLES_STREAMACCESS,
  109. ANA_TABLES_STREAMTIDX,
  110. ANA_TABLES_SEQ_HISTORY,
  111. ANA_TABLES_SEQ_MASK,
  112. ANA_TABLES_SFID_MASK,
  113. ANA_TABLES_SFIDACCESS,
  114. ANA_TABLES_SFIDTIDX,
  115. ANA_MSTI_STATE,
  116. ANA_OAM_UPM_LM_CNT,
  117. ANA_SG_ACCESS_CTRL,
  118. ANA_SG_CONFIG_REG_1,
  119. ANA_SG_CONFIG_REG_2,
  120. ANA_SG_CONFIG_REG_3,
  121. ANA_SG_CONFIG_REG_4,
  122. ANA_SG_CONFIG_REG_5,
  123. ANA_SG_GCL_GS_CONFIG,
  124. ANA_SG_GCL_TI_CONFIG,
  125. ANA_SG_STATUS_REG_1,
  126. ANA_SG_STATUS_REG_2,
  127. ANA_SG_STATUS_REG_3,
  128. ANA_PORT_VLAN_CFG,
  129. ANA_PORT_DROP_CFG,
  130. ANA_PORT_QOS_CFG,
  131. ANA_PORT_VCAP_CFG,
  132. ANA_PORT_VCAP_S1_KEY_CFG,
  133. ANA_PORT_VCAP_S2_CFG,
  134. ANA_PORT_PCP_DEI_MAP,
  135. ANA_PORT_CPU_FWD_CFG,
  136. ANA_PORT_CPU_FWD_BPDU_CFG,
  137. ANA_PORT_CPU_FWD_GARP_CFG,
  138. ANA_PORT_CPU_FWD_CCM_CFG,
  139. ANA_PORT_PORT_CFG,
  140. ANA_PORT_POL_CFG,
  141. ANA_PORT_PTP_CFG,
  142. ANA_PORT_PTP_DLY1_CFG,
  143. ANA_PORT_PTP_DLY2_CFG,
  144. ANA_PORT_SFID_CFG,
  145. ANA_PFC_PFC_CFG,
  146. ANA_PFC_PFC_TIMER,
  147. ANA_IPT_OAM_MEP_CFG,
  148. ANA_IPT_IPT,
  149. ANA_PPT_PPT,
  150. ANA_FID_MAP_FID_MAP,
  151. ANA_AGGR_CFG,
  152. ANA_CPUQ_CFG,
  153. ANA_CPUQ_CFG2,
  154. ANA_CPUQ_8021_CFG,
  155. ANA_DSCP_CFG,
  156. ANA_DSCP_REWR_CFG,
  157. ANA_VCAP_RNG_TYPE_CFG,
  158. ANA_VCAP_RNG_VAL_CFG,
  159. ANA_VRAP_CFG,
  160. ANA_VRAP_HDR_DATA,
  161. ANA_VRAP_HDR_MASK,
  162. ANA_DISCARD_CFG,
  163. ANA_FID_CFG,
  164. ANA_POL_PIR_CFG,
  165. ANA_POL_CIR_CFG,
  166. ANA_POL_MODE_CFG,
  167. ANA_POL_PIR_STATE,
  168. ANA_POL_CIR_STATE,
  169. ANA_POL_STATE,
  170. ANA_POL_FLOWC,
  171. ANA_POL_HYST,
  172. ANA_POL_MISC_CFG,
  173. QS_XTR_GRP_CFG = QS << TARGET_OFFSET,
  174. QS_XTR_RD,
  175. QS_XTR_FRM_PRUNING,
  176. QS_XTR_FLUSH,
  177. QS_XTR_DATA_PRESENT,
  178. QS_XTR_CFG,
  179. QS_INJ_GRP_CFG,
  180. QS_INJ_WR,
  181. QS_INJ_CTRL,
  182. QS_INJ_STATUS,
  183. QS_INJ_ERR,
  184. QS_INH_DBG,
  185. QSYS_PORT_MODE = QSYS << TARGET_OFFSET,
  186. QSYS_SWITCH_PORT_MODE,
  187. QSYS_STAT_CNT_CFG,
  188. QSYS_EEE_CFG,
  189. QSYS_EEE_THRES,
  190. QSYS_IGR_NO_SHARING,
  191. QSYS_EGR_NO_SHARING,
  192. QSYS_SW_STATUS,
  193. QSYS_EXT_CPU_CFG,
  194. QSYS_PAD_CFG,
  195. QSYS_CPU_GROUP_MAP,
  196. QSYS_QMAP,
  197. QSYS_ISDX_SGRP,
  198. QSYS_TIMED_FRAME_ENTRY,
  199. QSYS_TFRM_MISC,
  200. QSYS_TFRM_PORT_DLY,
  201. QSYS_TFRM_TIMER_CFG_1,
  202. QSYS_TFRM_TIMER_CFG_2,
  203. QSYS_TFRM_TIMER_CFG_3,
  204. QSYS_TFRM_TIMER_CFG_4,
  205. QSYS_TFRM_TIMER_CFG_5,
  206. QSYS_TFRM_TIMER_CFG_6,
  207. QSYS_TFRM_TIMER_CFG_7,
  208. QSYS_TFRM_TIMER_CFG_8,
  209. QSYS_RED_PROFILE,
  210. QSYS_RES_QOS_MODE,
  211. QSYS_RES_CFG,
  212. QSYS_RES_STAT,
  213. QSYS_EGR_DROP_MODE,
  214. QSYS_EQ_CTRL,
  215. QSYS_EVENTS_CORE,
  216. QSYS_QMAXSDU_CFG_0,
  217. QSYS_QMAXSDU_CFG_1,
  218. QSYS_QMAXSDU_CFG_2,
  219. QSYS_QMAXSDU_CFG_3,
  220. QSYS_QMAXSDU_CFG_4,
  221. QSYS_QMAXSDU_CFG_5,
  222. QSYS_QMAXSDU_CFG_6,
  223. QSYS_QMAXSDU_CFG_7,
  224. QSYS_PREEMPTION_CFG,
  225. QSYS_CIR_CFG,
  226. QSYS_EIR_CFG,
  227. QSYS_SE_CFG,
  228. QSYS_SE_DWRR_CFG,
  229. QSYS_SE_CONNECT,
  230. QSYS_SE_DLB_SENSE,
  231. QSYS_CIR_STATE,
  232. QSYS_EIR_STATE,
  233. QSYS_SE_STATE,
  234. QSYS_HSCH_MISC_CFG,
  235. QSYS_TAG_CONFIG,
  236. QSYS_TAS_PARAM_CFG_CTRL,
  237. QSYS_PORT_MAX_SDU,
  238. QSYS_PARAM_CFG_REG_1,
  239. QSYS_PARAM_CFG_REG_2,
  240. QSYS_PARAM_CFG_REG_3,
  241. QSYS_PARAM_CFG_REG_4,
  242. QSYS_PARAM_CFG_REG_5,
  243. QSYS_GCL_CFG_REG_1,
  244. QSYS_GCL_CFG_REG_2,
  245. QSYS_PARAM_STATUS_REG_1,
  246. QSYS_PARAM_STATUS_REG_2,
  247. QSYS_PARAM_STATUS_REG_3,
  248. QSYS_PARAM_STATUS_REG_4,
  249. QSYS_PARAM_STATUS_REG_5,
  250. QSYS_PARAM_STATUS_REG_6,
  251. QSYS_PARAM_STATUS_REG_7,
  252. QSYS_PARAM_STATUS_REG_8,
  253. QSYS_PARAM_STATUS_REG_9,
  254. QSYS_GCL_STATUS_REG_1,
  255. QSYS_GCL_STATUS_REG_2,
  256. REW_PORT_VLAN_CFG = REW << TARGET_OFFSET,
  257. REW_TAG_CFG,
  258. REW_PORT_CFG,
  259. REW_DSCP_CFG,
  260. REW_PCP_DEI_QOS_MAP_CFG,
  261. REW_PTP_CFG,
  262. REW_PTP_DLY1_CFG,
  263. REW_RED_TAG_CFG,
  264. REW_DSCP_REMAP_DP1_CFG,
  265. REW_DSCP_REMAP_CFG,
  266. REW_STAT_CFG,
  267. REW_REW_STICKY,
  268. REW_PPT,
  269. SYS_COUNT_RX_OCTETS = SYS << TARGET_OFFSET,
  270. SYS_COUNT_RX_UNICAST,
  271. SYS_COUNT_RX_MULTICAST,
  272. SYS_COUNT_RX_BROADCAST,
  273. SYS_COUNT_RX_SHORTS,
  274. SYS_COUNT_RX_FRAGMENTS,
  275. SYS_COUNT_RX_JABBERS,
  276. SYS_COUNT_RX_CRC_ALIGN_ERRS,
  277. SYS_COUNT_RX_SYM_ERRS,
  278. SYS_COUNT_RX_64,
  279. SYS_COUNT_RX_65_127,
  280. SYS_COUNT_RX_128_255,
  281. SYS_COUNT_RX_256_1023,
  282. SYS_COUNT_RX_1024_1526,
  283. SYS_COUNT_RX_1527_MAX,
  284. SYS_COUNT_RX_PAUSE,
  285. SYS_COUNT_RX_CONTROL,
  286. SYS_COUNT_RX_LONGS,
  287. SYS_COUNT_RX_CLASSIFIED_DROPS,
  288. SYS_COUNT_TX_OCTETS,
  289. SYS_COUNT_TX_UNICAST,
  290. SYS_COUNT_TX_MULTICAST,
  291. SYS_COUNT_TX_BROADCAST,
  292. SYS_COUNT_TX_COLLISION,
  293. SYS_COUNT_TX_DROPS,
  294. SYS_COUNT_TX_PAUSE,
  295. SYS_COUNT_TX_64,
  296. SYS_COUNT_TX_65_127,
  297. SYS_COUNT_TX_128_511,
  298. SYS_COUNT_TX_512_1023,
  299. SYS_COUNT_TX_1024_1526,
  300. SYS_COUNT_TX_1527_MAX,
  301. SYS_COUNT_TX_AGING,
  302. SYS_RESET_CFG,
  303. SYS_SR_ETYPE_CFG,
  304. SYS_VLAN_ETYPE_CFG,
  305. SYS_PORT_MODE,
  306. SYS_FRONT_PORT_MODE,
  307. SYS_FRM_AGING,
  308. SYS_STAT_CFG,
  309. SYS_SW_STATUS,
  310. SYS_MISC_CFG,
  311. SYS_REW_MAC_HIGH_CFG,
  312. SYS_REW_MAC_LOW_CFG,
  313. SYS_TIMESTAMP_OFFSET,
  314. SYS_CMID,
  315. SYS_PAUSE_CFG,
  316. SYS_PAUSE_TOT_CFG,
  317. SYS_ATOP,
  318. SYS_ATOP_TOT_CFG,
  319. SYS_MAC_FC_CFG,
  320. SYS_MMGT,
  321. SYS_MMGT_FAST,
  322. SYS_EVENTS_DIF,
  323. SYS_EVENTS_CORE,
  324. SYS_CNT,
  325. SYS_PTP_STATUS,
  326. SYS_PTP_TXSTAMP,
  327. SYS_PTP_NXT,
  328. SYS_PTP_CFG,
  329. SYS_RAM_INIT,
  330. SYS_CM_ADDR,
  331. SYS_CM_DATA_WR,
  332. SYS_CM_DATA_RD,
  333. SYS_CM_OP,
  334. SYS_CM_DATA,
  335. S2_CORE_UPDATE_CTRL = S2 << TARGET_OFFSET,
  336. S2_CORE_MV_CFG,
  337. S2_CACHE_ENTRY_DAT,
  338. S2_CACHE_MASK_DAT,
  339. S2_CACHE_ACTION_DAT,
  340. S2_CACHE_CNT_DAT,
  341. S2_CACHE_TG_DAT,
  342. PTP_PIN_CFG = PTP << TARGET_OFFSET,
  343. PTP_PIN_TOD_SEC_MSB,
  344. PTP_PIN_TOD_SEC_LSB,
  345. PTP_PIN_TOD_NSEC,
  346. PTP_CFG_MISC,
  347. PTP_CLK_CFG_ADJ_CFG,
  348. PTP_CLK_CFG_ADJ_FREQ,
  349. };
  350. enum ocelot_regfield {
  351. ANA_ADVLEARN_VLAN_CHK,
  352. ANA_ADVLEARN_LEARN_MIRROR,
  353. ANA_ANEVENTS_FLOOD_DISCARD,
  354. ANA_ANEVENTS_MSTI_DROP,
  355. ANA_ANEVENTS_ACLKILL,
  356. ANA_ANEVENTS_ACLUSED,
  357. ANA_ANEVENTS_AUTOAGE,
  358. ANA_ANEVENTS_VS2TTL1,
  359. ANA_ANEVENTS_STORM_DROP,
  360. ANA_ANEVENTS_LEARN_DROP,
  361. ANA_ANEVENTS_AGED_ENTRY,
  362. ANA_ANEVENTS_CPU_LEARN_FAILED,
  363. ANA_ANEVENTS_AUTO_LEARN_FAILED,
  364. ANA_ANEVENTS_LEARN_REMOVE,
  365. ANA_ANEVENTS_AUTO_LEARNED,
  366. ANA_ANEVENTS_AUTO_MOVED,
  367. ANA_ANEVENTS_DROPPED,
  368. ANA_ANEVENTS_CLASSIFIED_DROP,
  369. ANA_ANEVENTS_CLASSIFIED_COPY,
  370. ANA_ANEVENTS_VLAN_DISCARD,
  371. ANA_ANEVENTS_FWD_DISCARD,
  372. ANA_ANEVENTS_MULTICAST_FLOOD,
  373. ANA_ANEVENTS_UNICAST_FLOOD,
  374. ANA_ANEVENTS_DEST_KNOWN,
  375. ANA_ANEVENTS_BUCKET3_MATCH,
  376. ANA_ANEVENTS_BUCKET2_MATCH,
  377. ANA_ANEVENTS_BUCKET1_MATCH,
  378. ANA_ANEVENTS_BUCKET0_MATCH,
  379. ANA_ANEVENTS_CPU_OPERATION,
  380. ANA_ANEVENTS_DMAC_LOOKUP,
  381. ANA_ANEVENTS_SMAC_LOOKUP,
  382. ANA_ANEVENTS_SEQ_GEN_ERR_0,
  383. ANA_ANEVENTS_SEQ_GEN_ERR_1,
  384. ANA_TABLES_MACACCESS_B_DOM,
  385. ANA_TABLES_MACTINDX_BUCKET,
  386. ANA_TABLES_MACTINDX_M_INDEX,
  387. QSYS_TIMED_FRAME_ENTRY_TFRM_VLD,
  388. QSYS_TIMED_FRAME_ENTRY_TFRM_FP,
  389. QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO,
  390. QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL,
  391. QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T,
  392. SYS_RESET_CFG_CORE_ENA,
  393. SYS_RESET_CFG_MEM_ENA,
  394. SYS_RESET_CFG_MEM_INIT,
  395. REGFIELD_MAX
  396. };
  397. enum ocelot_clk_pins {
  398. ALT_PPS_PIN = 1,
  399. EXT_CLK_PIN,
  400. ALT_LDST_PIN,
  401. TOD_ACC_PIN
  402. };
  403. struct ocelot_multicast {
  404. struct list_head list;
  405. unsigned char addr[ETH_ALEN];
  406. u16 vid;
  407. u16 ports;
  408. };
  409. struct ocelot_port;
  410. struct ocelot_stat_layout {
  411. u32 offset;
  412. char name[ETH_GSTRING_LEN];
  413. };
  414. struct ocelot {
  415. struct device *dev;
  416. struct regmap *targets[TARGET_MAX];
  417. struct regmap_field *regfields[REGFIELD_MAX];
  418. const u32 *const *map;
  419. const struct ocelot_stat_layout *stats_layout;
  420. unsigned int num_stats;
  421. u8 base_mac[ETH_ALEN];
  422. struct net_device *hw_bridge_dev;
  423. u16 bridge_mask;
  424. u16 bridge_fwd_mask;
  425. struct workqueue_struct *ocelot_owq;
  426. int shared_queue_sz;
  427. u8 num_phys_ports;
  428. u8 num_cpu_ports;
  429. struct ocelot_port **ports;
  430. u32 *lags;
  431. /* Keep track of the vlan port masks */
  432. u32 vlan_mask[VLAN_N_VID];
  433. struct list_head multicast;
  434. /* Workqueue to check statistics for overflow with its lock */
  435. struct mutex stats_lock;
  436. u64 *stats;
  437. struct delayed_work stats_work;
  438. struct workqueue_struct *stats_queue;
  439. u8 ptp:1;
  440. struct ptp_clock *ptp_clock;
  441. struct ptp_clock_info ptp_info;
  442. struct hwtstamp_config hwtstamp_config;
  443. struct mutex ptp_lock; /* Protects the PTP interface state */
  444. spinlock_t ptp_clock_lock; /* Protects the PTP clock */
  445. };
  446. struct ocelot_port {
  447. struct net_device *dev;
  448. struct ocelot *ocelot;
  449. struct phy_device *phy;
  450. void __iomem *regs;
  451. u8 chip_port;
  452. /* Ingress default VLAN (pvid) */
  453. u16 pvid;
  454. /* Egress default VLAN (vid) */
  455. u16 vid;
  456. u8 vlan_aware;
  457. u64 *stats;
  458. phy_interface_t phy_mode;
  459. struct phy *serdes;
  460. struct ocelot_port_tc tc;
  461. u8 ptp_cmd;
  462. struct list_head skbs;
  463. u8 ts_id;
  464. };
  465. struct ocelot_skb {
  466. struct list_head head;
  467. struct sk_buff *skb;
  468. u8 id;
  469. };
  470. u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset);
  471. #define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  472. #define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi))
  473. #define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri))
  474. #define ocelot_read(ocelot, reg) __ocelot_read_ix(ocelot, reg, 0)
  475. void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset);
  476. #define ocelot_write_ix(ocelot, val, reg, gi, ri) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  477. #define ocelot_write_gix(ocelot, val, reg, gi) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi))
  478. #define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri))
  479. #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0)
  480. void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg,
  481. u32 offset);
  482. #define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
  483. #define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi))
  484. #define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri))
  485. #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0)
  486. u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
  487. void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
  488. int ocelot_regfields_init(struct ocelot *ocelot,
  489. const struct reg_field *const regfields);
  490. struct regmap *ocelot_io_platform_init(struct ocelot *ocelot,
  491. struct platform_device *pdev,
  492. const char *name);
  493. #define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))
  494. #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))
  495. int ocelot_init(struct ocelot *ocelot);
  496. void ocelot_deinit(struct ocelot *ocelot);
  497. int ocelot_chip_init(struct ocelot *ocelot);
  498. int ocelot_probe_port(struct ocelot *ocelot, u8 port,
  499. void __iomem *regs,
  500. struct phy_device *phy);
  501. extern struct notifier_block ocelot_netdevice_nb;
  502. extern struct notifier_block ocelot_switchdev_nb;
  503. extern struct notifier_block ocelot_switchdev_blocking_nb;
  504. int ocelot_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts);
  505. void ocelot_get_hwtimestamp(struct ocelot *ocelot, struct timespec64 *ts);
  506. #endif