Skip to content

Commit

Permalink
More audio hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcan committed Dec 26, 2016
1 parent 8041032 commit 9b76bd0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
43 changes: 43 additions & 0 deletions linux_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,49 @@ static void cpu_quiesce_gate(void *arg)

configure_vram();

uart_write_str("kexec: Resetting GPU...\n");

// Softreset GPU
*(volatile u64 *)PA_TO_DM(0xe480c300) = 0; // Halt RLC
*(volatile u64 *)PA_TO_DM(0xe48086d8) = 0x15000000; // Halt CP blocks
*(volatile u64 *)PA_TO_DM(0xe4808234) = 0x50000000; // Halt MEC
*(volatile u64 *)PA_TO_DM(0xe480d048) = 1; // Halt SDMA0
*(volatile u64 *)PA_TO_DM(0xe480d848) = 1; // Halt SDMA1
*(volatile u64 *)PA_TO_DM(0xe4808020) |= 0x10003; // Softreset GFX/CP/RLC
udelay(50);
*(volatile u64 *)PA_TO_DM(0xe4808020) &= ~0x10003;
udelay(50);
*(volatile u64 *)PA_TO_DM(0xe4800e60) |= 0x00100140; // Softreset SDMA/GRBM
udelay(50);
*(volatile u64 *)PA_TO_DM(0xe4800e60) &= ~0x00100140;
udelay(50);

// Enable audio output
*(volatile u64 *)PA_TO_DM(0xe4805e00) = 0x154;
*(volatile u64 *)PA_TO_DM(0xe4805e04) = 0x80000000;
*(volatile u64 *)PA_TO_DM(0xe4805e18) = 0x154;
*(volatile u64 *)PA_TO_DM(0xe4805e1c) = 0x80000000;
*(volatile u64 *)PA_TO_DM(0xe4805e30) = 0x154;
*(volatile u64 *)PA_TO_DM(0xe4805e34) = 0x80000000;
*(volatile u64 *)PA_TO_DM(0xe4813404) = 1;
*(volatile u64 *)PA_TO_DM(0xe481340c) = 1;

// // Set pin caps of pin 2 to vendor defined, to hide it
// *(volatile u64 *)PA_TO_DM(0xe4805e18) = 0x101;
// *(volatile u64 *)PA_TO_DM(0xe4805e1c) = 0xf00000;
// *(volatile u64 *)PA_TO_DM(0xe4805e18) = 0x120;
// *(volatile u64 *)PA_TO_DM(0xe4805e1c) = 0xf00000;
// // Set pin caps of pin 3 to !HDMI
// *(volatile u64 *)PA_TO_DM(0xe4805e30) = 0x121;
// *(volatile u64 *)PA_TO_DM(0xe4805e34) = 0x10;
// Set pin configuration default
*(volatile u64 *)PA_TO_DM(0xe4805e00) = 0x156;
*(volatile u64 *)PA_TO_DM(0xe4805e04) = 0x185600f0;
*(volatile u64 *)PA_TO_DM(0xe4805e18) = 0x156;
*(volatile u64 *)PA_TO_DM(0xe4805e1c) = 0x500000f0;
*(volatile u64 *)PA_TO_DM(0xe4805e30) = 0x156;
*(volatile u64 *)PA_TO_DM(0xe4805e34) = 0x014510f0;

uart_write_str("kexec: About to relocate and jump to kernel\n");

((jmp_to_linux_t)thunk_copy)(
Expand Down
15 changes: 15 additions & 0 deletions x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ static inline void wrmsr(u32 msr_id, u64 msr_value)
);
}

static inline u64 rdtsc (void)
{
unsigned int tickl, tickh;
asm volatile(
"rdtsc"
:"=a"(tickl),"=d"(tickh)
);
return ((u64)tickh << 32) | tickl;
}

static inline void udelay(unsigned int usec) {
u64 later = rdtsc() + usec * 1594ULL;
while (((s64)(later - rdtsc())) > 0);
}

static inline void disable_interrupts(void)
{
asm volatile("cli");
Expand Down

0 comments on commit 9b76bd0

Please sign in to comment.