blob: 1a09c5c81dc6b50ed58d3dc40109e15e22f2f0e3 [file] [log] [blame]
Dzmitry Sankouskie9be2042021-10-17 13:44:29 +03001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Qualcomm SDM845 pinctrl
4 *
5 * (C) Copyright 2021 Dzmitry Sankouski <dsankouski@gmail.com>
6 *
7 */
8
Dzmitry Sankouskie9be2042021-10-17 13:44:29 +03009#include <common.h>
Caleb Connolly506eb532023-11-14 12:55:40 +000010#include <dm.h>
11
12#include "pinctrl-qcom.h"
Dzmitry Sankouskie9be2042021-10-17 13:44:29 +030013
14#define MAX_PIN_NAME_LEN 32
15static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
16
17static const struct pinctrl_function msm_pinctrl_functions[] = {
18 {"qup9", 1},
19 {"gpio", 0},
20};
21
22static const char *sdm845_get_function_name(struct udevice *dev,
23 unsigned int selector)
24{
25 return msm_pinctrl_functions[selector].name;
26}
27
28static const char *sdm845_get_pin_name(struct udevice *dev,
29 unsigned int selector)
30{
31 snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector);
32 return pin_name;
33}
34
35static unsigned int sdm845_get_function_mux(unsigned int selector)
36{
37 return msm_pinctrl_functions[selector].val;
38}
39
Caleb Connolly506eb532023-11-14 12:55:40 +000040static struct msm_pinctrl_data sdm845_data = {
Dzmitry Sankouskie9be2042021-10-17 13:44:29 +030041 .pin_count = 150,
42 .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
43 .get_function_name = sdm845_get_function_name,
44 .get_function_mux = sdm845_get_function_mux,
45 .get_pin_name = sdm845_get_pin_name,
46};
Caleb Connolly506eb532023-11-14 12:55:40 +000047
48static const struct udevice_id msm_pinctrl_ids[] = {
49 { .compatible = "qcom,sdm845-pinctrl", .data = (ulong)&sdm845_data },
50 { /* Sentinal */ }
51};
52
53U_BOOT_DRIVER(pinctrl_sdm845) = {
54 .name = "pinctrl_sdm845",
55 .id = UCLASS_NOP,
56 .of_match = msm_pinctrl_ids,
57 .ops = &msm_pinctrl_ops,
58 .bind = msm_pinctrl_bind,
59};