Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm SDM845 pinctrl |
| 4 | * |
| 5 | * (C) Copyright 2021 Dzmitry Sankouski <dsankouski@gmail.com> |
Caleb Connolly | fabb897 | 2023-11-14 12:55:42 +0000 | [diff] [blame^] | 6 | * (C) Copyright 2023 Linaro Ltd. |
Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 7 | * |
| 8 | */ |
| 9 | |
Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 10 | #include <common.h> |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 11 | #include <dm.h> |
| 12 | |
| 13 | #include "pinctrl-qcom.h" |
Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 14 | |
Caleb Connolly | fabb897 | 2023-11-14 12:55:42 +0000 | [diff] [blame^] | 15 | #define NORTH 0x00500000 |
| 16 | #define SOUTH 0x00900000 |
| 17 | #define EAST 0x00100000 |
| 18 | |
Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 19 | #define MAX_PIN_NAME_LEN 32 |
| 20 | static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); |
| 21 | |
| 22 | static const struct pinctrl_function msm_pinctrl_functions[] = { |
| 23 | {"qup9", 1}, |
| 24 | {"gpio", 0}, |
| 25 | }; |
| 26 | |
Caleb Connolly | fabb897 | 2023-11-14 12:55:42 +0000 | [diff] [blame^] | 27 | static const unsigned int sdm845_pin_offsets[] = { |
| 28 | [0] = EAST, [1] = EAST, [2] = EAST, [3] = EAST, [4] = NORTH, |
| 29 | [5] = NORTH, [6] = NORTH, [7] = NORTH, [8] = EAST, [9] = EAST, |
| 30 | [10] = EAST, [11] = EAST, [12] = SOUTH, [13] = SOUTH, [14] = SOUTH, |
| 31 | [15] = SOUTH, [16] = SOUTH, [17] = SOUTH, [18] = SOUTH, [19] = SOUTH, |
| 32 | [20] = SOUTH, [21] = SOUTH, [22] = SOUTH, [23] = SOUTH, [24] = SOUTH, |
| 33 | [25] = SOUTH, [26] = SOUTH, [27] = EAST, [28] = EAST, [29] = EAST, |
| 34 | [30] = EAST, [31] = NORTH, [32] = NORTH, [33] = NORTH, [34] = NORTH, |
| 35 | [35] = SOUTH, [36] = SOUTH, [37] = SOUTH, [38] = NORTH, [39] = EAST, |
| 36 | [40] = SOUTH, [41] = EAST, [42] = EAST, [43] = EAST, [44] = EAST, |
| 37 | [45] = EAST, [46] = EAST, [47] = EAST, [48] = EAST, [49] = NORTH, |
| 38 | [50] = NORTH, [51] = NORTH, [52] = NORTH, [53] = NORTH, [54] = NORTH, |
| 39 | [55] = NORTH, [56] = NORTH, [57] = NORTH, [58] = NORTH, [59] = NORTH, |
| 40 | [60] = NORTH, [61] = NORTH, [62] = NORTH, [63] = NORTH, [64] = NORTH, |
| 41 | [65] = NORTH, [66] = NORTH, [67] = NORTH, [68] = NORTH, [69] = EAST, |
| 42 | [70] = EAST, [71] = EAST, [72] = EAST, [73] = EAST, [74] = EAST, |
| 43 | [75] = EAST, [76] = EAST, [77] = EAST, [78] = EAST, [79] = NORTH, |
| 44 | [80] = NORTH, [81] = NORTH, [82] = NORTH, [83] = NORTH, [84] = NORTH, |
| 45 | [85] = EAST, [86] = EAST, [87] = EAST, [88] = EAST, [89] = SOUTH, |
| 46 | [90] = SOUTH, [91] = SOUTH, [92] = SOUTH, [93] = SOUTH, [94] = SOUTH, |
| 47 | [95] = SOUTH, [96] = SOUTH, [97] = NORTH, [98] = NORTH, [99] = NORTH, |
| 48 | [100] = NORTH, [101] = NORTH, [102] = NORTH, [103] = NORTH, [104] = NORTH, |
| 49 | [105] = NORTH, [106] = NORTH, [107] = NORTH, [108] = NORTH, [109] = NORTH, |
| 50 | [110] = NORTH, [111] = NORTH, [112] = NORTH, [113] = NORTH, [114] = NORTH, |
| 51 | [115] = NORTH, [116] = NORTH, [117] = NORTH, [118] = NORTH, [119] = NORTH, |
| 52 | [120] = NORTH, [121] = NORTH, [122] = EAST, [123] = EAST, [124] = EAST, |
| 53 | [125] = EAST, [126] = EAST, [127] = NORTH, [128] = NORTH, [129] = NORTH, |
| 54 | [130] = NORTH, [131] = NORTH, [132] = NORTH, [133] = NORTH, [134] = NORTH, |
| 55 | [135] = NORTH, [136] = NORTH, [137] = NORTH, [138] = NORTH, [139] = NORTH, |
| 56 | [140] = NORTH, [141] = NORTH, [142] = NORTH, [143] = NORTH, [144] = NORTH, |
| 57 | [145] = NORTH, [146] = NORTH, [147] = NORTH, [148] = NORTH, [149] = NORTH, |
| 58 | }; |
| 59 | |
Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 60 | static const char *sdm845_get_function_name(struct udevice *dev, |
| 61 | unsigned int selector) |
| 62 | { |
| 63 | return msm_pinctrl_functions[selector].name; |
| 64 | } |
| 65 | |
| 66 | static const char *sdm845_get_pin_name(struct udevice *dev, |
| 67 | unsigned int selector) |
| 68 | { |
Caleb Connolly | fabb897 | 2023-11-14 12:55:42 +0000 | [diff] [blame^] | 69 | snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); |
Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 70 | return pin_name; |
| 71 | } |
| 72 | |
| 73 | static unsigned int sdm845_get_function_mux(unsigned int selector) |
| 74 | { |
| 75 | return msm_pinctrl_functions[selector].val; |
| 76 | } |
| 77 | |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 78 | static struct msm_pinctrl_data sdm845_data = { |
Caleb Connolly | fabb897 | 2023-11-14 12:55:42 +0000 | [diff] [blame^] | 79 | .pin_data = { |
| 80 | .pin_offsets = sdm845_pin_offsets, |
| 81 | .pin_count = ARRAY_SIZE(sdm845_pin_offsets), |
| 82 | }, |
Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 83 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 84 | .get_function_name = sdm845_get_function_name, |
| 85 | .get_function_mux = sdm845_get_function_mux, |
| 86 | .get_pin_name = sdm845_get_pin_name, |
| 87 | }; |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 88 | |
| 89 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 90 | { .compatible = "qcom,sdm845-pinctrl", .data = (ulong)&sdm845_data }, |
| 91 | { /* Sentinal */ } |
| 92 | }; |
| 93 | |
| 94 | U_BOOT_DRIVER(pinctrl_sdm845) = { |
| 95 | .name = "pinctrl_sdm845", |
| 96 | .id = UCLASS_NOP, |
| 97 | .of_match = msm_pinctrl_ids, |
| 98 | .ops = &msm_pinctrl_ops, |
| 99 | .bind = msm_pinctrl_bind, |
| 100 | }; |