blob: 70c0be0bca90e8ea86e27a661f3a0a9a6b48e4fd [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
9#include "pinctrl-snapdragon.h"
10#include <common.h>
11
12#define MAX_PIN_NAME_LEN 32
Stephan Gerhold80dbfb8c2021-07-05 14:18:47 +020013static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
Ramon Friede43d8e72018-05-16 12:13:40 +030014static const char * const msm_pinctrl_pins[] = {
15 "SDC1_CLK",
16 "SDC1_CMD",
17 "SDC1_DATA",
18 "SDC2_CLK",
19 "SDC2_CMD",
20 "SDC2_DATA",
21 "QDSD_CLK",
22 "QDSD_CMD",
23 "QDSD_DATA0",
24 "QDSD_DATA1",
25 "QDSD_DATA2",
26 "QDSD_DATA3",
27};
28
29static const struct pinctrl_function msm_pinctrl_functions[] = {
30 {"blsp1_uart", 2},
31};
32
33static const char *apq8016_get_function_name(struct udevice *dev,
34 unsigned int selector)
35{
36 return msm_pinctrl_functions[selector].name;
37}
38
39static const char *apq8016_get_pin_name(struct udevice *dev,
40 unsigned int selector)
41{
Ramon Fried0afbc812019-01-12 11:48:28 +020042 if (selector < 122) {
Ramon Friede43d8e72018-05-16 12:13:40 +030043 snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector);
44 return pin_name;
45 } else {
Ramon Fried0afbc812019-01-12 11:48:28 +020046 return msm_pinctrl_pins[selector - 122];
Ramon Friede43d8e72018-05-16 12:13:40 +030047 }
48}
49
50static unsigned int apq8016_get_function_mux(unsigned int selector)
51{
52 return msm_pinctrl_functions[selector].val;
53}
54
55struct msm_pinctrl_data apq8016_data = {
Ramon Fried0afbc812019-01-12 11:48:28 +020056 .pin_count = 133,
Ramon Friede43d8e72018-05-16 12:13:40 +030057 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
58 .get_function_name = apq8016_get_function_name,
59 .get_function_mux = apq8016_get_function_mux,
60 .get_pin_name = apq8016_get_pin_name,
61};