qDefineFlag(bool, dump, true, "dump status register only");
qDefineFlag(uint32, addr, 0, "register offset");
qDefineFlag(uint32, value, 0, "if write mode was enabled, this is the value to write");
qDefineFlag(bool, relative, true, "use offset");
uint32_t regaddr(uint32_t pa_offset, uint32_t addr, uint32_t reg_addr)
{
return addr - pa_offset + reg_addr;
}
sdkvoid dump_mipi_rx_regs(int mem_fd, int phy, int chn)
{
size_t len = 0x10000;
uint32_t offset = 0x11a40000;
uint32_t pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) - 1);
printf("mipi rx, pa_offset = %08x\n", pa_offset);
uint32_t* base = (uint32_t*)mmap(NULL, len + offset - pa_offset, PROT_READ | PROT_WRITE,
MAP_SHARED, mem_fd, pa_offset);
if (base) {
uint32_t pkt_intr_st = 0x1060 + 0x1000 * chn;
uint32_t pkt_intr_st2 = 0x1070 + 0x1000 * chn;
uint32_t frm_intr_st = 0x1080 + 0x1000 * chn;
printf("PKT_INTR_ST :\033[31m%08x\033[0m\n", *(base + regaddr(pa_offset, offset, pkt_intr_st) / 4)); printf("PKT_INTR_ST2:\033[31m%08x\033[0m\n", *(base + regaddr(pa_offset, offset, pkt_intr_st2) / 4)); printf("FRM_INTR_ST :\033[31m%08x\033[0m\n", *(base + regaddr(pa_offset,
offset, frm_intr_st) / 4)); //
munmap((void*)base, len + offset - pa_offset);
}
}
void process_read(int mem_fd, uint32_t addr)
{
if (qFlag(relative)) {
addr += 0x11a40000;
}
size_t len = 4;
uint32_t offset = addr;
uint32_t pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) - 1);
printf("pa_offset = %08x\n", pa_offset);
uint32_t* base = (uint32_t*)mmap(NULL, len + offset - pa_offset, PROT_READ | PROT_WRITE,
MAP_SHARED, mem_fd, pa_offset);
if (base) {
printf("Reg:%08x, Value:%08x\n", addr, *(base + regaddr(pa_offset, addr, 0) / 4));
//
munmap((void*)base, len + offset - pa_offset);
}
}
void process_write(int mem_fd, uint32_t addr, uint32_t value)
{
if (qFlag(relative)) {
addr += 0x11a40000;
}
size_t len = 4;
uint32_t offset = addr;
uint32_t pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) - 1);
printf("pa_offset = %08x\n", pa_offset);
uint32_t* base = (uint32_t*)mmap(NULL, len + offset - pa_offset, PROT_READ | PROT_WRITE,
MAP_SHARED, mem_fd, pa_offset);
if (base) {
*(base + regaddr(pa_offset, offset, 0) / 4) = value;
//
munmap((void*)base, len + offset - pa_offset);
}
}
int main(int argc, char** argv)
{
// usage
std::string usage = std::string() + "\n" +
argv[0] + "--dump=1, dump mipi_rx status registers\n" +
argv[0] + "--dump=0 --wr=1 --addr=0x1060, read the mipi_rx register\n" +
argv[0] + "--dump=0 --wr=1 --addr=0x11a41060 --relative=false, read any register\n" +
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论