Ramon Fried | f518086 | 2019-01-12 11:47:25 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm APQ8096 pinctrl |
| 4 | * |
| 5 | * (C) Copyright 2019 Ramon Fried <ramon.fried@gmail.com> |
| 6 | * |
| 7 | */ |
| 8 | |
Tom Rini | abb9a04 | 2024-05-18 20:20:43 -0600 | [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 | f518086 | 2019-01-12 11:47:25 +0200 | [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 | f518086 | 2019-01-12 11:47:25 +0200 | [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 | "sdc1_rclk", |
Ramon Fried | f518086 | 2019-01-12 11:47:25 +0200 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | static const struct pinctrl_function msm_pinctrl_functions[] = { |
| 27 | {"blsp_uart8", 2}, |
| 28 | }; |
| 29 | |
| 30 | static const char *apq8096_get_function_name(struct udevice *dev, |
| 31 | unsigned int selector) |
| 32 | { |
| 33 | return msm_pinctrl_functions[selector].name; |
| 34 | } |
| 35 | |
| 36 | static const char *apq8096_get_pin_name(struct udevice *dev, |
| 37 | unsigned int selector) |
| 38 | { |
| 39 | if (selector < 150) { |
Caleb Connolly | ab6a1ac | 2024-02-26 17:26:18 +0000 | [diff] [blame] | 40 | snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); |
Ramon Fried | f518086 | 2019-01-12 11:47:25 +0200 | [diff] [blame] | 41 | return pin_name; |
| 42 | } else { |
| 43 | return msm_pinctrl_pins[selector - 150]; |
| 44 | } |
| 45 | } |
| 46 | |
Volodymyr Babchuk | c4cc979 | 2024-03-11 21:33:46 +0000 | [diff] [blame] | 47 | static unsigned int apq8096_get_function_mux(__maybe_unused unsigned int pin, |
| 48 | unsigned int selector) |
Ramon Fried | f518086 | 2019-01-12 11:47:25 +0200 | [diff] [blame] | 49 | { |
| 50 | return msm_pinctrl_functions[selector].val; |
| 51 | } |
| 52 | |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 53 | static const struct msm_pinctrl_data apq8096_data = { |
Caleb Connolly | 190005c | 2024-02-26 17:26:17 +0000 | [diff] [blame] | 54 | .pin_data = { |
| 55 | .pin_count = 157, |
| 56 | .special_pins_start = 150, |
| 57 | }, |
Ramon Fried | f518086 | 2019-01-12 11:47:25 +0200 | [diff] [blame] | 58 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 59 | .get_function_name = apq8096_get_function_name, |
| 60 | .get_function_mux = apq8096_get_function_mux, |
| 61 | .get_pin_name = apq8096_get_pin_name, |
| 62 | }; |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 63 | |
| 64 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 65 | { .compatible = "qcom,msm8996-pinctrl", .data = (ulong)&apq8096_data }, |
| 66 | { /* Sentinal */ } |
| 67 | }; |
| 68 | |
| 69 | U_BOOT_DRIVER(pinctrl_apq8096) = { |
| 70 | .name = "pinctrl_apq8096", |
| 71 | .id = UCLASS_NOP, |
| 72 | .of_match = msm_pinctrl_ids, |
| 73 | .ops = &msm_pinctrl_ops, |
| 74 | .bind = msm_pinctrl_bind, |
| 75 | }; |