diff options
| author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-05-17 18:33:42 +0200 |
|---|---|---|
| committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-05-17 18:42:04 +0200 |
| commit | 79b904f3ec8ff0e95e4697cb2d5a996858157142 (patch) | |
| tree | 188dbfe112b54ea691cd20635ebe77b22934956e | |
| parent | b976b3ca20315380ee8ce74725c6700666cfd67f (diff) | |
| download | exynos-gpio-tool-79b904f3ec8ff0e95e4697cb2d5a996858157142.tar.gz exynos-gpio-tool-79b904f3ec8ff0e95e4697cb2d5a996858157142.tar.bz2 exynos-gpio-tool-79b904f3ec8ff0e95e4697cb2d5a996858157142.zip | |
Add dump_modem_gpio_infos_by_dt_name
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | exynos4412_gpios.h | 3 | ||||
| -rw-r--r-- | exynos4412_gpios_data.c | 1 | ||||
| -rw-r--r-- | main.c | 7 | ||||
| -rw-r--r-- | modem_gpios_data.c | 96 | ||||
| -rw-r--r-- | modem_gpios_data.h | 6 |
6 files changed, 80 insertions, 34 deletions
@@ -5,6 +5,7 @@ SOURCE := \ exynos4412_gpios.c \ exynos4412_gpios_data.c \ main.c \ + modem_gpios_data.c \ run: i9300-modem-pins ./$< diff --git a/exynos4412_gpios.h b/exynos4412_gpios.h index c085482..c0d4426 100644 --- a/exynos4412_gpios.h +++ b/exynos4412_gpios.h @@ -17,6 +17,9 @@ #ifndef EXYNOS4412_GPIOS_H #define EXYNOS4412_GPIOS_H + +#include <stdint.h> + int dump_gpio_infos(char *devmem, int fd, size_t page_size, char *bank, uint32_t gpio_offset); #endif /* EXYNOS4412_GPIOS_H */ diff --git a/exynos4412_gpios_data.c b/exynos4412_gpios_data.c index 9a28a7f..ceb26c0 100644 --- a/exynos4412_gpios_data.c +++ b/exynos4412_gpios_data.c @@ -230,7 +230,6 @@ struct gpio_register_data gpio_registers_data[] = { struct gpio_bank_data *get_gpio_bank_data(char *bank) { - int i = 0; while (1) { @@ -25,8 +25,9 @@ #include <sys/stat.h> -#include "exynos4412_gpios.h" #include "compatible_devices.h" +#include "exynos4412_gpios.h" +#include "modem_gpios_data.h" int main(int argc, char *argv[]) { @@ -56,8 +57,8 @@ int main(int argc, char *argv[]) return EX_UNAVAILABLE; } - rc = dump_gpio_infos(devmem, fd, page_size, "gpj1", 1); - + // rc = dump_gpio_infos(devmem, fd, page_size, "gpj1", 1); + rc = dump_modem_gpio_infos_by_dt_name(devmem, fd, page_size, "suspend-req"); if (rc == -1) { printf("dump_gpio_infos failed with error %d\n", rc); diff --git a/modem_gpios_data.c b/modem_gpios_data.c index 5510577..15b28c9 100644 --- a/modem_gpios_data.c +++ b/modem_gpios_data.c @@ -15,90 +15,126 @@ * 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, + .bank = "gpl2", + .gpio_offset = 5, /* Kernel and driver specific information */ - dt_gpio_name = "cp-on", + .dt_gpio_name = "cp-on", }, { /* Exynos GPIO */ - bank = "gpx3", - gpio_offset = 2, + .bank = "gpx3", + .gpio_offset = 2, /* Kernel and driver specific information */ - dt_gpio_name = "cd-reset", + .dt_gpio_name = "cd-reset", }, { /* Exynos GPIO */ - bank = "gpx1", - gpio_offset = 2, + .bank = "gpx1", + .gpio_offset = 2, /* Kernel and driver specific information */ - dt_gpio_name = "cd-dump", + .dt_gpio_name = "cd-dump", }, { /* Exynos GPIO */ - bank = "gpx1", - gpio_offset = 6, + .bank = "gpx1", + .gpio_offset = 6, /* Kernel and driver specific information */ - dt_gpio_name = "phone-active", + .dt_gpio_name = "phone-active", }, { /* Exynos GPIO */ - bank = "gpm3", - gpio_offset = 3, + .bank = "gpm3", + .gpio_offset = 3, /* Kernel and driver specific information */ - dt_gpio_name = "reset-req", + .dt_gpio_name = "reset-req", }, { /* Exynos GPIO */ - bank = "gpf1", - gpio_offset = 6, + .bank = "gpf1", + .gpio_offset = 6, /* Kernel and driver specific information */ - dt_gpio_name = "pda-active", + .dt_gpio_name = "pda-active", }, { /* Exynos GPIO */ - bank = "gpf1", - gpio_offset = 1, + .bank = "gpf1", + .gpio_offset = 1, /* Kernel and driver specific information */ - dt_gpio_name = "link-active", + .dt_gpio_name = "link-active", }, { /* Exynos GPIO */ - bank = "gpx1", - gpio_offset = 1, + .bank = "gpx1", + .gpio_offset = 1, /* Kernel and driver specific information */ - dt_gpio_name = "link-hostwake", + .dt_gpio_name = "link-hostwake", }, { /* Exynos GPIO */ - bank = "gpx1", - gpio_offset = 0, + .bank = "gpx1", + .gpio_offset = 0, /* Kernel and driver specific information */ - dt_gpio_name = "link-slavewake", + .dt_gpio_name = "link-slavewake", }, { /* Exynos GPIO */ - bank = "gpm2", - gpio_offset = 4, + .bank = "gpm2", + .gpio_offset = 4, /* Kernel and driver specific information */ - dt_gpio_name = "suspend-req", + .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; + + int i = 0; + + 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); +} diff --git a/modem_gpios_data.h b/modem_gpios_data.h index 8f36145..35ed20a 100644 --- a/modem_gpios_data.h +++ b/modem_gpios_data.h @@ -18,6 +18,9 @@ #ifndef MODEM_GPIOS_DATA_H #define MODEM_GPIOS_DATA_H +#include <stddef.h> +#include <stdint.h> + struct modem_gpio_data { /* Exynos GPIO */ char *bank; @@ -28,4 +31,7 @@ struct modem_gpio_data { char *dt_gpio_name; }; +int dump_modem_gpio_infos_by_dt_name(char *devmem, int fd, size_t page_size, + char *dt_name); + #endif /* MODEM_GPIOS_DATA_H */ |
