From patchwork Fri Jan 9 17:12:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Leite X-Patchwork-Id: 427184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4A6BF140077 for ; Sat, 10 Jan 2015 04:13:59 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 033782840F4; Fri, 9 Jan 2015 18:11:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id A085B28088F for ; Fri, 9 Jan 2015 18:11:03 +0100 (CET) X-policyd-weight: using cached result; rate: -5.5 Received: from smtp.rcn.com (smtp.rcn.com [69.168.97.78]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Fri, 9 Jan 2015 18:11:03 +0100 (CET) X_CMAE_Category: , , X-CNFS-Analysis: v=2.0 cv=bYPpoZzB c=1 sm=1 a=JcyngB3XFbJbZ0YyysOmzg==:17 a=8ndMLmUfAAAA:8 a=2C_z7mVFwIYMZ3K1gs4A:9 a=JcyngB3XFbJbZ0YyysOmzg==:117 X-CM-Score: 0 X-Scanned-by: Cloudmark Authority Engine X-Authed-Username: bGVpdGVjQHN0YXRpY2t5LmNvbQ== Authentication-Results: smtp01.rcn.cmh.synacor.com smtp.mail=leitec@staticky.com; spf=neutral; sender-id=neutral Authentication-Results: smtp01.rcn.cmh.synacor.com header.from=leitec@staticky.com; sender-id=neutral Received-SPF: neutral (smtp01.rcn.cmh.synacor.com: 208.58.65.40 is neither permitted nor denied by domain of staticky.com) Received: from [208.58.65.40] ([208.58.65.40:58878] helo=dirk.lan.staticky.com) by smtp.rcn.com (envelope-from ) (ecelerity 3.6.2.43620 r(Platform:3.6.2.0)) with ESMTP id A0/0E-43469-52C00B45; Fri, 09 Jan 2015 12:13:09 -0500 From: Claudio Leite To: openwrt-devel@lists.openwrt.org Date: Fri, 9 Jan 2015 12:12:48 -0500 Message-Id: <1420823570-8706-2-git-send-email-leitec@staticky.com> X-Mailer: git-send-email 2.2.1 In-Reply-To: <1420823570-8706-1-git-send-email-leitec@staticky.com> References: <1420823570-8706-1-git-send-email-leitec@staticky.com> Subject: [OpenWrt-Devel] [PATCH 2/4] mvsw61xx: rework chip recognition X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Recognizes 88E6171/6172/6176 at the moment. Signed-off-by: Claudio Leite --- .../linux/generic/files/drivers/net/phy/mvsw61xx.c | 27 ++++++++++++++++------ .../linux/generic/files/drivers/net/phy/mvsw61xx.h | 14 ++++++++--- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/target/linux/generic/files/drivers/net/phy/mvsw61xx.c b/target/linux/generic/files/drivers/net/phy/mvsw61xx.c index 7199de0..865bd11 100644 --- a/target/linux/generic/files/drivers/net/phy/mvsw61xx.c +++ b/target/linux/generic/files/drivers/net/phy/mvsw61xx.c @@ -740,8 +740,8 @@ static int mvsw61xx_probe(struct platform_device *pdev) 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); @@ -776,17 +776,28 @@ static int mvsw61xx_probe(struct platform_device *pdev) 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", @@ -808,7 +819,7 @@ static int mvsw61xx_probe(struct platform_device *pdev) 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); @@ -839,6 +850,8 @@ mvsw61xx_remove(struct platform_device *pdev) static const struct of_device_id mvsw61xx_match[] = { { .compatible = "marvell,88e6171" }, + { .compatible = "marvell,88e6172" }, + { .compatible = "marvell,88e6176" }, { } }; MODULE_DEVICE_TABLE(of, mvsw61xx_match); diff --git a/target/linux/generic/files/drivers/net/phy/mvsw61xx.h b/target/linux/generic/files/drivers/net/phy/mvsw61xx.h index bd9d60a..d61d21f 100644 --- a/target/linux/generic/files/drivers/net/phy/mvsw61xx.h +++ b/target/linux/generic/files/drivers/net/phy/mvsw61xx.h @@ -190,9 +190,16 @@ enum { }; #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 @@ -200,6 +207,7 @@ struct mvsw61xx_state { struct switch_dev dev; struct mii_bus *bus; int base_addr; + u16 model; bool registered; bool is_indirect;