blob: 8149ffd83cc469e854c02b33339d555e2035d588 [file] [log] [blame]
Ramon Friede43d8e72018-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 Friede43d8e72018-05-16 12:13:40 +03009#include <common.h>
Caleb Connolly506eb532023-11-14 12:55:40 +000010#include <dm.h>
11
12#include "pinctrl-qcom.h"
Ramon Friede43d8e72018-05-16 12:13:40 +030013
14#define MAX_PIN_NAME_LEN 32
Stephan Gerhold80dbfb8c2021-07-05 14:18:47 +020015static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
Ramon Friede43d8e72018-05-16 12:13:40 +030016static const char * const msm_pinctrl_pins[] = {
17 "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",
29};
30
31static const struct pinctrl_function msm_pinctrl_functions[] = {
32 {"blsp1_uart", 2},
33};
34
35static const char *apq8016_get_function_name(struct udevice *dev,
36 unsigned int selector)
37{
38 return msm_pinctrl_functions[selector].name;
39}
40
41static const char *apq8016_get_pin_name(struct udevice *dev,
42 unsigned int selector)
43{
Ramon Fried0afbc812019-01-12 11:48:28 +020044 if (selector < 122) {
Ramon Friede43d8e72018-05-16 12:13:40 +030045 snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector);
46 return pin_name;
47 } else {
Ramon Fried0afbc812019-01-12 11:48:28 +020048 return msm_pinctrl_pins[selector - 122];
Ramon Friede43d8e72018-05-16 12:13:40 +030049 }
50}
51
52static unsigned int apq8016_get_function_mux(unsigned int selector)
53{
54 return msm_pinctrl_functions[selector].val;
55}
56
Caleb Connolly506eb532023-11-14 12:55:40 +000057static const struct msm_pinctrl_data apq8016_data = {
Caleb Connollyfabb8972023-11-14 12:55:42 +000058 .pin_data = { .pin_count = 133, },
Ramon Friede43d8e72018-05-16 12:13:40 +030059 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
60 .get_function_name = apq8016_get_function_name,
61 .get_function_mux = apq8016_get_function_mux,
62 .get_pin_name = apq8016_get_pin_name,
63};
Caleb Connolly506eb532023-11-14 12:55:40 +000064
65static const struct udevice_id msm_pinctrl_ids[] = {
66 { .compatible = "qcom,msm8916-pinctrl", .data = (ulong)&apq8016_data },
67 { /* Sentinal */ }
68};
69
70U_BOOT_DRIVER(pinctrl_apq8016) = {
71 .name = "pinctrl_apq8016",
72 .id = UCLASS_NOP,
73 .of_match = msm_pinctrl_ids,
74 .ops = &msm_pinctrl_ops,
75 .bind = msm_pinctrl_bind,
76};