Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm IPQ40xx pinctrl |
| 4 | * |
| 5 | * Copyright (c) 2019 Sartura Ltd. |
| 6 | * |
| 7 | * Author: Robert Marko <robert.marko@sartura.hr> |
| 8 | */ |
| 9 | |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 10 | #include <common.h> |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 11 | #include <dm.h> |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 12 | |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 13 | #include "pinctrl-qcom.h" |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 14 | |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 15 | #define MAX_PIN_NAME_LEN 32 |
| 16 | static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 17 | static const struct pinctrl_function msm_pinctrl_functions[] = { |
| 18 | {"gpio", 0}, |
| 19 | {"blsp_uart0_0", 1}, /* Only for GPIO:16,17 */ |
| 20 | {"blsp_uart0_1", 2}, /* Only for GPIO:60,61 */ |
| 21 | {"blsp_uart1", 1}, |
Robert Marko | da34423 | 2020-10-08 22:05:10 +0200 | [diff] [blame] | 22 | {"blsp_spi0_0", 1}, /* Only for GPIO:12,13,14,15 */ |
| 23 | {"blsp_spi0_1", 2}, /* Only for GPIO:54,55,56,57 */ |
| 24 | {"blsp_spi1", 2}, |
Robert Marko | 6649aa8 | 2020-10-08 22:05:12 +0200 | [diff] [blame] | 25 | {"mdio_0", 1}, /* Only for GPIO6 */ |
| 26 | {"mdio_1", 2}, /* Only for GPIO53 */ |
| 27 | {"mdc_0", 1}, /* Only for GPIO7 */ |
| 28 | {"mdc_1", 2}, /* Only for GPIO52 */ |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 29 | }; |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 30 | static const char *ipq4019_get_function_name(struct udevice *dev, |
| 31 | unsigned int selector) |
| 32 | { |
| 33 | return msm_pinctrl_functions[selector].name; |
| 34 | } |
| 35 | |
| 36 | static const char *ipq4019_get_pin_name(struct udevice *dev, |
| 37 | unsigned int selector) |
| 38 | { |
| 39 | snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector); |
| 40 | return pin_name; |
| 41 | } |
| 42 | |
Volodymyr Babchuk | c4cc979 | 2024-03-11 21:33:46 +0000 | [diff] [blame] | 43 | static unsigned int ipq4019_get_function_mux(__maybe_unused unsigned int pin, |
| 44 | unsigned int selector) |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 45 | { |
| 46 | return msm_pinctrl_functions[selector].val; |
| 47 | } |
| 48 | |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 49 | static const struct msm_pinctrl_data ipq4019_data = { |
Caleb Connolly | 190005c | 2024-02-26 17:26:17 +0000 | [diff] [blame] | 50 | .pin_data = { |
| 51 | .pin_count = 100, |
| 52 | .special_pins_start = 100, /* There are no special pins */ |
| 53 | }, |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 54 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 55 | .get_function_name = ipq4019_get_function_name, |
| 56 | .get_function_mux = ipq4019_get_function_mux, |
| 57 | .get_pin_name = ipq4019_get_pin_name, |
| 58 | }; |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 59 | |
| 60 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 61 | { .compatible = "qcom,ipq4019-pinctrl", .data = (ulong)&ipq4019_data }, |
| 62 | { /* Sentinal */ } |
| 63 | }; |
| 64 | |
| 65 | U_BOOT_DRIVER(pinctrl_ipq4019) = { |
| 66 | .name = "pinctrl_ipq4019", |
| 67 | .id = UCLASS_NOP, |
| 68 | .of_match = msm_pinctrl_ids, |
| 69 | .ops = &msm_pinctrl_ops, |
| 70 | .bind = msm_pinctrl_bind, |
| 71 | }; |