From f525b5edb1cb8cf255c08121a5eea46e551340ff Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Sat, 1 Jul 2017 01:41:01 +0200 Subject: [PATCH] Import T713XXU2BQD3 kernel source changes Change-Id: I9897a6d702844ebd56458d82d5b7be87ab5a907b --- .../msm8976-sec-gts210velte-can-battery.dtsi | 49 ++- ...m8976-sec-gts210velte-eur-battery-r04.dtsi | 53 ++- .../msm8976-sec-gts210velte-eur-battery.dtsi | 2 +- .../msm8976-sec-gts210velte-tmo-battery.dtsi | 49 ++- .../msm8976-sec-gts210velte-vzw-battery.dtsi | 52 ++- ...8976-sec-gts210vewifi-eur-battery-r04.dtsi | 50 ++- ...sm8976-sec-gts28velte-eur-battery-r04.dtsi | 34 +- ...m8976-sec-gts28vewifi-eur-battery-r04.dtsi | 34 +- ...m8976-sec-gts28vewifi-eur-battery-r05.dtsi | 34 +- .../msm8976_sec_gts28vewifi_eur_defconfig | 1 + build_msm8952_kernel.sh | 317 +++++++++++++++++ build_msm8976_kernel.sh | 328 ++++++++++++++++++ .../HIF/sdio/linux/native_sdio/src/hif.c | 2 + drivers/sensorhub/stm/adpd142.c | 2 +- drivers/sensorhub/stm/adpd143.c | 2 +- .../msm/mdss/samsung/ss_dsi_panel_common.c | 22 +- fs/sdfat/api.h | 19 +- fs/sdfat/core.c | 260 +++++++++----- fs/sdfat/core_exfat.c | 163 +++++---- fs/sdfat/core_fat.c | 104 +++--- fs/sdfat/fatent.c | 7 + fs/sdfat/sdfat.c | 74 ++-- fs/sdfat/sdfat_fs.h | 2 +- fs/sdfat/version.h | 2 +- .../battery/fuelgauge/sm5703_fuelgauge.h | 14 + net/wireless/db.txt | 16 +- 26 files changed, 1303 insertions(+), 389 deletions(-) create mode 100644 build_msm8952_kernel.sh create mode 100644 build_msm8976_kernel.sh diff --git a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-can-battery.dtsi b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-can-battery.dtsi index ebe41def7824..08116865e6b2 100644 --- a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-can-battery.dtsi +++ b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-can-battery.dtsi @@ -86,12 +86,12 @@ SEC_BATTERY_FULL_CONDITION_VCELL */ battery,full_condition_type = <13>; battery,full_condition_soc = <93>; - battery,full_condition_vcell = <4300>; + battery,full_condition_vcell = <4250>; battery,recharge_check_count = <1>; battery,recharge_condition_type = <4>; /* SEC_BATTERY_RECHARGE_CONDITION_VCELL */ battery,recharge_condition_soc = <98>; - battery,recharge_condition_vcell = <4340>; + battery,recharge_condition_vcell = <4300>; battery,charging_total_time = <36000>; battery,recharging_total_time = <5400>; @@ -103,11 +103,11 @@ battery,swelling_low_temp_recov = <150>; //battery,swelling_chg_current = <1500>; battery,swelling_high_chg_current = <2100>; - battery,swelling_low_chg_current = <1500>; + battery,swelling_low_chg_current = <2100>; battery,swelling_full_check_current_2nd = <300>; - battery,swelling_drop_float_voltage = <4200>; - battery,swelling_high_rechg_voltage = <4150>; - battery,swelling_low_rechg_voltage = <4050>; + battery,swelling_drop_float_voltage = <4150>; + battery,swelling_high_rechg_voltage = <4000>; + battery,swelling_low_rechg_voltage = <4000>; battery,self_discharging_temp_block = <600>; battery,self_discharging_volt_block = <4250>; @@ -116,12 +116,21 @@ qcom,sec-battery-vadc = <&pm8950_vadc>; + /* cycle, chg_float_voltage, recharge_condition_vcell, full_condition_vcell, full_condition_soc */ + battery,age_data = < + 0 4350 4300 4250 93 + 200 4330 4280 4230 92 + 250 4310 4260 4210 91 + 300 4290 4240 4190 90 + 1000 4240 4190 4140 89 + >; + charger { status = "disable"; /* Charger */ battery,charger_name = "sm5703-charger"; battery,chg_gpio_en = <&msm_gpio 132 0x00>; - battery,chg_float_voltage = <4390>; + battery,chg_float_voltage = <4350>; battery,chg_polarity_en = <0>; battery,chg_gpio_status = <0>; @@ -152,11 +161,12 @@ }; battery_params { + /*SDI Battery data*/ battery,id = <(-1)>; /* -1 means auto, detected by F/G */ - battery0,battery_type = <4400>; /* 4200 4350 4400 */ - battery0,battery_table0 = <0x1400 0x1B47 0x1BAD 0x1C95 0x1D75 0x1D8C 0x1DF1 0x1E32 0x1EC9 0x1F34 0x1FA6 0x1FD9 0x2072 0x20F3 0x22C4 0x2399>; /*SDI Battery data*/ - battery0,battery_table1 = <0x1400 0x1B47 0x1BAD 0x1C95 0x1D75 0x1D8C 0x1DF1 0x1E32 0x1EC9 0x1F34 0x1FA6 0x1FD9 0x2072 0x20F3 0x22C4 0x2399>; /*SDI Battery data*/ - battery0,battery_table2 = <0x0 0x3C 0x91 0x114 0x24d 0x380 0x70B 0xBBD 0x177A 0x1B00 0x1D59 0x1FB2 0x220B 0x2591 0x2EF5 0x2F19>; /*SDI Battery data*/ + battery0,battery_type = <4350>; /* 4200 4350 4400 */ + battery0,battery_table0 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery0,battery_table1 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery0,battery_table2 = <0x0 0x48 0x1B0 0x2A1 0x5AE 0x934 0xF13 0x14F1 0x19A3 0x1D29 0x1F82 0x21DB 0x2434 0x27BA 0x2CE4 0x2CFB>; battery0,temp_std = <25>; battery0,temp_offset = <10>; battery0,temp_offset_cal = <0x01>; @@ -173,12 +183,15 @@ battery0,curr_cal = <0x7C85>; battery0,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery0,v_alarm = <3200>; - battery0,data_ver = <0x01>; + battery0,v_max_table = <0x2268 0x2241 0x221A 0x21F3 0x2191>; + battery0,q_max_table = <0x2CE4 0x2C20 0x2B5B 0x2A96 0x28AA>; + battery0,data_ver = <0x02>; - battery1,battery_type = <4400>; /* 4200 4350 4400 */ - battery1,battery_table0 = <0x1400 0x1B33 0x1C5F 0x1D61 0x1D83 0x1DF4 0x1E9C 0x1F06 0x1F68 0x1FFA 0x1FFA 0x2131 0x2169 0x2251 0x22C3 0x2399>; /*ATL Battery data*/ - battery1,battery_table1 = <0x1400 0x1B33 0x1C5F 0x1D61 0x1D83 0x1DF4 0x1E9C 0x1F06 0x1F68 0x1FFA 0x1FFA 0x2131 0x2169 0x2251 0x22C3 0x2399>; /*ATL Battery data*/ - battery1,battery_table2 = <0x0 0x6C 0x108 0x2A1 0x4EE 0xA9C 0x15FA 0x195B 0x1BA8 0x1F0A 0x1F0A 0x25D9 0x2826 0x2CB4 0x2EF5 0x2F19>; /*ATL Battery data*/ + /*ATL Battery data*/ + battery1,battery_type = <4350>; /* 4200 4350 4400 */ + battery1,battery_table0 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery1,battery_table1 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery1,battery_table2 = <0x0 0x48 0x1B0 0x2A1 0x5AE 0x934 0xF13 0x14F1 0x19A3 0x1D29 0x1F82 0x21DB 0x2434 0x27BA 0x2CE4 0x2CFB>; battery1,temp_std = <25>; battery1,temp_offset = <10>; battery1,temp_offset_cal = <0x01>; @@ -195,6 +208,8 @@ battery1,curr_cal = <0x7D85>; battery1,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery1,v_alarm = <3200>; - battery1,data_ver = <0x01>; + battery1,v_max_table = <0x2268 0x2241 0x221A 0x21F3 0x2191>; + battery1,q_max_table = <0x2CE4 0x2C20 0x2B5B 0x2A96 0x28AA>; + battery1,data_ver = <0x02>; }; }; diff --git a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-eur-battery-r04.dtsi b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-eur-battery-r04.dtsi index 8b4821f9a1d3..4c51955e8868 100644 --- a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-eur-battery-r04.dtsi +++ b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-eur-battery-r04.dtsi @@ -24,14 +24,14 @@ battery,polling_time = <10 30 30 30 3600>; - battery,temp_table_adc = <27304 27367 27429 27491 27554 27616 27703 27790 27877 27964 28051 28138 28225 28312 28399 28486 28584 28681 28779 28877 + battery,temp_table_adc = <26930 27304 27367 27429 27491 27554 27616 27703 27790 27877 27964 28051 28138 28225 28312 28399 28486 28584 28681 28779 28877 28974 29073 29173 29272 29371 29470 29532 29594 29718 29842 29965 30089 30219 30349 30544 30739 30816 30893 30970 31047 31123 31330 31536 31743 31949 32155 32311 32466 32621 32777 32932 33094 33257 33419 33581 33743 33941 34139 34337 34535 34733 34907 35081 35255 35429 35603 35780 35956 36133 36309 36486 36651 36816 36981 37146 37311 37479 37647 37815 37983 38151 38295 38439 38583 38727 38871 39013 39156 39298 39441 39583 39713 39842 39972 40101 40230 40332 40433 40535 40636 40738>; - battery,temp_table_data = <800 790 780 770 760 750 740 730 720 710 700 690 680 670 660 650 640 630 620 610 + battery,temp_table_data = <850 800 790 780 770 760 750 740 730 720 710 700 690 680 670 660 650 640 630 620 610 600 590 580 570 560 550 540 530 520 510 500 490 480 470 460 450 440 430 420 410 400 390 380 370 360 350 340 330 320 310 300 290 280 270 260 250 240 230 220 210 200 190 180 170 160 150 140 130 120 110 100 90 80 70 60 50 40 30 20 10 @@ -86,12 +86,12 @@ SEC_BATTERY_FULL_CONDITION_VCELL */ battery,full_condition_type = <13>; battery,full_condition_soc = <93>; - battery,full_condition_vcell = <4300>; + battery,full_condition_vcell = <4250>; battery,recharge_check_count = <1>; battery,recharge_condition_type = <4>; /* SEC_BATTERY_RECHARGE_CONDITION_VCELL */ battery,recharge_condition_soc = <98>; - battery,recharge_condition_vcell = <4340>; + battery,recharge_condition_vcell = <4300>; battery,charging_total_time = <36000>; battery,recharging_total_time = <5400>; @@ -103,11 +103,11 @@ battery,swelling_low_temp_recov = <150>; //battery,swelling_chg_current = <1500>; battery,swelling_high_chg_current = <2100>; - battery,swelling_low_chg_current = <1500>; + battery,swelling_low_chg_current = <2100>; battery,swelling_full_check_current_2nd = <300>; - battery,swelling_drop_float_voltage = <4200>; - battery,swelling_high_rechg_voltage = <4150>; - battery,swelling_low_rechg_voltage = <4050>; + battery,swelling_drop_float_voltage = <4150>; + battery,swelling_high_rechg_voltage = <4000>; + battery,swelling_low_rechg_voltage = <4000>; battery,self_discharging_temp_block = <600>; battery,self_discharging_volt_block = <4250>; @@ -116,12 +116,21 @@ qcom,sec-battery-vadc = <&pm8950_vadc>; + /* cycle, chg_float_voltage, recharge_condition_vcell, full_condition_vcell, full_condition_soc */ + battery,age_data = < + 0 4350 4300 4250 93 + 200 4330 4280 4230 92 + 250 4310 4260 4210 91 + 300 4290 4240 4190 90 + 1000 4240 4190 4140 89 + >; + charger { status = "disable"; /* Charger */ battery,charger_name = "sm5703-charger"; battery,chg_gpio_en = <&msm_gpio 132 0x00>; - battery,chg_float_voltage = <4390>; + battery,chg_float_voltage = <4350>; battery,chg_polarity_en = <0>; battery,chg_gpio_status = <0>; @@ -152,11 +161,12 @@ }; battery_params { + /*SDI Battery data*/ battery,id = <(-1)>; /* -1 means auto, detected by F/G */ - battery0,battery_type = <4400>; /* 4200 4350 4400 */ - battery0,battery_table0 = <0x1400 0x1B47 0x1BAD 0x1C95 0x1D75 0x1D8C 0x1DF1 0x1E32 0x1EC9 0x1F34 0x1FA6 0x1FD9 0x2072 0x20F3 0x22C4 0x2399>; /*SDI Battery data*/ - battery0,battery_table1 = <0x1400 0x1B47 0x1BAD 0x1C95 0x1D75 0x1D8C 0x1DF1 0x1E32 0x1EC9 0x1F34 0x1FA6 0x1FD9 0x2072 0x20F3 0x22C4 0x2399>; /*SDI Battery data*/ - battery0,battery_table2 = <0x0 0x3C 0x91 0x114 0x24d 0x380 0x70B 0xBBD 0x177A 0x1B00 0x1D59 0x1FB2 0x220B 0x2591 0x2EF5 0x2F19>; /*SDI Battery data*/ + battery0,battery_type = <4350>; /* 4200 4350 4400 */ + battery0,battery_table0 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery0,battery_table1 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery0,battery_table2 = <0x0 0x48 0x1B0 0x2A1 0x5AE 0x934 0xF13 0x14F1 0x19A3 0x1D29 0x1F82 0x21DB 0x2434 0x27BA 0x2CE4 0x2CFB>; battery0,temp_std = <25>; battery0,temp_offset = <10>; battery0,temp_offset_cal = <0x01>; @@ -173,12 +183,15 @@ battery0,curr_cal = <0x7C85>; battery0,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery0,v_alarm = <3200>; - battery0,data_ver = <0x01>; + battery0,v_max_table = <0x2268 0x2241 0x221A 0x21F3 0x2191>; + battery0,q_max_table = <0x2CE4 0x2C20 0x2B5B 0x2A96 0x28AA>; + battery0,data_ver = <0x02>; - battery1,battery_type = <4400>; /* 4200 4350 4400 */ - battery1,battery_table0 = <0x1400 0x1B33 0x1C5F 0x1D61 0x1D83 0x1DF4 0x1E9C 0x1F06 0x1F68 0x1FFA 0x1FFA 0x2131 0x2169 0x2251 0x22C3 0x2399>; /*ATL Battery data*/ - battery1,battery_table1 = <0x1400 0x1B33 0x1C5F 0x1D61 0x1D83 0x1DF4 0x1E9C 0x1F06 0x1F68 0x1FFA 0x1FFA 0x2131 0x2169 0x2251 0x22C3 0x2399>; /*ATL Battery data*/ - battery1,battery_table2 = <0x0 0x6C 0x108 0x2A1 0x4EE 0xA9C 0x15FA 0x195B 0x1BA8 0x1F0A 0x1F0A 0x25D9 0x2826 0x2CB4 0x2EF5 0x2F19>; /*ATL Battery data*/ + /*ATL Battery data*/ + battery1,battery_type = <4350>; /* 4200 4350 4400 */ + battery1,battery_table0 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery1,battery_table1 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery1,battery_table2 = <0x0 0x48 0x1B0 0x2A1 0x5AE 0x934 0xF13 0x14F1 0x19A3 0x1D29 0x1F82 0x21DB 0x2434 0x27BA 0x2CE4 0x2CFB>; battery1,temp_std = <25>; battery1,temp_offset = <10>; battery1,temp_offset_cal = <0x01>; @@ -195,6 +208,8 @@ battery1,curr_cal = <0x7D85>; battery1,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery1,v_alarm = <3200>; - battery1,data_ver = <0x01>; + battery1,v_max_table = <0x2268 0x2241 0x221A 0x21F3 0x2191>; + battery1,q_max_table = <0x2CE4 0x2C20 0x2B5B 0x2A96 0x28AA>; + battery1,data_ver = <0x02>; }; }; diff --git a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-eur-battery.dtsi b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-eur-battery.dtsi index b6d54684c448..b1f49476add4 100644 --- a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-eur-battery.dtsi +++ b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-eur-battery.dtsi @@ -127,7 +127,7 @@ battery,swelling_low_temp_recov = <150>; //battery,swelling_chg_current = <1500>; battery,swelling_high_chg_current = <2100>; - battery,swelling_low_chg_current = <1500>; + battery,swelling_low_chg_current = <2100>; battery,swelling_full_check_current_2nd = <200>; battery,swelling_drop_float_voltage = <4200>; battery,swelling_high_rechg_voltage = <4150>; diff --git a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-tmo-battery.dtsi b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-tmo-battery.dtsi index ebe41def7824..08116865e6b2 100644 --- a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-tmo-battery.dtsi +++ b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-tmo-battery.dtsi @@ -86,12 +86,12 @@ SEC_BATTERY_FULL_CONDITION_VCELL */ battery,full_condition_type = <13>; battery,full_condition_soc = <93>; - battery,full_condition_vcell = <4300>; + battery,full_condition_vcell = <4250>; battery,recharge_check_count = <1>; battery,recharge_condition_type = <4>; /* SEC_BATTERY_RECHARGE_CONDITION_VCELL */ battery,recharge_condition_soc = <98>; - battery,recharge_condition_vcell = <4340>; + battery,recharge_condition_vcell = <4300>; battery,charging_total_time = <36000>; battery,recharging_total_time = <5400>; @@ -103,11 +103,11 @@ battery,swelling_low_temp_recov = <150>; //battery,swelling_chg_current = <1500>; battery,swelling_high_chg_current = <2100>; - battery,swelling_low_chg_current = <1500>; + battery,swelling_low_chg_current = <2100>; battery,swelling_full_check_current_2nd = <300>; - battery,swelling_drop_float_voltage = <4200>; - battery,swelling_high_rechg_voltage = <4150>; - battery,swelling_low_rechg_voltage = <4050>; + battery,swelling_drop_float_voltage = <4150>; + battery,swelling_high_rechg_voltage = <4000>; + battery,swelling_low_rechg_voltage = <4000>; battery,self_discharging_temp_block = <600>; battery,self_discharging_volt_block = <4250>; @@ -116,12 +116,21 @@ qcom,sec-battery-vadc = <&pm8950_vadc>; + /* cycle, chg_float_voltage, recharge_condition_vcell, full_condition_vcell, full_condition_soc */ + battery,age_data = < + 0 4350 4300 4250 93 + 200 4330 4280 4230 92 + 250 4310 4260 4210 91 + 300 4290 4240 4190 90 + 1000 4240 4190 4140 89 + >; + charger { status = "disable"; /* Charger */ battery,charger_name = "sm5703-charger"; battery,chg_gpio_en = <&msm_gpio 132 0x00>; - battery,chg_float_voltage = <4390>; + battery,chg_float_voltage = <4350>; battery,chg_polarity_en = <0>; battery,chg_gpio_status = <0>; @@ -152,11 +161,12 @@ }; battery_params { + /*SDI Battery data*/ battery,id = <(-1)>; /* -1 means auto, detected by F/G */ - battery0,battery_type = <4400>; /* 4200 4350 4400 */ - battery0,battery_table0 = <0x1400 0x1B47 0x1BAD 0x1C95 0x1D75 0x1D8C 0x1DF1 0x1E32 0x1EC9 0x1F34 0x1FA6 0x1FD9 0x2072 0x20F3 0x22C4 0x2399>; /*SDI Battery data*/ - battery0,battery_table1 = <0x1400 0x1B47 0x1BAD 0x1C95 0x1D75 0x1D8C 0x1DF1 0x1E32 0x1EC9 0x1F34 0x1FA6 0x1FD9 0x2072 0x20F3 0x22C4 0x2399>; /*SDI Battery data*/ - battery0,battery_table2 = <0x0 0x3C 0x91 0x114 0x24d 0x380 0x70B 0xBBD 0x177A 0x1B00 0x1D59 0x1FB2 0x220B 0x2591 0x2EF5 0x2F19>; /*SDI Battery data*/ + battery0,battery_type = <4350>; /* 4200 4350 4400 */ + battery0,battery_table0 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery0,battery_table1 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery0,battery_table2 = <0x0 0x48 0x1B0 0x2A1 0x5AE 0x934 0xF13 0x14F1 0x19A3 0x1D29 0x1F82 0x21DB 0x2434 0x27BA 0x2CE4 0x2CFB>; battery0,temp_std = <25>; battery0,temp_offset = <10>; battery0,temp_offset_cal = <0x01>; @@ -173,12 +183,15 @@ battery0,curr_cal = <0x7C85>; battery0,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery0,v_alarm = <3200>; - battery0,data_ver = <0x01>; + battery0,v_max_table = <0x2268 0x2241 0x221A 0x21F3 0x2191>; + battery0,q_max_table = <0x2CE4 0x2C20 0x2B5B 0x2A96 0x28AA>; + battery0,data_ver = <0x02>; - battery1,battery_type = <4400>; /* 4200 4350 4400 */ - battery1,battery_table0 = <0x1400 0x1B33 0x1C5F 0x1D61 0x1D83 0x1DF4 0x1E9C 0x1F06 0x1F68 0x1FFA 0x1FFA 0x2131 0x2169 0x2251 0x22C3 0x2399>; /*ATL Battery data*/ - battery1,battery_table1 = <0x1400 0x1B33 0x1C5F 0x1D61 0x1D83 0x1DF4 0x1E9C 0x1F06 0x1F68 0x1FFA 0x1FFA 0x2131 0x2169 0x2251 0x22C3 0x2399>; /*ATL Battery data*/ - battery1,battery_table2 = <0x0 0x6C 0x108 0x2A1 0x4EE 0xA9C 0x15FA 0x195B 0x1BA8 0x1F0A 0x1F0A 0x25D9 0x2826 0x2CB4 0x2EF5 0x2F19>; /*ATL Battery data*/ + /*ATL Battery data*/ + battery1,battery_type = <4350>; /* 4200 4350 4400 */ + battery1,battery_table0 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery1,battery_table1 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery1,battery_table2 = <0x0 0x48 0x1B0 0x2A1 0x5AE 0x934 0xF13 0x14F1 0x19A3 0x1D29 0x1F82 0x21DB 0x2434 0x27BA 0x2CE4 0x2CFB>; battery1,temp_std = <25>; battery1,temp_offset = <10>; battery1,temp_offset_cal = <0x01>; @@ -195,6 +208,8 @@ battery1,curr_cal = <0x7D85>; battery1,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery1,v_alarm = <3200>; - battery1,data_ver = <0x01>; + battery1,v_max_table = <0x2268 0x2241 0x221A 0x21F3 0x2191>; + battery1,q_max_table = <0x2CE4 0x2C20 0x2B5B 0x2A96 0x28AA>; + battery1,data_ver = <0x02>; }; }; diff --git a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-vzw-battery.dtsi b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-vzw-battery.dtsi index eea30d0b7b2d..fe7840556c46 100644 --- a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-vzw-battery.dtsi +++ b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210velte-vzw-battery.dtsi @@ -40,7 +40,7 @@ battery,adc_check_count = <5>; - battery,cable_check_type = <4>; /* SEC_BATTERY_CABLE_CHECK_PSY */ + battery,cable_check_type = <6>; /* SEC_BATTERY_CABLE_CHECK_NOINCOMPATIBLECHARGE | SEC_BATTERY_CABLE_CHECK_PSY */ battery,cable_source_type = <3>; /* SEC_BATTERY_CABLE_SOURCE_EXTERNAL */ battery,event_waiting_time = <600>; battery,polling_type = <1>; /* SEC_BATTERY_MONITOR_ALARM */ @@ -86,12 +86,12 @@ SEC_BATTERY_FULL_CONDITION_VCELL */ battery,full_condition_type = <13>; battery,full_condition_soc = <93>; - battery,full_condition_vcell = <4300>; + battery,full_condition_vcell = <4250>; battery,recharge_check_count = <1>; battery,recharge_condition_type = <4>; /* SEC_BATTERY_RECHARGE_CONDITION_VCELL */ battery,recharge_condition_soc = <98>; - battery,recharge_condition_vcell = <4340>; + battery,recharge_condition_vcell = <4300>; battery,charging_total_time = <36000>; battery,recharging_total_time = <5400>; @@ -103,11 +103,11 @@ battery,swelling_low_temp_recov = <150>; //battery,swelling_chg_current = <1500>; battery,swelling_high_chg_current = <2100>; - battery,swelling_low_chg_current = <1500>; + battery,swelling_low_chg_current = <2100>; battery,swelling_full_check_current_2nd = <300>; - battery,swelling_drop_float_voltage = <4200>; - battery,swelling_high_rechg_voltage = <4150>; - battery,swelling_low_rechg_voltage = <4050>; + battery,swelling_drop_float_voltage = <4150>; + battery,swelling_high_rechg_voltage = <4000>; + battery,swelling_low_rechg_voltage = <4000>; battery,self_discharging_temp_block = <600>; battery,self_discharging_volt_block = <4250>; @@ -116,13 +116,21 @@ qcom,sec-battery-vadc = <&pm8950_vadc>; + /* cycle, chg_float_voltage, recharge_condition_vcell, full_condition_vcell, full_condition_soc */ + battery,age_data = < + 0 4350 4300 4250 93 + 200 4330 4280 4230 92 + 250 4310 4260 4210 91 + 300 4290 4240 4190 90 + 1000 4240 4190 4140 89 + >; + charger { status = "disable"; /* Charger */ battery,charger_name = "sm5703-charger"; battery,chg_gpio_en = <&msm_gpio 132 0x00>; - battery,chg_float_voltage = <4390>; - battery,chg_vbuslimit = <1>; + battery,chg_float_voltage = <4350>; battery,chg_polarity_en = <0>; battery,chg_gpio_status = <0>; @@ -153,11 +161,12 @@ }; battery_params { + /*SDI Battery data*/ battery,id = <(-1)>; /* -1 means auto, detected by F/G */ - battery0,battery_type = <4400>; /* 4200 4350 4400 */ - battery0,battery_table0 = <0x1400 0x1B47 0x1BAD 0x1C95 0x1D75 0x1D8C 0x1DF1 0x1E32 0x1EC9 0x1F34 0x1FA6 0x1FD9 0x2072 0x20F3 0x22C4 0x2399>; /*SDI Battery data*/ - battery0,battery_table1 = <0x1400 0x1B47 0x1BAD 0x1C95 0x1D75 0x1D8C 0x1DF1 0x1E32 0x1EC9 0x1F34 0x1FA6 0x1FD9 0x2072 0x20F3 0x22C4 0x2399>; /*SDI Battery data*/ - battery0,battery_table2 = <0x0 0x3C 0x91 0x114 0x24d 0x380 0x70B 0xBBD 0x177A 0x1B00 0x1D59 0x1FB2 0x220B 0x2591 0x2EF5 0x2F19>; /*SDI Battery data*/ + battery0,battery_type = <4350>; /* 4200 4350 4400 */ + battery0,battery_table0 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery0,battery_table1 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery0,battery_table2 = <0x0 0x48 0x1B0 0x2A1 0x5AE 0x934 0xF13 0x14F1 0x19A3 0x1D29 0x1F82 0x21DB 0x2434 0x27BA 0x2CE4 0x2CFB>; battery0,temp_std = <25>; battery0,temp_offset = <10>; battery0,temp_offset_cal = <0x01>; @@ -174,12 +183,15 @@ battery0,curr_cal = <0x7C85>; battery0,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery0,v_alarm = <3200>; - battery0,data_ver = <0x01>; + battery0,v_max_table = <0x2268 0x2241 0x221A 0x21F3 0x2191>; + battery0,q_max_table = <0x2CE4 0x2C20 0x2B5B 0x2A96 0x28AA>; + battery0,data_ver = <0x02>; - battery1,battery_type = <4400>; /* 4200 4350 4400 */ - battery1,battery_table0 = <0x1400 0x1B33 0x1C5F 0x1D61 0x1D83 0x1DF4 0x1E9C 0x1F06 0x1F68 0x1FFA 0x1FFA 0x2131 0x2169 0x2251 0x22C3 0x2399>; /*ATL Battery data*/ - battery1,battery_table1 = <0x1400 0x1B33 0x1C5F 0x1D61 0x1D83 0x1DF4 0x1E9C 0x1F06 0x1F68 0x1FFA 0x1FFA 0x2131 0x2169 0x2251 0x22C3 0x2399>; /*ATL Battery data*/ - battery1,battery_table2 = <0x0 0x6C 0x108 0x2A1 0x4EE 0xA9C 0x15FA 0x195B 0x1BA8 0x1F0A 0x1F0A 0x25D9 0x2826 0x2CB4 0x2EF5 0x2F19>; /*ATL Battery data*/ + /*ATL Battery data*/ + battery1,battery_type = <4350>; /* 4200 4350 4400 */ + battery1,battery_table0 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery1,battery_table1 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery1,battery_table2 = <0x0 0x48 0x1B0 0x2A1 0x5AE 0x934 0xF13 0x14F1 0x19A3 0x1D29 0x1F82 0x21DB 0x2434 0x27BA 0x2CE4 0x2CFB>; battery1,temp_std = <25>; battery1,temp_offset = <10>; battery1,temp_offset_cal = <0x01>; @@ -196,6 +208,8 @@ battery1,curr_cal = <0x7D85>; battery1,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery1,v_alarm = <3200>; - battery1,data_ver = <0x01>; + battery1,v_max_table = <0x2268 0x2241 0x221A 0x21F3 0x2191>; + battery1,q_max_table = <0x2CE4 0x2C20 0x2B5B 0x2A96 0x28AA>; + battery1,data_ver = <0x02>; }; }; diff --git a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210vewifi-eur-battery-r04.dtsi b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210vewifi-eur-battery-r04.dtsi index 1a7a83a8ee20..c811a363beef 100644 --- a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210vewifi-eur-battery-r04.dtsi +++ b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts210vewifi-eur-battery-r04.dtsi @@ -76,12 +76,12 @@ SEC_BATTERY_FULL_CONDITION_VCELL */ battery,full_condition_type = <13>; battery,full_condition_soc = <93>; - battery,full_condition_vcell = <4300>; + battery,full_condition_vcell = <4250>; battery,recharge_check_count = <1>; battery,recharge_condition_type = <4>; /* SEC_BATTERY_RECHARGE_CONDITION_VCELL */ battery,recharge_condition_soc = <98>; - battery,recharge_condition_vcell = <4340>; + battery,recharge_condition_vcell = <4300>; battery,charging_total_time = <36000>; battery,recharging_total_time = <5400>; @@ -93,11 +93,11 @@ battery,swelling_low_temp_recov = <150>; //battery,swelling_chg_current = <1500>; battery,swelling_high_chg_current = <2100>; - battery,swelling_low_chg_current = <1500>; + battery,swelling_low_chg_current = <2100>; battery,swelling_full_check_current_2nd = <300>; - battery,swelling_drop_float_voltage = <4200>; - battery,swelling_high_rechg_voltage = <4150>; - battery,swelling_low_rechg_voltage = <4050>; + battery,swelling_drop_float_voltage = <4150>; + battery,swelling_high_rechg_voltage = <4000>; + battery,swelling_low_rechg_voltage = <4000>; battery,self_discharging_temp_block = <600>; battery,self_discharging_volt_block = <4250>; @@ -105,13 +105,21 @@ battery,self_discharging_temp_pollingtime = <400>; qcom,sec-battery-vadc = <&pm8950_vadc>; - + + /* cycle, chg_float_voltage, recharge_condition_vcell, full_condition_vcell, full_condition_soc */ + battery,age_data = < + 0 4350 4300 4250 93 + 200 4330 4280 4230 92 + 250 4310 4260 4210 91 + 300 4290 4240 4190 90 + 1000 4240 4190 4140 89 + >; charger { status = "disable"; /* Charger */ battery,charger_name = "sm5703-charger"; battery,chg_gpio_en = <&msm_gpio 132 0x00>; - battery,chg_float_voltage = <4390>; + battery,chg_float_voltage = <4350>; battery,chg_polarity_en = <0>; battery,chg_gpio_status = <0>; @@ -142,11 +150,12 @@ }; battery_params { + /*SDI Battery data*/ battery,id = <(-1)>; /* -1 means auto, detected by F/G */ - battery0,battery_type = <4400>; /* 4200 4350 4400 */ - battery0,battery_table0 = <0x1400 0x1B47 0x1BAD 0x1C95 0x1D75 0x1D8C 0x1DF1 0x1E32 0x1EC9 0x1F34 0x1FA6 0x1FD9 0x2072 0x20F3 0x22C4 0x2399>; /*SDI Battery data*/ - battery0,battery_table1 = <0x1400 0x1B47 0x1BAD 0x1C95 0x1D75 0x1D8C 0x1DF1 0x1E32 0x1EC9 0x1F34 0x1FA6 0x1FD9 0x2072 0x20F3 0x22C4 0x2399>; /*SDI Battery data*/ - battery0,battery_table2 = <0x0 0x3C 0x91 0x114 0x24d 0x380 0x70B 0xBBD 0x177A 0x1B00 0x1D59 0x1FB2 0x220B 0x2591 0x2EF5 0x2F19>; /*SDI Battery data*/ + battery0,battery_type = <4350>; /* 4200 4350 4400 */ + battery0,battery_table0 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery0,battery_table1 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery0,battery_table2 = <0x0 0x48 0x1B0 0x2A1 0x5AE 0x934 0xF13 0x14F1 0x19A3 0x1D29 0x1F82 0x21DB 0x2434 0x27BA 0x2CE4 0x2CFB>; battery0,temp_std = <25>; battery0,temp_offset = <10>; battery0,temp_offset_cal = <0x01>; @@ -163,12 +172,15 @@ battery0,curr_cal = <0x7885>; battery0,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery0,v_alarm = <3200>; - battery0,data_ver = <0x01>; + battery0,v_max_table = <0x2268 0x2241 0x221A 0x21F3 0x2191>; + battery0,q_max_table = <0x2CE4 0x2C20 0x2B5B 0x2A96 0x28AA>; + battery0,data_ver = <0x02>; - battery1,battery_type = <4400>; /* 4200 4350 4400 */ - battery1,battery_table0 = <0x1400 0x1B33 0x1C5F 0x1D61 0x1D83 0x1DF4 0x1E9C 0x1F06 0x1F68 0x1FFA 0x1FFA 0x2131 0x2169 0x2251 0x22C3 0x2399>; /*ATL Battery data*/ - battery1,battery_table1 = <0x1400 0x1B33 0x1C5F 0x1D61 0x1D83 0x1DF4 0x1E9C 0x1F06 0x1F68 0x1FFA 0x1FFA 0x2131 0x2169 0x2251 0x22C3 0x2399>; /*ATL Battery data*/ - battery1,battery_table2 = <0x0 0x6C 0x108 0x2A1 0x4EE 0xA9C 0x15FA 0x195B 0x1BA8 0x1F0A 0x1F0A 0x25D9 0x2826 0x2CB4 0x2EF5 0x2F19>; /*ATL Battery data*/ + /*ATL Battery data*/ + battery1,battery_type = <4350>; /* 4200 4350 4400 */ + battery1,battery_table0 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery1,battery_table1 = <0x1400 0x1B45 0x1CF6 0x1D75 0x1D8B 0x1DEF 0x1E48 0x1E9E 0x1F0D 0x1FAA 0x1FDD 0x207E 0x20C5 0x2165 0x2268 0x2400>; + battery1,battery_table2 = <0x0 0x48 0x1B0 0x2A1 0x5AE 0x934 0xF13 0x14F1 0x19A3 0x1D29 0x1F82 0x21DB 0x2434 0x27BA 0x2CE4 0x2CFB>; battery1,temp_std = <25>; battery1,temp_offset = <10>; battery1,temp_offset_cal = <0x01>; @@ -185,6 +197,8 @@ battery1,curr_cal = <0x7D85>; battery1,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery1,v_alarm = <3200>; - battery1,data_ver = <0x01>; + battery1,v_max_table = <0x2268 0x2241 0x221A 0x21F3 0x2191>; + battery1,q_max_table = <0x2CE4 0x2C20 0x2B5B 0x2A96 0x28AA>; + battery1,data_ver = <0x02>; }; }; diff --git a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28velte-eur-battery-r04.dtsi b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28velte-eur-battery-r04.dtsi index dcf150f86841..aec0902d5b21 100644 --- a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28velte-eur-battery-r04.dtsi +++ b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28velte-eur-battery-r04.dtsi @@ -78,12 +78,12 @@ SEC_BATTERY_FULL_CONDITION_VCELL */ battery,full_condition_type = <13>; battery,full_condition_soc = <93>; - battery,full_condition_vcell = <4300>; + battery,full_condition_vcell = <4250>; battery,recharge_check_count = <1>; battery,recharge_condition_type = <4>; /* SEC_BATTERY_RECHARGE_CONDITION_VCELL */ battery,recharge_condition_soc = <98>; - battery,recharge_condition_vcell = <4340>; + battery,recharge_condition_vcell = <4300>; battery,charging_total_time = <21600>; battery,recharging_total_time = <5400>; @@ -97,10 +97,9 @@ battery,swelling_high_chg_current = <2100>; battery,swelling_low_chg_current = <1950>; battery,swelling_full_check_current_2nd = <200>; - battery,swelling_drop_float_voltage = <4200>; - battery,swelling_high_rechg_voltage = <4150>; - battery,swelling_low_rechg_voltage = <4050>; - battery,swelling_block_time = <600>; + battery,swelling_drop_float_voltage = <4150>; + battery,swelling_high_rechg_voltage = <4000>; + battery,swelling_low_rechg_voltage = <4000>; battery,self_discharging_temp_block = <600>; battery,self_discharging_volt_block = <4250>; @@ -109,12 +108,21 @@ qcom,sec-battery-vadc = <&pm8950_vadc>; + /* cycle, chg_float_voltage, recharge_condition_vcell, full_condition_vcell, full_condition_soc */ + battery,age_data = < + 0 4350 4300 4250 93 + 200 4330 4280 4230 92 + 250 4310 4260 4210 91 + 300 4290 4240 4190 90 + 1000 4240 4190 4140 89 + >; + charger { status = "disable"; /* Charger */ battery,charger_name = "sm5703-charger"; battery,chg_gpio_en = <&msm_gpio 132 0x00>; - battery,chg_float_voltage = <4390>; + battery,chg_float_voltage = <4350>; battery,chg_polarity_en = <0>; battery,chg_gpio_status = <0>; @@ -146,10 +154,10 @@ battery_params { battery,id = <0>; /* -1 means auto, detected by F/G */ - battery0,battery_type = <4400>; /* 4200 4350 4400 */ - battery0,battery_table0 = <0x1400 0x1B33 0x1D0C 0x1D56 0x1D7E 0x1D8A 0x1DED 0x1E66 0x1EED 0x1FAD 0x1FE3 0x2085 0x209E 0x2138 0x2302 0x2399>; - battery0,battery_table1 = <0x1400 0x1B33 0x1D0C 0x1D56 0x1D7E 0x1D8A 0x1DED 0x1E66 0x1EED 0x1FAD 0x1FE3 0x2085 0x209E 0x2138 0x2302 0x2399>; - battery0,battery_table2 = <0x00 0x49 0x7A 0xCC 0x199 0x333 0x599 0xB33 0x1000 0x1333 0x14CC 0x1666 0x1733 0x1999 0x2000 0x2018>; + battery0,battery_type = <4350>; /* 4200 4350 4400 */ + battery0,battery_table0 = <0x1400 0x1B24 0x1D1D 0x1D7F 0x1D8A 0x1DE9 0x1E5A 0x1EBD 0x1F16 0x1FB4 0x1FF4 0x208F 0x20AA 0x2148 0x224C 0x2400>; + battery0,battery_table1 = <0x1400 0x1B24 0x1D1D 0x1D7F 0x1D8A 0x1DE9 0x1E5A 0x1EBD 0x1F16 0x1FB4 0x1FF4 0x208F 0x20AA 0x2148 0x224C 0x2400>; + battery0,battery_table2 = <0x0 0x28 0x147 0x214 0x3AE 0x614 0xAE1 0xEE1 0x1147 0x13AE 0x1547 0x16E1 0x17AE 0x1A14 0x1D99 0x1DA8>; battery0,temp_std = <25>; battery0,temp_offset = <10>; battery0,temp_offset_cal = <0x01>; @@ -166,6 +174,8 @@ battery0,curr_cal = <0x7385>; battery0,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery0,v_alarm = <3250>; - battery0,data_ver = <0x01>; + battery0,v_max_table = <0x224C 0x2225 0x21FE 0x21D7 0x2174>; + battery0,q_max_table = <0x1D99 0x1D13 0x1C8D 0x1C07 0x1AB8>; + battery0,data_ver = <0x02>; }; }; diff --git a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28vewifi-eur-battery-r04.dtsi b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28vewifi-eur-battery-r04.dtsi index 95c46d63b7a5..ff213bf75544 100644 --- a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28vewifi-eur-battery-r04.dtsi +++ b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28vewifi-eur-battery-r04.dtsi @@ -76,12 +76,12 @@ SEC_BATTERY_FULL_CONDITION_VCELL */ battery,full_condition_type = <13>; battery,full_condition_soc = <93>; - battery,full_condition_vcell = <4300>; + battery,full_condition_vcell = <4250>; battery,recharge_check_count = <1>; battery,recharge_condition_type = <4>; /* SEC_BATTERY_RECHARGE_CONDITION_VCELL */ battery,recharge_condition_soc = <98>; - battery,recharge_condition_vcell = <4350>; + battery,recharge_condition_vcell = <4300>; battery,charging_total_time = <21600>; battery,recharging_total_time = <5400>; @@ -95,10 +95,9 @@ battery,swelling_high_chg_current = <2100>; battery,swelling_low_chg_current = <1950>; battery,swelling_full_check_current_2nd = <200>; - battery,swelling_drop_float_voltage = <4200>; - battery,swelling_high_rechg_voltage = <4150>; - battery,swelling_low_rechg_voltage = <4050>; - battery,swelling_block_time = <600>; + battery,swelling_drop_float_voltage = <4150>; + battery,swelling_high_rechg_voltage = <4000>; + battery,swelling_low_rechg_voltage = <4000>; battery,self_discharging_temp_block = <600>; battery,self_discharging_volt_block = <4250>; @@ -107,12 +106,21 @@ qcom,sec-battery-vadc = <&pm8950_vadc>; + /* cycle, chg_float_voltage, recharge_condition_vcell, full_condition_vcell, full_condition_soc */ + battery,age_data = < + 0 4350 4300 4250 93 + 200 4330 4280 4230 92 + 250 4310 4260 4210 91 + 300 4290 4240 4190 90 + 1000 4240 4190 4140 89 + >; + charger { status = "disable"; /* Charger */ battery,charger_name = "sm5703-charger"; battery,chg_gpio_en = <&msm_gpio 132 0x00>; - battery,chg_float_voltage = <4390>; + battery,chg_float_voltage = <4350>; battery,chg_polarity_en = <0>; battery,chg_gpio_status = <0>; @@ -144,10 +152,10 @@ battery_params { battery,id = <0>; /* -1 means auto, detected by F/G */ - battery0,battery_type = <4400>; /* 4200 4350 4400 */ - battery0,battery_table0 = <0x1400 0x1B33 0x1D0C 0x1D56 0x1D7E 0x1D8A 0x1DED 0x1E66 0x1EED 0x1FAD 0x1FE3 0x2085 0x209E 0x2138 0x2302 0x2399>; - battery0,battery_table1 = <0x1400 0x1B33 0x1D0C 0x1D56 0x1D7E 0x1D8A 0x1DED 0x1E66 0x1EED 0x1FAD 0x1FE3 0x2085 0x209E 0x2138 0x2302 0x2399>; - battery0,battery_table2 = <0x00 0x49 0x7A 0xCC 0x199 0x333 0x599 0xB33 0x1000 0x1333 0x14CC 0x1666 0x1733 0x1999 0x2000 0x2018>; + battery0,battery_type = <4350>; /* 4200 4350 4400 */ + battery0,battery_table0 = <0x1400 0x1B24 0x1D1D 0x1D7F 0x1D8A 0x1DE9 0x1E5A 0x1EBD 0x1F16 0x1FB4 0x1FF4 0x208F 0x20AA 0x2148 0x224C 0x2400>; + battery0,battery_table1 = <0x1400 0x1B24 0x1D1D 0x1D7F 0x1D8A 0x1DE9 0x1E5A 0x1EBD 0x1F16 0x1FB4 0x1FF4 0x208F 0x20AA 0x2148 0x224C 0x2400>; + battery0,battery_table2 = <0x0 0x28 0x147 0x214 0x3AE 0x614 0xAE1 0xEE1 0x1147 0x13AE 0x1547 0x16E1 0x17AE 0x1A14 0x1D99 0x1DA8>; battery0,temp_std = <25>; battery0,temp_offset = <10>; battery0,temp_offset_cal = <0x01>; @@ -164,6 +172,8 @@ battery0,curr_cal = <0x7A85>; battery0,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery0,v_alarm = <3250>; - battery0,data_ver = <0x01>; + battery0,v_max_table = <0x224C 0x2225 0x21FE 0x21D7 0x2174>; + battery0,q_max_table = <0x1D99 0x1D13 0x1C8D 0x1C07 0x1AB8>; + battery0,data_ver = <0x02>; }; }; diff --git a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28vewifi-eur-battery-r05.dtsi b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28vewifi-eur-battery-r05.dtsi index 336f4a4146e1..a8bc92df9a7a 100644 --- a/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28vewifi-eur-battery-r05.dtsi +++ b/arch/arm/boot/dts/samsung/msm8976/msm8976-sec-gts28vewifi-eur-battery-r05.dtsi @@ -78,12 +78,12 @@ SEC_BATTERY_FULL_CONDITION_VCELL */ battery,full_condition_type = <13>; battery,full_condition_soc = <93>; - battery,full_condition_vcell = <4300>; + battery,full_condition_vcell = <4250>; battery,recharge_check_count = <1>; battery,recharge_condition_type = <4>; /* SEC_BATTERY_RECHARGE_CONDITION_VCELL */ battery,recharge_condition_soc = <98>; - battery,recharge_condition_vcell = <4350>; + battery,recharge_condition_vcell = <4300>; battery,charging_total_time = <21600>; battery,recharging_total_time = <5400>; @@ -97,10 +97,9 @@ battery,swelling_high_chg_current = <2100>; battery,swelling_low_chg_current = <1950>; battery,swelling_full_check_current_2nd = <200>; - battery,swelling_drop_float_voltage = <4200>; - battery,swelling_high_rechg_voltage = <4150>; - battery,swelling_low_rechg_voltage = <4050>; - battery,swelling_block_time = <600>; + battery,swelling_drop_float_voltage = <4150>; + battery,swelling_high_rechg_voltage = <4000>; + battery,swelling_low_rechg_voltage = <4000>; battery,self_discharging_temp_block = <600>; battery,self_discharging_volt_block = <4250>; @@ -109,12 +108,21 @@ qcom,sec-battery-vadc = <&pm8950_vadc>; + /* cycle, chg_float_voltage, recharge_condition_vcell, full_condition_vcell, full_condition_soc */ + battery,age_data = < + 0 4350 4300 4250 93 + 200 4330 4280 4230 92 + 250 4310 4260 4210 91 + 300 4290 4240 4190 90 + 1000 4240 4190 4140 89 + >; + charger { status = "disable"; /* Charger */ battery,charger_name = "sm5703-charger"; battery,chg_gpio_en = <&msm_gpio 132 0x00>; - battery,chg_float_voltage = <4390>; + battery,chg_float_voltage = <4350>; battery,chg_polarity_en = <0>; battery,chg_gpio_status = <0>; @@ -146,10 +154,10 @@ battery_params { battery,id = <0>; /* -1 means auto, detected by F/G */ - battery0,battery_type = <4400>; /* 4200 4350 4400 */ - battery0,battery_table0 = <0x1400 0x1B33 0x1D0C 0x1D56 0x1D7E 0x1D8A 0x1DED 0x1E66 0x1EED 0x1FAD 0x1FE3 0x2085 0x209E 0x2138 0x2302 0x2399>; - battery0,battery_table1 = <0x1400 0x1B33 0x1D0C 0x1D56 0x1D7E 0x1D8A 0x1DED 0x1E66 0x1EED 0x1FAD 0x1FE3 0x2085 0x209E 0x2138 0x2302 0x2399>; - battery0,battery_table2 = <0x00 0x49 0x7A 0xCC 0x199 0x333 0x599 0xB33 0x1000 0x1333 0x14CC 0x1666 0x1733 0x1999 0x2000 0x2018>; + battery0,battery_type = <4350>; /* 4200 4350 4400 */ + battery0,battery_table0 = <0x1400 0x1B24 0x1D1D 0x1D7F 0x1D8A 0x1DE9 0x1E5A 0x1EBD 0x1F16 0x1FB4 0x1FF4 0x208F 0x20AA 0x2148 0x224C 0x2400>; + battery0,battery_table1 = <0x1400 0x1B24 0x1D1D 0x1D7F 0x1D8A 0x1DE9 0x1E5A 0x1EBD 0x1F16 0x1FB4 0x1FF4 0x208F 0x20AA 0x2148 0x224C 0x2400>; + battery0,battery_table2 = <0x0 0x28 0x147 0x214 0x3AE 0x614 0xAE1 0xEE1 0x1147 0x13AE 0x1547 0x16E1 0x17AE 0x1A14 0x1D99 0x1DA8>; battery0,temp_std = <25>; battery0,temp_offset = <10>; battery0,temp_offset_cal = <0x01>; @@ -166,6 +174,8 @@ battery0,curr_cal = <0x7A85>; battery0,ext_temp_cal = <0 10 1 1 1 7 1 2>; battery0,v_alarm = <3250>; - battery0,data_ver = <0x01>; + battery0,v_max_table = <0x224C 0x2225 0x21FE 0x21D7 0x2174>; + battery0,q_max_table = <0x1D99 0x1D13 0x1C8D 0x1C07 0x1AB8>; + battery0,data_ver = <0x02>; }; }; diff --git a/arch/arm64/configs/msm8976_sec_gts28vewifi_eur_defconfig b/arch/arm64/configs/msm8976_sec_gts28vewifi_eur_defconfig index 626b4eafa038..264ddc380eb4 100644 --- a/arch/arm64/configs/msm8976_sec_gts28vewifi_eur_defconfig +++ b/arch/arm64/configs/msm8976_sec_gts28vewifi_eur_defconfig @@ -80,6 +80,7 @@ CONFIG_BATTERY_SWELLING=y CONFIG_BATTERY_SWELLING_SELF_DISCHARGING=y CONFIG_MUIC_SUPPORT_MULTIMEDIA_DOCK=y CONFIG_INBATVOLT_FG=y +CONFIG_BATTERY_AGE_FORECAST=y #Power off Alarm # CONFIG_RTC_AUTO_PWRON is not set diff --git a/build_msm8952_kernel.sh b/build_msm8952_kernel.sh new file mode 100644 index 000000000000..7a769d31f839 --- /dev/null +++ b/build_msm8952_kernel.sh @@ -0,0 +1,317 @@ +#!/bin/bash +# MSM8952 L kernel build script v0.5 + +BUILD_COMMAND=$1 +if [ "$BUILD_COMMAND" == "lte_eur" ]; then + PRODUCT_NAME=msm8952ltexx + SIGN_MODEL= +elif [ "$BUILD_COMMAND" == "a7xlte_chn" ]; then + PRODUCT_NAME=a7xltectc + SIGN_MODEL= +elif [ "$BUILD_COMMAND" == "j7xlte_chn" ]; then + PRODUCT_NAME=j7xltectc + SIGN_MODEL= +elif [ "$BUILD_COMMAND" == "on5xlte_chn" ]; then + PRODUCT_NAME=on5xltechn + SIGN_MODEL= +else +#default product + PRODUCT_NAME=$BUILD_COMMAND; + SIGN_MODEL= +fi + +BUILD_WHERE=$(pwd) +BUILD_KERNEL_DIR=$BUILD_WHERE +BUILD_ROOT_DIR=$BUILD_KERNEL_DIR/../.. +BUILD_KERNEL_OUT_DIR=$BUILD_ROOT_DIR/android/out/target/product/$PRODUCT_NAME/obj/KERNEL_OBJ +PRODUCT_OUT=$BUILD_ROOT_DIR/android/out/target/product/$PRODUCT_NAME + + +SECURE_SCRIPT=$BUILD_ROOT_DIR/buildscript/tools/signclient.jar +BUILD_CROSS_COMPILE=$BUILD_ROOT_DIR/android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi- +BUILD_JOB_NUMBER=`grep processor /proc/cpuinfo|wc -l` + +# Default Python version is 2.7 +mkdir -p bin +ln -sf /usr/bin/python2.7 ./bin/python +export PATH=$(pwd)/bin:$PATH + +KERNEL_DEFCONFIG=msm8952_sec_defconfig +DEBUG_DEFCONFIG=msm8952_sec_eng_defconfig +SELINUX_DEFCONFIG=selinux_defconfig +SELINUX_LOG_DEFCONFIG=selinux_log_defconfig +DMVERITY_DEFCONFIG=dmverity_defconfig + +while getopts "w:t:" flag; do + case $flag in + w) + BUILD_OPTION_HW_REVISION=$OPTARG + echo "-w : "$BUILD_OPTION_HW_REVISION"" + ;; + t) + TARGET_BUILD_VARIANT=$OPTARG + echo "-t : "$TARGET_BUILD_VARIANT"" + ;; + *) + echo "wrong 2nd param : "$OPTARG"" + exit -1 + ;; + esac +done + +shift $((OPTIND-1)) + +BUILD_COMMAND=$1 +SECURE_OPTION= +SEANDROID_OPTION= +if [ "$2" == "-B" ]; then + SECURE_OPTION=$2 +elif [ "$2" == "-E" ]; then + SEANDROID_OPTION=$2 +else + NO_JOB= +fi + +if [ "$3" == "-B" ]; then + SECURE_OPTION=$3 +elif [ "$3" == "-E" ]; then + SEANDROID_OPTION=$3 +else + NO_JOB= +fi + +MODEL=${BUILD_COMMAND%%_*} +TEMP=${BUILD_COMMAND#*_} +REGION=${TEMP%%_*} +CARRIER=${TEMP##*_} + +VARIANT=${CARRIER} +PROJECT_NAME=${VARIANT} +VARIANT_DEFCONFIG=msm8952_sec_${MODEL}_${CARRIER}_defconfig + +CERTIFICATION=NONCERT + +case $1 in + clean) + echo "Not support... remove kernel out directory by yourself" + exit 1 + ;; + + *) + + BOARD_KERNEL_BASE=0x80000000 + BOARD_KERNEL_PAGESIZE=2048 + BOARD_KERNEL_TAGS_OFFSET=0x01E00000 + BOARD_RAMDISK_OFFSET=0x02000000 + #BOARD_KERNEL_CMDLINE="console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3" + BOARD_KERNEL_CMDLINE="console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci" +# BOARD_KERNEL_CMDLINE="console=ttyHSL0,115200,n8 androidboot.hardware=qcom androidboot.bootdevice=soc.0/7824900.sdhci user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3 video=vfb:640x400,bpp=32,memsize=3072000 earlyprintk" + mkdir -p $BUILD_KERNEL_OUT_DIR + ;; + +esac + +KERNEL_ZIMG=$BUILD_KERNEL_OUT_DIR/arch/arm/boot/zImage +DTC=$BUILD_KERNEL_OUT_DIR/scripts/dtc/dtc + +FUNC_CLEAN_DTB() +{ + if ! [ -d $BUILD_KERNEL_OUT_DIR/arch/arm/boot/dts ] ; then + echo "no directory : "$BUILD_KERNEL_OUT_DIR/arch/arm/boot/dts"" + else + echo "rm files in : "$BUILD_KERNEL_OUT_DIR/arch/arm/boot/dts/*.dtb"" + rm $BUILD_KERNEL_OUT_DIR/arch/arm/boot/dts/*.dtb + fi +} + +INSTALLED_DTIMAGE_TARGET=${PRODUCT_OUT}/dt.img +DTBTOOL=$BUILD_KERNEL_DIR/tools/dtbTool + +FUNC_BUILD_DTIMAGE_TARGET() +{ + echo "" + echo "=================================" + echo "START : FUNC_BUILD_DTIMAGE_TARGET" + echo "=================================" + echo "" + echo "DT image target : $INSTALLED_DTIMAGE_TARGET" + + if ! [ -e $DTBTOOL ] ; then + if ! [ -d $BUILD_ROOT_DIR/android/out/host/linux-x86/bin ] ; then + mkdir -p $BUILD_ROOT_DIR/android/out/host/linux-x86/bin + fi + cp $BUILD_ROOT_DIR/kernel/tools/dtbTool $DTBTOOL + fi + + echo "$DTBTOOL -o $INSTALLED_DTIMAGE_TARGET -s $BOARD_KERNEL_PAGESIZE \ + -p $BUILD_KERNEL_OUT_DIR/scripts/dtc/ $BUILD_KERNEL_OUT_DIR/arch/arm/boot/dts/" + $DTBTOOL -o $INSTALLED_DTIMAGE_TARGET -s $BOARD_KERNEL_PAGESIZE \ + -p $BUILD_KERNEL_OUT_DIR/scripts/dtc/ $BUILD_KERNEL_OUT_DIR/arch/arm/boot/dts/ + + chmod a+r $INSTALLED_DTIMAGE_TARGET + + echo "" + echo "=================================" + echo "END : FUNC_BUILD_DTIMAGE_TARGET" + echo "=================================" + echo "" +} + +FUNC_BUILD_KERNEL() +{ + echo "" + echo "==============================================" + echo "START : FUNC_BUILD_KERNEL" + echo "==============================================" + echo "" + echo "build project="$PROJECT_NAME"" + echo "build common config="$KERNEL_DEFCONFIG "" + echo "build variant config="$VARIANT_DEFCONFIG "" + echo "build secure option="$SECURE_OPTION "" + echo "build SEANDROID option="$SEANDROID_OPTION "" + echo "build selinux defconfig="$SELINUX_DEFCONFIG "" + echo "build selinux log defconfig="$SELINUX_LOG_DEFCONFIG "" + echo "build tima defconfig="$TIMA_DEFCONFIG "" + + if [ "$BUILD_COMMAND" == "" ]; then + SECFUNC_PRINT_HELP; + exit -1; + fi + + FUNC_CLEAN_DTB + + make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm \ + CROSS_COMPILE=$BUILD_CROSS_COMPILE \ + VARIANT_DEFCONFIG=$VARIANT_DEFCONFIG \ + DEBUG_DEFCONFIG=$DEBUG_DEFCONFIG $KERNEL_DEFCONFIG\ + SELINUX_DEFCONFIG=$SELINUX_DEFCONFIG \ + SELINUX_LOG_DEFCONFIG=$SELINUX_LOG_DEFCONFIG || exit -1 + + make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm \ + CROSS_COMPILE=$BUILD_CROSS_COMPILE || exit -1 + + FUNC_BUILD_DTIMAGE_TARGET + + echo "" + echo "=================================" + echo "END : FUNC_BUILD_KERNEL" + echo "=================================" + echo "" +} + +FUNC_MKBOOTIMG() +{ + echo "" + echo "===================================" + echo "START : FUNC_MKBOOTIMG" + echo "===================================" + echo "" + MKBOOTIMGTOOL=$BUILD_ROOT_DIR/android/kernel/tools/mkbootimg + + if ! [ -e $MKBOOTIMGTOOL ] ; then + if ! [ -d $BUILD_ROOT_DIR/android/out/host/linux-x86/bin ] ; then + mkdir -p $BUILD_ROOT_DIR/android/out/host/linux-x86/bin + fi + cp $BUILD_ROOT_DIR/android/kernel/tools/mkbootimg $MKBOOTIMGTOOL + fi + + echo "Making boot.img ..." + echo " $MKBOOTIMGTOOL --kernel $KERNEL_ZIMG \ + --ramdisk $PRODUCT_OUT/ramdisk.img \ + --output $PRODUCT_OUT/boot.img \ + --cmdline "$BOARD_KERNEL_CMDLINE" \ + --base $BOARD_KERNEL_BASE \ + --pagesize $BOARD_KERNEL_PAGESIZE \ + --ramdisk_offset $BOARD_RAMDISK_OFFSET \ + --tags_offset $BOARD_KERNEL_TAGS_OFFSET \ + --dt $INSTALLED_DTIMAGE_TARGET" + + $MKBOOTIMGTOOL --kernel $KERNEL_ZIMG \ + --ramdisk $PRODUCT_OUT/ramdisk.img \ + --output $PRODUCT_OUT/boot.img \ + --cmdline "$BOARD_KERNEL_CMDLINE" \ + --base $BOARD_KERNEL_BASE \ + --pagesize $BOARD_KERNEL_PAGESIZE \ + --ramdisk_offset $BOARD_RAMDISK_OFFSET \ + --tags_offset $BOARD_KERNEL_TAGS_OFFSET \ + --dt $INSTALLED_DTIMAGE_TARGET + + if [ "$SEANDROID_OPTION" == "-E" ] ; then + FUNC_SEANDROID + fi + + if [ "$SECURE_OPTION" == "-B" ]; then + FUNC_SECURE_SIGNING + fi + + cd $PRODUCT_OUT + tar cvf boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar boot.img + + cd $BUILD_ROOT_DIR + if ! [ -d output ] ; then + mkdir -p output + fi + + echo "" + echo "=================================================" + echo "-->Note, copy to $BUILD_TOP_DIR/../output/ directory" + echo "=================================================" + cp $PRODUCT_OUT/boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar $BUILD_ROOT_DIR/output/boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar || exit -1 + cd ~ + + echo "" + echo "===================================" + echo "END : FUNC_MKBOOTIMG" + echo "===================================" + echo "" +} + +FUNC_SEANDROID() +{ + echo -n "SEANDROIDENFORCE" >> $PRODUCT_OUT/boot.img +} + +FUNC_SECURE_SIGNING() +{ + echo "java -jar $SECURE_SCRIPT -model $SIGN_MODEL -runtype ss_openssl_sha -input $PRODUCT_OUT/boot.img -output $PRODUCT_OUT/signed_boot.img" + openssl dgst -sha256 -binary $PRODUCT_OUT/boot.img > sig_32 + java -jar $SECURE_SCRIPT -runtype ss_openssl_sha -model $SIGN_MODEL -input sig_32 -output sig_256 + cat $PRODUCT_OUT/boot.img sig_256 > $PRODUCT_OUT/signed_boot.img + + mv -f $PRODUCT_OUT/boot.img $PRODUCT_OUT/unsigned_boot.img + mv -f $PRODUCT_OUT/signed_boot.img $PRODUCT_OUT/boot.img + + CERTIFICATION=CERT +} + +SECFUNC_PRINT_HELP() +{ + echo -e '\E[33m' + echo "Help" + echo "$0 \$1 \$2 \$3" + echo " \$1 : " + echo " for 8952 LTE_EUR_OPEN use lte_eur" + echo " for 8952 A7XLTE_CHN_CTC use a7xlte_chn" + echo " for 8952 J7XLTE_CHN_CTC use j7xlte_chn" + echo " \$2 : " + echo " -B or Nothing (-B : Secure Binary)" + echo " \$3 : " + echo " -E or Nothing (-E : SEANDROID Binary)" + echo -e '\E[0m' +} + + +# MAIN FUNCTION +rm -rf ./build.log +( + START_TIME=`date +%s` + + FUNC_BUILD_KERNEL + #FUNC_RAMDISK_EXTRACT_N_COPY + FUNC_MKBOOTIMG + + END_TIME=`date +%s` + + let "ELAPSED_TIME=$END_TIME-$START_TIME" + echo "Total compile time is $ELAPSED_TIME seconds" +) 2>&1 | tee -a ./build.log diff --git a/build_msm8976_kernel.sh b/build_msm8976_kernel.sh new file mode 100644 index 000000000000..7b5431d37cd2 --- /dev/null +++ b/build_msm8976_kernel.sh @@ -0,0 +1,328 @@ +#!/bin/bash +# MSM8916 KK kernel build script v0.5 + +BUILD_COMMAND=$1 +if [ "$BUILD_COMMAND" == "a9xlte_chn" ]; then + PRODUCT_NAME=a9xlte + SIGN_MODEL=SM-A9000_CHN_CHC_ROOT0 +elif [ "$BUILD_COMMAND" == "a9xlte_chnldu" ]; then + PRODUCT_NAME=a9xlte_chnldu + SIGN_MODEL=SM-A9000_CHN_CHC_ROOT0 +elif [ "$BUILD_COMMAND" == "a9xprolte_chn" ]; then + PRODUCT_NAME=a9xproltechn + SIGN_MODEL=SM-A9100_CHN_CHC_ROOT0 +elif [ "$BUILD_COMMAND" == "gts28velte_eur" ]; then + PRODUCT_NAME=gts28velte + SIGN_MODEL=SM-T719_EUR_XX_ROOT0 +elif [ "$BUILD_COMMAND" == "gts28velte_chn" ]; then + PRODUCT_NAME=gts28veltechn + SIGN_MODEL= +elif [ "$BUILD_COMMAND" == "gts210velte_eur" ]; then + PRODUCT_NAME=gts210velte + SIGN_MODEL=SM-T819_EUR_XX_ROOT0 +elif [ "$BUILD_COMMAND" == "gts28vewifi_eur" ]; then + PRODUCT_NAME=gts28vewifi + SIGN_MODEL= +elif [ "$BUILD_COMMAND" == "c9lte_chn" ]; then + PRODUCT_NAME=c9ltechn + SIGN_MODEL= +fi + +BUILD_WHERE=$(pwd) +BUILD_KERNEL_DIR=$BUILD_WHERE +BUILD_ROOT_DIR=$BUILD_KERNEL_DIR/../.. +BUILD_KERNEL_OUT_DIR=$BUILD_ROOT_DIR/android/out/target/product/$PRODUCT_NAME/obj/KERNEL_OBJ +PRODUCT_OUT=$BUILD_ROOT_DIR/android/out/target/product/$PRODUCT_NAME + + +SECURE_SCRIPT=$BUILD_ROOT_DIR/buildscript/tools/signclient.jar +BUILD_CROSS_COMPILE=$BUILD_ROOT_DIR/android/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android- +BUILD_JOB_NUMBER=`grep processor /proc/cpuinfo|wc -l` + +# Default Python version is 2.7 +mkdir -p bin +ln -sf /usr/bin/python2.7 ./bin/python +export PATH=$(pwd)/bin:$PATH + +KERNEL_DEFCONFIG=msm8976_sec_defconfig +DEBUG_DEFCONFIG=msm8976_sec_eng_defconfig +SELINUX_DEFCONFIG=selinux_defconfig +SELINUX_LOG_DEFCONFIG=selinux_log_defconfig +DMVERITY_DEFCONFIG=dmverity_defconfig + +while getopts "w:t:" flag; do + case $flag in + w) + BUILD_OPTION_HW_REVISION=$OPTARG + echo "-w : "$BUILD_OPTION_HW_REVISION"" + ;; + t) + TARGET_BUILD_VARIANT=$OPTARG + echo "-t : "$TARGET_BUILD_VARIANT"" + ;; + *) + echo "wrong 2nd param : "$OPTARG"" + exit -1 + ;; + esac +done + +shift $((OPTIND-1)) + +BUILD_COMMAND=$1 +SECURE_OPTION= +SEANDROID_OPTION= +if [ "$2" == "-B" ]; then + SECURE_OPTION=$2 +elif [ "$2" == "-E" ]; then + SEANDROID_OPTION=$2 +else + NO_JOB= +fi + +if [ "$3" == "-B" ]; then + SECURE_OPTION=$3 +elif [ "$3" == "-E" ]; then + SEANDROID_OPTION=$3 +else + NO_JOB= +fi + +MODEL=${BUILD_COMMAND%%_*} +TEMP=${BUILD_COMMAND#*_} +REGION=${TEMP%%_*} +CARRIER=${TEMP##*_} + +VARIANT=k${CARRIER} +PROJECT_NAME=${VARIANT} +VARIANT_DEFCONFIG=msm8976_sec_${MODEL}_${CARRIER}_defconfig + +CERTIFICATION=NONCERT + +case $1 in + clean) + echo "Not support... remove kernel out directory by yourself" + exit 1 + ;; + + *) + BOARD_KERNEL_BASE=0x80000000 + BOARD_KERNEL_PAGESIZE=2048 + BOARD_KERNEL_TAGS_OFFSET=0x01E00000 + BOARD_RAMDISK_OFFSET=0x02000000 +# BOARD_KERNEL_CMDLINE="console=null androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-5 androidboot.bootdevice=f9824900.sdhci" + BOARD_KERNEL_CMDLINE="console=null androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 earlyprintk" + mkdir -p $BUILD_KERNEL_OUT_DIR + ;; + +esac + +KERNEL_ZIMG=$BUILD_KERNEL_OUT_DIR/arch/arm64/boot/Image.gz +DTC=$BUILD_KERNEL_OUT_DIR/scripts/dtc/dtc + +FUNC_CLEAN_DTB() +{ + if ! [ -d $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts ] ; then + echo "no directory : "$BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts"" + else + echo "rm files in : "$BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/*.dtb"" + rm $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/*.dtb + fi +} + +INSTALLED_DTIMAGE_TARGET=${PRODUCT_OUT}/dt.img +DTBTOOL=$BUILD_KERNEL_DIR/tools/dtbTool + +FUNC_BUILD_DTIMAGE_TARGET() +{ + echo "" + echo "=================================" + echo "START : FUNC_BUILD_DTIMAGE_TARGET" + echo "=================================" + echo "" + echo "DT image target : $INSTALLED_DTIMAGE_TARGET" + + if ! [ -e $DTBTOOL ] ; then + if ! [ -d $BUILD_ROOT_DIR/android/out/host/linux-x86/bin ] ; then + mkdir -p $BUILD_ROOT_DIR/android/out/host/linux-x86/bin + fi + cp $BUILD_ROOT_DIR/kernel/tools/dtbTool $DTBTOOL + fi + + echo "$DTBTOOL -o $INSTALLED_DTIMAGE_TARGET -s $BOARD_KERNEL_PAGESIZE \ + -p $BUILD_KERNEL_OUT_DIR/scripts/dtc/ $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/" + $DTBTOOL -o $INSTALLED_DTIMAGE_TARGET -s $BOARD_KERNEL_PAGESIZE \ + -p $BUILD_KERNEL_OUT_DIR/scripts/dtc/ $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/ + + chmod a+r $INSTALLED_DTIMAGE_TARGET + + echo "" + echo "=================================" + echo "END : FUNC_BUILD_DTIMAGE_TARGET" + echo "=================================" + echo "" +} + +FUNC_BUILD_KERNEL() +{ + echo "" + echo "==============================================" + echo "START : FUNC_BUILD_KERNEL" + echo "==============================================" + echo "" + echo "build project="$PROJECT_NAME"" + echo "build common config="$KERNEL_DEFCONFIG "" + echo "build variant config="$VARIANT_DEFCONFIG "" + echo "build secure option="$SECURE_OPTION "" + echo "build SEANDROID option="$SEANDROID_OPTION "" + echo "build selinux defconfig="$SELINUX_DEFCONFIG "" + echo "build selinux log defconfig="$SELINUX_LOG_DEFCONFIG "" + echo "build tima defconfig="$TIMA_DEFCONFIG "" + + if [ "$BUILD_COMMAND" == "" ]; then + SECFUNC_PRINT_HELP; + exit -1; + fi + + FUNC_CLEAN_DTB + + make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm64 \ + CROSS_COMPILE=$BUILD_CROSS_COMPILE \ + VARIANT_DEFCONFIG=$VARIANT_DEFCONFIG \ + DEBUG_DEFCONFIG=$DEBUG_DEFCONFIG $KERNEL_DEFCONFIG \ + SELINUX_DEFCONFIG=$SELINUX_DEFCONFIG \ + SELINUX_LOG_DEFCONFIG=$SELINUX_LOG_DEFCONFIG || exit -1 + + make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm64 \ + CROSS_COMPILE=$BUILD_CROSS_COMPILE || exit -1 + + FUNC_BUILD_DTIMAGE_TARGET + + echo "" + echo "=================================" + echo "END : FUNC_BUILD_KERNEL" + echo "=================================" + echo "" +} + +FUNC_MKBOOTIMG() +{ + echo "" + echo "===================================" + echo "START : FUNC_MKBOOTIMG" + echo "===================================" + echo "" + MKBOOTIMGTOOL=$BUILD_ROOT_DIR/android/kernel/tools/mkbootimg + + if ! [ -e $MKBOOTIMGTOOL ] ; then + if ! [ -d $BUILD_ROOT_DIR/android/out/host/linux-x86/bin ] ; then + mkdir -p $BUILD_ROOT_DIR/android/out/host/linux-x86/bin + fi + cp $BUILD_ROOT_DIR/anroid/kernel/tools/mkbootimg $MKBOOTIMGTOOL + fi + + echo "Making boot.img ..." + echo " $MKBOOTIMGTOOL --kernel $KERNEL_ZIMG \ + --ramdisk $PRODUCT_OUT/ramdisk.img \ + --output $PRODUCT_OUT/boot.img \ + --cmdline "$BOARD_KERNEL_CMDLINE" \ + --base $BOARD_KERNEL_BASE \ + --pagesize $BOARD_KERNEL_PAGESIZE \ + --ramdisk_offset $BOARD_RAMDISK_OFFSET \ + --tags_offset $BOARD_KERNEL_TAGS_OFFSET \ + --dt $INSTALLED_DTIMAGE_TARGET" + + $MKBOOTIMGTOOL --kernel $KERNEL_ZIMG \ + --ramdisk $PRODUCT_OUT/ramdisk.img \ + --output $PRODUCT_OUT/boot.img \ + --cmdline "$BOARD_KERNEL_CMDLINE" \ + --base $BOARD_KERNEL_BASE \ + --pagesize $BOARD_KERNEL_PAGESIZE \ + --ramdisk_offset $BOARD_RAMDISK_OFFSET \ + --tags_offset $BOARD_KERNEL_TAGS_OFFSET \ + --dt $INSTALLED_DTIMAGE_TARGET + + if [ "$SEANDROID_OPTION" == "-E" ] ; then + FUNC_SEANDROID + fi + + if [ "$SECURE_OPTION" == "-B" ]; then + FUNC_SECURE_SIGNING + fi + + cd $PRODUCT_OUT + tar cvf boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar boot.img + + cd $BUILD_ROOT_DIR + if ! [ -d output ] ; then + mkdir -p output + fi + + echo "" + echo "=================================================" + echo "-->Note, copy to $BUILD_TOP_DIR/../output/ directory" + echo "=================================================" + cp $PRODUCT_OUT/boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar $BUILD_ROOT_DIR/output/boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar || exit -1 + cd ~ + + echo "" + echo "===================================" + echo "END : FUNC_MKBOOTIMG" + echo "===================================" + echo "" +} + +FUNC_SEANDROID() +{ + echo -n "SEANDROIDENFORCE" >> $PRODUCT_OUT/boot.img +} + +FUNC_SECURE_SIGNING() +{ + echo "java -jar $SECURE_SCRIPT -model $SIGN_MODEL -runtype ss_openssl_sha -input $PRODUCT_OUT/boot.img -output $PRODUCT_OUT/signed_boot.img" + openssl dgst -sha256 -binary $PRODUCT_OUT/boot.img > sig_32 + java -jar $SECURE_SCRIPT -runtype ss_openssl_sha -model $SIGN_MODEL -input sig_32 -output sig_256 + cat $PRODUCT_OUT/boot.img sig_256 > $PRODUCT_OUT/signed_boot.img + + mv -f $PRODUCT_OUT/boot.img $PRODUCT_OUT/unsigned_boot.img + mv -f $PRODUCT_OUT/signed_boot.img $PRODUCT_OUT/boot.img + + CERTIFICATION=CERT +} + +SECFUNC_PRINT_HELP() +{ + echo -e '\E[33m' + echo "Help" + echo "$0 \$1 \$2 \$3" + echo " \$1 : " + echo " for A9XLTE CHN OPEN use a9xlte_chn" + echo " for A9XLTE CHN LDU use a9xlte_chnldu" + echo " for A9XPROLTE CHN OPEN use a9xprolte_chn" + echo " for C9LTE CHN OPEN use c9lte_chn" + echo " for GTS28VELTE EUR OPEN use gts28velte_eur" + echo " for GTS28VELTE CHN OPEN use gts28velte_chn" + echo " for GTS210VELTE EUR OPEN use gts210velte_eur" + echo " for GTS28VEWIFI EUR OPEN use gts28vewifi_eur" + echo " \$2 : " + echo " -B or Nothing (-B : Secure Binary)" + echo " \$3 : " + echo " -E or Nothing (-E : SEANDROID Binary)" + echo -e '\E[0m' +} + + +# MAIN FUNCTION +rm -rf ./build.log +( + START_TIME=`date +%s` + + FUNC_BUILD_KERNEL + #FUNC_RAMDISK_EXTRACT_N_COPY + FUNC_MKBOOTIMG + + END_TIME=`date +%s` + + let "ELAPSED_TIME=$END_TIME-$START_TIME" + echo "Total compile time is $ELAPSED_TIME seconds" +) 2>&1 | tee -a ./build.log diff --git a/drivers/net/wireless/qcacld-2.0/CORE/SERVICES/HIF/sdio/linux/native_sdio/src/hif.c b/drivers/net/wireless/qcacld-2.0/CORE/SERVICES/HIF/sdio/linux/native_sdio/src/hif.c index e4d8c323153f..3f80e52f3dd1 100644 --- a/drivers/net/wireless/qcacld-2.0/CORE/SERVICES/HIF/sdio/linux/native_sdio/src/hif.c +++ b/drivers/net/wireless/qcacld-2.0/CORE/SERVICES/HIF/sdio/linux/native_sdio/src/hif.c @@ -2760,6 +2760,7 @@ int hif_reset_target(HIF_DEVICE *hif_device) ("AR6000: %s invalid HIF DEVICE \n", __func__)); return -ENODEV; } + sdio_claim_host(hif_device->func); /* Disable sdio func->pull down WLAN_EN-->pull down DAT_2 line */ ret = mmc_power_save_host(hif_device->func->card->host); if(ret) { @@ -2778,6 +2779,7 @@ int hif_reset_target(HIF_DEVICE *hif_device) } done: + sdio_release_host(hif_device->func); return ret; } #endif diff --git a/drivers/sensorhub/stm/adpd142.c b/drivers/sensorhub/stm/adpd142.c index 7e45b7d84897..24ba7d5b97bf 100644 --- a/drivers/sensorhub/stm/adpd142.c +++ b/drivers/sensorhub/stm/adpd142.c @@ -389,7 +389,7 @@ cmd_parsing(const char *buf, unsigned short cnt, unsigned short *data) } if (parsing_cnt < cnt) - *(data + parsing_cnt) = val; + *(data + parsing_cnt) = (unsigned short)val; else break; parsing_cnt++; diff --git a/drivers/sensorhub/stm/adpd143.c b/drivers/sensorhub/stm/adpd143.c index 0b453feeae89..2247aefbf37d 100644 --- a/drivers/sensorhub/stm/adpd143.c +++ b/drivers/sensorhub/stm/adpd143.c @@ -478,7 +478,7 @@ cmd_parsing(const char *buf, unsigned short cnt, unsigned short *data) } if (parsing_cnt < cnt) - *(data + parsing_cnt) = val; + *(data + parsing_cnt) = (unsigned short)val; else break; parsing_cnt++; diff --git a/drivers/video/msm/mdss/samsung/ss_dsi_panel_common.c b/drivers/video/msm/mdss/samsung/ss_dsi_panel_common.c index c17ed3e92c39..de113ca2ae9d 100644 --- a/drivers/video/msm/mdss/samsung/ss_dsi_panel_common.c +++ b/drivers/video/msm/mdss/samsung/ss_dsi_panel_common.c @@ -4153,7 +4153,7 @@ static void load_tuning_file(struct device *dev, char *filename) filp = filp_open(filename, O_RDONLY, 0); if (IS_ERR(filp)) { printk(KERN_ERR "%s File open failed\n", __func__); - return; + goto err; } l = filp->f_path.dentry->d_inode->i_size; @@ -4163,7 +4163,7 @@ static void load_tuning_file(struct device *dev, char *filename) if (dp == NULL) { LCD_INFO("Can't not alloc memory for tuning file load\n"); filp_close(filp, current->files); - return; + goto err; } pos = 0; memset(dp, 0, l); @@ -4176,7 +4176,7 @@ static void load_tuning_file(struct device *dev, char *filename) LCD_INFO("vfs_read() filed ret : %d\n", ret); kfree(dp); filp_close(filp, current->files); - return; + goto err; } filp_close(filp, current->files); @@ -4186,6 +4186,10 @@ static void load_tuning_file(struct device *dev, char *filename) sending_tune_cmd(dev, dp, l); kfree(dp); + + return; +err: + set_fs(fs); } static ssize_t tuning_show(struct device *dev, @@ -4280,7 +4284,8 @@ int mdss_samsung_read_otherline_panel_data(struct samsung_display_driver_data *v if (!IS_ERR_OR_NULL(vdd->panel_func.set_panel_fab_type)) vdd->panel_func.set_panel_fab_type(BASIC_FB_PANLE_TYPE);/*to work as original line panel*/ - return -ENOENT; + ret = -ENOENT; + goto err; } l = filp->f_path.dentry->d_inode->i_size; @@ -4290,7 +4295,8 @@ int mdss_samsung_read_otherline_panel_data(struct samsung_display_driver_data *v if (dp == NULL) { LCD_INFO("Can't not alloc memory for tuning file load\n"); filp_close(filp, current->files); - return -1; + ret = -1; + goto err; } pos = 0; memset(dp, 0, l); @@ -4303,7 +4309,8 @@ int mdss_samsung_read_otherline_panel_data(struct samsung_display_driver_data *v LCD_INFO("vfs_read() filed ret : %d\n", ret); kfree(dp); filp_close(filp, current->files); - return -1; + ret = -1; + goto err; } if (!IS_ERR_OR_NULL(vdd->panel_func.parsing_otherline_pdata)) @@ -4315,6 +4322,9 @@ int mdss_samsung_read_otherline_panel_data(struct samsung_display_driver_data *v kfree(dp); + return ret; +err: + set_fs(fs); return ret; } diff --git a/fs/sdfat/api.h b/fs/sdfat/api.h index d842479f70cf..26bc8168b877 100644 --- a/fs/sdfat/api.h +++ b/fs/sdfat/api.h @@ -161,6 +161,13 @@ typedef struct { u32 cache_valid_id; // for avoiding the race between alloc and free } EXTENT_T; +/* first empty entry hint information */ +typedef struct { + s32 eidx; // entry index of a directory + s32 count; // count of continuous empty entry + CHAIN_T cur; // the cluster that first empty slot exists in +} HINT_FEMP_T; + /* file id structure */ typedef struct { CHAIN_T dir; @@ -176,6 +183,7 @@ typedef struct { EXTENT_T extent; // extent cache for a file HINT_T hint_bmap; // hint for cluster last accessed HINT_T hint_stat; // hint for entry index we try to lookup next time + HINT_FEMP_T hint_femp; // hint for first empty entry } FILE_ID_T; typedef struct { @@ -195,14 +203,6 @@ typedef struct { DENTRY_NAMEBUF_T NameBuf; } DIR_ENTRY_T; -/* unused entry hint information */ -typedef struct { - u32 dir; - s32 entry; - s32 n_entry; - CHAIN_T clu; -} UENTRY_T; - /* cache information */ typedef struct __cache_entry { struct __cache_entry *next; @@ -230,7 +230,7 @@ typedef struct { s32 (*count_used_clusters)(struct super_block *sb, u32* ret_count); s32 (*init_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type,u32 start_clu, u64 size); s32 (*init_ext_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 num_entries, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname); - s32 (*find_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, HINT_T *hint_stat, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type); + s32 (*find_dir_entry)(struct super_block *sb, FILE_ID_T *fid, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type); s32 (*delete_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 offset, s32 num_entries); void (*get_uniname_from_ext_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u16 *uniname); s32 (*count_ext_entries)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, DENTRY_T *p_entry); @@ -280,7 +280,6 @@ typedef struct __FS_INFO_T { u32 clu_srch_ptr; // cluster search pointer u32 used_clusters; // number of used clusters - UENTRY_T hint_uentry; // unused entry hint information u32 prev_eio; // block device operation error flag diff --git a/fs/sdfat/core.c b/fs/sdfat/core.c index 0763812edbde..3594eda894a7 100644 --- a/fs/sdfat/core.c +++ b/fs/sdfat/core.c @@ -283,6 +283,7 @@ out: static s32 __find_last_cluster(struct super_block *sb, CHAIN_T *p_chain, u32* ret_clu) { u32 clu, next; + s32 count = 0; next = p_chain->dir; if (p_chain->flags == 0x03) { @@ -291,11 +292,20 @@ static s32 __find_last_cluster(struct super_block *sb, CHAIN_T *p_chain, u32* re } do { + count++; clu = next; if (fat_ent_get_safe(sb, clu, &next)) return -EIO; } while (!IS_CLUS_EOF(next)); - + + if (p_chain->size != count) { + sdfat_fs_error(sb, "bogus directory size " + "(clus : ondisk(%d) != counted(%d))", + p_chain->size, count); + sdfat_debug_bug_on(1); + return -EIO; + } + *ret_clu = clu; return 0; } @@ -577,6 +587,13 @@ s32 walk_fat_chain(struct super_block *sb, CHAIN_T *p_dir, s32 byte_offset, u32 while (clu_offset > 0) { if (get_next_clus_safe(sb, &cur_clu)) return -EIO; + if (IS_CLUS_EOF(cur_clu)) { + sdfat_fs_error(sb, "invalid dentry access " + "beyond EOF (clu : %u, eidx : %d)", + p_dir->dir, + byte_offset >> DENTRY_SIZE_BITS); + return -EIO; + } clu_offset--; } } @@ -653,8 +670,11 @@ DENTRY_T *get_dentry_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u return (DENTRY_T *)(buf + off); } /* end of get_dentry_in_dir */ +/* used only in search empty_slot() */ +#define CNT_UNUSED_NOHIT (-1) +#define CNT_UNUSED_HIT (-2) /* search EMPTY CONTINUOUS "num_entries" entries */ -static s32 search_empty_slot(struct super_block *sb, CHAIN_T *p_dir, s32 num_entries) +static s32 search_empty_slot(struct super_block *sb, HINT_FEMP_T *hint_femp, CHAIN_T *p_dir, s32 num_entries) { s32 i, dentry, num_empty = 0; s32 dentries_per_clu; @@ -668,22 +688,33 @@ static s32 search_empty_slot(struct super_block *sb, CHAIN_T *p_dir, s32 num_ent else dentries_per_clu = fsi->dentries_per_clu; - if (fsi->hint_uentry.dir == p_dir->dir) { - MMSG("%s: uentry HIT (clu:0x%08x ent:%d)\n", __func__, - fsi->hint_uentry.clu.dir, fsi->hint_uentry.entry); - if (fsi->hint_uentry.entry == -1) - return -ENOSPC; + ASSERT(-1 <= hint_femp->eidx); - clu.dir = fsi->hint_uentry.clu.dir; - clu.size = fsi->hint_uentry.clu.size; - clu.flags = fsi->hint_uentry.clu.flags; + if (hint_femp->eidx != -1) { + clu.dir = hint_femp->cur.dir; + clu.size = hint_femp->cur.size; + clu.flags = hint_femp->cur.flags; - dentry = fsi->hint_uentry.entry; + dentry = hint_femp->eidx; + + if (num_entries <= hint_femp->count) { + IMSG("%s: empty slot(HIT) - found " + "(clu : 0x%08x eidx : %d)\n", + __func__, hint_femp->cur.dir, hint_femp->eidx); + hint_femp->eidx = -1; + + if (fsi->vol_type == EXFAT) + return dentry; + + return dentry + (num_entries - 1); + } + IMSG("%s: empty slot(HIT) - search from " + "(clu : 0x%08x eidx : %d)\n", + __func__, hint_femp->cur.dir, hint_femp->eidx); } else { - MMSG("%s: uentry MISS (clu:0x%08x => 0x%08x)\n", __func__, - fsi->hint_uentry.dir, p_dir->dir); - fsi->hint_uentry.dir = CLUS_EOF; - fsi->hint_uentry.entry = -1; + IMSG("%s: empty slot(MISS) - search from " + "(clu:0x%08x eidx : 0)\n", + __func__, p_dir->dir); clu.dir = p_dir->dir; clu.size = p_dir->size; @@ -706,36 +737,49 @@ static s32 search_empty_slot(struct super_block *sb, CHAIN_T *p_dir, s32 num_ent type = fsi->fs_func->get_entry_type(ep); - if (type == TYPE_UNUSED) { + if ((type == TYPE_UNUSED) || (type == TYPE_DELETED)) { num_empty++; - if (fsi->hint_uentry.entry == -1) { - fsi->hint_uentry.dir = p_dir->dir; - fsi->hint_uentry.entry = dentry; - fsi->hint_uentry.n_entry = INT_MAX; + if (hint_femp->eidx == -1) { + hint_femp->eidx = dentry; + hint_femp->count = CNT_UNUSED_NOHIT; - fsi->hint_uentry.clu.dir = clu.dir; - fsi->hint_uentry.clu.size = clu.size; - fsi->hint_uentry.clu.flags = clu.flags; + hint_femp->cur.dir = clu.dir; + hint_femp->cur.size = clu.size; + hint_femp->cur.flags = clu.flags; + } + + if ((type == TYPE_UNUSED) && + (hint_femp->count != CNT_UNUSED_HIT)) { + hint_femp->count = CNT_UNUSED_HIT; } - } else if (type == TYPE_DELETED) { - num_empty++; } else { - /* TODO : Check whether bogus dentry exists or not - * after unused dentry - * hint_uentry means empty slot not TYPE_UNUSED - */ + if ((hint_femp->eidx != -1) && + (hint_femp->count == CNT_UNUSED_HIT)) { + /* unused empty group means + * an empty group which includes + * unused dentry + */ + sdfat_fs_error(sb, + "found bogus dentry(%d) " + "beyond unused empty group(%d) " + "(start_clu : %u, cur_clu : %u)\n", + dentry, hint_femp->eidx, p_dir->dir, + clu.dir); + return -EIO; + } + num_empty = 0; + hint_femp->eidx = -1; } if (num_empty >= num_entries) { - /* INVALIDATE */ - fsi->hint_uentry.dir = CLUS_EOF; - fsi->hint_uentry.entry = -1; + /* found and invalidate hint_femp */ + hint_femp->eidx = -1; if (fsi->vol_type == EXFAT) return (dentry - (num_entries-1)); - else - return dentry; + + return dentry; } } @@ -769,23 +813,35 @@ static s32 find_empty_entry(struct inode *inode, CHAIN_T *p_dir, s32 num_entries struct super_block *sb = inode->i_sb; FS_INFO_T *fsi = &(SDFAT_SB(sb)->fsi); FILE_ID_T *fid = &(SDFAT_I(inode)->fid); + HINT_FEMP_T hint_femp; + + hint_femp.eidx = -1; + + ASSERT(-1 <= fid->hint_femp.eidx); + + if (fid->hint_femp.eidx != -1) { + memcpy(&hint_femp, &fid->hint_femp, sizeof(HINT_FEMP_T)); + fid->hint_femp.eidx = -1; + } /* FAT16 root_dir */ if (IS_CLUS_FREE(p_dir->dir)) - return search_empty_slot(sb, p_dir, num_entries); + return search_empty_slot(sb, &hint_femp, p_dir, num_entries); - while ((dentry = search_empty_slot(sb, p_dir, num_entries)) < 0) { + while ((dentry = search_empty_slot(sb, &hint_femp, p_dir, num_entries)) < 0) { if (dentry == -EIO) break; - if (fsi->vol_type == EXFAT) { - if (p_dir->dir != fsi->root_dir) - size = i_size_read(inode); - } else if ((fid->size >> DENTRY_SIZE_BITS) >= MAX_FAT_DENTRIES) { +// if (fsi->vol_type == EXFAT) { +// if (p_dir->dir != fsi->root_dir) +// size = i_size_read(inode); +// } else if ((fid->size >> DENTRY_SIZE_BITS) >= MAX_FAT_DENTRIES) { + if ((fid->size >> DENTRY_SIZE_BITS) >= MAX_FAT_DENTRIES) { /* FAT spec allows a dir to grow upto 65536 dentries */ return -ENOSPC; } + /* we trust p_dir->size regardless of FAT type */ if (__find_last_cluster(sb, p_dir, &last_clu)) return -EIO; @@ -793,7 +849,7 @@ static s32 find_empty_entry(struct inode *inode, CHAIN_T *p_dir, s32 num_entries * Allocate new cluster to this directory */ clu.dir = last_clu + 1; - clu.size = 0; + clu.size = 0; /* UNUSED */ clu.flags = p_dir->flags; /* (0) check if there are reserved clusters @@ -819,46 +875,49 @@ static s32 find_empty_entry(struct inode *inode, CHAIN_T *p_dir, s32 num_entries */ chain_cont_cluster(sb, p_dir->dir, p_dir->size); p_dir->flags = 0x01; - fsi->hint_uentry.clu.flags = 0x01; + hint_femp.cur.flags = 0x01; } if (clu.flags == 0x01) if (fat_ent_set(sb, last_clu, clu.dir)) return -EIO; - if (fsi->hint_uentry.entry == -1) { - fsi->hint_uentry.dir = p_dir->dir; - fsi->hint_uentry.entry = p_dir->size << (fsi->cluster_size_bits - DENTRY_SIZE_BITS); + if (hint_femp.eidx == -1) { + /* the special case that new dentry + * should be allocated from the start of new cluster + */ - fsi->hint_uentry.clu.dir = clu.dir; - fsi->hint_uentry.clu.size = 0; - fsi->hint_uentry.clu.flags = clu.flags; + hint_femp.eidx = p_dir->size << + (fsi->cluster_size_bits - DENTRY_SIZE_BITS); + hint_femp.count = fsi->dentries_per_clu; + + hint_femp.cur.dir = clu.dir; + hint_femp.cur.size = 0; + hint_femp.cur.flags = clu.flags; } - fsi->hint_uentry.clu.size++; + hint_femp.cur.size++; p_dir->size++; + size = (p_dir->size << fsi->cluster_size_bits); /* (3) update the directory entry */ - if (fsi->vol_type == EXFAT) { - if (p_dir->dir != fsi->root_dir) { - size += fsi->cluster_size; + if ((fsi->vol_type == EXFAT) && (p_dir->dir != fsi->root_dir)) { + ep = get_dentry_in_dir(sb, + &(fid->dir), fid->entry+1, §or); + if (!ep) + return -EIO; + fsi->fs_func->set_entry_size(ep, size); + fsi->fs_func->set_entry_flag(ep, p_dir->flags); + if (dcache_modify(sb, sector)) + return -EIO; - ep = get_dentry_in_dir(sb, &(fid->dir), fid->entry+1, §or); - if (!ep) - return -EIO; - fsi->fs_func->set_entry_size(ep, size); - fsi->fs_func->set_entry_flag(ep, p_dir->flags); - if (dcache_modify(sb, sector)) - return -EIO; - - if (update_dir_chksum(sb, &(fid->dir), fid->entry)) - return -EIO; - } + if (update_dir_chksum(sb, &(fid->dir), fid->entry)) + return -EIO; } /* directory inode should be updated in here */ - i_size_write(inode, i_size_read(inode)+fsi->cluster_size); + i_size_write(inode, (loff_t)size); SDFAT_I(inode)->i_size_ondisk += fsi->cluster_size; SDFAT_I(inode)->i_size_aligned += fsi->cluster_size; - SDFAT_I(inode)->fid.size += fsi->cluster_size; + SDFAT_I(inode)->fid.size = size; SDFAT_I(inode)->fid.flags = p_dir->flags; inode->i_blocks += 1 << (fsi->cluster_size_bits - sb->s_blocksize_bits); } @@ -1158,7 +1217,8 @@ static s32 __resolve_path(struct inode *inode, const u8 *path, CHAIN_T *p_dir, U if ((lossy && !lookup) || !namelen) return -EINVAL; - fid->size = i_size_read(inode); + sdfat_debug_bug_on(fid->size != i_size_read(inode)); +// fid->size = i_size_read(inode); p_dir->dir = fid->start_clu; p_dir->size = (s32)(fid->size >> fsi->cluster_size_bits); @@ -1215,15 +1275,8 @@ static s32 create_dir(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname if (ret) return ret; - if (fsi->vol_type == EXFAT) { - size = fsi->cluster_size; - } else { - /* for the consistency of DIR entry size (non-zero) */ - if (fsi->vol_type == FAT32) - size = fsi->cluster_size; - else - size = 0; - + size = fsi->cluster_size; + if (fsi->vol_type != EXFAT) { /* initialize the . and .. entry Information for . points to itself Information for .. points to parent dir */ @@ -1282,6 +1335,7 @@ static s32 create_dir(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname fid->version = 0; fid->hint_stat.eidx = 0; fid->hint_stat.clu = fid->start_clu; + fid->hint_femp.eidx = -1; return 0; } /* end of create_dir */ @@ -1331,6 +1385,7 @@ static s32 create_file(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uninam fid->version = 0; fid->hint_stat.eidx = 0; fid->hint_stat.clu = fid->start_clu; + fid->hint_femp.eidx = -1; return 0; } /* end of create_file */ @@ -1883,11 +1938,12 @@ s32 fscore_lookup(struct inode *inode, u8 *path, FILE_ID_T *fid) dir_fid->hint_stat.clu = dir.dir; dir_fid->hint_stat.eidx = 0; dir_fid->version = (u32)(inode->i_version & 0xffffffff); + dir_fid->hint_femp.eidx = -1; } /* search the file name for directories */ - dentry = fsi->fs_func->find_dir_entry(sb, &dir, &dir_fid->hint_stat, - &uni_name, num_entries, &dos_name, TYPE_ALL); + dentry = fsi->fs_func->find_dir_entry(sb, dir_fid, &dir, &uni_name, + num_entries, &dos_name, TYPE_ALL); if ((dentry < 0) && (dentry != -EEXIST)) return dentry; /* -error value */ @@ -1934,6 +1990,19 @@ s32 fscore_lookup(struct inode *inode, u8 *path, FILE_ID_T *fid) fid->start_clu = fsi->fs_func->get_entry_clu0(ep2); } + if ((fid->type == TYPE_DIR) && (fsi->vol_type != EXFAT)) { + s32 num_clu = 0; + CHAIN_T tmp_dir; + + tmp_dir.dir = fid->start_clu; + tmp_dir.flags = fid->flags; + tmp_dir.size = 0; /* UNUSED */ + + if (__count_num_clusters(sb, &tmp_dir, &num_clu)) + return -EIO; + fid->size = (u64)num_clu << fsi->cluster_size_bits; + } + /* FOR GRACEFUL ERROR HANDLING */ if (IS_CLUS_FREE(fid->start_clu)) { sdfat_fs_error(sb, @@ -1952,6 +2021,7 @@ s32 fscore_lookup(struct inode *inode, u8 *path, FILE_ID_T *fid) fid->version = 0; fid->hint_stat.eidx = 0; fid->hint_stat.clu = fid->start_clu; + fid->hint_femp.eidx = -1; TMSG("%s exited successfully\n", __func__); return 0; @@ -2530,6 +2600,7 @@ s32 fscore_truncate(struct inode *inode, u64 old_size, u64 new_size) /* hint_stat will be used if this is directory. */ fid->hint_stat.eidx = 0; fid->hint_stat.clu = fid->start_clu; + fid->hint_femp.eidx = -1; /* free the clusters */ if (fsi->fs_func->free_cluster(sb, &clu, evict)) @@ -2779,8 +2850,13 @@ out: } /* end of fscore_remove */ -/* get the information of a given file +/* + * Get the information of a given file * REMARK : This function does not need any file name on linux + * + * info.Size means the value saved on disk. + * But root directory doesn`t have real dentry, + * so the size of root directory returns calculated one exceptively. */ s32 fscore_read_inode(struct inode *inode, DIR_ENTRY_T *info) { @@ -2810,11 +2886,7 @@ s32 fscore_read_inode(struct inode *inode, DIR_ENTRY_T *info) dir.dir = fsi->root_dir; dir.flags = 0x01; - dir.size = 0; - /* - * NOTE : - * If "dir.flags" has 0x01, "dir.size" is meaningles. - */ + dir.size = 0; /* UNUSED */ /* FAT16 root_dir */ if (IS_CLUS_FREE(fsi->root_dir)) { @@ -2888,15 +2960,15 @@ s32 fscore_read_inode(struct inode *inode, DIR_ENTRY_T *info) dir.size = fid->size >> fsi->cluster_size_bits; /* * NOTE : - * If "dir.flags" has 0x01, "dir.size" is meaningles. + * If "dir.flags" has 0x01, "dir.size" is meaningless. */ - if (info->Size == 0) { - s32 num_clu; - if (__count_num_clusters(sb, &dir, &num_clu)) - return -EIO; - info->Size = (u64)num_clu << fsi->cluster_size_bits; - } +// if (info->Size == 0) { +// s32 num_clu; +// if (__count_num_clusters(sb, &dir, &num_clu)) +// return -EIO; +// info->Size = (u64)num_clu << fsi->cluster_size_bits; +// } count = __count_dos_name_entries(sb, &dir, TYPE_DIR, &dotcnt); if (count < 0) @@ -3351,7 +3423,7 @@ out: /* read a directory entry from the opened directory */ s32 fscore_readdir(struct inode *inode, DIR_ENTRY_T *dir_entry) { - s32 i, dentry, clu_offset; + s32 i, clu_offset; s32 dentries_per_clu, dentries_per_clu_bits = 0; u32 type, sector; CHAIN_T dir, clu; @@ -3361,6 +3433,7 @@ s32 fscore_readdir(struct inode *inode, DIR_ENTRY_T *dir_entry) struct super_block *sb = inode->i_sb; FS_INFO_T *fsi = &(SDFAT_SB(sb)->fsi); FILE_ID_T *fid = &(SDFAT_I(inode)->fid); + s32 dentry = (s32) fid->rwoffset; /* check if the given file ID is opened */ if (fid->type != TYPE_DIR) @@ -3374,10 +3447,9 @@ s32 fscore_readdir(struct inode *inode, DIR_ENTRY_T *dir_entry) dir.dir = fid->start_clu; dir.size = (s32)(fid->size >> fsi->cluster_size_bits); dir.flags = fid->flags; + sdfat_debug_bug_on(dentry >= (dir.size * fsi->dentries_per_clu)); } - dentry = (s32) fid->rwoffset; - if (IS_CLUS_FREE(dir.dir)) { /* FAT16 root_dir */ dentries_per_clu = fsi->dentries_in_root; @@ -3513,7 +3585,7 @@ s32 fscore_readdir(struct inode *inode, DIR_ENTRY_T *dir_entry) dir_entry->NameBuf.lfn[0] = '\0'; - fid->rwoffset = (s64) ++dentry; + fid->rwoffset = (s64) dentry; return 0; } /* end of fscore_readdir */ diff --git a/fs/sdfat/core_exfat.c b/fs/sdfat/core_exfat.c index d5c711859807..35b79c418449 100644 --- a/fs/sdfat/core_exfat.c +++ b/fs/sdfat/core_exfat.c @@ -711,21 +711,28 @@ static s32 __extract_uni_name_from_name_entry(NAME_DENTRY_T *ep, u16 *uniname, s } /* end of __extract_uni_name_from_name_entry */ +#define DIRENT_STEP_FILE (0) +#define DIRENT_STEP_STRM (1) +#define DIRENT_STEP_NAME (2) +#define DIRENT_STEP_SECD (3) + /* return values of exfat_find_dir_entry() * >= 0 : return dir entiry position with the name in dir * -EEXIST : (root dir, ".") it is the root dir itself * -ENOENT : entry with the name does not exist * -EIO : I/O error */ -static s32 exfat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, HINT_T *hint_stat, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *unused, u32 type) +static s32 exfat_find_dir_entry(struct super_block *sb, FILE_ID_T *fid, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *unused, u32 type) { - s32 i, rewind = 0, dentry = 0, end_eidx = 0, num_ext_entries = 0, len; - s32 order = 0, is_feasible_entry = false; + s32 i, rewind = 0, dentry = 0, end_eidx = 0, num_ext = 0, len; + s32 order, step, name_len; s32 dentries_per_clu, num_empty = 0; u32 entry_type; u16 entry_uniname[16], *uniname = NULL, unichar; CHAIN_T clu; DENTRY_T *ep; + HINT_T *hint_stat = &fid->hint_stat; + HINT_FEMP_T candi_empty; FILE_DENTRY_T *file_ep; STRM_DENTRY_T *strm_ep; NAME_DENTRY_T *name_ep; @@ -751,10 +758,10 @@ static s32 exfat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, HINT_T * end_eidx = dentry; } - fsi->hint_uentry.dir = p_dir->dir; - fsi->hint_uentry.entry = -1; - + candi_empty.eidx = -1; rewind: + order = 0; + step = DIRENT_STEP_FILE; while (!IS_CLUS_EOF(clu.dir)) { i = dentry & (dentries_per_clu - 1); for (; i < dentries_per_clu; i++, dentry++) { @@ -768,73 +775,104 @@ rewind: entry_type = exfat_get_entry_type(ep); if ((entry_type == TYPE_UNUSED) || (entry_type == TYPE_DELETED)) { - is_feasible_entry = false; - - if (fsi->hint_uentry.entry == -1) { - num_empty++; + step = DIRENT_STEP_FILE; + num_empty++; + if (candi_empty.eidx == -1) { if (num_empty == 1) { - fsi->hint_uentry.clu.dir = clu.dir; - fsi->hint_uentry.clu.size = clu.size; - fsi->hint_uentry.clu.flags = clu.flags; + candi_empty.cur.dir = clu.dir; + candi_empty.cur.size = clu.size; + candi_empty.cur.flags = clu.flags; } - if ((num_empty >= num_entries) || (entry_type == TYPE_UNUSED)) { - fsi->hint_uentry.entry = dentry - (num_empty-1); + + if (num_empty >= num_entries) { + candi_empty.eidx = dentry - (num_empty - 1); + ASSERT(0 <= candi_empty.eidx); + candi_empty.count = num_empty; + + if ((fid->hint_femp.eidx == -1) || + (candi_empty.eidx <= fid->hint_femp.eidx)) { + memcpy(&fid->hint_femp, + &candi_empty, + sizeof(HINT_FEMP_T)); + } } } - if (entry_type == TYPE_UNUSED) { + if (entry_type == TYPE_UNUSED) goto not_found; + continue; + } + + num_empty = 0; + candi_empty.eidx = -1; + + if ((entry_type == TYPE_FILE) || (entry_type == TYPE_DIR)) { + step = DIRENT_STEP_FILE; + if ((type == TYPE_ALL) || (type == entry_type)) { + file_ep = (FILE_DENTRY_T *) ep; + num_ext = file_ep->num_ext; + step = DIRENT_STEP_STRM; } - } else { - num_empty = 0; + continue; + } - if ((entry_type == TYPE_FILE) || (entry_type == TYPE_DIR)) { - if ((type == TYPE_ALL) || (type == entry_type)) { - file_ep = (FILE_DENTRY_T *) ep; - num_ext_entries = file_ep->num_ext; - is_feasible_entry = true; - } else { - is_feasible_entry = false; + if (entry_type == TYPE_STREAM) { + if (step != DIRENT_STEP_STRM) { + step = DIRENT_STEP_FILE; + continue; + } + step = DIRENT_STEP_FILE; + strm_ep = (STRM_DENTRY_T *) ep; + if ((p_uniname->name_hash == le16_to_cpu(strm_ep->name_hash)) && + (p_uniname->name_len == strm_ep->name_len)) { + step = DIRENT_STEP_NAME; + order = 1; + name_len = 0; + } + continue; + } + + if (entry_type == TYPE_EXTEND) { + if (step != DIRENT_STEP_NAME) { + step = DIRENT_STEP_FILE; + continue; + } + name_ep = (NAME_DENTRY_T *) ep; + + if ((++order) == 2) + uniname = p_uniname->name; + else + uniname += 15; + + len = __extract_uni_name_from_name_entry(name_ep, entry_uniname, order); + name_len += len; + + unichar = *(uniname+len); + *(uniname+len) = 0x0; + + if (nls_cmp_uniname(sb, uniname, entry_uniname)) { + step = DIRENT_STEP_FILE; + } else if (name_len == p_uniname->name_len) { + if (order == num_ext) { + //fid->hint_femp.eidx = -1; + goto found; } - } else if (entry_type == TYPE_STREAM) { - if (is_feasible_entry) { - strm_ep = (STRM_DENTRY_T *) ep; - if ((p_uniname->name_hash == le16_to_cpu(strm_ep->name_hash)) && - (p_uniname->name_len == strm_ep->name_len)) { - order = 1; - } else { - is_feasible_entry = false; - } - } - } else if (entry_type == TYPE_EXTEND) { - if (is_feasible_entry) { - name_ep = (NAME_DENTRY_T *) ep; + step = DIRENT_STEP_SECD; + } - if ((++order) == 2) - uniname = p_uniname->name; - else - uniname += 15; + *(uniname+len) = unichar; + continue; + } - len = __extract_uni_name_from_name_entry(name_ep, entry_uniname, order); - - unichar = *(uniname+len); - *(uniname+len) = 0x0; - - if (nls_cmp_uniname(sb, uniname, entry_uniname)) { - is_feasible_entry = false; - } else if (order == num_ext_entries) { - fsi->hint_uentry.dir = CLUS_EOF; - fsi->hint_uentry.entry = -1; - goto found; - } - - *(uniname+len) = unichar; - } - } else { - is_feasible_entry = false; + if (entry_type & (TYPE_CRITICAL_SEC | TYPE_BENIGN_SEC)) { + if (step == DIRENT_STEP_SECD) { + if (++order == num_ext) + goto found; + continue; } } + step = DIRENT_STEP_FILE; } if (clu.flags == 0x03) { @@ -856,6 +894,9 @@ not_found: rewind = 1; dentry = 0; clu.dir = p_dir->dir; + /* reset empty hint */ + num_empty = 0; + candi_empty.eidx = -1; goto rewind; } @@ -881,13 +922,13 @@ found: /* just initialized hint_stat */ hint_stat->clu = p_dir->dir; hint_stat->eidx = 0; - return (dentry - num_ext_entries); + return (dentry - num_ext); } } hint_stat->clu = clu.dir; hint_stat->eidx = dentry + 1; - return (dentry - num_ext_entries); + return (dentry - num_ext); } /* end of exfat_find_dir_entry */ /* returns -EIO on error */ diff --git a/fs/sdfat/core_fat.c b/fs/sdfat/core_fat.c index d5aed19395f2..4bbfd226429c 100644 --- a/fs/sdfat/core_fat.c +++ b/fs/sdfat/core_fat.c @@ -608,15 +608,17 @@ static inline s32 __get_dentries_per_clu(FS_INFO_T *fsi, s32 clu) return fsi->dentries_per_clu; } -static s32 fat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, HINT_T *hint_stat, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type) +static s32 fat_find_dir_entry(struct super_block *sb, FILE_ID_T *fid, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type) { s32 i, rewind = 0, dentry = 0, end_eidx = 0; s32 chksum = 0, lfn_ord = 0, lfn_len = 0; - s32 dentries_per_clu; + s32 dentries_per_clu, num_empty = 0; u32 entry_type; u16 entry_uniname[14], *uniname = NULL; CHAIN_T clu; DENTRY_T *ep; + HINT_T *hint_stat = &fid->hint_stat; + HINT_FEMP_T candi_empty; FS_INFO_T *fsi = &(SDFAT_SB(sb)->fsi); /* @@ -634,6 +636,8 @@ static s32 fat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, HINT_T *hi end_eidx = dentry; } + candi_empty.eidx = -1; + MMSG("lookup dir= %s\n", p_dosname->name); rewind: while (!IS_CLUS_EOF(clu.dir)) { @@ -659,6 +663,9 @@ rewind: s32 len = 13; u16 unichar; + num_empty = 0; + candi_empty.eidx = -1; + /* check whether new lfn or not */ if (cur_ord & MSDOS_LAST_LFN) { cur_ord &= ~(MSDOS_LAST_LFN); @@ -735,6 +742,10 @@ rewind: u32 cur_chksum = (s32)calc_chksum_1byte( (void *) dos_ep->name, DOS_NAME_LENGTH, 0); + + num_empty = 0; + candi_empty.eidx = -1; + MMSG("checking dir= %c%c%c%c%c%c%c%c%c%c%c\n", dos_ep->name[0], dos_ep->name[1], dos_ep->name[2], dos_ep->name[3], @@ -763,13 +774,35 @@ rewind: } /* DO HANDLE MISMATCHED SFN, FALL THROUGH */ - } else if (entry_type == TYPE_UNUSED) { - goto not_found; - } + } else if ((entry_type == TYPE_UNUSED) || (entry_type == TYPE_DELETED)) { + num_empty++; + if (candi_empty.eidx == -1) { + if (num_empty == 1) { + candi_empty.cur.dir = clu.dir; + candi_empty.cur.size = clu.size; + candi_empty.cur.flags = clu.flags; + } + if (num_empty >= num_entries) { + candi_empty.eidx = dentry - (num_empty - 1); + ASSERT(0 <= candi_empty.eidx); + candi_empty.count = num_empty; + + if ((fid->hint_femp.eidx == -1) || + (candi_empty.eidx <= fid->hint_femp.eidx)) { + memcpy(&fid->hint_femp, + &candi_empty, + sizeof(HINT_FEMP_T)); + } + } + } + + if (entry_type == TYPE_UNUSED) + goto not_found; + /* FALL THROUGH */ + } reset_dentry_set: - /* TYPE_DELETED OR TYPE_VOLUME */ - /* OR MISMATCHED SFN */ + /* TYPE_DELETED, TYPE_VOLUME OR MISMATCHED SFN */ lfn_ord = 0; lfn_len = 0; chksum = 0; @@ -790,6 +823,13 @@ not_found: rewind = 1; dentry = 0; clu.dir = p_dir->dir; + /* reset dentry set */ + lfn_ord = 0; + lfn_len = 0; + chksum = 0; + /* reset empty hint_*/ + num_empty = 0; + candi_empty.eidx = -1; goto rewind; } @@ -946,22 +986,16 @@ invalid_lfn: /* Find if the shortname exists and check if there are free entries */ -static s32 __fat_find_shortname_entry(struct super_block *sb, CHAIN_T *p_dir, u8 *p_dosname, s32 *offset, int n_entry_needed) +static s32 __fat_find_shortname_entry(struct super_block *sb, CHAIN_T *p_dir, u8 *p_dosname, s32 *offset, __attribute__((unused))int n_entry_needed) { u32 type; s32 i, dentry = 0; - s32 hint_n_empty = 0, hint_clu = 0; s32 dentries_per_clu; DENTRY_T *ep = NULL; DOS_DENTRY_T *dos_ep = NULL; CHAIN_T clu = *p_dir; FS_INFO_T *fsi = &(SDFAT_SB(sb)->fsi); - if ((fsi->hint_uentry.dir == p_dir->dir) - && (fsi->hint_uentry.n_entry >= n_entry_needed)) { - n_entry_needed = 0; // No need for search - } - if (offset) *offset = -1; @@ -977,48 +1011,6 @@ static s32 __fat_find_shortname_entry(struct super_block *sb, CHAIN_T *p_dir, u8 return -EIO; type = fat_get_entry_type(ep); - if (n_entry_needed > 0) { - /* Update unused hint */ - - if (type == TYPE_DELETED) { - if (hint_n_empty == 0) - hint_clu = clu.dir; - - hint_n_empty++; - } else if (type == TYPE_UNUSED) { - /* Hint entry = end of dir */ - if (hint_n_empty == 0) - hint_clu = clu.dir; - - if (fsi->hint_uentry.entry == -1) { - fsi->hint_uentry.dir = p_dir->dir; - fsi->hint_uentry.entry = dentry - hint_n_empty; - fsi->hint_uentry.n_entry = INT_MAX; - - fsi->hint_uentry.clu.dir = hint_clu; - fsi->hint_uentry.clu.size = clu.size; - fsi->hint_uentry.clu.flags = clu.flags; - - MMSG("find_shortname: uentry_hint added (clu:0x%08x ent:%d) UNUSED\n", fsi->hint_uentry.clu.dir, fsi->hint_uentry.entry); - } - } else { - if ((fsi->hint_uentry.entry == -1) \ - && (hint_n_empty >= n_entry_needed)) { - /* Hint entry = an empty entry */ - fsi->hint_uentry.dir = p_dir->dir; - fsi->hint_uentry.entry = dentry - hint_n_empty; - fsi->hint_uentry.n_entry = hint_n_empty; - - fsi->hint_uentry.clu.dir = hint_clu; - fsi->hint_uentry.clu.size = clu.size; - fsi->hint_uentry.clu.flags = clu.flags; - - MMSG("find_shortname: uentry_hint added (clu:0x%08x ent:%d)\n", fsi->hint_uentry.clu.dir, fsi->hint_uentry.entry); - } - - hint_n_empty = 0; - } - } if ((type == TYPE_FILE) || (type == TYPE_DIR)) { dos_ep = (DOS_DENTRY_T *)ep; diff --git a/fs/sdfat/fatent.c b/fs/sdfat/fatent.c index 78d36da71ce3..8fb88a5d27d5 100644 --- a/fs/sdfat/fatent.c +++ b/fs/sdfat/fatent.c @@ -355,6 +355,13 @@ s32 fat_ent_get(struct super_block *sb, u32 loc, u32 *content) return err; } + if (*content && !IS_CLUS_EOF(*content) && + (*content < CLUS_BASE || fsi->num_clusters <= *content)) { + sdfat_fs_error(sb, "invalid access to FAT (entry 0x%08x) " + "bogus content (0x%08x)", loc, *content); + return -EIO; + } + return 0; } diff --git a/fs/sdfat/sdfat.c b/fs/sdfat/sdfat.c index 84cd6c1246b9..13336a526515 100644 --- a/fs/sdfat/sdfat.c +++ b/fs/sdfat/sdfat.c @@ -67,6 +67,9 @@ #include "sdfat.h" #include "version.h" +/* skip iterating emit_dots when dir is empty */ +#define ITER_POS_FILLED_DOTS (2) + /* type index declare at sdfat.h */ const char* FS_TYPE_STR[] = { "auto", @@ -236,7 +239,7 @@ static int sdfat_iterate(struct file *filp, struct dir_context *ctx) DENTRY_NAMEBUF_T *nb = &(de.NameBuf); unsigned long inum; loff_t cpos; - int err = 0; + int err = 0, fake_offset = 0; sdfat_init_namebuf(nb); __lock_super(sb); @@ -245,8 +248,10 @@ static int sdfat_iterate(struct file *filp, struct dir_context *ctx) if ((fsi->vol_type == EXFAT) || (inode->i_ino == SDFAT_ROOT_INO)) { if (!dir_emit_dots(filp, ctx)) goto out; - if (ctx->pos == 2) + if (ctx->pos == ITER_POS_FILLED_DOTS) { cpos = 0; + fake_offset = 1; + } } if (cpos & (DENTRY_SIZE - 1)) { err = -ENOENT; @@ -261,6 +266,9 @@ get_new: SDFAT_I(inode)->fid.size = i_size_read(inode); SDFAT_I(inode)->fid.rwoffset = cpos >> DENTRY_SIZE_BITS; + if (cpos >= SDFAT_I(inode)->fid.size) + goto end_of_dir; + err = fsapi_readdir(inode, &de); if (err) { // at least we tried to read a sector @@ -310,6 +318,8 @@ get_new: goto get_new; end_of_dir: + if (!cpos && fake_offset) + cpos = ITER_POS_FILLED_DOTS; ctx->pos = cpos; out: __unlock_super(sb); @@ -376,7 +386,7 @@ static int sdfat_readdir(struct file *filp, void *dirent, filldir_t filldir) DENTRY_NAMEBUF_T *nb = &(de.NameBuf); unsigned long inum; loff_t cpos; - int err = 0; + int err = 0, fake_offset = 0; sdfat_init_namebuf(nb); __lock_super(sb); @@ -384,7 +394,7 @@ static int sdfat_readdir(struct file *filp, void *dirent, filldir_t filldir) cpos = filp->f_pos; /* Fake . and .. for the root directory. */ if ((fsi->vol_type == EXFAT) || (inode->i_ino == SDFAT_ROOT_INO)) { - while (cpos < 2) { + while (cpos < ITER_POS_FILLED_DOTS) { if (inode->i_ino == SDFAT_ROOT_INO) inum = SDFAT_ROOT_INO; else if (cpos == 0) @@ -397,8 +407,9 @@ static int sdfat_readdir(struct file *filp, void *dirent, filldir_t filldir) cpos++; filp->f_pos++; } - if (cpos == 2) { + if (cpos == ITER_POS_FILLED_DOTS) { cpos = 0; + fake_offset = 1; } } if (cpos & (DENTRY_SIZE - 1)) { @@ -414,6 +425,9 @@ get_new: SDFAT_I(inode)->fid.size = i_size_read(inode); SDFAT_I(inode)->fid.rwoffset = cpos >> DENTRY_SIZE_BITS; + if (cpos >= SDFAT_I(inode)->fid.size) + goto end_of_dir; + err = fsapi_readdir(inode, &de); if (err) { // at least we tried to read a sector @@ -463,6 +477,8 @@ get_new: goto get_new; end_of_dir: + if (!cpos && fake_offset) + cpos = ITER_POS_FILLED_DOTS; filp->f_pos = cpos; out: __unlock_super(sb); @@ -1046,7 +1062,7 @@ static int __sdfat_revalidate_ci(struct dentry *dentry, unsigned int flags) */ if (!flags) return 0; - +#endif /* * Drop the negative dentry, in order to make sure to use the * case sensitive name which is specified by user if this is @@ -1054,7 +1070,6 @@ static int __sdfat_revalidate_ci(struct dentry *dentry, unsigned int flags) */ if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET)) return 0; -#endif return __sdfat_revalidate_common(dentry); } @@ -2250,16 +2265,29 @@ static struct dentry* __sdfat_lookup(struct inode *dir, struct dentry *dentry) */ if (alias && alias->d_parent == dentry->d_parent && !sdfat_d_anon_disconn(alias)) { + /* - * This inode has non anonymous-DCACHE_DISCONNECTED - * dentry. This means, the user did ->lookup() by an - * another name (longname vs 8.3 alias of it) in past. - * - * Switch to new one for reason of locality if possible. + * Unhashed alias is able to exist because of revalidate() + * called by lookup_fast. You can easily make this status + * by calling create and lookup concurrently + * In such case, we reuse an alias instead of new dentry */ - BUG_ON(d_unhashed(alias)); - if (!S_ISDIR(i_mode)) + if (d_unhashed(alias)) { + BUG_ON(alias->d_name.hash_len != dentry->d_name.hash_len); + sdfat_msg(sb, KERN_INFO, "rehashed a dentry(%p) " + "in read lookup", alias); + d_drop(dentry); + d_rehash(alias); + } else if (!S_ISDIR(i_mode)) { + /* + * This inode has non anonymous-DCACHE_DISCONNECTED + * dentry. This means, the user did ->lookup() by an + * another name (longname vs 8.3 alias of it) in past. + * + * Switch to new one for reason of locality if possible. + */ d_move(alias, dentry); + } iput(inode); __unlock_super(sb); TMSG("%s exited\n", __func__); @@ -3622,6 +3650,7 @@ static int sdfat_fill_inode(struct inode *inode, const FILE_ID_T *fid) struct sdfat_sb_info *sbi = SDFAT_SB(inode->i_sb); FS_INFO_T *fsi = &(sbi->fsi); DIR_ENTRY_T info; + u64 size = fid->size; memcpy(&(SDFAT_I(inode)->fid), fid, sizeof(FILE_ID_T)); @@ -3663,16 +3692,20 @@ static int sdfat_fill_inode(struct inode *inode, const FILE_ID_T *fid) } - i_size_write(inode, info.Size); + /* + * Use fid->size instead of info.Size + * because info.Size means the value saved on disk + */ + i_size_write(inode, size); /* ondisk and aligned size should be aligned with block size */ - if (info.Size & (inode->i_sb->s_blocksize - 1)) { - info.Size |= (inode->i_sb->s_blocksize - 1); - info.Size++; + if (size & (inode->i_sb->s_blocksize - 1)) { + size |= (inode->i_sb->s_blocksize - 1); + size++; } - SDFAT_I(inode)->i_size_aligned = info.Size; - SDFAT_I(inode)->i_size_ondisk = info.Size; + SDFAT_I(inode)->i_size_aligned = size; + SDFAT_I(inode)->i_size_ondisk = size; sdfat_debug_check_clusters(inode); sdfat_save_attr(inode, info.Attr); @@ -4534,6 +4567,7 @@ static int sdfat_read_root(struct inode *inode) inode->i_fop = &sdfat_dir_operations; i_size_write(inode, info.Size); + SDFAT_I(inode)->fid.size = info.Size; inode->i_blocks = ( (i_size_read(inode) + (fsi->cluster_size - 1)) & ~((loff_t)fsi->cluster_size - 1) ) >> inode->i_blkbits; SDFAT_I(inode)->i_pos = ((loff_t) fsi->root_dir << 32) | 0xffffffff; diff --git a/fs/sdfat/sdfat_fs.h b/fs/sdfat/sdfat_fs.h index 976bdd86bda5..4c273d40f80b 100644 --- a/fs/sdfat/sdfat_fs.h +++ b/fs/sdfat/sdfat_fs.h @@ -34,7 +34,7 @@ #define EXFAT_SUPER_MAGIC (0x2011BAB0UL) #endif /* EXFAT_SUPER_MAGIC */ -#define SDFAT_SUPER_MAGIC (0x2014CABEUL) +#define SDFAT_SUPER_MAGIC (0x5EC5DFA4UL) #define SDFAT_ROOT_INO 1 /* FAT types */ diff --git a/fs/sdfat/version.h b/fs/sdfat/version.h index e5a4359eb9f1..058c48bf3a6a 100644 --- a/fs/sdfat/version.h +++ b/fs/sdfat/version.h @@ -24,4 +24,4 @@ /* PURPOSE : sdFAT File Manager */ /* */ /************************************************************************/ -#define SDFAT_VERSION "1.3.18" +#define SDFAT_VERSION "1.3.20" diff --git a/include/linux/battery/fuelgauge/sm5703_fuelgauge.h b/include/linux/battery/fuelgauge/sm5703_fuelgauge.h index 51a4c10a6a84..bd4dcd2e03a3 100644 --- a/include/linux/battery/fuelgauge/sm5703_fuelgauge.h +++ b/include/linux/battery/fuelgauge/sm5703_fuelgauge.h @@ -24,6 +24,10 @@ #define FG_DRIVER_VER "0.0.0.1" +#if defined(CONFIG_BATTERY_AGE_FORECAST) +#define ENABLE_BATT_LONG_LIFE 1 +#endif + /*To differentiate two battery Packs: SDI & ATL*/ enum { SDI_BATTERY_TYPE = 0, @@ -87,6 +91,12 @@ struct sec_fg_info { int battery_typ; /*SDI_BATTERY_TYPE or ATL_BATTERY_TYPE*/ int batt_id_adc_check; int battery_table[3][16]; +#ifdef ENABLE_BATT_LONG_LIFE + int v_max_table[5]; + int q_max_table[5]; + int v_max_now; + int q_max_now; +#endif int rce_value[3]; int dtcd_value; int rs_value[4]; /*rs mix_factor max min*/ @@ -158,6 +168,10 @@ struct sec_fuelgauge_info { unsigned int capacity_old; /* only for atomic calculation */ unsigned int capacity_max; /* only for dynamic calculation */ +#if defined(CONFIG_BATTERY_AGE_FORECAST) + unsigned int chg_full_soc; /* BATTERY_AGE_FORECAST */ +#endif + bool initial_update_of_soc; struct mutex fg_lock; diff --git a/net/wireless/db.txt b/net/wireless/db.txt index ad233c352ec4..696823f27ca5 100644 --- a/net/wireless/db.txt +++ b/net/wireless/db.txt @@ -538,13 +538,6 @@ country KH: (5490 - 5710 @ 80), (N/A, 27), DFS (5735 - 5835 @ 40), (N/A, 30) -country KP: - (2402 - 2482 @ 20), (N/A, 20) - (5170 - 5330 @ 20), (6, 20) - (5160 - 5250 @ 20), (6, 20), DFS - (5490 - 5630 @ 20), (6, 30), DFS - (5735 - 5815 @ 20), (6, 30) - country KR: (2402 - 2482 @ 20), (N/A, 20) (5150 - 5250 @ 80), (6, 20) @@ -696,10 +689,11 @@ country MU: (5490 - 5710 @ 80), (N/A, 27), DFS country MY: - (2402 - 2482 @ 40), (N/A, 20) - (5170 - 5250 @ 80), (N/A, 17) - (5250 - 5330 @ 80), (N/A, 23), DFS - (5735 - 5835 @ 80), (N/A, 30) + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5650 @ 160), (24), DFS + (5735 - 5835 @ 80), (24) country MX: (2402 - 2482 @ 40), (3, 20)