-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kernel/aarch64: Use MM APIs for MMIO
This causes serial output to stop working before MM is completely initialized, as MMIO is not usable before that.
- Loading branch information
Showing
22 changed files
with
169 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2024, Sönke Holz <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <AK/Singleton.h> | ||
#include <Kernel/Arch/aarch64/RPi/AUX.h> | ||
#include <Kernel/Arch/aarch64/RPi/MMIO.h> | ||
|
||
namespace Kernel::RPi { | ||
|
||
// bcm2711-peripherals.pdf "2. Auxiliaries: UART1, SPI1 & SPI2" | ||
struct AUXRegisters { | ||
u32 IRQ; | ||
struct { | ||
u32 mini_uart_enable : 1; | ||
u32 spi1_enable : 1; | ||
u32 spi2_enable : 1; | ||
u32 : 29; | ||
} ENABLES; | ||
}; | ||
static_assert(AssertSize<AUXRegisters, 8>()); | ||
|
||
AUX::AUX() | ||
: m_registers(MMIO::the().peripheral<AUXRegisters>(0x21'5000).release_value_but_fixme_should_propagate_errors()) | ||
{ | ||
} | ||
|
||
AUX& AUX::the() | ||
{ | ||
static Singleton<AUX> instance; | ||
return instance; | ||
} | ||
|
||
void AUX::set_peripheral_enabled(Peripheral peripheral, bool enabled) | ||
{ | ||
switch (peripheral) { | ||
case Peripheral::MiniUART: | ||
m_registers->ENABLES.mini_uart_enable = enabled; | ||
break; | ||
case Peripheral::SPI1: | ||
m_registers->ENABLES.spi1_enable = enabled; | ||
break; | ||
case Peripheral::SPI2: | ||
m_registers->ENABLES.spi2_enable = enabled; | ||
break; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2024, Sönke Holz <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <Kernel/Memory/TypedMapping.h> | ||
|
||
namespace Kernel::RPi { | ||
|
||
struct AUXRegisters; | ||
|
||
class AUX { | ||
public: | ||
AUX(); | ||
static AUX& the(); | ||
|
||
enum class Peripheral { | ||
MiniUART, | ||
SPI1, | ||
SPI2, | ||
}; | ||
|
||
void set_peripheral_enabled(Peripheral, bool); | ||
|
||
private: | ||
Memory::TypedMapping<AUXRegisters volatile> m_registers; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.