Sumit Garg | 46ad40b | 2022-07-12 12:42:10 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm QCS404 pinctrl |
| 4 | * |
| 5 | * (C) Copyright 2022 Sumit Garg <sumit.garg@linaro.org> |
| 6 | */ |
| 7 | |
Sumit Garg | 46ad40b | 2022-07-12 12:42:10 +0530 | [diff] [blame] | 8 | #include <common.h> |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | |
| 11 | #include "pinctrl-qcom.h" |
Sumit Garg | 46ad40b | 2022-07-12 12:42:10 +0530 | [diff] [blame] | 12 | |
| 13 | #define MAX_PIN_NAME_LEN 32 |
| 14 | static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); |
| 15 | static const char * const msm_pinctrl_pins[] = { |
| 16 | "SDC1_RCLK", |
| 17 | "SDC1_CLK", |
| 18 | "SDC1_CMD", |
| 19 | "SDC1_DATA", |
| 20 | "SDC2_CLK", |
| 21 | "SDC2_CMD", |
| 22 | "SDC2_DATA", |
| 23 | }; |
| 24 | |
| 25 | static const struct pinctrl_function msm_pinctrl_functions[] = { |
| 26 | {"blsp_uart2", 1}, |
Sumit Garg | 09aea5d | 2023-02-01 19:28:51 +0530 | [diff] [blame] | 27 | {"rgmii_int", 1}, |
| 28 | {"rgmii_ck", 1}, |
| 29 | {"rgmii_tx", 1}, |
| 30 | {"rgmii_ctl", 1}, |
| 31 | {"rgmii_rx", 1}, |
| 32 | {"rgmii_mdio", 1}, |
| 33 | {"rgmii_mdc", 1}, |
Sumit Garg | 00e8469 | 2023-02-01 19:28:59 +0530 | [diff] [blame] | 34 | {"blsp_i2c0", 3}, |
| 35 | {"blsp_i2c1", 2}, |
| 36 | {"blsp_i2c_sda_a2", 3}, |
| 37 | {"blsp_i2c_scl_a2", 3}, |
| 38 | {"blsp_i2c3", 2}, |
| 39 | {"blsp_i2c4", 1}, |
Sumit Garg | 46ad40b | 2022-07-12 12:42:10 +0530 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | static const char *qcs404_get_function_name(struct udevice *dev, |
| 43 | unsigned int selector) |
| 44 | { |
| 45 | return msm_pinctrl_functions[selector].name; |
| 46 | } |
| 47 | |
| 48 | static const char *qcs404_get_pin_name(struct udevice *dev, |
| 49 | unsigned int selector) |
| 50 | { |
| 51 | if (selector < 120) { |
| 52 | snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector); |
| 53 | return pin_name; |
| 54 | } else { |
| 55 | return msm_pinctrl_pins[selector - 120]; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | static unsigned int qcs404_get_function_mux(unsigned int selector) |
| 60 | { |
| 61 | return msm_pinctrl_functions[selector].val; |
| 62 | } |
| 63 | |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 64 | static struct msm_pinctrl_data qcs404_data = { |
Caleb Connolly | fabb897 | 2023-11-14 12:55:42 +0000 | [diff] [blame] | 65 | .pin_data = { .pin_count = 126, }, |
Sumit Garg | 46ad40b | 2022-07-12 12:42:10 +0530 | [diff] [blame] | 66 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 67 | .get_function_name = qcs404_get_function_name, |
| 68 | .get_function_mux = qcs404_get_function_mux, |
| 69 | .get_pin_name = qcs404_get_pin_name, |
| 70 | }; |
Caleb Connolly | 506eb53 | 2023-11-14 12:55:40 +0000 | [diff] [blame] | 71 | |
| 72 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 73 | { .compatible = "qcom,qcs404-pinctrl", .data = (ulong)&qcs404_data }, |
| 74 | { /* Sentinal */ } |
| 75 | }; |
| 76 | |
| 77 | U_BOOT_DRIVER(pinctrl_qcs404) = { |
| 78 | .name = "pinctrl_qcs404", |
| 79 | .id = UCLASS_NOP, |
| 80 | .of_match = msm_pinctrl_ids, |
| 81 | .ops = &msm_pinctrl_ops, |
| 82 | .bind = msm_pinctrl_bind, |
| 83 | }; |