blob: ac00afa2a1f4e65491e0555b8032ad7a26ac4273 [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
Sumit Garg46ad40b2022-07-12 12:42:10 +05308#include <common.h>
Caleb Connolly506eb532023-11-14 12:55:40 +00009#include <dm.h>
10
11#include "pinctrl-qcom.h"
Sumit Garg46ad40b2022-07-12 12:42:10 +053012
13#define MAX_PIN_NAME_LEN 32
14static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
15static const char * const msm_pinctrl_pins[] = {
16 "SDC1_RCLK",
17 "SDC1_CLK",
18 "SDC1_CMD",
19 "SDC1_DATA",
20 "SDC2_CLK",
21 "SDC2_CMD",
22 "SDC2_DATA",
23};
24
25static const struct pinctrl_function msm_pinctrl_functions[] = {
26 {"blsp_uart2", 1},
Sumit Garg09aea5d2023-02-01 19:28:51 +053027 {"rgmii_int", 1},
28 {"rgmii_ck", 1},
29 {"rgmii_tx", 1},
30 {"rgmii_ctl", 1},
31 {"rgmii_rx", 1},
32 {"rgmii_mdio", 1},
33 {"rgmii_mdc", 1},
Sumit Garg00e84692023-02-01 19:28:59 +053034 {"blsp_i2c0", 3},
35 {"blsp_i2c1", 2},
36 {"blsp_i2c_sda_a2", 3},
37 {"blsp_i2c_scl_a2", 3},
38 {"blsp_i2c3", 2},
39 {"blsp_i2c4", 1},
Sumit Garg46ad40b2022-07-12 12:42:10 +053040};
41
42static const char *qcs404_get_function_name(struct udevice *dev,
43 unsigned int selector)
44{
45 return msm_pinctrl_functions[selector].name;
46}
47
48static const char *qcs404_get_pin_name(struct udevice *dev,
49 unsigned int selector)
50{
51 if (selector < 120) {
52 snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector);
53 return pin_name;
54 } else {
55 return msm_pinctrl_pins[selector - 120];
56 }
57}
58
59static unsigned int qcs404_get_function_mux(unsigned int selector)
60{
61 return msm_pinctrl_functions[selector].val;
62}
63
Caleb Connolly506eb532023-11-14 12:55:40 +000064static struct msm_pinctrl_data qcs404_data = {
Caleb Connollyfabb8972023-11-14 12:55:42 +000065 .pin_data = { .pin_count = 126, },
Sumit Garg46ad40b2022-07-12 12:42:10 +053066 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
67 .get_function_name = qcs404_get_function_name,
68 .get_function_mux = qcs404_get_function_mux,
69 .get_pin_name = qcs404_get_pin_name,
70};
Caleb Connolly506eb532023-11-14 12:55:40 +000071
72static const struct udevice_id msm_pinctrl_ids[] = {
73 { .compatible = "qcom,qcs404-pinctrl", .data = (ulong)&qcs404_data },
74 { /* Sentinal */ }
75};
76
77U_BOOT_DRIVER(pinctrl_qcs404) = {
78 .name = "pinctrl_qcs404",
79 .id = UCLASS_NOP,
80 .of_match = msm_pinctrl_ids,
81 .ops = &msm_pinctrl_ops,
82 .bind = msm_pinctrl_bind,
83};