diff options
Diffstat (limited to 'net/dsa/mv88e6xxx.h')
-rw-r--r-- | net/dsa/mv88e6xxx.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/net/dsa/mv88e6xxx.h b/net/dsa/mv88e6xxx.h new file mode 100644 index 000000000000..a004d4d02081 --- /dev/null +++ b/net/dsa/mv88e6xxx.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * net/dsa/mv88e6xxx.h - Marvell 88e6xxx switch chip support | ||
3 | * Copyright (c) 2008 Marvell Semiconductor | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #ifndef __MV88E6XXX_H | ||
12 | #define __MV88E6XXX_H | ||
13 | |||
14 | #define REG_PORT(p) (0x10 + (p)) | ||
15 | #define REG_GLOBAL 0x1b | ||
16 | #define REG_GLOBAL2 0x1c | ||
17 | |||
18 | struct mv88e6xxx_priv_state { | ||
19 | /* | ||
20 | * When using multi-chip addressing, this mutex protects | ||
21 | * access to the indirect access registers. (In single-chip | ||
22 | * mode, this mutex is effectively useless.) | ||
23 | */ | ||
24 | struct mutex smi_mutex; | ||
25 | |||
26 | /* | ||
27 | * This mutex serialises access to the statistics unit. | ||
28 | * Hold this mutex over snapshot + dump sequences. | ||
29 | */ | ||
30 | struct mutex stats_mutex; | ||
31 | }; | ||
32 | |||
33 | struct mv88e6xxx_hw_stat { | ||
34 | char string[ETH_GSTRING_LEN]; | ||
35 | int sizeof_stat; | ||
36 | int reg; | ||
37 | }; | ||
38 | |||
39 | int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg); | ||
40 | int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg); | ||
41 | int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr, | ||
42 | int reg, u16 val); | ||
43 | int mv88e6xxx_reg_write(struct dsa_switch *ds, int addr, int reg, u16 val); | ||
44 | int mv88e6xxx_config_prio(struct dsa_switch *ds); | ||
45 | int mv88e6xxx_set_addr_indirect(struct dsa_switch *ds, u8 *addr); | ||
46 | int mv88e6xxx_phy_read(struct dsa_switch *ds, int addr, int regnum); | ||
47 | int mv88e6xxx_phy_write(struct dsa_switch *ds, int addr, int regnum, u16 val); | ||
48 | void mv88e6xxx_poll_link(struct dsa_switch *ds); | ||
49 | void mv88e6xxx_get_strings(struct dsa_switch *ds, | ||
50 | int nr_stats, struct mv88e6xxx_hw_stat *stats, | ||
51 | int port, uint8_t *data); | ||
52 | void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, | ||
53 | int nr_stats, struct mv88e6xxx_hw_stat *stats, | ||
54 | int port, uint64_t *data); | ||
55 | |||
56 | #define REG_READ(addr, reg) \ | ||
57 | ({ \ | ||
58 | int __ret; \ | ||
59 | \ | ||
60 | __ret = mv88e6xxx_reg_read(ds, addr, reg); \ | ||
61 | if (__ret < 0) \ | ||
62 | return __ret; \ | ||
63 | __ret; \ | ||
64 | }) | ||
65 | |||
66 | #define REG_WRITE(addr, reg, val) \ | ||
67 | ({ \ | ||
68 | int __ret; \ | ||
69 | \ | ||
70 | __ret = mv88e6xxx_reg_write(ds, addr, reg, val); \ | ||
71 | if (__ret < 0) \ | ||
72 | return __ret; \ | ||
73 | }) | ||
74 | |||
75 | |||
76 | |||
77 | #endif | ||