Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF047C6FD1F for ; Sun, 19 Mar 2023 11:34:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7960285936; Sun, 19 Mar 2023 12:34:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pTRT0mHy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A643D8594F; Sun, 19 Mar 2023 12:34:36 +0100 (CET) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A16A085935 for ; Sun, 19 Mar 2023 12:34:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jbx6244@gmail.com Received: by mail-ed1-x536.google.com with SMTP id fd5so36578135edb.7 for ; Sun, 19 Mar 2023 04:34:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679225673; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=aZGsbpn4ak5l6uoAdK53q5CfKSMi0wMHDH2fYX3Xze0=; b=pTRT0mHyfZ8pH94myvFgK31dt9mmj3EVk2T/E5jx8ZSklmRSxMw4vR3cQXfSqHXCgx RXy27HvbN8Oa61kD9DW/3eJ8XkHv+Lhgdi4ijHFSyf5dnvACdE78oCBMHYPnUpZ0jxns sJYclK49zQt9vFlUOVcgvDZCTBfq2EmIa72VZJoOwscA/pvAF5XjV6YVGRBDreoJLHYX DFYziqvC0wp2cwbtCmfBgeaiLv7sBb1P6w1HTcA1EoYqDiJwels+fZwnQ8N5064XTTkZ aPbTypBcxwg8vjKtz5LRb6jwbWhbXbTtTdUYsfE56nUdGOHNaOF+oGk6d09h8CZ3fNj/ hMEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679225673; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aZGsbpn4ak5l6uoAdK53q5CfKSMi0wMHDH2fYX3Xze0=; b=hpXNW+hDwEN7x4fAvTmU8M11vmrGEKtNvs4KugyGSZx6mpJ2/29EkQAWjUf8coZzPU 0cOu+zYvtptMvIVQnoc9NIw0x3VVrFwEeFf06Taf68b1009+sAQ2pC9/OJj18l9V+FRm r4UN6ZALLNJz0UITTZjv30qp8COgTCSKc4H+/yAPgsbLQ79lIi8UB2oBWv1u+IvpHXjk xMofQc1XeWb9f1YzBAsNoKOSZTeJ6GshOnpYnz93bUV+m1KOi3h4cXWylEDYi/k3GYVu MFj3jBab6vyk8BU9fJvIq445Im6X6tMY+SVytQnkIau7JjMPafyDdrhh8LQZMrvVglSl H5DA== X-Gm-Message-State: AO0yUKUPZnk9+7zll2G/wc1uZoNxiFUWX5vGYGguKm9RQj6bG8kF/9xM eByprJYPPrH04UFlLzgU5jw= X-Google-Smtp-Source: AK7set83JdraMFqcjUg17Mg1KH33elHk/7jgIRukyLHH5YCoP41fTxz2U48cvdboFC7yPqDX2AqXlQ== X-Received: by 2002:aa7:c0c7:0:b0:4bd:8714:cc54 with SMTP id j7-20020aa7c0c7000000b004bd8714cc54mr9894787edp.36.1679225673089; Sun, 19 Mar 2023 04:34:33 -0700 (PDT) Received: from [192.168.2.2] (81-204-249-205.fixed.kpn.net. [81.204.249.205]) by smtp.gmail.com with ESMTPSA id i24-20020a508718000000b004aef147add6sm3422068edb.47.2023.03.19.04.34.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Mar 2023 04:34:32 -0700 (PDT) Message-ID: Date: Sun, 19 Mar 2023 12:34:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v1 1/6] rockchip: gpio: rk_gpio: use ROCKCHIP_GPIOS_PER_BANK as divider To: Simon Glass Cc: kever.yang@rock-chips.com, philipp.tomsich@vrull.eu, u-boot@lists.denx.de References: Content-Language: en-US From: Johan Jonker In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 3/18/23 21:20, Simon Glass wrote: > Hi Johan, > > On Thu, 16 Mar 2023 at 10:46, Johan Jonker wrote: >> >> The current divider to calculate the bank ID can change. >> Use a constant ROCKCHIP_GPIOS_PER_BANK as fixed divider. > > What is the motivation for this patch? The gpio-ranges property format: gpio-ranges = <[pin controller phandle], [GPIO controller offset], [pin controller offset], [number of pins]>; 1: Given the Rockchip TRM not all gpio-banks have 32 pins per bank. 2: The "gpio-ranges" syntax allows multiple items with variable number of pins. === Theoretical example: gpio-ranges = <&pinctrl 0 32 32>; // 32/32 => bank 1 vs. gpio-ranges = <&pinctrl 16 48 16>, // 48/16 => bank 3 vs. 48/32 => bank 1 <&pinctrl 0 32 16>; // 32/16 => bank 2 vs. 32/32 => bank 1 Both descriptions are valid. The number of pins in the second example is reduced to 16 per item. Using that as divider will give a wrong bank number. Use a constant instead. For the Rockchip situation simple parsing the first item is enough the know it's bank number for now. To do it correct one could parse a list of gpio-range items, but that makes it more complicated. From gpio.txt: Each offset runs from 0 to N. It is perfectly fine to pile any number of ranges with just one pin-to-GPIO line mapping if the ranges are concocted, but in practice these ranges are often lumped in discrete sets. > >> >> Signed-off-by: Johan Jonker >> --- >> drivers/gpio/rk_gpio.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) > > Reviewed-by: Simon Glass > >> >> diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c >> index f7ad4d68..0a2acf18 100644 >> --- a/drivers/gpio/rk_gpio.c >> +++ b/drivers/gpio/rk_gpio.c >> @@ -160,7 +160,7 @@ static int rockchip_gpio_probe(struct udevice *dev) >> 0, &args); >> if (!ret || ret != -ENOENT) { >> uc_priv->gpio_count = args.args[2]; >> - priv->bank = args.args[1] / args.args[2]; >> + priv->bank = args.args[1] / ROCKCHIP_GPIOS_PER_BANK; >> } else { >> uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK; >> end = strrchr(dev->name, '@'); >> -- >> 2.20.1 >> > > Regards, > SImon