blob: cc8f405e20b4392cf9226b805bc85b73aedd9134 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Mateusz Kulikowski2507d822016-03-31 23:12:32 +02002/*
Caleb Connollyfabb8972023-11-14 12:55:42 +00003 * Qualcomm common pin control data.
Mateusz Kulikowski2507d822016-03-31 23:12:32 +02004 *
Caleb Connollyfabb8972023-11-14 12:55:42 +00005 * Copyright (C) 2023 Linaro Ltd.
Mateusz Kulikowski2507d822016-03-31 23:12:32 +02006 */
Caleb Connollyfabb8972023-11-14 12:55:42 +00007#ifndef _QCOM_GPIO_H_
8#define _QCOM_GPIO_H_
9
10#include <asm/types.h>
11#include <stdbool.h>
12
Neil Armstronga670b692024-05-28 10:31:54 +020013struct msm_special_pin_data {
14 char *name;
15
16 u32 ctl_reg;
17 u32 io_reg;
18
19 unsigned pull_bit:5;
20 unsigned drv_bit:5;
21
22 unsigned oe_bit:5;
23 unsigned in_bit:5;
24 unsigned out_bit:5;
25};
26
Caleb Connollyfabb8972023-11-14 12:55:42 +000027struct msm_pin_data {
28 int pin_count;
29 const unsigned int *pin_offsets;
Caleb Connolly190005c2024-02-26 17:26:17 +000030 unsigned int special_pins_start;
Neil Armstronga670b692024-05-28 10:31:54 +020031 const struct msm_special_pin_data *special_pins_data;
Caleb Connollyfabb8972023-11-14 12:55:42 +000032};
33
34static inline u32 qcom_pin_offset(const unsigned int *offs, unsigned int selector)
35{
36 u32 out = (selector * 0x1000);
37
38 if (offs)
39 return out + offs[selector];
40
41 return out;
42}
43
Caleb Connolly190005c2024-02-26 17:26:17 +000044static inline bool qcom_is_special_pin(const struct msm_pin_data *pindata, unsigned int pin)
45{
46 return pindata->special_pins_start && pin >= pindata->special_pins_start;
47}
48
Caleb Connollyfabb8972023-11-14 12:55:42 +000049#endif /* _QCOM_GPIO_H_ */