Difference between revisions of "User:Z3ntu/Qualcomm Mainlining"

From postmarketOS
Jump to navigation Jump to search
Line 16: Line 16:
 
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)
 
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)
  
== rpm regulators ==
+
== regulators ==
 +
 
 +
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 ===
 +
 
 +
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 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";
 
Downstream: compatible = "qcom,rpm-smd-regulator-resource";
Line 22: Line 37:
 
struct rpm_regulator_data[]:
 
struct rpm_regulator_data[]:
  
name: take s1 from regulator-s1
+
* name: take s1 from regulator-s1
type: translate qcom,resource-name to constant
+
* type: translate qcom,resource-name to constant
id: qcom,resource-id
+
* id: qcom,resource-id
desc: ???
+
* desc: TODO lk2nd can dump the regulators - need spmi regulator support there https://pastebin.com/raw/7vTgkK9t https://github.com/msm8916-mainline/lk2nd/commit/95b440edf9e743c8d88777cff789367d635ddd9e . Then you can check https://github.com/torvalds/linux/blob/e359bce39d9085ab24eaa0bb0778bb5f6894144a/drivers/regulator/qcom_spmi-regulator.c#L456-L545 for a lookup.
supply: check pins it seems, VDD_GR1 - VDD_GR7 (not obvious what they supply but sometimes it's noted), normally something like VDD_L13_20_23_24
+
* supply: see section above

Revision as of 21:44, 27 April 2021

First steps for a new SoC

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

smem

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)

regulators

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

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 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[]: