From 586b15bce82a2161dbe71991c14c8c36f5683033 Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Sun, 29 Mar 2020 20:57:39 +0300 Subject: [PATCH 01/33] common/board_f: Move arm-specific reserve_mmu to arch/arm/lib/cache.c Move the ARM-specific reserve_mmu definition from common/board_f.c to arch/arm/lib/cache.c. Signed-off-by: Ovidiu Panait Reviewed-by: Simon Glass --- arch/arm/lib/cache.c | 28 ++++++++++++++++++++++++++++ common/board_f.c | 28 ---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c index 007d4ebc49..b8e1e340a1 100644 --- a/arch/arm/lib/cache.c +++ b/arch/arm/lib/cache.c @@ -10,6 +10,8 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + /* * Flush range from all levels of d-cache/unified-cache. * Affects the range [start, start + size - 1]. @@ -118,3 +120,29 @@ void invalidate_l2_cache(void) isb(); } #endif + +__weak int reserve_mmu(void) +{ +#if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) + /* reserve TLB table */ + gd->arch.tlb_size = PGTABLE_SIZE; + gd->relocaddr -= gd->arch.tlb_size; + + /* round down to next 64 kB limit */ + gd->relocaddr &= ~(0x10000 - 1); + + gd->arch.tlb_addr = gd->relocaddr; + debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr, + gd->arch.tlb_addr + gd->arch.tlb_size); + +#ifdef CONFIG_SYS_MEM_RESERVE_SECURE + /* + * Record allocated tlb_addr in case gd->tlb_addr to be overwritten + * with location within secure ram. + */ + gd->arch.tlb_allocated = gd->arch.tlb_addr; +#endif +#endif + + return 0; +} diff --git a/common/board_f.c b/common/board_f.c index 2ec5dbaa68..26309c44d2 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -385,34 +385,6 @@ static int reserve_round_4k(void) return 0; } -#ifdef CONFIG_ARM -__weak int reserve_mmu(void) -{ -#if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) - /* reserve TLB table */ - gd->arch.tlb_size = PGTABLE_SIZE; - gd->relocaddr -= gd->arch.tlb_size; - - /* round down to next 64 kB limit */ - gd->relocaddr &= ~(0x10000 - 1); - - gd->arch.tlb_addr = gd->relocaddr; - debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr, - gd->arch.tlb_addr + gd->arch.tlb_size); - -#ifdef CONFIG_SYS_MEM_RESERVE_SECURE - /* - * Record allocated tlb_addr in case gd->tlb_addr to be overwritten - * with location within secure ram. - */ - gd->arch.tlb_allocated = gd->arch.tlb_addr; -#endif -#endif - - return 0; -} -#endif - static int reserve_video(void) { #ifdef CONFIG_DM_VIDEO From 6184858b859f6fcea4b23f76cfb7988882a3c8a7 Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Sun, 29 Mar 2020 20:57:40 +0300 Subject: [PATCH 02/33] arm: asm/cache.c: Introduce arm_reserve_mmu As a preparation for turning reserve_mmu into an arch-specific variant, introduce arm_reserve_mmu on ARM. It implements the default routine for reserving memory for MMU TLB and needs to be weakly defined in order to allow for machines to override it. Without this decoupling, after introducing arch_reserve_mmu, there would be two weak definitions for it, one in common/board_f.c and one in arch/arm/lib/cache.c. Signed-off-by: Ovidiu Panait Reviewed-by: Simon Glass --- arch/arm/include/asm/cache.h | 11 +++++++++++ arch/arm/lib/cache.c | 5 +++++ arch/arm/mach-versal/cpu.c | 3 ++- arch/arm/mach-zynqmp/cpu.c | 3 ++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h index 950ec1e793..c20e05ec7f 100644 --- a/arch/arm/include/asm/cache.h +++ b/arch/arm/include/asm/cache.h @@ -49,4 +49,15 @@ void dram_bank_mmu_setup(int bank); */ #define ARCH_DMA_MINALIGN CONFIG_SYS_CACHELINE_SIZE +/* + * arm_reserve_mmu() - Reserve memory for MMU TLB table + * + * Default implementation for reserving memory for MMU TLB table. It is used + * during generic board init sequence in common/board_f.c. Weakly defined, so + * that machines can override it if needed. + * + * Return: 0 if OK + */ +int arm_reserve_mmu(void); + #endif /* _ASM_CACHE_H */ diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c index b8e1e340a1..3cbed602eb 100644 --- a/arch/arm/lib/cache.c +++ b/arch/arm/lib/cache.c @@ -122,6 +122,11 @@ void invalidate_l2_cache(void) #endif __weak int reserve_mmu(void) +{ + return arm_reserve_mmu(); +} + +__weak int arm_reserve_mmu(void) { #if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) /* reserve TLB table */ diff --git a/arch/arm/mach-versal/cpu.c b/arch/arm/mach-versal/cpu.c index 829a6c1b3e..1b760ba5de 100644 --- a/arch/arm/mach-versal/cpu.c +++ b/arch/arm/mach-versal/cpu.c @@ -9,6 +9,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -107,7 +108,7 @@ u64 get_page_table_size(void) } #if defined(CONFIG_SYS_MEM_RSVD_FOR_MMU) -int reserve_mmu(void) +int arm_reserve_mmu(void) { tcm_init(TCM_LOCK); gd->arch.tlb_size = PGTABLE_SIZE; diff --git a/arch/arm/mach-zynqmp/cpu.c b/arch/arm/mach-zynqmp/cpu.c index 442427bc11..811684a9f8 100644 --- a/arch/arm/mach-zynqmp/cpu.c +++ b/arch/arm/mach-zynqmp/cpu.c @@ -11,6 +11,7 @@ #include #include #include +#include #define ZYNQ_SILICON_VER_MASK 0xF000 #define ZYNQ_SILICON_VER_SHIFT 12 @@ -116,7 +117,7 @@ void tcm_init(u8 mode) #endif #ifdef CONFIG_SYS_MEM_RSVD_FOR_MMU -int reserve_mmu(void) +int arm_reserve_mmu(void) { tcm_init(TCM_LOCK); gd->arch.tlb_size = PGTABLE_SIZE; From 79926e4f2f3cf84c65188c59ea1e93d6b221d36b Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Sun, 29 Mar 2020 20:57:41 +0300 Subject: [PATCH 03/33] common/board_f: Make reserve_mmu generic Introduce arch_reserve_mmu to allow for architecture-specific reserve_mmu routines. Also, define a weak nop stub for it. Signed-off-by: Ovidiu Panait Reviewed-by: Simon Glass --- arch/arm/lib/cache.c | 2 +- common/board_f.c | 9 ++++++--- include/init.h | 13 ++++++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c index 3cbed602eb..44dde26065 100644 --- a/arch/arm/lib/cache.c +++ b/arch/arm/lib/cache.c @@ -121,7 +121,7 @@ void invalidate_l2_cache(void) } #endif -__weak int reserve_mmu(void) +int arch_reserve_mmu(void) { return arm_reserve_mmu(); } diff --git a/common/board_f.c b/common/board_f.c index 26309c44d2..5c650f046c 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -385,6 +385,11 @@ static int reserve_round_4k(void) return 0; } +__weak int arch_reserve_mmu(void) +{ + return 0; +} + static int reserve_video(void) { #ifdef CONFIG_DM_VIDEO @@ -951,9 +956,7 @@ static const init_fnc_t init_sequence_f[] = { reserve_pram, #endif reserve_round_4k, -#ifdef CONFIG_ARM - reserve_mmu, -#endif + arch_reserve_mmu, reserve_video, reserve_trace, reserve_uboot, diff --git a/include/init.h b/include/init.h index 2a33a3fd1e..9ef88c966b 100644 --- a/include/init.h +++ b/include/init.h @@ -129,6 +129,18 @@ int testdram(void); */ int arch_reserve_stacks(void); +/** + * arch_reserve_mmu() - Reserve memory for MMU TLB table + * + * Architecture-specific routine for reserving memory for the MMU TLB table. + * This is used in generic board init sequence in common/board_f.c. + * + * If an implementation is not provided, it will just be a nop stub. + * + * Return: 0 if OK + */ +int arch_reserve_mmu(void); + /** * init_cache_f_r() - Turn on the cache in preparation for relocation * @@ -145,7 +157,6 @@ int init_cache_f_r(void); int print_cpuinfo(void); #endif int timer_init(void); -int reserve_mmu(void); int misc_init_f(void); #if defined(CONFIG_DTB_RESELECT) From 593f3976bee1213ac8d3d124c59aefc8889edc8b Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Sun, 5 Apr 2020 19:19:31 +0300 Subject: [PATCH 04/33] mtd: nand: pxa3xx: fix raw read when last_chunk_size == 0 Commit 6293b0361d9 ("mtd: nand: pxa3xx: add raw read support") added the local data_len variable in handle_data_pio() to track read size, but forgot to update the condition of drain_fifo() call. That happens to work when the layout last_chunk_size != 0. But when last_chunk_size == 0, drain_fifo() is not called to read the last chunk, which leads to "Wait timeout!!!" error. Fix this. Fixes: 6293b0361d9 ("mtd: nand: pxa3xx: add raw read support") Cc: Miquel Raynal Signed-off-by: Baruch Siach --- drivers/mtd/nand/raw/pxa3xx_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/pxa3xx_nand.c b/drivers/mtd/nand/raw/pxa3xx_nand.c index 03f210bdb0..7e3346dfcc 100644 --- a/drivers/mtd/nand/raw/pxa3xx_nand.c +++ b/drivers/mtd/nand/raw/pxa3xx_nand.c @@ -639,7 +639,7 @@ static void handle_data_pio(struct pxa3xx_nand_info *info) DIV_ROUND_UP(info->step_spare_size, 4)); break; case STATE_PIO_READING: - if (info->step_chunk_size) + if (data_len) drain_fifo(info, info->data_buff + info->data_buff_pos, DIV_ROUND_UP(data_len, 4)); From 4b4858936fadd61a1696cb5408ab81330ddb5c14 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 8 Apr 2020 10:09:16 +0200 Subject: [PATCH 05/33] lib: strto: Stop detection when invalid char is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This issue has been found when mtd partition are specified. Autodetection code should stop when the first invalid char is found. Here is the example of commands: setenv mtdids nand0=memory-controller@e000e000 setenv mtdparts "mtdparts=nand0:4m(boot),4m(env),64m(kernel),96m(rootfs)" mtd list Before: Zynq> mtd list List of MTD devices: * nand0 - type: NAND flash - block size: 0x20000 bytes - min I/O: 0x800 bytes - OOB size: 64 bytes - OOB available: 16 bytes - ECC strength: 1 bits - ECC step size: 2048 bytes - bitflip threshold: 1 bits - 0x000000000000-0x000010000000 : "nand0" - 0x000000000000-0x000000400000 : "boot" - 0x000000400000-0x000000800000 : "env" - 0x000000800000-0x000006c00000 : "kernel" - 0x000006c00000-0x000010000000 : "rootfs" Where it is visible that kernel partition has 100m instead of 64m After: Zynq> mtd list * nand0 - type: NAND flash - block size: 0x20000 bytes - min I/O: 0x800 bytes - OOB size: 64 bytes - OOB available: 16 bytes - ECC strength: 1 bits - ECC step size: 2048 bytes - bitflip threshold: 1 bits - 0x000000000000-0x000010000000 : "nand0" - 0x000000000000-0x000000400000 : "boot" - 0x000000400000-0x000000800000 : "env" - 0x000000800000-0x000004800000 : "kernel" - 0x000004800000-0x00000a800000 : "rootfs" Signed-off-by: Michal Simek Fixes: 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16 detection") Tested-by: Heiko Schocher Tested-by: Pali Rohár --- lib/strto.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/strto.c b/lib/strto.c index 1ac2b09c72..606701566f 100644 --- a/lib/strto.c +++ b/lib/strto.c @@ -34,6 +34,9 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base) *base = 16; break; } + + if (!(var >= '0' && var <= '9')) + break; } while (var); } } From 4f04d54981cd9d641e4ca958c551aeb00ee55484 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 8 Apr 2020 08:32:55 -0600 Subject: [PATCH 06/33] test: Add the beginnings of some string tests There are quite a few string functions in U-Boot with no tests. Make a start by adding a test for strtoul(). Signed-off-by: Simon Glass --- include/test/suites.h | 1 + test/Makefile | 1 + test/cmd_ut.c | 5 ++++ test/str_ut.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 test/str_ut.c diff --git a/include/test/suites.h b/include/test/suites.h index 39ad81a90f..213e3cee77 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -33,6 +33,7 @@ int do_ut_lib(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); int do_ut_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); int do_ut_optee(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +int do_ut_str(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); int do_ut_unicode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); diff --git a/test/Makefile b/test/Makefile index 2971d0d87f..bab8f1a5c2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_UNIT_TEST) += ut.o obj-$(CONFIG_SANDBOX) += command_ut.o obj-$(CONFIG_SANDBOX) += compression.o obj-$(CONFIG_SANDBOX) += print_ut.o +obj-$(CONFIG_SANDBOX) += str_ut.o obj-$(CONFIG_UT_TIME) += time_ut.o obj-$(CONFIG_UT_UNICODE) += unicode_ut.o obj-y += log/ diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 7fdcdbb1a6..bd20a69c55 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -74,6 +74,8 @@ static cmd_tbl_t cmd_ut_sub[] = { "", ""), U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist, "", ""), + U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, + "", ""), #endif }; @@ -137,6 +139,9 @@ static char ut_help_text[] = #ifdef CONFIG_UT_OVERLAY "ut overlay [test-name]\n" #endif +#ifdef CONFIG_SANDBOX + "ut str - Basic test of string functions\n" +#endif #ifdef CONFIG_UT_TIME "ut time - Very basic test of time functions\n" #endif diff --git a/test/str_ut.c b/test/str_ut.c new file mode 100644 index 0000000000..fab8de595c --- /dev/null +++ b/test/str_ut.c @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020 Google LLC + */ + +#include +#include +#include +#include +#include + +/* This is large enough for any of the test strings */ +#define TEST_STR_SIZE 200 + +static const char str1[] = "I'm sorry I'm late."; +static const char str2[] = "1099abNo, don't bother apologising."; +static const char str3[] = "0xbI'm sorry you're alive."; + +/* Declare a new str test */ +#define STR_TEST(_name, _flags) UNIT_TEST(_name, _flags, str_test) + +static int run_strtoul(struct unit_test_state *uts, const char *str, int base, + ulong expect_val, int expect_endp_offset) +{ + char *endp; + ulong val; + + val = simple_strtoul(str, &endp, base); + ut_asserteq(expect_val, val); + ut_asserteq(expect_endp_offset, endp - str); + + return 0; +} + +static int str_simple_strtoul(struct unit_test_state *uts) +{ + /* Base 10 and base 16 */ + ut_assertok(run_strtoul(uts, str2, 10, 1099, 4)); + ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6)); + + /* Invalid string */ + ut_assertok(run_strtoul(uts, str1, 10, 0, 0)); + + /* Base 0 */ + ut_assertok(run_strtoul(uts, str1, 0, 0, 0)); + ut_assertok(run_strtoul(uts, str2, 0, 1099, 4)); + ut_assertok(run_strtoul(uts, str3, 0, 0xb, 3)); + + /* Base 2 */ + ut_assertok(run_strtoul(uts, str1, 2, 0, 0)); + ut_assertok(run_strtoul(uts, str2, 2, 2, 2)); + + /* Check endp being NULL */ + ut_asserteq(1099, simple_strtoul(str2, NULL, 0)); + + return 0; +} +STR_TEST(str_simple_strtoul, 0); + +int do_ut_str(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + struct unit_test *tests = ll_entry_start(struct unit_test, + str_test); + const int n_ents = ll_entry_count(struct unit_test, str_test); + + return cmd_ut_category("str", "str_", tests, n_ents, argc, argv); +} From fdc79a6b125d52b6ca0fd65df538db7810d88a8d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 8 Apr 2020 08:32:56 -0600 Subject: [PATCH 07/33] lib: Add a function to convert a string to upper case Add a helper function for this operation. Update the strtoul() tests to check upper case as well. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- include/vsprintf.h | 12 +++++++ lib/strto.c | 8 +++++ test/str_ut.c | 80 ++++++++++++++++++++++++++++++++++++---------- 3 files changed, 84 insertions(+), 16 deletions(-) diff --git a/include/vsprintf.h b/include/vsprintf.h index 56844dd2de..d9fb68add0 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -222,4 +222,16 @@ bool str2long(const char *p, ulong *num); * @hz: Value to convert */ char *strmhz(char *buf, unsigned long hz); + +/** + * str_to_upper() - Convert a string to upper case + * + * This simply uses toupper() on each character of the string. + * + * @in: String to convert (must be large enough to hold the output string) + * @out: Buffer to put converted string + * @len: Number of bytes available in @out (SIZE_MAX for all) + */ +void str_to_upper(const char *in, char *out, size_t len); + #endif diff --git a/lib/strto.c b/lib/strto.c index 606701566f..3d77115d4d 100644 --- a/lib/strto.c +++ b/lib/strto.c @@ -179,3 +179,11 @@ long trailing_strtol(const char *str) { return trailing_strtoln(str, NULL); } + +void str_to_upper(const char *in, char *out, size_t len) +{ + for (; len > 0 && *in; len--) + *out++ = toupper(*in++); + if (len) + *out = '\0'; +} diff --git a/test/str_ut.c b/test/str_ut.c index fab8de595c..7c8015050a 100644 --- a/test/str_ut.c +++ b/test/str_ut.c @@ -19,36 +19,84 @@ static const char str3[] = "0xbI'm sorry you're alive."; /* Declare a new str test */ #define STR_TEST(_name, _flags) UNIT_TEST(_name, _flags, str_test) -static int run_strtoul(struct unit_test_state *uts, const char *str, int base, - ulong expect_val, int expect_endp_offset) +static int str_test_upper(struct unit_test_state *uts) { + char out[TEST_STR_SIZE]; + + /* Make sure it adds a terminator */ + out[strlen(str1)] = 'a'; + str_to_upper(str1, out, SIZE_MAX); + ut_asserteq_str("I'M SORRY I'M LATE.", out); + + /* In-place operation */ + strcpy(out, str2); + str_to_upper(out, out, SIZE_MAX); + ut_asserteq_str("1099ABNO, DON'T BOTHER APOLOGISING.", out); + + /* Limited length */ + str_to_upper(str1, out, 7); + ut_asserteq_str("I'M SORO, DON'T BOTHER APOLOGISING.", out); + + /* In-place with limited length */ + strcpy(out, str2); + str_to_upper(out, out, 7); + ut_asserteq_str("1099ABNo, don't bother apologising.", out); + + /* Copy an empty string to a buffer with space*/ + out[1] = 0x7f; + str_to_upper("", out, SIZE_MAX); + ut_asserteq('\0', *out); + ut_asserteq(0x7f, out[1]); + + /* Copy an empty string to a buffer with no space*/ + out[0] = 0x7f; + str_to_upper("", out, 0); + ut_asserteq(0x7f, out[0]); + + return 0; +} +STR_TEST(str_test_upper, 0); + +static int run_strtoul(struct unit_test_state *uts, const char *str, int base, + ulong expect_val, int expect_endp_offset, bool upper) +{ + char out[TEST_STR_SIZE]; char *endp; ulong val; - val = simple_strtoul(str, &endp, base); + strcpy(out, str); + if (upper) + str_to_upper(out, out, -1); + + val = simple_strtoul(out, &endp, base); ut_asserteq(expect_val, val); - ut_asserteq(expect_endp_offset, endp - str); + ut_asserteq(expect_endp_offset, endp - out); return 0; } static int str_simple_strtoul(struct unit_test_state *uts) { - /* Base 10 and base 16 */ - ut_assertok(run_strtoul(uts, str2, 10, 1099, 4)); - ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6)); + int upper; - /* Invalid string */ - ut_assertok(run_strtoul(uts, str1, 10, 0, 0)); + /* Check that it is case-insentive */ + for (upper = 0; upper < 2; upper++) { + /* Base 10 and base 16 */ + ut_assertok(run_strtoul(uts, str2, 10, 1099, 4, upper)); + ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6, upper)); - /* Base 0 */ - ut_assertok(run_strtoul(uts, str1, 0, 0, 0)); - ut_assertok(run_strtoul(uts, str2, 0, 1099, 4)); - ut_assertok(run_strtoul(uts, str3, 0, 0xb, 3)); + /* Invalid string */ + ut_assertok(run_strtoul(uts, str1, 10, 0, 0, upper)); - /* Base 2 */ - ut_assertok(run_strtoul(uts, str1, 2, 0, 0)); - ut_assertok(run_strtoul(uts, str2, 2, 2, 2)); + /* Base 0 */ + ut_assertok(run_strtoul(uts, str1, 0, 0, 0, upper)); + ut_assertok(run_strtoul(uts, str2, 0, 1099, 4, upper)); + ut_assertok(run_strtoul(uts, str3, 0, 0xb, 3, upper)); + + /* Base 2 */ + ut_assertok(run_strtoul(uts, str1, 2, 0, 0, upper)); + ut_assertok(run_strtoul(uts, str2, 2, 2, 2, upper)); + } /* Check endp being NULL */ ut_asserteq(1099, simple_strtoul(str2, NULL, 0)); From 2c2ca207e4ed7def3f3f33ab930e673a45bb3743 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 8 Apr 2020 08:32:58 -0600 Subject: [PATCH 08/33] uuid: Use const char * where possible Update the arguments of these functions so they can be called from code which uses constant strings. Signed-off-by: Simon Glass --- include/uuid.h | 8 +++++--- lib/uuid.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/uuid.h b/include/uuid.h index abcc325eae..73c5a89ec7 100644 --- a/include/uuid.h +++ b/include/uuid.h @@ -35,11 +35,13 @@ struct uuid { #define UUID_VARIANT 0x1 int uuid_str_valid(const char *uuid); -int uuid_str_to_bin(char *uuid_str, unsigned char *uuid_bin, int str_format); -void uuid_bin_to_str(unsigned char *uuid_bin, char *uuid_str, int str_format); +int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin, + int str_format); +void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str, + int str_format); #ifdef CONFIG_PARTITION_TYPE_GUID int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin); -int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str); +int uuid_guid_get_str(const unsigned char *guid_bin, char *guid_str); #endif void gen_rand_uuid(unsigned char *uuid_bin); void gen_rand_uuid_str(char *uuid_str, int str_format); diff --git a/lib/uuid.c b/lib/uuid.c index 3d3c7abcae..c1cb9df6aa 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -121,7 +121,7 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin) * @param guid_bin - pointer to string with partition type guid [16B] * @param guid_str - pointer to allocated partition type string [7B] */ -int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str) +int uuid_guid_get_str(const unsigned char *guid_bin, char *guid_str) { int i; @@ -143,7 +143,8 @@ int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str) * @param uuid_bin - pointer to allocated array for big endian output [16B] * @str_format - UUID string format: 0 - UUID; 1 - GUID */ -int uuid_str_to_bin(char *uuid_str, unsigned char *uuid_bin, int str_format) +int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin, + int str_format) { uint16_t tmp16; uint32_t tmp32; @@ -194,7 +195,8 @@ int uuid_str_to_bin(char *uuid_str, unsigned char *uuid_bin, int str_format) * @str_format: bit 0: 0 - UUID; 1 - GUID * bit 1: 0 - lower case; 2 - upper case */ -void uuid_bin_to_str(unsigned char *uuid_bin, char *uuid_str, int str_format) +void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str, + int str_format) { const u8 uuid_char_order[UUID_BIN_LEN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; From f05970380e4c72a198cce29affc622a8e543b4de Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 8 Apr 2020 08:32:59 -0600 Subject: [PATCH 09/33] pci: Add a macro to convert BDF from linux to U-Boot U-Boot's BDF format has its bits in the same position as the device tree PCI definition. Some x86 devices use linux format in their register format and it is useful to be able to convert to U-Boot format. Add a macro for this. Signed-off-by: Simon Glass --- include/pci.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/pci.h b/include/pci.h index 174ddd4460..aff56b24f9 100644 --- a/include/pci.h +++ b/include/pci.h @@ -543,6 +543,9 @@ typedef int pci_dev_t; #define PCI_VENDEV(v, d) (((v) << 16) | (d)) #define PCI_ANY_ID (~0) +/* Convert from Linux format to U-Boot format */ +#define PCI_TO_BDF(val) ((val) << 8) + struct pci_device_id { unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */ unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */ From 3a905cd231de8834cda329f20854dc1f91328ae5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 8 Apr 2020 08:33:00 -0600 Subject: [PATCH 10/33] dm: mmc: Update mmc_get_mmc_dev() to use const * This function does not modify the device to change it to use const *, so that callers with a const udevice * can call it without a cast. Signed-off-by: Simon Glass Reviewed-by: Jaehoon Chung --- drivers/mmc/mmc-uclass.c | 2 +- include/mmc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index cb26d841be..f313bc1734 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -239,7 +239,7 @@ int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg) return 0; } -struct mmc *mmc_get_mmc_dev(struct udevice *dev) +struct mmc *mmc_get_mmc_dev(const struct udevice *dev) { struct mmc_uclass_priv *upriv; diff --git a/include/mmc.h b/include/mmc.h index 5e9d15cb41..6a2e9739e0 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -377,7 +377,7 @@ struct mmc_uclass_priv { * @dev: Device * @return associated mmc struct pointer if available, else NULL */ -struct mmc *mmc_get_mmc_dev(struct udevice *dev); +struct mmc *mmc_get_mmc_dev(const struct udevice *dev); /* End of driver model support */ From b5d5d908225051c609a8d140ce074a079e66f26e Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 10 Apr 2020 16:34:40 +0200 Subject: [PATCH 11/33] cosmetic: README: Fix one CONFIG name Only replace CONFIF_ by CONFIG_ Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 841412bacc..e73b9d7c2e 100644 --- a/README +++ b/README @@ -1640,7 +1640,7 @@ The following options need to be configured: - CONFIG_SYS_RCAR_I2C2_SPEED for for the speed channel 2 - CONFIG_SYS_RCAR_I2C3_BASE for setting the register channel 3 - CONFIG_SYS_RCAR_I2C3_SPEED for for the speed channel 3 - - CONFIF_SYS_RCAR_I2C_NUM_CONTROLLERS for number of i2c buses + - CONFIG_SYS_RCAR_I2C_NUM_CONTROLLERS for number of i2c buses - drivers/i2c/sh_i2c.c: - activate this driver with CONFIG_SYS_I2C_SH From a3d7cb1939ada77a2c0b7668bb9d80298de3ff31 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 10 Apr 2020 16:34:41 +0200 Subject: [PATCH 12/33] README: remove references on no more used config CONFIG_SYS_RCAR_I2C* Remove the references in README on CONFIG_SYS_RCAR_I2C_* not use in U-Boot drivers/i2c/rcar_i2c.c, since commit a4d9aafadb31 ("i2c: rcar_i2c: Remove the driver") and commit a06a0ac36d59 ("i2c: rcar_i2c: Add DM and DT capable I2C driver") Checked by the command: grep -r SYS_RCAR_I2C * And these CONFIG are only defined in arch/arm/mach-rmobile/include/mach/rcar-base.h Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- README | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README b/README index e73b9d7c2e..0834850676 100644 --- a/README +++ b/README @@ -1632,16 +1632,6 @@ The following options need to be configured: - activate this driver with CONFIG_SYS_I2C_RCAR - This driver adds 4 i2c buses - - CONFIG_SYS_RCAR_I2C0_BASE for setting the register channel 0 - - CONFIG_SYS_RCAR_I2C0_SPEED for for the speed channel 0 - - CONFIG_SYS_RCAR_I2C1_BASE for setting the register channel 1 - - CONFIG_SYS_RCAR_I2C1_SPEED for for the speed channel 1 - - CONFIG_SYS_RCAR_I2C2_BASE for setting the register channel 2 - - CONFIG_SYS_RCAR_I2C2_SPEED for for the speed channel 2 - - CONFIG_SYS_RCAR_I2C3_BASE for setting the register channel 3 - - CONFIG_SYS_RCAR_I2C3_SPEED for for the speed channel 3 - - CONFIG_SYS_RCAR_I2C_NUM_CONTROLLERS for number of i2c buses - - drivers/i2c/sh_i2c.c: - activate this driver with CONFIG_SYS_I2C_SH - This driver adds from 2 to 5 i2c buses From f62782fb2999dd8109a3ffe9ee0a51e54ab034ab Mon Sep 17 00:00:00 2001 From: Ley Foon Tan Date: Fri, 17 Apr 2020 14:45:35 +0800 Subject: [PATCH 13/33] cache: l2x0: Fix write to incorrect shared-override bit The existing code write bit-0 for shared attribute override enable bit. It should be bit-22 based on cache controller specification [1]. [1] http://infocenter.arm.com/help/topic/com.arm.doc.ddi0246f/DDI0246F_l2c310_r3p2_trm.pdf Signed-off-by: Ley Foon Tan --- drivers/cache/cache-l2x0.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cache/cache-l2x0.c b/drivers/cache/cache-l2x0.c index 67c752d076..226824c283 100644 --- a/drivers/cache/cache-l2x0.c +++ b/drivers/cache/cache-l2x0.c @@ -33,8 +33,8 @@ static void l2c310_of_parse_and_init(struct udevice *dev) saved_reg &= ~L310_AUX_CTRL_INST_PREFETCH_MASK; } - saved_reg |= dev_read_bool(dev, "arm,shared-override"); - writel(saved_reg, ®s->pl310_aux_ctrl); + if (dev_read_bool(dev, "arm,shared-override")) + saved_reg |= L310_SHARED_ATT_OVERRIDE_ENABLE; saved_reg = readl(®s->pl310_tag_latency_ctrl); if (!dev_read_u32_array(dev, "arm,tag-latency", tag, 3)) From c3da3f58086b30d0d435a002781121c1e820c7da Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 17 Apr 2020 16:21:35 +0900 Subject: [PATCH 14/33] kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o if_changed must have FORCE as a prerequisite. Add $(obj)/dts/dt-platdata.o to 'targets' so that the corresponding .cmd file is included. Signed-off-by: Masahiro Yamada --- scripts/Makefile.spl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 5384f21278..4c2c0567c5 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -307,10 +307,11 @@ quiet_cmd_dtoch = DTOC H $@ cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ struct quiet_cmd_plat = PLAT $@ -cmd_plat = $(CC) $(c_flags) -c $< -o $@ +cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@) +targets += $(obj)/dts/dt-platdata.o $(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c \ - include/generated/dt-structs-gen.h + include/generated/dt-structs-gen.h FORCE $(call if_changed,plat) PHONY += dts_dir From b5a2046376e7f18f796f641a51fdc66a5a52306a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 17 Apr 2020 16:21:36 +0900 Subject: [PATCH 15/33] kbuild: cherry-pick kbuild changes from Linux b42841b7bb62 kbuild: Get rid of KBUILD_STR 2aedcd098a94 kbuild: suppress annoying "... is up to date." message 9c8fa9bc08f6 kbuild: fix if_change and friends to consider argument order ebf003f0cfb3 kbuild: Consolidate header generation from ASM offset information 2982c953570b kbuild: remove redundant $(wildcard ...) for cmd_files calculation 8a78756eb545 kbuild: create object directories simpler and faster 4d4b5c2e3b6e treewide: remove explicit rules for *offsets.s 01d509a48b46 kbuild: remove unimportant comments from ./Kbuild Signed-off-by: Masahiro Yamada --- Kbuild | 45 +++--------------------------------------- Makefile | 3 +-- scripts/Kbuild.include | 15 +++++++------- scripts/Makefile.build | 18 +++++------------ scripts/Makefile.host | 12 ----------- scripts/Makefile.lib | 42 ++++++++++++++++++++++++++++++--------- 6 files changed, 50 insertions(+), 85 deletions(-) diff --git a/Kbuild b/Kbuild index e2e3b2995f..6014f7c34a 100644 --- a/Kbuild +++ b/Kbuild @@ -1,54 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0 # # Kbuild for top-level directory of U-Boot -# This file takes care of the following: -# 1) Generate generic-asm-offsets.h -# 2) Generate asm-offsets.h - -# Default sed regexp - multiline due to syntax constraints -define sed-y - "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \ - /^->/{s:->#\(.*\):/* \1 */:; \ - s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:->::; p;}" -endef - -# Use filechk to avoid rebuilds when a header changes, but the resulting file -# does not -define filechk_offsets - (set -e; \ - echo "#ifndef $2"; \ - echo "#define $2"; \ - echo "/*"; \ - echo " * DO NOT MODIFY."; \ - echo " *"; \ - echo " * This file was generated by Kbuild"; \ - echo " */"; \ - echo ""; \ - sed -ne $(sed-y); \ - echo ""; \ - echo "#endif" ) -endef ##### -# 1) Generate generic-asm-offsets.h +# Generate generic-asm-offsets.h generic-offsets-file := include/generated/generic-asm-offsets.h always := $(generic-offsets-file) targets := lib/asm-offsets.s -# We use internal kbuild rules to avoid the "is up to date" message from make -lib/asm-offsets.s: lib/asm-offsets.c FORCE - $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) - $(obj)/$(generic-offsets-file): lib/asm-offsets.s FORCE $(call filechk,offsets,__GENERIC_ASM_OFFSETS_H__) ##### -# 2) Generate asm-offsets.h -# +# Generate asm-offsets.h ifneq ($(wildcard $(srctree)/arch/$(ARCH)/lib/asm-offsets.c),) offsets-file := include/generated/asm-offsets.h @@ -59,10 +25,5 @@ targets += arch/$(ARCH)/lib/asm-offsets.s CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY -# We use internal kbuild rules to avoid the "is up to date" message from make -arch/$(ARCH)/lib/asm-offsets.s: arch/$(ARCH)/lib/asm-offsets.c FORCE - $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) - $(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s FORCE $(call filechk,offsets,__ASM_OFFSETS_H__) diff --git a/Makefile b/Makefile index b7fa6d89ce..b8a4b5058a 100644 --- a/Makefile +++ b/Makefile @@ -2241,8 +2241,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) # read all saved command lines -targets := $(wildcard $(sort $(targets))) -cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) +cmd_files := $(wildcard .*.cmd $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) $(cmd_files): ; # Do not try to update included dependency files diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index cad3b6e76c..dfb67226b0 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -7,6 +7,7 @@ quote := " squote := ' empty := space := $(empty) $(empty) +space_escape := _-_SPACE_-_ pound := \# ### @@ -234,10 +235,10 @@ objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) # See Documentation/kbuild/makefiles.txt for more info ifneq ($(KBUILD_NOCMDDEP),1) -# Check if both arguments has same arguments. Result is empty string if equal. -# User may override this check using make KBUILD_NOCMDDEP=1 -arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ - $(filter-out $(cmd_$@), $(cmd_$(1))) ) +# Check if both arguments are the same including their order. Result is empty +# string if equal. User may override this check using make KBUILD_NOCMDDEP=1 +arg-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), \ + $(subst $(space),$(space_escape),$(strip $(cmd_$1)))) else arg-check = $(if $(strip $(cmd_$@)),,1) endif @@ -259,7 +260,7 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ @set -e; \ $(echo-cmd) $(cmd_$(1)); \ - printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) + printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) # Execute the command and also postprocess generated .d dependencies file. if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ @@ -267,14 +268,14 @@ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ $(echo-cmd) $(cmd_$(1)); \ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ rm -f $(depfile); \ - mv -f $(dot-target).tmp $(dot-target).cmd) + mv -f $(dot-target).tmp $(dot-target).cmd, @:) # Usage: $(call if_changed_rule,foo) # Will check if $(cmd_foo) or any of the prerequisites changed, # and if so will execute $(rule_foo). if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ @set -e; \ - $(rule_$(1))) + $(rule_$(1)), @:) ### # why - tell why a a target got build diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 5e5f1682c9..705a886cb9 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -75,17 +75,6 @@ ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(h include scripts/Makefile.host endif -# Uncommented for U-Boot -# We need to create output dicrectory for SPL and TPL even for in-tree build -#ifneq ($(KBUILD_SRC),) -# Create output directory if not already present -_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) - -# Create directories for object files if directory does not exist -# Needed when obj-y := dir/file.o syntax is used -_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) -#endif - ifndef obj $(warning kbuild: Makefile.build is included improperly) endif @@ -441,11 +430,14 @@ FORCE: # optimization, we don't need to read them if the target does not # exist, we will rebuild anyway in that case. -targets := $(wildcard $(sort $(targets))) -cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) +cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) include $(cmd_files) endif +# Create directories for object files if they do not exist +obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets)))) +$(shell mkdir -p $(obj-dirs)) + .PHONY: $(PHONY) diff --git a/scripts/Makefile.host b/scripts/Makefile.host index da2f4d5bfd..69983a19a4 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -53,15 +53,6 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs)))) -# output directory for programs/.o files -# hostprogs-y := tools/build may have been specified. -# Retrieve also directory of .o files from prog-objs or prog-cxxobjs notation -host-objdirs := $(dir $(__hostprogs) $(host-cobjs) $(host-cxxobjs)) - -host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs)))) - - -__hostprogs := $(addprefix $(obj)/,$(__hostprogs)) host-csingle := $(addprefix $(obj)/,$(host-csingle)) host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) @@ -72,9 +63,6 @@ host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib)) host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs)) host-shared := $(addprefix $(obj)/,$(host-shared)) -host-objdirs := $(addprefix $(obj)/,$(host-objdirs)) - -obj-dirs += $(host-objdirs) ##### # Handle options to gcc. Support building with separate output directory diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 1c8cb7488f..63fbadd757 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -57,15 +57,11 @@ single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) # objects depend on those (obviously) multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) -multi-objs := $(multi-objs-y) $(multi-objs-m) # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to # tell kbuild to descend subdir-obj-y := $(filter %/built-in.o, $(obj-y)) -# $(obj-dirs) is a list of directories that contain object files -obj-dirs := $(dir $(multi-objs) $(obj-y)) - # Replace multi-part objects by their individual parts, look at local dir only real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) @@ -88,7 +84,6 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) -obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) # These flags are needed for modversions and compiling, so we define them here # already @@ -97,10 +92,10 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) # Note: Files that end up in two or more modules are compiled without the # KBUILD_MODNAME definition. The reason is that any made-up name would # differ in different configs. -name-fix = $(subst $(comma),_,$(subst -,_,$1)) -basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" +name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) +basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) modname_flags = $(if $(filter 1,$(words $(modname))),\ - -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") + -DKBUILD_MODNAME=$(call name-fix,$(modname))) orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ $(ccflags-y) $(CFLAGS_$(basetarget).o) @@ -153,7 +148,7 @@ endif # Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ $(__c_flags) $(modkern_cflags) \ - -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) + $(basename_flags) $(modname_flags) a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ $(__a_flags) $(modkern_aflags) @@ -576,3 +571,32 @@ quiet_cmd_fdtgrep = FDTGREP $@ quiet_cmd_fdt_rm_props = FDTGREP $@ cmd_fdt_rm_props = cat $< | $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \ $(addprefix -P ,$(subst $\",,$(CONFIG_OF_REMOVE_PROPS))) + +# ASM offsets +# --------------------------------------------------------------------------- + +# Default sed regexp - multiline due to syntax constraints +define sed-offsets + "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \ + /^->/{s:->#\(.*\):/* \1 */:; \ + s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:->::; p;}" +endef + +# Use filechk to avoid rebuilds when a header changes, but the resulting file +# does not +define filechk_offsets + (set -e; \ + echo "#ifndef $2"; \ + echo "#define $2"; \ + echo "/*"; \ + echo " * DO NOT MODIFY."; \ + echo " *"; \ + echo " * This file was generated by Kbuild"; \ + echo " */"; \ + echo ""; \ + sed -ne $(sed-offsets); \ + echo ""; \ + echo "#endif" ) +endef From cb2a2ebd4f93220936de721918ed9a3ca57cc5db Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 19 Apr 2020 11:07:34 +0200 Subject: [PATCH 16/33] coccinelle: check for casting malloc output Casting the (void *) output of memory allocation functions before assignment like in sata->cmd_hdr_tbl_offset = (void *)malloc(length + align); is useless. Adopt the Linux kernel script scripts/coccinelle/api/alloc/alloc_cast.cocci. Now 'make coccicheck' generates warnings like: ./drivers/ata/fsl_sata.c:143:29-33: WARNING: casting value returned by memory allocation function to (void *) is useless. Signed-off-by: Heinrich Schuchardt --- scripts/coccinelle/api/alloc/alloc_cast.cocci | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 scripts/coccinelle/api/alloc/alloc_cast.cocci diff --git a/scripts/coccinelle/api/alloc/alloc_cast.cocci b/scripts/coccinelle/api/alloc/alloc_cast.cocci new file mode 100644 index 0000000000..e336784a9f --- /dev/null +++ b/scripts/coccinelle/api/alloc/alloc_cast.cocci @@ -0,0 +1,102 @@ +// SPDX-License-Identifier: GPL-2.0-only +/// Remove casting the values returned by memory allocation functions +/// like kmalloc, kzalloc, kmem_cache_alloc, kmem_cache_zalloc etc. +/// +//# This makes an effort to find cases of casting of values returned by +//# malloc, calloc, kmalloc, kmalloc_array, kmalloc_node and removes +//# the casting as it is not required. The result in the patch case may +//# need some reformatting. +// +// Confidence: High +// Copyright: (C) 2014 Himangi Saraogi +// Copyright: (C) 2017 Himanshu Jha +// Comments: +// Options: --no-includes --include-headers +// + +virtual context +virtual patch +virtual org +virtual report + +@initialize:python@ +@@ +import re +pattern = '__' +m = re.compile(pattern) + +@r1 depends on context || patch@ +type T; +@@ + + (T *) + \(malloc\|calloc\|kmalloc\|kmalloc_array\|kmalloc_node\)(...) + +//---------------------------------------------------------- +// For context mode +//---------------------------------------------------------- + +@script:python depends on context@ +t << r1.T; +@@ + +if m.search(t) != None: + cocci.include_match(False) + +@depends on context && r1@ +type r1.T; +@@ + +* (T *) + \(malloc\|calloc\|kmalloc\|kmalloc_array\|kmalloc_node\)(...) + +//---------------------------------------------------------- +// For patch mode +//---------------------------------------------------------- + +@script:python depends on patch@ +t << r1.T; +@@ + +if m.search(t) != None: + cocci.include_match(False) + +@depends on patch && r1@ +type r1.T; +@@ + +- (T *) + \(malloc\|calloc\|kmalloc\|kmalloc_array\|kmalloc_node\)(...) + +//---------------------------------------------------------- +// For org and report mode +//---------------------------------------------------------- + +@r2 depends on org || report@ +type T; +position p; +@@ + + (T@p *) + \(malloc\|calloc\|kmalloc\|kmalloc_array\|kmalloc_node\)(...) + +@script:python depends on org@ +p << r2.p; +t << r2.T; +@@ + +if m.search(t) != None: + cocci.include_match(False) +else: + coccilib.org.print_safe_todo(p[0], t) + +@script:python depends on report@ +p << r2.p; +t << r2.T; +@@ + +if m.search(t) != None: + cocci.include_match(False) +else: + msg="WARNING: casting value returned by memory allocation function to (%s *) is useless." % (t) + coccilib.report.print_report(p[0], msg) From c11f0d88ba462976335a4990a30a99d1d0b49195 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 19 Apr 2020 11:56:02 +0200 Subject: [PATCH 17/33] coccinelle: adjust NULL check before free() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The free() function checks if its argument is NULL. We should avoid checking for NULL before calling free like in     if (result->tds)         free(result->tds); The list of relevant functions differs between Linux and U-Boot, e.g. we use free(). Adjust the list of relevant functions. Signed-off-by: Heinrich Schuchardt --- scripts/coccinelle/free/ifnullfree.cocci | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/scripts/coccinelle/free/ifnullfree.cocci b/scripts/coccinelle/free/ifnullfree.cocci index 14a4cd98e8..2d59545d7d 100644 --- a/scripts/coccinelle/free/ifnullfree.cocci +++ b/scripts/coccinelle/free/ifnullfree.cocci @@ -1,10 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-only /// NULL check before some freeing functions is not needed. /// /// Based on checkpatch warning /// "kfree(NULL) is safe this check is probably not required" /// and kfreeaddr.cocci by Julia Lawall. /// -// Copyright: (C) 2014 Fabian Frederick. GPLv2. +// Copyright: (C) 2014 Fabian Frederick. // Comments: - // Options: --no-includes --include-headers @@ -18,21 +19,19 @@ expression E; @@ - if (E != NULL) ( + free(E); +| kfree(E); | - kzfree(E); + vfree(E); | - debugfs_remove(E); + vfree_recursive(E); | - debugfs_remove_recursive(E); -| - usb_free_urb(E); + kmem_cache_free(E); | kmem_cache_destroy(E); | - mempool_destroy(E); -| - dma_pool_destroy(E); + gzfree(E); ) @r depends on context || report || org @ @@ -41,9 +40,8 @@ position p; @@ * if (E != NULL) -* \(kfree@p\|kzfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\| -* usb_free_urb@p\|kmem_cache_destroy@p\|mempool_destroy@p\| -* dma_pool_destroy@p\)(E); +* \(free@p\|kfree@p\|vfree@p\|debugfs_remove_recursive@p\| +* kmem_cache_free@p\|kmem_cache_destroy@p\|gzfree@p\)(E); @script:python depends on org@ p << r.p; @@ -55,5 +53,5 @@ cocci.print_main("NULL check before that freeing function is not needed", p) p << r.p; @@ -msg = "WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values." +msg = "WARNING: NULL check before some freeing functions is not needed." coccilib.report.print_report(p[0], msg) From b1a6bb3b5998f0f2e84f0a6d255e936be3eb17f5 Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:25 +0530 Subject: [PATCH 18/33] arm: actions: Add common framework for Actions Owl Semi SoCs This commit adds common arch support for Actions Semi Owl series SoCs and removes the Bubblegum96 board files. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Andre Przywara Signed-off-by: Amit Singh Tomar --- MAINTAINERS | 3 +- arch/arm/Kconfig | 3 +- arch/arm/mach-owl/Kconfig | 29 ++++++++----------- arch/arm/mach-owl/Makefile | 1 + .../bubblegum_96.c => arch/arm/mach-owl/soc.c | 4 +-- board/ucRobotics/bubblegum_96/Kconfig | 15 ---------- board/ucRobotics/bubblegum_96/MAINTAINERS | 6 ---- board/ucRobotics/bubblegum_96/Makefile | 3 -- configs/bubblegum_96_defconfig | 4 +-- .../configs/{bubblegum_96.h => owl-common.h} | 6 ++-- 10 files changed, 22 insertions(+), 52 deletions(-) rename board/ucRobotics/bubblegum_96/bubblegum_96.c => arch/arm/mach-owl/soc.c (92%) delete mode 100644 board/ucRobotics/bubblegum_96/Kconfig delete mode 100644 board/ucRobotics/bubblegum_96/MAINTAINERS delete mode 100644 board/ucRobotics/bubblegum_96/Makefile rename include/configs/{bubblegum_96.h => owl-common.h} (89%) diff --git a/MAINTAINERS b/MAINTAINERS index 0ee358bac6..4504afc892 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -272,9 +272,10 @@ M: Manivannan Sadhasivam S: Maintained F: arch/arm/include/asm/arch-owl/ F: arch/arm/mach-owl/ -F: board/ucRobotics/ F: drivers/clk/owl/ F: drivers/serial/serial_owl.c +F: include/configs/owl-common.h +F: configs/bubblegum_96_defconfig ARM RENESAS RMOBILE/R-CAR M: Nobuhiro Iwamatsu diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 33b484753c..e85506a51a 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -874,9 +874,9 @@ config ARCH_MX5 config ARCH_OWL bool "Actions Semi OWL SoCs" - select ARM64 select DM select DM_SERIAL + select OWL_SERIAL select OF_CONTROL imply CMD_DM @@ -1870,7 +1870,6 @@ source "board/spear/spear600/Kconfig" source "board/spear/x600/Kconfig" source "board/st/stv0991/Kconfig" source "board/tcl/sl50/Kconfig" -source "board/ucRobotics/bubblegum_96/Kconfig" source "board/birdland/bav335x/Kconfig" source "board/toradex/colibri_pxa270/Kconfig" source "board/variscite/dart_6ul/Kconfig" diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig index 199e772988..28984c1b08 100644 --- a/arch/arm/mach-owl/Kconfig +++ b/arch/arm/mach-owl/Kconfig @@ -1,27 +1,22 @@ if ARCH_OWL -config SYS_SOC - default "owl" - choice - prompt "Actions Semi OWL SoCs board select" + prompt "Actions Semi Owl SoC Variant" optional -config TARGET_BUBBLEGUM_96 - bool "96Boards Bubblegum-96" - help - Support for 96Boards Bubblegum-96. This board complies with - 96Board Consumer Edition Specification. Features: - - Actions Semi S900 SoC (4xCortex A53, Power VR G6230 GPU) - - 2GiB RAM - - 8GiB eMMC, uSD slot - - WiFi, Bluetooth and GPS module - - 2x Host, 1x Device USB port - - HDMI - - 20-pin low speed and 40-pin high speed expanders, 6 LED, 3 buttons +config MACH_S900 + bool "Actions Semi S900 SoC" + select ARM64 endchoice -source "board/ucRobotics/bubblegum_96/Kconfig" +config SYS_TEXT_BASE + default 0x11000000 + +config SYS_CONFIG_NAME + default "owl-common" + +config SYS_SOC + default "s900" if MACH_S900 endif diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile index 1b43dc2921..0b181c62d6 100644 --- a/arch/arm/mach-owl/Makefile +++ b/arch/arm/mach-owl/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0+ +obj-y += soc.o obj-y += sysmap-s900.o diff --git a/board/ucRobotics/bubblegum_96/bubblegum_96.c b/arch/arm/mach-owl/soc.c similarity index 92% rename from board/ucRobotics/bubblegum_96/bubblegum_96.c rename to arch/arm/mach-owl/soc.c index c16f117bf8..409cbd319f 100644 --- a/board/ucRobotics/bubblegum_96/bubblegum_96.c +++ b/arch/arm/mach-owl/soc.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Bubblegum-96 Boards Support + * Actions Semi Owl SoCs platform support. * * Copyright (C) 2018 Manivannan Sadhasivam */ @@ -40,7 +40,7 @@ static void show_psci_version(void) arm_smccc_smc(ARM_PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0, 0, 0, 0, 0, &res); printf("PSCI: v%ld.%ld\n", - PSCI_VERSION_MAJOR(res.a0), + PSCI_VERSION_MAJOR(res.a0), PSCI_VERSION_MINOR(res.a0)); } diff --git a/board/ucRobotics/bubblegum_96/Kconfig b/board/ucRobotics/bubblegum_96/Kconfig deleted file mode 100644 index 2dd40d9b6a..0000000000 --- a/board/ucRobotics/bubblegum_96/Kconfig +++ /dev/null @@ -1,15 +0,0 @@ -if TARGET_BUBBLEGUM_96 - -config SYS_BOARD - default "bubblegum_96" - -config SYS_VENDOR - default "ucRobotics" - -config SYS_SOC - default "s900" - -config SYS_CONFIG_NAME - default "bubblegum_96" - -endif diff --git a/board/ucRobotics/bubblegum_96/MAINTAINERS b/board/ucRobotics/bubblegum_96/MAINTAINERS deleted file mode 100644 index d0cb7278c6..0000000000 --- a/board/ucRobotics/bubblegum_96/MAINTAINERS +++ /dev/null @@ -1,6 +0,0 @@ -BUBBLEGUM_96 BOARD -M: Manivannan Sadhasivam -S: Maintained -F: board/ucRobotics/bubblegum_96/ -F: include/configs/bubblegum_96.h -F: configs/bubblegum_96_defconfig diff --git a/board/ucRobotics/bubblegum_96/Makefile b/board/ucRobotics/bubblegum_96/Makefile deleted file mode 100644 index c4b524def2..0000000000 --- a/board/ucRobotics/bubblegum_96/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0+ - -obj-y := bubblegum_96.o diff --git a/configs/bubblegum_96_defconfig b/configs/bubblegum_96_defconfig index ae44ce1e94..8c94def75e 100644 --- a/configs/bubblegum_96_defconfig +++ b/configs/bubblegum_96_defconfig @@ -1,9 +1,8 @@ CONFIG_ARM=y CONFIG_ARCH_OWL=y -CONFIG_SYS_TEXT_BASE=0x11000000 CONFIG_ENV_SIZE=0x2000 -CONFIG_TARGET_BUBBLEGUM_96=y CONFIG_NR_DRAM_BANKS=1 +CONFIG_MACH_S900=y CONFIG_IDENT_STRING="\nBubblegum-96" CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTDELAY=5 @@ -21,4 +20,3 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_CLK=y CONFIG_CLK_OWL=y CONFIG_CLK_S900=y -CONFIG_OWL_SERIAL=y diff --git a/include/configs/bubblegum_96.h b/include/configs/owl-common.h similarity index 89% rename from include/configs/bubblegum_96.h rename to include/configs/owl-common.h index c739d665f6..f77a5fa4c1 100644 --- a/include/configs/bubblegum_96.h +++ b/include/configs/owl-common.h @@ -1,14 +1,14 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Board configuration file for Bubblegum-96 + * Board configuration file for Actions Semi Owl SoCs. * * Copyright (C) 2015 Actions Semi Co., Ltd. * Copyright (C) 2018 Manivannan Sadhasivam * */ -#ifndef _BUBBLEGUM_96_H_ -#define _BUGGLEGUM_96_H_ +#ifndef _OWL_COMMON_CONFIG_H_ +#define _OWL_COMMON_CONFIG_H_ /* SDRAM Definitions */ #define CONFIG_SYS_SDRAM_BASE 0x0 From d996f35403ec25cb620f74090fac214bf28989d6 Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:26 +0530 Subject: [PATCH 19/33] arm: actions: rename sysmap-s900 to sysmap-owl Now that memory maps(for both S700 and S900 SoCs) can be managed using a common file, rename sysmap-s900 to sysmap-owl to reflect the same. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Amit Singh Tomar --- arch/arm/mach-owl/Makefile | 2 +- arch/arm/mach-owl/{sysmap-s900.c => sysmap-owl.c} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename arch/arm/mach-owl/{sysmap-s900.c => sysmap-owl.c} (83%) diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile index 0b181c62d6..f3a69ebf15 100644 --- a/arch/arm/mach-owl/Makefile +++ b/arch/arm/mach-owl/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0+ obj-y += soc.o -obj-y += sysmap-s900.o +obj-$(CONFIG_ARM64) += sysmap-owl.o diff --git a/arch/arm/mach-owl/sysmap-s900.c b/arch/arm/mach-owl/sysmap-owl.c similarity index 83% rename from arch/arm/mach-owl/sysmap-s900.c rename to arch/arm/mach-owl/sysmap-owl.c index f78b639740..81f6ca2e49 100644 --- a/arch/arm/mach-owl/sysmap-s900.c +++ b/arch/arm/mach-owl/sysmap-owl.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Actions Semi S900 Memory map + * Memory map for Actions Semi Owl series SoCs. * * Copyright (C) 2015 Actions Semi Co., Ltd. * Copyright (C) 2018 Manivannan Sadhasivam @@ -9,7 +9,7 @@ #include #include -static struct mm_region s900_mem_map[] = { +static struct mm_region owl_mem_map[] = { { .virt = 0x0UL, /* DDR */ .phys = 0x0UL, /* DDR */ @@ -29,4 +29,4 @@ static struct mm_region s900_mem_map[] = { } }; -struct mm_region *mem_map = s900_mem_map; +struct mm_region *mem_map = owl_mem_map; From bf66584336351355cd487c166f645f12c2442925 Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:27 +0530 Subject: [PATCH 20/33] serial: actions: add compatible string This patch adds "actions,owl-uart" string to the owl uart driver. It is also defined in Linux kernel. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Andre Przywara Signed-off-by: Amit Singh Tomar --- drivers/serial/serial_owl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/serial/serial_owl.c b/drivers/serial/serial_owl.c index 7ead73e6b7..539acdc92a 100644 --- a/drivers/serial/serial_owl.c +++ b/drivers/serial/serial_owl.c @@ -121,6 +121,7 @@ static const struct dm_serial_ops owl_serial_ops = { static const struct udevice_id owl_serial_ids[] = { { .compatible = "actions,s900-serial" }, + { .compatible = "actions,owl-uart" }, { } }; From 4939beea8e14314bc27ca343526c456ed75640fb Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:28 +0530 Subject: [PATCH 21/33] arm: dts: sync dts for Action Semi S900 Synchronize device tree bindings with v5.5-rc6 tag with commit id "b3a987b0264d". Also, it removes older clock binding defined for S900 along with undocumented compatible string "actions,s900-serial" from serial driver and adapts clock driver to cater to new bindings. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Andre Przywara Signed-off-by: Amit Singh Tomar --- arch/arm/dts/Makefile | 2 +- arch/arm/dts/s900.dtsi | 324 ++++++++++++++++-- drivers/clk/owl/clk_s900.c | 6 +- drivers/serial/serial_owl.c | 1 - include/dt-bindings/clock/actions,s900-cmu.h | 129 +++++++ include/dt-bindings/clock/s900_cmu.h | 77 ----- .../dt-bindings/reset/actions,s900-reset.h | 65 ++++ 7 files changed, 500 insertions(+), 104 deletions(-) create mode 100644 include/dt-bindings/clock/actions,s900-cmu.h delete mode 100644 include/dt-bindings/clock/s900_cmu.h create mode 100644 include/dt-bindings/reset/actions,s900-reset.h diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 59a2713cb2..ba96efaa1e 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -64,7 +64,7 @@ dtb-$(CONFIG_KIRKWOOD) += \ kirkwood-pogo_e02.dtb \ kirkwood-sheevaplug.dtb -dtb-$(CONFIG_ARCH_OWL) += \ +dtb-$(CONFIG_MACH_S900) += \ bubblegum_96.dtb dtb-$(CONFIG_ROCKCHIP_PX30) += \ diff --git a/arch/arm/dts/s900.dtsi b/arch/arm/dts/s900.dtsi index 2bbb30a5a8..eb35cf78ab 100644 --- a/arch/arm/dts/s900.dtsi +++ b/arch/arm/dts/s900.dtsi @@ -1,17 +1,94 @@ -// SPDX-License-Identifier: GPL-2.0+ -// -// Device Tree Source for Actions Semi S900 SoC -// -// Copyright (C) 2015 Actions Semi Co., Ltd. -// Copyright (C) 2018 Manivannan Sadhasivam +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2017 Andreas Färber + */ -/dts-v1/; -#include +#include +#include +#include +#include / { compatible = "actions,s900"; - #address-cells = <0x2>; - #size-cells = <0x2>; + interrupt-parent = <&gic>; + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x0 0x0>; + enable-method = "psci"; + }; + + cpu1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x0 0x1>; + enable-method = "psci"; + }; + + cpu2: cpu@2 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x0 0x2>; + enable-method = "psci"; + }; + + cpu3: cpu@3 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x0 0x3>; + enable-method = "psci"; + }; + }; + + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + secmon@1f000000 { + reg = <0x0 0x1f000000 0x0 0x1000000>; + no-map; + }; + }; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + + arm-pmu { + compatible = "arm,cortex-a53-pmu"; + interrupts = , + , + , + ; + interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupts = , + , + , + ; + }; + + hosc: hosc { + compatible = "fixed-clock"; + clock-frequency = <24000000>; + #clock-cells = <0>; + }; losc: losc { compatible = "fixed-clock"; @@ -26,28 +103,231 @@ }; soc { - u-boot,dm-pre-reloc; compatible = "simple-bus"; - #address-cells = <0x2>; - #size-cells = <0x2>; + #address-cells = <2>; + #size-cells = <2>; ranges; - uart5: serial@e012a000 { - u-boot,dm-pre-reloc; - compatible = "actions,s900-serial"; - reg = <0x0 0xe012a000 0x0 0x1000>; - clocks = <&cmu CLOCK_UART5>; + gic: interrupt-controller@e00f1000 { + compatible = "arm,gic-400"; + reg = <0x0 0xe00f1000 0x0 0x1000>, + <0x0 0xe00f2000 0x0 0x2000>, + <0x0 0xe00f4000 0x0 0x2000>, + <0x0 0xe00f6000 0x0 0x2000>; + interrupts = ; + interrupt-controller; + #interrupt-cells = <3>; + }; + + uart0: serial@e0120000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe0120000 0x0 0x2000>; + clocks = <&cmu CLK_UART0>; + interrupts = ; status = "disabled"; }; + uart1: serial@e0122000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe0122000 0x0 0x2000>; + clocks = <&cmu CLK_UART1>; + interrupts = ; + status = "disabled"; + }; + + uart2: serial@e0124000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe0124000 0x0 0x2000>; + clocks = <&cmu CLK_UART2>; + interrupts = ; + status = "disabled"; + }; + + uart3: serial@e0126000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe0126000 0x0 0x2000>; + clocks = <&cmu CLK_UART3>; + interrupts = ; + status = "disabled"; + }; + + uart4: serial@e0128000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe0128000 0x0 0x2000>; + clocks = <&cmu CLK_UART4>; + interrupts = ; + status = "disabled"; + }; + + uart5: serial@e012a000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe012a000 0x0 0x2000>; + clocks = <&cmu CLK_UART5>; + interrupts = ; + status = "disabled"; + }; + + uart6: serial@e012c000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe012c000 0x0 0x2000>; + clocks = <&cmu CLK_UART6>; + interrupts = ; + status = "disabled"; + }; + + sps: power-controller@e012e000 { + compatible = "actions,s900-sps"; + reg = <0x0 0xe012e000 0x0 0x2000>; + #power-domain-cells = <1>; + }; + cmu: clock-controller@e0160000 { - u-boot,dm-pre-reloc; compatible = "actions,s900-cmu"; reg = <0x0 0xe0160000 0x0 0x1000>; - clocks = <&losc>, <&diff24M>; - clock-names = "losc", "diff24M"; + clocks = <&hosc>, <&losc>; #clock-cells = <1>; + #reset-cells = <1>; + }; + + i2c0: i2c@e0170000 { + compatible = "actions,s900-i2c"; + reg = <0 0xe0170000 0 0x1000>; + clocks = <&cmu CLK_I2C0>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c1: i2c@e0172000 { + compatible = "actions,s900-i2c"; + reg = <0 0xe0172000 0 0x1000>; + clocks = <&cmu CLK_I2C1>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c2: i2c@e0174000 { + compatible = "actions,s900-i2c"; + reg = <0 0xe0174000 0 0x1000>; + clocks = <&cmu CLK_I2C2>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c3: i2c@e0176000 { + compatible = "actions,s900-i2c"; + reg = <0 0xe0176000 0 0x1000>; + clocks = <&cmu CLK_I2C3>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c4: i2c@e0178000 { + compatible = "actions,s900-i2c"; + reg = <0 0xe0178000 0 0x1000>; + clocks = <&cmu CLK_I2C4>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c5: i2c@e017a000 { + compatible = "actions,s900-i2c"; + reg = <0 0xe017a000 0 0x1000>; + clocks = <&cmu CLK_I2C5>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + pinctrl: pinctrl@e01b0000 { + compatible = "actions,s900-pinctrl"; + reg = <0x0 0xe01b0000 0x0 0x1000>; + clocks = <&cmu CLK_GPIO>; + gpio-controller; + gpio-ranges = <&pinctrl 0 0 146>; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + interrupts = , + , + , + , + , + ; + }; + + timer: timer@e0228000 { + compatible = "actions,s900-timer"; + reg = <0x0 0xe0228000 0x0 0x8000>; + interrupts = ; + interrupt-names = "timer1"; + }; + + dma: dma-controller@e0260000 { + compatible = "actions,s900-dma"; + reg = <0x0 0xe0260000 0x0 0x1000>; + interrupts = , + , + , + ; + #dma-cells = <1>; + dma-channels = <12>; + dma-requests = <46>; + clocks = <&cmu CLK_DMAC>; + }; + + mmc0: mmc@e0330000 { + compatible = "actions,owl-mmc"; + reg = <0x0 0xe0330000 0x0 0x4000>; + interrupts = ; + clocks = <&cmu CLK_SD0>; + resets = <&cmu RESET_SD0>; + dmas = <&dma 2>; + dma-names = "mmc"; + status = "disabled"; + }; + + mmc1: mmc@e0334000 { + compatible = "actions,owl-mmc"; + reg = <0x0 0xe0334000 0x0 0x4000>; + interrupts = ; + clocks = <&cmu CLK_SD1>; + resets = <&cmu RESET_SD1>; + dmas = <&dma 3>; + dma-names = "mmc"; + status = "disabled"; + }; + + mmc2: mmc@e0338000 { + compatible = "actions,owl-mmc"; + reg = <0x0 0xe0338000 0x0 0x4000>; + interrupts = ; + clocks = <&cmu CLK_SD2>; + resets = <&cmu RESET_SD2>; + dmas = <&dma 4>; + dma-names = "mmc"; + status = "disabled"; + }; + + mmc3: mmc@e033c000 { + compatible = "actions,owl-mmc"; + reg = <0x0 0xe033c000 0x0 0x4000>; + interrupts = ; + clocks = <&cmu CLK_SD3>; + resets = <&cmu RESET_SD3>; + dmas = <&dma 46>; + dma-names = "mmc"; + status = "disabled"; }; }; }; - diff --git a/drivers/clk/owl/clk_s900.c b/drivers/clk/owl/clk_s900.c index a7c15d2812..d60f199252 100644 --- a/drivers/clk/owl/clk_s900.c +++ b/drivers/clk/owl/clk_s900.c @@ -12,7 +12,7 @@ #include #include -#include +#include void owl_clk_init(struct owl_clk_priv *priv) { @@ -78,7 +78,7 @@ int owl_clk_enable(struct clk *clk) struct owl_clk_priv *priv = dev_get_priv(clk->dev); switch (clk->id) { - case CLOCK_UART5: + case CLK_UART5: owl_uart_clk_enable(priv); break; default: @@ -93,7 +93,7 @@ int owl_clk_disable(struct clk *clk) struct owl_clk_priv *priv = dev_get_priv(clk->dev); switch (clk->id) { - case CLOCK_UART5: + case CLK_UART5: owl_uart_clk_disable(priv); break; default: diff --git a/drivers/serial/serial_owl.c b/drivers/serial/serial_owl.c index 539acdc92a..bb60ca2d9b 100644 --- a/drivers/serial/serial_owl.c +++ b/drivers/serial/serial_owl.c @@ -120,7 +120,6 @@ static const struct dm_serial_ops owl_serial_ops = { }; static const struct udevice_id owl_serial_ids[] = { - { .compatible = "actions,s900-serial" }, { .compatible = "actions,owl-uart" }, { } }; diff --git a/include/dt-bindings/clock/actions,s900-cmu.h b/include/dt-bindings/clock/actions,s900-cmu.h new file mode 100644 index 0000000000..7c1251565f --- /dev/null +++ b/include/dt-bindings/clock/actions,s900-cmu.h @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// Device Tree binding constants for Actions Semi S900 Clock Management Unit +// +// Copyright (c) 2014 Actions Semi Inc. +// Copyright (c) 2018 Linaro Ltd. + +#ifndef __DT_BINDINGS_CLOCK_S900_CMU_H +#define __DT_BINDINGS_CLOCK_S900_CMU_H + +#define CLK_NONE 0 + +/* fixed rate clocks */ +#define CLK_LOSC 1 +#define CLK_HOSC 2 + +/* pll clocks */ +#define CLK_CORE_PLL 3 +#define CLK_DEV_PLL 4 +#define CLK_DDR_PLL 5 +#define CLK_NAND_PLL 6 +#define CLK_DISPLAY_PLL 7 +#define CLK_DSI_PLL 8 +#define CLK_ASSIST_PLL 9 +#define CLK_AUDIO_PLL 10 + +/* system clock */ +#define CLK_CPU 15 +#define CLK_DEV 16 +#define CLK_NOC 17 +#define CLK_NOC_MUX 18 +#define CLK_NOC_DIV 19 +#define CLK_AHB 20 +#define CLK_APB 21 +#define CLK_DMAC 22 + +/* peripheral device clock */ +#define CLK_GPIO 23 + +#define CLK_BISP 24 +#define CLK_CSI0 25 +#define CLK_CSI1 26 + +#define CLK_DE0 27 +#define CLK_DE1 28 +#define CLK_DE2 29 +#define CLK_DE3 30 +#define CLK_DSI 32 + +#define CLK_GPU 33 +#define CLK_GPU_CORE 34 +#define CLK_GPU_MEM 35 +#define CLK_GPU_SYS 36 + +#define CLK_HDE 37 +#define CLK_I2C0 38 +#define CLK_I2C1 39 +#define CLK_I2C2 40 +#define CLK_I2C3 41 +#define CLK_I2C4 42 +#define CLK_I2C5 43 +#define CLK_I2SRX 44 +#define CLK_I2STX 45 +#define CLK_IMX 46 +#define CLK_LCD 47 +#define CLK_NAND0 48 +#define CLK_NAND1 49 +#define CLK_PWM0 50 +#define CLK_PWM1 51 +#define CLK_PWM2 52 +#define CLK_PWM3 53 +#define CLK_PWM4 54 +#define CLK_PWM5 55 +#define CLK_SD0 56 +#define CLK_SD1 57 +#define CLK_SD2 58 +#define CLK_SD3 59 +#define CLK_SENSOR 60 +#define CLK_SPEED_SENSOR 61 +#define CLK_SPI0 62 +#define CLK_SPI1 63 +#define CLK_SPI2 64 +#define CLK_SPI3 65 +#define CLK_THERMAL_SENSOR 66 +#define CLK_UART0 67 +#define CLK_UART1 68 +#define CLK_UART2 69 +#define CLK_UART3 70 +#define CLK_UART4 71 +#define CLK_UART5 72 +#define CLK_UART6 73 +#define CLK_VCE 74 +#define CLK_VDE 75 + +#define CLK_USB3_480MPLL0 76 +#define CLK_USB3_480MPHY0 77 +#define CLK_USB3_5GPHY 78 +#define CLK_USB3_CCE 79 +#define CLK_USB3_MAC 80 + +#define CLK_TIMER 83 + +#define CLK_HDMI_AUDIO 84 + +#define CLK_24M 85 + +#define CLK_EDP 86 + +#define CLK_24M_EDP 87 +#define CLK_EDP_PLL 88 +#define CLK_EDP_LINK 89 + +#define CLK_USB2H0_PLLEN 90 +#define CLK_USB2H0_PHY 91 +#define CLK_USB2H0_CCE 92 +#define CLK_USB2H1_PLLEN 93 +#define CLK_USB2H1_PHY 94 +#define CLK_USB2H1_CCE 95 + +#define CLK_DDR0 96 +#define CLK_DDR1 97 +#define CLK_DMM 98 + +#define CLK_ETH_MAC 99 +#define CLK_RMII_REF 100 + +#define CLK_NR_CLKS (CLK_RMII_REF + 1) + +#endif /* __DT_BINDINGS_CLOCK_S900_CMU_H */ diff --git a/include/dt-bindings/clock/s900_cmu.h b/include/dt-bindings/clock/s900_cmu.h deleted file mode 100644 index 2685a6df4a..0000000000 --- a/include/dt-bindings/clock/s900_cmu.h +++ /dev/null @@ -1,77 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Copyright (C) 2015 Actions Semi Co., Ltd. - * Copyright (C) 2018 Manivannan Sadhasivam - * - */ - -#ifndef _DT_BINDINGS_CLOCK_S900_CMU_H_ -#define _DT_BINDINGS_CLOCK_S900_CMU_H_ - -/* Module Clock ID */ -#define CLOCK_DDRCH1 0 -#define CLOCK_DMAC 1 -#define CLOCK_DDRCH0 2 -#define CLOCK_BROM 3 -#define CLOCK_NANDC0 4 -#define CLOCK_SD0 5 -#define CLOCK_SD1 6 -#define CLOCK_SD2 7 -#define CLOCK_DE 8 -#define CLOCK_LVDS 9 -#define CLOCK_EDP 10 -#define CLOCK_NANDC1 11 -#define CLOCK_DSI 12 -#define CLOCK_CSI0 13 -#define CLOCK_BISP 14 -#define CLOCK_CSI1 15 -#define CLOCK_SD3 16 -#define CLOCK_I2C4 17 -#define CLOCK_GPIO 18 -#define CLOCK_DMM 19 -#define CLOCK_I2STX 20 -#define CLOCK_I2SRX 21 -#define CLOCK_HDMIA 22 -#define CLOCK_SPDIF 23 -#define CLOCK_PCM0 24 -#define CLOCK_VDE 25 -#define CLOCK_VCE 26 -#define CLOCK_HDE 27 -#define CLOCK_SHARESRAM 28 -#define CLOCK_CMU_DDR1 29 -#define CLOCK_GPU3D 30 -#define CLOCK_CMUDDR0 31 -#define CLOCK_SPEED 32 -#define CLOCK_I2C5 33 -#define CLOCK_THERMAL 34 -#define CLOCK_HDMI 35 -#define CLOCK_PWM4 36 -#define CLOCK_PWM5 37 -#define CLOCK_UART0 38 -#define CLOCK_UART1 39 -#define CLOCK_UART2 40 -#define CLOCK_IRC 41 -#define CLOCK_SPI0 42 -#define CLOCK_SPI1 43 -#define CLOCK_SPI2 44 -#define CLOCK_SPI3 45 -#define CLOCK_I2C0 46 -#define CLOCK_I2C1 47 -#define CLOCK_PCM1 48 -#define CLOCK_IMX 49 -#define CLOCK_UART6 50 -#define CLOCK_UART3 51 -#define CLOCK_UART4 52 -#define CLOCK_UART5 53 -#define CLOCK_ETHERNET 54 -#define CLOCK_PWM0 55 -#define CLOCK_PWM1 56 -#define CLOCK_PWM2 57 -#define CLOCK_PWM3 58 -#define CLOCK_TIMER 59 -#define CLOCK_SE 60 -#define CLOCK_HDCP2TX 61 -#define CLOCK_I2C2 62 -#define CLOCK_I2C3 63 - -#endif diff --git a/include/dt-bindings/reset/actions,s900-reset.h b/include/dt-bindings/reset/actions,s900-reset.h new file mode 100644 index 0000000000..42c19d02e4 --- /dev/null +++ b/include/dt-bindings/reset/actions,s900-reset.h @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: (GPL-2.0-or-later OR MIT) +// +// Device Tree binding constants for Actions Semi S900 Reset Management Unit +// +// Copyright (c) 2018 Linaro Ltd. + +#ifndef __DT_BINDINGS_ACTIONS_S900_RESET_H +#define __DT_BINDINGS_ACTIONS_S900_RESET_H + +#define RESET_CHIPID 0 +#define RESET_CPU_SCNT 1 +#define RESET_SRAMI 2 +#define RESET_DDR_CTL_PHY 3 +#define RESET_DMAC 4 +#define RESET_GPIO 5 +#define RESET_BISP_AXI 6 +#define RESET_CSI0 7 +#define RESET_CSI1 8 +#define RESET_DE 9 +#define RESET_DSI 10 +#define RESET_GPU3D_PA 11 +#define RESET_GPU3D_PB 12 +#define RESET_HDE 13 +#define RESET_I2C0 14 +#define RESET_I2C1 15 +#define RESET_I2C2 16 +#define RESET_I2C3 17 +#define RESET_I2C4 18 +#define RESET_I2C5 19 +#define RESET_IMX 20 +#define RESET_NANDC0 21 +#define RESET_NANDC1 22 +#define RESET_SD0 23 +#define RESET_SD1 24 +#define RESET_SD2 25 +#define RESET_SD3 26 +#define RESET_SPI0 27 +#define RESET_SPI1 28 +#define RESET_SPI2 29 +#define RESET_SPI3 30 +#define RESET_UART0 31 +#define RESET_UART1 32 +#define RESET_UART2 33 +#define RESET_UART3 34 +#define RESET_UART4 35 +#define RESET_UART5 36 +#define RESET_UART6 37 +#define RESET_HDMI 38 +#define RESET_LVDS 39 +#define RESET_EDP 40 +#define RESET_USB2HUB 41 +#define RESET_USB2HSIC 42 +#define RESET_USB3 43 +#define RESET_PCM1 44 +#define RESET_AUDIO 45 +#define RESET_PCM0 46 +#define RESET_SE 47 +#define RESET_GIC 48 +#define RESET_DDR_CTL_PHY_AXI 49 +#define RESET_CMU_DDR 50 +#define RESET_DMM 51 +#define RESET_HDCP2TX 52 +#define RESET_ETHERNET 53 + +#endif /* __DT_BINDINGS_ACTIONS_S900_RESET_H */ From 5bc4c0bccc360692b5d140b1da5235d7ea56325f Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:29 +0530 Subject: [PATCH 22/33] arm: dts: actions: s900: add u-boot specific dtsi file Devices like uart and clk are needed to be enabled before relocation. This patch adds u-boot.dtsi file that mark these device as dm-pre-reloc. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Andre Przywara Signed-off-by: Amit Singh Tomar --- arch/arm/dts/s900-u-boot.dtsi | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 arch/arm/dts/s900-u-boot.dtsi diff --git a/arch/arm/dts/s900-u-boot.dtsi b/arch/arm/dts/s900-u-boot.dtsi new file mode 100644 index 0000000000..a95f2cc628 --- /dev/null +++ b/arch/arm/dts/s900-u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + */ + +/{ + soc { + u-boot,dm-pre-reloc; + }; +}; + +&uart5 { + u-boot,dm-pre-reloc; +}; + +&cmu { + u-boot,dm-pre-reloc; +}; From 8b520ac15300ed8ae146979554757d8702c35e67 Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:30 +0530 Subject: [PATCH 23/33] clk: actions: Add common clock driver This patch converts S900 clock driver to something common that can be used for other SoCs, for instance S700(few of clk registers are same). Reviewed-by: Andre Przywara Signed-off-by: Amit Singh Tomar --- arch/arm/Kconfig | 2 + arch/arm/include/asm/arch-owl/regs_s700.h | 56 +++++++++++++++ configs/bubblegum_96_defconfig | 3 - drivers/clk/owl/Kconfig | 8 +-- drivers/clk/owl/Makefile | 2 +- drivers/clk/owl/{clk_s900.c => clk_owl.c} | 72 ++++++++++++------- .../clk_s900.h => drivers/clk/owl/clk_owl.h | 19 +++-- 7 files changed, 119 insertions(+), 43 deletions(-) create mode 100644 arch/arm/include/asm/arch-owl/regs_s700.h rename drivers/clk/owl/{clk_s900.c => clk_owl.c} (61%) rename arch/arm/include/asm/arch-owl/clk_s900.h => drivers/clk/owl/clk_owl.h (87%) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index e85506a51a..2f831a9a2c 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -877,6 +877,8 @@ config ARCH_OWL select DM select DM_SERIAL select OWL_SERIAL + select CLK + select CLK_OWL select OF_CONTROL imply CMD_DM diff --git a/arch/arm/include/asm/arch-owl/regs_s700.h b/arch/arm/include/asm/arch-owl/regs_s700.h new file mode 100644 index 0000000000..2f21c15cca --- /dev/null +++ b/arch/arm/include/asm/arch-owl/regs_s700.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Actions Semi S700 Register Definitions + * + */ + +#ifndef _OWL_REGS_S700_H_ +#define _OWL_REGS_S700_H_ + +#define CMU_COREPLL 0x0000 +#define CMU_DEVPLL 0x0004 +#define CMU_DDRPLL 0x0008 +#define CMU_NANDPLL 0x000C +#define CMU_DISPLAYPLL 0x0010 +#define CMU_AUDIOPLL 0x0014 +#define CMU_TVOUTPLL 0x0018 +#define CMU_BUSCLK 0x001C +#define CMU_SENSORCLK 0x0020 +#define CMU_LCDCLK 0x0024 +#define CMU_DSIPLLCLK 0x0028 +#define CMU_CSICLK 0x002C +#define CMU_DECLK 0x0030 +#define CMU_SICLK 0x0034 +#define CMU_BUSCLK1 0x0038 +#define CMU_HDECLK 0x003C +#define CMU_VDECLK 0x0040 +#define CMU_VCECLK 0x0044 +#define CMU_NANDCCLK 0x004C +#define CMU_SD0CLK 0x0050 +#define CMU_SD1CLK 0x0054 +#define CMU_SD2CLK 0x0058 +#define CMU_UART0CLK 0x005C +#define CMU_UART1CLK 0x0060 +#define CMU_UART2CLK 0x0064 +#define CMU_UART3CLK 0x0068 +#define CMU_UART4CLK 0x006C +#define CMU_UART5CLK 0x0070 +#define CMU_UART6CLK 0x0074 +#define CMU_PWM0CLK 0x0078 +#define CMU_PWM1CLK 0x007C +#define CMU_PWM2CLK 0x0080 +#define CMU_PWM3CLK 0x0084 +#define CMU_PWM4CLK 0x0088 +#define CMU_PWM5CLK 0x008C +#define CMU_GPU3DCLK 0x0090 +#define CMU_CORECTL 0x009C +#define CMU_DEVCLKEN0 0x00A0 +#define CMU_DEVCLKEN1 0x00A4 +#define CMU_DEVRST0 0x00A8 +#define CMU_DEVRST1 0x00AC +#define CMU_USBPLL 0x00B0 +#define CMU_ETHERNETPLL 0x00B4 +#define CMU_CVBSPLL 0x00B8 +#define CMU_SSTSCLK 0x00C0 + +#endif diff --git a/configs/bubblegum_96_defconfig b/configs/bubblegum_96_defconfig index 8c94def75e..e76e9a2e5a 100644 --- a/configs/bubblegum_96_defconfig +++ b/configs/bubblegum_96_defconfig @@ -17,6 +17,3 @@ CONFIG_CMD_CACHE=y CONFIG_CMD_TIMER=y CONFIG_DEFAULT_DEVICE_TREE="bubblegum_96" CONFIG_SYS_RELOC_GD_ENV_ADDR=y -CONFIG_CLK=y -CONFIG_CLK_OWL=y -CONFIG_CLK_S900=y diff --git a/drivers/clk/owl/Kconfig b/drivers/clk/owl/Kconfig index 661f1981b9..c6afef9003 100644 --- a/drivers/clk/owl/Kconfig +++ b/drivers/clk/owl/Kconfig @@ -3,10 +3,6 @@ config CLK_OWL depends on CLK && ARCH_OWL help Enable support for clock managemet unit present in Actions Semi - OWL SoCs. + Owl series S900/S700 SoCs. + -config CLK_S900 - bool "Actions Semi S900 clock driver" - depends on CLK_OWL && ARM64 - help - Enable support for the clocks in Actions Semi S900 SoC. diff --git a/drivers/clk/owl/Makefile b/drivers/clk/owl/Makefile index 63ab573f71..5218b6b4dc 100644 --- a/drivers/clk/owl/Makefile +++ b/drivers/clk/owl/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0+ -obj-$(CONFIG_CLK_S900) += clk_s900.o +obj-$(CONFIG_CLK_OWL) += clk_owl.o diff --git a/drivers/clk/owl/clk_s900.c b/drivers/clk/owl/clk_owl.c similarity index 61% rename from drivers/clk/owl/clk_s900.c rename to drivers/clk/owl/clk_owl.c index d60f199252..5607b2b7b5 100644 --- a/drivers/clk/owl/clk_s900.c +++ b/drivers/clk/owl/clk_owl.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Actions Semi S900 clock driver + * Common clock driver for Actions Semi SoCs. * * Copyright (C) 2015 Actions Semi Co., Ltd. * Copyright (C) 2018 Manivannan Sadhasivam @@ -8,20 +8,25 @@ #include #include -#include -#include +#include "clk_owl.h" #include - +#if defined(CONFIG_MACH_S900) +#include #include +#elif defined(CONFIG_MACH_S700) +#include +#include +#endif void owl_clk_init(struct owl_clk_priv *priv) { u32 bus_clk = 0, core_pll, dev_pll; +#if defined(CONFIG_MACH_S900) /* Enable ASSIST_PLL */ setbits_le32(priv->base + CMU_ASSISTPLL, BIT(0)); - udelay(PLL_STABILITY_WAIT_US); +#endif /* Source HOSC to DEV_CLK */ clrbits_le32(priv->base + CMU_DEVPLL, CMU_DEVPLL_CLK); @@ -58,31 +63,30 @@ void owl_clk_init(struct owl_clk_priv *priv) udelay(PLL_STABILITY_WAIT_US); } -void owl_uart_clk_enable(struct owl_clk_priv *priv) -{ - /* Source HOSC for UART5 interface */ - clrbits_le32(priv->base + CMU_UART5CLK, CMU_UARTCLK_SRC_DEVPLL); - - /* Enable UART5 interface clock */ - setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_UART5); -} - -void owl_uart_clk_disable(struct owl_clk_priv *priv) -{ - /* Disable UART5 interface clock */ - clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_UART5); -} - int owl_clk_enable(struct clk *clk) { struct owl_clk_priv *priv = dev_get_priv(clk->dev); + enum owl_soc model = dev_get_driver_data(clk->dev); switch (clk->id) { case CLK_UART5: - owl_uart_clk_enable(priv); + if (model != S900) + return -EINVAL; + /* Source HOSC for UART5 interface */ + clrbits_le32(priv->base + CMU_UART5CLK, CMU_UARTCLK_SRC_DEVPLL); + /* Enable UART5 interface clock */ + setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_UART5); + break; + case CLK_UART3: + if (model != S700) + return -EINVAL; + /* Source HOSC for UART3 interface */ + clrbits_le32(priv->base + CMU_UART3CLK, CMU_UARTCLK_SRC_DEVPLL); + /* Enable UART3 interface clock */ + setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_UART3); break; default: - return 0; + return -EINVAL; } return 0; @@ -91,13 +95,23 @@ int owl_clk_enable(struct clk *clk) int owl_clk_disable(struct clk *clk) { struct owl_clk_priv *priv = dev_get_priv(clk->dev); + enum owl_soc model = dev_get_driver_data(clk->dev); switch (clk->id) { case CLK_UART5: - owl_uart_clk_disable(priv); + if (model != S900) + return -EINVAL; + /* Disable UART5 interface clock */ + clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_UART5); + break; + case CLK_UART3: + if (model != S700) + return -EINVAL; + /* Disable UART3 interface clock */ + clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_UART3); break; default: - return 0; + return -EINVAL; } return 0; @@ -117,18 +131,22 @@ static int owl_clk_probe(struct udevice *dev) return 0; } -static struct clk_ops owl_clk_ops = { +static const struct clk_ops owl_clk_ops = { .enable = owl_clk_enable, .disable = owl_clk_disable, }; static const struct udevice_id owl_clk_ids[] = { - { .compatible = "actions,s900-cmu" }, +#if defined(CONFIG_MACH_S900) + { .compatible = "actions,s900-cmu", .data = S900 }, +#elif defined(CONFIG_MACH_S700) + { .compatible = "actions,s700-cmu", .data = S700 }, +#endif { } }; U_BOOT_DRIVER(clk_owl) = { - .name = "clk_s900", + .name = "clk_owl", .id = UCLASS_CLK, .of_match = owl_clk_ids, .ops = &owl_clk_ops, diff --git a/arch/arm/include/asm/arch-owl/clk_s900.h b/drivers/clk/owl/clk_owl.h similarity index 87% rename from arch/arm/include/asm/arch-owl/clk_s900.h rename to drivers/clk/owl/clk_owl.h index 88e88f77f8..b8d33624c5 100644 --- a/arch/arm/include/asm/arch-owl/clk_s900.h +++ b/drivers/clk/owl/clk_owl.h @@ -1,17 +1,22 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Actions Semi S900 Clock Definitions + * Actions Semi SoCs Clock Definitions * * Copyright (C) 2015 Actions Semi Co., Ltd. * Copyright (C) 2018 Manivannan Sadhasivam * */ -#ifndef _OWL_CLK_S900_H_ -#define _OWL_CLK_S900_H_ +#ifndef _OWL_CLK_H_ +#define _OWL_CLK_H_ #include +enum owl_soc { + S700, + S900, +}; + struct owl_clk_priv { phys_addr_t base; }; @@ -49,9 +54,11 @@ struct owl_clk_priv { /* UARTCLK register definitions */ #define CMU_UARTCLK_SRC_DEVPLL BIT(16) -/* DEVCLKEN1 register definitions */ -#define CMU_DEVCLKEN1_UART5 BIT(21) - #define PLL_STABILITY_WAIT_US 50 +#define CMU_DEVCLKEN1_UART5 BIT(21) +#define CMU_DEVCLKEN1_UART3 BIT(11) + +#define CMU_DEVCLKEN1_ETH_S700 BIT(23) + #endif From 1050eaa0821e16d622f4a91295a751c4b37e9032 Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:31 +0530 Subject: [PATCH 24/33] arm: actions: add S700 SoC device tree This patch adds .dtsi file(sync with Linux 5.5-rc6 with hash "b3a987b0264d") and required binding for S700 SoC that is a 64-bit Quad-core ARM Cortex-A53 cores. It also provisions dts file to be built based on selected platform(CONFIG_MACH_S900/S700). Reviewed-by: Manivannan Sadhasivam Reviewed-by: Andre Przywara Signed-off-by: Amit Singh Tomar --- arch/arm/dts/Makefile | 2 + arch/arm/dts/s700.dtsi | 248 ++++++++++++++++++ include/dt-bindings/clock/actions,s700-cmu.h | 118 +++++++++ .../dt-bindings/reset/actions,s700-reset.h | 34 +++ 4 files changed, 402 insertions(+) create mode 100644 arch/arm/dts/s700.dtsi create mode 100644 include/dt-bindings/clock/actions,s700-cmu.h create mode 100644 include/dt-bindings/reset/actions,s700-reset.h diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index ba96efaa1e..af7d804b66 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -66,6 +66,8 @@ dtb-$(CONFIG_KIRKWOOD) += \ dtb-$(CONFIG_MACH_S900) += \ bubblegum_96.dtb +dtb-$(CONFIG_MACH_S700) += \ + s700-cubieboard7.dtb dtb-$(CONFIG_ROCKCHIP_PX30) += \ px30-evb.dtb \ diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi new file mode 100644 index 0000000000..2006ad5424 --- /dev/null +++ b/arch/arm/dts/s700.dtsi @@ -0,0 +1,248 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2017 Andreas Färber + */ + +#include +#include +#include + +/ { + compatible = "actions,s700"; + interrupt-parent = <&gic>; + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x0 0x0>; + enable-method = "psci"; + }; + + cpu1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x0 0x1>; + enable-method = "psci"; + }; + + cpu2: cpu@2 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x0 0x2>; + enable-method = "psci"; + }; + + cpu3: cpu@3 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x0 0x3>; + enable-method = "psci"; + }; + }; + + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + secmon@1f000000 { + reg = <0x0 0x1f000000 0x0 0x1000000>; + no-map; + }; + }; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + + arm-pmu { + compatible = "arm,cortex-a53-pmu"; + interrupts = , + , + , + ; + interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupts = , + , + , + ; + }; + + hosc: hosc { + compatible = "fixed-clock"; + clock-frequency = <24000000>; + #clock-cells = <0>; + }; + + losc: losc { + compatible = "fixed-clock"; + clock-frequency = <32768>; + #clock-cells = <0>; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + gic: interrupt-controller@e00f1000 { + compatible = "arm,gic-400"; + reg = <0x0 0xe00f1000 0x0 0x1000>, + <0x0 0xe00f2000 0x0 0x2000>, + <0x0 0xe00f4000 0x0 0x2000>, + <0x0 0xe00f6000 0x0 0x2000>; + interrupts = ; + interrupt-controller; + #interrupt-cells = <3>; + }; + + uart0: serial@e0120000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe0120000 0x0 0x2000>; + clocks = <&cmu CLK_UART0>; + interrupts = ; + status = "disabled"; + }; + + uart1: serial@e0122000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe0122000 0x0 0x2000>; + clocks = <&cmu CLK_UART1>; + interrupts = ; + status = "disabled"; + }; + + uart2: serial@e0124000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe0124000 0x0 0x2000>; + clocks = <&cmu CLK_UART2>; + interrupts = ; + status = "disabled"; + }; + + uart3: serial@e0126000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe0126000 0x0 0x2000>; + clocks = <&cmu CLK_UART3>; + interrupts = ; + status = "disabled"; + }; + + uart4: serial@e0128000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe0128000 0x0 0x2000>; + clocks = <&cmu CLK_UART4>; + interrupts = ; + status = "disabled"; + }; + + uart5: serial@e012a000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe012a000 0x0 0x2000>; + clocks = <&cmu CLK_UART5>; + interrupts = ; + status = "disabled"; + }; + + uart6: serial@e012c000 { + compatible = "actions,s900-uart", "actions,owl-uart"; + reg = <0x0 0xe012c000 0x0 0x2000>; + clocks = <&cmu CLK_UART6>; + interrupts = ; + status = "disabled"; + }; + + cmu: clock-controller@e0168000 { + compatible = "actions,s700-cmu"; + reg = <0x0 0xe0168000 0x0 0x1000>; + clocks = <&hosc>, <&losc>; + #clock-cells = <1>; + #reset-cells = <1>; + }; + + i2c0: i2c@e0170000 { + compatible = "actions,s700-i2c"; + reg = <0 0xe0170000 0 0x1000>; + clocks = <&cmu CLK_I2C0>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c1: i2c@e0174000 { + compatible = "actions,s700-i2c"; + reg = <0 0xe0174000 0 0x1000>; + clocks = <&cmu CLK_I2C1>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c2: i2c@e0178000 { + compatible = "actions,s700-i2c"; + reg = <0 0xe0178000 0 0x1000>; + clocks = <&cmu CLK_I2C2>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c3: i2c@e017c000 { + compatible = "actions,s700-i2c"; + reg = <0 0xe017c000 0 0x1000>; + clocks = <&cmu CLK_I2C3>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + sps: power-controller@e01b0100 { + compatible = "actions,s700-sps"; + reg = <0x0 0xe01b0100 0x0 0x100>; + #power-domain-cells = <1>; + }; + + timer: timer@e024c000 { + compatible = "actions,s700-timer"; + reg = <0x0 0xe024c000 0x0 0x4000>; + interrupts = ; + interrupt-names = "timer1"; + }; + + pinctrl: pinctrl@e01b0000 { + compatible = "actions,s700-pinctrl"; + reg = <0x0 0xe01b0000 0x0 0x1000>; + clocks = <&cmu CLK_GPIO>; + gpio-controller; + gpio-ranges = <&pinctrl 0 0 136>; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + interrupts = , + , + , + , + ; + }; + }; +}; diff --git a/include/dt-bindings/clock/actions,s700-cmu.h b/include/dt-bindings/clock/actions,s700-cmu.h new file mode 100644 index 0000000000..3e19429967 --- /dev/null +++ b/include/dt-bindings/clock/actions,s700-cmu.h @@ -0,0 +1,118 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * Device Tree binding constants for Actions Semi S700 Clock Management Unit + * + * Copyright (c) 2014 Actions Semi Inc. + * Author: David Liu + * + * Author: Pathiban Nallathambi + * Author: Saravanan Sekar + */ + +#ifndef __DT_BINDINGS_CLOCK_S700_H +#define __DT_BINDINGS_CLOCK_S700_H + +#define CLK_NONE 0 + +/* pll clocks */ +#define CLK_CORE_PLL 1 +#define CLK_DEV_PLL 2 +#define CLK_DDR_PLL 3 +#define CLK_NAND_PLL 4 +#define CLK_DISPLAY_PLL 5 +#define CLK_TVOUT_PLL 6 +#define CLK_CVBS_PLL 7 +#define CLK_AUDIO_PLL 8 +#define CLK_ETHERNET_PLL 9 + +/* system clock */ +#define CLK_CPU 10 +#define CLK_DEV 11 +#define CLK_AHB 12 +#define CLK_APB 13 +#define CLK_DMAC 14 +#define CLK_NOC0_CLK_MUX 15 +#define CLK_NOC1_CLK_MUX 16 +#define CLK_HP_CLK_MUX 17 +#define CLK_HP_CLK_DIV 18 +#define CLK_NOC1_CLK_DIV 19 +#define CLK_NOC0 20 +#define CLK_NOC1 21 +#define CLK_SENOR_SRC 22 + +/* peripheral device clock */ +#define CLK_GPIO 23 +#define CLK_TIMER 24 +#define CLK_DSI 25 +#define CLK_CSI 26 +#define CLK_SI 27 +#define CLK_DE 28 +#define CLK_HDE 29 +#define CLK_VDE 30 +#define CLK_VCE 31 +#define CLK_NAND 32 +#define CLK_SD0 33 +#define CLK_SD1 34 +#define CLK_SD2 35 + +#define CLK_UART0 36 +#define CLK_UART1 37 +#define CLK_UART2 38 +#define CLK_UART3 39 +#define CLK_UART4 40 +#define CLK_UART5 41 +#define CLK_UART6 42 + +#define CLK_PWM0 43 +#define CLK_PWM1 44 +#define CLK_PWM2 45 +#define CLK_PWM3 46 +#define CLK_PWM4 47 +#define CLK_PWM5 48 +#define CLK_GPU3D 49 + +#define CLK_I2C0 50 +#define CLK_I2C1 51 +#define CLK_I2C2 52 +#define CLK_I2C3 53 + +#define CLK_SPI0 54 +#define CLK_SPI1 55 +#define CLK_SPI2 56 +#define CLK_SPI3 57 + +#define CLK_USB3_480MPLL0 58 +#define CLK_USB3_480MPHY0 59 +#define CLK_USB3_5GPHY 60 +#define CLK_USB3_CCE 61 +#define CLK_USB3_MAC 62 + +#define CLK_LCD 63 +#define CLK_HDMI_AUDIO 64 +#define CLK_I2SRX 65 +#define CLK_I2STX 66 + +#define CLK_SENSOR0 67 +#define CLK_SENSOR1 68 + +#define CLK_HDMI_DEV 69 + +#define CLK_ETHERNET 70 +#define CLK_RMII_REF 71 + +#define CLK_USB2H0_PLLEN 72 +#define CLK_USB2H0_PHY 73 +#define CLK_USB2H0_CCE 74 +#define CLK_USB2H1_PLLEN 75 +#define CLK_USB2H1_PHY 76 +#define CLK_USB2H1_CCE 77 + +#define CLK_TVOUT 78 + +#define CLK_THERMAL_SENSOR 79 + +#define CLK_IRC_SWITCH 80 +#define CLK_PCM1 81 +#define CLK_NR_CLKS (CLK_PCM1 + 1) + +#endif /* __DT_BINDINGS_CLOCK_S700_H */ diff --git a/include/dt-bindings/reset/actions,s700-reset.h b/include/dt-bindings/reset/actions,s700-reset.h new file mode 100644 index 0000000000..5e3b16b8ef --- /dev/null +++ b/include/dt-bindings/reset/actions,s700-reset.h @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: (GPL-2.0-or-later OR MIT) +// +// Device Tree binding constants for Actions Semi S700 Reset Management Unit +// +// Copyright (c) 2018 Linaro Ltd. + +#ifndef __DT_BINDINGS_ACTIONS_S700_RESET_H +#define __DT_BINDINGS_ACTIONS_S700_RESET_H + +#define RESET_AUDIO 0 +#define RESET_CSI 1 +#define RESET_DE 2 +#define RESET_DSI 3 +#define RESET_GPIO 4 +#define RESET_I2C0 5 +#define RESET_I2C1 6 +#define RESET_I2C2 7 +#define RESET_I2C3 8 +#define RESET_KEY 9 +#define RESET_LCD0 10 +#define RESET_SI 11 +#define RESET_SPI0 12 +#define RESET_SPI1 13 +#define RESET_SPI2 14 +#define RESET_SPI3 15 +#define RESET_UART0 16 +#define RESET_UART1 17 +#define RESET_UART2 18 +#define RESET_UART3 19 +#define RESET_UART4 20 +#define RESET_UART5 21 +#define RESET_UART6 22 + +#endif /* __DT_BINDINGS_ACTIONS_S700_RESET_H */ From ea6314a797935fe3ca60b111035dcd25aaf85b71 Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:32 +0530 Subject: [PATCH 25/33] arm: dts: actions: s700: add u-boot specific dtsi file Devices like uart and clk are needed to be enabled before relocation. this patch adds u-boot.dtsi file that mark these device as dm-pre-reloc. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Andre Przywara Signed-off-by: Amit Singh Tomar --- arch/arm/dts/s700-u-boot.dtsi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 arch/arm/dts/s700-u-boot.dtsi diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi new file mode 100644 index 0000000000..a527cccc75 --- /dev/null +++ b/arch/arm/dts/s700-u-boot.dtsi @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 Amit Singh Tomar + */ + +/{ + soc { + u-boot,dm-pre-reloc; + }; +}; + +&uart3 { + u-boot,dm-pre-reloc; +}; + +&cmu { + u-boot,dm-pre-reloc; +}; From 78e4f4594de0c0ab873a038379d958f7fa669069 Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:33 +0530 Subject: [PATCH 26/33] arm: add support Actions Semi S700 This patch adds basic support for Actions Semi based S700 SoC, which is driven by common owl framework. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Andre Przywara Signed-off-by: Amit Singh Tomar --- arch/arm/mach-owl/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig index 28984c1b08..cde2ade30b 100644 --- a/arch/arm/mach-owl/Kconfig +++ b/arch/arm/mach-owl/Kconfig @@ -8,6 +8,10 @@ config MACH_S900 bool "Actions Semi S900 SoC" select ARM64 +config MACH_S700 + bool "Actions Semi S700 SoC" + select ARM64 + endchoice config SYS_TEXT_BASE @@ -18,5 +22,6 @@ config SYS_CONFIG_NAME config SYS_SOC default "s900" if MACH_S900 + default "s700" if MACH_S700 endif From d5c819b885c217f545f9d86bc7f18f6adc739e47 Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:34 +0530 Subject: [PATCH 27/33] actions: Move defconfig options to Kconfig This patch moves some of the config options from bubblegum_96_defconfig to respective Kconfig files. Signed-off-by: Amit Singh Tomar --- Kconfig | 2 +- arch/arm/Kconfig | 1 + configs/bubblegum_96_defconfig | 2 -- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Kconfig b/Kconfig index 83b5b05392..9a5e600753 100644 --- a/Kconfig +++ b/Kconfig @@ -111,7 +111,7 @@ config ENV_VARS_UBOOT_CONFIG config NR_DRAM_BANKS int "Number of DRAM banks" - default 1 if ARCH_SUNXI + default 1 if ARCH_SUNXI || ARCH_OWL default 4 help This defines the number of DRAM banks. diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2f831a9a2c..1bcf345028 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -880,6 +880,7 @@ config ARCH_OWL select CLK select CLK_OWL select OF_CONTROL + select CONFIG_SYS_RELOC_GD_ENV_ADDR imply CMD_DM config ARCH_QEMU diff --git a/configs/bubblegum_96_defconfig b/configs/bubblegum_96_defconfig index e76e9a2e5a..2228fafac6 100644 --- a/configs/bubblegum_96_defconfig +++ b/configs/bubblegum_96_defconfig @@ -1,7 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_OWL=y CONFIG_ENV_SIZE=0x2000 -CONFIG_NR_DRAM_BANKS=1 CONFIG_MACH_S900=y CONFIG_IDENT_STRING="\nBubblegum-96" CONFIG_DISTRO_DEFAULTS=y @@ -16,4 +15,3 @@ CONFIG_CMD_MEMINFO=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIMER=y CONFIG_DEFAULT_DEVICE_TREE="bubblegum_96" -CONFIG_SYS_RELOC_GD_ENV_ADDR=y From 99d5ac6f1550caf024853567501d8fdfddd10d83 Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:35 +0530 Subject: [PATCH 28/33] arm: add Cubieboard7 board support The Cubieboard is a single board computer containing a Actions S700 SoC(with 4 ARMv8 Cortex-A53 cores). This patch adds respective defconfig alongwith .dts(copied from Linux v5.5-rc6 with hash "b3a987b0264d"). Signed-off-by: Amit Singh Tomar --- arch/arm/dts/s700-cubieboard7.dts | 92 +++++++++++++++++++++++++++++++ configs/cubieboard7_defconfig | 12 ++++ 2 files changed, 104 insertions(+) create mode 100644 arch/arm/dts/s700-cubieboard7.dts create mode 100644 configs/cubieboard7_defconfig diff --git a/arch/arm/dts/s700-cubieboard7.dts b/arch/arm/dts/s700-cubieboard7.dts new file mode 100644 index 0000000000..63e375cd9e --- /dev/null +++ b/arch/arm/dts/s700-cubieboard7.dts @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2017 Andreas Färber + */ + +/dts-v1/; + +#include "s700.dtsi" + +/ { + compatible = "cubietech,cubieboard7", "actions,s700"; + model = "CubieBoard7"; + + aliases { + serial3 = &uart3; + }; + + chosen { + stdout-path = "serial3:115200n8"; + }; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x0 0x0 0x80000000>; + }; + + memory@1,e0000000 { + device_type = "memory"; + reg = <0x1 0xe0000000 0x0 0x0>; + }; +}; + +&i2c0 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_default>; +}; + +&i2c1 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_default>; +}; + +&i2c2 { + status = "disabled"; + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_default>; +}; + +&pinctrl { + i2c0_default: i2c0_default { + pinmux { + groups = "i2c0_mfp"; + function = "i2c0"; + }; + pinconf { + pins = "i2c0_sclk", "i2c0_sdata"; + bias-pull-up; + }; + }; + + i2c1_default: i2c1_default { + pinmux { + groups = "i2c1_dummy"; + function = "i2c1"; + }; + pinconf { + pins = "i2c1_sclk", "i2c1_sdata"; + bias-pull-up; + }; + }; + + i2c2_default: i2c2_default { + pinmux { + groups = "i2c2_dummy"; + function = "i2c2"; + }; + pinconf { + pins = "i2c2_sclk", "i2c2_sdata"; + bias-pull-up; + }; + }; +}; + +&timer { + clocks = <&hosc>; +}; + +&uart3 { + status = "okay"; +}; diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig new file mode 100644 index 0000000000..637dc9e9fb --- /dev/null +++ b/configs/cubieboard7_defconfig @@ -0,0 +1,12 @@ +CONFIG_ARM=y +CONFIG_ARCH_OWL=y +CONFIG_MACH_S700=y +CONFIG_IDENT_STRING="\ncubieboard7" +CONFIG_DISTRO_DEFAULTS=y +CONFIG_BOOTDELAY=5 +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyOWL3,115200n8" +# CONFIG_DISPLAY_CPUINFO is not set +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_SYS_PROMPT="U-Boot => " +CONFIG_DEFAULT_DEVICE_TREE="s700-cubieboard7" From 5f0ec25974ed7dbb71c31296dfbf28a52794b45c Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:36 +0530 Subject: [PATCH 29/33] doc: boards: add Cubieboard7 documentation This adds build and flash steps for Actions S700 based Cubieboard7 board. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Amit Singh Tomar --- doc/board/actions/cubieboard7.rst | 114 ++++++++++++++++++++++++++++++ doc/board/actions/index.rst | 10 +++ doc/board/index.rst | 1 + 3 files changed, 125 insertions(+) create mode 100644 doc/board/actions/cubieboard7.rst create mode 100644 doc/board/actions/index.rst diff --git a/doc/board/actions/cubieboard7.rst b/doc/board/actions/cubieboard7.rst new file mode 100644 index 0000000000..e01d2d0370 --- /dev/null +++ b/doc/board/actions/cubieboard7.rst @@ -0,0 +1,114 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. Copyright (C) 2020 Amit Singh Tomar + +CUBIEBOARD7 +=========== + +About this +---------- + +This document describes build and flash steps for Actions S700 SoC based Cubieboard7 +board. + +Cubieboard7 initial configuration +--------------------------------- + +Default Cubieboard7 comes with pre-installed Android where U-Boot is configured with +a bootdelay of 0, entering a prompt by pressing keys does not seem to work. + +Though, one can enter ADFU mode and flash debian image(from host machine) where +getting into u-boot prompt is easy. + +Enter ADFU Mode +---------------- + +Before write the firmware, let the development board entering the ADFU mode: insert +one end of the USB cable to the PC, press and hold the ADFU button, and then connect +the other end of the USB cable to the Mini USB port of the development board, release +the ADFU button, after connecting it will enter the ADFU mode. + +Check whether entered ADFU Mode +-------------------------------- + +The user needs to run the following command on the PC side to check if the ADFU +device is detected. ID realted to "Actions Semiconductor Co., Ltd" means that +the PC side has been correctly detected ADFU device, the development board +also enter into the ADFU mode. + +.. code-block:: none + + $ lsusb + Bus 001 Device 005: ID 04f2:b2eb Chicony Electronics Co., Ltd + Bus 001 Device 004: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 [ThinkPad] + Bus 001 Device 003: ID 046d:c534 Logitech, Inc. Unifying Receiver + Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub + Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub + Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub + Bus 003 Device 013: ID 10d6:10d6 Actions Semiconductor Co., Ltd + Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub + +Flashing debian image +--------------------- + +.. code-block:: none + + $ sudo ./ActionsFWU.py --fw=debian-stretch-desktop-cb7-emmc-v2.0.fw + ActionsFWU.py : 1.0.150828.0830 + libScript.so : 2.3.150825.0951 + libFileSystem.so: 2.3.150825.0952 + libProduction.so: 2.3.150915.1527 + =====burn all partition==== + FW_VER: 3.10.37.180608 + 3% DOWNLOAD ADFUDEC ... + 5% DOWNLOAD BOOT PARA ... + 7% SWITCH ADFUDEC ... + 12% DOWNLOAD BL31 ... + 13% DOWNLOAD BL32 ... + 15% DOWNLOAD VMLINUX ... + 20% DOWNLOAD INITRD ... + 24% DOWNLOAD FDT ... + 27% DOWNLOAD ADFUS ... + 30% SWITCH ADFUS ... + 32% DOWNLOAD MBR ... + 35% DOWNLOAD PARTITIONS ... + WRITE_MBRC_PARTITION + 35% write p0 size = 2048 : ok + WRITE_BOOT_PARTITION + 35% write p1 size = 2048 : ok + WRITE_MISC_PARTITION + 36% write p2 size = 98304 : ok + WRITE_SYSTEM_PARTITION + 94% write p3 size = 4608000 : ok + FORMAT_SWAP_PARTITION + 94% write p4 size = 20480 : ok + 95% TRANSFER OVER ... + Firmware upgrade successfully! + +Debian image can be downloaded from here[1]. + +Once debian image is flashed, one can get into u-boot prompt by pressing any key and from +there run ums command(make sure, usb cable is connected between host and target): + +.. code-block:: none + + owl> ums 0 mmc 1 + +Above command would mount debian image partition on host machine. + +Building U-BOOT proper image +---------------------------- + +.. code-block:: none + + $ make clean + $ export CROSS_COMPILE=aarch64-linux-gnu- + $ make ARCH=arm cubieboard7_defconfig + $ make u-boot-dtb.img -j16 + +u-boot-dtb.img can now be flashed to debian image partition mounted on host machine. + +.. code-block:: none + + $ sudo dd if=u-boot-dtb.img of=/dev/sdb bs=1024 seek=3072 + +[1]: https://pan.baidu.com/s/1uawPr0Jao2HgWFLZCLzHAg#list/path=%2FCubieBoard_Download%2FBoard%2FCubieBoard7%2F%E6%96%B9%E7%B3%96%E6%96%B9%E6%A1%88%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99%2FImage%2FDebian%2FV2.1-test&parentPath=%2F diff --git a/doc/board/actions/index.rst b/doc/board/actions/index.rst new file mode 100644 index 0000000000..c596879158 --- /dev/null +++ b/doc/board/actions/index.rst @@ -0,0 +1,10 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. Copyright (C) 2020 Amit Singh Tomar + +Actions +======== + +.. toctree:: + :maxdepth: 2 + + cubieboard7 diff --git a/doc/board/index.rst b/doc/board/index.rst index 51a2ae6f28..01b233f737 100644 --- a/doc/board/index.rst +++ b/doc/board/index.rst @@ -6,6 +6,7 @@ Board-specific doc .. toctree:: :maxdepth: 2 + actions/index AndesTech/index atmel/index coreboot/index From dd786d4c4c0869625e76b8cef32539473529ecd2 Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Sun, 19 Apr 2020 19:28:37 +0530 Subject: [PATCH 30/33] MAINTAINERS: add entry for cubieboard7 config This commit adds entry for cubieboard7 config under Actions Semi OWL family. Signed-off-by: Amit Singh Tomar --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 4504afc892..dd92af5182 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -276,6 +276,7 @@ F: drivers/clk/owl/ F: drivers/serial/serial_owl.c F: include/configs/owl-common.h F: configs/bubblegum_96_defconfig +F: configs/cubieboard7_defconfig ARM RENESAS RMOBILE/R-CAR M: Nobuhiro Iwamatsu From 077e72c6e6266a215cdbb8bfb07d791cb9c070ec Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 20 Apr 2020 12:44:01 +0200 Subject: [PATCH 31/33] spl: fit: do not check argument of free() The free() function checks if its argument is NULL. It is superfluous to do the same check on the calling side. Signed-off-by: Heinrich Schuchardt --- common/spl/spl_fit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 69dabd27f6..c51e4beb1c 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -425,8 +425,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, debug("%s: DT overlay %s applied\n", __func__, fit_get_name(fit, node, NULL)); } - if (tmpbuffer) - free(tmpbuffer); + free(tmpbuffer); if (ret) return ret; } From cffedec2e8f7f11fbe31f4706a222d279cf19c1d Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Mon, 20 Apr 2020 16:13:41 +0200 Subject: [PATCH 32/33] spi: mpc8xxx_spi: fix missing dev_err definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The build currently fails with drivers/spi/mpc8xxx_spi.c:64:3: warning: implicit declaration of function ‘dev_err’ [-Wimplicit-function-declaration] ... drivers/spi/built-in.o: In function `mpc8xxx_spi_set_speed': drivers/spi/mpc8xxx_spi.c:227: undefined reference to `dev_err' Fixes: 4856cc7a97 (mpc8xxx_spi: implement real ->set_speed) Fixes: 1a7b462dee (mpc8xxx_spi: put max_cs to use) Signed-off-by: Rasmus Villemoes --- drivers/spi/mpc8xxx_spi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index 1bde31ad34..e48debb045 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -12,6 +12,7 @@ #include #include #include +#include enum { SPI_EV_NE = BIT(31 - 22), /* Receiver Not Empty */ From 691132e850539cb0956a106933d5bde37470bfc7 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 20 Apr 2020 18:31:21 +0200 Subject: [PATCH 33/33] rtc: ds1374: typo Watchdog %s/Watchdoc/Watchdog/ Signed-off-by: Heinrich Schuchardt --- drivers/rtc/ds1374.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rtc/ds1374.c b/drivers/rtc/ds1374.c index 5a2060fe75..9f2647d707 100644 --- a/drivers/rtc/ds1374.c +++ b/drivers/rtc/ds1374.c @@ -58,7 +58,7 @@ #define RTC_CTL_BIT_RS2 (1<<2) /* Bit 2/2 - Rate Select square wave output */ #define RTC_CTL_BIT_WDSTR (1<<3) /* Bit 3 - Watchdog Reset Steering */ #define RTC_CTL_BIT_BBSQW (1<<4) /* Bit 4 - Battery-Backed Square-Wave */ -#define RTC_CTL_BIT_WD_ALM (1<<5) /* Bit 5 - Watchdoc/Alarm Counter Select */ +#define RTC_CTL_BIT_WD_ALM (1<<5) /* Bit 5 - Watchdog/Alarm Counter Select */ #define RTC_CTL_BIT_WACE (1<<6) /* Bit 6 - Watchdog/Alarm Counter Enable WACE*/ #define RTC_CTL_BIT_EN_OSC (1<<7) /* Bit 7 - Enable Oscilator */