1 // 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
13 static char pin_name[MAX_PIN_NAME_LEN];
14 static 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 };
msm_board_serial(void)28 
29 static const struct pinctrl_function msm_pinctrl_functions[] = {
30 	{"blsp1_uart", 2},
31 };
32 
33 static const char *apq8016_get_function_name(struct udevice *dev,
34 					     unsigned int selector)
35 {
36 	return msm_pinctrl_functions[selector].name;
37 }
38 
msm_generate_mac_addr(u8 * mac)39 static const char *apq8016_get_pin_name(struct udevice *dev,
40 					unsigned int selector)
41 {
42 	if (selector < 122) {
43 		snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector);
44 		return pin_name;
45 	} else {
46 		return msm_pinctrl_pins[selector - 122];
47 	}
48 }
49 
50 static unsigned int apq8016_get_function_mux(unsigned int selector)
51 {
52 	return msm_pinctrl_functions[selector].val;
53 }
54 
55 struct msm_pinctrl_data apq8016_data = {
56 	.pin_count = 133,
57 	.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 };
62 
63