]> www.infradead.org Git - users/jedix/linux-maple.git/commit
media: qcom: camss: csiphy-3ph: Remove redundant PHY init sequence control loop
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Mon, 13 Jan 2025 04:31:19 +0000 (10:01 +0530)
committerHans Verkuil <hverkuil@xs4all.nl>
Thu, 6 Feb 2025 12:49:31 +0000 (13:49 +0100)
commit87c2c271652325803e46840f26a1dc8c9e93abca
treeee410ab1813068f2dfc768268dd7021853ef0bbd
parent8fae162daec53f99db917840d86477f79550bfd6
media: qcom: camss: csiphy-3ph: Remove redundant PHY init sequence control loop

Adding a new CSIPHY init sequence using downstream as a reference prompted
me to look at why we are splitting up the init sequence into chunks.

Right now we declare CSI PHY init sequences as an array of five equally
sized writes with a hard-coded control loop to iterate through each of the
five indexes. One bug in this model is that if you don't have an even
number of writes, you can't init the PHY as you wish.

In downstream the original code has something of the character
phy_init_seq[MAX_LANES][MAX_PARAMS] which in upstream we have translated
into phy_init_seq[5][SOME_NUMBER_OF_EQUAL_WRITES];

What the code does is take a pointer to the first index of the
r = &phy_init_seq[0][0]; and then literally does write(r, value); r++;

The controlling loop that hard-codes '5' in-lieu of MAX_LANES does no
special sleep, fabric-coherence sync or even a printk() to justify its
existence. Our compilers are optimising all of this away anyway so lets
drop.

Reduce the array declaration down to one flat aggregate init and let the
code just step through. As a happy side-effect we can then also handle
odd-number writes as the number of elements in the init sequence will no
longer have to be evenly divisible.

Reviewed-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Depeng Shao <quic_depengs@quicinc.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c