aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc/xilinx-xadc-core.c
diff options
context:
space:
mode:
authorManish Narani <manish.narani@xilinx.com>2018-07-23 11:02:01 -0400
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-07-29 07:49:48 -0400
commit81f5471838c279c97f0b46f18e766c2ac0de8806 (patch)
tree5982fe6b985ffa762e49f9a9a4efb9d2c9e82983 /drivers/iio/adc/xilinx-xadc-core.c
parent0a8460966fc28c3c25160c34da055e9a8a0c90a1 (diff)
iio: adc: xilinx: limit pcap clock frequency value
This patch limits the xadc pcap clock frequency value to be less than 200MHz. This fixes the issue when zynq is booted at higher frequency values, pcap crosses the maximum limit of 200MHz(Fmax) as it is derived from IOPLL. If this limit is crossed it is required to alter the WEDGE and REDGE bits of XADC_CFG register to make timings better in the interface. So to avoid alteration of these bits every time, the pcap value should not cross the Fmax limit. Signed-off-by: Manish Narani <manish.narani@xilinx.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc/xilinx-xadc-core.c')
-rw-r--r--drivers/iio/adc/xilinx-xadc-core.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index 23395fc5b267..0dd306d2c7f1 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -322,6 +322,7 @@ static irqreturn_t xadc_zynq_interrupt_handler(int irq, void *devid)
322 322
323#define XADC_ZYNQ_TCK_RATE_MAX 50000000 323#define XADC_ZYNQ_TCK_RATE_MAX 50000000
324#define XADC_ZYNQ_IGAP_DEFAULT 20 324#define XADC_ZYNQ_IGAP_DEFAULT 20
325#define XADC_ZYNQ_PCAP_RATE_MAX 200000000
325 326
326static int xadc_zynq_setup(struct platform_device *pdev, 327static int xadc_zynq_setup(struct platform_device *pdev,
327 struct iio_dev *indio_dev, int irq) 328 struct iio_dev *indio_dev, int irq)
@@ -332,6 +333,7 @@ static int xadc_zynq_setup(struct platform_device *pdev,
332 unsigned int div; 333 unsigned int div;
333 unsigned int igap; 334 unsigned int igap;
334 unsigned int tck_rate; 335 unsigned int tck_rate;
336 int ret;
335 337
336 /* TODO: Figure out how to make igap and tck_rate configurable */ 338 /* TODO: Figure out how to make igap and tck_rate configurable */
337 igap = XADC_ZYNQ_IGAP_DEFAULT; 339 igap = XADC_ZYNQ_IGAP_DEFAULT;
@@ -343,6 +345,13 @@ static int xadc_zynq_setup(struct platform_device *pdev,
343 if (!pcap_rate) 345 if (!pcap_rate)
344 return -EINVAL; 346 return -EINVAL;
345 347
348 if (pcap_rate > XADC_ZYNQ_PCAP_RATE_MAX) {
349 ret = clk_set_rate(xadc->clk,
350 (unsigned long)XADC_ZYNQ_PCAP_RATE_MAX);
351 if (ret)
352 return ret;
353 }
354
346 if (tck_rate > pcap_rate / 2) { 355 if (tck_rate > pcap_rate / 2) {
347 div = 2; 356 div = 2;
348 } else { 357 } else {
@@ -368,6 +377,12 @@ static int xadc_zynq_setup(struct platform_device *pdev,
368 XADC_ZYNQ_CFG_REDGE | XADC_ZYNQ_CFG_WEDGE | 377 XADC_ZYNQ_CFG_REDGE | XADC_ZYNQ_CFG_WEDGE |
369 tck_div | XADC_ZYNQ_CFG_IGAP(igap)); 378 tck_div | XADC_ZYNQ_CFG_IGAP(igap));
370 379
380 if (pcap_rate > XADC_ZYNQ_PCAP_RATE_MAX) {
381 ret = clk_set_rate(xadc->clk, pcap_rate);
382 if (ret)
383 return ret;
384 }
385
371 return 0; 386 return 0;
372} 387}
373 388