pinctrl: mediatek: convert most definitions to const
There exists a situation of the mediatek pinctrl driver that may return
wrong pin function value for the pinmux driver:
- All pin function arrays are defined without const
- Some pin function arrays contain all-zero value, e.g.:
static int mt7622_spi_funcs[] = { 0, 0, 0, 0, 0, 0, };
- These arrays will be put into .bss section during compilation
- .bss section has no "a" attribute and does not exist in the final binary
file after objcopy.
- FDT binary blob is appended to the u-boot binary, which occupies the
.bss section.
- During board_f stage, .bss has not been initialized, and contains the
data of FDT, which is not full-zero data.
- pinctrl driver is initialized in board_f stage, and it will get wrong
data if another driver is going to set default pinctrl.
Since pinmux information and soc data are only meant to be read-only, thus
should be declared as const. This will force all pinctrl data being put
into .rodata section. Since .rodata has "a" attribute, even the all-zero
data will be allocated and filled with correct value in to u-boot binary.
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8512.c b/drivers/pinctrl/mediatek/pinctrl-mt8512.c
index 3d9c0ab..bc5fb83 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8512.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8512.c
@@ -315,12 +315,12 @@
*/
/* UART */
-static int mt8512_uart0_0_rxd_txd_pins[] = { 52, 53, };
-static int mt8512_uart0_0_rxd_txd_funcs[] = { 1, 1, };
-static int mt8512_uart1_0_rxd_txd_pins[] = { 54, 55, };
-static int mt8512_uart1_0_rxd_txd_funcs[] = { 1, 1, };
-static int mt8512_uart2_0_rxd_txd_pins[] = { 28, 29, };
-static int mt8512_uart2_0_rxd_txd_funcs[] = { 1, 1, };
+static const int mt8512_uart0_0_rxd_txd_pins[] = { 52, 53, };
+static const int mt8512_uart0_0_rxd_txd_funcs[] = { 1, 1, };
+static const int mt8512_uart1_0_rxd_txd_pins[] = { 54, 55, };
+static const int mt8512_uart1_0_rxd_txd_funcs[] = { 1, 1, };
+static const int mt8512_uart2_0_rxd_txd_pins[] = { 28, 29, };
+static const int mt8512_uart2_0_rxd_txd_funcs[] = { 1, 1, };
/* Joint those groups owning the same capability in user point of view which
* allows that people tend to use through the device tree.
@@ -330,13 +330,13 @@
"uart2_0_rxd_txd", };
/* SNAND */
-static int mt8512_snfi_pins[] = { 71, 76, 77, 78, 79, 80, };
-static int mt8512_snfi_funcs[] = { 3, 3, 3, 3, 3, 3, };
+static const int mt8512_snfi_pins[] = { 71, 76, 77, 78, 79, 80, };
+static const int mt8512_snfi_funcs[] = { 3, 3, 3, 3, 3, 3, };
/* MMC0 */
-static int mt8512_msdc0_pins[] = { 76, 77, 78, 79, 80, 81, 82, 83, 84,
- 85, 86, };
-static int mt8512_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
+static const int mt8512_msdc0_pins[] = { 76, 77, 78, 79, 80, 81, 82, 83, 84,
+ 85, 86, };
+static const int mt8512_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
static const struct mtk_group_desc mt8512_groups[] = {
PINCTRL_PIN_GROUP("uart0_0_rxd_txd", mt8512_uart0_0_rxd_txd),
@@ -356,7 +356,7 @@
{"snand", mt8512_msdc_groups, ARRAY_SIZE(mt8512_msdc_groups)},
};
-static struct mtk_pinctrl_soc mt8512_data = {
+static const struct mtk_pinctrl_soc mt8512_data = {
.name = "mt8512_pinctrl",
.reg_cal = mt8512_reg_cals,
.pins = mt8512_pins,