Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp341937rdb; Mon, 18 Sep 2023 17:49:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3weTd5x1KzL++NtqFu9UaAuTTJhfvXtNSLNoU9eD4CwLHRySvj7DpI6SRjmO1lJcOj1DF X-Received: by 2002:a05:6a00:1a56:b0:68b:bf33:2957 with SMTP id h22-20020a056a001a5600b0068bbf332957mr10523209pfv.22.1695084593858; Mon, 18 Sep 2023 17:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695084593; cv=none; d=google.com; s=arc-20160816; b=clvDdKxlBkm1xDgGWOQJ8Id3KzjdVJX0eMNC8qNdrlJGsTtVI6o+INrxCk8YTu20eu Ql1Q8fKlUFCwQVqTyZzGVfP9s9T+YZGzwUsi5AJZoqApj+0HEgBR1cUtcprb9HKadgHl ac88h8E+ceMXWt4EKvsnmvLDott1yEHrIDl6kzb9kCMIRe6klZ2vyn3zRLhzyRsTpkw1 BLb6DoKAtDrNMCDQIk8tvBK2SKoizCJ+J6FU80Em1KOetvZVYFsoOWRD52Oj+chI6sXO +lSdPayW/tUcvH3RTY/VQZLgn8L2tb6TDmEy/5rkM/Ch0O66FaQTWdX5C12sc6cYpTs/ BXeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4dwqbabpRXtAFfSri7LBE3DGA0CnqUUPOENxivi1UzE=; fh=INm4myRxNPT9b73eFR05FWh2cDosJdY43dfgBn8X4XA=; b=Dd4rd2KU5KQ6aC0VAUzAaRdPKhr73qLYDJE12XwxYQlCifTgowjJa0sy/tY4jtmAWU dnT4l9vwalDi6+2azLwDDlxlsID3HA3on04jtQdkk1NpeShnjt1XSyqpVs1Nwb5b/GzI jENc1dk5V/PwOCWEUcb++TpUhBHst4WrDa/OChJT95AUBAzunw5d4wj+9rDALb9a83U3 3djfBCU0JUtDmsgUJf362fj27zYN2VnFj+b1q5cCri+9QyuW24TmbnD3hRNq/o4VnJcb jWaKUY0+jwEtQK7IoWGy7UBbAJNfm2a2Fu/HMOKDIBJfUv+daaHb1x+Cox4EUh4rVWjM knWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="lzrXogp/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x11-20020a056a00270b00b0068ff333d768si8624782pfv.384.2023.09.18.17.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 17:49:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="lzrXogp/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B0724802945F; Mon, 18 Sep 2023 10:07:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231382AbjIRRH4 (ORCPT + 99 others); Mon, 18 Sep 2023 13:07:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231354AbjIRRHv (ORCPT ); Mon, 18 Sep 2023 13:07:51 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1698FE3; Mon, 18 Sep 2023 10:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=4dwqbabpRXtAFfSri7LBE3DGA0CnqUUPOENxivi1UzE=; b=lzrXogp/kL8mBy8K9gKe6RuiQk 2joE3ilZNPoITCwSoJQJn6JMlDtBYr8oVbiH9gFaWl7rIExh6fiqpmpD17Y1b/vrycqL3J20/Cebh AfHqNIDExteB9DzPDiZ7+czGCHJ6WWBa9Hte8Uepc1WOVbDdJGXAy7nIgGfF6OFaLE1M=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1qiGwi-006oFv-Mn; Mon, 18 Sep 2023 18:18:00 +0200 Date: Mon, 18 Sep 2023 18:18:00 +0200 From: Andrew Lunn To: Jay Monkman Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Piergiorgio Beruto , Arndt Schuebel Subject: Re: [PATCH 3/4] net: phy: Add GPIO and DT support to NCN26000 Message-ID: <4242c63c-eec2-4168-ae59-b4fac8cdea3e@lunn.ch> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 10:07:54 -0700 (PDT) On Mon, Sep 18, 2023 at 01:59:03AM -0500, Jay Monkman wrote: > > This adds GPIO support and devicetree configuration for > the NCN26000 PHY. Please Cc: the GPIO maintainers. They have specialist knowledge that netdev reviews like me don't have. You probably want to separate this out into a patch of its own, since you don't want to be spamming GPIO people with a MAC driver etc. > +// clause 45 vendor specific registers > +#define NCN26000_REG_PHYCFG1_MMD MDIO_MMD_VEND2 Please use MDIO_MMD_VEND2 directly, so it is clear you are in vendor space. > +static int ncn26000_gpio_request(struct gpio_chip *gc, unsigned int offset) > +{ > + struct ncn26000_priv *priv = gpiochip_get_data(gc); > + > + if (offset > 2) > + return -ENODEV; Can that happen? I would expect the GPIO core to perform this validation? > + > + if (priv->gpiomask & (1 << offset)) > + return 0; > + > + return -EBUSY; Is this function even needed? All it seems to do is validation. No resources are actually reserved. > +static void ncn26000_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) > +{ > + struct ncn26000_priv *priv = gpiochip_get_data(gc); > + u32 dio_reg; > + > + dio_reg = phy_read(priv->phydev, NCN26000_REG_DIO_CONFIG); > + > + switch (offset) { > + case 0: > + if (!val == !(priv->diocfg & NCN26000_DIO_CFG_VAL0)) > + dio_reg |= NCN26000_DIO_CFG_VAL0; > + else > + dio_reg &= ~NCN26000_DIO_CFG_VAL0; > + break; > + > + case 1: > + if (!val == !(priv->diocfg & NCN26000_DIO_CFG_VAL1)) > + dio_reg |= NCN26000_DIO_CFG_VAL1; > + else > + dio_reg &= ~NCN26000_DIO_CFG_VAL1; > + break; > + > + default: > + dev_err(priv->dev, "invalid GPIO offset: %d\n", offset); > + return; > + } > + > + phy_write(priv->phydev, NCN26000_REG_DIO_CONFIG, dio_reg); You are doing a read/modify/write here. How does locking work? > +static int ncn26000_gpio_get_dir(struct gpio_chip *gc, unsigned int offset) > +{ > + return GPIO_LINE_DIRECTION_OUT; > +} So they are all GPO? No GPI or GPIO? > +static int ncn26000_gpio_setup(struct ncn26000_priv *priv) > +{ > + struct gpio_chip *gc = &priv->gpio_chip; > + > + gc->request = ncn26000_gpio_request; > + gc->get_direction = ncn26000_gpio_get_dir; > + gc->direction_output = ncn26000_gpio_dir_out; > + gc->set = ncn26000_gpio_set; > + gc->label = "ncn26000-gpio"; > + gc->base = -1; > + gc->ngpio = 2; > + gc->parent = priv->dev; > + gc->owner = THIS_MODULE; > + > + return devm_gpiochip_add_data(priv->dev, gc, priv); > +} Am i right in saying that the rest of this patch has nothing to do with GPIOs? Please split it up into multiple patches. Andrew