forked from Ivasoft/openwrt
ar8216: move definitions from ar8216.c to ar8216.h and introduce ar8327.h
Move several structure definitions and #defines from ar8216.c to ar8216.h and move AR8327/AR8337 header stuff into a new header file ar8327.h. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 43844
This commit is contained in:
@@ -39,145 +39,10 @@
|
||||
#include <linux/version.h>
|
||||
|
||||
#include "ar8216.h"
|
||||
|
||||
/* size of the vlan table */
|
||||
#define AR8X16_MAX_VLANS 128
|
||||
#define AR8X16_PROBE_RETRIES 10
|
||||
#define AR8X16_MAX_PORTS 8
|
||||
#include "ar8327.h"
|
||||
|
||||
#define AR8XXX_MIB_WORK_DELAY 2000 /* msecs */
|
||||
|
||||
struct ar8xxx_priv;
|
||||
|
||||
#define AR8XXX_CAP_GIGE BIT(0)
|
||||
#define AR8XXX_CAP_MIB_COUNTERS BIT(1)
|
||||
|
||||
#define AR8XXX_NUM_PHYS 5
|
||||
|
||||
enum {
|
||||
AR8XXX_VER_AR8216 = 0x01,
|
||||
AR8XXX_VER_AR8236 = 0x03,
|
||||
AR8XXX_VER_AR8316 = 0x10,
|
||||
AR8XXX_VER_AR8327 = 0x12,
|
||||
AR8XXX_VER_AR8337 = 0x13,
|
||||
};
|
||||
|
||||
struct ar8xxx_mib_desc {
|
||||
unsigned int size;
|
||||
unsigned int offset;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
struct ar8xxx_chip {
|
||||
unsigned long caps;
|
||||
bool config_at_probe;
|
||||
bool mii_lo_first;
|
||||
|
||||
/* parameters to calculate REG_PORT_STATS_BASE */
|
||||
unsigned reg_port_stats_start;
|
||||
unsigned reg_port_stats_length;
|
||||
|
||||
int (*hw_init)(struct ar8xxx_priv *priv);
|
||||
void (*cleanup)(struct ar8xxx_priv *priv);
|
||||
|
||||
const char *name;
|
||||
int vlans;
|
||||
int ports;
|
||||
const struct switch_dev_ops *swops;
|
||||
|
||||
void (*init_globals)(struct ar8xxx_priv *priv);
|
||||
void (*init_port)(struct ar8xxx_priv *priv, int port);
|
||||
void (*setup_port)(struct ar8xxx_priv *priv, int port, u32 members);
|
||||
u32 (*read_port_status)(struct ar8xxx_priv *priv, int port);
|
||||
int (*atu_flush)(struct ar8xxx_priv *priv);
|
||||
void (*vtu_flush)(struct ar8xxx_priv *priv);
|
||||
void (*vtu_load_vlan)(struct ar8xxx_priv *priv, u32 vid, u32 port_mask);
|
||||
void (*phy_fixup)(struct ar8xxx_priv *priv, int phy);
|
||||
void (*set_mirror_regs)(struct ar8xxx_priv *priv);
|
||||
|
||||
const struct ar8xxx_mib_desc *mib_decs;
|
||||
unsigned num_mibs;
|
||||
unsigned mib_func;
|
||||
};
|
||||
|
||||
enum ar8327_led_pattern {
|
||||
AR8327_LED_PATTERN_OFF = 0,
|
||||
AR8327_LED_PATTERN_BLINK,
|
||||
AR8327_LED_PATTERN_ON,
|
||||
AR8327_LED_PATTERN_RULE,
|
||||
};
|
||||
|
||||
struct ar8327_led_entry {
|
||||
unsigned reg;
|
||||
unsigned shift;
|
||||
};
|
||||
|
||||
struct ar8327_led {
|
||||
struct led_classdev cdev;
|
||||
struct ar8xxx_priv *sw_priv;
|
||||
|
||||
char *name;
|
||||
bool active_low;
|
||||
u8 led_num;
|
||||
enum ar8327_led_mode mode;
|
||||
|
||||
struct mutex mutex;
|
||||
spinlock_t lock;
|
||||
struct work_struct led_work;
|
||||
bool enable_hw_mode;
|
||||
enum ar8327_led_pattern pattern;
|
||||
};
|
||||
|
||||
struct ar8327_data {
|
||||
u32 port0_status;
|
||||
u32 port6_status;
|
||||
|
||||
struct ar8327_led **leds;
|
||||
unsigned int num_leds;
|
||||
};
|
||||
|
||||
struct ar8xxx_priv {
|
||||
struct switch_dev dev;
|
||||
struct mii_bus *mii_bus;
|
||||
struct phy_device *phy;
|
||||
|
||||
int (*get_port_link)(unsigned port);
|
||||
|
||||
const struct net_device_ops *ndo_old;
|
||||
struct net_device_ops ndo;
|
||||
struct mutex reg_mutex;
|
||||
u8 chip_ver;
|
||||
u8 chip_rev;
|
||||
const struct ar8xxx_chip *chip;
|
||||
void *chip_data;
|
||||
bool initialized;
|
||||
bool port4_phy;
|
||||
char buf[2048];
|
||||
|
||||
bool init;
|
||||
|
||||
struct mutex mib_lock;
|
||||
struct delayed_work mib_work;
|
||||
int mib_next_port;
|
||||
u64 *mib_stats;
|
||||
|
||||
struct list_head list;
|
||||
unsigned int use_count;
|
||||
|
||||
/* all fields below are cleared on reset */
|
||||
bool vlan;
|
||||
u16 vlan_id[AR8X16_MAX_VLANS];
|
||||
u8 vlan_table[AR8X16_MAX_VLANS];
|
||||
u8 vlan_tagged;
|
||||
u16 pvid[AR8X16_MAX_PORTS];
|
||||
|
||||
/* mirroring */
|
||||
bool mirror_rx;
|
||||
bool mirror_tx;
|
||||
int source_port;
|
||||
int monitor_port;
|
||||
};
|
||||
|
||||
#define MIB_DESC(_s , _o, _n) \
|
||||
{ \
|
||||
.size = (_s), \
|
||||
@@ -270,47 +135,6 @@ static const struct ar8xxx_mib_desc ar8236_mibs[] = {
|
||||
static DEFINE_MUTEX(ar8xxx_dev_list_lock);
|
||||
static LIST_HEAD(ar8xxx_dev_list);
|
||||
|
||||
static inline struct ar8xxx_priv *
|
||||
swdev_to_ar8xxx(struct switch_dev *swdev)
|
||||
{
|
||||
return container_of(swdev, struct ar8xxx_priv, dev);
|
||||
}
|
||||
|
||||
static inline bool ar8xxx_has_gige(struct ar8xxx_priv *priv)
|
||||
{
|
||||
return priv->chip->caps & AR8XXX_CAP_GIGE;
|
||||
}
|
||||
|
||||
static inline bool ar8xxx_has_mib_counters(struct ar8xxx_priv *priv)
|
||||
{
|
||||
return priv->chip->caps & AR8XXX_CAP_MIB_COUNTERS;
|
||||
}
|
||||
|
||||
static inline bool chip_is_ar8216(struct ar8xxx_priv *priv)
|
||||
{
|
||||
return priv->chip_ver == AR8XXX_VER_AR8216;
|
||||
}
|
||||
|
||||
static inline bool chip_is_ar8236(struct ar8xxx_priv *priv)
|
||||
{
|
||||
return priv->chip_ver == AR8XXX_VER_AR8236;
|
||||
}
|
||||
|
||||
static inline bool chip_is_ar8316(struct ar8xxx_priv *priv)
|
||||
{
|
||||
return priv->chip_ver == AR8XXX_VER_AR8316;
|
||||
}
|
||||
|
||||
static inline bool chip_is_ar8327(struct ar8xxx_priv *priv)
|
||||
{
|
||||
return priv->chip_ver == AR8XXX_VER_AR8327;
|
||||
}
|
||||
|
||||
static inline bool chip_is_ar8337(struct ar8xxx_priv *priv)
|
||||
{
|
||||
return priv->chip_ver == AR8XXX_VER_AR8337;
|
||||
}
|
||||
|
||||
static inline void
|
||||
split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user