Received: by 2002:ac0:950e:0:0:0:0:0 with SMTP id f14csp1282044imc; Sun, 17 Mar 2019 09:15:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqysI6yNJvT2mfO0HQx+cILHzxz7fN1ZN2M5PM/C8Es4XS27ZcpeEMVK1in1UDn8Mk235giJ X-Received: by 2002:a17:902:6b49:: with SMTP id g9mr15431337plt.291.1552839303393; Sun, 17 Mar 2019 09:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552839303; cv=none; d=google.com; s=arc-20160816; b=W329pkyuIHMGn9oWfOh9JIrqciOQQEZ0Ge1uVKaU1JyLMFG80ri6YCtMp5T0QEthX+ BRV2VlMYlUM7nxYf2jr182IEExPtOnl1Hlkrl5gjbmCcF6Z/RayeWC0jSQDIf6DvVEXq NdpwpJAL9mnf2qsNBdSM9gttvXVCqvCZq7hB4AQwFUrtoO0UjIrLWyXTROaFllQH3yx6 SKfvRrDfYk9kgeQ7BTPEnuUbKuJ6xXemvKInV7Tp72hb6gGyMsI7V6qClXEuzPOM1tph VEY66bzbHCvOu+pvRjE53D0Mb2SxQDq8fMo2dUppUea1IiUiRxUlNuzOfMsj327Rqm6K IY9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ga/d6DAfonYT+aevDO+ynI5XmAxDR8reYVrq9kRGXeU=; b=omWYLcKHUCFCMkxVz4n/VZLxgJVnQ3Szw7lxQ7uMdzTjsNgvwq1/ntaKaEQ2w9NfOP iuESCY/9YYUz4rewcdelOvS4qs4PUYVWrPEK0oJ0FTKWNG5mGYKL+gaqCdgAlTgvP195 7IkPkrLwZFrWb+Khyl9SRzWohiwhAO625dHaQ5JibMmusaWBQ13UWdyP1f5AklqrLVEn L17brGJu6vre4HWABdec1bR1Zsp5tAT+LB3yFE81Ss5EqLfJGuHalkDKPPEAAjLySJ9c RP+Kns6zRCuNPdYXIhAjeQj+03fqG81GO+Iqld68x0hTzxEycKu/2GtRkvJKkOyWzkfL /nLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=un6l3eJT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si7409724plb.367.2019.03.17.09.14.47; Sun, 17 Mar 2019 09:15:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=un6l3eJT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727395AbfCQQOJ (ORCPT + 99 others); Sun, 17 Mar 2019 12:14:09 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:56494 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbfCQQOI (ORCPT ); Sun, 17 Mar 2019 12:14:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Ga/d6DAfonYT+aevDO+ynI5XmAxDR8reYVrq9kRGXeU=; b=un6l3eJTOWHqfEoAodPnhb1QTO 2UAS6okdoMWGsw3GKOuFwNkhe9WV4mOjDBdev5BLLDVsCEdtn/A8OMXo+uuHcAugzwriQknwZjEdW IAuCh5mSK6moTSLbZro6PW4tdt+Qc+hZv0mXp50oMDZRRyiE7WO4mwEZKjiPnj51np4I=; Received: from andrew by vps0.lunn.ch with local (Exim 4.89) (envelope-from ) id 1h5YQE-00067B-Tr; Sun, 17 Mar 2019 17:14:02 +0100 Date: Sun, 17 Mar 2019 17:14:02 +0100 From: Andrew Lunn To: Jerome Brunet Cc: Florian Fainelli , Heiner Kallweit , "David S. Miller" , Kevin Hilman , netdev@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH net-next 2/3] net: phy: add amlogic g12a mdio mux support Message-ID: <20190317161402.GB22226@lunn.ch> References: <20190314140135.19184-1-jbrunet@baylibre.com> <20190314140135.19184-3-jbrunet@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190314140135.19184-3-jbrunet@baylibre.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 14, 2019 at 03:01:34PM +0100, Jerome Brunet wrote: > Add support for the mdio mux and internal phy glue of the g12a SoC family > > Signed-off-by: Jerome Brunet > --- > drivers/net/phy/Kconfig | 10 + > drivers/net/phy/Makefile | 1 + > drivers/net/phy/mdio-mux-meson-g12a.c | 371 ++++++++++++++++++++++++++ > 3 files changed, 382 insertions(+) > create mode 100644 drivers/net/phy/mdio-mux-meson-g12a.c > > diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig > index 071869db44cf..831aa350b1cb 100644 > --- a/drivers/net/phy/Kconfig > +++ b/drivers/net/phy/Kconfig > @@ -74,6 +74,16 @@ config MDIO_BUS_MUX_GPIO > several child MDIO busses to a parent bus. Child bus > selection is under the control of GPIO lines. > > +config MDIO_BUS_MUX_MESON_G12A > + tristate "Amlogic G12a based MDIO bus multiplexer" > + depends on ARCH_MESON || COMPILE_TEST > + depends on OF_MDIO && HAS_IOMEM > + select MDIO_BUS_MUX Hi Jerome Do you need some clock depends? > +static int g12a_mdio_switch_fn(int current_child, int desired_child, > + void *data) > +{ > + struct device *dev = data; > + struct g12a_mdio_mux *priv = dev_get_drvdata(dev); David won't like that you don't have reverse Christmas tree. You need to do the assignment to priv in the body of the code. Or can you pass data directly to dev_get_drvdata? > +static int g12a_mdio_mux_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct resource *res; > + struct g12a_mdio_mux *priv; > + int ret; Reverse Christmas tree please. > + > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + platform_set_drvdata(pdev, priv); > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + priv->regs = devm_ioremap_resource(dev, res); > + if (IS_ERR(priv->regs)) > + return PTR_ERR(priv->regs); > + > + priv->pclk = devm_clk_get(dev, "pclk"); > + if (IS_ERR(priv->pclk)) { > + ret = PTR_ERR(priv->pclk); > + if (ret != -EPROBE_DEFER) > + dev_err(dev, "failed to get peripheral clock\n"); > + return ret; > + } > + > + /* Make sure the device registers are clocked */ > + ret = clk_prepare_enable(priv->pclk); > + if (ret) { > + dev_err(dev, "failed to enable peripheral clock"); > + return ret; > + } > + > + /* Register PLL in CCF */ > + ret = g12a_ephy_glue_clk_register(dev); On error, you are not disabling the peripheral clock. > + if (ret) > + return ret; > + > + return mdio_mux_init(dev, dev->of_node, g12a_mdio_switch_fn, > + &priv->mux_handle, dev, NULL); > +} Andrew