bcm2835: Move mailbox init into bcm2835 framebuffer

We won't need the mailbox for most chipsets except bcm2835
to determine the framebuffer base address.
(especially at this early boot stage)

This simplifies things by making the mailbox usage limited
to boot_arch_arm and not spreading it all thoughout the
platform u-boot code... however we keep the mailbox driver
as-is since it would make a good kernel driver someday.

mmu_man mentioned us "finding" the fb base from the mailbox
and modifying the FDT to let it know the base reg of the
framebuffer... that's beyond 'just getting things building'
though :-)

Change-Id: Ic2772b85dff004f9d21447ea5958b5ae9776d526
This commit is contained in:
Alexander von Gluck IV
2018-11-02 12:46:54 -05:00
parent 3bac8deff6
commit 8de3883d8b
5 changed files with 23 additions and 41 deletions
@@ -27,14 +27,19 @@
#include "arch_mailbox.h"
#include "arch_mmu.h"
#include "fdt_support.h"
//XXX
extern "C" bool
mmu_get_virtual_mapping(addr_t virtualAddress, phys_addr_t *_physicalAddress);
extern "C" ArchMailbox*
arch_get_mailbox_arm_bcm2835(addr_t base);
extern void* gFDT;
extern ArchMailbox *gMailbox;
struct framebuffer_config {
uint32 width;
@@ -64,6 +69,8 @@ virtual status_t Init();
virtual status_t Probe();
virtual status_t SetDefaultMode();
virtual status_t SetVideoMode(int width, int height, int depth);
private:
ArchMailbox* fMailbox;
};
@@ -77,7 +84,18 @@ arch_get_fb_arm_bcm2835(addr_t base)
status_t
ArchFBArmBCM2835::Init()
{
if (gMailbox == NULL) {
if (!gFDT) {
dprintf("ERROR: FDT access is unavailable!");
return B_ERROR;
}
phys_addr_t mboxBase = fdt_get_device_reg_byname(gFDT, "/axi/mbox");
if (!mboxBase) {
dprintf("ERROR: /axi/mbox is unavailable!");
return B_ERROR;
}
fMailbox = arch_get_mailbox_arm_bcm2835(mboxBase);
if (fMailbox == NULL) {
dprintf("ERROR: Broadcom mailbox is unavailable!");
return B_ERROR;
}
@@ -129,13 +147,13 @@ ArchFBArmBCM2835::SetVideoMode(int width, int height, int depth)
sFramebufferConfig.color_map[i] = 0x1111 * i;
}
status_t result = gMailbox->Write(ARM_MAILBOX_CHANNEL_FRAMEBUFFER,
status_t result = fMailbox->Write(ARM_MAILBOX_CHANNEL_FRAMEBUFFER,
(uint32)&sFramebufferConfig | BCM283X_VIDEO_CORE_L2_COHERENT);
if (result != B_OK)
return result;
uint32 value;
result = gMailbox->Read(ARM_MAILBOX_CHANNEL_FRAMEBUFFER, value);
result = fMailbox->Read(ARM_MAILBOX_CHANNEL_FRAMEBUFFER, value);
if (result != B_OK)
return result;
@@ -83,6 +83,7 @@ ArchMailboxArmBCM2835::GetRegister(unsigned reg)
return *reinterpret_cast<std::atomic<uint32_t>*>(addr);
}
inline uint32
ArchMailboxArmBCM2835::RegisterRead(addr_t reg)
{
@@ -2,7 +2,6 @@ SubDir HAIKU_TOP src system boot platform u-boot arch arm ;
SubDirHdrs $(HAIKU_TOP) src system boot platform $(TARGET_BOOT_PLATFORM) ;
SubDirHdrs $(HAIKU_TOP) src system boot arch $(TARGET_KERNEL_ARCH) ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel bus_managers fdt ;
UsePrivateSystemHeaders ;
UsePrivateHeaders kernel [ FDirName kernel platform u-boot ] ;
@@ -14,8 +13,6 @@ SubDirC++Flags -fno-rtti ;
BootMergeObject boot_platform_u-boot_arm.o :
# must come first to have _start_* at correct locations
shell.S
arch_mailbox.cpp
;
#SEARCH on [ FGristFiles arch_cpu_asm.S ]
@@ -1,27 +0,0 @@
/*
* Copyright 2012-2016 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Alexander von Gluck IV, [email protected]
*/
#include "arch_mailbox.h"
#include "fdt_support.h"
ArchMailbox *gMailbox = NULL;
extern void* gFDT;
extern "C" status_t
arch_mailbox_init()
{
extern ArchMailbox *arch_get_mailbox_arm_bcm2835(addr_t base);
phys_addr_t mboxBase = fdt_get_device_reg_byname(gFDT, "/axi/mbox");
if (!mboxBase) {
return B_ERROR;
}
gMailbox = arch_get_mailbox_arm_bcm2835(mboxBase);
return B_OK;
}
@@ -70,9 +70,6 @@ extern "C" void _start(void);
extern "C" int start_gen(int argc, const char **argv,
struct image_header *uimage=NULL, void *fdt=NULL);
extern "C" void dump_uimage(struct image_header *image);
#if defined(__arm__)
extern "C" status_t arch_mailbox_init();
#endif
// declared in shell.S
@@ -230,10 +227,6 @@ start_gen(int argc, const char **argv, struct image_header *uimage, void *fdt)
serial_init(gFDT);
#if defined(__arm__)
arch_mailbox_init();
#endif
// initialize the OpenFirmware wrapper
// TODO: We need to call this when HAIKU_KERNEL_PLATFORM == openfirmware
// boot_platform_init()?