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

iio: adc: Add dt support for turning on the phy in exynos-adc

Without this change the exynos adc controller needed to have its phy
enabled in some out-of-driver C code. Add support for specifying the
phy enable register by listing it in the reg list.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Tested-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Doug Anderson and committed by
Jonathan Cameron
bb916ebb f2f7a449

+15 -3
+2 -2
Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt
··· 15 15 Must be "samsung,exynos-adc-v2" for 16 16 future controllers. 17 17 - reg: Contains ADC register address range (base address and 18 - length). 18 + length) and the address of the phy enable register. 19 19 - interrupts: Contains the interrupt information for the timer. The 20 20 format is being dependent on which interrupt controller 21 21 the Samsung device uses. ··· 27 27 28 28 adc: adc@12D10000 { 29 29 compatible = "samsung,exynos-adc-v1"; 30 - reg = <0x12D10000 0x100>; 30 + reg = <0x12D10000 0x100>, <0x10040718 0x4>; 31 31 interrupts = <0 106 0>; 32 32 #io-channel-cells = <1>; 33 33 io-channel-ranges;
+13 -1
drivers/iio/adc/exynos_adc.c
··· 85 85 86 86 struct exynos_adc { 87 87 void __iomem *regs; 88 + void __iomem *enable_reg; 88 89 struct clk *clk; 89 90 unsigned int irq; 90 91 struct regulator *vdd; ··· 270 269 info = iio_priv(indio_dev); 271 270 272 271 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 273 - 274 272 info->regs = devm_request_and_ioremap(&pdev->dev, mem); 275 273 if (!info->regs) { 274 + ret = -ENOMEM; 275 + goto err_iio; 276 + } 277 + 278 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); 279 + info->enable_reg = devm_request_and_ioremap(&pdev->dev, mem); 280 + if (!info->enable_reg) { 276 281 ret = -ENOMEM; 277 282 goto err_iio; 278 283 } ··· 301 294 info->irq); 302 295 goto err_iio; 303 296 } 297 + 298 + writel(1, info->enable_reg); 304 299 305 300 info->clk = devm_clk_get(&pdev->dev, "adc"); 306 301 if (IS_ERR(info->clk)) { ··· 379 370 exynos_adc_remove_devices); 380 371 regulator_disable(info->vdd); 381 372 clk_disable_unprepare(info->clk); 373 + writel(0, info->enable_reg); 382 374 iio_device_unregister(indio_dev); 383 375 free_irq(info->irq, info); 384 376 iio_device_free(indio_dev); ··· 405 395 } 406 396 407 397 clk_disable_unprepare(info->clk); 398 + writel(0, info->enable_reg); 408 399 regulator_disable(info->vdd); 409 400 410 401 return 0; ··· 421 410 if (ret) 422 411 return ret; 423 412 413 + writel(1, info->enable_reg); 424 414 clk_prepare_enable(info->clk); 425 415 426 416 exynos_adc_hw_init(info);