From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B3C4C282D7 for ; Wed, 30 Jan 2019 15:33:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B5D2205C9 for ; Wed, 30 Jan 2019 15:33:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="D88VpGOx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730612AbfA3Pdh (ORCPT ); Wed, 30 Jan 2019 10:33:37 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:60910 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728529AbfA3Pdh (ORCPT ); Wed, 30 Jan 2019 10:33:37 -0500 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=lvVRGbasPnNpfPCbUm3fTYHLDAoewHZmLlfnm90VDXc=; b=D88VpGOxvRgKk18Kglcd48RuBv Qxccu5/qgGnOn3v4ztR74UJhUiDkWZMtz+6RvHI9QdzHMCMxV+1egtPtn1I4h5rhbW4c19HDJU6IF +sOBhJMAOXKmTtuPCrCWSVmtWGatcYozssK6MaImCNZdm0WAQc0AYUik35qOqAJ6NlOI=; Received: from andrew by vps0.lunn.ch with local (Exim 4.89) (envelope-from ) id 1gorrr-0003r4-8Y; Wed, 30 Jan 2019 16:33:35 +0100 Date: Wed, 30 Jan 2019 16:33:35 +0100 From: Andrew Lunn To: Pankaj Bansal Cc: Florian Fainelli , "netdev@vger.kernel.org" Subject: Re: [PATCH 1/1] netdev/phy: add MDIO bus multiplexer driven by a regmap Message-ID: <20190130153335.GD23766@lunn.ch> References: <20190130164644.3948-1-pankaj.bansal@nxp.com> <20190130164644.3948-2-pankaj.bansal@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190130164644.3948-2-pankaj.bansal@nxp.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Jan 30, 2019 at 11:22:00AM +0000, Pankaj Bansal wrote: > Add support for an MDIO bus multiplexer controlled by a regmap > device, like an FPGA. > > Tested on a NXP LX2160AQDS board which uses the "QIXIS" FPGA > attached to the i2c bus. > > Signed-off-by: Pankaj Bansal > --- > drivers/net/phy/Makefile | 2 +- > drivers/net/phy/mdio-mux-regmap.c | 170 ++++++++++++++++++++++++++++ > include/linux/mdio-mux.h | 20 ++++ > 3 files changed, 191 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile > index f41b14115fde..16145973a42f 100644 > --- a/drivers/net/phy/Makefile > +++ b/drivers/net/phy/Makefile > @@ -25,7 +25,7 @@ obj-$(CONFIG_PHYLIB) += libphy.o > obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o > obj-$(CONFIG_MDIO_BCM_UNIMAC) += mdio-bcm-unimac.o > obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o > -obj-$(CONFIG_MDIO_BUS_MUX) += mdio-mux.o > +obj-$(CONFIG_MDIO_BUS_MUX) += mdio-mux.o mdio-mux-regmap.o Please add a new KCONFIG symbol for it. And think about the depend/select statement, since you need regmap. > +/* MDIO multiplexing switch function > + * > + * This function is called by the mdio-mux layer when it thinks the mdio bus > + * multiplexer needs to switch. > + * > + * 'current_child' is the current value of the mux register (masked via > + * s->mask). > + * > + * 'desired_child' is the value of the 'reg' property of the target child MDIO > + * node. > + * > + * The first time this function is called, current_child == -1. > + * > + * If current_child == desired_child, then the mux is already set to the > + * correct bus. > + */ Please use kerneldoc formatting for this function documentation. > +int mdio_mux_regmap_init(struct device *dev, > + struct device_node *mux_node, > + void **data) > +{ > + /* Verify that the 'reg' property of each child MDIO bus does not > + * set any bits outside of the 'mask'. > + */ > + for_each_available_child_of_node(mux_node, child) { > + ret = of_property_read_u32(child, "reg", &val); > + if (ret) { > + dev_err(dev, "mdio-mux child node %pOF is missing a 'reg' property\n", child); You can probably remove "mdio-mux child node " making the line < 80, but still retain the meaning. The child node name should be sufficient to identify it. > + of_node_put(child); > + return -ENODEV; > + } > + if (val & ~s->mask) { > + dev_err(dev, "mdio-mux child node %pOF has a 'reg' value with unmasked bits\n", child); Same here. Andrew