Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20240729095047.25040-3-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Antoniu Miclaus and committed by
Jonathan Cameron
6140a92c 87bcd0f9

+28 -7
+28 -7
drivers/iio/frequency/adf4377.c
··· 400 400 ADF4377_MUXOUT_HIGH = 0x8, 401 401 }; 402 402 403 + struct adf4377_chip_info { 404 + const char *name; 405 + bool has_gpio_enclk2; 406 + }; 407 + 403 408 struct adf4377_state { 409 + const struct adf4377_chip_info *chip_info; 404 410 struct spi_device *spi; 405 411 struct regmap *regmap; 406 412 struct clk *clkin; ··· 895 889 return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk1), 896 890 "failed to get the CE GPIO\n"); 897 891 898 - st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "clk2-enable", 899 - GPIOD_OUT_LOW); 900 - if (IS_ERR(st->gpio_enclk2)) 901 - return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2), 902 - "failed to get the CE GPIO\n"); 892 + if (st->chip_info->has_gpio_enclk2) { 893 + st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "clk2-enable", 894 + GPIOD_OUT_LOW); 895 + if (IS_ERR(st->gpio_enclk2)) 896 + return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2), 897 + "failed to get the CE GPIO\n"); 898 + } 903 899 904 900 ret = device_property_match_property_string(&spi->dev, "adi,muxout-select", 905 901 adf4377_muxout_modes, ··· 929 921 return NOTIFY_OK; 930 922 } 931 923 924 + static const struct adf4377_chip_info adf4377_chip_info = { 925 + .name = "adf4377", 926 + .has_gpio_enclk2 = true, 927 + }; 928 + 929 + static const struct adf4377_chip_info adf4378_chip_info = { 930 + .name = "adf4378", 931 + .has_gpio_enclk2 = false, 932 + }; 933 + 932 934 static int adf4377_probe(struct spi_device *spi) 933 935 { 934 936 struct iio_dev *indio_dev; ··· 963 945 964 946 st->regmap = regmap; 965 947 st->spi = spi; 948 + st->chip_info = spi_get_device_match_data(spi); 966 949 mutex_init(&st->lock); 967 950 968 951 ret = adf4377_properties_parse(st); ··· 983 964 } 984 965 985 966 static const struct spi_device_id adf4377_id[] = { 986 - { "adf4377", 0 }, 967 + { "adf4377", (kernel_ulong_t)&adf4377_chip_info }, 968 + { "adf4378", (kernel_ulong_t)&adf4378_chip_info }, 987 969 {} 988 970 }; 989 971 MODULE_DEVICE_TABLE(spi, adf4377_id); 990 972 991 973 static const struct of_device_id adf4377_of_match[] = { 992 - { .compatible = "adi,adf4377" }, 974 + { .compatible = "adi,adf4377", .data = &adf4377_chip_info }, 975 + { .compatible = "adi,adf4378", .data = &adf4378_chip_info }, 993 976 {} 994 977 }; 995 978 MODULE_DEVICE_TABLE(of, adf4377_of_match);