1 /*
2  * Marvell 88E6xxx Switch Global 2 Registers support (device address 0x1C)
3  *
4  * Copyright (c) 2008 Marvell Semiconductor
5  *
6  * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
7  *	Vivien Didelot <vivien.didelot@savoirfairelinux.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  */
14 
15 #ifndef _MV88E6XXX_GLOBAL2_H
16 #define _MV88E6XXX_GLOBAL2_H
17 
18 #include "mv88e6xxx.h"
19 
20 #ifdef CONFIG_NET_DSA_MV88E6XXX_GLOBAL2
21 
22 static inline int mv88e6xxx_g2_require(struct mv88e6xxx_chip *chip)
23 {
24 	return 0;
25 }
26 
27 int mv88e6xxx_g2_smi_phy_read(struct mv88e6xxx_chip *chip,
28 			      struct mii_bus *bus,
29 			      int addr, int reg, u16 *val);
30 int mv88e6xxx_g2_smi_phy_write(struct mv88e6xxx_chip *chip,
31 			       struct mii_bus *bus,
32 			       int addr, int reg, u16 val);
33 int mv88e6xxx_g2_set_switch_mac(struct mv88e6xxx_chip *chip, u8 *addr);
34 
35 int mv88e6xxx_g2_get_eeprom8(struct mv88e6xxx_chip *chip,
36 			     struct ethtool_eeprom *eeprom, u8 *data);
37 int mv88e6xxx_g2_set_eeprom8(struct mv88e6xxx_chip *chip,
38 			     struct ethtool_eeprom *eeprom, u8 *data);
39 
40 int mv88e6xxx_g2_get_eeprom16(struct mv88e6xxx_chip *chip,
41 			      struct ethtool_eeprom *eeprom, u8 *data);
42 int mv88e6xxx_g2_set_eeprom16(struct mv88e6xxx_chip *chip,
43 			      struct ethtool_eeprom *eeprom, u8 *data);
44 
45 int mv88e6xxx_g2_pvt_write(struct mv88e6xxx_chip *chip, int src_dev,
46 			   int src_port, u16 data);
47 int mv88e6xxx_g2_misc_4_bit_port(struct mv88e6xxx_chip *chip);
48 
49 int mv88e6xxx_g2_setup(struct mv88e6xxx_chip *chip);
50 int mv88e6xxx_g2_irq_setup(struct mv88e6xxx_chip *chip);
51 void mv88e6xxx_g2_irq_free(struct mv88e6xxx_chip *chip);
52 int mv88e6095_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip);
53 
54 extern const struct mv88e6xxx_irq_ops mv88e6097_watchdog_ops;
55 extern const struct mv88e6xxx_irq_ops mv88e6390_watchdog_ops;
56 
57 #else /* !CONFIG_NET_DSA_MV88E6XXX_GLOBAL2 */
58 
59 static inline int mv88e6xxx_g2_require(struct mv88e6xxx_chip *chip)
60 {
61 	if (mv88e6xxx_has(chip, MV88E6XXX_FLAG_GLOBAL2)) {
62 		dev_err(chip->dev, "this chip requires CONFIG_NET_DSA_MV88E6XXX_GLOBAL2 enabled\n");
63 		return -EOPNOTSUPP;
64 	}
65 
66 	return 0;
67 }
68 
69 static inline int mv88e6xxx_g2_smi_phy_read(struct mv88e6xxx_chip *chip,
70 					    struct mii_bus *bus,
71 					    int addr, int reg, u16 *val)
72 {
73 	return -EOPNOTSUPP;
74 }
75 
76 static inline int mv88e6xxx_g2_smi_phy_write(struct mv88e6xxx_chip *chip,
77 					     struct mii_bus *bus,
78 					     int addr, int reg, u16 val)
79 {
80 	return -EOPNOTSUPP;
81 }
82 
83 static inline int mv88e6xxx_g2_set_switch_mac(struct mv88e6xxx_chip *chip,
84 					      u8 *addr)
85 {
86 	return -EOPNOTSUPP;
87 }
88 
89 static inline int mv88e6xxx_g2_get_eeprom8(struct mv88e6xxx_chip *chip,
90 					   struct ethtool_eeprom *eeprom,
91 					   u8 *data)
92 {
93 	return -EOPNOTSUPP;
94 }
95 
96 static inline int mv88e6xxx_g2_set_eeprom8(struct mv88e6xxx_chip *chip,
97 					   struct ethtool_eeprom *eeprom,
98 					   u8 *data)
99 {
100 	return -EOPNOTSUPP;
101 }
102 
103 static inline int mv88e6xxx_g2_get_eeprom16(struct mv88e6xxx_chip *chip,
104 					    struct ethtool_eeprom *eeprom,
105 					    u8 *data)
106 {
107 	return -EOPNOTSUPP;
108 }
109 
110 static inline int mv88e6xxx_g2_set_eeprom16(struct mv88e6xxx_chip *chip,
111 					    struct ethtool_eeprom *eeprom,
112 					    u8 *data)
113 {
114 	return -EOPNOTSUPP;
115 }
116 
117 int mv88e6xxx_g2_pvt_write(struct mv88e6xxx_chip *chip, int src_dev,
118 			   int src_port, u16 data)
119 {
120 	return -EOPNOTSUPP;
121 }
122 
123 int mv88e6xxx_g2_misc_4_bit_port(struct mv88e6xxx_chip *chip)
124 {
125 	return -EOPNOTSUPP;
126 }
127 
128 static inline int mv88e6xxx_g2_setup(struct mv88e6xxx_chip *chip)
129 {
130 	return -EOPNOTSUPP;
131 }
132 
133 static inline int mv88e6xxx_g2_irq_setup(struct mv88e6xxx_chip *chip)
134 {
135 	return -EOPNOTSUPP;
136 }
137 
138 static inline void mv88e6xxx_g2_irq_free(struct mv88e6xxx_chip *chip)
139 {
140 }
141 
142 static inline int mv88e6095_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip)
143 {
144 	return -EOPNOTSUPP;
145 }
146 
147 static const struct mv88e6xxx_irq_ops mv88e6097_watchdog_ops = {};
148 static const struct mv88e6xxx_irq_ops mv88e6390_watchdog_ops = {};
149 
150 #endif /* CONFIG_NET_DSA_MV88E6XXX_GLOBAL2 */
151 
152 #endif /* _MV88E6XXX_GLOBAL2_H */
153