From patchwork Thu Apr 4 16:37:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2394021 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 F39623FD8C for ; Thu, 4 Apr 2013 16:39:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762758Ab3DDQji (ORCPT ); Thu, 4 Apr 2013 12:39:38 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:55124 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762587Ab3DDQji (ORCPT ); Thu, 4 Apr 2013 12:39:38 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MKQ00MOZOY00T80@mailout2.samsung.com> for linux-samsung-soc@vger.kernel.org; Fri, 05 Apr 2013 01:39:37 +0900 (KST) X-AuditID: cbfee61b-b7f076d0000034b6-c5-515dacc86dfe Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 95.1B.13494.8CCAD515; Fri, 05 Apr 2013 01:39:36 +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:36 +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 12/14] clocksource: samsung-time: Use master driver to control PWM channels Date: Thu, 04 Apr 2013 18:37:09 +0200 Message-id: <1365093431-30621-13-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+NgFlrJIsWRmVeSWpSXmKPExsVy+t9jAd0Ta2IDDbo+alr8nXSM3WLv23+M Fv9mn2KzuPX5EbvFxpUf2SwOzH7IanG0x87i/6PXrBanL11jtDi4bimrxZnfuha9C66yWazY eoHF4mzTG3aLTY+vsVrMOL+PyeL2ZV6L39saWSzWHrnLbrH0+kUmi0vzmlgsvn/7xmZxupvV Yt7nnUwW62e8ZrHYvGkqs8WqXX8YHaQ91sxbw+jR0tzD5vH71yRGj52z7rJ73Lm2h83j3blz 7B7zTgZ6bF5S73F+xkJGj5cTf7N59G1Zxehx/s1UFo/t1+Yxe0x7fZ7N4/MmOY/XN2YzBghE cdmkpOZklqUW6dslcGXMO3aZsaBTv+Ld/gmsDYz/1boYOTkkBEwk9q7uYIWwxSQu3FvP1sXI xSEksIhRYvG5oywQTheTxPK3+5lAqtgE1CQ+NzxiA7FFBDQkpnQ9ZgexmQU6WSV2TRcBsYUF EiRu/eplBrFZBFQltj4/BlbDK+Assf3XLxaIbfIST+/3gc3hBIr/P/sBbL6QgJNE2+9DjBMY eRcwMqxiFE0tSC4oTkrPNdIrTswtLs1L10vOz93ECI7AZ9I7GFc1WBxiFOBgVOLhzeiLDRRi TSwrrsw9xCjBwawkwnu0BSjEm5JYWZValB9fVJqTWnyIUZqDRUmc92CrdaCQQHpiSWp2ampB ahFMlomDU6qB0S9kcnjwq0nWQg9+7dVt1bkUIvDoPqPZvsPlRjeNKw4pb1C9y8Xer65g9TBI 6vRC2Wl+Huu2FN7OXs1o3mu2oupXe8irm4o/8je7uD8//jaAjX/R2r46c9U3LamBz5vjC/9/ ZOcWWXJzg+K81j9FbwueMLUVh9xMjnvpOOOHfG3/pEpLk6NKSizFGYmGWsxFxYkAZ7eP1rwC AAA= 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 use functions provided by the master driver to control status of PWM channels instead of modifying shared registers directly. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park --- drivers/clocksource/samsung-time.c | 168 ++++--------------------------------- 1 file changed, 15 insertions(+), 153 deletions(-) diff --git a/drivers/clocksource/samsung-time.c b/drivers/clocksource/samsung-time.c index 7674882..9425955 100644 --- a/drivers/clocksource/samsung-time.c +++ b/drivers/clocksource/samsung-time.c @@ -76,153 +76,11 @@ static struct samsung_timer_source timer_source; static unsigned long clock_count_per_tick; static void samsung_timer_resume(void); -static void samsung_time_stop(enum samsung_timer_mode mode) -{ - unsigned long tcon; - - tcon = __raw_readl(S3C2410_TCON); - - switch (mode) { - case SAMSUNG_PWM0: - tcon &= ~S3C2410_TCON_T0START; - break; - - case SAMSUNG_PWM1: - tcon &= ~S3C2410_TCON_T1START; - break; - - case SAMSUNG_PWM2: - tcon &= ~S3C2410_TCON_T2START; - break; - - case SAMSUNG_PWM3: - tcon &= ~S3C2410_TCON_T3START; - break; - - case SAMSUNG_PWM4: - tcon &= ~S3C2410_TCON_T4START; - break; - - default: - printk(KERN_ERR "Invalid Timer %d\n", mode); - break; - } - __raw_writel(tcon, S3C2410_TCON); -} - -static void samsung_time_setup(enum samsung_timer_mode mode, unsigned long tcnt) -{ - unsigned long tcon; - - tcon = __raw_readl(S3C2410_TCON); - - tcnt--; - - switch (mode) { - case SAMSUNG_PWM0: - tcon &= ~(0x0f << 0); - tcon |= S3C2410_TCON_T0MANUALUPD; - break; - - case SAMSUNG_PWM1: - tcon &= ~(0x0f << 8); - tcon |= S3C2410_TCON_T1MANUALUPD; - break; - - case SAMSUNG_PWM2: - tcon &= ~(0x0f << 12); - tcon |= S3C2410_TCON_T2MANUALUPD; - break; - - case SAMSUNG_PWM3: - tcon &= ~(0x0f << 16); - tcon |= S3C2410_TCON_T3MANUALUPD; - break; - - case SAMSUNG_PWM4: - tcon &= ~(0x07 << 20); - tcon |= S3C2410_TCON_T4MANUALUPD; - break; - - default: - printk(KERN_ERR "Invalid Timer %d\n", mode); - break; - } - - __raw_writel(tcnt, S3C2410_TCNTB(mode)); - __raw_writel(tcnt, S3C2410_TCMPB(mode)); - __raw_writel(tcon, S3C2410_TCON); -} - -static void samsung_time_start(enum samsung_timer_mode mode, bool periodic) -{ - unsigned long tcon; - - tcon = __raw_readl(S3C2410_TCON); - - switch (mode) { - case SAMSUNG_PWM0: - tcon |= S3C2410_TCON_T0START; - tcon &= ~S3C2410_TCON_T0MANUALUPD; - - if (periodic) - tcon |= S3C2410_TCON_T0RELOAD; - else - tcon &= ~S3C2410_TCON_T0RELOAD; - break; - - case SAMSUNG_PWM1: - tcon |= S3C2410_TCON_T1START; - tcon &= ~S3C2410_TCON_T1MANUALUPD; - - if (periodic) - tcon |= S3C2410_TCON_T1RELOAD; - else - tcon &= ~S3C2410_TCON_T1RELOAD; - break; - - case SAMSUNG_PWM2: - tcon |= S3C2410_TCON_T2START; - tcon &= ~S3C2410_TCON_T2MANUALUPD; - - if (periodic) - tcon |= S3C2410_TCON_T2RELOAD; - else - tcon &= ~S3C2410_TCON_T2RELOAD; - break; - - case SAMSUNG_PWM3: - tcon |= S3C2410_TCON_T3START; - tcon &= ~S3C2410_TCON_T3MANUALUPD; - - if (periodic) - tcon |= S3C2410_TCON_T3RELOAD; - else - tcon &= ~S3C2410_TCON_T3RELOAD; - break; - - case SAMSUNG_PWM4: - tcon |= S3C2410_TCON_T4START; - tcon &= ~S3C2410_TCON_T4MANUALUPD; - - if (periodic) - tcon |= S3C2410_TCON_T4RELOAD; - else - tcon &= ~S3C2410_TCON_T4RELOAD; - break; - - default: - printk(KERN_ERR "Invalid Timer %d\n", mode); - break; - } - __raw_writel(tcon, S3C2410_TCON); -} - static int samsung_set_next_event(unsigned long cycles, struct clock_event_device *evt) { - samsung_time_setup(timer_source.event_id, cycles); - samsung_time_start(timer_source.event_id, false); + samsung_pwm_setup(pwm, timer_source.event_id, cycles - 1, cycles - 1); + samsung_pwm_start(pwm, timer_source.event_id, false); return 0; } @@ -230,12 +88,13 @@ static int samsung_set_next_event(unsigned long cycles, static void samsung_set_mode(enum clock_event_mode mode, struct clock_event_device *evt) { - samsung_time_stop(timer_source.event_id); + samsung_pwm_stop(pwm, timer_source.event_id); switch (mode) { case CLOCK_EVT_MODE_PERIODIC: - samsung_time_setup(timer_source.event_id, clock_count_per_tick); - samsung_time_start(timer_source.event_id, true); + samsung_pwm_setup(pwm, timer_source.event_id, + clock_count_per_tick - 1, clock_count_per_tick - 1); + samsung_pwm_start(pwm, timer_source.event_id, true); break; case CLOCK_EVT_MODE_ONESHOT: @@ -254,12 +113,14 @@ static void samsung_set_mode(enum clock_event_mode mode, static void samsung_timer_resume(void) { /* event timer restart */ - samsung_time_setup(timer_source.event_id, clock_count_per_tick); - samsung_time_start(timer_source.event_id, true); + samsung_pwm_setup(pwm, timer_source.event_id, + clock_count_per_tick - 1, clock_count_per_tick - 1); + samsung_pwm_start(pwm, timer_source.event_id, true); /* source timer restart */ - samsung_time_setup(timer_source.source_id, timer_source.tcnt_max); - samsung_time_start(timer_source.source_id, true); + samsung_pwm_setup(pwm, timer_source.source_id, + timer_source.tcnt_max, timer_source.tcnt_max); + samsung_pwm_start(pwm, timer_source.source_id, true); } static struct clock_event_device time_event_device = { @@ -364,8 +225,9 @@ static void __init samsung_clocksource_init(void) clock_rate = pclk / (timer_source.tscaler_div * timer_source.tdiv); - samsung_time_setup(timer_source.source_id, timer_source.tcnt_max); - samsung_time_start(timer_source.source_id, true); + samsung_pwm_setup(pwm, timer_source.source_id, + timer_source.tcnt_max, timer_source.tcnt_max); + samsung_pwm_start(pwm, timer_source.source_id, true); setup_sched_clock(samsung_read_sched_clock, pwm->variant.bits, clock_rate);