Caleb Connolly | 7cf77da | 2024-04-10 19:52:37 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm sm6115 pinctrl |
| 4 | * |
| 5 | * (C) Copyright 2024 Linaro Ltd. |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #include <dm.h> |
| 10 | |
| 11 | #include "pinctrl-qcom.h" |
| 12 | |
| 13 | #define WEST 0x00000000 |
| 14 | #define SOUTH 0x00400000 |
| 15 | #define EAST 0x00800000 |
| 16 | |
| 17 | #define MAX_PIN_NAME_LEN 32 |
| 18 | static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); |
| 19 | |
| 20 | static const struct pinctrl_function msm_pinctrl_functions[] = { |
| 21 | { "qup4", 1 }, |
| 22 | { "gpio", 0 }, |
| 23 | }; |
| 24 | |
| 25 | static const unsigned int sm6115_pin_offsets[] = { |
| 26 | [0] = WEST, |
| 27 | [1] = WEST, |
| 28 | [2] = WEST, |
| 29 | [3] = WEST, |
| 30 | [4] = WEST, |
| 31 | [5] = WEST, |
| 32 | [6] = WEST, |
| 33 | [7] = WEST, |
| 34 | [8] = EAST, |
| 35 | [9] = EAST, |
| 36 | [10] = EAST, |
| 37 | [11] = EAST, |
| 38 | [12] = WEST, |
| 39 | [13] = WEST, |
| 40 | [14] = WEST, |
| 41 | [15] = WEST, |
| 42 | [16] = WEST, |
| 43 | [17] = WEST, |
| 44 | [18] = EAST, |
| 45 | [19] = EAST, |
| 46 | [20] = EAST, |
| 47 | [21] = EAST, |
| 48 | [22] = EAST, |
| 49 | [23] = EAST, |
| 50 | [24] = EAST, |
| 51 | [25] = EAST, |
| 52 | [26] = EAST, |
| 53 | [27] = EAST, |
| 54 | [28] = EAST, |
| 55 | [29] = EAST, |
| 56 | [30] = EAST, |
| 57 | [31] = EAST, |
| 58 | [32] = EAST, |
| 59 | [33] = EAST, |
| 60 | [34] = EAST, |
| 61 | [35] = EAST, |
| 62 | [36] = EAST, |
| 63 | [37] = EAST, |
| 64 | [38] = EAST, |
| 65 | [39] = EAST, |
| 66 | [40] = EAST, |
| 67 | [41] = EAST, |
| 68 | [42] = EAST, |
| 69 | [43] = EAST, |
| 70 | [44] = EAST, |
| 71 | [45] = EAST, |
| 72 | [46] = EAST, |
| 73 | [47] = EAST, |
| 74 | [48] = EAST, |
| 75 | [49] = EAST, |
| 76 | [50] = EAST, |
| 77 | [51] = EAST, |
| 78 | [52] = EAST, |
| 79 | [53] = EAST, |
| 80 | [54] = EAST, |
| 81 | [55] = EAST, |
| 82 | [56] = EAST, |
| 83 | [57] = EAST, |
| 84 | [58] = EAST, |
| 85 | [59] = EAST, |
| 86 | [60] = EAST, |
| 87 | [61] = EAST, |
| 88 | [62] = EAST, |
| 89 | [63] = EAST, |
| 90 | [64] = EAST, |
| 91 | [65] = WEST, |
| 92 | [66] = WEST, |
| 93 | [67] = WEST, |
| 94 | [68] = WEST, |
| 95 | [69] = WEST, |
| 96 | [70] = WEST, |
| 97 | [71] = WEST, |
| 98 | [72] = SOUTH, |
| 99 | [73] = SOUTH, |
| 100 | [74] = SOUTH, |
| 101 | [75] = SOUTH, |
| 102 | [76] = SOUTH, |
| 103 | [77] = SOUTH, |
| 104 | [78] = SOUTH, |
| 105 | [79] = SOUTH, |
| 106 | [80] = WEST, |
| 107 | [81] = WEST, |
| 108 | [82] = WEST, |
| 109 | [83] = WEST, |
| 110 | [84] = WEST, |
| 111 | [85] = WEST, |
| 112 | [86] = WEST, |
| 113 | [87] = EAST, |
| 114 | [88] = EAST, |
| 115 | [89] = WEST, |
| 116 | [90] = EAST, |
| 117 | [91] = EAST, |
| 118 | [92] = WEST, |
| 119 | [93] = WEST, |
| 120 | [94] = WEST, |
| 121 | [95] = WEST, |
| 122 | [96] = WEST, |
| 123 | [97] = WEST, |
| 124 | [98] = SOUTH, |
| 125 | [99] = SOUTH, |
| 126 | [100] = SOUTH, |
| 127 | [101] = SOUTH, |
| 128 | [102] = SOUTH, |
| 129 | [103] = SOUTH, |
| 130 | [104] = SOUTH, |
| 131 | [105] = SOUTH, |
| 132 | [106] = SOUTH, |
| 133 | [107] = SOUTH, |
| 134 | [108] = SOUTH, |
| 135 | [109] = SOUTH, |
| 136 | [110] = SOUTH, |
| 137 | [111] = SOUTH, |
| 138 | [112] = SOUTH, |
| 139 | /* Special pins */ |
| 140 | [113] = 0, |
| 141 | [114] = 0, |
| 142 | [115] = 0, |
| 143 | [116] = 0, |
| 144 | [117] = 0, |
| 145 | [118] = 0, |
| 146 | [119] = 0, |
| 147 | [120] = 0, |
| 148 | }; |
| 149 | |
| 150 | static const char *sm6115_get_function_name(struct udevice *dev, unsigned int selector) |
| 151 | { |
| 152 | return msm_pinctrl_functions[selector].name; |
| 153 | } |
| 154 | |
| 155 | static const char *sm6115_get_pin_name(struct udevice *dev, unsigned int selector) |
| 156 | { |
| 157 | static const char *special_pins_names[] = { |
| 158 | "ufs_reset", "sdc1_rclk", "sdc1_clk", "sdc1_cmd", |
| 159 | "sdc1_data", "sdc2_clk", "sdc2_cmd", "sdc2_data", |
| 160 | }; |
| 161 | |
| 162 | if (selector >= 113 && selector <= 120) |
| 163 | snprintf(pin_name, MAX_PIN_NAME_LEN, special_pins_names[selector - 113]); |
| 164 | else |
| 165 | snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); |
| 166 | |
| 167 | return pin_name; |
| 168 | } |
| 169 | |
| 170 | static unsigned int sm6115_get_function_mux(__maybe_unused unsigned int pin, unsigned int selector) |
| 171 | { |
| 172 | return msm_pinctrl_functions[selector].val; |
| 173 | } |
| 174 | |
| 175 | struct msm_pinctrl_data sm6115_data = { |
| 176 | .pin_data = { |
| 177 | .pin_offsets = sm6115_pin_offsets, |
| 178 | .pin_count = ARRAY_SIZE(sm6115_pin_offsets), |
| 179 | .special_pins_start = 113, |
| 180 | }, |
| 181 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 182 | .get_function_name = sm6115_get_function_name, |
| 183 | .get_function_mux = sm6115_get_function_mux, |
| 184 | .get_pin_name = sm6115_get_pin_name, |
| 185 | }; |
| 186 | |
| 187 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 188 | { |
| 189 | .compatible = "qcom,sm6115-tlmm", |
| 190 | .data = (ulong)&sm6115_data |
| 191 | }, |
| 192 | { /* Sentinel */ } }; |
| 193 | |
| 194 | U_BOOT_DRIVER(pinctrl_sm6115) = { |
| 195 | .name = "pinctrl_sm6115", |
| 196 | .id = UCLASS_NOP, |
| 197 | .of_match = msm_pinctrl_ids, |
| 198 | .ops = &msm_pinctrl_ops, |
| 199 | .bind = msm_pinctrl_bind, |
| 200 | }; |