blob: b14a8921af4f39b39f066603b9ff24afffdf88c5 [file] [log] [blame]
Ramon Friedad970512018-05-16 12:13:40 +03001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Qualcomm APQ8016 pinctrl
4 *
5 * (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com>
6 *
7 */
8
Ramon Friedad970512018-05-16 12:13:40 +03009#include <common.h>
Caleb Connolly53b2c7a2023-11-14 12:55:40 +000010#include <dm.h>
11
12#include "pinctrl-qcom.h"
Ramon Friedad970512018-05-16 12:13:40 +030013
14#define MAX_PIN_NAME_LEN 32
Stephan Gerhold548b89f2021-07-05 14:18:47 +020015static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
Ramon Friedad970512018-05-16 12:13:40 +030016static const char * const msm_pinctrl_pins[] = {
Caleb Connolly97487ac2024-02-26 17:26:18 +000017 "sdc1_clk",
18 "sdc1_cmd",
19 "sdc1_data",
20 "sdc2_clk",
21 "sdc2_cmd",
22 "sdc2_data",
23 "qdsd_clk",
24 "qdsd_cmd",
25 "qdsd_data0",
26 "qdsd_data1",
27 "qdsd_data2",
28 "qdsd_data3",
Ramon Friedad970512018-05-16 12:13:40 +030029};
30
31static const struct pinctrl_function msm_pinctrl_functions[] = {
Sumit Garg095d96d2024-04-12 15:24:36 +053032 {"gpio", 0},
Sumit Garg6e992a62024-04-12 15:24:33 +053033 {"blsp_uart1", 2},
Caleb Connollyc744e632024-02-26 17:26:21 +000034 {"blsp_uart2", 2},
Ramon Friedad970512018-05-16 12:13:40 +030035};
36
37static const char *apq8016_get_function_name(struct udevice *dev,
38 unsigned int selector)
39{
40 return msm_pinctrl_functions[selector].name;
41}
42
43static const char *apq8016_get_pin_name(struct udevice *dev,
44 unsigned int selector)
45{
Ramon Fried8d24a472019-01-12 11:48:28 +020046 if (selector < 122) {
Caleb Connolly97487ac2024-02-26 17:26:18 +000047 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
Ramon Friedad970512018-05-16 12:13:40 +030048 return pin_name;
49 } else {
Ramon Fried8d24a472019-01-12 11:48:28 +020050 return msm_pinctrl_pins[selector - 122];
Ramon Friedad970512018-05-16 12:13:40 +030051 }
52}
53
Volodymyr Babchuk493f0692024-03-11 21:33:46 +000054static unsigned int apq8016_get_function_mux(__maybe_unused unsigned int pin,
55 unsigned int selector)
Ramon Friedad970512018-05-16 12:13:40 +030056{
57 return msm_pinctrl_functions[selector].val;
58}
59
Caleb Connolly53b2c7a2023-11-14 12:55:40 +000060static const struct msm_pinctrl_data apq8016_data = {
Caleb Connollya245aec2024-02-26 17:26:17 +000061 .pin_data = {
62 .pin_count = 133,
63 .special_pins_start = 122,
64 },
Ramon Friedad970512018-05-16 12:13:40 +030065 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
66 .get_function_name = apq8016_get_function_name,
67 .get_function_mux = apq8016_get_function_mux,
68 .get_pin_name = apq8016_get_pin_name,
69};
Caleb Connolly53b2c7a2023-11-14 12:55:40 +000070
71static const struct udevice_id msm_pinctrl_ids[] = {
72 { .compatible = "qcom,msm8916-pinctrl", .data = (ulong)&apq8016_data },
73 { /* Sentinal */ }
74};
75
76U_BOOT_DRIVER(pinctrl_apq8016) = {
77 .name = "pinctrl_apq8016",
78 .id = UCLASS_NOP,
79 .of_match = msm_pinctrl_ids,
80 .ops = &msm_pinctrl_ops,
81 .bind = msm_pinctrl_bind,
Caleb Connolly80489762024-02-26 17:26:19 +000082 .flags = DM_FLAG_PRE_RELOC,
Caleb Connolly53b2c7a2023-11-14 12:55:40 +000083};