Neil Armstrong | 159dc0c | 2024-11-15 16:44:15 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm x1e80100 pinctrl |
| 4 | * |
| 5 | * (C) Copyright 2024 Linaro Ltd. |
| 6 | * |
| 7 | */ |
| 8 | |
| 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 | {"qup2_se5", 1}, |
| 18 | {"gpio", 0}, |
| 19 | }; |
| 20 | |
| 21 | #define SDC_QDSD_PINGROUP(pg_name, ctl, pull, drv) \ |
| 22 | { \ |
| 23 | .name = pg_name, \ |
| 24 | .ctl_reg = ctl, \ |
| 25 | .io_reg = 0, \ |
| 26 | .pull_bit = pull, \ |
| 27 | .drv_bit = drv, \ |
| 28 | .oe_bit = -1, \ |
| 29 | .in_bit = -1, \ |
| 30 | .out_bit = -1, \ |
| 31 | } |
| 32 | |
| 33 | #define UFS_RESET(pg_name, ctl) \ |
| 34 | { \ |
| 35 | .name = pg_name, \ |
| 36 | .ctl_reg = ctl, \ |
| 37 | .io_reg = ctl + 0x4, \ |
| 38 | .pull_bit = 3, \ |
| 39 | .drv_bit = 0, \ |
| 40 | .oe_bit = -1, \ |
| 41 | .in_bit = -1, \ |
| 42 | .out_bit = 0, \ |
| 43 | } |
| 44 | |
| 45 | static const struct msm_special_pin_data msm_special_pins_data[] = { |
| 46 | [0] = UFS_RESET("ufs_reset", 0xf9000), |
| 47 | [1] = SDC_QDSD_PINGROUP("sdc2_clk", 0xf2000, 14, 6), |
| 48 | [2] = SDC_QDSD_PINGROUP("sdc2_cmd", 0xf2000, 11, 3), |
| 49 | [3] = SDC_QDSD_PINGROUP("sdc2_data", 0xf2000, 9, 0), |
| 50 | }; |
| 51 | |
| 52 | static const char *x1e80100_get_function_name(struct udevice *dev, |
| 53 | unsigned int selector) |
| 54 | { |
| 55 | return msm_pinctrl_functions[selector].name; |
| 56 | } |
| 57 | |
| 58 | static const char *x1e80100_get_pin_name(struct udevice *dev, |
| 59 | unsigned int selector) |
| 60 | { |
| 61 | if (selector >= 238 && selector <= 241) |
| 62 | snprintf(pin_name, MAX_PIN_NAME_LEN, |
| 63 | msm_special_pins_data[selector - 238].name); |
| 64 | else |
| 65 | snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); |
| 66 | |
| 67 | return pin_name; |
| 68 | } |
| 69 | |
| 70 | static unsigned int x1e80100_get_function_mux(__maybe_unused unsigned int pin, |
| 71 | unsigned int selector) |
| 72 | { |
| 73 | return msm_pinctrl_functions[selector].val; |
| 74 | } |
| 75 | |
| 76 | static struct msm_pinctrl_data x1e80100_data = { |
| 77 | .pin_data = { |
| 78 | .pin_count = 242, |
| 79 | .special_pins_start = 238, |
| 80 | .special_pins_data = msm_special_pins_data, |
| 81 | }, |
| 82 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 83 | .get_function_name = x1e80100_get_function_name, |
| 84 | .get_function_mux = x1e80100_get_function_mux, |
| 85 | .get_pin_name = x1e80100_get_pin_name, |
| 86 | }; |
| 87 | |
| 88 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 89 | { .compatible = "qcom,x1e80100-tlmm", .data = (ulong)&x1e80100_data }, |
| 90 | { /* Sentinel */ } |
| 91 | }; |
| 92 | |
| 93 | U_BOOT_DRIVER(pinctrl_x1e80100) = { |
| 94 | .name = "pinctrl_x1e80100", |
| 95 | .id = UCLASS_NOP, |
| 96 | .of_match = msm_pinctrl_ids, |
| 97 | .ops = &msm_pinctrl_ops, |
| 98 | .bind = msm_pinctrl_bind, |
| 99 | }; |
| 100 | |