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}, |
Neil Armstrong | 4f2a057 | 2024-11-25 09:29:10 +0100 | [diff] [blame] | 19 | {"pcie1_clk_req_n", 1}, |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 20 | }; |
| 21 | |
Neil Armstrong | d1ec475 | 2024-05-28 10:31:56 +0200 | [diff] [blame] | 22 | #define SDC_QDSD_PINGROUP(pg_name, ctl, pull, drv) \ |
| 23 | { \ |
| 24 | .name = pg_name, \ |
| 25 | .ctl_reg = ctl, \ |
| 26 | .io_reg = 0, \ |
| 27 | .pull_bit = pull, \ |
| 28 | .drv_bit = drv, \ |
| 29 | .oe_bit = -1, \ |
| 30 | .in_bit = -1, \ |
| 31 | .out_bit = -1, \ |
| 32 | } |
| 33 | |
| 34 | #define UFS_RESET(pg_name, ctl, io) \ |
| 35 | { \ |
| 36 | .name = pg_name, \ |
| 37 | .ctl_reg = ctl, \ |
| 38 | .io_reg = io, \ |
| 39 | .pull_bit = 3, \ |
| 40 | .drv_bit = 0, \ |
| 41 | .oe_bit = -1, \ |
| 42 | .in_bit = -1, \ |
| 43 | .out_bit = 0, \ |
| 44 | } |
| 45 | |
| 46 | static const struct msm_special_pin_data msm_special_pins_data[] = { |
| 47 | [0] = UFS_RESET("ufs_reset", 0xde000, 0xde004), |
| 48 | [1] = SDC_QDSD_PINGROUP("sdc2_clk", 0xd6000, 14, 6), |
| 49 | [2] = SDC_QDSD_PINGROUP("sdc2_cmd", 0xd6000, 11, 3), |
| 50 | [3] = SDC_QDSD_PINGROUP("sdc2_data", 0xd6000, 9, 0), |
| 51 | }; |
| 52 | |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 53 | static const char *sm8550_get_function_name(struct udevice *dev, |
| 54 | unsigned int selector) |
| 55 | { |
| 56 | return msm_pinctrl_functions[selector].name; |
| 57 | } |
| 58 | |
| 59 | static const char *sm8550_get_pin_name(struct udevice *dev, |
| 60 | unsigned int selector) |
| 61 | { |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 62 | if (selector >= 210 && selector <= 213) |
Neil Armstrong | d1ec475 | 2024-05-28 10:31:56 +0200 | [diff] [blame] | 63 | snprintf(pin_name, MAX_PIN_NAME_LEN, |
| 64 | msm_special_pins_data[selector - 210].name); |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 65 | else |
| 66 | snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); |
| 67 | |
| 68 | return pin_name; |
| 69 | } |
| 70 | |
Varadarajan Narayanan | e7f07e0 | 2025-02-26 12:15:02 +0530 | [diff] [blame^] | 71 | static int sm8550_get_function_mux(__maybe_unused unsigned int pin, |
| 72 | unsigned int selector) |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 73 | { |
| 74 | return msm_pinctrl_functions[selector].val; |
| 75 | } |
| 76 | |
| 77 | static struct msm_pinctrl_data sm8550_data = { |
| 78 | .pin_data = { |
| 79 | .pin_count = 214, |
| 80 | .special_pins_start = 210, |
Neil Armstrong | d1ec475 | 2024-05-28 10:31:56 +0200 | [diff] [blame] | 81 | .special_pins_data = msm_special_pins_data, |
Neil Armstrong | f0f7ff8 | 2024-04-05 10:15:10 +0200 | [diff] [blame] | 82 | }, |
| 83 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 84 | .get_function_name = sm8550_get_function_name, |
| 85 | .get_function_mux = sm8550_get_function_mux, |
| 86 | .get_pin_name = sm8550_get_pin_name, |
| 87 | }; |
| 88 | |
| 89 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 90 | { .compatible = "qcom,sm8550-tlmm", .data = (ulong)&sm8550_data }, |
| 91 | { /* Sentinel */ } |
| 92 | }; |
| 93 | |
| 94 | U_BOOT_DRIVER(pinctrl_sm8550) = { |
| 95 | .name = "pinctrl_sm8550", |
| 96 | .id = UCLASS_NOP, |
| 97 | .of_match = msm_pinctrl_ids, |
| 98 | .ops = &msm_pinctrl_ops, |
| 99 | .bind = msm_pinctrl_bind, |
| 100 | }; |
| 101 | |