Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 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 |
Stephan Gerhold | 80dbfb8c | 2021-07-05 14:18:47 +0200 | [diff] [blame] | 13 | static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 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 | }; |
| 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 | |
| 39 | static const char *apq8016_get_pin_name(struct udevice *dev, |
| 40 | unsigned int selector) |
| 41 | { |
Ramon Fried | 0afbc81 | 2019-01-12 11:48:28 +0200 | [diff] [blame] | 42 | if (selector < 122) { |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 43 | snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector); |
| 44 | return pin_name; |
| 45 | } else { |
Ramon Fried | 0afbc81 | 2019-01-12 11:48:28 +0200 | [diff] [blame] | 46 | return msm_pinctrl_pins[selector - 122]; |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 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 = { |
Ramon Fried | 0afbc81 | 2019-01-12 11:48:28 +0200 | [diff] [blame] | 56 | .pin_count = 133, |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 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 | }; |