Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm sm8550 pinctrl |
| 4 | * |
| 5 | * (C) Copyright 2024 Linaro Ltd. |
| 6 | * |
| 7 | */ |
| 8 | |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 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 | {"qup1_se7", 1}, |
| 18 | {"gpio", 0}, |
| 19 | }; |
| 20 | |
Neil Armstrong | d1ec475 | 2024-05-28 10:31:56 +0200 | [diff] [blame] | 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, io) \ |
| 34 | { \ |
| 35 | .name = pg_name, \ |
| 36 | .ctl_reg = ctl, \ |
| 37 | .io_reg = io, \ |
| 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", 0xde000, 0xde004), |
| 47 | [1] = SDC_QDSD_PINGROUP("sdc2_clk", 0xd6000, 14, 6), |
| 48 | [2] = SDC_QDSD_PINGROUP("sdc2_cmd", 0xd6000, 11, 3), |
| 49 | [3] = SDC_QDSD_PINGROUP("sdc2_data", 0xd6000, 9, 0), |
| 50 | }; |
| 51 | |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 52 | static const char *sm8550_get_function_name(struct udevice *dev, |
| 53 | unsigned int selector) |
| 54 | { |
| 55 | return msm_pinctrl_functions[selector].name; |
| 56 | } |
| 57 | |
| 58 | static const char *sm8550_get_pin_name(struct udevice *dev, |
| 59 | unsigned int selector) |
| 60 | { |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 61 | if (selector >= 210 && selector <= 213) |
Neil Armstrong | d1ec475 | 2024-05-28 10:31:56 +0200 | [diff] [blame] | 62 | snprintf(pin_name, MAX_PIN_NAME_LEN, |
| 63 | msm_special_pins_data[selector - 210].name); |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 64 | else |
| 65 | snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); |
| 66 | |
| 67 | return pin_name; |
| 68 | } |
| 69 | |
| 70 | static unsigned int sm8550_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 sm8550_data = { |
| 77 | .pin_data = { |
| 78 | .pin_count = 214, |
| 79 | .special_pins_start = 210, |
Neil Armstrong | d1ec475 | 2024-05-28 10:31:56 +0200 | [diff] [blame] | 80 | .special_pins_data = msm_special_pins_data, |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 81 | }, |
| 82 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 83 | .get_function_name = sm8550_get_function_name, |
| 84 | .get_function_mux = sm8550_get_function_mux, |
| 85 | .get_pin_name = sm8550_get_pin_name, |
| 86 | }; |
| 87 | |
| 88 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 89 | { .compatible = "qcom,sm8550-tlmm", .data = (ulong)&sm8550_data }, |
| 90 | { /* Sentinel */ } |
| 91 | }; |
| 92 | |
| 93 | U_BOOT_DRIVER(pinctrl_sm8550) = { |
| 94 | .name = "pinctrl_sm8550", |
| 95 | .id = UCLASS_NOP, |
| 96 | .of_match = msm_pinctrl_ids, |
| 97 | .ops = &msm_pinctrl_ops, |
| 98 | .bind = msm_pinctrl_bind, |
| 99 | }; |
| 100 | |