Talk:Qualcomm Snapdragon 800/801 (MSM8974)

From postmarketOS Wiki

Chip variants

Basically there's MSM8x74 = Snapdragon 800; MSM8x74AA, MSM8x74AB & MSM8x74AC = Snapdragon 801. In the 801 variants the only difference seems to be the lower/higher frequencies of various components (e.g. GPU). Compared to Snapdragon 800 there seem to be a bit more major differences though in clock configuration for example.

Search for `cpu_is_msm8974pro` in arch/arm/mach-msm/clock-8974.c to find the clock differences.

Example: Fairphone 2, MSM8974PRO-AA in Android Settings, /sys/devices/soc0/revision: "1.1", /sys/devices/soc0/soc_id: "217"

BUT Mainline seems to ONLY call the -AC variant 'pro', see drivers/soc/qcom/socinfo.c (search for "74PRO"), these are called PRO-AC on downstream (and others PRO-AA, PRO-AB), so PRO-A* seems to be Snapdragon 801 while the non-PRO (downstream) are 800

There are also the naming variant MSM8974AB-AA, MSM8974AB-AB & MSM8974AB-AC where the first AB = PRO = Snapdragon 801; apparently AA & AC are kind of variants of the AB base variant, so AB base variant + AA more specific variant.

For Snapdragon 800 there's also a v1 and v2 (which also have different clock configs for example); Snapdragon 801 is also sometimes called v3 but that seems to be more marketing than something the processor says (in socinfo)

Z3ntu (talk) 21:57, 20 February 2021 (UTC)

Coincell

A capacitor (or actual coin cell) that stores some energy, e.g. for keeping the RTC alive when the battery is temporarily removed. A component of the pm8941 charges this capacitor, controlled by the downstream driver drivers/platform/msm/qpnp-coincell.c .

	pm8941_coincell: qcom,coincell@2800 {
		compatible = "qcom,qpnp-coincell";
		reg = <0x2800 0x100>;
	};

In mainline the properties qcom,rset-ohms and qcom,vset-millivolts are required to be set while downstream has them optional and keeps the hardware defaults if not set explicitely. Fortunately the downstream driver prints the values after probe is done, so figuring out the correct value is easy.

[    2.578974] qpnp_coincell_charger_show_state: enabled=Y, voltage=3000 mV, resistance=2100 ohm

From that you can set the mainline dt properties:

			qcom,rset-ohms = <2100>;
			qcom,vset-millivolts = <3000>;

Battery monitoring system (BMS)

Some msm8974 devices use a component in the pm8941 as a fuel gauge (= how many % battery are left). There's a driver from Craig Tatlor on LKML and I (z3ntu) have done some fixes and adjustments for it; unfortunately there seem to still be quite some discrepancies between downstream % value and mainline % value.

[    2.966561] BMS: qpnp_bms_probe: probe success: soc =100 vbatt = 4086901 ocv = 4314054 r_sense_uohm = 9031 warm_reset = 0

qcom-bms fc4cf000.spmi:pm8941@0:bms@4000: read open circuit voltage of: 3944 mV
qcom-bms fc4cf000.spmi:pm8941@0:bms@4000: read temperature of: 33 °C
qcom-bms fc4cf000.spmi:pm8941@0:bms@4000: read coulomb counter value of: 17475 uAh

Basically it seems like the driver is reading these three values and then interpolating the percentage from a table that's specified in the device tree. This script can be used to convert this lookup table from downstream to mainline: https://github.com/z3ntu/downstream-dtb-bms-converter

Downstream also has the ability to find the correct "battery" in dt by looking at the battery id resistor that's built into the battery (e.g. on FP2 the new battery pack has a resistor of 100kOhm while the old battery has a resistor of 47kOhm. Mainline should also be able to read this but this hasn't been successful for me. VADC_LR_MUX2_BAT_ID in vadc@3100