From patchwork Thu May 15 06:15:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 4179361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 08428BFF02 for ; Thu, 15 May 2014 06:18:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B0BC202F2 for ; Thu, 15 May 2014 06:18:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30CB2201F4 for ; Thu, 15 May 2014 06:18:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WkoxS-0000RN-8u; Thu, 15 May 2014 06:15:58 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WkoxP-0000LF-OR for linux-arm-kernel@lists.infradead.org; Thu, 15 May 2014 06:15:56 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4F6FS1F000856; Thu, 15 May 2014 01:15:28 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4F6FSqJ031047; Thu, 15 May 2014 01:15:28 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Thu, 15 May 2014 01:15:28 -0500 Received: from [172.24.191.25] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4F6FOcu007465; Thu, 15 May 2014 01:15:25 -0500 Message-ID: <53745B74.2040808@ti.com> Date: Thu, 15 May 2014 11:45:16 +0530 From: Kishon Vijay Abraham I User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: =?UTF-8?B?QW50b2luZSBUw6luYXJ0?= Subject: Re: [PATCH v3 1/6] phy: add a driver for the Berlin SATA PHY References: <1400060942-10588-1-git-send-email-antoine.tenart@free-electrons.com> <1400060942-10588-2-git-send-email-antoine.tenart@free-electrons.com> <537341AF.5030105@ti.com> <20140514102122.GA11140@kwain> In-Reply-To: <20140514102122.GA11140@kwain> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140514_231555_884225_52E7815F X-CRM114-Status: GOOD ( 21.61 ) X-Spam-Score: -5.7 (-----) Cc: thomas.petazzoni@free-electrons.com, zmxu@marvell.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, alexandre.belloni@free-electrons.com, jszhang@marvell.com, tj@kernel.org, linux-arm-kernel@lists.infradead.org, sebastian.hesselbarth@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On Wednesday 14 May 2014 03:51 PM, Antoine Ténart wrote: > Hi, > > On Wed, May 14, 2014 at 03:43:03PM +0530, Kishon Vijay Abraham I wrote: >> Hi, >> >> On Wednesday 14 May 2014 03:18 PM, Antoine Ténart wrote: > > […] > >>> +#define to_berlin_sata_phy_priv(desc) \ >>> + container_of((desc), struct phy_berlin_priv, phys[(desc)->index]) >>> + >>> +struct phy_berlin_desc { >>> + struct phy *phy; >>> + u32 val; >>> + unsigned index; >>> +}; >>> + >>> +struct phy_berlin_priv { >>> + void __iomem *base; >>> + spinlock_t lock; >>> + struct phy_berlin_desc phys[BERLIN_SATA_PHY_NB]; >> >> Can't we do away with hardcoding BERLIN_SATA_PHY_NB? > > We can't if we want to be able to use the container_of macro in > to_berlin_sata_phy_priv(). And we want a common structure to store the > common spinlock and base address. to get phy_berlin_priv, you can use dev_get_drvdata(phy->dev->parent). > > […] > >>> + /* >>> + * By default the PHY node is used to request and match a PHY. >>> + * We describe one PHY per sub-node here. Use the right node. >>> + */ >>> + phy->dev.of_node = child; >>> + >>> + priv->phys[phy_id].phy = phy; >>> + priv->phys[phy_id].val = desc[phy_id].val; >>> + priv->phys[phy_id].index = phy_id; >>> + phy_set_drvdata(phy, &priv->phys[phy_id]); >>> + >>> + /* Make sure the PHY is off */ >>> + phy_berlin_sata_power_off(phy); >>> + >>> + phy_provider = devm_of_phy_provider_register(&phy->dev, >>> + of_phy_simple_xlate); >>> + if (IS_ERR(phy_provider)) >>> + return PTR_ERR(phy_provider); >> >> was this intentional? registering multiple PHY providers? > > Yes. Each sub-node describe a PHY and register as a PHY provider. This > allow to reference the PHY as <&sata_phy0> and not <&sata_phy 0>. It > would be confusing to have a sub-node sata_phy0 and to use its parent > to access it. It is still a single PHY provider, so you can't register multiple PHY providers. So in this case <&sata_phy 0> is not that bad. However phy-core.c should be patched with the following (only compile tested) From 2517d4c0ad7f13abc2613516ef2b222a1fbcb550 Mon Sep 17 00:00:00 2001 From: Kishon Vijay Abraham I Date: Thu, 15 May 2014 11:32:57 +0530 Subject: [PATCH] phy: phy-core: Support modelling multi-PHY PHY nodes as subnodes of PHY PROVIDER When a single PHY provider implementing multiple PHYs is represented in dt, the PHYs should be modelled as sub nodes of the PHY PROVIDER node. So the consumers using the PHY will have the phandle of the sub node rather than the phandle of the PHY PROVIDER. Amended *of_phy_provider_lookup* in PHY core to return the PHY PROVIDER even when the phandle of the PHY PROVIDERs sub node is provided. Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/phy-core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) return ERR_PTR(-EPROBE_DEFER); diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 03cf8fb..124c6ec 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -83,10 +83,18 @@ static struct phy *phy_lookup(struct device *device, const char *port) static struct phy_provider *of_phy_provider_lookup(struct device_node *node) { struct phy_provider *phy_provider; + struct device_node *child; list_for_each_entry(phy_provider, &phy_provider_list, list) { - if (phy_provider->dev->of_node == node) + if (phy_provider->dev->of_node != node) { + for_each_child_of_node(phy_provider->dev->of_node, + child) { + if (child == node) + return phy_provider; + } + } else { return phy_provider; + } }