From: Kang KyungWoo Date: Mon, 13 Jun 2016 12:07:13 +0000 (+0900) Subject: [COMMON] rtc: samsung: Add disabling clock control with AP rtc X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4cc08c8af79cbac5d180fe5f1f24d2187237f5db;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] rtc: samsung: Add disabling clock control with AP rtc This patch is for disabling clock control for AP RTC. At exynos8 series, we no longer need to control ap rtc clock due to clock source has been changed. Change-Id: I00806873df732937eb41f4db68d5ccf3fcde6a4d Signed-off-by: Kang KyungWoo --- diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index c111e2c2b059..4e10ae3a9a9c 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c @@ -57,6 +57,7 @@ struct s3c_rtc { struct s3c_rtc_data { int max_user_freq; bool needs_src_clk; + bool clock_ctrl_disable; void (*irq_handler) (struct s3c_rtc *info, int mask); void (*set_freq) (struct s3c_rtc *info, int freq); @@ -73,6 +74,9 @@ static int s3c_rtc_enable_clk(struct s3c_rtc *info) unsigned long irq_flags; int ret = 0; + if (info->data->clock_ctrl_disable) + return; + spin_lock_irqsave(&info->alarm_clk_lock, irq_flags); if (info->clk_disabled) { @@ -100,6 +104,9 @@ static void s3c_rtc_disable_clk(struct s3c_rtc *info) { unsigned long irq_flags; + if (info->data->clock_ctrl_disable) + return; + spin_lock_irqsave(&info->alarm_clk_lock, irq_flags); if (!info->clk_disabled) { if (info->data->needs_src_clk) @@ -467,6 +474,9 @@ static int s3c_rtc_remove(struct platform_device *pdev) s3c_rtc_setaie(info->dev, 0); + if (info->data->clock_ctrl_disable) + return 0; + if (info->data->needs_src_clk) clk_unprepare(info->rtc_src_clk); clk_unprepare(info->rtc_clk); @@ -528,36 +538,25 @@ static int s3c_rtc_probe(struct platform_device *pdev) if (IS_ERR(info->base)) return PTR_ERR(info->base); - info->rtc_clk = devm_clk_get(&pdev->dev, "rtc"); - if (IS_ERR(info->rtc_clk)) { - ret = PTR_ERR(info->rtc_clk); - if (ret != -EPROBE_DEFER) + if (!info->data->clock_ctrl_disable) { + info->rtc_clk = devm_clk_get(&pdev->dev, "rtc"); + if (IS_ERR(info->rtc_clk)) { dev_err(&pdev->dev, "failed to find rtc clock\n"); - else - dev_dbg(&pdev->dev, "probe deferred due to missing rtc clk\n"); - return ret; - } - ret = clk_prepare_enable(info->rtc_clk); - if (ret) - return ret; + return PTR_ERR(info->rtc_clk); + } + clk_prepare_enable(info->rtc_clk); - if (info->data->needs_src_clk) { - info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src"); - if (IS_ERR(info->rtc_src_clk)) { - ret = PTR_ERR(info->rtc_src_clk); - if (ret != -EPROBE_DEFER) + if (info->data->needs_src_clk) { + info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src"); + if (IS_ERR(info->rtc_src_clk)) { dev_err(&pdev->dev, "failed to find rtc source clock\n"); - else - dev_dbg(&pdev->dev, - "probe deferred due to missing rtc src clk\n"); - goto err_src_clk; + clk_disable_unprepare(info->rtc_clk); + return PTR_ERR(info->rtc_src_clk); + } + clk_prepare_enable(info->rtc_src_clk); } - ret = clk_prepare_enable(info->rtc_src_clk); - if (ret) - goto err_src_clk; } - /* check to see if everything is setup correctly */ if (info->data->enable) info->data->enable(info); @@ -615,6 +614,9 @@ err_nortc: if (info->data->disable) info->data->disable(info); + if (info->data->clock_ctrl_disable) + return ret; + if (info->data->needs_src_clk) clk_disable_unprepare(info->rtc_src_clk); err_src_clk: @@ -843,6 +845,18 @@ static struct s3c_rtc_data const s3c6410_rtc_data = { .disable = s3c6410_rtc_disable, }; +static struct s3c_rtc_data const exynos8_rtc_data = { + .max_user_freq = 32768, + .clock_ctrl_disable = true, + .irq_handler = s3c6410_rtc_irq, + .set_freq = s3c6410_rtc_setfreq, + .enable_tick = s3c6410_rtc_enable_tick, + .save_tick_cnt = s3c6410_rtc_save_tick_cnt, + .restore_tick_cnt = s3c6410_rtc_restore_tick_cnt, + .enable = s3c24xx_rtc_enable, + .disable = s3c6410_rtc_disable, +}; + static const struct of_device_id s3c_rtc_dt_match[] = { { .compatible = "samsung,s3c2410-rtc", @@ -859,7 +873,11 @@ static const struct of_device_id s3c_rtc_dt_match[] = { }, { .compatible = "samsung,exynos3250-rtc", .data = &s3c6410_rtc_data, + }, { + .compatible = "samsung,exynos8-rtc", + .data = (void *)&exynos8_rtc_data, }, + { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match);