blob: af969e177d73493765780d218b5f65f9ed094c1a [file] [log] [blame]
Caleb Connolly0f496132024-04-10 19:52:36 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Qualcomm qcm2290 pinctrl
4 *
5 * (C) Copyright 2024 Linaro Ltd.
6 *
7 */
8
9#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 { "qup4", 1 },
18 { "gpio", 0 },
19};
20
21static const char *qcm2290_get_function_name(struct udevice *dev, unsigned int selector)
22{
23 return msm_pinctrl_functions[selector].name;
24}
25
26static const char *qcm2290_get_pin_name(struct udevice *dev, unsigned int selector)
27{
28 static const char *const special_pins_names[] = {
29 "sdc1_rclk", "sdc1_clk", "sdc1_cmd", "sdc1_data",
30 "sdc2_clk", "sdc2_cmd", "sdc2_data",
31 };
32
33 if (selector >= 127 && selector <= 133)
34 snprintf(pin_name, MAX_PIN_NAME_LEN, special_pins_names[selector - 127]);
35 else
36 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
37
38 return pin_name;
39}
40
41static unsigned int qcm2290_get_function_mux(__maybe_unused unsigned int pin, unsigned int selector)
42{
43 return msm_pinctrl_functions[selector].val;
44}
45
46struct msm_pinctrl_data qcm2290_data = {
47 .pin_data = {
48 .pin_count = 133,
49 .special_pins_start = 127,
50 },
51 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
52 .get_function_name = qcm2290_get_function_name,
53 .get_function_mux = qcm2290_get_function_mux,
54 .get_pin_name = qcm2290_get_pin_name,
55};
56
57static const struct udevice_id msm_pinctrl_ids[] = {
58 {
59 .compatible = "qcom,qcm2290-tlmm",
60 .data = (ulong)&qcm2290_data
61 },
62 { /* Sentinel */ } };
63
64U_BOOT_DRIVER(pinctrl_qcm2290) = {
65 .name = "pinctrl_qcm2290",
66 .id = UCLASS_NOP,
67 .of_match = msm_pinctrl_ids,
68 .ops = &msm_pinctrl_ops,
69 .bind = msm_pinctrl_bind,
70};