User:Knuxify/Draft:Qualcomm/Adding a new SoC to mainline Linux: Difference between revisions

Knuxify (talk | contribs)
Knuxify (talk | contribs)
No edit summary
Line 70: Line 70:


<syntaxhighlight lang="makefile">
<syntaxhighlight lang="makefile">
obj-$(CONFIG_SM_GCC_xxxx) += gcc-smXXXX.o
obj-$(CONFIG_SM_GCC_CODENAME) += CODENAME-gcc.o
</syntaxhighlight>
</syntaxhighlight>


Open <code>driver/clk/qcom/gcc-smXXXX.c</code>.
Copy your downstream driver to <code>driver/clk/qcom/CODENAME-gcc.c</code>.


Paste the initialization code from another GCC driver (<syntaxhighlight inline lang="c">static struct platform_driver gcc_smXXXX_driver</syntaxhighlight> and onwards.)
Paste the initialization code from another GCC driver (<syntaxhighlight inline lang="c">static struct platform_driver gcc_smXXXX_driver</syntaxhighlight> and onwards.)
{{todo|There are some missing struct members, these can be ommited. IIRC one has a counterpart in mainline but I don't remember which one... revisit this, maybe?}}
=== Interconnect driver ===
TODO figure out what the interconnect actually does.
Similar to clocks, interconnects are nearly the same as in downstream, but need some changes.
Add a Kconfig option and a Makefile entry in <code>drivers/interconnect/qcom/{Kconfig,Makefile}</code> (see how the other drivers do it). Then, copy your interconnect driver to <code>drivers/interconnect/qcom/codename.c</code>.
'''Do not copy the accompanying header file.''' Mainline stopped using static IDs for ICC nodes as of 2025-10; you'll need to convert your driver.
* In every instance of <code>qcom_icc_node</code>:
** Remove the <code>.id</code> member;
** Replace <code>.links</code> with <code>.link-nodes</code> containing a list with pointers to a qcom_icc_desc. To figure out what to point to - see <code>static struct qcom_icc_node *XXXXXX_nodes[] = {</code> structs - the name will be the same.
''See https://lore.kernel.org/all/[email protected]/ for an example. Ignore the part where they add <code>alloc_dyn_id</code>, that was removed in another commit as dynamic IDs are now the only option.''
=== TLMM/pinctrl ===
Driver is in drivers/pinctrl/qcom.
Downstream driver is split into a .c file and a .h file; mainline has them both in the .c file. TODO I don't remember exactly how I arrived at the mainline driver...
* Replace <code>MSM_GPIO_PIN_FUNCTION(gpio)</code> with <code>MSM_PIN_FUNCTION(gpio)</code>
* Replace the probe and platform_device stuff with the same stuff copied from another driver in mainline


== Porting the PMIC(s) ==
== Porting the PMIC(s) ==