| From c82d5e52563b9bbfefe0551d43e58c0dbf9a62f9 Mon Sep 17 00:00:00 2001 |
| From: Wanwei Jiang <wanwei.jiang@amlogic.com> |
| Date: Thu, 2 Feb 2023 15:49:10 +0800 |
| Subject: [PATCH] init: initialize the building framework of android-mainline |
| for amlogic [1/1] |
| |
| PD#SWPL-109858 |
| |
| Problem: |
| Initialize the building framework of android-mainline for amlogic |
| |
| Solution: |
| Initialize the building framework of android-mainline for amlogic |
| |
| Verify: |
| sc2 |
| |
| Change-Id: Icfbc29709af1545b802ed7794808a2ab560ed08a |
| Signed-off-by: Wanwei Jiang <wanwei.jiang@amlogic.com> |
| --- |
| .gitignore | 3 + |
| Kbuild | 3 + |
| Makefile | 22 ++++++ |
| drivers/Kconfig | 61 +++++++++++++++ |
| scripts/checkpatch.pl | 158 +++++++++++++++++++-------------------- |
| scripts/kconfig/Makefile | 9 ++- |
| 6 files changed, 176 insertions(+), 80 deletions(-) |
| |
| diff --git a/.gitignore b/.gitignore |
| index 0bbae167bf93..58177e21bd82 100644 |
| --- a/.gitignore |
| +++ b/.gitignore |
| @@ -170,3 +170,6 @@ sphinx_*/ |
| |
| # Rust analyzer configuration |
| /rust-project.json |
| + |
| +# amlogic drivers |
| +/common_drivers/ |
| diff --git a/Kbuild b/Kbuild |
| index 464b34a08f51..bd26c93f68ef 100644 |
| --- a/Kbuild |
| +++ b/Kbuild |
| @@ -97,3 +97,6 @@ obj-$(CONFIG_SAMPLES) += samples/ |
| obj-$(CONFIG_NET) += net/ |
| obj-y += virt/ |
| obj-y += $(ARCH_DRIVERS) |
| +obj-$(CONFIG_AMLOGIC_IN_KERNEL_MODULES) += $(COMMON_DRIVERS_DIR)/drivers/ |
| +obj-$(CONFIG_AMLOGIC_IN_KERNEL_MODULES) += $(COMMON_DRIVERS_DIR)/sound/ |
| +obj-$(CONFIG_AMLOGIC_IN_KERNEL_MODULES) += $(COMMON_DRIVERS_DIR)/samples/ |
| diff --git a/Makefile b/Makefile |
| index 7404c8549acd..beb8fece314f 100644 |
| --- a/Makefile |
| +++ b/Makefile |
| @@ -440,6 +440,14 @@ ifneq ($(SRCARCH),$(SUBARCH)) |
| cross_compiling := 1 |
| endif |
| |
| +# ifdef CONFIG_AMLOGIC_DRIVER |
| +# config cannot be used here to mark AMLOGIC modifications |
| +# If these three variables are not set externally, set their default values |
| +export COMMON_DRIVERS_DIR ?= common_drivers |
| +dtstree ?= $(COMMON_DRIVERS_DIR)/arch/$(SRCARCH)/boot/dts/amlogic |
| +export DTC_INCLUDE ?= $(srctree)/$(COMMON_DRIVERS_DIR)/include |
| +# endif |
| + |
| KCONFIG_CONFIG ?= .config |
| export KCONFIG_CONFIG |
| |
| @@ -836,6 +844,17 @@ endif # need-config |
| |
| KBUILD_CFLAGS += -fno-delete-null-pointer-checks |
| |
| +ifdef CONFIG_AMLOGIC_DRIVER |
| +USERINCLUDE += \ |
| + -I$(srctree)/$(COMMON_DRIVERS_DIR)/include \ |
| + -I$(srctree)/$(COMMON_DRIVERS_DIR)/include/uapi |
| + |
| +LINUXINCLUDE += \ |
| + -I$(srctree)/$(COMMON_DRIVERS_DIR)/include \ |
| + -I$(srctree)/$(COMMON_DRIVERS_DIR)/include/uapi |
| +KBUILD_CFLAGS += -Werror |
| +endif |
| + |
| ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE |
| KBUILD_CFLAGS += -O2 |
| KBUILD_RUSTFLAGS += -Copt-level=2 |
| @@ -1160,6 +1179,9 @@ ifeq ($(KBUILD_EXTMOD),) |
| endif |
| $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)include/uapi |
| $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)arch/$(SRCARCH)/include/uapi |
| +ifdef CONFIG_AMLOGIC_DRIVER |
| + $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)$(COMMON_DRIVERS_DIR)/include/uapi |
| +endif |
| |
| ifeq ($(KBUILD_EXTMOD),) |
| |
| diff --git a/drivers/Kconfig b/drivers/Kconfig |
| index efb66e25fa2d..cb21f498edc8 100644 |
| --- a/drivers/Kconfig |
| +++ b/drivers/Kconfig |
| @@ -243,4 +243,65 @@ source "drivers/hte/Kconfig" |
| |
| source "drivers/cdx/Kconfig" |
| |
| +config AMLOGIC_DRIVER |
| + bool "Amlogic Peripheral drivers" |
| + default n |
| + help |
| + this option is provided for control amlogic |
| + drivers, if you want to use amlogic driver |
| + please open it. |
| + Note: All amlogic driver should be placed in |
| + directory $(COMMON_DRIVERS_DIR)/drivers/ |
| + |
| +if AMLOGIC_DRIVER |
| +config AMLOGIC_BREAK_GKI_20 |
| + bool "Amlogic Break GKI 2.0" |
| + default n |
| + help |
| + this option is provide for control Break GKI 2.0, |
| + if you want to break gki2.0 rule, should enable it, |
| + all break gki2.0 modify should be depends on this option |
| + |
| +config AMLOGIC_BREAK_GKI |
| + bool "Amlogic Break GKI" |
| + select AMLOGIC_BREAK_GKI_20 |
| + default n |
| + help |
| + this option is provide for control Break GKI, |
| + if you want to debug driver temporarily, should enable it, |
| + export function or variable with this config, |
| + and the driver Kconfig depends on this option |
| + |
| +config AMLOGIC_MODIFY |
| + bool "Amlogic modify for kernel code" |
| + default n |
| + help |
| + This option is set up for AMLOGIC modify of standard |
| + kernel source code. All modify of kernel standard code |
| + should be wrapped by this config |
| + |
| +config AMLOGIC_IN_KERNEL_MODULES |
| + bool "Amlogic Drivers in build or extra build" |
| + default n |
| + help |
| + this option is provided for control amlogic |
| + drivers in build or extra build, if you want |
| + to in build, should enable; if want to extra |
| + build, should disable |
| + |
| +config AMLOGIC_KERNEL_VERSION |
| + int "Amlogic Kernel Version" |
| + default 15606 |
| + help |
| + kernel from android15-6.6 |
| + so the default value is 15606 |
| + the driver uses it to adapt different kernel versions |
| + |
| +if AMLOGIC_IN_KERNEL_MODULES |
| +source "$(COMMON_DRIVERS_DIR)/drivers/Kconfig" |
| +source "$(COMMON_DRIVERS_DIR)/sound/Kconfig" |
| +source "$(COMMON_DRIVERS_DIR)/samples/Kconfig" |
| +endif |
| +endif |
| + |
| endmenu |
| diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl |
| index 7d16f863edf1..21fa16d0363c 100755 |
| --- a/scripts/checkpatch.pl |
| +++ b/scripts/checkpatch.pl |
| @@ -59,7 +59,7 @@ my $configuration_file = ".checkpatch.conf"; |
| my $max_line_length = 100; |
| my $ignore_perl_version = 0; |
| my $minimum_perl_version = 5.10.0; |
| -my $min_conf_desc_length = 4; |
| +my $min_conf_desc_length = 2; |
| my $spelling_file = "$D/spelling.txt"; |
| my $codespell = 0; |
| my $codespellfile = "/usr/share/codespell/dictionary.txt"; |
| @@ -457,8 +457,8 @@ if ($tree) { |
| } |
| |
| if (!defined $root) { |
| - print "Must be run from the top-level dir. of a kernel tree\n"; |
| - exit(2); |
| + # print "Must be run from the top-level dir. of a kernel tree\n"; |
| + # exit(2); |
| } |
| } |
| |
| @@ -1147,7 +1147,7 @@ sub is_maintained_obsolete { |
| sub is_SPDX_License_valid { |
| my ($license) = @_; |
| |
| - return 1 if (!$tree || which("python3") eq "" || !(-x "$root/scripts/spdxcheck.py") || !(-e "$gitroot")); |
| + return 1 if (!$tree || which("python3") eq "" || !(-x "scripts/spdxcheck.py") || !(-e "$gitroot")); |
| |
| my $root_path = abs_path($root); |
| my $status = `cd "$root_path"; echo "$license" | scripts/spdxcheck.py -`; |
| @@ -2860,7 +2860,7 @@ sub process { |
| |
| $p1_prefix = $1; |
| if (!$file && $tree && $p1_prefix ne '' && |
| - -e "$root/$p1_prefix") { |
| + -e "$p1_prefix") { |
| WARN("PATCH_PREFIX", |
| "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n"); |
| } |
| @@ -2884,10 +2884,10 @@ sub process { |
| } |
| |
| if ($found_file) { |
| - if (is_maintained_obsolete($realfile)) { |
| - WARN("OBSOLETE", |
| - "$realfile is marked as 'obsolete' in the MAINTAINERS hierarchy. No unnecessary modifications please.\n"); |
| - } |
| + # if (is_maintained_obsolete($realfile)) { |
| + # WARN("OBSOLETE", |
| + # "$realfile is marked as 'obsolete' in the MAINTAINERS hierarchy. No unnecessary modifications please.\n"); |
| + # } |
| if ($realfile =~ m@^(?:drivers/net/|net/|drivers/staging/)@) { |
| $check = 1; |
| } else { |
| @@ -2902,8 +2902,8 @@ sub process { |
| |
| if (($last_binding_patch != -1) && |
| ($last_binding_patch ^ $is_binding_patch)) { |
| - WARN("DT_SPLIT_BINDING_PATCH", |
| - "DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.rst\n"); |
| + # WARN("DT_SPLIT_BINDING_PATCH", |
| + # "DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.rst\n"); |
| } |
| } |
| |
| @@ -2925,9 +2925,9 @@ sub process { |
| $commit_log_lines++; #could be a $signature |
| } |
| } elsif ($has_commit_log && $commit_log_lines < 2) { |
| - WARN("COMMIT_MESSAGE", |
| - "Missing commit description - Add an appropriate one\n"); |
| - $commit_log_lines = 2; #warn only once |
| + # WARN("COMMIT_MESSAGE", |
| + # "Missing commit description - Add an appropriate one\n"); |
| + # $commit_log_lines = 2; #warn only once |
| } |
| |
| # Check if the commit log has what seems like a diff which can confuse patch |
| @@ -3065,8 +3065,8 @@ sub process { |
| my ($email_name, $name_comment, $email_address, $comment) = parse_email($email); |
| my $suggested_email = format_email(($email_name, $name_comment, $email_address, $comment)); |
| if ($suggested_email eq "") { |
| - ERROR("BAD_SIGN_OFF", |
| - "Unrecognized email address: '$email'\n" . $herecurr); |
| + # ERROR("BAD_SIGN_OFF", |
| + # "Unrecognized email address: '$email'\n" . $herecurr); |
| } else { |
| my $dequoted = $suggested_email; |
| $dequoted =~ s/^"//; |
| @@ -3242,11 +3242,11 @@ sub process { |
| |
| # Check for Gerrit Change-Ids not in any patch context |
| if ($realfile eq '' && !$has_patch_separator && $line =~ /^\s*change-id:/i) { |
| - if (ERROR("GERRIT_CHANGE_ID", |
| - "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr) && |
| - $fix) { |
| - fix_delete_line($fixlinenr, $rawline); |
| - } |
| + # if (ERROR("GERRIT_CHANGE_ID", |
| + # "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr) && |
| + # $fix) { |
| + # fix_delete_line($fixlinenr, $rawline); |
| + # } |
| } |
| |
| # Check if the commit log is in a possible stack dump |
| @@ -3397,16 +3397,16 @@ sub process { |
| } |
| |
| # Check for added, moved or deleted files |
| - if (!$reported_maintainer_file && !$in_commit_log && |
| - ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ || |
| - $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || |
| - ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && |
| - (defined($1) || defined($2))))) { |
| - $is_patch = 1; |
| - $reported_maintainer_file = 1; |
| - WARN("FILE_PATH_CHANGES", |
| - "added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr); |
| - } |
| + # if (!$reported_maintainer_file && !$in_commit_log && |
| + # ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ || |
| + # $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || |
| + # ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && |
| + # (defined($1) || defined($2))))) { |
| + # $is_patch = 1; |
| + # $reported_maintainer_file = 1; |
| + # WARN("FILE_PATH_CHANGES", |
| + # "added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr); |
| + # } |
| |
| # Check for adding new DT bindings not in schema format |
| if (!$in_commit_log && |
| @@ -3640,8 +3640,8 @@ sub process { |
| if ($needs_help && |
| $help_length < $min_conf_desc_length) { |
| my $stat_real = get_stat_real($linenr, $ln - 1); |
| - WARN("CONFIG_DESCRIPTION", |
| - "please write a help paragraph that fully describes the config symbol\n" . "$here\n$stat_real\n"); |
| + #WARN("CONFIG_DESCRIPTION", |
| + # "please write a help paragraph that fully describes the config symbol\n" . "$here\n$stat_real\n"); |
| } |
| } |
| |
| @@ -3716,8 +3716,8 @@ sub process { |
| $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/; |
| `grep -Erq "$compat|$compat2|$compat3" $dt_path`; |
| if ( $? >> 8 ) { |
| - WARN("UNDOCUMENTED_DT_STRING", |
| - "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr); |
| + # WARN("UNDOCUMENTED_DT_STRING", |
| + # "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr); |
| } |
| |
| next if $compat !~ /^([a-zA-Z0-9\-]+)\,/; |
| @@ -3760,10 +3760,10 @@ sub process { |
| "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr); |
| } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) { |
| my $spdx_license = $1; |
| - if (!is_SPDX_License_valid($spdx_license)) { |
| - WARN("SPDX_LICENSE_TAG", |
| - "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr); |
| - } |
| + #if (!is_SPDX_License_valid($spdx_license)) { |
| + # WARN("SPDX_LICENSE_TAG", |
| + # "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr); |
| + #} |
| if ($realfile =~ m@^Documentation/devicetree/bindings/@ && |
| $spdx_license !~ /GPL-2\.0(?:-only)? OR BSD-2-Clause/) { |
| my $msg_level = \&WARN; |
| @@ -3786,8 +3786,8 @@ sub process { |
| |
| # check for embedded filenames |
| if ($rawline =~ /^\+.*\b\Q$realfile\E\b/) { |
| - WARN("EMBEDDED_FILENAME", |
| - "It's generally not useful to have the filename in the file\n" . $herecurr); |
| + #WARN("EMBEDDED_FILENAME", |
| + # "It's generally not useful to have the filename in the file\n" . $herecurr); |
| } |
| |
| # check we are in a valid source file if not then ignore this hunk |
| @@ -3950,34 +3950,34 @@ sub process { |
| } |
| |
| # check multi-line statement indentation matches previous line |
| - if ($perl_version_ok && |
| - $prevline =~ /^\+([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|(?:\*\s*)*$Lval\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) { |
| - $prevline =~ /^\+(\t*)(.*)$/; |
| - my $oldindent = $1; |
| - my $rest = $2; |
| - |
| - my $pos = pos_last_openparen($rest); |
| - if ($pos >= 0) { |
| - $line =~ /^(\+| )([ \t]*)/; |
| - my $newindent = $2; |
| - |
| - my $goodtabindent = $oldindent . |
| - "\t" x ($pos / $tabsize) . |
| - " " x ($pos % $tabsize); |
| - my $goodspaceindent = $oldindent . " " x $pos; |
| - |
| - if ($newindent ne $goodtabindent && |
| - $newindent ne $goodspaceindent) { |
| - |
| - if (CHK("PARENTHESIS_ALIGNMENT", |
| - "Alignment should match open parenthesis\n" . $hereprev) && |
| - $fix && $line =~ /^\+/) { |
| - $fixed[$fixlinenr] =~ |
| - s/^\+[ \t]*/\+$goodtabindent/; |
| - } |
| - } |
| - } |
| - } |
| + # if ($perl_version_ok && |
| + # $prevline =~ /^\+([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|(?:\*\s*)*$Lval\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) { |
| + # $prevline =~ /^\+(\t*)(.*)$/; |
| + # my $oldindent = $1; |
| + # my $rest = $2; |
| + |
| + # my $pos = pos_last_openparen($rest); |
| + # if ($pos >= 0) { |
| + # $line =~ /^(\+| )([ \t]*)/; |
| + # my $newindent = $2; |
| + |
| + # my $goodtabindent = $oldindent . |
| + # "\t" x ($pos / $tabsize) . |
| + # " " x ($pos % $tabsize); |
| + # my $goodspaceindent = $oldindent . " " x $pos; |
| + |
| + # if ($newindent ne $goodtabindent && |
| + # $newindent ne $goodspaceindent) { |
| + |
| + # if (CHK("PARENTHESIS_ALIGNMENT", |
| + # "Alignment should match open parenthesis\n" . $hereprev) && |
| + # $fix && $line =~ /^\+/) { |
| + # $fixed[$fixlinenr] =~ |
| + # s/^\+[ \t]*/\+$goodtabindent/; |
| + # } |
| + # } |
| + # } |
| + # } |
| |
| # check for space after cast like "(int) foo" or "(struct foo) bar" |
| # avoid checking a few false positives: |
| @@ -6919,8 +6919,8 @@ sub process { |
| if (!defined($stat_real)) { |
| $stat_real = get_stat_real($linenr, $lc); |
| } |
| - WARN("VSPRINTF_SPECIFIER_PX", |
| - "Using vsprintf specifier '\%px' potentially exposes the kernel memory layout, if you don't really need the address please consider using '\%p'.\n" . "$here\n$stat_real\n"); |
| + # WARN("VSPRINTF_SPECIFIER_PX", |
| + # "Using vsprintf specifier '\%px' potentially exposes the kernel memory layout, if you don't really need the address please consider using '\%p'.\n" . "$here\n$stat_real\n"); |
| } |
| } |
| if ($bad_specifier ne "") { |
| @@ -7184,14 +7184,14 @@ sub process { |
| } |
| |
| # checks for new __setup's |
| - if ($rawline =~ /\b__setup\("([^"]*)"/) { |
| - my $name = $1; |
| - |
| - if (!grep(/$name/, @setup_docs)) { |
| - CHK("UNDOCUMENTED_SETUP", |
| - "__setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.txt\n" . $herecurr); |
| - } |
| - } |
| + # if ($rawline =~ /\b__setup\("([^"]*)"/) { |
| + # my $name = $1; |
| + |
| + # if (!grep(/$name/, @setup_docs)) { |
| + # CHK("UNDOCUMENTED_SETUP", |
| + # "__setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.txt\n" . $herecurr); |
| + # } |
| + # } |
| |
| # check for pointless casting of alloc functions |
| if ($line =~ /\*\s*\)\s*$allocFunctions\b/) { |
| diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile |
| index 4eee155121a8..063f9efe9b04 100644 |
| --- a/scripts/kconfig/Makefile |
| +++ b/scripts/kconfig/Makefile |
| @@ -91,7 +91,14 @@ else |
| endif |
| |
| %_defconfig: $(obj)/conf |
| - $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) |
| +# config cannot be used here to mark AMLOGIC modifications |
| +# support two config directory, arch/$(SRCARCH)/configs/ and $(COMMON_DRIVERS_DIR)/arch/$(SRCARCH)/configs/ |
| + $(if $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$@), \ |
| + $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig), \ |
| + $(Q)$< $(silent) --defconfig=$(COMMON_DRIVERS_DIR)/arch/$(SRCARCH)/configs/$@ $(Kconfig)) |
| +# else |
| +# $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) |
| +# endif |
| |
| configfiles = $(wildcard $(srctree)/kernel/configs/$(1) $(srctree)/arch/$(SRCARCH)/configs/$(1)) |
| all-config-fragments = $(call configfiles,*.config) |
| -- |
| 2.42.0 |
| |