From patchwork Sat Oct 7 12:30:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 730716 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35E831C6B3 for ; Sat, 7 Oct 2023 12:30:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="E1rsKkeq" Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D4F6BF for ; Sat, 7 Oct 2023 05:30:52 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-50435ad51bbso3712409e87.2 for ; Sat, 07 Oct 2023 05:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696681851; x=1697286651; 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=yEmvs2sZsMEqyjDKDTqp8o0I9KZnW9keEx0nKVJ6imY=; b=E1rsKkeqfbhPv+PaYrCI5RAnovDbviwMOXYMwqKOSw+2g2/99UBjqGtUxIoZEVik8c RuzZoD1s8bUEfqmXCpJzTETwcQjUdfWA1Ijk8eOKlFrQpqWlUlIPcB2MPovlUE72PRsT tH2G5BftIY9eQ8ApEybYikhsFxCgOtRlfyKnYjcE6iGjBl0rlg/Cck8FZ0OgC6hI6rtk 2QUhKnAxtI+CB+FWm1pfKrGN/BCkWQJt1GjPta/6hQMSHbK9sBlLLRlFWnq8ASBkWjm2 7MLG1vcE5pSGutXAoQ9NXP9S6nE5x12IyIDltyikRpm0DEkrVWR1Fd09h+pIB8cdOA2L 2f9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696681851; x=1697286651; 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=yEmvs2sZsMEqyjDKDTqp8o0I9KZnW9keEx0nKVJ6imY=; b=FdKDeGkvk1BM42jLBpFoA3gU3Ps0laMzLZdsPkHaYOR8UA/cYO//UaWBzEIMIn/1ed hASTIXtZ61wCrjbDM4QtlWDzdgu374jdf1UfefO9PIBQAbdT2L7JUDfe7x/QzAKyEjxF RPxd/R0/uH/6Ci3aOqbqzJH0LOGY7OvJIEJtFjlH8aK56fWVjcY0Z3FRTtLBVjBkCkYf D+fXsz0XHYQoE+5WprB3H/Y/EJP4/RaTQjKCbl66xG9FI57cg1oDHZ4B+JYi5UTX/eXG O5lnH52pgQK030VLcw6JAspXhz/lwrQ2n8QGEkV6nloYackmEf7HC4rYouYlxOphSBgO q/OA== X-Gm-Message-State: AOJu0Yxbp/6gstilZTcjouPUkroEr2dSD+F8au0FjkUgwmqptx3NX+E5 EIXvdg2TJiSgHJIoranYomN84A== X-Google-Smtp-Source: AGHT+IEQ66aqbACFExWgB2QTaCVfRmQI5Nr7NO/lZ/Hue+rmUnJ+3qMV9hvqZo1jU5FMhEb961JahQ== X-Received: by 2002:a19:2d56:0:b0:505:8075:7c17 with SMTP id t22-20020a192d56000000b0050580757c17mr8406645lft.22.1696681850816; Sat, 07 Oct 2023 05:30:50 -0700 (PDT) Received: from [192.168.1.2] (c-21d3225c.014-348-6c756e10.bbcust.telenor.se. [92.34.211.33]) by smtp.gmail.com with ESMTPSA id 28-20020ac25f5c000000b005068d6de988sm410569lfz.226.2023.10.07.05.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 05:30:50 -0700 (PDT) From: Linus Walleij Date: Sat, 07 Oct 2023 14:30:49 +0200 Subject: [PATCH v2 1/2] rtc: rtc7301: Rewrite bindings in schema Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231007-rtc-7301-regwidth-v2-1-c913aa95f666@linaro.org> References: <20231007-rtc-7301-regwidth-v2-0-c913aa95f666@linaro.org> In-Reply-To: <20231007-rtc-7301-regwidth-v2-0-c913aa95f666@linaro.org> To: Alessandro Zummo , Alexandre Belloni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Akinobu Mita , Howard Harte Cc: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net This rewrites the Epson RTC7301 bindings to use YAML schema, and adds a property for "reg-io-width" as used in several other bindings to account for different register strides. The USRobotics USR8200 uses the byte IO width. Signed-off-by: Linus Walleij Reviewed-by: Rob Herring --- .../devicetree/bindings/rtc/epson,rtc7301.txt | 16 ------- .../devicetree/bindings/rtc/epson,rtc7301.yaml | 50 ++++++++++++++++++++++ 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/Documentation/devicetree/bindings/rtc/epson,rtc7301.txt b/Documentation/devicetree/bindings/rtc/epson,rtc7301.txt deleted file mode 100644 index 5f9df3f1467c..000000000000 --- a/Documentation/devicetree/bindings/rtc/epson,rtc7301.txt +++ /dev/null @@ -1,16 +0,0 @@ -EPSON TOYOCOM RTC-7301SF/DG - -Required properties: - -- compatible: Should be "epson,rtc7301sf" or "epson,rtc7301dg" -- reg: Specifies base physical address and size of the registers. -- interrupts: A single interrupt specifier. - -Example: - -rtc: rtc@44a00000 { - compatible = "epson,rtc7301dg"; - reg = <0x44a00000 0x10000>; - interrupt-parent = <&axi_intc_0>; - interrupts = <3 2>; -}; diff --git a/Documentation/devicetree/bindings/rtc/epson,rtc7301.yaml b/Documentation/devicetree/bindings/rtc/epson,rtc7301.yaml new file mode 100644 index 000000000000..0937b094821d --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/epson,rtc7301.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rtc/epson,rtc7301.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Epson Toyocom RTC-7301SF/DG + +description: + The only difference between the two variants is the packaging. + The DG variant is a DIL package, and the SF variant is a flat + package. + +maintainers: + - Akinobu Mita + +properties: + compatible: + enum: + - epson,rtc7301dg + - epson,rtc7301sf + + reg: + maxItems: 1 + + reg-io-width: + description: + The size (in bytes) of the IO accesses that should be performed + on the device. If not specified, the default is 4. + enum: [1, 4] + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + rtc: rtc@44a00000 { + compatible = "epson,rtc7301dg"; + reg = <0x44a00000 0x10000>; + reg-io-width = <4>; + interrupt-parent = <&axi_intc_0>; + interrupts = <3 2>; + }; From patchwork Sat Oct 7 12:30:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 730542 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67F3D1F5EA for ; Sat, 7 Oct 2023 12:30:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="W9OLyJmU" Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E146FC5 for ; Sat, 7 Oct 2023 05:30:53 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5045cb9c091so3981816e87.3 for ; Sat, 07 Oct 2023 05:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696681852; x=1697286652; 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=mLPFclkATy4LIwppN+u/n/AESvBYT+nNmBG9F7Vienk=; b=W9OLyJmU3Ve9iNg8C/RatCORpDZoC4fMk+WSRNFA23rBojAwg421BgmDtt1QjiihIP JaSO2YlMWsYdyvbF/aFlyCuKIvRc+/s210RnvkON5IJOH2hmsJt6U4SYTcw+/GYhUNnK GtBF8+ppOucZC3XnIt0QcRi9upjzAPN/RWWjkVxIMD/XttHjD5FH906qYH/SkOJOUCqg fJM/TApyRvhSDqVamf75xJ9ukmS9pIOjJjCIVDOR+4zJ2zMVkWNSmbf3wkJ5NZUln+Gp kdRP7pWECRx+GFfPsY2CsMqEfS6CrHmudJ6RJD1hn9TOQGnj3eoduUcLYuDk645JiWde ONng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696681852; x=1697286652; 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=mLPFclkATy4LIwppN+u/n/AESvBYT+nNmBG9F7Vienk=; b=nJwQ4mMTPDxq+s31OxIjlQB0hCxRSSBH3lnHd68GaWD73SzZSUv2HMx4F2CbeUTHLM fZz4hTSGCwyHzhrcf4Te7Y1eYUOcaGgaH+03KvhXJWea3FzB69MZVtNASkYQn/Sk470e 3L3IOoM8jr4sIr+Et99KHOS9U4VikTIElcTnLCPLb0ME96bhzzF5VEKRONFuZgu+dyDh 5BgOrXbKHDHYbbVxBr8Y3uASNmwnQ8HgT4Jk2QNmT+mCChUWQNjRWOt7Ctwe+CnwN5YS wcLjJkNj7EkWftdUlWqRoohboww79hgVMVL5NJxsv0+tL9/+v0C2LPIsjZElFK1L84Ek cgNQ== X-Gm-Message-State: AOJu0YzSO/yTJSEzcDSXF4vbBH29sYU1GDOX7mB81WaBxi0jdJlzHoau ykD3VAc2X3svZXlqFZH+Klw6tQ== X-Google-Smtp-Source: AGHT+IFfVwOKbEvfCSN6p85x/+ek9Cp7A2gMPeASsX4kzVNHmRMBMp8jA/k+CbOdx3BU+9aXusB9/w== X-Received: by 2002:a05:6512:531:b0:4fd:fabf:b6ee with SMTP id o17-20020a056512053100b004fdfabfb6eemr8753564lfc.9.1696681851775; Sat, 07 Oct 2023 05:30:51 -0700 (PDT) Received: from [192.168.1.2] (c-21d3225c.014-348-6c756e10.bbcust.telenor.se. [92.34.211.33]) by smtp.gmail.com with ESMTPSA id 28-20020ac25f5c000000b005068d6de988sm410569lfz.226.2023.10.07.05.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 05:30:51 -0700 (PDT) From: Linus Walleij Date: Sat, 07 Oct 2023 14:30:50 +0200 Subject: [PATCH v2 2/2] rtc: rtc7301: Support byte-addressed IO Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231007-rtc-7301-regwidth-v2-2-c913aa95f666@linaro.org> References: <20231007-rtc-7301-regwidth-v2-0-c913aa95f666@linaro.org> In-Reply-To: <20231007-rtc-7301-regwidth-v2-0-c913aa95f666@linaro.org> To: Alessandro Zummo , Alexandre Belloni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Akinobu Mita , Howard Harte Cc: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,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 The old RTC7301 driver in OpenWrt used byte access, but the current mainline Linux driver uses 32bit word access. Make this configurable using device properties using the standard property "reg-io-width" in e.g. device tree. This is needed for the USRobotics USR8200 which has the chip connected using byte accesses. Debugging and testing by Howard Harte. Signed-off-by: Linus Walleij --- drivers/rtc/rtc-r7301.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-r7301.c b/drivers/rtc/rtc-r7301.c index 5dbaeb7af648..ef913cf8593f 100644 --- a/drivers/rtc/rtc-r7301.c +++ b/drivers/rtc/rtc-r7301.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -55,12 +56,23 @@ struct rtc7301_priv { u8 bank; }; -static const struct regmap_config rtc7301_regmap_config = { +/* + * When the device is memory-mapped, some platforms pack the registers into + * 32-bit access using the lower 8 bits at each 4-byte stride, while others + * expose them as simply consecutive bytes. + */ +static const struct regmap_config rtc7301_regmap_32_config = { .reg_bits = 32, .val_bits = 8, .reg_stride = 4, }; +static const struct regmap_config rtc7301_regmap_8_config = { + .reg_bits = 8, + .val_bits = 8, + .reg_stride = 1, +}; + static u8 rtc7301_read(struct rtc7301_priv *priv, unsigned int reg) { int reg_stride = regmap_get_reg_stride(priv->regmap); @@ -356,7 +368,9 @@ static int __init rtc7301_rtc_probe(struct platform_device *dev) void __iomem *regs; struct rtc7301_priv *priv; struct rtc_device *rtc; + static const struct regmap_config *mapconf; int ret; + u32 val; priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -366,8 +380,25 @@ static int __init rtc7301_rtc_probe(struct platform_device *dev) if (IS_ERR(regs)) return PTR_ERR(regs); + ret = device_property_read_u32(&dev->dev, "reg-io-width", &val); + if (ret) + /* Default to 32bit accesses */ + val = 4; + + switch (val) { + case 1: + mapconf = &rtc7301_regmap_8_config; + break; + case 4: + mapconf = &rtc7301_regmap_32_config; + break; + default: + dev_err(&dev->dev, "invalid reg-io-width %d\n", val); + return -EINVAL; + } + priv->regmap = devm_regmap_init_mmio(&dev->dev, regs, - &rtc7301_regmap_config); + mapconf); if (IS_ERR(priv->regmap)) return PTR_ERR(priv->regmap);