1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2009-2016 Cavium, Inc.
6 enum cavium_mdiobus_mode
{
13 #define SMI_WR_DAT 0x8
14 #define SMI_RD_DAT 0x10
18 #ifdef __BIG_ENDIAN_BITFIELD
19 #define OCT_MDIO_BITFIELD_FIELD(field, more) \
24 #define OCT_MDIO_BITFIELD_FIELD(field, more) \
32 struct cvmx_smix_clk_s
{
33 OCT_MDIO_BITFIELD_FIELD(u64 reserved_25_63
:39,
34 OCT_MDIO_BITFIELD_FIELD(u64 mode
:1,
35 OCT_MDIO_BITFIELD_FIELD(u64 reserved_21_23
:3,
36 OCT_MDIO_BITFIELD_FIELD(u64 sample_hi
:5,
37 OCT_MDIO_BITFIELD_FIELD(u64 sample_mode
:1,
38 OCT_MDIO_BITFIELD_FIELD(u64 reserved_14_14
:1,
39 OCT_MDIO_BITFIELD_FIELD(u64 clk_idle
:1,
40 OCT_MDIO_BITFIELD_FIELD(u64 preamble
:1,
41 OCT_MDIO_BITFIELD_FIELD(u64 sample
:4,
42 OCT_MDIO_BITFIELD_FIELD(u64 phase
:8,
49 struct cvmx_smix_cmd_s
{
50 OCT_MDIO_BITFIELD_FIELD(u64 reserved_18_63
:46,
51 OCT_MDIO_BITFIELD_FIELD(u64 phy_op
:2,
52 OCT_MDIO_BITFIELD_FIELD(u64 reserved_13_15
:3,
53 OCT_MDIO_BITFIELD_FIELD(u64 phy_adr
:5,
54 OCT_MDIO_BITFIELD_FIELD(u64 reserved_5_7
:3,
55 OCT_MDIO_BITFIELD_FIELD(u64 reg_adr
:5,
62 struct cvmx_smix_en_s
{
63 OCT_MDIO_BITFIELD_FIELD(u64 reserved_1_63
:63,
64 OCT_MDIO_BITFIELD_FIELD(u64 en
:1,
69 union cvmx_smix_rd_dat
{
71 struct cvmx_smix_rd_dat_s
{
72 OCT_MDIO_BITFIELD_FIELD(u64 reserved_18_63
:46,
73 OCT_MDIO_BITFIELD_FIELD(u64 pending
:1,
74 OCT_MDIO_BITFIELD_FIELD(u64 val
:1,
75 OCT_MDIO_BITFIELD_FIELD(u64 dat
:16,
80 union cvmx_smix_wr_dat
{
82 struct cvmx_smix_wr_dat_s
{
83 OCT_MDIO_BITFIELD_FIELD(u64 reserved_18_63
:46,
84 OCT_MDIO_BITFIELD_FIELD(u64 pending
:1,
85 OCT_MDIO_BITFIELD_FIELD(u64 val
:1,
86 OCT_MDIO_BITFIELD_FIELD(u64 dat
:16,
91 struct cavium_mdiobus
{
92 struct mii_bus
*mii_bus
;
94 enum cavium_mdiobus_mode mode
;
97 #ifdef CONFIG_CAVIUM_OCTEON_SOC
99 #include <asm/octeon/octeon.h>
101 static inline void oct_mdio_writeq(u64 val
, u64 addr
)
103 cvmx_write_csr(addr
, val
);
106 static inline u64
oct_mdio_readq(u64 addr
)
108 return cvmx_read_csr(addr
);
111 #include <linux/io-64-nonatomic-lo-hi.h>
113 #define oct_mdio_writeq(val, addr) writeq(val, (void *)addr)
114 #define oct_mdio_readq(addr) readq((void *)addr)
117 int cavium_mdiobus_read(struct mii_bus
*bus
, int phy_id
, int regnum
);
118 int cavium_mdiobus_write(struct mii_bus
*bus
, int phy_id
, int regnum
, u16 val
);