Trying to unify capitalization and formatting of comments. Writing of periods
at the end of comments is however still inconsistent.
Signed-off-by: Martin Mares <mj@ucw.cz>
Signed-off-by: Patrick Horn <patrick.horn@gmail.com>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21710
3c298f89-4303-0410-b956-
a3cf2f4a3e73
/*********** CONSTANTS ***********/
struct register_mappings {
char *NAME;
/*********** CONSTANTS ***********/
struct register_mappings {
char *NAME;
- u16 MODEL_NO; // compare to bits 4-9 of MII register 0,3.
+ u16 MODEL_NO; // Compare to bits 4-9 of MII register 0,3.
bitnum NUM_PORTS;
bitnum CPU_PORT;
bitnum NUM_PORTS;
bitnum CPU_PORT;
.SIMPLE_VLAN_REGISTERS = 0,
.SIMPLE_VLAN_REGISTERS = 0,
- // Register 19-21 documentation is missing/contradictory.
- // For registers 19-21 ports need to be: even numbers to MSB, odd to LSB.
- // This contradicts text for ROM registers, but follows logic of CoS bits.
-
- .VLAN_LOOKUP_REG = {0,19},// +N/2
+ // Only programmable via EEPROM
+ .VLAN_LOOKUP_REG = NOTSUPPORTED,// +N/2
.VLAN_LOOKUP_REG_5 = NOTSUPPORTED,
.VLAN_LOOKUP_EVEN_BIT = {8,9,10,11,12,-1,-1,-1,-1},
.VLAN_LOOKUP_ODD_BIT = {0,1,2,3,4,-1,-1,-1,-1},
.VLAN_LOOKUP_REG_5 = NOTSUPPORTED,
.VLAN_LOOKUP_EVEN_BIT = {8,9,10,11,12,-1,-1,-1,-1},
.VLAN_LOOKUP_ODD_BIT = {0,1,2,3,4,-1,-1,-1,-1},
int num_vlans;
unsigned int vlan_ports[MAX_VLANS];
const struct register_mappings *regs;
int num_vlans;
unsigned int vlan_ports[MAX_VLANS];
const struct register_mappings *regs;
- reg proc_mii; /*!< phy/reg for the low level register access via /proc */
+ reg proc_mii; // phy/reg for the low level register access via swconfig
static int ip_phy_read(struct ip175c_state *state, int port, int reg)
{
int val = mdiobus_read(state->mii_bus, port, reg);
static int ip_phy_read(struct ip175c_state *state, int port, int reg)
{
int val = mdiobus_read(state->mii_bus, port, reg);
static int ip_phy_write(struct ip175c_state *state, int port, int reg, u16 val)
{
int err;
static int ip_phy_write(struct ip175c_state *state, int port, int reg, u16 val)
{
int err;
static int ip_phy_write_masked(struct ip175c_state *state, int port, int reg, unsigned int mask, unsigned int data)
{
int val = ip_phy_read(state, port, reg);
static int ip_phy_write_masked(struct ip175c_state *state, int port, int reg, unsigned int mask, unsigned int data)
{
int val = ip_phy_read(state, port, reg);
/**
* These two macros are to simplify the mapping of logical bits to the bits in hardware.
* NOTE: these macros will return if there is an error!
/**
* These two macros are to simplify the mapping of logical bits to the bits in hardware.
* NOTE: these macros will return if there is an error!
return val; \
} while (0)
return val; \
} while (0)
static int get_model(struct ip175c_state *state)
{
reg oui_id_reg = {0, 2};
static int get_model(struct ip175c_state *state)
{
reg oui_id_reg = {0, 2};
state->num_vlans+=1; // does not include WAN.
}
state->num_vlans+=1; // does not include WAN.
}
val = getPhy(state, state->regs->VLAN_CONTROL_REG);
if (val < 0) {
return 0;
val = getPhy(state, state->regs->VLAN_CONTROL_REG);
if (val < 0) {
return 0;
-/** Get all state variables for VLAN mappings and port-based tagging. **/
+
+/** Get all state variables for VLAN mappings and port-based tagging **/
static int get_state(struct ip175c_state *state)
{
int i, j;
static int get_state(struct ip175c_state *state)
{
int i, j;
/** Only update vlan and router flags in the switch **/
static int update_flags(struct ip175c_state *state)
{
/** Only update vlan and router flags in the switch **/
static int update_flags(struct ip175c_state *state)
{
}
return update_flags(state);
}
return update_flags(state);
-
- // software reset: 30.0 = 0x175C
- // wait 2ms
- // reset ports 0,1,2,3,4
-/*
- Uses only the VLAN port mask and the add tag mask to generate the other fields:
- which ports are part of the same VLAN, removing vlan tags, and VLAN tag ids.
+/**
+ * Uses only the VLAN port mask and the add tag mask to generate the other fields:
+ * which ports are part of the same VLAN, removing vlan tags, and VLAN tag ids.
*/
static void correct_vlan_state(struct ip175c_state *state)
{
*/
static void correct_vlan_state(struct ip175c_state *state)
{
state->num_vlans = 0;
for (i=0; i<MAX_VLANS; i++) {
if (state->vlan_ports[i] != 0) {
state->num_vlans = 0;
for (i=0; i<MAX_VLANS; i++) {
if (state->vlan_ports[i] != 0) {
- state->num_vlans = i+1; //hack -- we need to store the "set" vlans somewhere...
+ state->num_vlans = i+1; // Hack -- we need to store the "set" vlans somewhere...
for (i=0; i<state->regs->NUM_PORTS; i++) {
unsigned int portmask = (1<<i);
if (!state->vlan_enabled) {
for (i=0; i<state->regs->NUM_PORTS; i++) {
unsigned int portmask = (1<<i);
if (!state->vlan_enabled) {
- // share with everybody!
+ // Share with everybody!
state->ports[i].shareports = (1<<state->regs->NUM_PORTS)-1;
continue;
}
state->ports[i].shareports = (1<<state->regs->NUM_PORTS)-1;
continue;
}
struct ip175c_state *state = dev->priv;
int err;
struct ip175c_state *state = dev->priv;
int err;
- err = get_state(state); // may be set in get_state.
+ err = get_state(state); // May be set in get_state.
if (err < 0)
return err;
val->value.i = state->vlan_enabled;
if (err < 0)
return err;
val->value.i = state->vlan_enabled;
enable = val->value.i;
if (state->vlan_enabled == enable) {
enable = val->value.i;
if (state->vlan_enabled == enable) {
- // do not change any state.
+ // Do not change any state.
return 0;
}
state->vlan_enabled = enable;
return 0;
}
state->vlan_enabled = enable;
state->vlan_ports[i] = 0x0;
if (state->vlan_enabled) {
state->vlan_ports[i] = 0x0;
if (state->vlan_enabled) {
- // updates other fields only based off vlan_ports and add_tag fields.
+ // Updates other fields only based off vlan_ports and add_tag fields.
// Note that by default, no ports are in any vlans.
correct_vlan_state(state);
}
// Note that by default, no ports are in any vlans.
correct_vlan_state(state);
}
- // ensure sane defaults?
+ // Ensure sane defaults?
return update_state(state);
}
return update_state(state);
}
- if (REG_SUPP(state->regs->MII_REGISTER_EN)){
+ if (REG_SUPP(state->regs->MII_REGISTER_EN)) {
int val = getPhy(state, state->regs->MII_REGISTER_EN);
if (val < 0) {
return val;
int val = getPhy(state, state->regs->MII_REGISTER_EN);
if (val < 0) {
return val;
return err;
err = getPhy(state, state->regs->RESET_REG);
return err;
err = getPhy(state, state->regs->RESET_REG);
- /* data sheet specifies reset period is 2 msec
- (don't see any mention of the 2ms delay in the IP178C spec, only
- in IP175C, but it can't hurt.) */
+ /*
+ * Data sheet specifies reset period to be 2 msec.
+ * (I don't see any mention of the 2ms delay in the IP178C spec, only
+ * in IP175C, but it can't hurt.)
+ */
-/*! get the current register number */
static int ip175c_get_tagged(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_get_tagged(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
-/*! set a new register address for low level access to registers */
static int ip175c_set_tagged(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_set_tagged(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
-
-/* low level /proc procedures */
-
-/*! get the current phy address */
+/** Get the current phy address */
static int ip175c_get_phy(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_get_phy(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
-/*! set a new phy address for low level access to registers */
+/** Set a new phy address for low level access to registers */
static int ip175c_set_phy(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_set_phy(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
-/*! get the current register number */
+/** Get the current register number */
static int ip175c_get_reg(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_get_reg(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
-/*! set a new register address for low level access to registers */
+/** Set a new register address for low level access to registers */
static int ip175c_set_reg(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_set_reg(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
-/*! get the register content of state->proc_mii */
+/** Get the register content of state->proc_mii */
static int ip175c_get_val(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_get_val(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
-/*! write a value to the register defined by phy/reg above */
+/** Write a value to the register defined by phy/reg above */
static int ip175c_set_val(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_set_val(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_read_name(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_read_name(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
- val->value.s = state->regs->NAME; // just a const pointer, won't be freed by swconfig.
+ val->value.s = state->regs->NAME; // Just a const pointer, won't be freed by swconfig.
static int ip175c_set_port_speed(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_set_port_speed(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
- /* can't set speed for cpu port */
+ /* Can't set speed for cpu port */
if (nr == state->regs->CPU_PORT)
return -EINVAL;
if (nr == state->regs->CPU_PORT)
return -EINVAL;
static int ip175c_get_port_status(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
static int ip175c_get_port_status(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
[IP175C_REGISTER_PHY] = {
.id = IP175C_REGISTER_PHY,
.type = SWITCH_TYPE_INT,
[IP175C_REGISTER_PHY] = {
.id = IP175C_REGISTER_PHY,
.type = SWITCH_TYPE_INT,
- .description = "Direct register access: set phy (0-4, or 29,30,31)",
+ .description = "Direct register access: set PHY (0-4, or 29,30,31)",
.name = "phy",
.get = ip175c_get_phy,
.set = ip175c_set_phy,
.name = "phy",
.get = ip175c_get_phy,
.set = ip175c_set_phy,
[IP175C_REGISTER_MII] = {
.id = IP175C_REGISTER_MII,
.type = SWITCH_TYPE_INT,
[IP175C_REGISTER_MII] = {
.id = IP175C_REGISTER_MII,
.type = SWITCH_TYPE_INT,
- .description = "Direct register access: set mii number (0-31)",
+ .description = "Direct register access: set MII register number (0-31)",
.name = "reg",
.get = ip175c_get_reg,
.set = ip175c_set_reg,
.name = "reg",
.get = ip175c_get_reg,
.set = ip175c_set_reg,
struct switch_dev *dev;
int err;
struct switch_dev *dev;
int err;
- /* we only attach to PHY 0, but use all available PHYs */
+ /* We only attach to PHY 0, but use all available PHYs */
if (pdev->addr != 0)
return -ENODEV;
if (pdev->addr != 0)
return -ENODEV;
module_init(ip175c_init);
module_exit(ip175c_exit);
module_init(ip175c_init);
module_exit(ip175c_exit);