Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: rockchip: grf: switch to FIELD_PREP_WM16_CONST macro

The era of hand-rolled HIWORD_UPDATE macros is over, at least for those
drivers that use constant masks.

Switch the rockchip grf driver to the FIELD_PREP_WM16_CONST macro, which
brings with it more error checking while still being able to be used in
initializers.

All HIWORD_UPDATE instances and its definition are removed from the
driver, as the conversion here is obvious, and static_asserts were used
during development to make sure the ones greater than one bit in width
were really equivalent.

Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>

authored by

Nicolas Frattaroli and committed by
Yury Norov
90fbf6a2 47975a87

+17 -18
+17 -18
drivers/soc/rockchip/grf.c
··· 6 6 */ 7 7 8 8 #include <linux/err.h> 9 + #include <linux/hw_bitfield.h> 9 10 #include <linux/mfd/syscon.h> 10 11 #include <linux/of.h> 11 12 #include <linux/platform_device.h> 12 13 #include <linux/regmap.h> 13 14 14 - #define HIWORD_UPDATE(val, mask, shift) \ 15 - ((val) << (shift) | (mask) << ((shift) + 16)) 16 15 17 16 struct rockchip_grf_value { 18 17 const char *desc; ··· 31 32 * Disable auto jtag/sdmmc switching that causes issues with the 32 33 * clock-framework and the mmc controllers making them unreliable. 33 34 */ 34 - { "jtag switching", RK3036_GRF_SOC_CON0, HIWORD_UPDATE(0, 1, 11) }, 35 + { "jtag switching", RK3036_GRF_SOC_CON0, FIELD_PREP_WM16_CONST(BIT(11), 0) }, 35 36 }; 36 37 37 38 static const struct rockchip_grf_info rk3036_grf __initconst = { ··· 43 44 #define RK3128_GRF_SOC_CON1 0x144 44 45 45 46 static const struct rockchip_grf_value rk3128_defaults[] __initconst = { 46 - { "jtag switching", RK3128_GRF_SOC_CON0, HIWORD_UPDATE(0, 1, 8) }, 47 - { "vpu main clock", RK3128_GRF_SOC_CON1, HIWORD_UPDATE(0, 1, 10) }, 47 + { "jtag switching", RK3128_GRF_SOC_CON0, FIELD_PREP_WM16_CONST(BIT(8), 0) }, 48 + { "vpu main clock", RK3128_GRF_SOC_CON1, FIELD_PREP_WM16_CONST(BIT(10), 0) }, 48 49 }; 49 50 50 51 static const struct rockchip_grf_info rk3128_grf __initconst = { ··· 55 56 #define RK3228_GRF_SOC_CON6 0x418 56 57 57 58 static const struct rockchip_grf_value rk3228_defaults[] __initconst = { 58 - { "jtag switching", RK3228_GRF_SOC_CON6, HIWORD_UPDATE(0, 1, 8) }, 59 + { "jtag switching", RK3228_GRF_SOC_CON6, FIELD_PREP_WM16_CONST(BIT(8), 0) }, 59 60 }; 60 61 61 62 static const struct rockchip_grf_info rk3228_grf __initconst = { ··· 67 68 #define RK3288_GRF_SOC_CON2 0x24c 68 69 69 70 static const struct rockchip_grf_value rk3288_defaults[] __initconst = { 70 - { "jtag switching", RK3288_GRF_SOC_CON0, HIWORD_UPDATE(0, 1, 12) }, 71 - { "pwm select", RK3288_GRF_SOC_CON2, HIWORD_UPDATE(1, 1, 0) }, 71 + { "jtag switching", RK3288_GRF_SOC_CON0, FIELD_PREP_WM16_CONST(BIT(12), 0) }, 72 + { "pwm select", RK3288_GRF_SOC_CON2, FIELD_PREP_WM16_CONST(BIT(0), 1) }, 72 73 }; 73 74 74 75 static const struct rockchip_grf_info rk3288_grf __initconst = { ··· 79 80 #define RK3328_GRF_SOC_CON4 0x410 80 81 81 82 static const struct rockchip_grf_value rk3328_defaults[] __initconst = { 82 - { "jtag switching", RK3328_GRF_SOC_CON4, HIWORD_UPDATE(0, 1, 12) }, 83 + { "jtag switching", RK3328_GRF_SOC_CON4, FIELD_PREP_WM16_CONST(BIT(12), 0) }, 83 84 }; 84 85 85 86 static const struct rockchip_grf_info rk3328_grf __initconst = { ··· 90 91 #define RK3368_GRF_SOC_CON15 0x43c 91 92 92 93 static const struct rockchip_grf_value rk3368_defaults[] __initconst = { 93 - { "jtag switching", RK3368_GRF_SOC_CON15, HIWORD_UPDATE(0, 1, 13) }, 94 + { "jtag switching", RK3368_GRF_SOC_CON15, FIELD_PREP_WM16_CONST(BIT(13), 0) }, 94 95 }; 95 96 96 97 static const struct rockchip_grf_info rk3368_grf __initconst = { ··· 101 102 #define RK3399_GRF_SOC_CON7 0xe21c 102 103 103 104 static const struct rockchip_grf_value rk3399_defaults[] __initconst = { 104 - { "jtag switching", RK3399_GRF_SOC_CON7, HIWORD_UPDATE(0, 1, 12) }, 105 + { "jtag switching", RK3399_GRF_SOC_CON7, FIELD_PREP_WM16_CONST(BIT(12), 0) }, 105 106 }; 106 107 107 108 static const struct rockchip_grf_info rk3399_grf __initconst = { ··· 112 113 #define RK3566_GRF_USB3OTG0_CON1 0x0104 113 114 114 115 static const struct rockchip_grf_value rk3566_defaults[] __initconst = { 115 - { "usb3otg port switch", RK3566_GRF_USB3OTG0_CON1, HIWORD_UPDATE(0, 1, 12) }, 116 - { "usb3otg clock switch", RK3566_GRF_USB3OTG0_CON1, HIWORD_UPDATE(1, 1, 7) }, 117 - { "usb3otg disable usb3", RK3566_GRF_USB3OTG0_CON1, HIWORD_UPDATE(1, 1, 0) }, 116 + { "usb3otg port switch", RK3566_GRF_USB3OTG0_CON1, FIELD_PREP_WM16_CONST(BIT(12), 0) }, 117 + { "usb3otg clock switch", RK3566_GRF_USB3OTG0_CON1, FIELD_PREP_WM16_CONST(BIT(7), 1) }, 118 + { "usb3otg disable usb3", RK3566_GRF_USB3OTG0_CON1, FIELD_PREP_WM16_CONST(BIT(0), 1) }, 118 119 }; 119 120 120 121 static const struct rockchip_grf_info rk3566_pipegrf __initconst = { ··· 125 126 #define RK3576_SYSGRF_SOC_CON1 0x0004 126 127 127 128 static const struct rockchip_grf_value rk3576_defaults_sys_grf[] __initconst = { 128 - { "i3c0 weakpull", RK3576_SYSGRF_SOC_CON1, HIWORD_UPDATE(3, 3, 6) }, 129 - { "i3c1 weakpull", RK3576_SYSGRF_SOC_CON1, HIWORD_UPDATE(3, 3, 8) }, 129 + { "i3c0 weakpull", RK3576_SYSGRF_SOC_CON1, FIELD_PREP_WM16_CONST(GENMASK(7, 6), 3) }, 130 + { "i3c1 weakpull", RK3576_SYSGRF_SOC_CON1, FIELD_PREP_WM16_CONST(GENMASK(9, 8), 3) }, 130 131 }; 131 132 132 133 static const struct rockchip_grf_info rk3576_sysgrf __initconst = { ··· 137 138 #define RK3576_IOCGRF_MISC_CON 0x04F0 138 139 139 140 static const struct rockchip_grf_value rk3576_defaults_ioc_grf[] __initconst = { 140 - { "jtag switching", RK3576_IOCGRF_MISC_CON, HIWORD_UPDATE(0, 1, 1) }, 141 + { "jtag switching", RK3576_IOCGRF_MISC_CON, FIELD_PREP_WM16_CONST(BIT(1), 0) }, 141 142 }; 142 143 143 144 static const struct rockchip_grf_info rk3576_iocgrf __initconst = { ··· 148 149 #define RK3588_GRF_SOC_CON6 0x0318 149 150 150 151 static const struct rockchip_grf_value rk3588_defaults[] __initconst = { 151 - { "jtag switching", RK3588_GRF_SOC_CON6, HIWORD_UPDATE(0, 1, 14) }, 152 + { "jtag switching", RK3588_GRF_SOC_CON6, FIELD_PREP_WM16_CONST(BIT(14), 0) }, 152 153 }; 153 154 154 155 static const struct rockchip_grf_info rk3588_sysgrf __initconst = {