Merge branch 'master' into master

This commit is contained in:
Ivaylo Ivanov 2023-07-18 14:59:15 +03:00 committed by GitHub
commit 05a43c1d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 163 additions and 34 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

@ -49,6 +49,12 @@ menu "Device Support"
help help
Say Y if you want to include support for Samsung Galaxy S20 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"
@ -62,6 +68,8 @@ menu "Device Specific Addresses"
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_X1S
default 0x090000000 if SAMSUNG_J5LTE
config FRAMEBUFFER_BASE config FRAMEBUFFER_BASE
hex "Framebuffer Base Address (for SimpleFB)" hex "Framebuffer Base Address (for SimpleFB)"
@ -73,6 +81,7 @@ menu "Device Specific Addresses"
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 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)"
@ -84,6 +93,7 @@ menu "Device Specific Addresses"
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 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)"
@ -95,7 +105,8 @@ menu "Device Specific Addresses"
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 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)"
depends on SIMPLE_FB depends on SIMPLE_FB
@ -106,5 +117,6 @@ menu "Device Specific Addresses"
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_X1S
default 4 if SAMSUNG_J5LTE
endmenu endmenu

View File

@ -5,3 +5,4 @@ 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_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);
}

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

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_

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"
@ -50,5 +54,11 @@ choice
select EXYNOS select EXYNOS
help help
Say Y if your device uses Samsung Exynos990 SoC Say Y if your device uses Samsung Exynos990 SoC
endchoice
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

@ -4,3 +4,4 @@ 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_EXYNOS_990) += exynos/exynos990.o
lib-$(CONFIG_QC32_8916) += qualcomm/msm8916.o

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) {
}