blob: 58fc94e71ac152538a09b1bca9b0f58ef913967b [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},
19};
20
Neil Armstrong219e52c2024-05-28 10:31:57 +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", 0xde004, 0xdf000),
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 Armstrong06534722024-04-05 10:15:11 +020052static const char *sm8650_get_function_name(struct udevice *dev,
53 unsigned int selector)
54{
55 return msm_pinctrl_functions[selector].name;
56}
57
58static const char *sm8650_get_pin_name(struct udevice *dev,
59 unsigned int selector)
60{
Neil Armstrong06534722024-04-05 10:15:11 +020061 if (selector >= 210 && selector <= 213)
Neil Armstrong219e52c2024-05-28 10:31:57 +020062 snprintf(pin_name, MAX_PIN_NAME_LEN,
63 msm_special_pins_data[selector - 210].name);
Neil Armstrong06534722024-04-05 10:15:11 +020064 else
65 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
66
67 return pin_name;
68}
69
70static unsigned int sm8650_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 sm8650_data = {
77 .pin_data = {
78 .pin_count = 214,
79 .special_pins_start = 210,
Neil Armstrong219e52c2024-05-28 10:31:57 +020080 .special_pins_data = msm_special_pins_data,
Neil Armstrong06534722024-04-05 10:15:11 +020081 },
82 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
83 .get_function_name = sm8650_get_function_name,
84 .get_function_mux = sm8650_get_function_mux,
85 .get_pin_name = sm8650_get_pin_name,
86};
87
88static const struct udevice_id msm_pinctrl_ids[] = {
89 { .compatible = "qcom,sm8650-tlmm", .data = (ulong)&sm8650_data },
90 { /* Sentinel */ }
91};
92
93U_BOOT_DRIVER(pinctrl_sm8650) = {
94 .name = "pinctrl_sm8650",
95 .id = UCLASS_NOP,
96 .of_match = msm_pinctrl_ids,
97 .ops = &msm_pinctrl_ops,
98 .bind = msm_pinctrl_bind,
99};
100