-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[driver] longanpi-4b support dram init
- Loading branch information
1 parent
c50139c
commit 207dfe4
Showing
7 changed files
with
2,064 additions
and
1 deletion.
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,5 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
add_syterkit_app(init_dram | ||
main.c | ||
) |
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,45 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
|
||
#include <stdbool.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <time.h> | ||
#include <types.h> | ||
|
||
#include <log.h> | ||
|
||
#include <common.h> | ||
|
||
#include <pmu/axp.h> | ||
#include <sys-dram.h> | ||
#include <sys-i2c.h> | ||
|
||
extern sunxi_serial_t uart_dbg; | ||
|
||
int main(void) { | ||
sunxi_serial_init(&uart_dbg); | ||
|
||
show_banner(); | ||
|
||
sunxi_clk_init(); | ||
|
||
sunxi_clk_dump(); | ||
|
||
mdelay(30); /* Delay 300ms for pmu bootup */ | ||
|
||
printk(LOG_LEVEL_INFO, "DRAM: DRAM Size = %dMB\n", sunxi_dram_init(NULL)); | ||
|
||
sunxi_clk_dump(); | ||
|
||
int i = 0; | ||
|
||
while (1) { | ||
i++; | ||
printk(LOG_LEVEL_INFO, "Count: %d\n", i); | ||
mdelay(1000); | ||
} | ||
|
||
abort(); | ||
|
||
return 0; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
add_library(chip_drivers-obj OBJECT | ||
sys-clk.c | ||
sys-dram.c | ||
) |
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,46 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
|
||
#include <barrier.h> | ||
#include <io.h> | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <types.h> | ||
|
||
#include <jmp.h> | ||
#include <log.h> | ||
|
||
#include <sys-dram.h> | ||
#include <sys-rtc.h> | ||
|
||
#define INIT_DRAM_BIN_BASE 0x38000 | ||
|
||
extern uint8_t __ddr_bin_start[]; | ||
extern uint8_t __ddr_bin_end[]; | ||
|
||
uint64_t sunxi_dram_init(void *para) { | ||
uint8_t *src = __ddr_bin_start; | ||
uint8_t *dst = (uint8_t *) INIT_DRAM_BIN_BASE; | ||
|
||
printk(LOG_LEVEL_DEBUG, "DRAM: load dram init from 0x%08x -> 0x%08x size: %08x\n", src, dst, __ddr_bin_end - __ddr_bin_start); | ||
memcpy(dst, src, __ddr_bin_end - __ddr_bin_start); | ||
|
||
printk(LOG_LEVEL_DEBUG, "DRAM: Now jump to 0x%08x run DRAMINIT\n", dst); | ||
|
||
__asm__ __volatile__("isb sy" | ||
: | ||
: | ||
: "memory"); | ||
__asm__ __volatile__("dsb sy" | ||
: | ||
: | ||
: "memory"); | ||
__asm__ __volatile__("dmb sy" | ||
: | ||
: | ||
: "memory"); | ||
((void (*)(void)) ((void *) INIT_DRAM_BIN_BASE))(); | ||
|
||
return 0; | ||
} |