From patchwork Wed Oct 16 07:21:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 836389 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 E36D71B0F3E for ; Wed, 16 Oct 2024 07:21:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729063317; cv=none; b=X7hJgU+yAc8dJ3R/AJwuHkFrpp7TIAGG91iBpSju6N7qk0aw+lTIh7hU/NxdLOr+s14vUyOzCCxWIj6aDeU168Vcl5jGJkrW0FD/Ypln8Is8fmfjl0ENrDRROBev20kAHSF3twATN+mE1EgBLfqHMCUt06jj+8s2Yri+Ra5HCvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729063317; c=relaxed/simple; bh=fZX5uLXA4BeanITrl+JqJGbDkF3ehpMnwgrGdcS+aHM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=InFfupSBKyJxmeNQIaqAHPmw5/RIFPZ3QIJobT0X4z/gvDp2rwOzCnjq+no7QoFdl2OFuYoOGPrf+buDB58IEP7X8Pqa3us3aAvBY7Mc1pdqTGdf34YCY+/1F3ab1nl/VTmsHyBQhQTOg1UEb99JhRo/yv2TgxAl/fOiZV7SCfo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=WXwlQ+h9; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WXwlQ+h9" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2fb5638dd57so26187751fa.0 for ; Wed, 16 Oct 2024 00:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729063314; x=1729668114; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Bh1/o0DmTgXcHb4M3eK+ULBA1+u4qfeJ4X2c+J6/Fwc=; b=WXwlQ+h9s1wNHuKF+S/Q3Gi4b8Hx0F/CIQdPxsJMLSY6RSdojpeLVfC29G0UAqDRp3 yqtlGGx9gw4kY7aaXyHQ5GdObIyznOxlqriYSvYrXA4SqFjc6d1NkbB1Ew1esgpfVaOG Qc2RLOsnyYnc3lCt7LjZ6xDdsOjr8QwNwgOi3T4BKZqVkVOmcSPFBgn/G4WywUY3lR1B /O/1ZkdMWKq6t+ZnVPr8H8LmrzpFYC7YUsZECxgXSex2R76dISBYkdH9rI1HDFkE+NnN NgHAcLPieLdJLESaFTj5pUA5Mz9C4RCCogKx3Cx0GHWwb43WWn25y9BVtc7+2BkJScLj ++XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729063314; x=1729668114; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bh1/o0DmTgXcHb4M3eK+ULBA1+u4qfeJ4X2c+J6/Fwc=; b=Zc2qJDQPYsISU/90tqSL7AkeYtfPJJ94I4BcQK5YE3SravUWJ6Ar4l7uaPf9J5DBQa 3fM+u1aEmt1keIxJIoWu4iHK0i4CH7BM+Oht1elf+QzudM9TvNIKTiOuFshHX2Ugtdq7 5NAgIfHhgvNxgGUTD+7kYuWEU5D8KcXWE10Tpb85dIcVkfVJcKlqoqTk9GMqR5jsk+WY 5PkjNdWRT3cBhKWrK8i/PHtvmFjvqfD8I3jJvKHHIbBJs7OG0j1WuOfQ6rjOcijOkeDx nNOuEefa7rnxI3nKFgg7jTnyDTt7kWY+i1OE71JKrUeArxv3IE9axuuCNk7e7e1TNFWw Vf9A== X-Gm-Message-State: AOJu0YxzAUKaiCKy5tf7dzpfPzZRZ41L9b7Jm/lNpTezTSBQ3teIJUAp 6TZT4vaCPA/5LrzecDaCFPWHbeIgiRMrCBKaywpVKDm3EcBDaz5+UoOKfuoCWig= X-Google-Smtp-Source: AGHT+IGQYS2LTltQ0bfUJZ/Qv3S3Tz7UZp727vfFOxwkrNdzBmCn2taulYm/TU13WyOH8CGWvsZY2w== X-Received: by 2002:a2e:a544:0:b0:2fa:bb65:801f with SMTP id 38308e7fff4ca-2fb61b45f86mr21564641fa.10.1729063313964; Wed, 16 Oct 2024 00:21:53 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fb642a8fdesm1289761fa.5.2024.10.16.00.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 00:21:53 -0700 (PDT) From: Linus Walleij Date: Wed, 16 Oct 2024 09:21:52 +0200 Subject: [PATCH 1/2] dt-bindings: gpio-mmio: Add ngpios property Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241016-gpio-ngpios-v1-1-f16cf154f715@linaro.org> References: <20241016-gpio-ngpios-v1-0-f16cf154f715@linaro.org> In-Reply-To: <20241016-gpio-ngpios-v1-0-f16cf154f715@linaro.org> To: Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 This adds the ngpios property to MMIO GPIO. We restrict the property to 1..63 since there is no point in 0 GPIO lines and we support up to 64bits wide registers for now. Signed-off-by: Linus Walleij --- Documentation/devicetree/bindings/gpio/gpio-mmio.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/gpio/gpio-mmio.yaml b/Documentation/devicetree/bindings/gpio/gpio-mmio.yaml index b394e058256e..87e986386f32 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-mmio.yaml +++ b/Documentation/devicetree/bindings/gpio/gpio-mmio.yaml @@ -37,7 +37,8 @@ properties: description: A list of registers in the controller. The width of each register is determined by its size. All registers must have the same width. The number - of GPIOs is set by the width, with bit 0 corresponding to GPIO 0. + of GPIOs is set by the width, with bit 0 corresponding to GPIO 0, unless + the ngpios property further restricts the number of used lines. items: - description: Register to READ the value of the GPIO lines. If GPIO line is high, @@ -74,6 +75,15 @@ properties: native-endian: true + ngpios: + minimum: 1 + maximum: 63 + description: + If this property is present the number of usable GPIO lines are restricted + to the first 0 .. ngpios lines. This is useful when the GPIO MMIO register + has 32 bits for GPIO but only the first 12 are actually connected to + real electronics, and then we set ngpios to 12. + no-output: $ref: /schemas/types.yaml#/definitions/flag description: @@ -111,6 +121,7 @@ examples: compatible = "brcm,bcm6345-gpio"; reg-names = "dirout", "dat"; reg = <0xfffe0406 2>, <0xfffe040a 2>; + ngpios = <15>; native-endian; gpio-controller; #gpio-cells = <2>; From patchwork Wed Oct 16 07:21:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 835954 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 1B6EB1B218C for ; Wed, 16 Oct 2024 07:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729063319; cv=none; b=FdiJTRLhvkZD1dngPV5UWnR/8R2dpFjEhlE0gmQGncKreSHIm2YYkuToE/+pti5H1y9PgPUl57E91XwavebcuTo2Qy+jgZTndXYtrwykAQQoc1rg0Xh82c+eSIxZqaC7px0bVD82G0Z8k7vxvIFCM9VhHYQJEjpkDY1kMaYGJOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729063319; c=relaxed/simple; bh=JBspCVFtpJjpthgUxIJaESpNK6TktgdyO35oURkfSeM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YC1L0ukqi8QntwxApQ7DFgHPDn4RQhHqciUsFQvoV7W/jzMRNihRe280qXUQC1f2pc8R1IpfdsSOdW+x7en0FGJ4Og2m8Fn41dQFo2l6XDshjc4rs2AjrsBHhlLtrHSLFu+P8SNYYbXmd4+hKJg9vOMkMMxp2dU3w1GVVyNwpf8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=fJUxM1eO; arc=none smtp.client-ip=209.85.208.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fJUxM1eO" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2fabb837ddbso78540881fa.1 for ; Wed, 16 Oct 2024 00:21:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729063316; x=1729668116; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vX2MWErp0/u4Uf4asG1ORKJB5iRHzlOAqYylAI75SY0=; b=fJUxM1eOn5AH6DMuTs9HKCViQfduKSUesf9fxjQELZTRaCcMSmAeUMFGh/EhYG547t A9VeqoA7O3msTQ2i1j2x+kV1Tl9n8VS0jp98e61A76ddb5quWeEMcI0BG6V7c/5MEEIi M8hLhO5G2bMKAQ/RrOGSm1ZYvB7bZnTzG3VtqiiIYQ+A1EgOMs6bGU/FuQkZwS6XNHSa MxI1+7nwYk1szaxLUED4XNpd+SD+j1Askn06hdcd5uoGetCpnUqayLhk+ZzdA9559H9g lWw5IZNcmOwt7aT6xysDKKL22NLP0YOCSb/3QANRgO+UEwngg02syB0VOOYWNP1ATbbj Kl5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729063316; x=1729668116; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vX2MWErp0/u4Uf4asG1ORKJB5iRHzlOAqYylAI75SY0=; b=f+mb6wWXVxc2/t0JNQZBb5eMRH2st9Gwgg7q+QjmIKrHU2RlsJaovanqM4As4ARmu/ ySrxC21T9nH+xUaC+02162PQFd+rajoqCXQJcCrjxy4+18ALhK1g/EWWtmVcWbZstjbI +bLFLP/Uw1L/1sT2pKn1ZDhXb1wWG56tkpTSKurUkZ5ywe0cXaJ2k0z1dHWDgxwgNfkM NwHUsAlBK5B194IYetjj2upIEgB+1Oaz6xdUL7MhdWhR78v1CcNBRyDEh/ZTbnL1ofb4 XeA3Ft/9MREUEzWKZhc02022TvNf6vlUHHiRotRyGj78w/X/u2syOZ61gjV4ag8K4/TQ NZ9Q== X-Gm-Message-State: AOJu0Ywwh9Hcj+fkrWn/mAKyfoRSVmzk9CX0x9SRCIeDJ5J+DX4vfflp TDSCM0lHKW4CX2RJr7T7uWswW0NXKTTHTayS6mxbTPa/pX+tnoON1fJV04LbL2c= X-Google-Smtp-Source: AGHT+IHbasEV4OEbnj6oWKrBr1odwTwS9/GUyVEzEp30I2Bp530ocpSedDMrkezLwO0TtyqXQOJKjw== X-Received: by 2002:a2e:be20:0:b0:2fb:5c84:929b with SMTP id 38308e7fff4ca-2fb5c849623mr44326191fa.36.1729063316217; Wed, 16 Oct 2024 00:21:56 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fb642a8fdesm1289761fa.5.2024.10.16.00.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 00:21:55 -0700 (PDT) From: Linus Walleij Date: Wed, 16 Oct 2024 09:21:53 +0200 Subject: [PATCH 2/2] gpio: mmio: Parse ngpios property Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241016-gpio-ngpios-v1-2-f16cf154f715@linaro.org> References: <20241016-gpio-ngpios-v1-0-f16cf154f715@linaro.org> In-Reply-To: <20241016-gpio-ngpios-v1-0-f16cf154f715@linaro.org> To: Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 This makes the MMIO GPIO driver parse the ngpios property from devices instatiated directly from the device tree so we can further restrict the number of GPIOs down from the number of bits on the target register. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mmio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c index d89e78f0ead3..9e944c191551 100644 --- a/drivers/gpio/gpio-mmio.c +++ b/drivers/gpio/gpio-mmio.c @@ -694,6 +694,7 @@ MODULE_DEVICE_TABLE(of, bgpio_of_match); static struct bgpio_pdata *bgpio_parse_fw(struct device *dev, unsigned long *flags) { struct bgpio_pdata *pdata; + u32 ngpios; if (!dev_fwnode(dev)) return NULL; @@ -704,6 +705,9 @@ static struct bgpio_pdata *bgpio_parse_fw(struct device *dev, unsigned long *fla pdata->base = -1; + if (!device_property_read_u32(dev, "ngpios", &ngpios)) + pdata->ngpios = ngpios; + if (device_is_big_endian(dev)) *flags |= BGPIOF_BIG_ENDIAN_BYTE_ORDER;