From patchwork Tue Aug 11 00:58:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 6987321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 36BDB9F373 for ; Tue, 11 Aug 2015 01:01:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56CF3205DD for ; Tue, 11 Aug 2015 01:01:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80320205D3 for ; Tue, 11 Aug 2015 01:01:15 +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 1ZOxuV-0002Jm-CG; Tue, 11 Aug 2015 00:59:23 +0000 Received: from mail-ig0-x233.google.com ([2607:f8b0:4001:c05::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZOxuH-00023i-VB for linux-arm-kernel@lists.infradead.org; Tue, 11 Aug 2015 00:59:11 +0000 Received: by igbij6 with SMTP id ij6so81056190igb.1 for ; Mon, 10 Aug 2015 17:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f0O6f9PLCZctncUGT+kTwd59wVf4SpuLITC+9jFjRqw=; b=kRy8Do6FsmfHJ8or57jMeLCMlNDls5RurPqCFMxSA99mVCbUtZvyEC/aMm1LMigXUb 1sq3meELuFINQBUis58cgYaUz9+z78k0oWW1kqrFFLkOf55RQEI8BJfJ3s7IXnYSq230 TUM6pAXPpW5eIU0bm32qntuBUGNV8tIQb4lWNbDH9ZJ+BfCAKlGMOyIPxXSQmITsDJzs /J4EBjtUztVJKG6R1ifHb0F481dNcjAZ+DFGsDX4YQcvE9LP2Pl5bMuTpvZNcjoZhhM6 34nVPGlxQxjyhgRaEx1npGN1cSlE/vrk1AwTjz8oW2ZLHZnZ39wJF08eO5pPwwMd0Ga5 jnvA== X-Received: by 10.50.112.166 with SMTP id ir6mr10974043igb.75.1439254728111; Mon, 10 Aug 2015 17:58:48 -0700 (PDT) Received: from dl.caveonetworks.com (64.2.3.194.ptr.us.xo.net. [64.2.3.194]) by smtp.gmail.com with ESMTPSA id 90sm415122iog.35.2015.08.10.17.58.45 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 10 Aug 2015 17:58:46 -0700 (PDT) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id t7B0wiJx002915; Mon, 10 Aug 2015 17:58:44 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id t7B0widf002914; Mon, 10 Aug 2015 17:58:44 -0700 From: David Daney To: netdev@vger.kernel.org, "David S. Miller" , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] net: thunder: Factor out DT specific code in BGX Date: Mon, 10 Aug 2015 17:58:36 -0700 Message-Id: <1439254717-2875-2-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1439254717-2875-1-git-send-email-ddaney.cavm@gmail.com> References: <1439254717-2875-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150810_175910_158764_6DC4763C X-CRM114-Status: GOOD ( 15.08 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-mips@linux-mips.org, rafael@kernel.org, David Daney , Tomasz Nowicki , Robert Richter , linux-acpi@vger.kernel.org, Robert Richter , Sunil Goutham , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Robert Richter Separate DT code in preparation for follow-on ACPI integration. Based on code from: Tomasz Nowicki Signed-off-by: Robert Richter Signed-off-by: David Daney --- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 48 +++++++++++++++++------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index b961a89..615b2af 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c @@ -835,18 +835,28 @@ static void bgx_get_qlm_mode(struct bgx *bgx) } } -static void bgx_init_of(struct bgx *bgx, struct device_node *np) +#if IS_ENABLED(CONFIG_OF_MDIO) + +static int bgx_init_of_phy(struct bgx *bgx) { + struct device_node *np; struct device_node *np_child; u8 lmac = 0; + char bgx_sel[5]; + const char *mac; - for_each_child_of_node(np, np_child) { - struct device_node *phy_np; - const char *mac; + /* Get BGX node from DT */ + snprintf(bgx_sel, 5, "bgx%d", bgx->bgx_id); + np = of_find_node_by_name(NULL, bgx_sel); + if (!np) + return -ENODEV; - phy_np = of_parse_phandle(np_child, "phy-handle", 0); - if (phy_np) - bgx->lmac[lmac].phydev = of_phy_find_device(phy_np); + for_each_child_of_node(np, np_child) { + struct device_node *phy_np = of_parse_phandle(np_child, + "phy-handle", 0); + if (!phy_np) + continue; + bgx->lmac[lmac].phydev = of_phy_find_device(phy_np); mac = of_get_mac_address(np_child); if (mac) @@ -858,6 +868,21 @@ static void bgx_init_of(struct bgx *bgx, struct device_node *np) if (lmac == MAX_LMAC_PER_BGX) break; } + return 0; +} + +#else + +static int bgx_init_of_phy(struct bgx *bgx) +{ + return -ENODEV; +} + +#endif /* CONFIG_OF_MDIO */ + +static int bgx_init_phy(struct bgx *bgx) +{ + return bgx_init_of_phy(bgx); } static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) @@ -865,8 +890,6 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) int err; struct device *dev = &pdev->dev; struct bgx *bgx = NULL; - struct device_node *np; - char bgx_sel[5]; u8 lmac; bgx = devm_kzalloc(dev, sizeof(*bgx), GFP_KERNEL); @@ -902,10 +925,9 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) bgx_vnic[bgx->bgx_id] = bgx; bgx_get_qlm_mode(bgx); - snprintf(bgx_sel, 5, "bgx%d", bgx->bgx_id); - np = of_find_node_by_name(NULL, bgx_sel); - if (np) - bgx_init_of(bgx, np); + err = bgx_init_phy(bgx); + if (err) + goto err_enable; bgx_init_hw(bgx);