From patchwork Fri Jan 25 10:06:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 2042651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 01C28DF223 for ; Fri, 25 Jan 2013 10:12:37 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TygEf-00085R-0e; Fri, 25 Jan 2013 10:10:13 +0000 Received: from zmc.proxad.net ([212.27.53.206]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TygE6-0007sS-3m for linux-arm-kernel@lists.infradead.org; Fri, 25 Jan 2013 10:09:40 +0000 Received: from localhost (localhost [127.0.0.1]) by zmc.proxad.net (Postfix) with ESMTP id 685DBBAF8AB; Fri, 25 Jan 2013 11:09:35 +0100 (CET) X-Virus-Scanned: amavisd-new at localhost Received: from zmc.proxad.net ([127.0.0.1]) by localhost (zmc.proxad.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MtxrLAqNRXsj; Fri, 25 Jan 2013 11:09:34 +0100 (CET) Received: from flexo.iliad.local (freebox.vlq16.iliad.fr [213.36.7.13]) by zmc.proxad.net (Postfix) with ESMTPSA id D4987BB03BB; Fri, 25 Jan 2013 11:09:34 +0100 (CET) From: Florian Fainelli To: netdev@vger.kernel.org Subject: [RFC PATCH 4/4] net: mvmdio: add getter and setter for PHY addresses Date: Fri, 25 Jan 2013 11:06:49 +0100 Message-Id: <1359108409-4378-5-git-send-email-florian@openwrt.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359108409-4378-1-git-send-email-florian@openwrt.org> References: <1359108409-4378-1-git-send-email-florian@openwrt.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130125_050938_387562_521D3E19 X-CRM114-Status: GOOD ( 12.57 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: thomas.petazzoni@free-electrons.com, andrew@lunn.ch, jason@lakedaemon.net, arnd@arndb.de, gregory.clement@free-electrons.com, ian.molton@codethink.co.uk, Florian Fainelli , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch adds orion_mdio_{set,get}_phy_addr(.., port_number, phy_addr) which is a feature available in this MDIO driver to monitor a particular PHY address. This brings mvmdio one step closer to what is used in mv643x_eth. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/marvell/mvmdio.c | 29 +++++++++++++++++++++++++++++ include/linux/marvell_mvmdio.h | 10 ++++++++++ 2 files changed, 39 insertions(+) create mode 100644 include/linux/marvell_mvmdio.h diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c index bdd9047..09e2470 100644 --- a/drivers/net/ethernet/marvell/mvmdio.c +++ b/drivers/net/ethernet/marvell/mvmdio.c @@ -32,7 +32,9 @@ #include #include #include +#include +#define MVMDIO_PHY_ADDR 0x0000 #define MVMDIO_SMI_REG 0x0004 #define MVMDIO_SMI_DATA_SHIFT 0 #define MVMDIO_SMI_PHY_ADDR_SHIFT 16 @@ -188,6 +190,33 @@ static irqreturn_t orion_mdio_err_irq(int irq, void *dev_id) return IRQ_NONE; } +void orion_mdio_phy_addr_set(struct platform_device *pdev, + int port_num, int phy_addr) +{ + struct orion_mdio_dev *dev = + platform_get_drvdata(pdev); + int addr_shift = 5 * port_num; + u32 data; + + data = readl(dev->regs + MVMDIO_PHY_ADDR); + data &= ~(0x1f << addr_shift); + data |= (phy_addr & 0x1f) << addr_shift; + writel(data, dev->regs + MVMDIO_PHY_ADDR); +} +EXPORT_SYMBOL(orion_mdio_phy_addr_set); + +int orion_mdio_phy_addr_get(struct platform_device *pdev, int port_num) +{ + struct orion_mdio_dev *dev = + platform_get_drvdata(pdev); + unsigned int data; + + data = readl(dev->regs + MVMDIO_PHY_ADDR); + + return (data >> (5 * port_num)) & 0x1f; +} +EXPORT_SYMBOL(orion_mdio_phy_addr_get); + static int orion_mdio_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; diff --git a/include/linux/marvell_mvmdio.h b/include/linux/marvell_mvmdio.h new file mode 100644 index 0000000..c2dfec4 --- /dev/null +++ b/include/linux/marvell_mvmdio.h @@ -0,0 +1,10 @@ +#ifndef _MARVELL_MVMDIO_H +#define _MARVELL_MVMDIO_H + +#include + +void orion_mdio_phy_addr_set(struct platform_device *pdev, + int port_num, int phy_addr); +int orion_mdio_phy_addr_get(struct platform_device *pdev, int port_num); + +#endif /* _MARVELL_MVMDIO_H */