treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / phy / mdio-cavium.h
blobe33d3ea9a907790c9fd28b9654805b536f5c5cdf
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 2009-2016 Cavium, Inc.
4 */
6 enum cavium_mdiobus_mode {
7 UNINIT = 0,
8 C22,
9 C45
12 #define SMI_CMD 0x0
13 #define SMI_WR_DAT 0x8
14 #define SMI_RD_DAT 0x10
15 #define SMI_CLK 0x18
16 #define SMI_EN 0x20
18 #ifdef __BIG_ENDIAN_BITFIELD
19 #define OCT_MDIO_BITFIELD_FIELD(field, more) \
20 field; \
21 more
23 #else
24 #define OCT_MDIO_BITFIELD_FIELD(field, more) \
25 more \
26 field;
28 #endif
30 union cvmx_smix_clk {
31 u64 u64;
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,
43 ;))))))))))
44 } s;
47 union cvmx_smix_cmd {
48 u64 u64;
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,
56 ;))))))
57 } s;
60 union cvmx_smix_en {
61 u64 u64;
62 struct cvmx_smix_en_s {
63 OCT_MDIO_BITFIELD_FIELD(u64 reserved_1_63:63,
64 OCT_MDIO_BITFIELD_FIELD(u64 en:1,
65 ;))
66 } s;
69 union cvmx_smix_rd_dat {
70 u64 u64;
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,
76 ;))))
77 } s;
80 union cvmx_smix_wr_dat {
81 u64 u64;
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,
87 ;))))
88 } s;
91 struct cavium_mdiobus {
92 struct mii_bus *mii_bus;
93 u64 register_base;
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);
110 #else
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)
115 #endif
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);