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 | |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 9 | #include <common.h> |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 10 | #include <dm.h> |
| 11 | |
| 12 | #include "pinctrl-qcom.h" |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 13 | |
| 14 | #define MAX_PIN_NAME_LEN 32 |
Stephan Gerhold | 80dbfb8c | 2021-07-05 14:18:47 +0200 | [diff] [blame] | 15 | static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 16 | static const char * const msm_pinctrl_pins[] = { |
Caleb Connolly | ab6a1ac | 2024-02-26 17:26:18 +0000 | [diff] [blame] | 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", |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | static const struct pinctrl_function msm_pinctrl_functions[] = { |
Caleb Connolly | 154ed1d | 2024-02-26 17:26:21 +0000 | [diff] [blame] | 32 | {"blsp_uart2", 2}, |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | static const char *apq8016_get_function_name(struct udevice *dev, |
| 36 | unsigned int selector) |
| 37 | { |
| 38 | return msm_pinctrl_functions[selector].name; |
| 39 | } |
| 40 | |
| 41 | static const char *apq8016_get_pin_name(struct udevice *dev, |
| 42 | unsigned int selector) |
| 43 | { |
Ramon Fried | 0afbc81 | 2019-01-12 11:48:28 +0200 | [diff] [blame] | 44 | if (selector < 122) { |
Caleb Connolly | ab6a1ac | 2024-02-26 17:26:18 +0000 | [diff] [blame] | 45 | snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 46 | return pin_name; |
| 47 | } else { |
Ramon Fried | 0afbc81 | 2019-01-12 11:48:28 +0200 | [diff] [blame] | 48 | return msm_pinctrl_pins[selector - 122]; |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | |
| 52 | static unsigned int apq8016_get_function_mux(unsigned int selector) |
| 53 | { |
| 54 | return msm_pinctrl_functions[selector].val; |
| 55 | } |
| 56 | |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 57 | static const struct msm_pinctrl_data apq8016_data = { |
Caleb Connolly | 190005c | 2024-02-26 17:26:17 +0000 | [diff] [blame] | 58 | .pin_data = { |
| 59 | .pin_count = 133, |
| 60 | .special_pins_start = 122, |
| 61 | }, |
Ramon Fried | e43d8e7 | 2018-05-16 12:13:40 +0300 | [diff] [blame] | 62 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 63 | .get_function_name = apq8016_get_function_name, |
| 64 | .get_function_mux = apq8016_get_function_mux, |
| 65 | .get_pin_name = apq8016_get_pin_name, |
| 66 | }; |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 67 | |
| 68 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 69 | { .compatible = "qcom,msm8916-pinctrl", .data = (ulong)&apq8016_data }, |
| 70 | { /* Sentinal */ } |
| 71 | }; |
| 72 | |
| 73 | U_BOOT_DRIVER(pinctrl_apq8016) = { |
| 74 | .name = "pinctrl_apq8016", |
| 75 | .id = UCLASS_NOP, |
| 76 | .of_match = msm_pinctrl_ids, |
| 77 | .ops = &msm_pinctrl_ops, |
| 78 | .bind = msm_pinctrl_bind, |
Caleb Connolly | e8976f3 | 2024-02-26 17:26:19 +0000 | [diff] [blame] | 79 | .flags = DM_FLAG_PRE_RELOC, |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 80 | }; |