User:Z3ntu/Qualcomm Mainlining

From postmarketOS

First steps for a new SoC

  • gcc (global clock controller)
  • SoC dtsi
  • device dts
  • pinctrl?


Downstream compatible: "qcom,smem"

Normally the reg for reg-names = "smem" is used with address & size. BUT if e.g. smem_targ_info_imem is set, then the driver will read the address from this register and ignore the address from dts.

The error "qcom-smem smem: SMEM is not initialized by SBL" very likely means that the address is wrong. Double check the downstream driver and add some prints to see what's happening there. In msm8226 driver, a print after smem_targ_info_done with "SMEM_INFO("%s: got smem_ram_phys %pa and smem_ram_size %pa !\n", __func__, &smem_ram_phys, &smem_ram_size);" was useful.

This should enable you to read socinfo from /sys/devices/soc0/* and /sys/kernel/debug/qcom_socinfo/* (assuming you've enabled CONFIG_QCOM_SOCINFO and mounted debugfs)


TODO Insert text about spmi vs smd rpm regulators. In a nutshell, the rpm firmware normally should control the regulators and you talk to that via smd. Rpm firmware then (presumably) talks spmi to the regulators. And Linux should use the rpm route to control them.

spmi regulators

Downstream: compatible = "qcom,qpnp-regulator";

Add new compatible to spmi regulator driver drivers/regulator/qcom_spmi-regulator.c from e.g. arch/arm/boot/dts/qcom/msm-pm8226.dtsi , should be relatively straight forward. Supplies are documented in the next section.

Add the node to dts and you should be good. You can check name & microvolts and whether it's enabled in /sys/class/regulators

regulator supplies

The regulators you'll configure have supplies which you should note down. This is unfortunately not noted in the downstream kernel. These are often called e.g. VDD_L13_20_23_24 (pin name) / vdd_l13_l20_l23_l24 (Linux name). On pm8226 these are called VDD_GR1 to VDD_GR7. The VDD_L13_20_23_24 supplies (obviously) l13, l20, l23 & l24. What VDD_GR2 supplies is more of a mystery but sometimes clues can be found in various schematics, if you have such available. The names are also documented in the Device Specification for the PMIC, if such is available.

rpm regulators

Downstream: compatible = "qcom,rpm-smd-regulator-resource";

struct rpm_regulator_data[]: