Robert Marko | e479a7d | 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 | |
| 10 | #include "pinctrl-snapdragon.h" |
| 11 | #include <common.h> |
| 12 | |
| 13 | #define MAX_PIN_NAME_LEN 32 |
| 14 | static char pin_name[MAX_PIN_NAME_LEN]; |
| 15 | |
| 16 | static const struct pinctrl_function msm_pinctrl_functions[] = { |
| 17 | {"gpio", 0}, |
| 18 | {"blsp_uart0_0", 1}, /* Only for GPIO:16,17 */ |
| 19 | {"blsp_uart0_1", 2}, /* Only for GPIO:60,61 */ |
| 20 | {"blsp_uart1", 1}, |
Robert Marko | 96d6036 | 2020-10-08 22:05:10 +0200 | [diff] [blame] | 21 | {"blsp_spi0_0", 1}, /* Only for GPIO:12,13,14,15 */ |
| 22 | {"blsp_spi0_1", 2}, /* Only for GPIO:54,55,56,57 */ |
| 23 | {"blsp_spi1", 2}, |
Robert Marko | 5297341 | 2020-10-08 22:05:12 +0200 | [diff] [blame] | 24 | {"mdio_0", 1}, /* Only for GPIO6 */ |
| 25 | {"mdio_1", 2}, /* Only for GPIO53 */ |
| 26 | {"mdc_0", 1}, /* Only for GPIO7 */ |
| 27 | {"mdc_1", 2}, /* Only for GPIO52 */ |
Robert Marko | e479a7d | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 28 | }; |
| 29 | |
| 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 | |
| 43 | static unsigned int ipq4019_get_function_mux(unsigned int selector) |
| 44 | { |
| 45 | return msm_pinctrl_functions[selector].val; |
| 46 | } |
| 47 | |
| 48 | struct msm_pinctrl_data ipq4019_data = { |
| 49 | .pin_count = 100, |
| 50 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 51 | .get_function_name = ipq4019_get_function_name, |
| 52 | .get_function_mux = ipq4019_get_function_mux, |
| 53 | .get_pin_name = ipq4019_get_pin_name, |
| 54 | }; |