blob: dac24f11bc2c78c7964b22b60ba077f969eddc3d [file] [log] [blame]
Caleb Connolly022ba9b2024-04-10 19:52:38 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Qualcomm sm8250 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 NORTH 0x00800000
16
17#define MAX_PIN_NAME_LEN 32
18static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
19
20static const struct pinctrl_function msm_pinctrl_functions[] = { { "qup12", 1 },
21 { "gpio", 0 },
22 { "sdc2_clk", 0 } };
23
24static const unsigned int sm8250_pin_offsets[] = {
25 [0] = SOUTH, [1] = SOUTH, [2] = SOUTH, [3] = SOUTH, [4] = NORTH, [5] = NORTH,
26 [6] = NORTH, [7] = NORTH, [8] = NORTH, [9] = NORTH, [10] = NORTH, [11] = NORTH,
27 [12] = NORTH, [13] = NORTH, [14] = NORTH, [15] = NORTH, [16] = NORTH, [17] = NORTH,
28 [18] = NORTH, [19] = NORTH, [20] = NORTH, [21] = NORTH, [22] = NORTH, [23] = NORTH,
29 [24] = SOUTH, [25] = SOUTH, [26] = SOUTH, [27] = SOUTH, [28] = NORTH, [29] = NORTH,
30 [30] = NORTH, [31] = NORTH, [32] = SOUTH, [33] = SOUTH, [34] = SOUTH, [35] = SOUTH,
31 [36] = SOUTH, [37] = SOUTH, [38] = SOUTH, [39] = SOUTH, [40] = SOUTH, [41] = SOUTH,
32 [42] = SOUTH, [43] = SOUTH, [44] = SOUTH, [45] = SOUTH, [46] = SOUTH, [47] = SOUTH,
33 [48] = SOUTH, [49] = SOUTH, [50] = SOUTH, [51] = SOUTH, [52] = SOUTH, [53] = SOUTH,
34 [54] = SOUTH, [55] = SOUTH, [56] = SOUTH, [57] = SOUTH, [58] = SOUTH, [59] = SOUTH,
35 [60] = SOUTH, [61] = SOUTH, [62] = SOUTH, [63] = SOUTH, [64] = SOUTH, [65] = SOUTH,
36 [66] = NORTH, [67] = NORTH, [68] = NORTH, [69] = SOUTH, [70] = SOUTH, [71] = SOUTH,
37 [72] = SOUTH, [73] = SOUTH, [74] = SOUTH, [75] = SOUTH, [76] = SOUTH, [77] = NORTH,
38 [78] = NORTH, [79] = NORTH, [80] = NORTH, [81] = NORTH, [82] = NORTH, [83] = NORTH,
39 [84] = NORTH, [85] = SOUTH, [86] = SOUTH, [87] = SOUTH, [88] = SOUTH, [89] = SOUTH,
40 [90] = SOUTH, [91] = SOUTH, [92] = NORTH, [93] = NORTH, [94] = NORTH, [95] = NORTH,
41 [96] = NORTH, [97] = NORTH, [98] = NORTH, [99] = NORTH, [100] = NORTH, [101] = NORTH,
42 [102] = NORTH, [103] = NORTH, [104] = NORTH, [105] = NORTH, [106] = NORTH, [107] = NORTH,
43 [108] = NORTH, [109] = NORTH, [110] = NORTH, [111] = NORTH, [112] = NORTH, [113] = NORTH,
44 [114] = NORTH, [115] = NORTH, [116] = NORTH, [117] = NORTH, [118] = NORTH, [119] = NORTH,
45 [120] = NORTH, [121] = NORTH, [122] = NORTH, [123] = NORTH, [124] = NORTH, [125] = SOUTH,
46 [126] = SOUTH, [127] = SOUTH, [128] = SOUTH, [129] = SOUTH, [130] = SOUTH, [131] = SOUTH,
47 [132] = SOUTH, [133] = WEST, [134] = WEST, [135] = WEST, [136] = WEST, [137] = WEST,
48 [138] = WEST, [139] = WEST, [140] = WEST, [141] = WEST, [142] = WEST, [143] = WEST,
49 [144] = WEST, [145] = WEST, [146] = WEST, [147] = WEST, [148] = WEST, [149] = WEST,
50 [150] = WEST, [151] = WEST, [152] = WEST, [153] = WEST, [154] = WEST, [155] = WEST,
51 [156] = WEST, [157] = WEST, [158] = WEST, [159] = WEST, [160] = WEST, [161] = WEST,
52 [162] = WEST, [163] = WEST, [164] = WEST, [165] = WEST, [166] = WEST, [167] = WEST,
53 [168] = WEST, [169] = WEST, [170] = WEST, [171] = WEST, [172] = WEST, [173] = WEST,
54 [174] = WEST, [175] = WEST, [176] = WEST, [177] = WEST, [178] = WEST, [179] = WEST,
55 [180] = 0, [181] = 0, [182] = 0, [183] = 0,
56};
57
58static const char *sm8250_get_function_name(struct udevice *dev, unsigned int selector)
59{
60 return msm_pinctrl_functions[selector].name;
61}
62
63static const char *sm8250_get_pin_name(struct udevice *dev, unsigned int selector)
64{
65 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
66 return pin_name;
67}
68
69static unsigned int sm8250_get_function_mux(__maybe_unused unsigned int pin, unsigned int selector)
70{
71 return msm_pinctrl_functions[selector].val;
72}
73
74static struct msm_pinctrl_data sm8250_data = {
75 .pin_data = {
76 .pin_offsets = sm8250_pin_offsets,
77 .pin_count = ARRAY_SIZE(sm8250_pin_offsets),
78 .special_pins_start = 180,
79 },
80 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
81 .get_function_name = sm8250_get_function_name,
82 .get_function_mux = sm8250_get_function_mux,
83 .get_pin_name = sm8250_get_pin_name,
84};
85
86static const struct udevice_id msm_pinctrl_ids[] = {
87 {
88 .compatible = "qcom,sm8250-pinctrl",
89 .data = (ulong)&sm8250_data
90 },
91 { /* Sentinel */ } };
92
93U_BOOT_DRIVER(pinctrl_sm8250) = {
94 .name = "pinctrl_sm8250",
95 .id = UCLASS_NOP,
96 .of_match = msm_pinctrl_ids,
97 .ops = &msm_pinctrl_ops,
98 .bind = msm_pinctrl_bind,
99};