Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm sm8550 pinctrl |
| 4 | * |
| 5 | * (C) Copyright 2024 Linaro Ltd. |
| 6 | * |
| 7 | */ |
| 8 | |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | |
| 11 | #include "pinctrl-qcom.h" |
| 12 | |
| 13 | #define MAX_PIN_NAME_LEN 32 |
| 14 | static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); |
| 15 | |
| 16 | static const struct pinctrl_function msm_pinctrl_functions[] = { |
| 17 | {"qup1_se7", 1}, |
| 18 | {"gpio", 0}, |
| 19 | }; |
| 20 | |
| 21 | static const char *sm8550_get_function_name(struct udevice *dev, |
| 22 | unsigned int selector) |
| 23 | { |
| 24 | return msm_pinctrl_functions[selector].name; |
| 25 | } |
| 26 | |
| 27 | static const char *sm8550_get_pin_name(struct udevice *dev, |
| 28 | unsigned int selector) |
| 29 | { |
| 30 | static const char *special_pins_names[] = { |
| 31 | "ufs_reset", |
| 32 | "sdc2_clk", |
| 33 | "sdc2_cmd", |
| 34 | "sdc2_data", |
| 35 | }; |
| 36 | |
| 37 | if (selector >= 210 && selector <= 213) |
| 38 | snprintf(pin_name, MAX_PIN_NAME_LEN, special_pins_names[selector - 210]); |
| 39 | else |
| 40 | snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); |
| 41 | |
| 42 | return pin_name; |
| 43 | } |
| 44 | |
| 45 | static unsigned int sm8550_get_function_mux(__maybe_unused unsigned int pin, |
| 46 | unsigned int selector) |
| 47 | { |
| 48 | return msm_pinctrl_functions[selector].val; |
| 49 | } |
| 50 | |
| 51 | static struct msm_pinctrl_data sm8550_data = { |
| 52 | .pin_data = { |
| 53 | .pin_count = 214, |
| 54 | .special_pins_start = 210, |
| 55 | }, |
| 56 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 57 | .get_function_name = sm8550_get_function_name, |
| 58 | .get_function_mux = sm8550_get_function_mux, |
| 59 | .get_pin_name = sm8550_get_pin_name, |
| 60 | }; |
| 61 | |
| 62 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 63 | { .compatible = "qcom,sm8550-tlmm", .data = (ulong)&sm8550_data }, |
| 64 | { /* Sentinel */ } |
| 65 | }; |
| 66 | |
| 67 | U_BOOT_DRIVER(pinctrl_sm8550) = { |
| 68 | .name = "pinctrl_sm8550", |
| 69 | .id = UCLASS_NOP, |
| 70 | .of_match = msm_pinctrl_ids, |
| 71 | .ops = &msm_pinctrl_ops, |
| 72 | .bind = msm_pinctrl_bind, |
| 73 | }; |
| 74 | |