diff options
| author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-06-02 16:33:44 +0200 |
|---|---|---|
| committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-06-02 16:33:44 +0200 |
| commit | be608255818438498defda7316ccc2d7990aa88e (patch) | |
| tree | dcf42d3d9d0a4a25ae05f4a67d6d83f117c80817 | |
| parent | 97cb7b6083ba0a9c646415bd2f72cf8cb87df344 (diff) | |
| download | exynos-gpio-tool-be608255818438498defda7316ccc2d7990aa88e.tar.gz exynos-gpio-tool-be608255818438498defda7316ccc2d7990aa88e.tar.bz2 exynos-gpio-tool-be608255818438498defda7316ccc2d7990aa88e.zip | |
simplyfiy mmap_gpio_hardware_blocks
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
| -rw-r--r-- | exynos4412_gpios.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/exynos4412_gpios.c b/exynos4412_gpios.c index 1c6474e..b478794 100644 --- a/exynos4412_gpios.c +++ b/exynos4412_gpios.c @@ -28,21 +28,23 @@ void *mmap_gpio_hardware_blocks(int debug, char *devmem, int fd, size_t page_size) { - /* TODO: also map GPIO_right - * GPIO_right: base_addr: 0x11000000 len: 0x400000 - * GPIO_left: base_addr: 0x11400000 len: 0x400000 - */ - uint32_t base_addr = 0x11000000; - size_t len = 0x800000; - - void *map_base_addr; + uint32_t base_addr; uint32_t *virt_addr; - + off_t len; int rc; - map_base_addr = mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, - base_addr & ~(page_size -1)); - if (map_base_addr == MAP_FAILED) { + /* GPIO_right: base_addr: 0x11000000 len: 0x400000 + * GPIO_left: base_addr: 0x11400000 len: 0x400000 + */ + base_addr = 0x11000000u; + len = 0x800000; + + /* virt_addr points to the beining of the file, so to the physical + * address 0 + */ + virt_addr = mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, + base_addr); + if (virt_addr == MAP_FAILED) { rc = errno; printf("mmap on %s failed with error %d: %s\n", devmem, rc, strerror(rc)); @@ -50,14 +52,8 @@ void *mmap_gpio_hardware_blocks(int debug, char *devmem, int fd, return NULL; } - virt_addr = map_base_addr + (base_addr & 4095); - - if (debug) { - printf("%s: mapped address 0x%x @ %p\n", __func__, 0, - map_base_addr); - printf("%s: mapped 0x%x bytes of address 0x%x @ %p\n", __func__, - len, base_addr, virt_addr); - } + if (debug) + printf("%s: mapped address 0 @ %p\n", __func__, virt_addr); return virt_addr; } |
