From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43DB51850B5 for ; Wed, 28 Aug 2024 15:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724858678; cv=none; b=qlTRNAD3Gnb9KIeyNhsYa7VNoILgi+kyULkbI1j6Ihvzcen7u3Hx9g0evWuAhYPQdTmTIjaUA2FJhFLWJG62h0g/TbjhL0WooPqyQs2S6IuqLWIm9SCnjOcvfhZv8eWcZDhj4A3ybRpMnU0fbRFfAIGdaDuD6EBtjH2Wj7x/MpI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724858678; c=relaxed/simple; bh=sECdKZWmQ58VFDoOPO3d4pP0VUHs2KL2y5lS6y1lA/o=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LJnPPF7XxY5xTOd9zfevQeoI0OklMJNBkG0sifF9WLm9b/kBeN/387BUG6dZiMm7HBK8JQB+Z6S/y/C3QXnfC/bMqRwMgqnTDG9THvoTd/d++yno9sB/A8DKpf9YMy2Ik8M9Szldp9q7HxrHLwmWnTA28Zvhjk8pl64OiCu2LFg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=BRNmXv8y; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="BRNmXv8y" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a868b739cd9so824324666b.2 for ; Wed, 28 Aug 2024 08:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1724858673; x=1725463473; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :date:from:from:to:cc:subject:date:message-id:reply-to; bh=RccO/6aYSzsD64ZgEXVUnoiwa51kK0FzwBqBJe1629o=; b=BRNmXv8yjiovcJXbjKFM8khnJr8M2n/lU+gyfFIF2F1cYXcaDIYgkKMneAp4GU3mCI hfc+ugTygrpALphhIZsu7jejr3nKDTdXhLHf3xqgkSVZi8fG6nuyqeAKSBGF6iXF467Y DFGrNpKyHlpMOWLmY+lLcsxDztm42qJtVQSDZ2fd/ppHeL+qrFdrq330slxPIGz6R5Ch 131dWnTV1L5GYI7aRMit8Z0z+qhvoKLhm7U6E4XuAS58pJ/KURoI7hOZn1kpor3eUZ3G 5CVVTwcyoWRONBdTwbzJuIZZCumB0qA9HkG0ONnMzlnQwtHaOUqhfc2NSs+z+8P4CSSj knUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724858673; x=1725463473; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RccO/6aYSzsD64ZgEXVUnoiwa51kK0FzwBqBJe1629o=; b=itZX88wXJzf0OiVSfq9zlsFklnCOA/AhwDuY5N/9zwcIn2yG6RwrvKX5m/dw2iWINo BaxfSN3QtteezD+Iv3QBGj6XzhHTVVXuYy9mz31NxxwqeqvBTUBc4CHcZvlnHlARYleK VJFqXdlhE/G1mUwHrzisDcRG07YG45bwdgPzNL8u7V4sqyiZpEhjGMBxiM0tPJaM9vk6 bc1oZwNuNzAKeJaWLs1bz2BYo/kouZoxnGqaWLQ5hB35s3YZxI6c4BOJaCLE3IDgtdQ8 PanteBKoaX9TVZV+9V3PgwtVaD2knu8fKK80LehU2+CoeVEm6unDKoLHuf4351Y6ttC5 y0HA== X-Forwarded-Encrypted: i=1; AJvYcCWPcZ2KtnrMQ6/9k25NuVNQwPApyBrnuGtf49VZuN5pjdRVEKjWvrGwekpCgCFk1/tAnyaLWOtGtI0=@vger.kernel.org X-Gm-Message-State: AOJu0YyUG9t9OcB3TjtSyc3E4n+l+kV3VHJMa4kXaRgPe7SXixBFiJ9N TYtsfkdCBYpUvHmXLgdvfvztyXEhUGDsGbyvfOLzYaSb97lWljCwkvG61Ij/bqU= X-Google-Smtp-Source: AGHT+IEGTIMf9HDmr3RD/PvAk+4C11JysnBRyFuK/mQqbOsClKq28ul4IglJqfFC2hAOgC6a2khVvQ== X-Received: by 2002:a17:906:6a29:b0:a7a:a7b8:adae with SMTP id a640c23a62f3a-a870a94fe14mr219949166b.4.1724858673188; Wed, 28 Aug 2024 08:24:33 -0700 (PDT) Received: from localhost (host-80-182-198-72.retail.telecomitalia.it. [80.182.198.72]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a86e594a599sm255662266b.201.2024.08.28.08.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 08:24:32 -0700 (PDT) From: Andrea della Porta X-Google-Original-From: Andrea della Porta Date: Wed, 28 Aug 2024 17:24:39 +0200 To: Linus Walleij Cc: Andrea della Porta , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Catalin Marinas , Will Deacon , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nicolas Ferre , Claudiu Beznea , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Saravana Kannan , Bjorn Helgaas , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-arch@vger.kernel.org, Lee Jones , Andrew Lunn , Stefan Wahren Subject: Re: [PATCH 07/11] pinctrl: rp1: Implement RaspberryPi RP1 gpio support Message-ID: Mail-Followup-To: Linus Walleij , Andrea della Porta , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Catalin Marinas , Will Deacon , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nicolas Ferre , Claudiu Beznea , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Saravana Kannan , Bjorn Helgaas , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-arch@vger.kernel.org, Lee Jones , Andrew Lunn , Stefan Wahren References: Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Hi Linus, On 10:59 Mon 26 Aug , Linus Walleij wrote: > Hi Andrea, > > thanks for your patch! Thanks for your review! > > On Tue, Aug 20, 2024 at 4:36 PM Andrea della Porta > wrote: > > > The RP1 is an MFD supporting a gpio controller and /pinmux/pinctrl. > > Add minimum support for the gpio only portion. The driver is in > > pinctrl folder since upcoming patches will add the pinmux/pinctrl > > support where the gpio part can be seen as an addition. > > > > Signed-off-by: Andrea della Porta > (...) > > > +#include > > +#include > (...) > > > +static void rp1_pad_update(struct rp1_pin_info *pin, u32 clr, u32 set) > > +{ > > + u32 padctrl = readl(pin->pad); > > + > > + padctrl &= ~clr; > > + padctrl |= set; > > + > > + writel(padctrl, pin->pad); > > +} > > Looks a bit like a reimplementation of regmap-mmio? If you want to do > this why not use regmap-mmio? Agreed. I can leverage regmail_field to get rid of the reimplemented code for the pin->pad register region. Do you think it could be worth using regmap-mmio also on pin->gpio, pin->inte, pin->ints and pin->rio even though they are not doing any special field manipulation as the pin->pad case? > > > +static void rp1_set_dir(struct rp1_pin_info *pin, bool is_input) > > +{ > > + int offset = is_input ? RP1_CLR_OFFSET : RP1_SET_OFFSET; > > + > > + writel(1 << pin->offset, pin->rio + RP1_RIO_OE + offset); > > If you include bitops.h what about: > > writel(BIT(pin->offset), pin->rio + RP1_RIO_OE + offset); Ack. > > > +static int rp1_get_value(struct rp1_pin_info *pin) > > +{ > > + return !!(readl(pin->rio + RP1_RIO_IN) & (1 << pin->offset)); > > +} > > Also here Ack. > > > + > > +static void rp1_set_value(struct rp1_pin_info *pin, int value) > > +{ > > + /* Assume the pin is already an output */ > > + writel(1 << pin->offset, > > + pin->rio + RP1_RIO_OUT + (value ? RP1_SET_OFFSET : RP1_CLR_OFFSET)); > > +} > > And here Ack. > > > +static int rp1_gpio_set_config(struct gpio_chip *chip, unsigned int offset, > > + unsigned long config) > > +{ > > + struct rp1_pin_info *pin = rp1_get_pin(chip, offset); > > + unsigned long configs[] = { config }; > > + > > + return rp1_pinconf_set(pin, offset, configs, > > + ARRAY_SIZE(configs)); > > +} > > Nice that you implement this! Thanks :) > > > +static void rp1_gpio_irq_config(struct rp1_pin_info *pin, bool enable) > > +{ > > + writel(1 << pin->offset, > > + pin->inte + (enable ? RP1_SET_OFFSET : RP1_CLR_OFFSET)); > > BIT() Ack. Many thanks, Andrea > > Yours, > Linus Walleij