summaryrefslogtreecommitdiffstats
path: root/modem_gpios_data.c
blob: 85520249b415b67b39fac91a49604e85871be888 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 * Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#include <stddef.h>
#include <string.h>

#include "exynos4412_gpios.h"
#include "modem_gpios_data.h"

struct modem_gpio_data modem_gpio_datas[] = {
	{
		/* Exynos GPIO */
		.bank = "gpl2",
		.gpio_offset = 5,

		/* Kernel and driver specific information */
		.dt_gpio_name = "cp-on",
	},
	{
		/* Exynos GPIO */
		.bank = "gpx3",
		.gpio_offset = 2,

		/* Kernel and driver specific information */
		.dt_gpio_name = "cd-reset",
	},
	{
		/* Exynos GPIO */
		.bank = "gpx1",
		.gpio_offset = 2,

		/* Kernel and driver specific information */
		.dt_gpio_name = "cd-dump",
	},
	{
		/* Exynos GPIO */
		.bank = "gpx1",
		.gpio_offset = 6,

		/* Kernel and driver specific information */
		.dt_gpio_name = "phone-active",
	},
	{
		/* Exynos GPIO */
		.bank = "gpm3",
		.gpio_offset = 3,

		/* Kernel and driver specific information */
		.dt_gpio_name = "reset-req",
	},
	{
		/* Exynos GPIO */
		.bank = "gpf1",
		.gpio_offset = 6,

		/* Kernel and driver specific information */
		.dt_gpio_name = "pda-active",
	},
	{
		/* Exynos GPIO */
		.bank = "gpf1",
		.gpio_offset = 1,

		/* Kernel and driver specific information */
		.dt_gpio_name = "link-active",
	},
	{
		/* Exynos GPIO */
		.bank = "gpx1",
		.gpio_offset = 1,

		/* Kernel and driver specific information */
		.dt_gpio_name = "link-hostwake",
	},
	{
		/* Exynos GPIO */
		.bank = "gpx1",
		.gpio_offset = 0,

		/* Kernel and driver specific information */
		.dt_gpio_name = "link-slavewake",
	},
	{
		/* Exynos GPIO */
		.bank = "gpm2",
		.gpio_offset = 4,

		/* Kernel and driver specific information */
		.dt_gpio_name = "suspend-req",
	},
	{
		/* Sentinel */
	},
};

struct modem_gpio_data *get_modem_gpio_data_by_dt_name(char *dt_name)
{
	int i = 0;

	while (1) {
		if (modem_gpio_datas[i].bank == NULL)
			break;

		if (!strcmp(modem_gpio_datas[i].dt_gpio_name, dt_name))
			return &(modem_gpio_datas[i]);

		i++;
	}

	return NULL;
}

int dump_modem_gpio_infos_by_dt_name(char *devmem, int fd, size_t page_size,
				     char *dt_name)
{
	struct modem_gpio_data *modem_gpio_data;

	modem_gpio_data = get_modem_gpio_data_by_dt_name(dt_name);
	if (modem_gpio_data == NULL)
		return -1;

	return dump_gpio_infos(devmem, fd, page_size, modem_gpio_data->bank,
			       modem_gpio_data->gpio_offset);
}