Re: [PATCH] media: atomisp: csi2-bridge: Only change the PMC clock rate when needed
From: Andy Shevchenko
Date: Fri Nov 13 2026 - 07:33:49 EST
On Thu, Nov 12, 2026 at 5:39 PM Manuel Levi via B4 Relay
<devnull+mlevif.gmail.com@xxxxxxxxxx> wrote:
> atomisp_csi2_set_pmc_clk_freq() enables and then disables the sensor's
> PMC platform clock before setting its rate to 19.2 MHz, which leaves the
> clock forced off in hardware.
>
> The sensor's clock is also controlled by ACPI: the CLKn power resource
Would be nice to add a Link tag below to the ACPI tables
Link: $ACPI_TABLES [1]
and refer to it like "...by ACPI [1]: ..." in the above text.
> in the sensor's _PR0 writes the same PMC clock control field that
> clk-pmc-atom writes (1 = force on, 2 = force off), and the two do not
> coordinate. If the sensor is in D0 while the bridge runs, the clock is
> switched off under it and the sensor stops responding on I2C.
>
> This happens when the sensor driver probes at the same time as the
> bridge: the i2c core powers the sensor to D0 for every probe attempt,
> including those that end in -EPROBE_DEFER while waiting for the bridge's
> fwnode graph. On a Lenovo Miix 320-10ICR (Cherry Trail) the ov2680 probe
> then fails to read the chip ID in about 1 out of 10 boots:
>
> ov2680 i2c-OVTI2680:00: Error reading reg 0x300a: -121
> ov2680 i2c-OVTI2680:00: failed to read chip id
>
> The sensor never binds, so atomisp registers no camera at all.
>
> This can be reproduced on demand: with the ov2680 runtime-resumed
> (CLK2 on, chip ID reads fine), running the same clk_prepare_enable(),
> clk_disable_unprepare(), clk_set_rate() sequence on pmc_plt_clk_2 from
> a test module makes the sensor NAK (-EREMOTEIO) until its power
> resources are cycled.
>
> The enable/disable sequence is only needed to change the rate, which can
> default to 25 MHz on Bay Trail. On Cherry Trail the clocks already run at
> 19.2 MHz. Skip the sequence when the clock already has the right rate,
> so that the bridge leaves the clock state to ACPI.
>
> Tested on a Lenovo Miix 320-10ICR with the atomisp driver from Debian's
> 6.12.116 kernel (this function is unchanged in mainline): with this
> patch pmc_plt_clk_2 and pmc_plt_clk_4 are no longer switched off during
> bridge init (checked with clk trace events), and both sensors were
> registered on all 10 test boots.
> Fixes: 0af9078315c1 ("media: atomisp: csi2-bridge: Set PMC clk-rate for sensors to 19.2 MHz")
> Signed-off-by: Manuel Levi <mlevif@xxxxxxxxx>
We might need to have Cc: stable@ as well.
...
> + /*
> + * Only touch the clock when its rate needs changing (on BYT it may
> + * default to 25 MHz). The enable + disable below leaves the clock
> + * forced off, while ACPI controls the same clock through the CLKn
> + * power resource in the sensor's _PR0. If the sensor is powered up at
> + * this point, e.g. by a concurrent probe of its driver, it would lose
> + * its clock and stop responding.
> + */
> + if (clk_get_rate(clk) == PMC_CLK_RATE_19_2MHZ) {
> + clk_put(clk);
> + return 0;
> + }
Hmm... Wouldn't it be possible to actually avoid any clock rate
settings if we have respective _PRx() methods in ACPI for the sensor?
Hans, can you check your DSDT collection for this? I mean the presence
of _PRx() methods and if they switch any clocks on or off.
--
With Best Regards,
Andy Shevchenko