blob: 9697cb5beb7a0a30d9a10f3e556bc06c5fc5349a [file] [log] [blame]
Ramon Friedf5180862019-01-12 11:47:25 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Qualcomm APQ8096 pinctrl
4 *
5 * (C) Copyright 2019 Ramon Fried <ramon.fried@gmail.com>
6 *
7 */
8
Tom Riniabb9a042024-05-18 20:20:43 -06009#include <common.h>
Caleb Connolly506eb532023-11-14 12:55:40 +000010#include <dm.h>
11
12#include "pinctrl-qcom.h"
Ramon Friedf5180862019-01-12 11:47:25 +020013
14#define MAX_PIN_NAME_LEN 32
Stephan Gerhold80dbfb8c2021-07-05 14:18:47 +020015static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
Ramon Friedf5180862019-01-12 11:47:25 +020016static const char * const msm_pinctrl_pins[] = {
Caleb Connollyab6a1ac2024-02-26 17:26:18 +000017 "sdc1_clk",
18 "sdc1_cmd",
19 "sdc1_data",
20 "sdc2_clk",
21 "sdc2_cmd",
22 "sdc2_data",
23 "sdc1_rclk",
Ramon Friedf5180862019-01-12 11:47:25 +020024};
25
26static const struct pinctrl_function msm_pinctrl_functions[] = {
27 {"blsp_uart8", 2},
28};
29
30static const char *apq8096_get_function_name(struct udevice *dev,
31 unsigned int selector)
32{
33 return msm_pinctrl_functions[selector].name;
34}
35
36static const char *apq8096_get_pin_name(struct udevice *dev,
37 unsigned int selector)
38{
39 if (selector < 150) {
Caleb Connollyab6a1ac2024-02-26 17:26:18 +000040 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
Ramon Friedf5180862019-01-12 11:47:25 +020041 return pin_name;
42 } else {
43 return msm_pinctrl_pins[selector - 150];
44 }
45}
46
Volodymyr Babchukc4cc9792024-03-11 21:33:46 +000047static unsigned int apq8096_get_function_mux(__maybe_unused unsigned int pin,
48 unsigned int selector)
Ramon Friedf5180862019-01-12 11:47:25 +020049{
50 return msm_pinctrl_functions[selector].val;
51}
52
Caleb Connolly506eb532023-11-14 12:55:40 +000053static const struct msm_pinctrl_data apq8096_data = {
Caleb Connolly190005c2024-02-26 17:26:17 +000054 .pin_data = {
55 .pin_count = 157,
56 .special_pins_start = 150,
57 },
Ramon Friedf5180862019-01-12 11:47:25 +020058 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
59 .get_function_name = apq8096_get_function_name,
60 .get_function_mux = apq8096_get_function_mux,
61 .get_pin_name = apq8096_get_pin_name,
62};
Caleb Connolly506eb532023-11-14 12:55:40 +000063
64static const struct udevice_id msm_pinctrl_ids[] = {
65 { .compatible = "qcom,msm8996-pinctrl", .data = (ulong)&apq8096_data },
66 { /* Sentinal */ }
67};
68
69U_BOOT_DRIVER(pinctrl_apq8096) = {
70 .name = "pinctrl_apq8096",
71 .id = UCLASS_NOP,
72 .of_match = msm_pinctrl_ids,
73 .ops = &msm_pinctrl_ops,
74 .bind = msm_pinctrl_bind,
75};