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: 2394111 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id DBF0ADF25A for ; Thu, 4 Apr 2013 16:42:07 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UNnEl-0002YS-3b for patchwork-linux-arm@patchwork.kernel.org; Thu, 04 Apr 2013 16:42:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UNnDk-00055K-TV; Thu, 04 Apr 2013 16:41:04 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UNnBv-0003fW-MM for linux-arm-kernel@lists.infradead.org; Thu, 04 Apr 2013 16:39:14 +0000 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-arm-kernel@lists.infradead.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 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== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130404_123912_281796_6ACDEF53 X-CRM114-Status: GOOD ( 12.40 ) X-Spam-Score: -7.5 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.24 listed in list.dnswl.org] 1.7 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -2.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: mark.rutland@arm.com, heiko@sntech.de, Tomasz Figa , tomasz.figa@gmail.com, buserror@gmail.com, jacmet@sunsite.dk, augulis.darius@gmail.com, christer@weinigel.se, sylvester.nawrocki@gmail.com, m.szyprowski@samsung.com, kgene.kim@samsung.com, linux@arm.linux.org.uk, sameo@linux.intel.com, kwangwoo.lee@gmail.com, mcuelenaere@gmail.com, arnd@arndb.de, devicetree-discuss@lists.ozlabs.org, linux-samsung-soc@vger.kernel.org, john.stultz@linaro.org, ghcstop@gmail.com, linux@simtec.co.uk, broonie@opensource.wolfsonmicro.com, jekhor@gmail.com, kyungmin.park@samsung.com, tglx@linutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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)