xref: /openbmc/u-boot/arch/arm/mach-snapdragon/pinctrl-apq8096.c (revision 0da90255083681a02b24528f80da9d4062ff634a)
1*94268f1aSRamon Fried // SPDX-License-Identifier: GPL-2.0+
2*94268f1aSRamon Fried /*
3*94268f1aSRamon Fried  * Qualcomm APQ8096 pinctrl
4*94268f1aSRamon Fried  *
5*94268f1aSRamon Fried  * (C) Copyright 2019 Ramon Fried <ramon.fried@gmail.com>
6*94268f1aSRamon Fried  *
7*94268f1aSRamon Fried  */
8*94268f1aSRamon Fried 
9*94268f1aSRamon Fried #include "pinctrl-snapdragon.h"
10*94268f1aSRamon Fried #include <common.h>
11*94268f1aSRamon Fried 
12*94268f1aSRamon Fried #define MAX_PIN_NAME_LEN 32
13*94268f1aSRamon Fried static char pin_name[MAX_PIN_NAME_LEN];
14*94268f1aSRamon Fried static const char * const msm_pinctrl_pins[] = {
15*94268f1aSRamon Fried 	"SDC1_CLK",
16*94268f1aSRamon Fried 	"SDC1_CMD",
17*94268f1aSRamon Fried 	"SDC1_DATA",
18*94268f1aSRamon Fried 	"SDC2_CLK",
19*94268f1aSRamon Fried 	"SDC2_CMD",
20*94268f1aSRamon Fried 	"SDC2_DATA",
21*94268f1aSRamon Fried 	"SDC1_RCLK",
22*94268f1aSRamon Fried };
23*94268f1aSRamon Fried 
24*94268f1aSRamon Fried static const struct pinctrl_function msm_pinctrl_functions[] = {
25*94268f1aSRamon Fried 	{"blsp_uart8", 2},
26*94268f1aSRamon Fried };
27*94268f1aSRamon Fried 
apq8096_get_function_name(struct udevice * dev,unsigned int selector)28*94268f1aSRamon Fried static const char *apq8096_get_function_name(struct udevice *dev,
29*94268f1aSRamon Fried 					     unsigned int selector)
30*94268f1aSRamon Fried {
31*94268f1aSRamon Fried 	return msm_pinctrl_functions[selector].name;
32*94268f1aSRamon Fried }
33*94268f1aSRamon Fried 
apq8096_get_pin_name(struct udevice * dev,unsigned int selector)34*94268f1aSRamon Fried static const char *apq8096_get_pin_name(struct udevice *dev,
35*94268f1aSRamon Fried 					unsigned int selector)
36*94268f1aSRamon Fried {
37*94268f1aSRamon Fried 	if (selector < 150) {
38*94268f1aSRamon Fried 		snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector);
39*94268f1aSRamon Fried 		return pin_name;
40*94268f1aSRamon Fried 	} else {
41*94268f1aSRamon Fried 		return msm_pinctrl_pins[selector - 150];
42*94268f1aSRamon Fried 	}
43*94268f1aSRamon Fried }
44*94268f1aSRamon Fried 
apq8096_get_function_mux(unsigned int selector)45*94268f1aSRamon Fried static unsigned int apq8096_get_function_mux(unsigned int selector)
46*94268f1aSRamon Fried {
47*94268f1aSRamon Fried 	return msm_pinctrl_functions[selector].val;
48*94268f1aSRamon Fried }
49*94268f1aSRamon Fried 
50*94268f1aSRamon Fried struct msm_pinctrl_data apq8096_data = {
51*94268f1aSRamon Fried 	.pin_count = 157,
52*94268f1aSRamon Fried 	.functions_count = ARRAY_SIZE(msm_pinctrl_functions),
53*94268f1aSRamon Fried 	.get_function_name = apq8096_get_function_name,
54*94268f1aSRamon Fried 	.get_function_mux = apq8096_get_function_mux,
55*94268f1aSRamon Fried 	.get_pin_name = apq8096_get_pin_name,
56*94268f1aSRamon Fried };
57