blob: 132ece868bf2dbc0cd8805c59d90891db48bc67f [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
Caleb Connolly506eb532023-11-14 12:55:40 +00009#include <dm.h>
10
11#include "pinctrl-qcom.h"
Ramon Friedf5180862019-01-12 11:47:25 +020012
13#define MAX_PIN_NAME_LEN 32
Stephan Gerhold80dbfb8c2021-07-05 14:18:47 +020014static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
Ramon Friedf5180862019-01-12 11:47:25 +020015static const char * const msm_pinctrl_pins[] = {
Caleb Connollyab6a1ac2024-02-26 17:26:18 +000016 "sdc1_clk",
17 "sdc1_cmd",
18 "sdc1_data",
19 "sdc2_clk",
20 "sdc2_cmd",
21 "sdc2_data",
22 "sdc1_rclk",
Ramon Friedf5180862019-01-12 11:47:25 +020023};
24
25static const struct pinctrl_function msm_pinctrl_functions[] = {
26 {"blsp_uart8", 2},
27};
28
29static const char *apq8096_get_function_name(struct udevice *dev,
30 unsigned int selector)
31{
32 return msm_pinctrl_functions[selector].name;
33}
34
35static const char *apq8096_get_pin_name(struct udevice *dev,
36 unsigned int selector)
37{
38 if (selector < 150) {
Caleb Connollyab6a1ac2024-02-26 17:26:18 +000039 snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
Ramon Friedf5180862019-01-12 11:47:25 +020040 return pin_name;
41 } else {
42 return msm_pinctrl_pins[selector - 150];
43 }
44}
45
Volodymyr Babchukc4cc9792024-03-11 21:33:46 +000046static unsigned int apq8096_get_function_mux(__maybe_unused unsigned int pin,
47 unsigned int selector)
Ramon Friedf5180862019-01-12 11:47:25 +020048{
49 return msm_pinctrl_functions[selector].val;
50}
51
Caleb Connolly506eb532023-11-14 12:55:40 +000052static const struct msm_pinctrl_data apq8096_data = {
Caleb Connolly190005c2024-02-26 17:26:17 +000053 .pin_data = {
54 .pin_count = 157,
55 .special_pins_start = 150,
56 },
Ramon Friedf5180862019-01-12 11:47:25 +020057 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
58 .get_function_name = apq8096_get_function_name,
59 .get_function_mux = apq8096_get_function_mux,
60 .get_pin_name = apq8096_get_pin_name,
61};
Caleb Connolly506eb532023-11-14 12:55:40 +000062
63static const struct udevice_id msm_pinctrl_ids[] = {
64 { .compatible = "qcom,msm8996-pinctrl", .data = (ulong)&apq8096_data },
65 { /* Sentinal */ }
66};
67
68U_BOOT_DRIVER(pinctrl_apq8096) = {
69 .name = "pinctrl_apq8096",
70 .id = UCLASS_NOP,
71 .of_match = msm_pinctrl_ids,
72 .ops = &msm_pinctrl_ops,
73 .bind = msm_pinctrl_bind,
74};