mirror of
https://github.com/ivoszbg/uniLoader.git
synced 2024-11-21 19:40:07 +00:00
board: Introduce board file configurations
This is meant to replace the current Kconfig / SoC / Board files configuration, which is ugly and annoying to maintain. Begin by creating the board files registration framework and transitioning all exynos boards to it. This also opens room for creating the drivers registration framework in the future. All non-samsung boards will be no longer able to do their board configuration until they're also transitioned. Every new board must have the following structure: struct board_data default_board = { .name = "DEFAULT", .init = NULL, .late_init = NULL, .driver_setup = NULL, }; Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
This commit is contained in:
parent
69c7156eb3
commit
b301e51432
@ -1,9 +1,42 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) BotchedRPR <thenxguy0@gmail.com>
|
||||
*
|
||||
* Copyright (c) BotchedRPR <thenxguy0@gmail.com>
|
||||
* Copyright (c) 2024, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#include <board.h>
|
||||
|
||||
void board_init(void) {
|
||||
#define DECON_F_BASE 0x19050000
|
||||
#define HW_SW_TRIG_CONTROL 0x70
|
||||
|
||||
// Early initialization
|
||||
static void c1s_init(void)
|
||||
{
|
||||
/* Allow framebuffer to be written to */
|
||||
*(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x1281;
|
||||
}
|
||||
|
||||
// Late initialization
|
||||
static void c1s_late_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void c1s_driver_setup(void)
|
||||
{
|
||||
// Register drivers for S5PV210-specific peripherals
|
||||
// register_driver(&simplefb_driver);
|
||||
// Add more drivers here as needed
|
||||
}
|
||||
|
||||
// Create the board_data structure for S5PV210
|
||||
static struct board_data c1s_board = {
|
||||
.name = "C1S",
|
||||
.init = c1s_init,
|
||||
.late_init = c1s_late_init,
|
||||
.driver_setup = c1s_driver_setup,
|
||||
};
|
||||
|
||||
// Function to retrieve current board data (could be hardcoded or chosen via config)
|
||||
struct board_data *get_current_board(void) {
|
||||
return &c1s_board; // Return the correct board based on runtime config
|
||||
}
|
||||
|
@ -2,7 +2,40 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#include <board.h>
|
||||
|
||||
void board_init(void) {
|
||||
#define DECON_F_BASE 0x12860000
|
||||
#define HW_SW_TRIG_CONTROL 0x70
|
||||
|
||||
// Early initialization
|
||||
static void dreamlte_init(void)
|
||||
{
|
||||
/* Allow framebuffer to be written to */
|
||||
*(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x1281;
|
||||
}
|
||||
|
||||
// Late initialization
|
||||
static void dreamlte_late_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void dreamlte_driver_setup(void)
|
||||
{
|
||||
// Register drivers for S5PV210-specific peripherals
|
||||
// register_driver(&simplefb_driver);
|
||||
// Add more drivers here as needed
|
||||
}
|
||||
|
||||
// Create the board_data structure for S5PV210
|
||||
static struct board_data dreamlte_board = {
|
||||
.name = "DREAMLTE",
|
||||
.init = dreamlte_init,
|
||||
.late_init = dreamlte_late_init,
|
||||
.driver_setup = dreamlte_driver_setup,
|
||||
};
|
||||
|
||||
// Function to retrieve current board data (could be hardcoded or chosen via config)
|
||||
struct board_data *get_current_board(void) {
|
||||
return &dreamlte_board; // Return the correct board based on runtime config
|
||||
}
|
||||
|
@ -1,7 +1,42 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (c) 2024 Alexandru Chimac <alexchimac@protonmail.com>
|
||||
* Copyright (c) 2024, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#include <board.h>
|
||||
|
||||
void board_init(void) {
|
||||
#define DECON_F_BASE 0x148b0000
|
||||
#define HW_SW_TRIG_CONTROL 0x70
|
||||
|
||||
// Early initialization
|
||||
static void gta4xl_init(void)
|
||||
{
|
||||
/* Allow framebuffer to be written to */
|
||||
*(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x1281;
|
||||
}
|
||||
|
||||
// Late initialization
|
||||
static void gta4xl_late_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void gta4xl_driver_setup(void)
|
||||
{
|
||||
// Register drivers for S5PV210-specific peripherals
|
||||
// register_driver(&simplefb_driver);
|
||||
// Add more drivers here as needed
|
||||
}
|
||||
|
||||
// Create the board_data structure for S5PV210
|
||||
static struct board_data gta4xl_board = {
|
||||
.name = "GTA4XL",
|
||||
.init = gta4xl_init,
|
||||
.late_init = gta4xl_late_init,
|
||||
.driver_setup = gta4xl_driver_setup,
|
||||
};
|
||||
|
||||
// Function to retrieve current board data
|
||||
struct board_data *get_current_board(void) {
|
||||
return >a4xl_board; // Return the correct board based on runtime config
|
||||
}
|
||||
|
@ -1,8 +1,42 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2023, predefine <predefine@yandex.ru>
|
||||
* Copyright (c) 2024, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#include <board.h>
|
||||
|
||||
void board_init(void) {
|
||||
#define DECON_F_BASE 0x14830000
|
||||
#define HW_SW_TRIG_CONTROL 0x70
|
||||
|
||||
// Early initialization
|
||||
static void j4lte_init(void)
|
||||
{
|
||||
/* Allow framebuffer to be written to */
|
||||
*(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x1281;
|
||||
}
|
||||
|
||||
// Late initialization
|
||||
static void j4lte_late_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void j4lte_driver_setup(void)
|
||||
{
|
||||
// Register drivers for S5PV210-specific peripherals
|
||||
// register_driver(&simplefb_driver);
|
||||
// Add more drivers here as needed
|
||||
}
|
||||
|
||||
// Create the board_data structure for S5PV210
|
||||
static struct board_data j4lte_board = {
|
||||
.name = "J4LTE",
|
||||
.init = j4lte_init,
|
||||
.late_init = j4lte_late_init,
|
||||
.driver_setup = j4lte_driver_setup,
|
||||
};
|
||||
|
||||
// Function to retrieve current board data
|
||||
struct board_data *get_current_board(void) {
|
||||
return &j4lte_board; // Return the correct board based on runtime config
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
|
||||
#include <board.h>
|
||||
#include <main.h>
|
||||
|
||||
#define PIPE_SSPP_SRC_FORMAT 0x30
|
||||
@ -11,16 +12,39 @@
|
||||
#define PIPE_SSPP_SRC_YSTRIDE 0x24
|
||||
|
||||
#define MDP_CTL_0_BASE 0x1A02000
|
||||
#define CTL_FLUSH 0x18
|
||||
#define MDP_CTL_FLUSH 0x18
|
||||
|
||||
void board_init(void) {
|
||||
static void j5lte_init(void)
|
||||
{
|
||||
/* TODO: Doesn't really work :P */
|
||||
writel(0x000236FF, PIPE_BASE + PIPE_SSPP_SRC_FORMAT);
|
||||
writel(0x03020001, PIPE_BASE + PIPE_SSPP_SRC_UNPACK_PATTERN);
|
||||
writel(720 * 4, MDP_CTL_0_BASE + CTL_FLUSH);
|
||||
writel((720 * 4), MDP_CTL_0_BASE + MDP_CTL_FLUSH);
|
||||
writel((1 << (0)), PIPE_BASE + PIPE_SSPP_SRC_YSTRIDE);
|
||||
}
|
||||
|
||||
void reboot(void) {
|
||||
writel(0x0, 0x004AB000);
|
||||
// Late initialization
|
||||
static void j5lte_late_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void j5lte_driver_setup(void)
|
||||
{
|
||||
// Register drivers for S5PV210-specific peripherals
|
||||
// register_driver(&simplefb_driver);
|
||||
// Add more drivers here as needed
|
||||
}
|
||||
|
||||
// Create the board_data structure for S5PV210
|
||||
static struct board_data j5lte_board = {
|
||||
.name = "J5LTE",
|
||||
.init = j5lte_init,
|
||||
.late_init = j5lte_late_init,
|
||||
.driver_setup = j5lte_driver_setup,
|
||||
};
|
||||
|
||||
// Function to retrieve current board data
|
||||
struct board_data *get_current_board(void) {
|
||||
return &j5lte_board; // Return the correct board based on runtime config
|
||||
}
|
||||
|
@ -1,8 +1,42 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2022, David Wronek <w.david0@protonmail.com>
|
||||
* Copyright (c) 2024, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#include <board.h>
|
||||
|
||||
void board_init(void) {
|
||||
#define DECON_F_BASE 0x14860000
|
||||
#define HW_SW_TRIG_CONTROL 0x70
|
||||
|
||||
// Early initialization
|
||||
static void jackpotlte_init(void)
|
||||
{
|
||||
/* Allow framebuffer to be written to */
|
||||
*(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x1281;
|
||||
}
|
||||
|
||||
// Late initialization
|
||||
static void jackpotlte_late_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void jackpotlte_driver_setup(void)
|
||||
{
|
||||
// Register drivers for S5PV210-specific peripherals
|
||||
// register_driver(&simplefb_driver);
|
||||
// Add more drivers here as needed
|
||||
}
|
||||
|
||||
// Create the board_data structure for S5PV210
|
||||
static struct board_data jackpotlte_board = {
|
||||
.name = "JACKPOTLTE",
|
||||
.init = jackpotlte_init,
|
||||
.late_init = jackpotlte_late_init,
|
||||
.driver_setup = jackpotlte_driver_setup,
|
||||
};
|
||||
|
||||
// Function to retrieve current board data
|
||||
struct board_data *get_current_board(void) {
|
||||
return &jackpotlte_board; // Return the correct board based on runtime config
|
||||
}
|
||||
|
@ -1,8 +1,42 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2022, Faiz Faadhillah <faiz.faadhillah@gmail.com>
|
||||
* Copyright (c) 2024, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#include <board.h>
|
||||
|
||||
void board_init(void) {
|
||||
#define DECON_F_BASE 0x13930000
|
||||
#define HW_SW_TRIG_CONTROL 0x6b0
|
||||
|
||||
// Early initialization
|
||||
static void noblelte_init(void)
|
||||
{
|
||||
/* Allow framebuffer to be written to */
|
||||
*(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x2058;
|
||||
}
|
||||
|
||||
// Late initialization
|
||||
static void noblelte_late_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void noblelte_driver_setup(void)
|
||||
{
|
||||
// Register drivers for S5PV210-specific peripherals
|
||||
// register_driver(&simplefb_driver);
|
||||
// Add more drivers here as needed
|
||||
}
|
||||
|
||||
// Create the board_data structure for S5PV210
|
||||
static struct board_data noblelte_board = {
|
||||
.name = "NOBLELTE",
|
||||
.init = noblelte_init,
|
||||
.late_init = noblelte_late_init,
|
||||
.driver_setup = noblelte_driver_setup,
|
||||
};
|
||||
|
||||
// Function to retrieve current board data
|
||||
struct board_data *get_current_board(void) {
|
||||
return &noblelte_board; // Return the correct board based on runtime config
|
||||
}
|
||||
|
@ -1,8 +1,42 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2022, Markuss Broks <markuss.broks@gmail.com>
|
||||
* Copyright (c) 2024, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#include <board.h>
|
||||
|
||||
void board_init(void) {
|
||||
#define DECON_F_BASE 0x16030000
|
||||
#define HW_SW_TRIG_CONTROL 0x70
|
||||
|
||||
// Early initialization
|
||||
static void starlte_init(void)
|
||||
{
|
||||
/* Allow framebuffer to be written to */
|
||||
*(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x1281;
|
||||
}
|
||||
|
||||
// Late initialization
|
||||
static void starlte_late_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void starlte_driver_setup(void)
|
||||
{
|
||||
// Register drivers for S5PV210-specific peripherals
|
||||
// register_driver(&simplefb_driver);
|
||||
// Add more drivers here as needed
|
||||
}
|
||||
|
||||
// Create the board_data structure for S5PV210
|
||||
static struct board_data starlte_board = {
|
||||
.name = "STARLTE",
|
||||
.init = starlte_init,
|
||||
.late_init = starlte_late_init,
|
||||
.driver_setup = starlte_driver_setup,
|
||||
};
|
||||
|
||||
// Function to retrieve current board data
|
||||
struct board_data *get_current_board(void) {
|
||||
return &starlte_board; // Return the correct board based on runtime config
|
||||
}
|
||||
|
@ -1,8 +1,42 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2022, halal-beef <78730004+halal-beef@users.noreply.github.com>
|
||||
* Copyright (c) 2024, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#include <board.h>
|
||||
|
||||
void board_init(void) {
|
||||
#define DECON_F_BASE 0x19050000
|
||||
#define HW_SW_TRIG_CONTROL 0x70
|
||||
|
||||
// Early initialization
|
||||
static void x1s_init(void)
|
||||
{
|
||||
/* Allow framebuffer to be written to */
|
||||
*(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x1281;
|
||||
}
|
||||
|
||||
// Late initialization
|
||||
static void x1s_late_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void x1s_driver_setup(void)
|
||||
{
|
||||
// Register drivers for S5PV210-specific peripherals
|
||||
// register_driver(&simplefb_driver);
|
||||
// Add more drivers here as needed
|
||||
}
|
||||
|
||||
// Create the board_data structure for S5PV210
|
||||
static struct board_data x1s_board = {
|
||||
.name = "X1S",
|
||||
.init = x1s_init,
|
||||
.late_init = x1s_late_init,
|
||||
.driver_setup = x1s_driver_setup,
|
||||
};
|
||||
|
||||
// Function to retrieve current board data
|
||||
struct board_data *get_current_board(void) {
|
||||
return &x1s_board; // Return the correct board based on runtime config
|
||||
}
|
||||
|
@ -1,8 +1,42 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2022, David Wronek <w.david0@protonmail.com>
|
||||
* Copyright (c) 2024, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#include <board.h>
|
||||
|
||||
void board_init(void) {
|
||||
#define DECON_F_BASE 0x13930000
|
||||
#define HW_SW_TRIG_CONTROL 0x6b0
|
||||
|
||||
// Early initialization
|
||||
static void zeroflte_init(void)
|
||||
{
|
||||
/* Allow framebuffer to be written to */
|
||||
*(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x2058;
|
||||
}
|
||||
|
||||
// Late initialization
|
||||
static void zeroflte_late_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void zeroflte_driver_setup(void)
|
||||
{
|
||||
// Register drivers for S5PV210-specific peripherals
|
||||
// register_driver(&simplefb_driver);
|
||||
// Add more drivers here as needed
|
||||
}
|
||||
|
||||
// Create the board_data structure for S5PV210
|
||||
static struct board_data zeroflte_board = {
|
||||
.name = "ZEROFLTE",
|
||||
.init = zeroflte_init,
|
||||
.late_init = zeroflte_late_init,
|
||||
.driver_setup = zeroflte_driver_setup,
|
||||
};
|
||||
|
||||
// Function to retrieve current board data
|
||||
struct board_data *get_current_board(void) {
|
||||
return &zeroflte_board; // Return the correct board based on runtime config
|
||||
}
|
||||
|
39
include/board.h
Normal file
39
include/board.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Board files registration framework
|
||||
* Copyright (c) 2024, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#ifndef BOARD_H_ /* Include guard */
|
||||
#define BOARD_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/*
|
||||
* Well, well, well. We come back to this style again.
|
||||
* TODO: Implement libfdt once we have C libs all sorted out.
|
||||
*
|
||||
* @name -> board name
|
||||
* @init -> initialization as soon as we hit C
|
||||
* @late_init -> late initialization
|
||||
* @driver_setup -> driver initialization
|
||||
*/
|
||||
struct board_data {
|
||||
const char *name;
|
||||
void (*init)(void);
|
||||
void (*late_init)(void);
|
||||
void (*driver_setup)(void);
|
||||
};
|
||||
|
||||
extern struct board_data *get_current_board(void);
|
||||
|
||||
// Declare a weak reference to the board data structure
|
||||
extern struct board_data __attribute__((weak)) default_board;
|
||||
|
||||
struct board_data default_board = {
|
||||
.name = "DEFAULT",
|
||||
.init = NULL, // No init function for the default
|
||||
.late_init = NULL,
|
||||
.driver_setup = NULL,
|
||||
};
|
||||
|
||||
#endif // BOARD_H_
|
14
main/main.c
14
main/main.c
@ -3,21 +3,25 @@
|
||||
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
|
||||
#include <board.h>
|
||||
#include <main.h>
|
||||
#include <string.h>
|
||||
|
||||
void main(void* dt, void* kernel) {
|
||||
/* Initialize SoC and Board specific peripherals/quirks */
|
||||
struct board_data *board = get_current_board();
|
||||
|
||||
/* TODO: Find a better way to make this more universal (since devices like arm64 Samsung Galaxies enable FB after soc_init) */
|
||||
/* TODO: Move into the simpleFB driver once the drivers framework is done */
|
||||
#ifdef CONFIG_SIMPLE_FB
|
||||
clean_fb((char*)CONFIG_FRAMEBUFFER_BASE, CONFIG_FRAMEBUFFER_WIDTH, CONFIG_FRAMEBUFFER_HEIGHT, CONFIG_FRAMEBUFFER_STRIDE);
|
||||
#endif
|
||||
soc_init();
|
||||
printk("soc_init() passed!");
|
||||
board->init();
|
||||
printk("board init() passed!");
|
||||
|
||||
board_init();
|
||||
printk("board_init() passed!");
|
||||
board->driver_setup();
|
||||
|
||||
board->late_init();
|
||||
printk("board late_init() passed!");
|
||||
|
||||
/* Copy kernel to memory and boot */
|
||||
printk("Booting linux...");
|
||||
|
Loading…
Reference in New Issue
Block a user