pinctrl: rockchip: Fix drive and input schmitt on RK3568
authorJonas Karlman <jonas@kwiboo.se>
Mon, 14 Aug 2023 00:28:26 +0000 (00:28 +0000)
committerKever Yang <kever.yang@rock-chips.com>
Mon, 14 Aug 2023 03:07:27 +0000 (11:07 +0800)
commitd7009faa098169abd7ff0e4b41af89b17896a7da
tree2920bb606a1d9c4c310f6721f017c86933e47260
parenta73a28b3298dacea3a39f97c6da50fe7cd10e7df
pinctrl: rockchip: Fix drive and input schmitt on RK3568

On RK3568 most pins have a configurable drive strength of level 0-5 and
some pins level 0-11. When rk3568_set_drive is called with a strength
value above 7 the drv value written to reg may overflow into the write
enable bits, resulting in a bad configuration.

This cause e.g. ethernet PHY on Radxa CM3-IO board not to work after
drive is configured according to the device tree.

  Could not get PHY for ethernet@fe010000: addr 0

Level 6-11 can be configured using a second reg for some pins, however
the drv value is reused resulting in lower 6 bits being written to reg.

Input schmitt is configured in 2-bit fields on RK3568 compared to
earlier generation and 2'b10 should be used to enable input schmitt.

Change to use regmap_update_bits with a rmask to fix the overflow issue
and closer match the linux driver. Bit shift the drv value used for the
second reg to configure drive strength level 6-11. Also write correct
values for input schmitt setting.

Fixes: 1977d746aa54 ("rockchip: rk3568: add rk3568 pinctrl driver")
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/pinctrl/rockchip/pinctrl-rk3568.c