From patchwork Thu Apr 4 16:37:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2394101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id AEADE3FD8C for ; Thu, 4 Apr 2013 16:41:35 +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 1UNnEE-0002Qx-S1 for patchwork-linux-arm@patchwork.kernel.org; Thu, 04 Apr 2013 16:41:35 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UNnDU-0004rx-C7; Thu, 04 Apr 2013 16:40:48 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UNnBm-0003Yl-Ts for linux-arm-kernel@lists.infradead.org; Thu, 04 Apr 2013 16:39:07 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MKQ008A9OWWS790@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 05 Apr 2013 01:39:00 +0900 (KST) X-AuditID: cbfee61a-b7fa86d0000045ae-62-515daca3f866 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 88.78.17838.3ACAD515; Fri, 05 Apr 2013 01:38:59 +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:38:59 +0900 (KST) From: Tomasz Figa To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 08/14] clocksource: samsung-time: Use Samsung PWM/timer master driver Date: Thu, 04 Apr 2013 18:37:05 +0200 Message-id: <1365093431-30621-9-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+t9jAd3Fa2IDDV5s07f4O+kYu8Xet/8Y Lf7NPsVmcevzI3aLjSs/slkcmP2Q1eJoj53F/0evWS1OX7rGaHFw3VJWizO/dS16F1xls1ix 9QKLxdmmN+wWmx5fY7WYcX4fk8Xty7wWv7c1slisPXKX3WLp9YtMFpfmNbFYfP/2jc3idDer xbzPO5ks1s94zWKxedNUZotVu/4wOkh7rJm3htGjpbmHzeP3r0mMHjtn3WX3uHNtD5vHu3Pn 2D3mnQz02Lyk3uP8jIWMHi8n/mbz6NuyitHj/JupLB7br81j9pj2+jybx+dNch6vb8xmDBCI 4rJJSc3JLEst0rdL4MroO/2UqeCbTsWbCSsYGxjb1LoYOTkkBEwkjn9vYIGwxSQu3FvPBmIL CSxilJjZ5NjFyAVkdzFJHPn6mR0kwSagJvG54RFYkYiAhsSUrsdgcWaBTlaJXdNFQGxhgSiJ Y8dfMYPYLAKqEpemN7KC2LwCThL3tsyGWiYv8fR+H9gcTgFnif9nPzBBLHaSaPt9iHECI+8C RoZVjKKpBckFxUnpuYZ6xYm5xaV56XrJ+bmbGMHx90xqB+PKBotDjAIcjEo8vBl9sYFCrIll xZW5hxglOJiVRHiPtgCFeFMSK6tSi/Lji0pzUosPMUpzsCiJ8x5otQ4UEkhPLEnNTk0tSC2C yTJxcEo1MLLomC3l9ww9KdNz6Hmk9H8vS8GXDu8WLdUxd2g09dZdKTtZfdIrpebijvV6b9cz fV0c0Tp5uoQXS+KrYwu44vRFC/9v0mKYXxe9/++5wHtlei+iq3NrZkiy187SWH1/1uw8xvlt ld5iIvrPme5xpOrYLuJ4da9x4x5TXtbQ/v6ydT/2uJZqKbEUZyQaajEXFScCALhqVD+7AgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130404_123903_468951_B49FE3EC X-CRM114-Status: GOOD ( 15.00 ) 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.33 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 samsung-time clocksource driver to use the interface provided by Samsung PWM/timer master driver to get platform data. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park --- arch/arm/plat-samsung/devs.c | 7 ++++ arch/arm/plat-samsung/include/plat/samsung-time.h | 17 +++++++-- drivers/clocksource/samsung-time.c | 44 ++++++++++++++--------- include/linux/platform_data/samsung-pwm.h | 1 + 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c index bfae4dd..747763d 100644 --- a/arch/arm/plat-samsung/devs.c +++ b/arch/arm/plat-samsung/devs.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -1184,6 +1185,12 @@ struct platform_device samsung_device_pwm = { .resource = samsung_pwm_resource, }; +void samsung_timer_init(void) +{ + samsung_pwm_register(&samsung_device_pwm); + samsung_time_init(); +} + /* RTC */ #ifdef CONFIG_PLAT_S3C24XX diff --git a/arch/arm/plat-samsung/include/plat/samsung-time.h b/arch/arm/plat-samsung/include/plat/samsung-time.h index 5d098ef..c0f35cc 100644 --- a/arch/arm/plat-samsung/include/plat/samsung-time.h +++ b/arch/arm/plat-samsung/include/plat/samsung-time.h @@ -13,6 +13,10 @@ #ifndef __ASM_PLAT_SAMSUNG_TIME_H #define __ASM_PLAT_SAMSUNG_TIME_H __FILE__ +#include + +#include + /* SAMSUNG HR-Timer Clock mode */ enum samsung_timer_mode { SAMSUNG_PWM0, @@ -39,8 +43,17 @@ struct samsung_timer_source { #define TSIZE 32 #endif -extern void __init samsung_set_timer_source(enum samsung_timer_mode event, - enum samsung_timer_mode source); +static inline void samsung_set_timer_source(enum samsung_timer_mode event, + enum samsung_timer_mode source) +{ + struct samsung_pwm_variant *variant; + + variant = samsung_device_pwm.dev.platform_data; + BUG_ON(!variant); + + variant->output_mask = (1 << 5) - 1; + variant->output_mask &= ~((1 << event) | (1 << source)); +} extern void __init samsung_timer_init(void); diff --git a/drivers/clocksource/samsung-time.c b/drivers/clocksource/samsung-time.c index bccc291..11d7a54 100644 --- a/drivers/clocksource/samsung-time.c +++ b/drivers/clocksource/samsung-time.c @@ -14,19 +14,14 @@ #include #include #include +#include #include -#include -#include -#include -#include #include -#include #include #include - -#define S3C_TIMERREG(x) (S3C_VA_TIMER + (x)) +#define S3C_TIMERREG(x) (pwm->base + (x)) #define S3C_TIMERREG2(tmr,reg) S3C_TIMERREG((reg)+0x0c+((tmr)*0x0c)) #define S3C2410_TCON S3C_TIMERREG(0x08) @@ -61,6 +56,7 @@ #define S3C2410_TCON_T0MANUALUPD (1<<1) #define S3C2410_TCON_T0START (1<<0) +static struct samsung_pwm *pwm; static struct clk *tin_event; static struct clk *tin_source; static struct clk *tdiv_event; @@ -256,16 +252,9 @@ static void samsung_timer_resume(void) samsung_time_start(timer_source.source_id, true); } -void __init samsung_set_timer_source(enum samsung_timer_mode event, - enum samsung_timer_mode source) -{ s3c_device_timer[event].dev.bus = &platform_bus_type; s3c_device_timer[source].dev.bus = &platform_bus_type; - timer_source.event_id = event; - timer_source.source_id = source; -} - static struct clock_event_device time_event_device = { .name = "samsung_event_timer", .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, @@ -311,7 +300,7 @@ static void __init samsung_clockevent_init(void) time_event_device.cpumask = cpumask_of(0); clockevents_config_and_register(&time_event_device, clock_rate, 1, -1); - irq_number = timer_source.event_id + IRQ_TIMER0; + irq_number = pwm->irq[timer_source.event_id]; setup_irq(irq_number, &samsung_clock_event_irq); } @@ -420,8 +409,31 @@ static void __init samsung_timer_resources(void) clk_enable(tin_source); } -void __init samsung_timer_init(void) +void __init samsung_time_init(void) { + u8 mask; + int channel; + + pwm = samsung_pwm_get(NULL); + if (IS_ERR(pwm)) + panic("failed to get PWM device"); + + mask = ~pwm->variant.output_mask & ((1 << SAMSUNG_PWM_NUM) - 1); + channel = fls(mask) - 1; + if (channel < 0) + panic("failed to find PWM channel for clocksource"); + timer_source.source_id = channel; + + samsung_pwm_request(pwm, channel); + + mask &= ~(1 << channel); + channel = fls(mask) - 1; + if (channel < 0) + panic("failed to find PWM channel for clock event"); + timer_source.event_id = channel; + + samsung_pwm_request(pwm, channel); + samsung_timer_resources(); samsung_clockevent_init(); samsung_clocksource_init(); diff --git a/include/linux/platform_data/samsung-pwm.h b/include/linux/platform_data/samsung-pwm.h index 8c48dbb..ca6c488 100644 --- a/include/linux/platform_data/samsung-pwm.h +++ b/include/linux/platform_data/samsung-pwm.h @@ -24,5 +24,6 @@ struct samsung_pwm_variant { }; extern int samsung_pwm_register(struct platform_device *pdev); +extern void samsung_time_init(void); #endif