unicore32 core architecture: timer and time
Subsystems (2)
PATCH 9/12 unicore32 core architecture: timer and time
From: Guan Xuetao <[email protected]>
Patch 9 implements timer and time. RTC and PWM device drivers are also here.
--- arch/unicore32/include/asm/timex.h | 34 +++ arch/unicore32/kernel/time.c | 157 +++++++++++++++ drivers/staging/puv3/puv3_pwm.c | 271 +++++++++++++++++++++++++ drivers/staging/puv3/puv3_rtc.c | 388 ++++++++++++++++++++++++++++++++++++ 4 files changed, 850 insertions(+), 0 deletions(-)
arch/unicore32/include/asm/timex.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* linux/arch/unicore32/include/asm/timex.h +* +* Code specific to PKUnity SoC and UniCore ISA +* +* Copyright (C) 2001-2010 GUAN Xue-tao +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __UNICORE_TIMEX_H__ +#define __UNICORE_TIMEX_H__ + +#ifdef CONFIG_ARCH_FPGA + +/* in FPGA, APB clock is 33M, and OST clock is 32K, */ +/* so, 1M is selected for timer interrupt correctly */ +#define CLOCK_TICK_RATE (32*1024) + +#endif + +#if defined(CONFIG_PUV3_DB0913 ) \ + || defined(CONFIG_PUV3_NB0916 ) \ + || defined(CONFIG_PUV3_SMW0919 ) + +#define CLOCK_TICK_RATE (14318000) + +#endif + +#include <asm-generic/timex.h> + +#endif
arch/unicore32/kernel/time.c new file +157 -0
157 lines not on this page · raw message
drivers/staging/puv3/puv3_pwm.c new file +271 -0
271 lines not on this page · raw message
drivers/staging/puv3/puv3_rtc.c new file +388 -0
388 lines not on this page · raw message
2010/12/25 Guan Xuetao <[email protected]>:
Quoted 5 lines
From: Guan Xuetao <[email protected]>
Patch 9 implements timer and time. RTC and PWM device drivers are also here.
Signed-off-by Guan Xuetao <[email protected]>
Just a small request:
Quoted 6 lines
+static struct clocksource
cksrc_puv3_oscr= {
+ .name = "oscr",
+ .rating = 200,
+ .read =puv3_read_oscr,
+ .mask =CLOCKSOURCE_MASK(32),
+ .shift = 18,
Drop the shift assignment here.
Quoted 3 lines
+ cksrc_puv3_oscr.mult =
+clocksource_hz2mult(CLOCK_TICK_RATE, cksrc_puv3_oscr.shift); +
Drop the mult assignment here.
Quoted 1 line
+
clocksource_register(&cksrc_puv3_oscr);
Use "clocksource_register_hz(&cksrc_puv3_oscr, CLOCK_TICK_RATE );" and the kernel will fill in mult/shift appropriately.
If you have any troubles after doing so, let me know.
thanks
-john
Quoted 33 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of john stultz
Sent: Tuesday, December 28, 2010 5:27 AM
To: Guan Xuetao
Cc: [email protected]; [email protected]
Subject: Re: [PATCHv1 09/12] unicore32 core architecture: timer and time2010/12/25 Guan Xuetao <[email protected]>:
Quoted 5 lines
From: Guan Xuetao <[email protected]>
Patch 9 implements timer and time. RTC and PWM device drivers are also here.
Signed-off-by Guan Xuetao <[email protected]>Just a small request:
Quoted 6 lines
+static struct clocksource
cksrc_puv3_oscr= {
+ .name = "oscr",
+ .rating = 200,
+ .read =puv3_read_oscr,
+ .mask =CLOCKSOURCE_MASK(32),
+ .shift = 18,Drop the shift assignment here.
Quoted 3 lines
+ cksrc_puv3_oscr.mult =
+clocksource_hz2mult(CLOCK_TICK_RATE, cksrc_puv3_oscr.shift); +Drop the mult assignment here.
Quoted 6 lines
Quoted 1 line
+
clocksource_register(&cksrc_puv3_oscr);Use "
clocksource_register_hz(&cksrc_puv3_oscr, CLOCK_TICK_RATE );" and the kernel will fill in mult/shift appropriately.If you have any troubles after doing so, let me know.
When using clocksource_register_hz(&cksrc_puv3_oscr, CLOCK_TICK_RATE ),
the shift value become 0, and mult value become 0x838a91a7, and the system will be broken
after printing "Switching to clocksource oscr".
When using clocksource_register_khz(&cksrc_puv3_oscr, CLOCK_TICK_RATE ),
the shift value become 0, and mult value become 0x4359611, and the system will run smoothly, but timer interrupt seems too frequently. Perhaps it is 4 times faster.
For comparison, originally, when shift value is set to 0x12, the mult value become 1175e5e.
Which one is better?
Quoted 3 lines
thanks
-john
Thanks john.
Guan Xuetao
Quoted 53 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Guan Xuetao
Sent: Sunday, January 02, 2011 5:48 PM
To: 'john stultz'
Cc: [email protected]; [email protected]
Subject: RE: [PATCHv1 09/12] unicore32 core architecture: timer and timeQuoted 31 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of john stultz
Sent: Tuesday, December 28, 2010 5:27 AM
To: Guan Xuetao
Cc: [email protected]; [email protected]
Subject: Re: [PATCHv1 09/12] unicore32 core architecture: timer and time2010/12/25 Guan Xuetao <[email protected]>:
Quoted 5 lines
From: Guan Xuetao <[email protected]>
Patch 9 implements timer and time. RTC and PWM device drivers are also here.
Signed-off-by Guan Xuetao <[email protected]>Just a small request:
Quoted 6 lines
+static struct clocksource
cksrc_puv3_oscr= {
+ .name = "oscr",
+ .rating = 200,
+ .read =puv3_read_oscr,
+ .mask =CLOCKSOURCE_MASK(32),
+ .shift = 18,Drop the shift assignment here.
Quoted 3 lines
+ cksrc_puv3_oscr.mult =
+clocksource_hz2mult(CLOCK_TICK_RATE, cksrc_puv3_oscr.shift); +Drop the mult assignment here.
Quoted 6 lines
Quoted 1 line
+
clocksource_register(&cksrc_puv3_oscr);Use "
clocksource_register_hz(&cksrc_puv3_oscr, CLOCK_TICK_RATE );" and the kernel will fill in mult/shift appropriately.If you have any troubles after doing so, let me know.
When using
clocksource_register_hz(&cksrc_puv3_oscr, CLOCK_TICK_RATE ),
the shift value become 0, and mult value become0x838a91a7, and the system will be broken
after printing "Switching to clocksource oscr".
Quoted 6 lines
When using
clocksource_register_khz(&cksrc_puv3_oscr, CLOCK_TICK_RATE ),
the shift value become 0, and mult value become0x4359611, and the system will run smoothly, but timer interrupt seems too frequently. Perhaps it is 4 times faster.For comparison, originally, when shift value is set to
0x12, the mult value become 1175e5e.
The error is the implementation of do_div() function.
When replacing the arch-specific div64.h with asm-generic/div64.h, clocksource_rigister_hz() works. Thanks.
Quoted 10 lines
Which one is better?
Quoted 3 lines
thanks
-johnThanks john.
Guan Xuetao
Guan Xuetao
Quoted 8 lines · Guan Xuetao
Quoted 8 lines
When using
clocksource_register_hz(&cksrc_puv3_oscr, CLOCK_TICK_RATE ),
the shift value become 0, and mult value become0x838a91a7, and the system will be broken
after printing "Switching to clocksource oscr".When using
clocksource_register_khz(&cksrc_puv3_oscr, CLOCK_TICK_RATE ),
the shift value become 0, and mult value become0x4359611, and the system will run smoothly, but timer interrupt seems too frequently. Perhaps it is 4 times faster.
Quoted 5 lines
Quoted 2 lines
For comparison, originally, when shift value is set to
0x12, the mult value become 1175e5e.The error is the implementation of
do_div()function.
When replacing the arch-specificdiv64.hwithasm-generic/div64.h,clocksource_rigister_hz()works.
Oh great! You had me worried I had a bug in the mult/shift calculation.
Great to hear all is working now! If you run into other clock/time related troubles, please let me know.
thanks
-john