2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2009-2016 Cavium, Inc.
9 enum cavium_mdiobus_mode
{
16 #define SMI_WR_DAT 0x8
17 #define SMI_RD_DAT 0x10
21 #ifdef __BIG_ENDIAN_BITFIELD
22 #define OCT_MDIO_BITFIELD_FIELD(field, more) \
27 #define OCT_MDIO_BITFIELD_FIELD(field, more) \
35 struct cvmx_smix_clk_s
{
36 OCT_MDIO_BITFIELD_FIELD(u64 reserved_25_63
:39,
37 OCT_MDIO_BITFIELD_FIELD(u64 mode
:1,
38 OCT_MDIO_BITFIELD_FIELD(u64 reserved_21_23
:3,
39 OCT_MDIO_BITFIELD_FIELD(u64 sample_hi
:5,
40 OCT_MDIO_BITFIELD_FIELD(u64 sample_mode
:1,
41 OCT_MDIO_BITFIELD_FIELD(u64 reserved_14_14
:1,
42 OCT_MDIO_BITFIELD_FIELD(u64 clk_idle
:1,
43 OCT_MDIO_BITFIELD_FIELD(u64 preamble
:1,
44 OCT_MDIO_BITFIELD_FIELD(u64 sample
:4,
45 OCT_MDIO_BITFIELD_FIELD(u64 phase
:8,
52 struct cvmx_smix_cmd_s
{
53 OCT_MDIO_BITFIELD_FIELD(u64 reserved_18_63
:46,
54 OCT_MDIO_BITFIELD_FIELD(u64 phy_op
:2,
55 OCT_MDIO_BITFIELD_FIELD(u64 reserved_13_15
:3,
56 OCT_MDIO_BITFIELD_FIELD(u64 phy_adr
:5,
57 OCT_MDIO_BITFIELD_FIELD(u64 reserved_5_7
:3,
58 OCT_MDIO_BITFIELD_FIELD(u64 reg_adr
:5,
65 struct cvmx_smix_en_s
{
66 OCT_MDIO_BITFIELD_FIELD(u64 reserved_1_63
:63,
67 OCT_MDIO_BITFIELD_FIELD(u64 en
:1,
72 union cvmx_smix_rd_dat
{
74 struct cvmx_smix_rd_dat_s
{
75 OCT_MDIO_BITFIELD_FIELD(u64 reserved_18_63
:46,
76 OCT_MDIO_BITFIELD_FIELD(u64 pending
:1,
77 OCT_MDIO_BITFIELD_FIELD(u64 val
:1,
78 OCT_MDIO_BITFIELD_FIELD(u64 dat
:16,
83 union cvmx_smix_wr_dat
{
85 struct cvmx_smix_wr_dat_s
{
86 OCT_MDIO_BITFIELD_FIELD(u64 reserved_18_63
:46,
87 OCT_MDIO_BITFIELD_FIELD(u64 pending
:1,
88 OCT_MDIO_BITFIELD_FIELD(u64 val
:1,
89 OCT_MDIO_BITFIELD_FIELD(u64 dat
:16,
94 struct cavium_mdiobus
{
95 struct mii_bus
*mii_bus
;
97 enum cavium_mdiobus_mode mode
;
100 #ifdef CONFIG_CAVIUM_OCTEON_SOC
102 #include <asm/octeon/octeon.h>
104 static inline void oct_mdio_writeq(u64 val
, u64 addr
)
106 cvmx_write_csr(addr
, val
);
109 static inline u64
oct_mdio_readq(u64 addr
)
111 return cvmx_read_csr(addr
);
114 #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr)
115 #define oct_mdio_readq(addr) readq((void *)addr)
118 int cavium_mdiobus_read(struct mii_bus
*bus
, int phy_id
, int regnum
);
119 int cavium_mdiobus_write(struct mii_bus
*bus
, int phy_id
, int regnum
, u16 val
);