diff options
Diffstat (limited to 'drivers/iio/adc/exynos_adc.c')
-rw-r--r-- | drivers/iio/adc/exynos_adc.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index d25b262193a7..9d296094892d 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c | |||
@@ -290,32 +290,30 @@ static int exynos_adc_probe(struct platform_device *pdev) | |||
290 | 290 | ||
291 | init_completion(&info->completion); | 291 | init_completion(&info->completion); |
292 | 292 | ||
293 | ret = request_irq(info->irq, exynos_adc_isr, | ||
294 | 0, dev_name(&pdev->dev), info); | ||
295 | if (ret < 0) { | ||
296 | dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", | ||
297 | info->irq); | ||
298 | return ret; | ||
299 | } | ||
300 | |||
301 | writel(1, info->enable_reg); | ||
302 | |||
303 | info->clk = devm_clk_get(&pdev->dev, "adc"); | 293 | info->clk = devm_clk_get(&pdev->dev, "adc"); |
304 | if (IS_ERR(info->clk)) { | 294 | if (IS_ERR(info->clk)) { |
305 | dev_err(&pdev->dev, "failed getting clock, err = %ld\n", | 295 | dev_err(&pdev->dev, "failed getting clock, err = %ld\n", |
306 | PTR_ERR(info->clk)); | 296 | PTR_ERR(info->clk)); |
307 | ret = PTR_ERR(info->clk); | 297 | return PTR_ERR(info->clk); |
308 | goto err_irq; | ||
309 | } | 298 | } |
310 | 299 | ||
311 | info->vdd = devm_regulator_get(&pdev->dev, "vdd"); | 300 | info->vdd = devm_regulator_get(&pdev->dev, "vdd"); |
312 | if (IS_ERR(info->vdd)) { | 301 | if (IS_ERR(info->vdd)) { |
313 | dev_err(&pdev->dev, "failed getting regulator, err = %ld\n", | 302 | dev_err(&pdev->dev, "failed getting regulator, err = %ld\n", |
314 | PTR_ERR(info->vdd)); | 303 | PTR_ERR(info->vdd)); |
315 | ret = PTR_ERR(info->vdd); | 304 | return PTR_ERR(info->vdd); |
316 | goto err_irq; | ||
317 | } | 305 | } |
318 | 306 | ||
307 | ret = regulator_enable(info->vdd); | ||
308 | if (ret) | ||
309 | return ret; | ||
310 | |||
311 | ret = clk_prepare_enable(info->clk); | ||
312 | if (ret) | ||
313 | goto err_disable_reg; | ||
314 | |||
315 | writel(1, info->enable_reg); | ||
316 | |||
319 | info->version = exynos_adc_get_version(pdev); | 317 | info->version = exynos_adc_get_version(pdev); |
320 | 318 | ||
321 | platform_set_drvdata(pdev, indio_dev); | 319 | platform_set_drvdata(pdev, indio_dev); |
@@ -332,16 +330,18 @@ static int exynos_adc_probe(struct platform_device *pdev) | |||
332 | else | 330 | else |
333 | indio_dev->num_channels = MAX_ADC_V2_CHANNELS; | 331 | indio_dev->num_channels = MAX_ADC_V2_CHANNELS; |
334 | 332 | ||
333 | ret = request_irq(info->irq, exynos_adc_isr, | ||
334 | 0, dev_name(&pdev->dev), info); | ||
335 | if (ret < 0) { | ||
336 | dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", | ||
337 | info->irq); | ||
338 | goto err_disable_clk; | ||
339 | } | ||
340 | |||
335 | ret = iio_device_register(indio_dev); | 341 | ret = iio_device_register(indio_dev); |
336 | if (ret) | 342 | if (ret) |
337 | goto err_irq; | 343 | goto err_irq; |
338 | 344 | ||
339 | ret = regulator_enable(info->vdd); | ||
340 | if (ret) | ||
341 | goto err_iio_dev; | ||
342 | |||
343 | clk_prepare_enable(info->clk); | ||
344 | |||
345 | exynos_adc_hw_init(info); | 345 | exynos_adc_hw_init(info); |
346 | 346 | ||
347 | ret = of_platform_populate(np, exynos_adc_match, NULL, &pdev->dev); | 347 | ret = of_platform_populate(np, exynos_adc_match, NULL, &pdev->dev); |
@@ -355,12 +355,14 @@ static int exynos_adc_probe(struct platform_device *pdev) | |||
355 | err_of_populate: | 355 | err_of_populate: |
356 | device_for_each_child(&pdev->dev, NULL, | 356 | device_for_each_child(&pdev->dev, NULL, |
357 | exynos_adc_remove_devices); | 357 | exynos_adc_remove_devices); |
358 | regulator_disable(info->vdd); | ||
359 | clk_disable_unprepare(info->clk); | ||
360 | err_iio_dev: | ||
361 | iio_device_unregister(indio_dev); | 358 | iio_device_unregister(indio_dev); |
362 | err_irq: | 359 | err_irq: |
363 | free_irq(info->irq, info); | 360 | free_irq(info->irq, info); |
361 | err_disable_clk: | ||
362 | writel(0, info->enable_reg); | ||
363 | clk_disable_unprepare(info->clk); | ||
364 | err_disable_reg: | ||
365 | regulator_disable(info->vdd); | ||
364 | return ret; | 366 | return ret; |
365 | } | 367 | } |
366 | 368 | ||
@@ -371,11 +373,11 @@ static int exynos_adc_remove(struct platform_device *pdev) | |||
371 | 373 | ||
372 | device_for_each_child(&pdev->dev, NULL, | 374 | device_for_each_child(&pdev->dev, NULL, |
373 | exynos_adc_remove_devices); | 375 | exynos_adc_remove_devices); |
374 | regulator_disable(info->vdd); | ||
375 | clk_disable_unprepare(info->clk); | ||
376 | writel(0, info->enable_reg); | ||
377 | iio_device_unregister(indio_dev); | 376 | iio_device_unregister(indio_dev); |
378 | free_irq(info->irq, info); | 377 | free_irq(info->irq, info); |
378 | writel(0, info->enable_reg); | ||
379 | clk_disable_unprepare(info->clk); | ||
380 | regulator_disable(info->vdd); | ||
379 | 381 | ||
380 | return 0; | 382 | return 0; |
381 | } | 383 | } |
@@ -397,8 +399,8 @@ static int exynos_adc_suspend(struct device *dev) | |||
397 | writel(con, ADC_V1_CON(info->regs)); | 399 | writel(con, ADC_V1_CON(info->regs)); |
398 | } | 400 | } |
399 | 401 | ||
400 | clk_disable_unprepare(info->clk); | ||
401 | writel(0, info->enable_reg); | 402 | writel(0, info->enable_reg); |
403 | clk_disable_unprepare(info->clk); | ||
402 | regulator_disable(info->vdd); | 404 | regulator_disable(info->vdd); |
403 | 405 | ||
404 | return 0; | 406 | return 0; |
@@ -414,9 +416,11 @@ static int exynos_adc_resume(struct device *dev) | |||
414 | if (ret) | 416 | if (ret) |
415 | return ret; | 417 | return ret; |
416 | 418 | ||
417 | writel(1, info->enable_reg); | 419 | ret = clk_prepare_enable(info->clk); |
418 | clk_prepare_enable(info->clk); | 420 | if (ret) |
421 | return ret; | ||
419 | 422 | ||
423 | writel(1, info->enable_reg); | ||
420 | exynos_adc_hw_init(info); | 424 | exynos_adc_hw_init(info); |
421 | 425 | ||
422 | return 0; | 426 | return 0; |