From patchwork Thu Aug 2 19:43:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 1268001 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id EDBD63FCC5 for ; Thu, 2 Aug 2012 19:47:34 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sx1Jc-00080b-4D; Thu, 02 Aug 2012 19:44:12 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Sx1JY-00080U-HE for linux-arm-kernel@merlin.infradead.org; Thu, 02 Aug 2012 19:44:08 +0000 Received: from svenfoo.org ([82.94.215.22] helo=mail.zonque.de) by casper.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Sx1JW-0005lm-6z for linux-arm-kernel@lists.infradead.org; Thu, 02 Aug 2012 19:44:07 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.zonque.de (Postfix) with ESMTP id 8EC91C0067; Thu, 2 Aug 2012 21:43:59 +0200 (CEST) Received: from mail.zonque.de ([127.0.0.1]) by localhost (rambrand.bugwerft.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4i84dg4JUTV7; Thu, 2 Aug 2012 21:43:59 +0200 (CEST) Received: from tamtam.taperay.com (i59F72AC4.versanet.de [89.247.42.196]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.zonque.de (Postfix) with ESMTPSA id 18180C029C; Thu, 2 Aug 2012 21:43:59 +0200 (CEST) From: Daniel Mack To: netdev@vger.kernel.org Subject: [PATCH 2/2] net: davinci_mdio: add DT bindings Date: Thu, 2 Aug 2012 21:43:36 +0200 Message-Id: <1343936616-29318-2-git-send-email-zonque@gmail.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1343936616-29318-1-git-send-email-zonque@gmail.com> References: <1343936616-29318-1-git-send-email-zonque@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20120802_204406_447307_36DBB33A X-CRM114-Status: GOOD ( 17.39 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.3.2 on casper.infradead.org summary: Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zonque[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 0.8 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.9 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Cc: mugunthanvnm@ti.com, paul@pwsan.com, devicetree-discuss@lists.ozlabs.org, Daniel Mack , koen@dominion.thruhere.net, 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 Signed-off-by: Daniel Mack --- .../devicetree/bindings/net/davinci_mdio.txt | 24 +++++++++++++ drivers/net/ethernet/ti/davinci_mdio.c | 39 ++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/davinci_mdio.txt diff --git a/Documentation/devicetree/bindings/net/davinci_mdio.txt b/Documentation/devicetree/bindings/net/davinci_mdio.txt new file mode 100644 index 0000000..03292a5 --- /dev/null +++ b/Documentation/devicetree/bindings/net/davinci_mdio.txt @@ -0,0 +1,24 @@ +Davinci MDIO DT bindings + +Required properties: + + - compatible : should be "ti,davinci-mdio" + +Optional properties: + + - bus-freq : an integer to specify the bus speed + +Examples: + + mdio: davinci_mdio@4a101000 { + compatible = "ti,davinci-mdio"; + ti,hwmods = "davinci_mdio"; + }; + + or + + mdio: davinci_mdio@4a101000 { + compatible = "ti,davinci-mdio"; + reg = <0x4a101000 0x100>; + }; + diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c index b4b6015..2640cae 100644 --- a/drivers/net/ethernet/ti/davinci_mdio.c +++ b/drivers/net/ethernet/ti/davinci_mdio.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include /* * This timeout definition is a worst-case ultra defensive measure against @@ -289,6 +291,37 @@ static int davinci_mdio_write(struct mii_bus *bus, int phy_id, return 0; } +#ifdef CONFIG_OF +static const struct of_device_id davinci_mdio_dt_ids[] = { + { .compatible = "ti,davinci-mdio" }, + { } +}; +MODULE_DEVICE_TABLE(of, davinci_mdio_dt_ids); + +static inline int davinci_mdio_probe_dt(struct device *dev, + struct mdio_platform_data *pdata) +{ + struct device_node *np = dev->of_node; + const struct of_device_id *of_id = + of_match_device(davinci_mdio_dt_ids, dev); + u32 tmp; + + if (!of_id) + return 0; + + if (of_property_read_u32(np, "bus-freq", &tmp) == 0) + pdata->bus_freq = tmp; + + return 0; +} +#else +static inline int davinci_mdio_probe_dt(struct device *dev, + struct mdio_platform_data *pdata) +{ + return 0; +} +#endif + static int __devinit davinci_mdio_probe(struct platform_device *pdev) { struct mdio_platform_data *pdata = pdev->dev.platform_data; @@ -306,6 +339,10 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev) data->pdata = pdata ? (*pdata) : default_pdata; + ret = davinci_mdio_probe_dt(dev, pdata); + if (ret < 0) + goto free_mem; + data->bus = mdiobus_alloc(); if (!data->bus) { dev_err(dev, "failed to alloc mii bus\n"); @@ -389,6 +426,7 @@ bail_out: pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); +free_mem: kfree(data); return ret; @@ -471,6 +509,7 @@ static struct platform_driver davinci_mdio_driver = { .name = "davinci_mdio", .owner = THIS_MODULE, .pm = &davinci_mdio_pm_ops, + .of_match_table = of_match_ptr(davinci_mdio_dt_ids), }, .probe = davinci_mdio_probe, .remove = __devexit_p(davinci_mdio_remove),