OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 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 | #include <linux/platform_device.h> |
||
17 | |||
18 | struct rtl8366_smi_ops; |
||
19 | struct rtl8366_vlan_ops; |
||
20 | struct mii_bus; |
||
21 | struct dentry; |
||
22 | struct inode; |
||
23 | struct file; |
||
24 | |||
25 | struct rtl8366_mib_counter { |
||
26 | unsigned base; |
||
27 | unsigned offset; |
||
28 | unsigned length; |
||
29 | const char *name; |
||
30 | }; |
||
31 | |||
32 | struct rtl8366_smi { |
||
33 | struct device *parent; |
||
34 | unsigned int gpio_sda; |
||
35 | unsigned int gpio_sck; |
||
3 | office | 36 | void (*hw_reset)(bool active); |
1 | office | 37 | unsigned int clk_delay; /* ns */ |
38 | u8 cmd_read; |
||
39 | u8 cmd_write; |
||
40 | spinlock_t lock; |
||
41 | struct mii_bus *mii_bus; |
||
42 | int mii_irq[PHY_MAX_ADDR]; |
||
43 | struct switch_dev sw_dev; |
||
44 | |||
45 | unsigned int cpu_port; |
||
46 | unsigned int num_ports; |
||
47 | unsigned int num_vlan_mc; |
||
48 | unsigned int num_mib_counters; |
||
49 | struct rtl8366_mib_counter *mib_counters; |
||
50 | |||
51 | struct rtl8366_smi_ops *ops; |
||
52 | |||
53 | int vlan_enabled; |
||
54 | int vlan4k_enabled; |
||
55 | |||
56 | char buf[4096]; |
||
57 | #ifdef CONFIG_RTL8366_SMI_DEBUG_FS |
||
58 | struct dentry *debugfs_root; |
||
59 | u16 dbg_reg; |
||
60 | u8 dbg_vlan_4k_page; |
||
61 | #endif |
||
62 | }; |
||
63 | |||
64 | struct rtl8366_vlan_mc { |
||
65 | u16 vid; |
||
66 | u16 untag; |
||
67 | u16 member; |
||
68 | u8 fid; |
||
69 | u8 priority; |
||
70 | }; |
||
71 | |||
72 | struct rtl8366_vlan_4k { |
||
73 | u16 vid; |
||
74 | u16 untag; |
||
75 | u16 member; |
||
76 | u8 fid; |
||
77 | }; |
||
78 | |||
79 | struct rtl8366_smi_ops { |
||
80 | int (*detect)(struct rtl8366_smi *smi); |
||
81 | int (*reset_chip)(struct rtl8366_smi *smi); |
||
82 | int (*setup)(struct rtl8366_smi *smi); |
||
83 | |||
84 | int (*mii_read)(struct mii_bus *bus, int addr, int reg); |
||
85 | int (*mii_write)(struct mii_bus *bus, int addr, int reg, u16 val); |
||
86 | |||
87 | int (*get_vlan_mc)(struct rtl8366_smi *smi, u32 index, |
||
88 | struct rtl8366_vlan_mc *vlanmc); |
||
89 | int (*set_vlan_mc)(struct rtl8366_smi *smi, u32 index, |
||
90 | const struct rtl8366_vlan_mc *vlanmc); |
||
91 | int (*get_vlan_4k)(struct rtl8366_smi *smi, u32 vid, |
||
92 | struct rtl8366_vlan_4k *vlan4k); |
||
93 | int (*set_vlan_4k)(struct rtl8366_smi *smi, |
||
94 | const struct rtl8366_vlan_4k *vlan4k); |
||
95 | int (*get_mc_index)(struct rtl8366_smi *smi, int port, int *val); |
||
96 | int (*set_mc_index)(struct rtl8366_smi *smi, int port, int index); |
||
97 | int (*get_mib_counter)(struct rtl8366_smi *smi, int counter, |
||
98 | int port, unsigned long long *val); |
||
99 | int (*is_vlan_valid)(struct rtl8366_smi *smi, unsigned vlan); |
||
100 | int (*enable_vlan)(struct rtl8366_smi *smi, int enable); |
||
101 | int (*enable_vlan4k)(struct rtl8366_smi *smi, int enable); |
||
102 | int (*enable_port)(struct rtl8366_smi *smi, int port, int enable); |
||
103 | }; |
||
104 | |||
105 | struct rtl8366_smi *rtl8366_smi_alloc(struct device *parent); |
||
106 | int rtl8366_smi_init(struct rtl8366_smi *smi); |
||
107 | void rtl8366_smi_cleanup(struct rtl8366_smi *smi); |
||
108 | int rtl8366_smi_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data); |
||
109 | int rtl8366_smi_write_reg_noack(struct rtl8366_smi *smi, u32 addr, u32 data); |
||
110 | int rtl8366_smi_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data); |
||
111 | int rtl8366_smi_rmwr(struct rtl8366_smi *smi, u32 addr, u32 mask, u32 data); |
||
112 | |||
113 | int rtl8366_reset_vlan(struct rtl8366_smi *smi); |
||
114 | int rtl8366_enable_vlan(struct rtl8366_smi *smi, int enable); |
||
115 | int rtl8366_enable_all_ports(struct rtl8366_smi *smi, int enable); |
||
116 | |||
117 | #ifdef CONFIG_RTL8366_SMI_DEBUG_FS |
||
118 | int rtl8366_debugfs_open(struct inode *inode, struct file *file); |
||
119 | #endif |
||
120 | |||
121 | static inline struct rtl8366_smi *sw_to_rtl8366_smi(struct switch_dev *sw) |
||
122 | { |
||
123 | return container_of(sw, struct rtl8366_smi, sw_dev); |
||
124 | } |
||
125 | |||
126 | int rtl8366_sw_reset_switch(struct switch_dev *dev); |
||
127 | int rtl8366_sw_get_port_pvid(struct switch_dev *dev, int port, int *val); |
||
128 | int rtl8366_sw_set_port_pvid(struct switch_dev *dev, int port, int val); |
||
129 | int rtl8366_sw_get_port_mib(struct switch_dev *dev, |
||
130 | const struct switch_attr *attr, |
||
131 | struct switch_val *val); |
||
132 | int rtl8366_sw_get_vlan_info(struct switch_dev *dev, |
||
133 | const struct switch_attr *attr, |
||
134 | struct switch_val *val); |
||
135 | int rtl8366_sw_get_vlan_fid(struct switch_dev *dev, |
||
136 | const struct switch_attr *attr, |
||
137 | struct switch_val *val); |
||
138 | int rtl8366_sw_set_vlan_fid(struct switch_dev *dev, |
||
139 | const struct switch_attr *attr, |
||
140 | struct switch_val *val); |
||
141 | int rtl8366_sw_get_vlan_ports(struct switch_dev *dev, struct switch_val *val); |
||
142 | int rtl8366_sw_set_vlan_ports(struct switch_dev *dev, struct switch_val *val); |
||
143 | int rtl8366_sw_get_vlan_enable(struct switch_dev *dev, |
||
144 | const struct switch_attr *attr, |
||
145 | struct switch_val *val); |
||
146 | int rtl8366_sw_set_vlan_enable(struct switch_dev *dev, |
||
147 | const struct switch_attr *attr, |
||
148 | struct switch_val *val); |
||
149 | int rtl8366_sw_get_port_stats(struct switch_dev *dev, int port, |
||
150 | struct switch_port_stats *stats, |
||
151 | int txb_id, int rxb_id); |
||
152 | |||
153 | struct rtl8366_smi* rtl8366_smi_probe(struct platform_device *pdev); |
||
154 | |||
155 | #endif /* _RTL8366_SMI_H */ |