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
|
/*
* 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/>.
*/
#ifndef EXYNOS4412_GPIOS_DATA_H
#define EXYNOS4412_GPIOS_DATA_H
struct gpio_bank_data {
char *name;
uint32_t nr_gpios;
uint32_t base;
uint32_t offset;
};
struct gpio_register_data {
char *name;
int (*get_value)(uint32_t register_value, int gpio_offset);
char *(*value_str)(int value);
uint32_t offset;
};
/*
* <GPIO>CON
*/
enum gpio_direction {
GPIO_INPUT = 0,
GPIO_OUTPUT = 1,
/* The rest of the values up to 0xf seem to be dependent on the pin */
};
/*
* <GPIO>DAT
*/
enum gpio_value {
GPIO_VALUE_LOW = 0,
GPIO_VALUE_HIGH = 1,
GPIO_VALUE_UNDEFINED = 2,
};
/*
* <GPIO>DRV
*/
enum gpio_drive_strength {
GPIO_DRIVE_1X = 0,
GPIO_DRIVE_3X = 1,
GPIO_DRIVE_2X = 2,
GPIO_DRIVE_4X = 3,
};
/*
* <GPIO>PUD
*/
enum gpio_pullup_pulldown {
GPIO_RESISTORS_PULLDOWN_DISABLE = 0,
GPIO_RESISTORS_ENABLE_PULL_DOWN = 1,
GPIO_RESISTORS_RESERVED = 2,
GPIO_RESISTORS_ENABLE_PULL_UP = 3,
};
/*
* <GPIO>CONPDN
*/
enum gpio_power_down {
GPIO_POWER_DOWN_OUTPUT_LOW = 0,
GPIO_POWER_DOWN_OUTPUT_HIGH = 1,
GPIO_POWER_DOWN_INPUT = 2,
GPIO_POWER_DOWN_PREVIOUS_STATE = 3,
};
int decode_gpio_data(int debug, char *bank, uint32_t gpio_offset,
char* gpio_register_name, uint32_t *virt_addr);
int get_bank_gpio_numbers(int debug, char *gpio_bank_name);
struct gpio_bank_data *get_gpio_bank_data(char *bank);
off_t get_gpio_register_offset(int debug, char *gpio_bank_name,
char *register_name);
char *gpio_data_str(char* gpio_register_name, uint32_t register_value);
void *mmap_gpio_bank(char *devmem, int fd, size_t page_size, char *bank);
void print_gpio_banks_data(void);
#endif /* EXYNOS4412_GPIOS_DATA_H */
|