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