kernel: ar8216: move port vlan setup into a separate function
[openwrt.git] / target / linux / generic / files / drivers / net / phy / rtl8366_smi.h
1 /*
2 * Realtek RTL8366 SMI interface driver defines
3 *
4 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11 #ifndef _RTL8366_SMI_H
12 #define _RTL8366_SMI_H
13
14 #include <linux/phy.h>
15 #include <linux/switch.h>
16
17 struct rtl8366_smi_ops;
18 struct rtl8366_vlan_ops;
19 struct mii_bus;
20 struct dentry;
21 struct inode;
22 struct file;
23
24 struct rtl8366_mib_counter {
25 unsigned base;
26 unsigned offset;
27 unsigned length;
28 const char *name;
29 };
30
31 struct rtl8366_smi {
32 struct device *parent;
33 unsigned int gpio_sda;
34 unsigned int gpio_sck;
35 spinlock_t lock;
36 struct mii_bus *mii_bus;
37 int mii_irq[PHY_MAX_ADDR];
38 struct switch_dev sw_dev;
39
40 unsigned int cpu_port;
41 unsigned int num_ports;
42 unsigned int num_vlan_mc;
43 unsigned int num_mib_counters;
44 struct rtl8366_mib_counter *mib_counters;
45
46 struct rtl8366_smi_ops *ops;
47
48 int vlan_enabled;
49 int vlan4k_enabled;
50
51 char buf[4096];
52 #ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
53 struct dentry *debugfs_root;
54 u16 dbg_reg;
55 u8 dbg_vlan_4k_page;
56 #endif
57 };
58
59 struct rtl8366_vlan_mc {
60 u16 vid;
61 u8 priority;
62 u8 untag;
63 u8 member;
64 u8 fid;
65 };
66
67 struct rtl8366_vlan_4k {
68 u16 vid;
69 u8 untag;
70 u8 member;
71 u8 fid;
72 };
73
74 struct rtl8366_smi_ops {
75 int (*detect)(struct rtl8366_smi *smi);
76 int (*setup)(struct rtl8366_smi *smi);
77
78 int (*mii_read)(struct mii_bus *bus, int addr, int reg);
79 int (*mii_write)(struct mii_bus *bus, int addr, int reg, u16 val);
80
81 int (*get_vlan_mc)(struct rtl8366_smi *smi, u32 index,
82 struct rtl8366_vlan_mc *vlanmc);
83 int (*set_vlan_mc)(struct rtl8366_smi *smi, u32 index,
84 const struct rtl8366_vlan_mc *vlanmc);
85 int (*get_vlan_4k)(struct rtl8366_smi *smi, u32 vid,
86 struct rtl8366_vlan_4k *vlan4k);
87 int (*set_vlan_4k)(struct rtl8366_smi *smi,
88 const struct rtl8366_vlan_4k *vlan4k);
89 int (*get_mc_index)(struct rtl8366_smi *smi, int port, int *val);
90 int (*set_mc_index)(struct rtl8366_smi *smi, int port, int index);
91 int (*get_mib_counter)(struct rtl8366_smi *smi, int counter,
92 int port, unsigned long long *val);
93 int (*is_vlan_valid)(struct rtl8366_smi *smi, unsigned vlan);
94 int (*enable_vlan)(struct rtl8366_smi *smi, int enable);
95 int (*enable_vlan4k)(struct rtl8366_smi *smi, int enable);
96 int (*enable_port)(struct rtl8366_smi *smi, int port, int enable);
97 };
98
99 struct rtl8366_smi *rtl8366_smi_alloc(struct device *parent);
100 int rtl8366_smi_init(struct rtl8366_smi *smi);
101 void rtl8366_smi_cleanup(struct rtl8366_smi *smi);
102 int rtl8366_smi_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data);
103 int rtl8366_smi_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data);
104 int rtl8366_smi_rmwr(struct rtl8366_smi *smi, u32 addr, u32 mask, u32 data);
105
106 int rtl8366_reset_vlan(struct rtl8366_smi *smi);
107 int rtl8366_enable_vlan(struct rtl8366_smi *smi, int enable);
108 int rtl8366_enable_all_ports(struct rtl8366_smi *smi, int enable);
109
110 #ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
111 int rtl8366_debugfs_open(struct inode *inode, struct file *file);
112 #endif
113
114 static inline struct rtl8366_smi *sw_to_rtl8366_smi(struct switch_dev *sw)
115 {
116 return container_of(sw, struct rtl8366_smi, sw_dev);
117 }
118
119 int rtl8366_sw_get_port_pvid(struct switch_dev *dev, int port, int *val);
120 int rtl8366_sw_set_port_pvid(struct switch_dev *dev, int port, int val);
121 int rtl8366_sw_get_port_mib(struct switch_dev *dev,
122 const struct switch_attr *attr,
123 struct switch_val *val);
124 int rtl8366_sw_get_vlan_info(struct switch_dev *dev,
125 const struct switch_attr *attr,
126 struct switch_val *val);
127 int rtl8366_sw_get_vlan_fid(struct switch_dev *dev,
128 const struct switch_attr *attr,
129 struct switch_val *val);
130 int rtl8366_sw_set_vlan_fid(struct switch_dev *dev,
131 const struct switch_attr *attr,
132 struct switch_val *val);
133 int rtl8366_sw_get_vlan_ports(struct switch_dev *dev, struct switch_val *val);
134 int rtl8366_sw_set_vlan_ports(struct switch_dev *dev, struct switch_val *val);
135 int rtl8366_sw_get_vlan_enable(struct switch_dev *dev,
136 const struct switch_attr *attr,
137 struct switch_val *val);
138 int rtl8366_sw_set_vlan_enable(struct switch_dev *dev,
139 const struct switch_attr *attr,
140 struct switch_val *val);
141
142 #endif /* _RTL8366_SMI_H */
This page took 0.052488 seconds and 5 git commands to generate.