35 #ifndef __CVMX_MIO_H__
36 #define __CVMX_MIO_H__
43 #define CVMX_MDIO_PHY_REG_CONTROL 0
65 #define CVMX_MDIO_PHY_REG_STATUS 1
92 #define CVMX_MDIO_PHY_REG_ID1 2
103 #define CVMX_MDIO_PHY_REG_ID2 3
116 #define CVMX_MDIO_PHY_REG_AUTONEG_ADVER 4
138 #define CVMX_MDIO_PHY_REG_LINK_PARTNER_ABILITY 5
160 #define CVMX_MDIO_PHY_REG_AUTONEG_EXPANSION 6
177 #define CVMX_MDIO_PHY_REG_CONTROL_1000 9
194 #define CVMX_MDIO_PHY_REG_STATUS_1000 10
212 #define CVMX_MDIO_PHY_REG_EXTENDED_STATUS 15
227 #define CVMX_MDIO_PHY_REG_MMD_CONTROL 13
240 #define CVMX_MDIO_PHY_REG_MMD_ADDRESS_DATA 14
249 #define MDIO_CLAUSE_22_WRITE 0
250 #define MDIO_CLAUSE_22_READ 1
252 #define MDIO_CLAUSE_45_ADDRESS 0
253 #define MDIO_CLAUSE_45_WRITE 1
254 #define MDIO_CLAUSE_45_READ_INC 2
255 #define MDIO_CLAUSE_45_READ 3
258 #define CVMX_MMD_DEVICE_PMA_PMD 1
259 #define CVMX_MMD_DEVICE_WIS 2
260 #define CVMX_MMD_DEVICE_PCS 3
261 #define CVMX_MMD_DEVICE_PHY_XS 4
262 #define CVMX_MMD_DEVICE_DTS_XS 5
263 #define CVMX_MMD_DEVICE_TC 6
264 #define CVMX_MMD_DEVICE_CL22_EXT 29
265 #define CVMX_MMD_DEVICE_VENDOR_1 30
266 #define CVMX_MMD_DEVICE_VENDOR_2 31
269 static inline void __cvmx_mdio_set_clause45_mode(
int bus_id)
273 smi_clk.
u64 = cvmx_read_csr(CVMX_SMIX_CLK(bus_id));
275 smi_clk.
s.preamble = 1;
276 cvmx_write_csr(CVMX_SMIX_CLK(bus_id), smi_clk.
u64);
280 static inline void __cvmx_mdio_set_clause22_mode(
int bus_id)
284 smi_clk.
u64 = cvmx_read_csr(CVMX_SMIX_CLK(bus_id));
286 cvmx_write_csr(CVMX_SMIX_CLK(bus_id), smi_clk.u64);
300 static inline int cvmx_mdio_read(
int bus_id,
int phy_id,
int location)
307 __cvmx_mdio_set_clause22_mode(bus_id);
313 cvmx_write_csr(CVMX_SMIX_CMD(bus_id),
smi_cmd.u64);
317 smi_rd.u64 = cvmx_read_csr(CVMX_SMIX_RD_DAT(bus_id));
318 }
while (smi_rd.s.pending && timeout--);
339 static inline int cvmx_mdio_write(
int bus_id,
int phy_id,
int location,
int val)
346 __cvmx_mdio_set_clause22_mode(bus_id);
350 cvmx_write_csr(CVMX_SMIX_WR_DAT(bus_id), smi_wr.u64);
356 cvmx_write_csr(CVMX_SMIX_CMD(bus_id),
smi_cmd.u64);
360 smi_wr.u64 = cvmx_read_csr(CVMX_SMIX_WR_DAT(bus_id));
361 }
while (smi_wr.s.pending && --timeout);
381 static inline int cvmx_mdio_45_read(
int bus_id,
int phy_id,
int device,
392 __cvmx_mdio_set_clause45_mode(bus_id);
396 cvmx_write_csr(CVMX_SMIX_WR_DAT(bus_id), smi_wr.u64);
402 cvmx_write_csr(CVMX_SMIX_CMD(bus_id),
smi_cmd.u64);
406 smi_wr.u64 = cvmx_read_csr(CVMX_SMIX_WR_DAT(bus_id));
407 }
while (smi_wr.s.pending && --timeout);
410 "device %2d register %2d TIME OUT(address)\n",
411 bus_id, phy_id, device, location);
419 cvmx_write_csr(CVMX_SMIX_CMD(bus_id),
smi_cmd.u64);
423 smi_rd.u64 = cvmx_read_csr(CVMX_SMIX_RD_DAT(bus_id));
424 }
while (smi_rd.s.pending && --timeout);
428 "device %2d register %2d TIME OUT(data)\n",
429 bus_id, phy_id, device, location);
437 "device %2d register %2d INVALID READ\n",
438 bus_id, phy_id, device, location);
457 static inline int cvmx_mdio_45_write(
int bus_id,
int phy_id,
int device,
458 int location,
int val)
467 __cvmx_mdio_set_clause45_mode(bus_id);
471 cvmx_write_csr(CVMX_SMIX_WR_DAT(bus_id), smi_wr.u64);
477 cvmx_write_csr(CVMX_SMIX_CMD(bus_id),
smi_cmd.u64);
481 smi_wr.u64 = cvmx_read_csr(CVMX_SMIX_WR_DAT(bus_id));
482 }
while (smi_wr.s.pending && --timeout);
488 cvmx_write_csr(CVMX_SMIX_WR_DAT(bus_id), smi_wr.u64);
494 cvmx_write_csr(CVMX_SMIX_CMD(bus_id),
smi_cmd.u64);
498 smi_wr.u64 = cvmx_read_csr(CVMX_SMIX_WR_DAT(bus_id));
499 }
while (smi_wr.s.pending && --timeout);