blob: 0c7437822ff20abef05a4526bfe0a8f6a3f596f3 [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
Caleb Connolly53b2c7a2023-11-14 12:55:40 +00009#include <dm.h>
10
11#include "pinctrl-qcom.h"
Ramon Friedad970512018-05-16 12:13:40 +030012
13#define MAX_PIN_NAME_LEN 32
Stephan Gerhold548b89f2021-07-05 14:18:47 +020014static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
Ramon Friedad970512018-05-16 12:13:40 +030015static const char * const msm_pinctrl_pins[] = {
Caleb Connolly97487ac2024-02-26 17:26:18 +000016 "sdc1_clk",
17 "sdc1_cmd",
18 "sdc1_data",
19 "sdc2_clk",
20 "sdc2_cmd",
21 "sdc2_data",
22 "qdsd_clk",
23 "qdsd_cmd",
24 "qdsd_data0",
25 "qdsd_data1",
26 "qdsd_data2",
27 "qdsd_data3",
Ramon Friedad970512018-05-16 12:13:40 +030028};
29
30static const struct pinctrl_function msm_pinctrl_functions[] = {
Sumit Garg095d96d2024-04-12 15:24:36 +053031 {"gpio", 0},
Sumit Garg6e992a62024-04-12 15:24:33 +053032 {"blsp_uart1", 2},
Caleb Connollyc744e632024-02-26 17:26:21 +000033 {"blsp_uart2", 2},
Ramon Friedad970512018-05-16 12:13:40 +030034};
35
36static const char *apq8016_get_function_name(struct udevice *dev,
37 unsigned int selector)
38{
39 return msm_pinctrl_functions[selector].name;
40}
41
42static const char *apq8016_get_pin_name(struct udevice *dev,
43 unsigned int selector)
44{
Ramon Fried8d24a472019-01-12 11:48:28 +020045 if (selector < 122) {
Caleb Connolly97487ac2024-02-26 17:26:18 +000046 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
Ramon Friedad970512018-05-16 12:13:40 +030047 return pin_name;
48 } else {
Ramon Fried8d24a472019-01-12 11:48:28 +020049 return msm_pinctrl_pins[selector - 122];
Ramon Friedad970512018-05-16 12:13:40 +030050 }
51}
52
Volodymyr Babchuk493f0692024-03-11 21:33:46 +000053static unsigned int apq8016_get_function_mux(__maybe_unused unsigned int pin,
54 unsigned int selector)
Ramon Friedad970512018-05-16 12:13:40 +030055{
56 return msm_pinctrl_functions[selector].val;
57}
58
Caleb Connolly53b2c7a2023-11-14 12:55:40 +000059static const struct msm_pinctrl_data apq8016_data = {
Caleb Connollya245aec2024-02-26 17:26:17 +000060 .pin_data = {
61 .pin_count = 133,
62 .special_pins_start = 122,
63 },
Ramon Friedad970512018-05-16 12:13:40 +030064 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
65 .get_function_name = apq8016_get_function_name,
66 .get_function_mux = apq8016_get_function_mux,
67 .get_pin_name = apq8016_get_pin_name,
68};
Caleb Connolly53b2c7a2023-11-14 12:55:40 +000069
70static const struct udevice_id msm_pinctrl_ids[] = {
71 { .compatible = "qcom,msm8916-pinctrl", .data = (ulong)&apq8016_data },
72 { /* Sentinal */ }
73};
74
75U_BOOT_DRIVER(pinctrl_apq8016) = {
76 .name = "pinctrl_apq8016",
77 .id = UCLASS_NOP,
78 .of_match = msm_pinctrl_ids,
79 .ops = &msm_pinctrl_ops,
80 .bind = msm_pinctrl_bind,
Caleb Connolly80489762024-02-26 17:26:19 +000081 .flags = DM_FLAG_PRE_RELOC,
Caleb Connolly53b2c7a2023-11-14 12:55:40 +000082};