iio: frequency: adf4371: Add support for ADF4372 PLL

The ADF4372 is part of the same family with ADF4371, the main difference
is that it has only 3 channels instead of 4, as the frequency quadrupler
is missing. As a result, the ADF4372 allows frequencies from 62.5 MHz to
16 GHz to be generated.

Datasheet:
Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adf4372.pdf

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Stefan Popa 2019-06-24 18:12:12 +03:00 committed by Jonathan Cameron
parent c444e956a2
commit 13a0af411a
2 changed files with 31 additions and 6 deletions

View File

@ -39,12 +39,12 @@ config ADF4350
module will be called adf4350.
config ADF4371
tristate "Analog Devices ADF4371 Wideband Synthesizer"
tristate "Analog Devices ADF4371/ADF4372 Wideband Synthesizers"
depends on SPI
select REGMAP_SPI
help
Say yes here to build support for Analog Devices ADF4371
Wideband Synthesizer. The driver provides direct access via sysfs.
Say yes here to build support for Analog Devices ADF4371 and ADF4372
Wideband Synthesizers. The driver provides direct access via sysfs.
To compile this driver as a module, choose M here: the
module will be called adf4371.

View File

@ -87,6 +87,11 @@ enum {
ADF4371_CH_RF32
};
enum adf4371_variant {
ADF4371,
ADF4372
};
struct adf4371_pwrdown {
unsigned int reg;
unsigned int bit;
@ -140,6 +145,11 @@ static const struct regmap_config adf4371_regmap_config = {
.read_flag_mask = BIT(7),
};
struct adf4371_chip_info {
unsigned int num_channels;
const struct iio_chan_spec *channels;
};
struct adf4371_state {
struct spi_device *spi;
struct regmap *regmap;
@ -152,6 +162,7 @@ struct adf4371_state {
* writes.
*/
struct mutex lock;
const struct adf4371_chip_info *chip_info;
unsigned long clkin_freq;
unsigned long fpfd;
unsigned int integer;
@ -429,6 +440,17 @@ static const struct iio_chan_spec adf4371_chan[] = {
ADF4371_CHANNEL(ADF4371_CH_RF32),
};
static const struct adf4371_chip_info adf4371_chip_info[] = {
[ADF4371] = {
.channels = adf4371_chan,
.num_channels = 4,
},
[ADF4372] = {
.channels = adf4371_chan,
.num_channels = 3,
}
};
static int adf4371_reg_access(struct iio_dev *indio_dev,
unsigned int reg,
unsigned int writeval,
@ -537,12 +559,13 @@ static int adf4371_probe(struct spi_device *spi)
st->regmap = regmap;
mutex_init(&st->lock);
st->chip_info = &adf4371_chip_info[id->driver_data];
indio_dev->dev.parent = &spi->dev;
indio_dev->name = id->name;
indio_dev->info = &adf4371_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = adf4371_chan;
indio_dev->num_channels = ARRAY_SIZE(adf4371_chan);
indio_dev->channels = st->chip_info->channels;
indio_dev->num_channels = st->chip_info->num_channels;
st->clkin = devm_clk_get(&spi->dev, "clkin");
if (IS_ERR(st->clkin))
@ -568,13 +591,15 @@ static int adf4371_probe(struct spi_device *spi)
}
static const struct spi_device_id adf4371_id_table[] = {
{ "adf4371", 0 },
{ "adf4371", ADF4371 },
{ "adf4372", ADF4372 },
{}
};
MODULE_DEVICE_TABLE(spi, adf4371_id_table);
static const struct of_device_id adf4371_of_match[] = {
{ .compatible = "adi,adf4371" },
{ .compatible = "adi,adf4372" },
{ },
};
MODULE_DEVICE_TABLE(of, adf4371_of_match);