[PATCH 0/6] pinctrl: mediatek: Fix gpio-ranges and include guard issues

Akari Tsuyukusa posted 6 patches 3 weeks, 5 days ago
arch/arm64/boot/dts/mediatek/mt6795.dtsi              | 2 +-
arch/arm64/boot/dts/mediatek/mt7981b.dtsi             | 2 +-
arch/arm64/boot/dts/mediatek/mt7986a.dtsi             | 2 +-
drivers/pinctrl/mediatek/pinctrl-mtk-mt6779.h         | 2 +-
drivers/pinctrl/mediatek/pinctrl-mtk-mt8188.h         | 2 +-
include/dt-bindings/pinctrl/mediatek,mt8188-pinfunc.h | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
[PATCH 0/6] pinctrl: mediatek: Fix gpio-ranges and include guard issues
Posted by Akari Tsuyukusa 3 weeks, 5 days ago
While looking at MediaTek's Pinctrl driver and device tree, I discovered
that on some SoCs, the gpio-ranges count was a little less than the pins
defined. This means that the last pin will no longer be available.

And fixing this issue, I also discovered that the #endif comment in the
include guard for some header files was different from the macro name at
the beginning. These issues do not affect the compiled kernel, but they
affect the readability and consistency of the code.

This series addresses the cases that can be confirmed correct without
requiring datasheet verification:

- mt6795 : gpio-ranges 196 -> 197
- mt7981b: gpio-ranges 56 -> 57
- mt7986a: gpio-ranges 100 -> 101
- mt6779 : include guard #endif comment fix
- mt8188 : include guard #endif comment fix (two files)

The following additional issues were identified during this investigation
but are not included in this series as they require further analysis
or datasheet confirmation:

MT6779: gpio-ranges = <&pio 0 0 210>;
    This matches the number of pins, but GPIO203 to 209 don't have
    GPIO function, and the driver also has no control over those pins.
    Probably needs to be fixed to "gpio-ranges = <&pio 0 0 203>;"

MT8183: gpio-ranges = <&pio 0 0 192>;
    This seems correct because it matches "pinctrl-mtk-mt8183.h".
    But, mode/dir/di/do are defined from pin 0 to 192.
    "pinctrl-mt8183.c" looks wrong.

MT8188: gpio-ranges = <&pio 0 0 176>;
    According to "pinctrl-mtk-mt8188.h", GPIO0 to 176 have GPIO function,
    and GPIO177 to 189 are EINT only pin, but mode/dir/di/do are defined
    from pin 0 to 177. "pinctrl-mt8188.c" is likely to be wrong.
    At least "176" is wrong, probably "gpio-ranges = <&pio 0 0 177>;"

MT8192: gpio-ranges = <&pio 0 0 220>;
    "pinctrl-mtk-mt8192.h" defines GPIO0 to 227 which have GPIO function,
    but mode/dir/di/do are defined from pin 0 to 228.
    "pinctrl-mt8192.c" looks wrong.
    Also, probably "gpio-ranges = <&pio 0 0 229>;"

MT8195: gpio-ranges = <&pio 0 0 144>;
    Like MT8188, GPIO144 to 164 don't have GPIO function,
    but mode/dir/di/do are defined from pin 0 to pin 144.
    "pinctrl-mt8195.c" is likely to be wrong.


Akari Tsuyukusa (6):
  arm64: dts: mediatek: mt6795: Fix gpio-ranges pin count
  arm64: dts: mediatek: mt7981b: Fix gpio-ranges pin count
  arm64: dts: mediatek: mt7986a: Fix gpio-ranges pin count
  pinctrl: mediatek: mt6779: Fix include guard comment in the header
  pinctrl: mediatek: mt8188: Fix include guard comment in the header
  dt-bindings: pinctrl: mediatek: mt8188: Fix include guard comment

 arch/arm64/boot/dts/mediatek/mt6795.dtsi              | 2 +-
 arch/arm64/boot/dts/mediatek/mt7981b.dtsi             | 2 +-
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi             | 2 +-
 drivers/pinctrl/mediatek/pinctrl-mtk-mt6779.h         | 2 +-
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8188.h         | 2 +-
 include/dt-bindings/pinctrl/mediatek,mt8188-pinfunc.h | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.53.0
Re: [PATCH 0/6] pinctrl: mediatek: Fix gpio-ranges and include guard issues
Posted by AngeloGioacchino Del Regno 3 weeks, 5 days ago
Il 12/03/26 05:15, Akari Tsuyukusa ha scritto:
> While looking at MediaTek's Pinctrl driver and device tree, I discovered
> that on some SoCs, the gpio-ranges count was a little less than the pins
> defined. This means that the last pin will no longer be available.
> 
> And fixing this issue, I also discovered that the #endif comment in the
> include guard for some header files was different from the macro name at
> the beginning. These issues do not affect the compiled kernel, but they
> affect the readability and consistency of the code.
> 
> This series addresses the cases that can be confirmed correct without
> requiring datasheet verification:
> 
> - mt6795 : gpio-ranges 196 -> 197
> - mt7981b: gpio-ranges 56 -> 57
> - mt7986a: gpio-ranges 100 -> 101
> - mt6779 : include guard #endif comment fix
> - mt8188 : include guard #endif comment fix (two files)
> 
> The following additional issues were identified during this investigation
> but are not included in this series as they require further analysis
> or datasheet confirmation:
> 
> MT6779: gpio-ranges = <&pio 0 0 210>;
>      This matches the number of pins, but GPIO203 to 209 don't have
>      GPIO function, and the driver also has no control over those pins.
>      Probably needs to be fixed to "gpio-ranges = <&pio 0 0 203>;"
> 
> MT8183: gpio-ranges = <&pio 0 0 192>;
>      This seems correct because it matches "pinctrl-mtk-mt8183.h".
>      But, mode/dir/di/do are defined from pin 0 to 192.
>      "pinctrl-mt8183.c" looks wrong.
> 
> MT8188: gpio-ranges = <&pio 0 0 176>;
>      According to "pinctrl-mtk-mt8188.h", GPIO0 to 176 have GPIO function,
>      and GPIO177 to 189 are EINT only pin, but mode/dir/di/do are defined
>      from pin 0 to 177. "pinctrl-mt8188.c" is likely to be wrong.
>      At least "176" is wrong, probably "gpio-ranges = <&pio 0 0 177>;"
> 
> MT8192: gpio-ranges = <&pio 0 0 220>;
>      "pinctrl-mtk-mt8192.h" defines GPIO0 to 227 which have GPIO function,
>      but mode/dir/di/do are defined from pin 0 to 228.
>      "pinctrl-mt8192.c" looks wrong.
>      Also, probably "gpio-ranges = <&pio 0 0 229>;"
> 
> MT8195: gpio-ranges = <&pio 0 0 144>;
>      Like MT8188, GPIO144 to 164 don't have GPIO function,
>      but mode/dir/di/do are defined from pin 0 to pin 144.
>      "pinctrl-mt8195.c" is likely to be wrong.
> 

The whole series is

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

> 
> Akari Tsuyukusa (6):
>    arm64: dts: mediatek: mt6795: Fix gpio-ranges pin count
>    arm64: dts: mediatek: mt7981b: Fix gpio-ranges pin count
>    arm64: dts: mediatek: mt7986a: Fix gpio-ranges pin count
>    pinctrl: mediatek: mt6779: Fix include guard comment in the header
>    pinctrl: mediatek: mt8188: Fix include guard comment in the header
>    dt-bindings: pinctrl: mediatek: mt8188: Fix include guard comment
> 
>   arch/arm64/boot/dts/mediatek/mt6795.dtsi              | 2 +-
>   arch/arm64/boot/dts/mediatek/mt7981b.dtsi             | 2 +-
>   arch/arm64/boot/dts/mediatek/mt7986a.dtsi             | 2 +-
>   drivers/pinctrl/mediatek/pinctrl-mtk-mt6779.h         | 2 +-
>   drivers/pinctrl/mediatek/pinctrl-mtk-mt8188.h         | 2 +-
>   include/dt-bindings/pinctrl/mediatek,mt8188-pinfunc.h | 2 +-
>   6 files changed, 6 insertions(+), 6 deletions(-)
>
Re: (subset) [PATCH 0/6] pinctrl: mediatek: Fix gpio-ranges and include guard issues
Posted by AngeloGioacchino Del Regno 3 weeks, 5 days ago
On Thu, 12 Mar 2026 13:15:27 +0900, Akari Tsuyukusa wrote:
> While looking at MediaTek's Pinctrl driver and device tree, I discovered
> that on some SoCs, the gpio-ranges count was a little less than the pins
> defined. This means that the last pin will no longer be available.
> 
> And fixing this issue, I also discovered that the #endif comment in the
> include guard for some header files was different from the macro name at
> the beginning. These issues do not affect the compiled kernel, but they
> affect the readability and consistency of the code.
> 
> [...]

Applied to v7.0-next/dts64, thanks!

[1/6] arm64: dts: mediatek: mt6795: Fix gpio-ranges pin count
      commit: c4c4823c8a5baa10b8100b01f49d7c3f4a871689
[2/6] arm64: dts: mediatek: mt7981b: Fix gpio-ranges pin count
      commit: b62a927f4a46a7f58d88ba3d5fb6e88e1a4b4603
[3/6] arm64: dts: mediatek: mt7986a: Fix gpio-ranges pin count
      commit: 820ed0c1a13c5fafb36232538d793f99a0986ef3

Cheers,
Angelo