From patchwork Mon Jun 6 12:41:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pramod Kumar X-Patchwork-Id: 9158033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 33BE560572 for ; Mon, 6 Jun 2016 12:43:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 247F525E13 for ; Mon, 6 Jun 2016 12:43:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1918B267EC; Mon, 6 Jun 2016 12:43:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id C03AF25E13 for ; Mon, 6 Jun 2016 12:43:55 +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 1b9trK-0007eD-4k; Mon, 06 Jun 2016 12:42:22 +0000 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b9trE-0007ai-9q for linux-arm-kernel@lists.infradead.org; Mon, 06 Jun 2016 12:42:17 +0000 Received: by mail-pf0-x22f.google.com with SMTP id z187so12721778pfz.3 for ; Mon, 06 Jun 2016 05:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d+n8tAI5psg0DOIKM+3l1TabJoRti/EcLWkldl07KTg=; b=hPPlrEcBnBWFfiTazKMy+HxYp7cXIAnYes9rM/UtBqx7klaClffpBBEHJjYrWOHMJj uyRV6+Lyo+ZVCWe249x4FmP+yMX7VMOm1pz72VZ47iGxF1mvwN+2hNmOKeFRxPyxWoak AWgJS4G6cHGPS5t0mV3cd9lVOp+axjEAWmJOI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=d+n8tAI5psg0DOIKM+3l1TabJoRti/EcLWkldl07KTg=; b=hjhqLspjErmKHsqguQ2c/8+BSxXDDRhzNbRklKojly2Oh5OvxbAWUU1BlP+xesXDou 5sO0jeUnSqeCyO2uerZNDycd9l8J7ah8cBdz/JQlSxn/RctYzgz9UzO4rMmos+v5qfrV Q1Zuv6p9BRBqlInIrRRWkcLexKaBbGeYEl2aXoWQyknjjioH75xkRHTRhj/3aVNwuRRn Mqicy/fq0vWNQ9oJhEkeAZ871a6NVCTQtbEre56CuWZ6WmIZiqRE+8E1/te8gGpBz8bv q42ncUI9F9SWVKlLERsUAPkt6206ClPhcKqu7ds7GS+yVfrj3Lf9SdDoK8PhAaAGSgnS nJpA== X-Gm-Message-State: ALyK8tIb4cqF9Eri/fwSk4EcJSFOkBKKbkwPyNLniuC2xI8B16kFZzM4EUPakQtiyfyudZV5 X-Received: by 10.98.155.207 with SMTP id e76mr7335830pfk.53.1465216915201; Mon, 06 Jun 2016 05:41:55 -0700 (PDT) Received: from pramodku-OptiPlex-7010.ban.broadcom.com ([202.140.36.35]) by smtp.gmail.com with ESMTPSA id x71sm27594372pfj.43.2016.06.06.05.41.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jun 2016 05:41:54 -0700 (PDT) From: Pramod Kumar To: Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Catalin Marinas , Will Deacon , Kishon Vijay Abraham I , "David S. Miller" Subject: [PATCH v4 1/7] mdio: mux: Enhanced MDIO mux framework for integrated multiplexers Date: Mon, 6 Jun 2016 18:11:34 +0530 Message-Id: <1465216900-11755-2-git-send-email-pramod.kumar@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465216900-11755-1-git-send-email-pramod.kumar@broadcom.com> References: <1465216900-11755-1-git-send-email-pramod.kumar@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160606_054216_387954_E87C880E X-CRM114-Status: GOOD ( 16.40 ) 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: devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pramod Kumar , bcm-kernel-feedback-list@broadcom.com, 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-Virus-Scanned: ClamAV using ClamSMTP An integrated multiplexer uses same address space for "muxed bus selection" and "generation of mdio transaction" hence its good to register parent bus from mux driver. Hence added a mechanism where mux driver could register a parent bus and pass it down to framework via mdio_mux_init api. Signed-off-by: Pramod Kumar Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- drivers/net/phy/mdio-mux-gpio.c | 2 +- drivers/net/phy/mdio-mux-mmioreg.c | 2 +- drivers/net/phy/mdio-mux.c | 28 ++++++++++++++++++---------- include/linux/mdio-mux.h | 4 +++- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/net/phy/mdio-mux-gpio.c b/drivers/net/phy/mdio-mux-gpio.c index 7ddb1ab..9199499 100644 --- a/drivers/net/phy/mdio-mux-gpio.c +++ b/drivers/net/phy/mdio-mux-gpio.c @@ -55,7 +55,7 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) return PTR_ERR(s->gpios); r = mdio_mux_init(&pdev->dev, - mdio_mux_gpio_switch_fn, &s->mux_handle, s); + mdio_mux_gpio_switch_fn, &s->mux_handle, s, NULL); if (r != 0) { gpiod_put_array(s->gpios); diff --git a/drivers/net/phy/mdio-mux-mmioreg.c b/drivers/net/phy/mdio-mux-mmioreg.c index 7fde454..d0bed52 100644 --- a/drivers/net/phy/mdio-mux-mmioreg.c +++ b/drivers/net/phy/mdio-mux-mmioreg.c @@ -126,7 +126,7 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev) } ret = mdio_mux_init(&pdev->dev, mdio_mux_mmioreg_switch_fn, - &s->mux_handle, s); + &s->mux_handle, s, NULL); if (ret) { dev_err(&pdev->dev, "failed to register mdio-mux bus %s\n", np->full_name); diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c index 5c81d6f..dbd4ecc 100644 --- a/drivers/net/phy/mdio-mux.c +++ b/drivers/net/phy/mdio-mux.c @@ -89,7 +89,8 @@ static int parent_count; int mdio_mux_init(struct device *dev, int (*switch_fn)(int cur, int desired, void *data), void **mux_handle, - void *data) + void *data, + struct mii_bus *mux_bus) { struct device_node *parent_bus_node; struct device_node *child_bus_node; @@ -101,10 +102,21 @@ int mdio_mux_init(struct device *dev, if (!dev->of_node) return -ENODEV; - parent_bus_node = of_parse_phandle(dev->of_node, "mdio-parent-bus", 0); + if (!mux_bus) { + parent_bus_node = of_parse_phandle(dev->of_node, + "mdio-parent-bus", 0); - if (!parent_bus_node) - return -ENODEV; + if (!parent_bus_node) + return -ENODEV; + + parent_bus = of_mdio_find_bus(parent_bus_node); + if (!parent_bus) { + ret_val = -EPROBE_DEFER; + goto err_parent_bus; + } + } else { + parent_bus = mux_bus; + } pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL); if (pb == NULL) { @@ -112,11 +124,6 @@ int mdio_mux_init(struct device *dev, goto err_parent_bus; } - parent_bus = of_mdio_find_bus(parent_bus_node); - if (parent_bus == NULL) { - ret_val = -EPROBE_DEFER; - goto err_parent_bus; - } pb->switch_data = data; pb->switch_fn = switch_fn; @@ -177,7 +184,8 @@ int mdio_mux_init(struct device *dev, put_device(&pb->mii_bus->dev); err_parent_bus: - of_node_put(parent_bus_node); + if (!mux_bus) + of_node_put(parent_bus_node); return ret_val; } EXPORT_SYMBOL_GPL(mdio_mux_init); diff --git a/include/linux/mdio-mux.h b/include/linux/mdio-mux.h index a243dbb..61f5b21 100644 --- a/include/linux/mdio-mux.h +++ b/include/linux/mdio-mux.h @@ -10,11 +10,13 @@ #ifndef __LINUX_MDIO_MUX_H #define __LINUX_MDIO_MUX_H #include +#include int mdio_mux_init(struct device *dev, int (*switch_fn) (int cur, int desired, void *data), void **mux_handle, - void *data); + void *data, + struct mii_bus *mux_bus); void mdio_mux_uninit(void *mux_handle);