blob: c65dfe0435eb6d72e1033fcb151114b7671bd537 [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},
19};
20
Neil Armstrongd1ec4752024-05-28 10:31:56 +020021#define SDC_QDSD_PINGROUP(pg_name, ctl, pull, drv) \
22 { \
23 .name = pg_name, \
24 .ctl_reg = ctl, \
25 .io_reg = 0, \
26 .pull_bit = pull, \
27 .drv_bit = drv, \
28 .oe_bit = -1, \
29 .in_bit = -1, \
30 .out_bit = -1, \
31 }
32
33#define UFS_RESET(pg_name, ctl, io) \
34 { \
35 .name = pg_name, \
36 .ctl_reg = ctl, \
37 .io_reg = io, \
38 .pull_bit = 3, \
39 .drv_bit = 0, \
40 .oe_bit = -1, \
41 .in_bit = -1, \
42 .out_bit = 0, \
43 }
44
45static const struct msm_special_pin_data msm_special_pins_data[] = {
46 [0] = UFS_RESET("ufs_reset", 0xde000, 0xde004),
47 [1] = SDC_QDSD_PINGROUP("sdc2_clk", 0xd6000, 14, 6),
48 [2] = SDC_QDSD_PINGROUP("sdc2_cmd", 0xd6000, 11, 3),
49 [3] = SDC_QDSD_PINGROUP("sdc2_data", 0xd6000, 9, 0),
50};
51
Neil Armstrongf0f7ff82024-04-05 10:15:10 +020052static const char *sm8550_get_function_name(struct udevice *dev,
53 unsigned int selector)
54{
55 return msm_pinctrl_functions[selector].name;
56}
57
58static const char *sm8550_get_pin_name(struct udevice *dev,
59 unsigned int selector)
60{
Neil Armstrongf0f7ff82024-04-05 10:15:10 +020061 if (selector >= 210 && selector <= 213)
Neil Armstrongd1ec4752024-05-28 10:31:56 +020062 snprintf(pin_name, MAX_PIN_NAME_LEN,
63 msm_special_pins_data[selector - 210].name);
Neil Armstrongf0f7ff82024-04-05 10:15:10 +020064 else
65 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
66
67 return pin_name;
68}
69
70static unsigned int sm8550_get_function_mux(__maybe_unused unsigned int pin,
71 unsigned int selector)
72{
73 return msm_pinctrl_functions[selector].val;
74}
75
76static struct msm_pinctrl_data sm8550_data = {
77 .pin_data = {
78 .pin_count = 214,
79 .special_pins_start = 210,
Neil Armstrongd1ec4752024-05-28 10:31:56 +020080 .special_pins_data = msm_special_pins_data,
Neil Armstrongf0f7ff82024-04-05 10:15:10 +020081 },
82 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
83 .get_function_name = sm8550_get_function_name,
84 .get_function_mux = sm8550_get_function_mux,
85 .get_pin_name = sm8550_get_pin_name,
86};
87
88static const struct udevice_id msm_pinctrl_ids[] = {
89 { .compatible = "qcom,sm8550-tlmm", .data = (ulong)&sm8550_data },
90 { /* Sentinel */ }
91};
92
93U_BOOT_DRIVER(pinctrl_sm8550) = {
94 .name = "pinctrl_sm8550",
95 .id = UCLASS_NOP,
96 .of_match = msm_pinctrl_ids,
97 .ops = &msm_pinctrl_ops,
98 .bind = msm_pinctrl_bind,
99};
100