From patchwork Thu Apr 4 16:37:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2393991 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 538583FD8C for ; Thu, 4 Apr 2013 16:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762945Ab3DDQjM (ORCPT ); Thu, 4 Apr 2013 12:39:12 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:53038 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762587Ab3DDQjL (ORCPT ); Thu, 4 Apr 2013 12:39:11 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MKQ001QROX7UC00@mailout1.samsung.com> for linux-samsung-soc@vger.kernel.org; Fri, 05 Apr 2013 01:39:10 +0900 (KST) X-AuditID: cbfee61a-b7fa86d0000045ae-77-515dacae6e7a Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id FF.78.17838.EACAD515; Fri, 05 Apr 2013 01:39:10 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MKQ00F2OOU1P170@mmp1.samsung.com>; Fri, 05 Apr 2013 01:39:10 +0900 (KST) From: Tomasz Figa To: linux-arm-kernel@lists.infradead.org Cc: devicetree-discuss@lists.ozlabs.org, linux-samsung-soc@vger.kernel.org, sameo@linux.intel.com, kgene.kim@samsung.com, kyungmin.park@samsung.com, linux@simtec.co.uk, broonie@opensource.wolfsonmicro.com, kwangwoo.lee@gmail.com, jacmet@sunsite.dk, augulis.darius@gmail.com, mcuelenaere@gmail.com, linux@arm.linux.org.uk, sylvester.nawrocki@gmail.com, buserror@gmail.com, christer@weinigel.se, jekhor@gmail.com, ghcstop@gmail.com, mark.rutland@arm.com, tomasz.figa@gmail.com, heiko@sntech.de, robherring2@gmail.com, m.szyprowski@samsung.com, arnd@arndb.de, john.stultz@linaro.org, tglx@linutronix.de, Tomasz Figa Subject: [PATCH v4 09/14] clocksource: samsung-time: Use variant data to get SoC-specific bits Date: Thu, 04 Apr 2013 18:37:06 +0200 Message-id: <1365093431-30621-10-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1365093431-30621-1-git-send-email-t.figa@samsung.com> References: <1365093431-30621-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsVy+t9jAd11a2IDDS79k7T4O+kYu8Xet/8Y Lf7NPsVmcevzI3aLjSs/slkcmP2Q1eJoj53F/0evWS1OX7rGaHFw3VJWizO/dS16F1xls1ix 9QKLxdmmN+wWmx5fY7WYcX4fk8Xty7wWv7c1slisPXKX3WLp9YtMFpfmNbFYfP/2jc3idDer xbzPO5ks1s94zWKxedNUZotVu/4wOkh7rJm3htGjpbmHzeP3r0mMHjtn3WX3uHNtD5vHu3Pn 2D3mnQz02Lyk3uP8jIWMHi8n/mbz6NuyitHj/JupLB7br81j9pj2+jybx+dNch6vb8xmDBCI 4rJJSc3JLEst0rdL4MqYMPUrW8EitYqjfzrZGhg3KnQxcnJICJhInPl1iRnCFpO4cG89Wxcj F4eQwCJGib6l31ggnC4miWm9/SwgVWwCahKfGx6xgdgiAhoSU7oes4PYzAKdrBK7pouA2MIC CRK/T24GquHgYBFQldi8NAwkzCvgLHH17TKoZfIST+/3gY3hBIr/P/uBCcQWEnCSaPt9iHEC I+8CRoZVjKKpBckFxUnpuYZ6xYm5xaV56XrJ+bmbGMHx90xqB+PKBotDjAIcjEo8vBl9sYFC rIllxZW5hxglOJiVRHiPtgCFeFMSK6tSi/Lji0pzUosPMUpzsCiJ8x5otQ4UEkhPLEnNTk0t SC2CyTJxcEo1MO52nhR+aL1r/fVyi9n7gjr0t/MpPZ2x2OF7P+M0cbV78d8eRay6m2807+S8 k22J/DpeN6OSlV84tP/ZfPFd1HvB6s9ltb+mZt1ZPWPOXe6qyO7FiTW+nYF21Tf8noqdW75d W1K7a0bJvv1vTN7fusK1cVrB7uta21nar6p1vgn/1XHm2SHv4BglluKMREMt5qLiRACygyQS uwIAAA== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch modifies the driver to calculate SoC-specific parameters from variant data received from PWM/timer master driver. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park --- arch/arm/plat-samsung/include/plat/samsung-time.h | 17 -------- drivers/clocksource/samsung-time.c | 51 ++++++++++++++++++----- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/arch/arm/plat-samsung/include/plat/samsung-time.h b/arch/arm/plat-samsung/include/plat/samsung-time.h index c0f35cc..785c6b7 100644 --- a/arch/arm/plat-samsung/include/plat/samsung-time.h +++ b/arch/arm/plat-samsung/include/plat/samsung-time.h @@ -26,23 +26,6 @@ enum samsung_timer_mode { SAMSUNG_PWM4, }; -struct samsung_timer_source { - unsigned int event_id; - unsigned int source_id; -}; - -#if defined(CONFIG_ARCH_S3C24XX) || defined(CONFIG_ARCH_S5PC100) -#define TCNT_MAX 0xffff -#define TSCALER_DIV 25 -#define TDIV 50 -#define TSIZE 16 -#else -#define TCNT_MAX 0xffffffff -#define TSCALER_DIV 2 -#define TDIV 2 -#define TSIZE 32 -#endif - static inline void samsung_set_timer_source(enum samsung_timer_mode event, enum samsung_timer_mode source) { diff --git a/drivers/clocksource/samsung-time.c b/drivers/clocksource/samsung-time.c index 11d7a54..4fa6f6f 100644 --- a/drivers/clocksource/samsung-time.c +++ b/drivers/clocksource/samsung-time.c @@ -20,7 +20,6 @@ #include #include -#include #define S3C_TIMERREG(x) (pwm->base + (x)) #define S3C_TIMERREG2(tmr,reg) S3C_TIMERREG((reg)+0x0c+((tmr)*0x0c)) @@ -56,6 +55,22 @@ #define S3C2410_TCON_T0MANUALUPD (1<<1) #define S3C2410_TCON_T0START (1<<0) +enum samsung_timer_mode { + SAMSUNG_PWM0, + SAMSUNG_PWM1, + SAMSUNG_PWM2, + SAMSUNG_PWM3, + SAMSUNG_PWM4, +}; + +struct samsung_timer_source { + unsigned int event_id; + unsigned int source_id; + u32 tcnt_max; + u16 tscaler_div; + u16 tdiv; +}; + static struct samsung_pwm *pwm; static struct clk *tin_event; static struct clk *tin_source; @@ -248,7 +263,7 @@ static void samsung_timer_resume(void) samsung_time_start(timer_source.event_id, true); /* source timer restart */ - samsung_time_setup(timer_source.source_id, TCNT_MAX); + samsung_time_setup(timer_source.source_id, timer_source.tcnt_max); samsung_time_start(timer_source.source_id, true); } @@ -290,15 +305,17 @@ static void __init samsung_clockevent_init(void) tscaler = clk_get_parent(tdiv_event); - clk_set_rate(tscaler, pclk / TSCALER_DIV); - clk_set_rate(tdiv_event, pclk / TDIV); + clk_set_rate(tscaler, pclk / timer_source.tscaler_div); + clk_set_rate(tdiv_event, + pclk / (timer_source.tscaler_div * timer_source.tdiv)); clk_set_parent(tin_event, tdiv_event); clock_rate = clk_get_rate(tin_event); clock_count_per_tick = clock_rate / HZ; time_event_device.cpumask = cpumask_of(0); - clockevents_config_and_register(&time_event_device, clock_rate, 1, -1); + clockevents_config_and_register(&time_event_device, clock_rate, + 1, timer_source.tcnt_max); irq_number = pwm->irq[timer_source.event_id]; setup_irq(irq_number, &samsung_clock_event_irq); @@ -349,21 +366,26 @@ static void __init samsung_clocksource_init(void) { unsigned long pclk; unsigned long clock_rate; + int ret; pclk = clk_get_rate(timerclk); - clk_set_rate(tdiv_source, pclk / TDIV); + clk_set_rate(tdiv_source, + pclk / (timer_source.tscaler_div * timer_source.tdiv)); clk_set_parent(tin_source, tdiv_source); clock_rate = clk_get_rate(tin_source); - samsung_time_setup(timer_source.source_id, TCNT_MAX); + samsung_time_setup(timer_source.source_id, timer_source.tcnt_max); samsung_time_start(timer_source.source_id, true); - setup_sched_clock(samsung_read_sched_clock, TSIZE, clock_rate); + setup_sched_clock(samsung_read_sched_clock, + pwm->variant.bits, clock_rate); - if (clocksource_mmio_init(samsung_timer_reg(), "samsung_clocksource_timer", - clock_rate, 250, TSIZE, clocksource_mmio_readl_down)) + ret = clocksource_mmio_init(samsung_timer_reg(), + "samsung_clocksource_timer", clock_rate, 250, + pwm->variant.bits, clocksource_mmio_readl_down); + if (ret) panic("samsung_clocksource_timer: can't register clocksource\n"); } @@ -407,6 +429,15 @@ static void __init samsung_timer_resources(void) panic("failed to get pwm-tdiv clock for source timer"); clk_enable(tin_source); + + timer_source.tcnt_max = (1UL << pwm->variant.bits) - 1; + if (pwm->variant.bits == 16) { + timer_source.tscaler_div = 25; + timer_source.tdiv = 2; + } else { + timer_source.tscaler_div = 2; + timer_source.tdiv = 1; + } } void __init samsung_time_init(void)