blob: a6e53c4412ecca8a95cab3e371b1b757defebfb7 [file] [log] [blame]
Sumit Garg46ad40b2022-07-12 12:42:10 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Qualcomm QCS404 pinctrl
4 *
5 * (C) Copyright 2022 Sumit Garg <sumit.garg@linaro.org>
6 */
7
8#include "pinctrl-snapdragon.h"
9#include <common.h>
10
11#define MAX_PIN_NAME_LEN 32
12static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
13static const char * const msm_pinctrl_pins[] = {
14 "SDC1_RCLK",
15 "SDC1_CLK",
16 "SDC1_CMD",
17 "SDC1_DATA",
18 "SDC2_CLK",
19 "SDC2_CMD",
20 "SDC2_DATA",
21};
22
23static const struct pinctrl_function msm_pinctrl_functions[] = {
24 {"blsp_uart2", 1},
Sumit Garg09aea5d2023-02-01 19:28:51 +053025 {"rgmii_int", 1},
26 {"rgmii_ck", 1},
27 {"rgmii_tx", 1},
28 {"rgmii_ctl", 1},
29 {"rgmii_rx", 1},
30 {"rgmii_mdio", 1},
31 {"rgmii_mdc", 1},
Sumit Garg00e84692023-02-01 19:28:59 +053032 {"blsp_i2c0", 3},
33 {"blsp_i2c1", 2},
34 {"blsp_i2c_sda_a2", 3},
35 {"blsp_i2c_scl_a2", 3},
36 {"blsp_i2c3", 2},
37 {"blsp_i2c4", 1},
Sumit Garg46ad40b2022-07-12 12:42:10 +053038};
39
40static const char *qcs404_get_function_name(struct udevice *dev,
41 unsigned int selector)
42{
43 return msm_pinctrl_functions[selector].name;
44}
45
46static const char *qcs404_get_pin_name(struct udevice *dev,
47 unsigned int selector)
48{
49 if (selector < 120) {
50 snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector);
51 return pin_name;
52 } else {
53 return msm_pinctrl_pins[selector - 120];
54 }
55}
56
57static unsigned int qcs404_get_function_mux(unsigned int selector)
58{
59 return msm_pinctrl_functions[selector].val;
60}
61
62struct msm_pinctrl_data qcs404_data = {
63 .pin_count = 126,
64 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
65 .get_function_name = qcs404_get_function_name,
66 .get_function_mux = qcs404_get_function_mux,
67 .get_pin_name = qcs404_get_pin_name,
68};