Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm SDM845 pinctrl |
| 4 | * |
| 5 | * (C) Copyright 2021 Dzmitry Sankouski <dsankouski@gmail.com> |
| 6 | * |
| 7 | */ |
| 8 | |
Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +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" |
Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 13 | |
| 14 | #define MAX_PIN_NAME_LEN 32 |
| 15 | static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); |
| 16 | |
| 17 | static const struct pinctrl_function msm_pinctrl_functions[] = { |
| 18 | {"qup9", 1}, |
| 19 | {"gpio", 0}, |
| 20 | }; |
| 21 | |
| 22 | static const char *sdm845_get_function_name(struct udevice *dev, |
| 23 | unsigned int selector) |
| 24 | { |
| 25 | return msm_pinctrl_functions[selector].name; |
| 26 | } |
| 27 | |
| 28 | static const char *sdm845_get_pin_name(struct udevice *dev, |
| 29 | unsigned int selector) |
| 30 | { |
| 31 | snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector); |
| 32 | return pin_name; |
| 33 | } |
| 34 | |
| 35 | static unsigned int sdm845_get_function_mux(unsigned int selector) |
| 36 | { |
| 37 | return msm_pinctrl_functions[selector].val; |
| 38 | } |
| 39 | |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame^] | 40 | static struct msm_pinctrl_data sdm845_data = { |
Dzmitry Sankouski | e9be204 | 2021-10-17 13:44:29 +0300 | [diff] [blame] | 41 | .pin_count = 150, |
| 42 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 43 | .get_function_name = sdm845_get_function_name, |
| 44 | .get_function_mux = sdm845_get_function_mux, |
| 45 | .get_pin_name = sdm845_get_pin_name, |
| 46 | }; |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame^] | 47 | |
| 48 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 49 | { .compatible = "qcom,sdm845-pinctrl", .data = (ulong)&sdm845_data }, |
| 50 | { /* Sentinal */ } |
| 51 | }; |
| 52 | |
| 53 | U_BOOT_DRIVER(pinctrl_sdm845) = { |
| 54 | .name = "pinctrl_sdm845", |
| 55 | .id = UCLASS_NOP, |
| 56 | .of_match = msm_pinctrl_ids, |
| 57 | .ops = &msm_pinctrl_ops, |
| 58 | .bind = msm_pinctrl_bind, |
| 59 | }; |