blob: f7fcad0e4aa3dc21365eca72a155f0d98ebd71e1 [file] [log] [blame]
Neil Armstrongf0f7ff82024-04-05 10:15:10 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Qualcomm sm8550 pinctrl
4 *
5 * (C) Copyright 2024 Linaro Ltd.
6 *
7 */
8
Neil Armstrongf0f7ff82024-04-05 10:15:10 +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 {"qup1_se7", 1},
18 {"gpio", 0},
Neil Armstrong4f2a0572024-11-25 09:29:10 +010019 {"pcie1_clk_req_n", 1},
Neil Armstrongf0f7ff82024-04-05 10:15:10 +020020};
21
Neil Armstrongd1ec4752024-05-28 10:31:56 +020022#define SDC_QDSD_PINGROUP(pg_name, ctl, pull, drv) \
23 { \
24 .name = pg_name, \
25 .ctl_reg = ctl, \
26 .io_reg = 0, \
27 .pull_bit = pull, \
28 .drv_bit = drv, \
29 .oe_bit = -1, \
30 .in_bit = -1, \
31 .out_bit = -1, \
32 }
33
34#define UFS_RESET(pg_name, ctl, io) \
35 { \
36 .name = pg_name, \
37 .ctl_reg = ctl, \
38 .io_reg = io, \
39 .pull_bit = 3, \
40 .drv_bit = 0, \
41 .oe_bit = -1, \
42 .in_bit = -1, \
43 .out_bit = 0, \
44 }
45
46static const struct msm_special_pin_data msm_special_pins_data[] = {
47 [0] = UFS_RESET("ufs_reset", 0xde000, 0xde004),
48 [1] = SDC_QDSD_PINGROUP("sdc2_clk", 0xd6000, 14, 6),
49 [2] = SDC_QDSD_PINGROUP("sdc2_cmd", 0xd6000, 11, 3),
50 [3] = SDC_QDSD_PINGROUP("sdc2_data", 0xd6000, 9, 0),
51};
52
Neil Armstrongf0f7ff82024-04-05 10:15:10 +020053static const char *sm8550_get_function_name(struct udevice *dev,
54 unsigned int selector)
55{
56 return msm_pinctrl_functions[selector].name;
57}
58
59static const char *sm8550_get_pin_name(struct udevice *dev,
60 unsigned int selector)
61{
Neil Armstrongf0f7ff82024-04-05 10:15:10 +020062 if (selector >= 210 && selector <= 213)
Neil Armstrongd1ec4752024-05-28 10:31:56 +020063 snprintf(pin_name, MAX_PIN_NAME_LEN,
64 msm_special_pins_data[selector - 210].name);
Neil Armstrongf0f7ff82024-04-05 10:15:10 +020065 else
66 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
67
68 return pin_name;
69}
70
Varadarajan Narayanane7f07e02025-02-26 12:15:02 +053071static int sm8550_get_function_mux(__maybe_unused unsigned int pin,
72 unsigned int selector)
Neil Armstrongf0f7ff82024-04-05 10:15:10 +020073{
74 return msm_pinctrl_functions[selector].val;
75}
76
77static struct msm_pinctrl_data sm8550_data = {
78 .pin_data = {
79 .pin_count = 214,
80 .special_pins_start = 210,
Neil Armstrongd1ec4752024-05-28 10:31:56 +020081 .special_pins_data = msm_special_pins_data,
Neil Armstrongf0f7ff82024-04-05 10:15:10 +020082 },
83 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
84 .get_function_name = sm8550_get_function_name,
85 .get_function_mux = sm8550_get_function_mux,
86 .get_pin_name = sm8550_get_pin_name,
87};
88
89static const struct udevice_id msm_pinctrl_ids[] = {
90 { .compatible = "qcom,sm8550-tlmm", .data = (ulong)&sm8550_data },
91 { /* Sentinel */ }
92};
93
94U_BOOT_DRIVER(pinctrl_sm8550) = {
95 .name = "pinctrl_sm8550",
96 .id = UCLASS_NOP,
97 .of_match = msm_pinctrl_ids,
98 .ops = &msm_pinctrl_ops,
99 .bind = msm_pinctrl_bind,
100};
101