[generic] revert unrelated change in previous commit
[openwrt.git] / target / linux / generic / files / drivers / net / phy / rtl8366s.c
index 8fa1ed1..4300872 100644 (file)
@@ -229,8 +229,8 @@ static int rtl8366s_reset_chip(struct rtl8366_smi *smi)
        int timeout = 10;
        u32 data;
 
-       rtl8366_smi_write_reg(smi, RTL8366S_RESET_CTRL_REG,
-                             RTL8366S_CHIP_CTRL_RESET_HW);
+       rtl8366_smi_write_reg_noack(smi, RTL8366S_RESET_CTRL_REG,
+                                   RTL8366S_CHIP_CTRL_RESET_HW);
        do {
                msleep(1);
                if (rtl8366_smi_read_reg(smi, RTL8366S_RESET_CTRL_REG, &data))
@@ -655,6 +655,49 @@ static int rtl8366s_sw_set_blinkrate(struct switch_dev *dev,
                                val->value.i);
 }
 
+static int rtl8366s_sw_get_max_length(struct switch_dev *dev,
+                                       const struct switch_attr *attr,
+                                       struct switch_val *val)
+{
+       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+       u32 data;
+
+       rtl8366_smi_read_reg(smi, RTL8366S_SGCR, &data);
+
+       val->value.i = ((data & (RTL8366S_SGCR_MAX_LENGTH_MASK)) >> 4);
+
+       return 0;
+}
+
+static int rtl8366s_sw_set_max_length(struct switch_dev *dev,
+                                       const struct switch_attr *attr,
+                                       struct switch_val *val)
+{
+       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+       char length_code;
+
+       switch (val->value.i) {
+               case 0:
+                       length_code = RTL8366S_SGCR_MAX_LENGTH_1522;
+                       break;
+               case 1:
+                       length_code = RTL8366S_SGCR_MAX_LENGTH_1536;
+                       break;
+               case 2:
+                       length_code = RTL8366S_SGCR_MAX_LENGTH_1552;
+                       break;
+               case 3:
+                       length_code = RTL8366S_SGCR_MAX_LENGTH_16000;
+                       break;
+               default:
+                       return -EINVAL;
+       }
+
+       return rtl8366_smi_rmwr(smi, RTL8366S_SGCR,
+                       RTL8366S_SGCR_MAX_LENGTH_MASK,
+                       length_code);
+}
+
 static int rtl8366s_sw_get_learning_enable(struct switch_dev *dev,
                                           const struct switch_attr *attr,
                                           struct switch_val *val)
@@ -863,6 +906,14 @@ static struct switch_attr rtl8366s_globals[] = {
                .set = rtl8366s_sw_set_blinkrate,
                .get = rtl8366s_sw_get_blinkrate,
                .max = 5
+       }, {
+               .type = SWITCH_TYPE_INT,
+               .name = "max_length",
+               .description = "Get/Set the maximum length of valid packets"
+               " (0 = 1522, 1 = 1536, 2 = 1552, 3 = 16000 (9216?))",
+               .set = rtl8366s_sw_set_max_length,
+               .get = rtl8366s_sw_get_max_length,
+               .max = 3,
        },
 };
 
@@ -945,7 +996,7 @@ static int rtl8366s_switch_init(struct rtl8366_smi *smi)
        dev->ports = RTL8366S_NUM_PORTS;
        dev->vlans = RTL8366S_NUM_VIDS;
        dev->ops = &rtl8366_ops;
-       dev->devname = dev_name(smi->parent);
+       dev->alias = dev_name(smi->parent);
 
        err = register_switch(dev, NULL);
        if (err)
@@ -1076,6 +1127,9 @@ static int __devinit rtl8366s_probe(struct platform_device *pdev)
 
        smi->gpio_sda = pdata->gpio_sda;
        smi->gpio_sck = pdata->gpio_sck;
+       smi->clk_delay = 10;
+       smi->cmd_read = 0xa9;
+       smi->cmd_write = 0xa8;
        smi->ops = &rtl8366s_smi_ops;
        smi->cpu_port = RTL8366S_PORT_NUM_CPU;
        smi->num_ports = RTL8366S_NUM_PORTS;
This page took 0.025376 seconds and 4 git commands to generate.