From patchwork Fri Jan 11 04:02:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 1963541 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 599E23FE37 for ; Fri, 11 Jan 2013 04:06:14 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TtVp9-00052w-7N; Fri, 11 Jan 2013 04:02:31 +0000 Received: from quartz.orcorp.ca ([184.70.90.242]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TtVp5-00052U-3i for linux-arm-kernel@lists.infradead.org; Fri, 11 Jan 2013 04:02:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=obsidianresearch.com; s=rsa1; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=EA/oLPU0SspwcfQOAitCwqfHNJ08y5WZ5D9EOa+WQRk=; b=b8nBn8+I8CcsCg7gtSv1BW8xlQp4pJx7QRh/RbOrj3AXv+XUJQAFi3nh9NWr6Z3MAdBB79q+V7rZdHokQ+xb8H7c9BtcAMUFBj4sjXM7Ht3d+c0sbxm23VMaxRNC1UQrIiKZ5HSfXXzkNPq1Q9HlhY8v6+ofwSrASleW8zEdMnk=; Received: from jgg by quartz.orcorp.ca with local (Exim 4.72) (envelope-from ) id 1TtVox-00067H-QJ; Thu, 10 Jan 2013 21:02:19 -0700 Date: Thu, 10 Jan 2013 21:02:19 -0700 From: Jason Gunthorpe To: Jason Cooper Subject: Re: [PATCH 2/3] ARM: Orion: Bind the orion bridge interrupt controller through DT Message-ID: <20130111040219.GA23206@obsidianresearch.com> References: <1355188683-18208-2-git-send-email-jgunthorpe@obsidianresearch.com> <20121211062430.GD25466@lunn.ch> <20121211065813.GA14843@obsidianresearch.com> <20121211071333.GR17242@lunn.ch> <20121211185535.GA14534@obsidianresearch.com> <20130110014734.GC5075@titan.lakedaemon.net> <20130110060710.GM24650@lunn.ch> <50EE8FC5.50105@gmail.com> <20130110184832.GB28004@obsidianresearch.com> <20130110185737.GO5075@titan.lakedaemon.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130110185737.GO5075@titan.lakedaemon.net> User-Agent: Mutt/1.5.20 (2009-06-14) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130110_230227_529035_35D71F6D X-CRM114-Status: GOOD ( 34.37 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Thomas Petazzoni , Andrew Lunn , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth 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: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On Thu, Jan 10, 2013 at 01:57:37PM -0500, Jason Cooper wrote: > Jason, > > On Thu, Jan 10, 2013 at 11:48:32AM -0700, Jason Gunthorpe wrote: > > There is a bunch of prep stuff that may still be pending: > > - Fixup remaining drivers (usb? ethernet?) to have DT bindings and > > get the IRQ number through DT > > any chance I could get you post your changes to the ethernet driver (DT > bindings)? iirc, you said you had based them off of Ian Molton's work. > Even if you posted them RFC, it'd be a good place to start from, > reignite conversation and so forth. I've attached the main mv dt patch as a MIME, sorry for the awkwardness, I am travelling and won't be available... Please feel free to re-post/alter as necessary. As I said before, I'm not happy with it because it doesn't follow the standard convention for MDIO phys. Jason From 4a20823d686b5ca60e6da1c84df3a652d8ebefcd Mon Sep 17 00:00:00 2001 From: Ian Molton Date: Tue, 7 Aug 2012 14:34:48 +0000 Subject: [PATCH] mv643xx.c: Add basic device tree support. This patch adds basic device tree support to the mv643xx ethernet driver. It should be enough for most current users of the device, and should allow a painless migration. Signed-off-by: Ian Molton --- Documentation/devicetree/bindings/net/mv643xx.txt | 75 +++++++++++++++++ drivers/net/ethernet/marvell/mv643xx_eth.c | 93 +++++++++++++++++++-- 2 files changed, 161 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/mv643xx.txt diff --git a/Documentation/devicetree/bindings/net/mv643xx.txt b/Documentation/devicetree/bindings/net/mv643xx.txt new file mode 100644 index 0000000..2727f798 --- /dev/null +++ b/Documentation/devicetree/bindings/net/mv643xx.txt @@ -0,0 +1,75 @@ +mv643xx related nodes. + +marvell,mdio-mv643xx: + +Required properties: + + - interrupts : where a is the SMI interrupt number. + - reg : the base address and size of the controllers register space. + +Optional properties: + - shared_smi : on some chips, the second PHY is "shared", meaning it is + really accessed via the first SMI controller. It is passed in this + way due to the present structure of the driver, which requires the + base address for the MAC to be passed in via the SMI controllers + platform data. + - tx_csum_limit : on some devices, this option is required for proper + operation wrt. jumbo frames. + + +Example: + +smi0: mdio@72000 { + compatible = "marvell,mdio-mv643xx"; + reg = <0x72000 0x4000>; + interrupts = <46>; + tx_csum_limit = <1600>; + status = "disabled"; +}; + +smi1: mdio@76000 { + compatible = "marvell,mdio-mv643xx"; + reg = <0x76000 0x4000>; + interrupts = <47>; + shared_smi = <&smi0>; + tx_csum_limit = <1600>; + status = "disabled"; +}; + + + +marvell,mv643xx-eth: + +Required properties: + - interrupts : the port interrupt number. + - mdio : phandle of the smi device as drescribed above + +Optional properties: + - port_number : the port number on this bus. + - phy_addr : the PHY address. + - reg : should match the mdio reg this device is attached to. + this is a required hack for now due to the way the + driver is constructed. This allows the device clock to be + kept running so that the MAC is not lost after boot. + + +Example: + +egiga0 { + compatible = "marvell,mv643xx-eth"; + reg = <0x72000 0x4000>; + mdio = <&smi0>; + port_number = <0>; + phy_addr = <0x80>; + interrupts = <11>; +}; + +egiga1 { + compatible = "marvell,mv643xx-eth"; + reg = <0x76000 0x4000>; + mdio = <&smi1>; + port_number = <0>; + phy_addr = <0x81>; + interrupts = <15>; +}; + diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index 84c1326..7048d7c 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -48,6 +48,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -2586,7 +2589,7 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp) static int mv643xx_eth_shared_probe(struct platform_device *pdev) { static int mv643xx_eth_version_printed; - struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data; + struct mv643xx_eth_shared_platform_data *pd; struct mv643xx_eth_shared_private *msp; const struct mbus_dram_target_info *dram; struct resource *res; @@ -2610,6 +2613,26 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) if (msp->base == NULL) goto out_free; + if (pdev->dev.of_node) { + struct device_node *np = NULL; + + /* when all users of this driver use FDT, we can remove this */ + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) { + dev_dbg(&pdev->dev, "Could not allocate platform data\n"); + goto out_free; + } + + of_property_read_u32(pdev->dev.of_node, + "tx_csum_limit", &pd->tx_csum_limit); + + np = of_parse_phandle(pdev->dev.of_node, "shared_smi", 0); + if (np) + pd->shared_smi = of_find_device_by_node(np); + + } else { + pd = pdev->dev.platform_data; + } /* * Set up and register SMI bus. */ @@ -2642,7 +2665,6 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (res != NULL) { int err; - err = request_irq(res->start, mv643xx_eth_err_irq, IRQF_SHARED, "mv643xx_eth", msp); if (!err) { @@ -2660,6 +2682,10 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ? pd->tx_csum_limit : 9 * 1024; + + if (pdev->dev.of_node) + kfree(pd); /* If we created a fake pd, free it now */ + infer_hw_params(msp); platform_set_drvdata(pdev, msp); @@ -2693,12 +2719,21 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static struct of_device_id mv_mdio_dt_ids[] __devinitdata = { + { .compatible = "marvell,mdio-mv643xx", }, + {}, +}; +MODULE_DEVICE_TABLE(of, mv_mdio_dt_ids); +#endif + static struct platform_driver mv643xx_eth_shared_driver = { .probe = mv643xx_eth_shared_probe, .remove = mv643xx_eth_shared_remove, .driver = { .name = MV643XX_ETH_SHARED_NAME, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(mv_mdio_dt_ids), }, }; @@ -2858,7 +2893,36 @@ static int mv643xx_eth_probe(struct platform_device *pdev) struct resource *res; int err; - pd = pdev->dev.platform_data; + if (pdev->dev.of_node) { + struct device_node *np = NULL; + + /* when all users of this driver use FDT, we can remove this */ + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) { + dev_dbg(&pdev->dev, "Could not allocate platform data\n"); + return -ENOMEM; + } + + of_property_read_u32(pdev->dev.of_node, + "port_number", &pd->port_number); + + if (!of_property_read_u32(pdev->dev.of_node, + "phy_addr", &pd->phy_addr)) + pd->phy_addr = MV643XX_ETH_PHY_ADDR(pd->phy_addr); + else + pd->phy_addr = MV643XX_ETH_PHY_ADDR_DEFAULT; + + np = of_parse_phandle(pdev->dev.of_node, "mdio", 0); + if (np) { + pd->shared = of_find_device_by_node(np); + } else { + kfree(pd); + return -ENODEV; + } + } else { + pd = pdev->dev.platform_data; + } + if (pd == NULL) { dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n"); return -ENODEV; @@ -2866,12 +2930,15 @@ static int mv643xx_eth_probe(struct platform_device *pdev) if (pd->shared == NULL) { dev_err(&pdev->dev, "no mv643xx_eth_platform_data->shared\n"); - return -ENODEV; + err = -ENODEV; + goto out_free_pd; } dev = alloc_etherdev_mq(sizeof(struct mv643xx_eth_private), 8); - if (!dev) - return -ENOMEM; + if (!dev) { + err = -ENOMEM; + goto out_free_pd; + } mp = netdev_priv(dev); platform_set_drvdata(pdev, mp); @@ -2908,6 +2975,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev) init_pscr(mp, pd->speed, pd->duplex); + if (pdev->dev.of_node) + kfree(pd); /* If we created a fake pd, free it now */ mib_counters_clear(mp); @@ -2927,7 +2996,6 @@ static int mv643xx_eth_probe(struct platform_device *pdev) mp->rx_oom.data = (unsigned long)mp; mp->rx_oom.function = oom_timer_wrapper; - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); BUG_ON(!res); dev->irq = res->start; @@ -2976,6 +3044,8 @@ out: } #endif free_netdev(dev); +out_free_pd: + kfree(pd); return err; } @@ -3015,6 +3085,14 @@ static void mv643xx_eth_shutdown(struct platform_device *pdev) port_reset(mp); } +#ifdef CONFIG_OF +static struct of_device_id mv_eth_dt_ids[] __devinitdata = { + { .compatible = "marvell,mv643xx-eth", }, + {}, +}; +MODULE_DEVICE_TABLE(of, mv_eth_dt_ids); +#endif + static struct platform_driver mv643xx_eth_driver = { .probe = mv643xx_eth_probe, .remove = mv643xx_eth_remove, @@ -3022,6 +3100,7 @@ static struct platform_driver mv643xx_eth_driver = { .driver = { .name = MV643XX_ETH_NAME, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(mv_eth_dt_ids), }, }; -- 1.7.10.4