blob: d9a8a6521118037c049090271359ec6ce5c782d4 [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
9#include <common.h>
10#include <dm.h>
11
12#include "pinctrl-qcom.h"
13
14#define MAX_PIN_NAME_LEN 32
15static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
16
17static const struct pinctrl_function msm_pinctrl_functions[] = {
18 {"qup1_se7", 1},
19 {"gpio", 0},
20};
21
22static const char *sm8550_get_function_name(struct udevice *dev,
23 unsigned int selector)
24{
25 return msm_pinctrl_functions[selector].name;
26}
27
28static const char *sm8550_get_pin_name(struct udevice *dev,
29 unsigned int selector)
30{
31 static const char *special_pins_names[] = {
32 "ufs_reset",
33 "sdc2_clk",
34 "sdc2_cmd",
35 "sdc2_data",
36 };
37
38 if (selector >= 210 && selector <= 213)
39 snprintf(pin_name, MAX_PIN_NAME_LEN, special_pins_names[selector - 210]);
40 else
41 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
42
43 return pin_name;
44}
45
46static unsigned int sm8550_get_function_mux(__maybe_unused unsigned int pin,
47 unsigned int selector)
48{
49 return msm_pinctrl_functions[selector].val;
50}
51
52static struct msm_pinctrl_data sm8550_data = {
53 .pin_data = {
54 .pin_count = 214,
55 .special_pins_start = 210,
56 },
57 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
58 .get_function_name = sm8550_get_function_name,
59 .get_function_mux = sm8550_get_function_mux,
60 .get_pin_name = sm8550_get_pin_name,
61};
62
63static const struct udevice_id msm_pinctrl_ids[] = {
64 { .compatible = "qcom,sm8550-tlmm", .data = (ulong)&sm8550_data },
65 { /* Sentinel */ }
66};
67
68U_BOOT_DRIVER(pinctrl_sm8550) = {
69 .name = "pinctrl_sm8550",
70 .id = UCLASS_NOP,
71 .of_match = msm_pinctrl_ids,
72 .ops = &msm_pinctrl_ops,
73 .bind = msm_pinctrl_bind,
74};
75