2 * Realtek RTL8366 SMI interface driver defines
4 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
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.
11 #ifndef _RTL8366_SMI_H
12 #define _RTL8366_SMI_H
14 #include <linux/phy.h>
15 #include <linux/switch.h>
17 struct rtl8366_smi_ops
;
18 struct rtl8366_vlan_ops
;
24 struct rtl8366_mib_counter
{
32 struct device
*parent
;
33 unsigned int gpio_sda
;
34 unsigned int gpio_sck
;
36 struct mii_bus
*mii_bus
;
37 int mii_irq
[PHY_MAX_ADDR
];
38 struct switch_dev sw_dev
;
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
;
46 struct rtl8366_smi_ops
*ops
;
52 #ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
53 struct dentry
*debugfs_root
;
59 struct rtl8366_vlan_mc
{
67 struct rtl8366_vlan_4k
{
74 struct rtl8366_smi_ops
{
75 int (*detect
)(struct rtl8366_smi
*smi
);
76 int (*setup
)(struct rtl8366_smi
*smi
);
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
);
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
);
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
);
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
);
110 #ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
111 int rtl8366_debugfs_open(struct inode
*inode
, struct file
*file
);
114 static inline struct rtl8366_smi
*sw_to_rtl8366_smi(struct switch_dev
*sw
)
116 return container_of(sw
, struct rtl8366_smi
, sw_dev
);
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
);
142 #endif /* _RTL8366_SMI_H */
This page took 0.071882 seconds and 5 git commands to generate.