unmaintained/alcatel-idol347-downstream: new device (Alcatel Idol 3 4.7) (MR 2319)

Based on Minecrell work at:
https://gitlab.com/Minecrell/pmaports/-/tree/alcatel-idol347-downstream
adapted smb1360 shared patches for idol347 downstream tree,
and added his idol347-like-mainline.patch gist which changes downstream DT
to mimic sane mainline settings for easy battery driver dump comparison.
This commit is contained in:
Vincent Knecht 2021-07-06 20:48:42 +02:00 committed by Minecrell
parent 637586a9c0
commit e76f4df119
No known key found for this signature in database
GPG key ID: B77CE638A6C2E562
12 changed files with 4194 additions and 0 deletions

View file

@ -0,0 +1,25 @@
# Unmaintained: Downstream port, only for testing. Use mainline port (alcatel-idol347)!
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-alcatel-idol347-downstream
pkgdesc="Alcatel OneTouch Idol 3 (4.7) (Downstream)"
pkgver=1
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="armv7"
options="!check !archcheck"
depends="postmarketos-base linux-alcatel-idol347-downstream mkbootimg mesa-dri-gallium msm-fb-refresher"
makedepends="devicepkg-dev"
source="deviceinfo"
build() {
devicepkg_build $startdir $pkgname
}
package() {
devicepkg_package $startdir $pkgname
}
sha512sums="
20f7c9f206a6d1b249f5763e45954616a3e790f7a9a268c13a809f556fdafdd718a7aefddda6a79851042b7582de39477244cd1f867103d7cd82aa68a7d425a5 deviceinfo
"

View file

@ -0,0 +1,33 @@
# Reference: <https://postmarketos.org/deviceinfo>
# Please use double quotes only. You can source this file in shell scripts.
deviceinfo_format_version="0"
deviceinfo_name="Alcatel OneTouch Idol 3 (4.7)"
deviceinfo_manufacturer="Alcatel"
deviceinfo_codename="alcatel-idol347-downstream"
deviceinfo_year="2015"
deviceinfo_modules_initfs=""
deviceinfo_arch="armv7"
# Device related
deviceinfo_chassis="handset"
deviceinfo_keyboard="false"
deviceinfo_external_storage="true"
deviceinfo_screen_width="720"
deviceinfo_screen_height="1280"
# Bootloader related
deviceinfo_flash_method="fastboot"
deviceinfo_kernel_cmdline="console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 earlyprintk androidboot.bootloader=L1BGC0C0BG00"
deviceinfo_generate_bootimg="true"
deviceinfo_bootimg_qcdt="false"
deviceinfo_bootimg_mtk_mkimage="false"
deviceinfo_bootimg_dtb_second="false"
deviceinfo_flash_offset_base="0x80000000"
deviceinfo_flash_offset_kernel="0x00008000"
deviceinfo_flash_offset_ramdisk="0x01000000"
deviceinfo_flash_offset_second="0x00f00000"
deviceinfo_flash_offset_tags="0x00000100"
deviceinfo_flash_pagesize="2048"
deviceinfo_flash_sparse="true"

View file

@ -0,0 +1,76 @@
# Unmaintained: Downstream port, only for testing. Use mainline port (alcatel-idol347)!
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm/configs/idol347_defconfig
pkgname=linux-alcatel-idol347-downstream
pkgver=3.10.49
pkgrel=0
pkgdesc="Alcatel Idol 3 4.7 downstream kernel fork"
arch="armv7"
_carch="arm"
_flavor="alcatel-idol347-downstream"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="bash bc bison devicepkg-dev flex openssl-dev perl gcc4 linux-headers"
# Compiler: GCC 4
if [ "${CC:0:5}" != "gcc4-" ]; then
CC="gcc4-$CC"
HOSTCC="gcc4-gcc"
CROSS_COMPILE="gcc4-$CROSS_COMPILE"
fi
# Source
_repository="android_kernel_qcom_msm8916"
_commit="e87abaceaaf3e67c25e1a734838ed277dc0c44a9"
_smb_tag="v5.11.7-msm8916"
_config="config-$_flavor.$arch"
source="
$pkgname-$_commit.tar.gz::https://github.com/msm8916-mainline/$_repository/archive/$_commit.tar.gz
$_config
cpr-dump.patch
gpio-debug.patch
idol347-like-mainline.patch
memshare-debug.patch
remove-gcc-wrapper.patch
smb1360-debug-idol347.patch
smb1360-dump-idol347.patch
smb1360-dump-$_smb_tag.c::https://raw.githubusercontent.com/msm8916-mainline/linux/$_smb_tag/drivers/power/supply/smb1360-dump.c
smb1360-like-mainline-idol347.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"
prepare() {
cp "$srcdir/smb1360-dump-$_smb_tag.c" drivers/power/smb1360-dump.c
# Downstream doesn't define U8_MAX...
sed -i 's/U8_MAX/0xff/g' drivers/power/smb1360-dump.c
default_prepare
REPLACE_GCCH=0 . downstreamkernel_prepare
}
build() {
unset LDFLAGS
make O="$_outdir" ARCH="$_carch" CC="$CC" HOSTCC="$HOSTCC" TARGET_PRODUCT=idol347 \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}
package() {
downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"
}
sha512sums="
21a59ee32045b25593617a84250e9768c9cd70760b24ba3d88a70bcae0fd4a52367c0b928aa2dbef3346eadff35b809f167db3f82fdada7182baa7345a4904ee linux-alcatel-idol347-downstream-e87abaceaaf3e67c25e1a734838ed277dc0c44a9.tar.gz
44174ab2e6af77f1b1dbb9d7f84f7756ce13a5e42618876eecbbcb3b4a4d7906b410ff75f9c192794d9ee49bbd34a4457279b43aa2ff22fb27415d08ad8ec4cd config-alcatel-idol347-downstream.armv7
f040a1d7169b9ddb5baabb7de1838441e8608894dc6dc61ececb1acb4fe9851289934b37d74afb61addc01d7a1e4f1d2413f5e542c2a4aeb0c01f680797d37c6 cpr-dump.patch
e9f809b6659375cd7e854821f9925faa263d287c06e44071017cd4afb32f79c47e63760c9c95b4f0c15b79b6b1af4a36911861104a7b56dea2195baf9e4f4685 gpio-debug.patch
bab8a081879b5e4b0d8f280fda099fde5f47eab62e8eb3aa50c36475edafc2e6b70aba5b9eec56bcfa94dc1d483d43c1f5ca37d7a0ade4354f456b5fa30d53ae idol347-like-mainline.patch
56083a8b290a7b1b1ffc9c8e3333db6d786a20d6e91ee400e895ecee8d31cccc75d809be13bcfe5cfb7d5b53a687b25281e8fd454cf420468ded3f77dcea9897 memshare-debug.patch
4a09fdcf99a4716a4ced11b7d74b7867423e5f6fa6c62674e57f496a10647c0b704fd5f91c46711e363337b54d3b7917b6c685230568eab44b6303bd285a2b61 remove-gcc-wrapper.patch
4f4ad8d9d8a7f04bf8f326e8bd87f17b3ff91d5792fd68c31ac777781ed44b97f06991ae9769bad01d8d1168a1cba0123ae69fd177dc8faa9cb663e115dc69ee smb1360-debug-idol347.patch
594017763bc82b29a24f18e3b3f9275eebbb720422ef1c1ea4d2d598baa1bb54761bc6f452d94b2079f7a6c6f6d0b7606684cca137a2b91a1c5fb94b2140e8fa smb1360-dump-idol347.patch
f61902474ab221a85a8910dcfbc48736e323a6bbc83896f778bb87d356464679c62ddf1c583e660a5c3c790dba420cce6cb9ca59b720234846dac7e80aa47368 smb1360-dump-v5.11.7-msm8916.c
33fe78be59acf7df9f0043819b66f79dba1fe2cd43cddedc361c17bb29454e1a55a5cd4825e9e61e45e7415986caddb795c0aefbd2fe8c631ffae24f2042bac1 smb1360-like-mainline-idol347.patch
"

View file

@ -0,0 +1 @@
../../.shared-patches/linux/qcom/msm8916/cpr-dump.patch

View file

@ -0,0 +1 @@
../../.shared-patches/linux/qcom/msm8916/gpio-debug.patch

View file

@ -0,0 +1,41 @@
diff --git a/arch/arm/boot/dts/idol347/msm8916-mtp-smb1360.dts b/arch/arm/boot/dts/idol347/msm8916-mtp-smb1360.dts
index 44923c774b3..97a22a33aa2 100644
--- a/arch/arm/boot/dts/idol347/msm8916-mtp-smb1360.dts
+++ b/arch/arm/boot/dts/idol347/msm8916-mtp-smb1360.dts
@@ -28,17 +28,16 @@
compatible = "qcom,smb1360-chg-fg";
reg = <0x14>;
interrupt-parent = <&msm_gpio>;
- interrupts = <9 2>;
+ interrupts = <9 8>;
pinctrl-names = "default";
pinctrl-0 = <&smb_int_default>;
regulator-name = "smb1360_otg_vreg";
- qcom,stat-pulsed-irq;
qcom,chg-inhibit-disabled;
qcom,float-voltage-mv = <4350>;
qcom,fg-cc-to-cv-mv = <4328>;
qcom,thermistor-c1-coeff = <0x86C8>;
qcom,iterm-ma = <75>;
- qcom,charging-timeout = <0>;
+ qcom,charging-timeout = <192>;
/* battery-profile selection properties */
qcom,batt-profile-select;
@@ -59,7 +58,7 @@
qcom,fg-soc-max = <85>;
qcom,fg-soc-min = <15>;
qcom,fg-delta-soc = <1>;
- qcom,fg-auto-recharge-soc = <99>;
+ qcom,fg-auto-recharge-soc = <95>;
qcom,thermal-mitigation = <1500 850 650 550>;
qcom,otp-rslow-cfg;//JRD BSP eric.gong "[Qualcomm]smb1360: Modify the rslow via OTP backup"
@@ -68,7 +67,6 @@
qcom,fg-reset-at-pon;
qcom,otg-batt-curr-limit = <1500>;
- qcom,config-hard-thresholds;
qcom,hot-bat-decidegc = <550>;
qcom,cold-bat-decidegc = <0>;
qcom,soft-jeita-supported;

View file

@ -0,0 +1 @@
../../.shared-patches/linux/qcom/msm8916/memshare-debug.patch

View file

@ -0,0 +1 @@
../../.shared-patches/linux/qcom/msm8916/remove-gcc-wrapper.patch

View file

@ -0,0 +1,49 @@
diff --git a/drivers/power/idol347/smb1360-charger-fg.c b/drivers/power/idol347/smb1360-charger-fg.c
index bc8859cd9a2..e223a5aea9e 100644
--- a/drivers/power/idol347/smb1360-charger-fg.c
+++ b/drivers/power/idol347/smb1360-charger-fg.c
@@ -9,6 +9,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
+#define DEBUG
#define pr_fmt(fmt) "SMB:%s: " fmt, __func__
#include <linux/i2c.h>
@@ -472,7 +473,7 @@ static int __smb1360_write(struct smb1360_chip *chip, int reg,
val, reg, ret);
return ret;
}
- //pr_debug("Writing 0x%02x=0x%02x\n", reg, val);
+ pr_debug("Writing 0x%02x=0x%02x\n", reg, val);
return 0;
}
@@ -967,6 +968,10 @@ static enum power_supply_property smb1360_battery_properties[] = {
};
static int smb1360_get_prop_batt_present(struct smb1360_chip *chip)
+/* Disable pr_debug() for read routines, those spam too much */
+#pragma push_macro("pr_debug")
+#undef pr_debug
+#define pr_debug(fmt, ...)
{
return chip->batt_present;
}
@@ -1223,6 +1228,7 @@ static int smb1360_get_prop_current_now(struct smb1360_chip *chip)
}
static int smb1360_set_minimum_usb_current(struct smb1360_chip *chip)
+#pragma pop_macro("pr_debug")
{
int rc = 0;
@@ -2577,7 +2583,7 @@ static irqreturn_t smb1360_stat_handler(int irq, void *dev_id)
handlers[i].prev_val = handlers[i].val;
}
- pr_debug("handler count = %d\n", handler_count);
+ //pr_debug("handler count = %d\n", handler_count);
if (handler_count)
power_supply_changed(&chip->batt_psy);

View file

@ -0,0 +1,89 @@
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index fbd12449dae..6575f0ea241 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -1,6 +1,7 @@
ccflags-$(CONFIG_POWER_SUPPLY_DEBUG) := -DDEBUG
power_supply-y := power_supply_core.o
+power_supply-y += smb1360-dump.o
power_supply-$(CONFIG_SYSFS) += power_supply_sysfs.o
power_supply-$(CONFIG_LEDS_TRIGGERS) += power_supply_leds.o
diff --git a/drivers/power/idol347/smb1360-charger-fg.c b/drivers/power/idol347/smb1360-charger-fg.c
index bc8859cd9a2..1a087158d21 100644
--- a/drivers/power/idol347/smb1360-charger-fg.c
+++ b/drivers/power/idol347/smb1360-charger-fg.c
@@ -3760,6 +3760,41 @@ static int smb1360_jeita_init(struct smb1360_chip *chip)
return rc;
}
+extern void smb1360_dump(struct i2c_client *client);
+extern void smb1360_dump_fg_scratch(struct i2c_client *fg_client);
+extern void smb1360_dump_fg(struct i2c_client *client);
+
+static void smb1360_dump_locked(struct smb1360_chip *chip)
+{
+ mutex_lock(&chip->read_write_lock);
+ smb1360_dump(chip->client);
+ mutex_unlock(&chip->read_write_lock);
+}
+
+static void smb1360_dump_fg_access(struct smb1360_chip *chip)
+{
+ int ret;
+
+ ret = smb1360_enable_fg_access(chip);
+ if (ret)
+ return;
+
+ mutex_lock(&chip->read_write_lock);
+ smb1360_dump_fg_scratch(chip->client);
+
+ /* Do cool hacks to access FG I2C address instead */
+ chip->fg_access_type = FG_ACCESS_CFG;
+ smb1360_select_fg_i2c_address(chip);
+
+ chip->client->addr = chip->fg_i2c_addr;
+ smb1360_dump_fg(chip->client);
+ chip->client->addr = chip->default_i2c_addr;
+ mutex_unlock(&chip->read_write_lock);
+
+ smb1360_disable_fg_access(chip);
+ smb1360_check_cycle_stretch(chip);
+}
+
#define FG_POWERON_DELAY_MS 2000
static int smb1360_hw_init(struct smb1360_chip *chip)
{
@@ -3767,6 +3802,9 @@ static int smb1360_hw_init(struct smb1360_chip *chip)
int i;
u8 reg, mask;
+ /* Dump initial FG registers */
+ smb1360_dump_fg_access(chip);
+
smb1360_check_feature_support(chip);
rc = smb1360_enable_volatile_writes(chip);
@@ -4097,6 +4135,10 @@ static int smb1360_hw_init(struct smb1360_chip *chip)
dev_err(chip->dev, "Couldn't '%s' charging rc = %d\n",
chip->charging_disabled ? "disable" : "enable", rc);
+ /* Dump final registers */
+ smb1360_dump_locked(chip);
+ smb1360_dump_fg_access(chip);
+
return rc;
}
@@ -4540,6 +4582,9 @@ static int smb1360_probe(struct i2c_client *client,
mutex_init(&chip->current_change_lock);
chip->default_i2c_addr = client->addr;
+ /* Dump initial registers */
+ smb1360_dump_locked(chip);
+
pr_debug("default_i2c_addr=%x\n", chip->default_i2c_addr);
rc = smb1360_hw_init(chip);

View file

@ -0,0 +1,13 @@
diff --git a/drivers/power/idol347/smb1360-charger-fg.c b/drivers/power/idol347/smb1360-charger-fg.c
index bc8859cd9a2..5ae109b9ff2 100644
--- a/drivers/power/idol347/smb1360-charger-fg.c
+++ b/drivers/power/idol347/smb1360-charger-fg.c
@@ -3408,7 +3408,7 @@ disable_access:
if (chip->soc_min != -EINVAL) {
if (is_between(chip->soc_min, 0, 100)) {
- reg = DIV_ROUND_UP(chip->soc_min * MAX_8_BITS,
+ reg = DIV_ROUND_CLOSEST(chip->soc_min * MAX_8_BITS,
100);
pr_debug("soc_min=%d reg=%x\n",
chip->soc_min, reg);