Root/target/linux/generic-2.6/files/drivers/net/phy/rtl8366_smi.h

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
16struct rtl8366_smi_ops;
17struct rtl8366_vlan_ops;
18struct mii_bus;
19struct dentry;
20struct inode;
21struct file;
22
23struct rtl8366_mib_counter {
24    unsigned base;
25    unsigned offset;
26    unsigned length;
27    const char *name;
28};
29
30struct rtl8366_smi {
31    struct device *parent;
32    unsigned int gpio_sda;
33    unsigned int gpio_sck;
34    spinlock_t lock;
35    struct mii_bus *mii_bus;
36    int mii_irq[PHY_MAX_ADDR];
37
38    unsigned int cpu_port;
39    unsigned int num_ports;
40    unsigned int num_vlan_mc;
41    unsigned int num_mib_counters;
42    struct rtl8366_mib_counter *mib_counters;
43
44    struct rtl8366_smi_ops *ops;
45
46    char buf[4096];
47#ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
48    struct dentry *debugfs_root;
49    u16 dbg_reg;
50#endif
51};
52
53struct rtl8366_vlan_mc {
54    u16 vid;
55    u8 priority;
56    u8 untag;
57    u8 member;
58    u8 fid;
59};
60
61struct rtl8366_vlan_4k {
62    u16 vid;
63    u8 untag;
64    u8 member;
65    u8 fid;
66};
67
68struct rtl8366_smi_ops {
69    int (*detect)(struct rtl8366_smi *smi);
70
71    int (*mii_read)(struct mii_bus *bus, int addr, int reg);
72    int (*mii_write)(struct mii_bus *bus, int addr, int reg, u16 val);
73
74    int (*get_vlan_mc)(struct rtl8366_smi *smi, u32 index,
75                   struct rtl8366_vlan_mc *vlanmc);
76    int (*set_vlan_mc)(struct rtl8366_smi *smi, u32 index,
77                   const struct rtl8366_vlan_mc *vlanmc);
78    int (*get_vlan_4k)(struct rtl8366_smi *smi, u32 vid,
79                   struct rtl8366_vlan_4k *vlan4k);
80    int (*set_vlan_4k)(struct rtl8366_smi *smi,
81                   const struct rtl8366_vlan_4k *vlan4k);
82    int (*get_mc_index)(struct rtl8366_smi *smi, int port, int *val);
83    int (*set_mc_index)(struct rtl8366_smi *smi, int port, int index);
84    int (*get_mib_counter)(struct rtl8366_smi *smi, int counter,
85                   int port, unsigned long long *val);
86};
87
88int rtl8366_smi_init(struct rtl8366_smi *smi);
89void rtl8366_smi_cleanup(struct rtl8366_smi *smi);
90int rtl8366_smi_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data);
91int rtl8366_smi_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data);
92int rtl8366_smi_rmwr(struct rtl8366_smi *smi, u32 addr, u32 mask, u32 data);
93
94int rtl8366_set_vlan(struct rtl8366_smi *smi, int vid, u32 member, u32 untag,
95             u32 fid);
96int rtl8366_reset_vlan(struct rtl8366_smi *smi);
97int rtl8366_get_pvid(struct rtl8366_smi *smi, int port, int *val);
98int rtl8366_set_pvid(struct rtl8366_smi *smi, unsigned port, unsigned vid);
99
100#ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
101int rtl8366_debugfs_open(struct inode *inode, struct file *file);
102#endif
103
104#endif /* _RTL8366_SMI_H */
105

Archive Download this file



interactive