Compare commits

...

4 Commits

Author SHA1 Message Date
Ivaylo Ivanov
d85632eb76
Merge pull request #6 from halal-beef/master
Support for the exynos990 and the Samsung S20
2023-07-18 15:01:20 +03:00
Ivaylo Ivanov
05a43c1d73
Merge branch 'master' into master 2023-07-18 14:59:15 +03:00
Ivaylo Ivanov
ed98b5d900 .: Multiple changes
arch: Implement ARM32 support
soc: Implement ARM32 support for MSM8916
board: Implement ARM32 support for Samsung Galaxy J5 2015
include: main: Revert built-in memcpy, rearrange and add support for writel
lib: simplefb: Make the clear screen function usable

Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
Cc: Efim Girjeu <efimgirjeu@gmail.com>
2023-07-18 14:41:37 +03:00
halal-beef
5901622aaa Support for the exynos990 and the Samsung S20 2023-07-16 10:20:06 +01:00
18 changed files with 216 additions and 33 deletions

12
arch/arm/Start.S Normal file
View File

@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
*/
ldr r0, =dtb
ldr r1, =kernel
b main
.global load_kernel
load_kernel:
bx r4

29
arch/arm/linker.lds.S Normal file
View File

@ -0,0 +1,29 @@
ENTRY(_start);
OUTPUT_FORMAT("elf32-littlearm")
OUTPUT_ARCH(arm)
TARGET(binary)
INPUT(KERNEL_PATH)
INPUT(DTB_PATH)
SECTIONS
{
. = 0x80008000;
.boot : {
arch/arm/Start.o
}
.dtb ALIGN(0x1000) : {
dtb = .;
DTB_PATH
}
.kernel ALIGN(0x1000) : {
kernel = .;
KERNEL_PATH
}
kernel_size = SIZEOF(.kernel);
}

View File

@ -41,7 +41,20 @@ menu "Device Support"
depends on EXYNOS_9810 depends on EXYNOS_9810
help help
Say Y if you want to include support for Samsung Galaxy S9 Say Y if you want to include support for Samsung Galaxy S9
config SAMSUNG_X1S
bool "Support for Samsung Galaxy S20"
default n
depends on EXYNOS_990
help
Say Y if you want to include support for Samsung Galaxy S20
config SAMSUNG_J5LTE
bool "Support for Samsung Galaxy J5 2015"
default n
depends on QC32_8916
help
Say Y if you want to include arm32 support for Samsung Galaxy J5 2015
endmenu endmenu
menu "Device Specific Addresses" menu "Device Specific Addresses"
@ -54,6 +67,9 @@ menu "Device Specific Addresses"
default 0x090000000 if SAMSUNG_ZEROFLTE default 0x090000000 if SAMSUNG_ZEROFLTE
default 0x090000000 if SAMSUNG_DREAMLTE default 0x090000000 if SAMSUNG_DREAMLTE
default 0x090000000 if SAMSUNG_STARLTE default 0x090000000 if SAMSUNG_STARLTE
default 0x090000000 if SAMSUNG_X1S
default 0x090000000 if SAMSUNG_J5LTE
config FRAMEBUFFER_BASE config FRAMEBUFFER_BASE
hex "Framebuffer Base Address (for SimpleFB)" hex "Framebuffer Base Address (for SimpleFB)"
@ -64,6 +80,8 @@ menu "Device Specific Addresses"
default 0x0e2a00000 if SAMSUNG_ZEROFLTE default 0x0e2a00000 if SAMSUNG_ZEROFLTE
default 0x0cc000000 if SAMSUNG_DREAMLTE default 0x0cc000000 if SAMSUNG_DREAMLTE
default 0x0cc000000 if SAMSUNG_STARLTE default 0x0cc000000 if SAMSUNG_STARLTE
default 0x0F1000000 if SAMSUNG_X1S
default 0x08e000000 if SAMSUNG_J5LTE
config FRAMEBUFFER_WIDTH config FRAMEBUFFER_WIDTH
int "Framebuffer Width (for SimpleFB)" int "Framebuffer Width (for SimpleFB)"
@ -74,6 +92,8 @@ menu "Device Specific Addresses"
default 1440 if SAMSUNG_ZEROFLTE default 1440 if SAMSUNG_ZEROFLTE
default 1440 if SAMSUNG_DREAMLTE default 1440 if SAMSUNG_DREAMLTE
default 1440 if SAMSUNG_STARLTE default 1440 if SAMSUNG_STARLTE
default 1440 if SAMSUNG_X1S
default 720 if SAMSUNG_J5LTE
config FRAMEBUFFER_HEIGHT config FRAMEBUFFER_HEIGHT
int "Framebuffer Height (for SimpleFB)" int "Framebuffer Height (for SimpleFB)"
@ -84,6 +104,8 @@ menu "Device Specific Addresses"
default 2560 if SAMSUNG_ZEROFLTE default 2560 if SAMSUNG_ZEROFLTE
default 2960 if SAMSUNG_DREAMLTE default 2960 if SAMSUNG_DREAMLTE
default 2960 if SAMSUNG_STARLTE default 2960 if SAMSUNG_STARLTE
default 3200 if SAMSUNG_X1S
default 1280 if SAMSUNG_J5LTE
config FRAMEBUFFER_STRIDE config FRAMEBUFFER_STRIDE
int "Framebuffer Stride (for SimpleFB)" int "Framebuffer Stride (for SimpleFB)"
@ -94,5 +116,7 @@ menu "Device Specific Addresses"
default 4 if SAMSUNG_ZEROFLTE default 4 if SAMSUNG_ZEROFLTE
default 4 if SAMSUNG_DREAMLTE default 4 if SAMSUNG_DREAMLTE
default 4 if SAMSUNG_STARLTE default 4 if SAMSUNG_STARLTE
default 4 if SAMSUNG_X1S
default 4 if SAMSUNG_J5LTE
endmenu endmenu

View File

@ -4,3 +4,5 @@ lib-$(CONFIG_SAMSUNG_JACKPOTLTE) += samsung/board-jackpotlte.o
lib-$(CONFIG_SAMSUNG_ZEROFLTE) += samsung/board-zeroflte.o lib-$(CONFIG_SAMSUNG_ZEROFLTE) += samsung/board-zeroflte.o
lib-$(CONFIG_SAMSUNG_DREAMLTE) += samsung/board-dreamlte.o lib-$(CONFIG_SAMSUNG_DREAMLTE) += samsung/board-dreamlte.o
lib-$(CONFIG_SAMSUNG_STARLTE) += samsung/board-starlte.o lib-$(CONFIG_SAMSUNG_STARLTE) += samsung/board-starlte.o
lib-$(CONFIG_SAMSUNG_X1S) += samsung/board-x1s.o
lib-$(CONFIG_SAMSUNG_J5LTE) += samsung/board-j5lte.o

View File

@ -0,0 +1,26 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
*/
#include <main.h>
#define PIPE_SSPP_SRC_FORMAT 0x30
#define PIPE_SSPP_SRC_UNPACK_PATTERN 0x34
#define PIPE_BASE 0x1A15000
#define PIPE_SSPP_SRC_YSTRIDE 0x24
#define MDP_CTL_0_BASE 0x1A02000
#define CTL_FLUSH 0x18
void board_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((1 << (0)), PIPE_BASE + PIPE_SSPP_SRC_YSTRIDE);
}
void reboot(void) {
writel(0x0, 0x004AB000);
}

View File

@ -0,0 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2022, halal-beef <78730004+halal-beef@users.noreply.github.com>
*/
void board_init(void) {
}

3
configs/j5lte_defconfig Normal file
View File

@ -0,0 +1,3 @@
CONFIG_CROSS_COMPILE="arm-none-eabi-"
CONFIG_SAMSUNG_J5LTE=y
CONFIG_QC32_8916=y

3
configs/x1s_defconfig Normal file
View File

@ -0,0 +1,3 @@
CONFIG_CROSS_COMPILE="aarch64-linux-gnu-"
CONFIG_EXYNOS_990=y
CONFIG_SAMSUNG_X1S=y

View File

@ -13,37 +13,17 @@ extern void load_kernel(void* dtb, void* x1, void* x2, void* x3, void* kernel);
extern void soc_init(void); extern void soc_init(void);
extern void board_init(void); extern void board_init(void);
extern void clean_fb(volatile char *fb, int width, int height, int stride);
extern void printk(char *text); extern void printk(char *text);
#ifndef __has_builtin extern void writel(unsigned int value, void* address);
#define __has_builtin(x) 0 #ifdef __aarch64__
/* Define our own 128 bit memcpy */
extern void memcpy(void *dest, void *src, size_t size);
#endif #endif
#if __has_builtin(__builtin_memcpy) #ifdef __arm__
void memcpy(void *dest, void *src, size_t size) { extern void memcpy (char* src, char* dest, size_t len);
__builtin_memcpy(dest, src, size);
}
#else
#ifdef __aarch64__
/* Define our own 128 bit memcpy */
void memcpy(void *dest, void *src, size_t size)
{
unsigned __int128 *src2 = src;
unsigned __int128 *dest2 = dest;
for (size_t i = 0; i < size / 16; i++)
dest2[i] = src2[i];
}
#endif
#ifdef __arm__
void memcpy (char* src, char* dest, size_t len) {
for (size_t i = 0; i < len; i++)
dest[i] = src[i];
}
#endif
#endif #endif
#endif // MAIN_H_ #endif // MAIN_H_

12
include/soc/exynos990.h Normal file
View File

@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2022, halal-beef <78730004+halal-beef@users.noreply.github.com>
*/
#ifndef EXYNOS990_H_ /* Include guard */
#define EXYNOS990_H_
#define DECON_F_BASE 0x19050000
#define HW_SW_TRIG_CONTROL 0x70
#endif // EXYNOS990_H_

9
include/soc/msm8916.h Normal file
View File

@ -0,0 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
*/
#ifndef MSM8916_H_ /* Include guard */
#define MSM8916_H_
#endif // MSM8916_H_

View File

@ -3,6 +3,16 @@
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com> * Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
*/ */
#include <lib/debug.h> #include <lib/debug.h>
#include <stddef.h>
/* TODO: Import libc */
void writel(unsigned int value, void* address) {
// Cast the address pointer to a 32-bit unsigned integer pointer
volatile unsigned int* ptr = (volatile unsigned int*)address;
// Write the value to the memory location
*ptr = value;
}
void printk(char *text) { void printk(char *text) {
#ifdef CONFIG_SIMPLE_FB #ifdef CONFIG_SIMPLE_FB
@ -16,3 +26,22 @@ void printk(char *text) {
debug_linecount++; debug_linecount++;
#endif #endif
} }
#ifdef __aarch64__
/* Define our own 128 bit memcpy */
void memcpy(void *dest, void *src, size_t size)
{
unsigned __int128 *src2 = src;
unsigned __int128 *dest2 = dest;
for (size_t i = 0; i < size / 16; i++)
dest2[i] = src2[i];
}
#endif
#ifdef __arm__
void memcpy (char* src, char* dest, size_t len) {
for (size_t i = 0; i < len; i++)
dest[i] = src[i];
}
#endif

View File

@ -8,7 +8,7 @@
#include <lib/simplefb.h> #include <lib/simplefb.h>
#include <lib/font.h> #include <lib/font.h>
void clean_fb(volatile char *fb, char *text, int width, int height, int stride) { void clean_fb(volatile char *fb, int width, int height, int stride) {
for (volatile char *addr = fb; addr < fb + (width * height * stride); addr += stride) for (volatile char *addr = fb; addr < fb + (width * height * stride); addr += stride)
*(int*) (addr) = 0x0; *(int*) (addr) = 0x0;
} }

View File

@ -6,9 +6,12 @@
#include <main.h> #include <main.h>
void main(void* dt, void* kernel) { void main(void* dt, void* kernel) {
/* C entry */
/* Initialize SoC and Board specific peripherals/quirks */ /* Initialize SoC and Board specific peripherals/quirks */
/* TODO: Find a better way to make this more universal (since devices like arm64 Samsung Galaxies enable FB after soc_init) */
#ifdef CONFIG_SIMPLE_FB
clean_fb((char*)CONFIG_FRAMEBUFFER_BASE, CONFIG_FRAMEBUFFER_WIDTH, CONFIG_FRAMEBUFFER_HEIGHT, CONFIG_FRAMEBUFFER_STRIDE);
#endif
soc_init(); soc_init();
printk("soc_init() passed!"); printk("soc_init() passed!");
@ -17,6 +20,10 @@ void main(void* dt, void* kernel) {
/* Copy kernel to memory and boot */ /* Copy kernel to memory and boot */
printk("Booting linux..."); printk("Booting linux...");
__builtin_memcpy((void*)CONFIG_PAYLOAD_ENTRY, kernel, (unsigned long) &kernel_size);
load_kernel(dt, 0, 0, 0, (void*)CONFIG_PAYLOAD_ENTRY); memcpy((void*)CONFIG_PAYLOAD_ENTRY, kernel, (unsigned long) &kernel_size);
load_kernel(dt, 0, 0, 0, (void*)CONFIG_PAYLOAD_ENTRY);
/* We shouldn't get there */
while(1) {}
} }

View File

@ -6,6 +6,10 @@ config EXYNOS
bool bool
default n default n
config QUALCOMM
bool
default n
choice choice
prompt "SoC Support" prompt "SoC Support"
@ -43,5 +47,18 @@ choice
select EXYNOS select EXYNOS
help help
Say Y if your device uses Samsung Exynos9810 SoC Say Y if your device uses Samsung Exynos9810 SoC
endchoice
config EXYNOS_990
bool "Support for Exynos 990"
default n
select EXYNOS
help
Say Y if your device uses Samsung Exynos990 SoC
config QC32_8916
bool "Support for QUALCOMM MSM8916"
default n
select QUALCOMM
help
Say Y if your device uses this Qualcomm SoC
endchoice

View File

@ -3,3 +3,5 @@ lib-$(CONFIG_EXYNOS_7420) += exynos/exynos7420.o
lib-$(CONFIG_EXYNOS_7885) += exynos/exynos7885.o lib-$(CONFIG_EXYNOS_7885) += exynos/exynos7885.o
lib-$(CONFIG_EXYNOS_8895) += exynos/exynos8895.o lib-$(CONFIG_EXYNOS_8895) += exynos/exynos8895.o
lib-$(CONFIG_EXYNOS_9810) += exynos/exynos9810.o lib-$(CONFIG_EXYNOS_9810) += exynos/exynos9810.o
lib-$(CONFIG_EXYNOS_990) += exynos/exynos990.o
lib-$(CONFIG_QC32_8916) += qualcomm/msm8916.o

10
soc/exynos/exynos990.c Normal file
View File

@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2022, halal-beef <78730004+halal-beef@users.noreply.github.com>
*/
#include <soc/exynos990.h>
void soc_init(void) {
*(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x1281;
}

10
soc/qualcomm/msm8916.c Normal file
View File

@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
*/
#include <soc/msm8916.h>
void soc_init(void) {
}