Skip to content

Commit 8bce508

Browse files
amiclausnunojsa
authored andcommitted
iio: frequency: adf4377: add adf4378 support
Add separate handling for adf4378 within the driver. The main difference between adf4377 and adf4378 is that adf4378 has only one output which is handled by only one gpio. Link: https://lore.kernel.org/all/20240729095047.25040-3-antoniu.miclaus@analog.com/ Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
1 parent 121abb1 commit 8bce508

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

drivers/iio/frequency/adf4377.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,13 @@ enum muxout_select_mode {
400400
ADF4377_MUXOUT_HIGH = 0x8,
401401
};
402402

403+
struct adf4377_chip_info {
404+
const char *name;
405+
bool has_gpio_enclk2;
406+
};
407+
403408
struct adf4377_state {
409+
const struct adf4377_chip_info *chip_info;
404410
struct spi_device *spi;
405411
struct regmap *regmap;
406412
struct clk *clkin;
@@ -889,11 +895,13 @@ static int adf4377_properties_parse(struct adf4377_state *st)
889895
return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk1),
890896
"failed to get the CE GPIO\n");
891897

892-
st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "clk2-enable",
893-
GPIOD_OUT_LOW);
894-
if (IS_ERR(st->gpio_enclk2))
895-
return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2),
896-
"failed to get the CE GPIO\n");
898+
if (st->chip_info->has_gpio_enclk2) {
899+
st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "clk2-enable",
900+
GPIOD_OUT_LOW);
901+
if (IS_ERR(st->gpio_enclk2))
902+
return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2),
903+
"failed to get the CE GPIO\n");
904+
}
897905

898906
ret = device_property_match_property_string(&spi->dev, "adi,muxout-select",
899907
adf4377_muxout_modes,
@@ -921,6 +929,16 @@ static int adf4377_freq_change(struct notifier_block *nb, unsigned long action,
921929
return NOTIFY_OK;
922930
}
923931

932+
static const struct adf4377_chip_info adf4377_chip_info = {
933+
.name = "adf4377",
934+
.has_gpio_enclk2 = true,
935+
};
936+
937+
static const struct adf4377_chip_info adf4378_chip_info = {
938+
.name = "adf4378",
939+
.has_gpio_enclk2 = false,
940+
};
941+
924942
static int adf4377_probe(struct spi_device *spi)
925943
{
926944
struct iio_dev *indio_dev;
@@ -945,6 +963,7 @@ static int adf4377_probe(struct spi_device *spi)
945963

946964
st->regmap = regmap;
947965
st->spi = spi;
966+
st->chip_info = spi_get_device_match_data(spi);
948967
mutex_init(&st->lock);
949968

950969
ret = adf4377_properties_parse(st);
@@ -964,13 +983,15 @@ static int adf4377_probe(struct spi_device *spi)
964983
}
965984

966985
static const struct spi_device_id adf4377_id[] = {
967-
{ "adf4377", 0 },
986+
{ "adf4377", (kernel_ulong_t)&adf4377_chip_info },
987+
{ "adf4378", (kernel_ulong_t)&adf4378_chip_info },
968988
{}
969989
};
970990
MODULE_DEVICE_TABLE(spi, adf4377_id);
971991

972992
static const struct of_device_id adf4377_of_match[] = {
973-
{ .compatible = "adi,adf4377" },
993+
{ .compatible = "adi,adf4377", .data = &adf4377_chip_info },
994+
{ .compatible = "adi,adf4378", .data = &adf4378_chip_info },
974995
{}
975996
};
976997
MODULE_DEVICE_TABLE(of, adf4377_of_match);

0 commit comments

Comments
 (0)