struct mvsw61xx_state *state;
struct device_node *np = pdev->dev.of_node;
struct device_node *mdio;
+ char *model_str;
u32 val;
- u16 reg;
int err;
state = kzalloc(sizeof(*state), GFP_KERNEL);
state->base_addr = MV_BASE;
}
- reg = r16(state->bus, state->is_indirect, state->base_addr,
- MV_PORTREG(IDENT, 0)) & MV_IDENT_MASK;
- if (reg != MV_IDENT_VALUE) {
- dev_err(&pdev->dev, "No switch found at 0x%02x\n",
+ state->model = r16(state->bus, state->is_indirect, state->base_addr,
+ MV_PORTREG(IDENT, 0)) & MV_IDENT_MASK;
+
+ switch(state->model) {
+ case MV_IDENT_VALUE_6171:
+ model_str = MV_IDENT_STR_6171;
+ break;
+ case MV_IDENT_VALUE_6172:
+ model_str = MV_IDENT_STR_6172;
+ break;
+ case MV_IDENT_VALUE_6176:
+ model_str = MV_IDENT_STR_6176;
+ break;
+ default:
+ dev_err(&pdev->dev, "No compatible switch found at 0x%02x\n",
state->base_addr);
err = -ENODEV;
goto out_err;
}
platform_set_drvdata(pdev, state);
- dev_info(&pdev->dev, "Found %s at %s:%02x\n", MV_IDENT_STR,
+ dev_info(&pdev->dev, "Found %s at %s:%02x\n", model_str,
state->bus->id, state->base_addr);
dev_info(&pdev->dev, "Using %sdirect addressing\n",
state->dev.vlans = MV_VLANS;
state->dev.cpu_port = state->cpu_port0;
state->dev.ports = MV_PORTS;
- state->dev.name = MV_IDENT_STR;
+ state->dev.name = model_str;
state->dev.ops = &mvsw61xx_ops;
state->dev.alias = dev_name(&pdev->dev);
static const struct of_device_id mvsw61xx_match[] = {
{ .compatible = "marvell,88e6171" },
+ { .compatible = "marvell,88e6172" },
+ { .compatible = "marvell,88e6176" },
{ }
};
MODULE_DEVICE_TABLE(of, mvsw61xx_match);
};
#define MV_INDIRECT_ADDR_S 5
-#define MV_IDENT_MASK 0xffc0
-#define MV_IDENT_VALUE 0x1700
-#define MV_IDENT_STR "MV88E617x"
+#define MV_IDENT_MASK 0xfff0
+
+#define MV_IDENT_VALUE_6171 0x1710
+#define MV_IDENT_STR_6171 "MV88E6171"
+
+#define MV_IDENT_VALUE_6172 0x1720
+#define MV_IDENT_STR_6172 "MV88E6172"
+
+#define MV_IDENT_VALUE_6176 0x1760
+#define MV_IDENT_STR_6176 "MV88E6176"
#define MV_PVID_MASK 0x0fff
struct switch_dev dev;
struct mii_bus *bus;
int base_addr;
+ u16 model;
bool registered;
bool is_indirect;