-
Notifications
You must be signed in to change notification settings - Fork 877
AD9213 driver #2804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
AD9213 driver #2804
Conversation
6eab46b
to
a6a3f96
Compare
drivers/iio/adc/ad9213.c
Outdated
|
||
MODULE_AUTHOR("Dragos Bogdan <dragos.bogdan@analog.com>"); | ||
MODULE_DESCRIPTION("Analog Devices AD9213 ADC"); | ||
MODULE_LICENSE("GPL v2"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MODULE_LICENSE("GPL v2"); | |
MODULE_LICENSE("GPL"); | |
MODULE_IMPORT_NS("IIO_BACKEND") |
a7d5e5f
to
d1d695c
Compare
Add JESD FSM ops. These modifications are required if the device is added to a JESD topology. Required by the AD9213 driver, so that the initialization sequence is synchronized with the AD9213 operation. Signed-off-by: George Mois <george.mois@analog.com>
Add OSCOUT1 as an output channel to the driver. The OSCOUT1 output is used a an input for the ADF4371 on the AD9213_EVB, and is used for synchronizing the initalization of the two devices in this setup. Signed-off-by: George Mois <george.mois@analog.com>
Remove the adi,divider-ratio defines, as they are no longer used. Signed-off-by: George Mois <george.mois@analog.com>
This adds device tree bindings for the AD9213 ADC. Signed-off-by: George Mois <george.mois@analog.com>
Add driver for AD9213. Signed-off-by: AndrDragomir <andrei.dragomir@analog.com> Signed-off-by: George Mois <george.mois@analog.com>
Add AD9213 driver to adi_mb_defconfig. Signed-off-by: George Mois <george.mois@analog.com>
Make sure the AD9213 ADC is built. Signed-off-by: George Mois <george.mois@analog.com>
Add devicetree for AD9213_EVB. Signed-off-by: AndrDragomir <andrei.dragomir@analog.com> Signed-off-by: George Mois <george.mois@analog.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The driver seems to be an old one that you're now adding. Please make sure to update it and make use of new kernel APIs and helpers.
Also, your commit subjects are not really good. Don't include file suffixes like .h or .c and do not include drivers: ...
. Just iio: ...
if (IS_ERR(st->clkin)) { | ||
dev_err(&spi->dev, "failed to get clkin\n"); | ||
return PTR_ERR(st->clkin); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the clock effectively required now... Shouldn't this still work without jesd?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should. This if will be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remove the error check. AFAICT, the clock is indeed mandatory when this device is part of the JESD topology. Hence, I would move the above code into the if (jdev)
block.
if (ch->num == 14) | ||
return (hmc->vcxo_freq / ch->divider); | ||
else | ||
return hmc7044_get_clk_attr(hw, IIO_CHAN_INFO_FREQUENCY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant else
|
||
return 0; | ||
} else { | ||
return hmc7044_set_clk_attr(hw, IIO_CHAN_INFO_FREQUENCY, rate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
HMC7044_CH_EN); | ||
if (ret) | ||
return ret; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, oscout looks like an output clock signal. Or is it something else? This feels like it should be using the clock subsystem.
/* protect against device accesses */ | ||
struct mutex lock; | ||
u64 adc_frequency_hz; | ||
struct iio_backend *back; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, please just use spaces for the fields. This kind of indentation often leads to unnecessary changes when new elements are added.
/* Power up the AD9213. */ | ||
/* Assert a Pin Reset. */ | ||
gpiod_set_value_cansleep(adc->reset_gpio, 0); | ||
mdelay(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need mdelay() here? Also, it seems we have lots of comments in this function. Make sure they follow kernel style comments and are really needed
ad9213_write(adc, AD9213_REG_PLL_ENABLE_CTRL, 0x00); | ||
|
||
/* Write Register 0x570, Bit 0 = 1, powers up JESD204B PLL. */ | ||
ad9213_write(adc, AD9213_REG_PLL_ENABLE_CTRL, AD9213_PWRUP_LCPLL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the calls to ad9213_write() check error codes
} | ||
|
||
adc->syncinb_cmos_en = | ||
of_property_read_bool(np, "adi,syncinb-cmos-enable"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use device properties
static struct spi_driver ad9213_driver = { | ||
.driver = { | ||
.name = "ad9213", | ||
.of_match_table = of_match_ptr(ad9213_of_match), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop of_match_ptr()
struct iio_dev *indio_dev = spi_get_drvdata(spi); | ||
|
||
iio_device_unregister(indio_dev); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for a .remove()
PR Description
The AD9213 is a single, 12-bit, 6 GSPS/10.25 GSPS, radio frequency (RF) analog-to-digital converter (ADC) with a 6.5 GHz input bandwidth. The AD9213 supports high dynamic range frequency and time domain applications requiring wide instantaneous bandwidth and low conversion error rates (CER). The AD9213 features a 16-lane JESD204B interface to support maximum bandwidth capability.
PR Type
PR Checklist