platform/u-boot: Make bcm2708 mailbox code functional

* Functional == compiles. Needs tested :-)
This commit is contained in:
Alexander von Gluck IV 2015-03-06 10:15:31 -06:00
parent 5906dbb4d4
commit 5eeb4163fa
4 changed files with 42 additions and 50 deletions

View File

@ -37,8 +37,8 @@ BootMergeObject boot_arch_$(TARGET_KERNEL_ARCH).o :
arch_framebuffer_bcm2708.cpp
arch_framebuffer_pxa.cpp
arch_framebuffer_omap3.cpp
arch_cpu.cpp
arch_mailbox_bcm2708.cpp
arch_cpu.cpp
arch_mmu.cpp
arch_start_kernel.S

View File

@ -109,14 +109,14 @@ check_cpu_features()
}
void
extern "C" void
arch_cpu_memory_read_barrier(void)
{
asm volatile ("" : : : "memory");
}
void
extern "C" void
arch_cpu_memory_write_barrier(void)
{
asm volatile ("" : : : "memory");

View File

@ -11,38 +11,10 @@
#include "arch_mailbox.h"
#include <arch_cpu.h>
#include "arch_cpu.h"
#include "bcm2708.h"
//extern addr_t gPeripheralBase;
//
//
//static inline addr_t
//convert_mailbox_reg(addr_t reg)
//{
// return gPeripheralBase + ARM_CTRL_0_MAILBOX_BASE + reg;
//}
//
//
//static inline void
//write_mailbox_reg(addr_t reg, uint32 value)
//{
// arch_cpu_memory_write_barrier();
// *(volatile uint32*)convert_mailbox_reg(reg) = value;
//}
//
//
//static inline uint32
//read_mailbox_reg(addr_t reg)
//{
// uint32 result = *(volatile uint32*)convert_mailbox_reg(reg);
// arch_cpu_memory_read_barrier();
// return result;
//}
class ArchMailboxArmBCM2708 : public ArchMailbox {
public:
ArchMailboxArmBCM2708(addr_t base)
@ -52,6 +24,10 @@ public:
virtual status_t Write(uint8 channel, uint32 value);
virtual status_t Read(uint8 channel, uint32& value);
private:
void RegisterWrite(addr_t reg, uint32 value);
uint32 RegisterRead(addr_t reg);
};
@ -66,11 +42,11 @@ status_t
ArchMailboxArmBCM2708::Write(uint8 channel, uint32 value)
{
// We have to wait for the mailbox to drain if it is marked full.
//while ((read_mailbox_reg(ARM_MAILBOX_STATUS) & ARM_MAILBOX_FULL) != 0)
// ;
while ((RegisterRead(ARM_MAILBOX_STATUS) & ARM_MAILBOX_FULL) != 0)
;
//value &= ARM_MAILBOX_DATA_MASK;
//write_mailbox_reg(ARM_MAILBOX_WRITE, value | channel);
value &= ARM_MAILBOX_DATA_MASK;
RegisterWrite(ARM_MAILBOX_WRITE, value | channel);
return B_OK;
}
@ -78,20 +54,37 @@ ArchMailboxArmBCM2708::Write(uint8 channel, uint32 value)
status_t
ArchMailboxArmBCM2708::Read(uint8 channel, uint32& value)
{
//while (true) {
// // Wait for something to arrive in the mailbox.
// if ((read_mailbox_reg(ARM_MAILBOX_STATUS) & ARM_MAILBOX_EMPTY) != 0)
// continue;
while (true) {
// Wait for something to arrive in the mailbox.
if ((RegisterRead(ARM_MAILBOX_STATUS) & ARM_MAILBOX_EMPTY) != 0)
continue;
// value = read_mailbox_reg(ARM_MAILBOX_READ);
// if ((value & ARM_MAILBOX_CHANNEL_MASK) != channel) {
// // Not for us, retry.
// continue;
// }
value = RegisterRead(ARM_MAILBOX_READ);
if ((value & ARM_MAILBOX_CHANNEL_MASK) != channel) {
// Not for us, retry.
continue;
}
// break;
//}
break;
}
//value &= ARM_MAILBOX_DATA_MASK;
value &= ARM_MAILBOX_DATA_MASK;
return B_OK;
}
uint32
ArchMailboxArmBCM2708::RegisterRead(addr_t reg)
{
uint32 result = *(volatile uint32*)(fBase + ARM_CTRL_0_MAILBOX_BASE + reg);
arch_cpu_memory_read_barrier();
return result;
}
void
ArchMailboxArmBCM2708::RegisterWrite(addr_t reg, uint32 value)
{
arch_cpu_memory_write_barrier();
*(volatile uint32*)(fBase + ARM_CTRL_0_MAILBOX_BASE + reg) = value;
}

View File

@ -20,8 +20,7 @@ arch_mailbox_init()
{
#if defined(BOARD_CPU_BCM2708)
extern ArchMailbox *arch_get_mailbox_arm_bcm2708(addr_t base);
#warning ARM: Add gPeripheralBase to ARM_CTRL_0_MAILBOX_BASE
gMailbox = arch_get_mailbox_arm_bcm2708(ARM_CTRL_0_MAILBOX_BASE);
gMailbox = arch_get_mailbox_arm_bcm2708(DEVICE_BASE);
#endif
return B_OK;
}