summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-07-02 11:04:38 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-07-02 11:04:38 +0200
commit93d4ea2ac8ab696de04d053d1381944cbc85e3df (patch)
tree0f1fa535533e402bcb7bd8fcc93aad6d6a73a283
parent62fe47768b26b7dceda983a16b042ddc4b59d246 (diff)
parentc325d97cfdaf44df8e497725fcb34500f228a712 (diff)
downloadbarebox-93d4ea2ac8ab696de04d053d1381944cbc85e3df.tar.gz
barebox-93d4ea2ac8ab696de04d053d1381944cbc85e3df.tar.xz
Merge branch 'for-next/mips-clocksource'
-rw-r--r--arch/mips/mach-xburst/csrc-jz4750.c7
-rw-r--r--arch/ppc/mach-mpc85xx/include/mach/clocks.h2
-rw-r--r--include/clock.h2
-rw-r--r--include/linux/time.h152
4 files changed, 7 insertions, 156 deletions
diff --git a/arch/mips/mach-xburst/csrc-jz4750.c b/arch/mips/mach-xburst/csrc-jz4750.c
index f625b703a1..36e401e480 100644
--- a/arch/mips/mach-xburst/csrc-jz4750.c
+++ b/arch/mips/mach-xburst/csrc-jz4750.c
@@ -28,7 +28,7 @@
#include <io.h>
#include <mach/jz4750d_regs.h>
-#define JZ_TIMER_CLOCK 40000
+#define JZ_TIMER_CLOCK 24000000
static uint64_t jz4750_cs_read(void)
{
@@ -38,12 +38,13 @@ static uint64_t jz4750_cs_read(void)
static struct clocksource jz4750_cs = {
.read = jz4750_cs_read,
.mask = CLOCKSOURCE_MASK(32),
- .shift = 10,
};
static int clocksource_init(void)
{
- jz4750_cs.mult = clocksource_hz2mult(JZ_TIMER_CLOCK, jz4750_cs.shift);
+ clocks_calc_mult_shift(&jz4750_cs.mult, &jz4750_cs.shift,
+ JZ_TIMER_CLOCK, NSEC_PER_SEC, 10);
+
init_clock(&jz4750_cs);
__raw_writel(TCU_OSTCSR_PRESCALE1 | TCU_OSTCSR_EXT_EN,
diff --git a/arch/ppc/mach-mpc85xx/include/mach/clocks.h b/arch/ppc/mach-mpc85xx/include/mach/clocks.h
index 94771682e8..2ab367b2ec 100644
--- a/arch/ppc/mach-mpc85xx/include/mach/clocks.h
+++ b/arch/ppc/mach-mpc85xx/include/mach/clocks.h
@@ -10,8 +10,6 @@ struct sys_info {
unsigned long freqLocalBus;
};
-#define NSEC_PER_SEC 1000000000L
-
unsigned long fsl_get_bus_freq(ulong dummy);
unsigned long fsl_get_timebase_clock(void);
void fsl_get_sys_info(struct sys_info *sysInfo);
diff --git a/include/clock.h b/include/clock.h
index 123f8747a8..c01a8d00ab 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -3,6 +3,8 @@
#ifndef CLOCK_H
#define CLOCK_H
+#include <linux/time.h>
+
#define CLOCKSOURCE_MASK(bits) (uint64_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
struct clocksource {
diff --git a/include/linux/time.h b/include/linux/time.h
index bf12b99d37..3942e82e10 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -3,156 +3,6 @@
#include <linux/types.h>
-#define _DEFUN(a,b,c) a(c)
-#define _CONST const
-#define _AND ,
-
-#define _REENT_ONLY
-
-#define SECSPERMIN 60L
-#define MINSPERHOUR 60L
-#define HOURSPERDAY 24L
-#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
-#define SECSPERDAY (SECSPERHOUR * HOURSPERDAY)
-#define DAYSPERWEEK 7
-#define MONSPERYEAR 12
-
-#define YEAR_BASE 1900
-#define EPOCH_YEAR 1970
-#define EPOCH_WDAY 4
-
-#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
-
-
-/* Used by other time functions. */
-struct tm {
- int tm_sec; /* Seconds. [0-60] (1 leap second) */
- int tm_min; /* Minutes. [0-59] */
- int tm_hour; /* Hours. [0-23] */
- int tm_mday; /* Day. [1-31] */
- int tm_mon; /* Month. [0-11] */
- int tm_year; /* Year - 1900. */
- int tm_wday; /* Day of week. [0-6] */
- int tm_yday; /* Days in year.[0-365] */
- int tm_isdst; /* DST. [-1/0/1]*/
-
-# ifdef __USE_BSD
- long int tm_gmtoff; /* Seconds east of UTC. */
- __const char *tm_zone; /* Timezone abbreviation. */
-# else
- long int __tm_gmtoff; /* Seconds east of UTC. */
- __const char *__tm_zone; /* Timezone abbreviation. */
-# endif
-};
-
-static inline char *
-_DEFUN (asctime_r, (tim_p, result),
- _CONST struct tm *tim_p _AND
- char *result)
-{
- static _CONST char day_name[7][3] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
- };
- static _CONST char mon_name[12][3] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
-
- sprintf (result, "%.3s %.3s %.2d %.2d:%.2d:%.2d %d\n",
- day_name[tim_p->tm_wday],
- mon_name[tim_p->tm_mon],
- tim_p->tm_mday, tim_p->tm_hour, tim_p->tm_min,
- tim_p->tm_sec, 1900 + tim_p->tm_year);
- return result;
-}
-
-static inline struct tm *
-_DEFUN (localtime_r, (tim_p, res),
- _CONST time_t * tim_p _AND
- struct tm *res)
-{
- static _CONST int mon_lengths[2][MONSPERYEAR] = {
- {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
- {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
- } ;
-
- static _CONST int year_lengths[2] = {
- 365,
- 366
- } ;
-
- long days, rem;
- int y;
- int yleap;
- _CONST int *ip;
-
- days = ((long) *tim_p) / SECSPERDAY;
- rem = ((long) *tim_p) % SECSPERDAY;
- while (rem < 0)
- {
- rem += SECSPERDAY;
- --days;
- }
- while (rem >= SECSPERDAY)
- {
- rem -= SECSPERDAY;
- ++days;
- }
-
- /* compute hour, min, and sec */
- res->tm_hour = (int) (rem / SECSPERHOUR);
- rem %= SECSPERHOUR;
- res->tm_min = (int) (rem / SECSPERMIN);
- res->tm_sec = (int) (rem % SECSPERMIN);
-
- /* compute day of week */
- if ((res->tm_wday = ((EPOCH_WDAY + days) % DAYSPERWEEK)) < 0)
- res->tm_wday += DAYSPERWEEK;
-
- /* compute year & day of year */
- y = EPOCH_YEAR;
- if (days >= 0)
- {
- for (;;)
- {
- yleap = isleap(y);
- if (days < year_lengths[yleap])
- break;
- y++;
- days -= year_lengths[yleap];
- }
- }
- else
- {
- do
- {
- --y;
- yleap = isleap(y);
- days += year_lengths[yleap];
- } while (days < 0);
- }
-
- res->tm_year = y - YEAR_BASE;
- res->tm_yday = days;
- ip = mon_lengths[yleap];
- for (res->tm_mon = 0; days >= ip[res->tm_mon]; ++res->tm_mon)
- days -= ip[res->tm_mon];
- res->tm_mday = days + 1;
-
- /* set daylight saving time flag */
- res->tm_isdst = -1;
-
- return (res);
-}
-
-static inline char *
-_DEFUN (ctime_r, (tim_p, result),
- _CONST time_t * tim_p _AND
- char * result)
-
-{
- struct tm tm;
- return asctime_r (localtime_r (tim_p, &tm), result);
-}
+#define NSEC_PER_SEC 1000000000L
#endif