blob: 9146d6abd9a046460836ad8cda6ea196bc4ca91f [file] [log] [blame]
Neil Armstrong06534722024-04-05 10:15:11 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Qualcomm sm8650 pinctrl
4 *
5 * (C) Copyright 2024 Linaro Ltd.
6 *
7 */
8
Neil Armstrong06534722024-04-05 10:15:11 +02009#include <dm.h>
10
11#include "pinctrl-qcom.h"
12
13#define MAX_PIN_NAME_LEN 32
14static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
15
16static const struct pinctrl_function msm_pinctrl_functions[] = {
17 {"qup2_se7", 1},
18 {"gpio", 0},
Neil Armstrongb7d0bb12024-11-25 09:29:11 +010019 {"pcie0_clk_req_n", 1},
20 {"pcie1_clk_req_n", 1},
Neil Armstrong06534722024-04-05 10:15:11 +020021};
22
Neil Armstrong219e52c2024-05-28 10:31:57 +020023#define SDC_QDSD_PINGROUP(pg_name, ctl, pull, drv) \
24 { \
25 .name = pg_name, \
26 .ctl_reg = ctl, \
27 .io_reg = 0, \
28 .pull_bit = pull, \
29 .drv_bit = drv, \
30 .oe_bit = -1, \
31 .in_bit = -1, \
32 .out_bit = -1, \
33 }
34
35#define UFS_RESET(pg_name, ctl, io) \
36 { \
37 .name = pg_name, \
38 .ctl_reg = ctl, \
39 .io_reg = io, \
40 .pull_bit = 3, \
41 .drv_bit = 0, \
42 .oe_bit = -1, \
43 .in_bit = -1, \
44 .out_bit = 0, \
45 }
46
47static const struct msm_special_pin_data msm_special_pins_data[] = {
48 [0] = UFS_RESET("ufs_reset", 0xde004, 0xdf000),
49 [1] = SDC_QDSD_PINGROUP("sdc2_clk", 0xd6000, 14, 6),
50 [2] = SDC_QDSD_PINGROUP("sdc2_cmd", 0xd6000, 11, 3),
51 [3] = SDC_QDSD_PINGROUP("sdc2_data", 0xd6000, 9, 0),
52};
53
Neil Armstrong06534722024-04-05 10:15:11 +020054static const char *sm8650_get_function_name(struct udevice *dev,
55 unsigned int selector)
56{
57 return msm_pinctrl_functions[selector].name;
58}
59
60static const char *sm8650_get_pin_name(struct udevice *dev,
61 unsigned int selector)
62{
Neil Armstrong06534722024-04-05 10:15:11 +020063 if (selector >= 210 && selector <= 213)
Neil Armstrong219e52c2024-05-28 10:31:57 +020064 snprintf(pin_name, MAX_PIN_NAME_LEN,
65 msm_special_pins_data[selector - 210].name);
Neil Armstrong06534722024-04-05 10:15:11 +020066 else
67 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
68
69 return pin_name;
70}
71
72static unsigned int sm8650_get_function_mux(__maybe_unused unsigned int pin,
73 unsigned int selector)
74{
75 return msm_pinctrl_functions[selector].val;
76}
77
78static struct msm_pinctrl_data sm8650_data = {
79 .pin_data = {
80 .pin_count = 214,
81 .special_pins_start = 210,
Neil Armstrong219e52c2024-05-28 10:31:57 +020082 .special_pins_data = msm_special_pins_data,
Neil Armstrong06534722024-04-05 10:15:11 +020083 },
84 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
85 .get_function_name = sm8650_get_function_name,
86 .get_function_mux = sm8650_get_function_mux,
87 .get_pin_name = sm8650_get_pin_name,
88};
89
90static const struct udevice_id msm_pinctrl_ids[] = {
91 { .compatible = "qcom,sm8650-tlmm", .data = (ulong)&sm8650_data },
92 { /* Sentinel */ }
93};
94
95U_BOOT_DRIVER(pinctrl_sm8650) = {
96 .name = "pinctrl_sm8650",
97 .id = UCLASS_NOP,
98 .of_match = msm_pinctrl_ids,
99 .ops = &msm_pinctrl_ops,
100 .bind = msm_pinctrl_bind,
101};
102