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>
16 struct rtl8366_smi_ops;
17 struct rtl8366_vlan_ops;
23 struct rtl8366_mib_counter {
31 struct device *parent;
32 unsigned int gpio_sda;
33 unsigned int gpio_sck;
35 struct mii_bus *mii_bus;
36 int mii_irq[PHY_MAX_ADDR];
38 unsigned int cpu_port;
39 unsigned int num_ports;
40 unsigned int num_vlan_mc;
42 struct rtl8366_smi_ops *ops;
45 #ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
46 struct dentry *debugfs_root;
51 struct rtl8366_vlan_mc {
59 struct rtl8366_vlan_4k {
66 struct rtl8366_smi_ops {
67 int (*detect)(struct rtl8366_smi *smi);
69 int (*mii_read)(struct mii_bus *bus, int addr, int reg);
70 int (*mii_write)(struct mii_bus *bus, int addr, int reg, u16 val);
72 int (*get_vlan_mc)(struct rtl8366_smi *smi, u32 index,
73 struct rtl8366_vlan_mc *vlanmc);
74 int (*set_vlan_mc)(struct rtl8366_smi *smi, u32 index,
75 const struct rtl8366_vlan_mc *vlanmc);
76 int (*get_vlan_4k)(struct rtl8366_smi *smi, u32 vid,
77 struct rtl8366_vlan_4k *vlan4k);
78 int (*set_vlan_4k)(struct rtl8366_smi *smi,
79 const struct rtl8366_vlan_4k *vlan4k);
80 int (*get_mc_index)(struct rtl8366_smi *smi, int port, int *val);
81 int (*set_mc_index)(struct rtl8366_smi *smi, int port, int index);
84 int rtl8366_smi_init(struct rtl8366_smi *smi);
85 void rtl8366_smi_cleanup(struct rtl8366_smi *smi);
86 int rtl8366_smi_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data);
87 int rtl8366_smi_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data);
88 int rtl8366_smi_rmwr(struct rtl8366_smi *smi, u32 addr, u32 mask, u32 data);
90 int rtl8366_set_vlan(struct rtl8366_smi *smi, int vid, u32 member, u32 untag,
92 int rtl8366_reset_vlan(struct rtl8366_smi *smi);
93 int rtl8366_get_pvid(struct rtl8366_smi *smi, int port, int *val);
94 int rtl8366_set_pvid(struct rtl8366_smi *smi, unsigned port, unsigned vid);
96 #ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
97 int rtl8366_debugfs_open(struct inode *inode, struct file *file);
100 #endif /* _RTL8366_SMI_H */