Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95177461 authored by Greg Ungerer's avatar Greg Ungerer
Browse files

m68knommu: make persistent clock code consistent with m68k



The read_persistent_clock() code is different on m68knommu, for really no
reason. With a few changes to support function names and some code
re-organization the code can be made the same.

This will make it easier to merge the arch/m68k/kernel/time.c for m68k and
m68knommu in a future patch.

Signed-off-by: default avatarGreg Ungerer <gerg@uclinux.org>
parent d3f033f8
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -22,8 +22,6 @@ extern unsigned int (*mach_get_ss)(void);
extern int (*mach_get_rtc_pll)(struct rtc_pll_info *);
extern int (*mach_set_rtc_pll)(struct rtc_pll_info *);
extern int (*mach_set_clock_mmss)(unsigned long);
extern void (*mach_gettod)(int *year, int *mon, int *day, int *hour,
			    int *min, int *sec);
extern void (*mach_reset)( void );
extern void (*mach_halt)( void );
extern void (*mach_power_off)( void );
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <linux/init.h>
#include <linux/initrd.h>
#include <linux/root_dev.h>
#include <linux/rtc.h>

#include <asm/setup.h>
#include <asm/irq.h>
@@ -48,6 +49,7 @@ char __initdata command_line[COMMAND_LINE_SIZE];

/* machine dependent timer functions */
int (*mach_set_clock_mmss)(unsigned long);
int (*mach_hwclk) (int, struct rtc_time*);

/* machine dependent reboot functions */
void (*mach_reset)(void);
+12 −24
Original line number Diff line number Diff line
@@ -20,15 +20,11 @@
#include <linux/profile.h>
#include <linux/time.h>
#include <linux/timex.h>
#include <linux/rtc.h>

#include <asm/machdep.h>
#include <asm/irq_regs.h>

#define	TICK_SIZE (tick_nsec / 1000)

/* machine dependent timer functions */
void (*mach_gettod)(int*, int*, int*, int*, int*, int*);

static inline int set_rtc_mmss(unsigned long nowtime)
{
	if (mach_set_clock_mmss)
@@ -55,28 +51,20 @@ irqreturn_t arch_timer_interrupt(int irq, void *dummy)
}
#endif

static unsigned long read_rtc_mmss(void)
void read_persistent_clock(struct timespec *ts)
{
	unsigned int year, mon, day, hour, min, sec;

	if (mach_gettod) {
		mach_gettod(&year, &mon, &day, &hour, &min, &sec);
		if ((year += 1900) < 1970)
			year += 100;
	} else {
		year = 1970;
		mon = day = 1;
		hour = min = sec = 0;
	}
	struct rtc_time time;
	ts->tv_sec = 0;
	ts->tv_nsec = 0;

	if (mach_hwclk) {
		mach_hwclk(0, &time);

	return  mktime(year, mon, day, hour, min, sec);
		if ((time.tm_year += 1900) < 1970)
			time.tm_year += 100;
		ts->tv_sec = mktime(time.tm_year, time.tm_mon, time.tm_mday,
			time.tm_hour, time.tm_min, time.tm_sec);
	}

void read_persistent_clock(struct timespec *ts)
{
	ts->tv_sec = read_rtc_mmss();
	ts->tv_nsec = 0;
}

int update_persistent_clock(struct timespec now)
+3 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/rtc.h>
#include <asm/system.h>
#include <asm/machdep.h>
#include <asm/MC68328.h>
@@ -26,7 +27,7 @@

/***************************************************************************/

void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec);
int m68328_hwclk(int set, struct rtc_time *t);

/***************************************************************************/

@@ -48,7 +49,7 @@ void config_BSP(char *command, int len)
  printk(KERN_INFO "68328 support Kenneth Albanowski <kjahds@kjshds.com>\n");
  printk(KERN_INFO "68328/Pilot support Bernhard Kuhn <kuhn@lpr.e-technik.tu-muenchen.de>\n");

  mach_gettod = m68328_timer_gettod;
  mach_hwclk = m68328_hwclk;
  mach_reset = m68328_reset;
}

+11 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/clocksource.h>
#include <linux/rtc.h>
#include <asm/setup.h>
#include <asm/system.h>
#include <asm/pgtable.h>
@@ -119,14 +120,17 @@ void hw_timer_init(void)

/***************************************************************************/

void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec)
int m68328_hwclk(int set, struct rtc_time *t)
{
	if (!set) {
		long now = RTCTIME;
		t->tm_year = t->tm_mon = t->tm_mday = 1;
		t->tm_hour = (now >> 24) % 24;
		t->tm_min = (now >> 16) % 60;
		t->tm_sec = now % 60;
	}

	*year = *mon = *day = 1;
	*hour = (now >> 24) % 24;
	*min = (now >> 16) % 60;
	*sec = now % 60;
	return 0;
}

/***************************************************************************/
Loading