Jump to content

User:Daviewales

From Nura Wiki

Owns Devices

Device Notes
Google Pixel 5 (google-redfin) daily driver (CalyxOS)
HTC Desire HD (htc-ace)
Motorola Moto G 2014 (motorola-titan) current mainlining target
Raspberry Pi 1 & 2 (raspberry-pi) Raspberry Pi 1
Raspberry Pi 4 (raspberry-pi4)
Samsung Galaxy K Zoom (samsung-m2alte)






Fix SD card errors when mainlining

I don't know where to put this, so I'm putting it here:

If you're creating a device tree, and attempting to add SD card support, but the SD card doesn't function and you're getting errors like the following in dmesg, then you might need to add load to the SD card regulator:

mmc1: tuning execution failed: -5

mmc1: Card stuck being busy! __mmc_poll_for_busy
mmc1: tried to HW reset card, got error -110
mmcblk1: recovery failed!
I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 2 prio class 2
mmcblk1: recovery failed!
I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
Buffer I/O error on dev mmcblk1, logical block 0, async page read
mmcblk1: recovery failed!
I/O error, dev mmcblk1, sector 8192 op 0x0:(READ) flags 0x80700 phys_seg 4 prio class 2
mmcblk1: recovery failed!
I/O error, dev mmcblk1, sector 8192 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
Buffer I/O error on dev mmcblk1p1, logical block 0, async page read

mmcblk1: recovery failed!
I/O error, dev mmcblk1, sector 8192 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2

mmcblk1: recovery failed!
blk_print_req_error: 8 callbacks suppressed
I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 4 prio class 2

For example, if your SD card has vmmc-supply = <&pm8226_l18>;, then you should try adding the following to your pm8226_l18 regulator definition:

regulator-system-load = <200000>;
regulator-allow-set-load;

For a complete example, see this commit:
https://github.com/msm8226-mainline/linux/commit/a8e4969897eefecc3656bbd19a50c02f0fb5cfb5


Notes on Mount Matrix for Accelerometer

The hwtest utility displays the raw values, so cannot be used to test your mount matrix. The monitor-sensors utility from the iio-sensor-proxy package does use the mount matrix, so can be used to confirm that your mount matrix is correct.

Notes on setting pmic registers from Lk2nd

(Thanks Travmurav for these details!)

You can read PMIC registers from Lk2nd with:

fastboot oem debug readpmic <address>

For example, the PM8916 and PM8226 PON_RESET_S3_TIMER controls how long you have to hold down the button before your device reboots. There are 8 possible values ranging from 0x0 to 0x7. 0x0 resets instantly. 0x7 waits 195.3 seconds. The values between range from 3.1 seconds to 97.7 seconds.

The PON_RESET_S3_TIMER setting has register value 0x875.

So, if your device takes a long time to reset when you hold the power button, you can check which value is set for PON_RESET_S3_TIMER as follows:

fastboot oem debug readpmic 0x875

In my case on motorola-titan, the value was 0x5, which is a 48.8 second reset time.

Then, to set a different value (say, 0x3, which corresponds to a 12.2 second reset time), run the following:

fastboot oem debug writepmic 0x875 0x03

Unfortunately, this is only temporary. The value will reset after reboot. If you want to make this permanent, you need to patch Lk2nd to configure this on boot. (See the implementation of writepmic in lk2nd/fastboot/debug.)

Notes on Lk2nd ramoops

(Thanks Travmurav!)

  1. Remove ramoops from dts
  2. Add lk2nd.pass-ramoops=zap to cmdline
  3. Telnet into the debug console and reboot, rather than forcing a reboot by holding the power button. (And hold Volume up to get back to lk2nd.)

Then run fastboot oem ramoops console and fastboot get_staged ramoops.txt to get the console log. Note that this doesn't work (in my case at least) if I force a reboot with the power button, as it seems to clear the RAM. But hopefully it will work for a bootloop. (Haven't tested this yet.)

Notes on pd_ignore_unused

When creating a device tree for a new device, often you'll use the various _ignore_unused kernel cmdline arguments, to allow things to work which are setup by the bootloader, before you've figured out exactly how to make them work properly in the device tree. (These arguments prevent the kernel from turning of clocks, regulators and power domains which it finds already on at boot.)

By enabling and disabling various combinations of the `_ignore_unused` cmdlines, you can determine whether you're missing a regulator, a clock, or a power domain.

But what if you want to know specifically which power domain is needed?

In this case, you can patch the kernel as follows to just print out which power domains are being disabled, and selectively skip disabling some by name:

diff --git i/drivers/pmdomain/core.c w/drivers/pmdomain/core.c
index ff5c7f2b69ce..af170e5d75ab 100644
--- i/drivers/pmdomain/core.c
+++ w/drivers/pmdomain/core.c
@@ -1329,14 +1329,34 @@ static int __init genpd_power_off_unused(void)
 
 	if (pd_ignore_unused) {
 		pr_warn("genpd: Not disabling unused power domains\n");
+		list_for_each_entry(genpd, &gpd_list, gpd_list_node) {
+			pr_info("genpd: NOT disabling power domain: %s\n", genpd->name);
+		}
 		return 0;
 	}
 
 	pr_info("genpd: Disabling unused power domains\n");
 	mutex_lock(&gpd_list_lock);
 
-	list_for_each_entry(genpd, &gpd_list, gpd_list_node)
-		genpd_queue_power_off_work(genpd);
+	list_for_each_entry(genpd, &gpd_list, gpd_list_node) {
+		if (
+			1 == 1
+			|| strcmp(genpd->name, "cx_vfc") == 0
+			|| strcmp(genpd->name, "cx_ao") == 0
+			|| strcmp(genpd->name, "cx") == 0
+			|| strcmp(genpd->name, "oxili_cx") == 0
+			|| strcmp(genpd->name, "camss_vfe") == 0
+			|| strcmp(genpd->name, "camss_jpeg") == 0
+			|| strcmp(genpd->name, "mdss") == 0
+			|| strcmp(genpd->name, "venus0") == 0
+			|| strcmp(genpd->name, "usb_hs_hsic") == 0
+		) {
+			pr_info("genpd: NOT disabling power domain: %s\n", genpd->name);
+		} else {
+			pr_info("genpd: Disabling power domain: %s\n", genpd->name);
+			genpd_queue_power_off_work(genpd);
+		}
+	}
 
 	mutex_unlock(&gpd_list_lock);