blob: 5250856176801789bd8cf08b8195fd7a0828b46a [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
Ramon Friedf5180862019-01-12 11:47:25 +02009#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[] = {
17 "SDC1_CLK",
18 "SDC1_CMD",
19 "SDC1_DATA",
20 "SDC2_CLK",
21 "SDC2_CMD",
22 "SDC2_DATA",
23 "SDC1_RCLK",
24};
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) {
40 snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector);
41 return pin_name;
42 } else {
43 return msm_pinctrl_pins[selector - 150];
44 }
45}
46
47static unsigned int apq8096_get_function_mux(unsigned int selector)
48{
49 return msm_pinctrl_functions[selector].val;
50}
51
Caleb Connolly506eb532023-11-14 12:55:40 +000052static const struct msm_pinctrl_data apq8096_data = {
Ramon Friedf5180862019-01-12 11:47:25 +020053 .pin_count = 157,
54 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
55 .get_function_name = apq8096_get_function_name,
56 .get_function_mux = apq8096_get_function_mux,
57 .get_pin_name = apq8096_get_pin_name,
58};
Caleb Connolly506eb532023-11-14 12:55:40 +000059
60static const struct udevice_id msm_pinctrl_ids[] = {
61 { .compatible = "qcom,msm8996-pinctrl", .data = (ulong)&apq8096_data },
62 { /* Sentinal */ }
63};
64
65U_BOOT_DRIVER(pinctrl_apq8096) = {
66 .name = "pinctrl_apq8096",
67 .id = UCLASS_NOP,
68 .of_match = msm_pinctrl_ids,
69 .ops = &msm_pinctrl_ops,
70 .bind = msm_pinctrl_bind,
71};