diff options
Diffstat (limited to 'scripts/cru.c')
| -rw-r--r-- | scripts/cru.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/cru.c b/scripts/cru.c new file mode 100644 index 0000000..f1e2645 --- /dev/null +++ b/scripts/cru.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/mman.h> + +/* RK3328 CRU peek/poke: ./cru <off> [value] (off relative to CRU base) */ +#define CRU_BASE 0xff440000 + +int main(int argc, char **argv) +{ + int fd = open("/dev/mem", O_RDWR | O_SYNC); + if (fd < 0) { perror("/dev/mem"); return 1; } + volatile unsigned int *cru = mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, + MAP_SHARED, fd, CRU_BASE & ~0xfffUL); + if (cru == MAP_FAILED) { perror("mmap"); return 1; } + volatile unsigned int *reg = cru + ((CRU_BASE & 0xfff) + strtoul(argv[1], 0, 0)) / 4; + if (argc == 3) { + *reg = strtoul(argv[2], 0, 0); + printf("wrote 0x%x\n", *reg); + } else { + printf("0x%x\n", *reg); + } + return 0; +} |
