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;
24 struct device *parent;
25 unsigned int gpio_sda;
26 unsigned int gpio_sck;
28 struct mii_bus *mii_bus;
29 int mii_irq[PHY_MAX_ADDR];
31 unsigned int cpu_port;
32 unsigned int num_ports;
33 unsigned int num_vlan_mc;
35 struct rtl8366_smi_ops *ops;
38 #ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
39 struct dentry *debugfs_root;
44 struct rtl8366_vlan_mc {
52 struct rtl8366_vlan_4k {
59 struct rtl8366_smi_ops {
60 int (*detect)(struct rtl8366_smi *smi);
62 int (*mii_read)(struct mii_bus *bus, int addr, int reg);
63 int (*mii_write)(struct mii_bus *bus, int addr, int reg, u16 val);
65 int (*get_vlan_mc)(struct rtl8366_smi *smi, u32 index,
66 struct rtl8366_vlan_mc *vlanmc);
67 int (*set_vlan_mc)(struct rtl8366_smi *smi, u32 index,
68 const struct rtl8366_vlan_mc *vlanmc);
69 int (*get_vlan_4k)(struct rtl8366_smi *smi, u32 vid,
70 struct rtl8366_vlan_4k *vlan4k);
71 int (*set_vlan_4k)(struct rtl8366_smi *smi,
72 const struct rtl8366_vlan_4k *vlan4k);
73 int (*get_mc_index)(struct rtl8366_smi *smi, int port, int *val);
74 int (*set_mc_index)(struct rtl8366_smi *smi, int port, int index);
77 int rtl8366_smi_init(struct rtl8366_smi *smi);
78 void rtl8366_smi_cleanup(struct rtl8366_smi *smi);
79 int rtl8366_smi_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data);
80 int rtl8366_smi_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data);
81 int rtl8366_smi_rmwr(struct rtl8366_smi *smi, u32 addr, u32 mask, u32 data);
83 int rtl8366_set_vlan(struct rtl8366_smi *smi, int vid, u32 member, u32 untag,
85 int rtl8366_reset_vlan(struct rtl8366_smi *smi);
86 int rtl8366_get_pvid(struct rtl8366_smi *smi, int port, int *val);
87 int rtl8366_set_pvid(struct rtl8366_smi *smi, unsigned port, unsigned vid);
89 #ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
90 int rtl8366_debugfs_open(struct inode *inode, struct file *file);
93 #endif /* _RTL8366_SMI_H */