Post Go back to editing

adrv9002 linux driver with external LO divider

Category: Software
Product Number: ADRV9002
Software Version: 2021_r2
Hi
I noticed when using the external LO that there is a mismatch between the initial settings and changing the settings via iio osc later.
When changing the profile the currently set up external LO clock rate gets queried and half the divided rate is set in the gui as LO frequency.
The profile has a divider of 2 set.
e.g. I set up the external LO synth to 200 MHz and in the GUI the Local oscillator frequency is set to 100 MHz.
So far so good.
But when I then change the LO frequency in the GUI the undivided rate is used in the infrastructure.
e.g. when I increment the rate to 101 MHz in the GUI the LO synth driver gets a request to set 101 MHz.
I would expect that it request  202 MHz with the divider of 2 applied.
I think the issue is in the adrv9002.c driver here:
It uses
clk_set_rate_scaled(c->ext_lo->clk, *freq* , &c->ext_lo->scale);
and I think it should be
clk_set_rate_scaled(c->ext_lo->clk, *lo_freq* , &c->ext_lo->scale);

I know that I use an older release but in the current main branch the code looks like this:
Here is the set code from adrv9002.c from main branch:
static int adrv9002_set_ext_lo(const struct adrv9002_chan *c, u64 freq)
{
	u64 lo_freq;

	if (!c->ext_lo)
		return 0;

	lo_freq = freq * c->ext_lo->divider;
	if (lo_freq < ADRV9002_EXT_LO_FREQ_MIN || lo_freq > ADRV9002_EXT_LO_FREQ_MAX) {
		const struct adrv9002_rf_phy *phy = chan_to_phy(c);

		dev_err(&phy->spi->dev, "Ext LO freq not in the [%d %llu] range\n",
			ADRV9002_EXT_LO_FREQ_MIN, ADRV9002_EXT_LO_FREQ_MAX);
		return -EINVAL;
	}

	return clk_set_rate_scaled(c->ext_lo->clk, freq, &c->ext_lo->scale);
}
 
Rregards
Philipp

Thread Notes