Skip to content
Snippets Groups Projects
Commit 4b550488 authored by Ralf Baechle's avatar Ralf Baechle
Browse files

[MIPS] Deforest the function pointer jungle in the time code.


Hard to follow who is pointing what to where and why so it's simply getting
in the way of the time code renovation.

Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent f5ff0a28
No related branches found
No related tags found
No related merge requests found
Showing
with 37 additions and 97 deletions
......@@ -50,7 +50,6 @@ extern void au1000_halt(void);
extern void au1000_power_off(void);
extern void au1x_time_init(void);
extern void au1x_timer_setup(struct irqaction *irq);
extern void au1xxx_time_init(void);
extern void set_cpuspec(void);
void __init plat_mem_setup(void)
......@@ -112,7 +111,6 @@ void __init plat_mem_setup(void)
_machine_restart = au1000_restart;
_machine_halt = au1000_halt;
pm_power_off = au1000_power_off;
board_time_init = au1xxx_time_init;
/* IO/MEM resources. */
set_io_port_base(0);
......
......@@ -329,7 +329,3 @@ void __init plat_timer_setup(struct irqaction *irq)
#endif
}
void __init au1xxx_time_init(void)
{
}
......@@ -68,7 +68,7 @@ DEFINE_SPINLOCK(titan_lock);
int titan_irqflags;
static void excite_timer_init(void)
void __init plat_time_init(void)
{
const u32 modebit5 = ocd_readl(0x00e4);
unsigned int
......@@ -261,9 +261,6 @@ void __init plat_mem_setup(void)
/* Announce RAM to system */
add_memory_region(0x00000000, memsize, BOOT_MEM_RAM);
/* Set up timer initialization hooks */
board_time_init = excite_timer_init;
/* Set up the peripheral address map */
*(boot_ocd_base + (LKB9 / sizeof (u32))) = 0;
*(boot_ocd_base + (LKB10 / sizeof (u32))) = 0;
......
......@@ -119,6 +119,5 @@ void __init plat_mem_setup(void)
_machine_restart = bcm47xx_machine_restart;
_machine_halt = bcm47xx_machine_halt;
pm_power_off = bcm47xx_machine_halt;
board_time_init = bcm47xx_time_init;
}
......@@ -28,8 +28,7 @@
#include <asm/time.h>
#include <bcm47xx.h>
void __init
bcm47xx_time_init(void)
void __init plat_time_init(void)
{
unsigned long hz;
......
......@@ -145,13 +145,9 @@ static void __init dec_be_init(void)
}
}
extern void dec_time_init(void);
void __init plat_mem_setup(void)
{
board_be_init = dec_be_init;
board_time_init = dec_time_init;
wbflush_setup();
......
......@@ -35,7 +35,7 @@
#include <asm/dec/ioasic_addrs.h>
#include <asm/dec/machtype.h>
static unsigned long dec_rtc_get_time(void)
unsigned long read_persistent_clock(void)
{
unsigned int year, mon, day, hour, min, sec, real_year;
unsigned long flags;
......@@ -74,13 +74,13 @@ static unsigned long dec_rtc_get_time(void)
}
/*
* In order to set the CMOS clock precisely, dec_rtc_set_mmss has to
* In order to set the CMOS clock precisely, rtc_mips_set_mmss has to
* be called 500 ms after the second nowtime has started, because when
* nowtime is written into the registers of the CMOS clock, it will
* jump to the next second precisely 500 ms later. Check the Dallas
* DS1287 data sheet for details.
*/
static int dec_rtc_set_mmss(unsigned long nowtime)
int rtc_mips_set_mmss(unsigned long nowtime)
{
int retval = 0;
int real_seconds, real_minutes, cmos_minutes;
......@@ -139,7 +139,6 @@ static int dec_rtc_set_mmss(unsigned long nowtime)
return retval;
}
static int dec_timer_state(void)
{
return (CMOS_READ(RTC_REG_C) & RTC_PF) != 0;
......@@ -160,11 +159,8 @@ static cycle_t dec_ioasic_hpt_read(void)
}
void __init dec_time_init(void)
void __init plat_time_init(void)
{
rtc_mips_get_time = dec_rtc_get_time;
rtc_mips_set_mmss = dec_rtc_set_mmss;
mips_timer_state = dec_timer_state;
mips_timer_ack = dec_timer_ack;
......
......@@ -88,7 +88,7 @@ static unsigned int __init detect_bus_frequency(unsigned long rtc_base)
return clock[reg];
}
static void __init emma2rh_time_init(void)
void __init plat_time_init(void)
{
u32 reg;
if (bus_frequency == 0)
......@@ -124,8 +124,6 @@ void __init plat_mem_setup(void)
set_io_port_base(KSEG1ADDR(EMMA2RH_PCI_IO_BASE));
board_time_init = emma2rh_time_init;
_machine_restart = markeins_machine_restart;
_machine_halt = markeins_machine_halt;
pm_power_off = markeins_machine_power_off;
......
......@@ -126,7 +126,6 @@ static void wrppmc_setup_serial(void)
void __init plat_mem_setup(void)
{
extern void wrppmc_time_init(void);
extern void wrppmc_machine_restart(char *command);
extern void wrppmc_machine_halt(void);
extern void wrppmc_machine_power_off(void);
......@@ -135,9 +134,6 @@ void __init plat_mem_setup(void)
_machine_halt = wrppmc_machine_halt;
pm_power_off = wrppmc_machine_power_off;
/* Use MIPS Count/Compare Timer */
board_time_init = wrppmc_time_init;
/* This makes the operations of 'in/out[bwl]' to the
* physical address ( < KSEG0) can work via KSEG1
*/
......
......@@ -38,7 +38,7 @@ void __init plat_timer_setup(struct irqaction *irq)
* NOTE: We disable all GT64120 timers, and use MIPS processor internal
* timer as the source of kernel clock tick.
*/
void __init wrppmc_time_init(void)
void __init plat_time_init(void)
{
/* Disable GT64120 timers */
GT_WRITE(GT_TC_CONTROL_OFS, 0x00);
......
......@@ -109,7 +109,7 @@ static void jmr3927_timer_ack(void)
jmr3927_tmrptr->tisr = 0; /* ack interrupt */
}
static void __init jmr3927_time_init(void)
void __init plat_time_init(void)
{
clocksource_mips.read = jmr3927_hpt_read;
mips_timer_ack = jmr3927_timer_ack;
......@@ -141,8 +141,6 @@ void __init plat_mem_setup(void)
set_io_port_base(JMR3927_PORT_BASE + JMR3927_PCIIO);
board_time_init = jmr3927_time_init;
_machine_restart = jmr3927_machine_restart;
_machine_halt = jmr3927_machine_halt;
pm_power_off = jmr3927_machine_power_off;
......
......@@ -49,24 +49,19 @@
* forward reference
*/
DEFINE_SPINLOCK(rtc_lock);
EXPORT_SYMBOL(rtc_lock);
/*
* By default we provide the null RTC ops
*/
static unsigned long null_rtc_get_time(void)
int __weak rtc_mips_set_time(unsigned long sec)
{
return mktime(2000, 1, 1, 0, 0, 0);
return 0;
}
EXPORT_SYMBOL(rtc_mips_set_time);
static int null_rtc_set_time(unsigned long sec)
int __weak rtc_mips_set_mmss(unsigned long nowtime)
{
return 0;
return rtc_mips_set_time(nowtime);
}
unsigned long (*rtc_mips_get_time)(void) = null_rtc_get_time;
int (*rtc_mips_set_time)(unsigned long) = null_rtc_set_time;
int (*rtc_mips_set_mmss)(unsigned long);
int update_persistent_clock(struct timespec now)
{
return rtc_mips_set_mmss(now.tv_sec);
......@@ -247,21 +242,18 @@ asmlinkage void ll_local_timer_interrupt(int irq)
/*
* time_init() - it does the following things.
*
* 1) board_time_init() -
* 1) plat_time_init() -
* a) (optional) set up RTC routines,
* b) (optional) calibrate and set the mips_hpt_frequency
* (only needed if you intended to use cpu counter as timer interrupt
* source)
* 2) setup xtime based on rtc_mips_get_time().
* 3) calculate a couple of cached variables for later usage
* 4) plat_timer_setup() -
* 2) calculate a couple of cached variables for later usage
* 3) plat_timer_setup() -
* a) (optional) over-write any choices made above by time_init().
* b) machine specific code should setup the timer irqaction.
* c) enable the timer interrupt
*/
void (*board_time_init)(void);
unsigned int mips_hpt_frequency;
static struct irqaction timer_irqaction = {
......@@ -341,19 +333,13 @@ static void __init init_mips_clocksource(void)
clocksource_register(&clocksource_mips);
}
void __init time_init(void)
void __init __weak plat_time_init(void)
{
if (board_time_init)
board_time_init();
if (!rtc_mips_set_mmss)
rtc_mips_set_mmss = rtc_mips_set_time;
xtime.tv_sec = rtc_mips_get_time();
xtime.tv_nsec = 0;
}
set_normalized_timespec(&wall_to_monotonic,
-xtime.tv_sec, -xtime.tv_nsec);
void __init time_init(void)
{
plat_time_init();
/* Choose appropriate high precision timer routines. */
if (!cpu_has_counter && !clocksource_mips.read)
......@@ -459,7 +445,4 @@ void to_tm(unsigned long tim, struct rtc_time *tm)
tm->tm_wday = (gday + 4) % 7; /* 1970/1/1 was Thursday */
}
EXPORT_SYMBOL(rtc_lock);
EXPORT_SYMBOL(to_tm);
EXPORT_SYMBOL(rtc_mips_set_time);
EXPORT_SYMBOL(rtc_mips_get_time);
......@@ -135,8 +135,7 @@ static void rtc_end_op(void)
lasat_ndelay(1000);
}
/* interface */
unsigned long ds1603_read(void)
unsigned long read_persistent_clock(void)
{
unsigned long word;
unsigned long flags;
......@@ -147,10 +146,11 @@ unsigned long ds1603_read(void)
word = rtc_read_word();
rtc_end_op();
spin_unlock_irqrestore(&rtc_lock, flags);
return word;
}
int ds1603_set(unsigned long time)
int rtc_mips_set_mmss(unsigned long time)
{
unsigned long flags;
......
......@@ -20,8 +20,6 @@ struct ds_defs {
extern struct ds_defs *ds1603;
unsigned long ds1603_read(void);
int ds1603_set(unsigned long);
void ds1603_set_trimmer(unsigned int);
void ds1603_enable(void);
void ds1603_disable(void);
......
......@@ -117,7 +117,7 @@ static struct notifier_block lasat_panic_block[] =
}
};
static void lasat_time_init(void)
void plat_time_init(void)
{
mips_hpt_frequency = lasat_board_info.li_cpu_hz / 2;
}
......@@ -142,12 +142,8 @@ void __init plat_mem_setup(void)
lasat_reboot_setup();
board_time_init = lasat_time_init;
#ifdef CONFIG_DS1603
ds1603 = &ds_defs[mips_machtype];
rtc_mips_get_time = ds1603_read;
rtc_mips_set_time = ds1603_set;
#endif
#ifdef DYNAMIC_SERIAL_INIT
......
......@@ -32,6 +32,8 @@
#include <linux/mutex.h>
#include <linux/uaccess.h>
#include <asm/time.h>
#include "sysctl.h"
#include "ds1603.h"
......@@ -106,7 +108,7 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
mutex_lock(&lasat_info_mutex);
if (!write) {
rtctmp = ds1603_read();
rtctmp = read_persistent_clock();
/* check for time < 0 and set to 0 */
if (rtctmp < 0)
rtctmp = 0;
......@@ -116,7 +118,7 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
mutex_unlock(&lasat_info_mutex);
return r;
}
ds1603_set(rtctmp);
rtc_mips_set_mmss(rtctmp);
mutex_unlock(&lasat_info_mutex);
return 0;
......@@ -152,7 +154,7 @@ int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen,
int r;
mutex_lock(&lasat_info_mutex);
rtctmp = ds1603_read();
rtctmp = read_persistent_clock();
if (rtctmp < 0)
rtctmp = 0;
r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen);
......@@ -161,7 +163,7 @@ int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen,
return r;
}
if (newval && newlen)
ds1603_set(rtctmp);
rtc_mips_set_mmss(rtctmp);
mutex_unlock(&lasat_info_mutex);
return 1;
......
......@@ -58,13 +58,13 @@ void __init plat_timer_setup(struct irqaction *irq)
setup_irq(MIPS_CPU_IRQ_BASE + 7, irq);
}
static void __init loongson2e_time_init(void)
void __init plat_time_init(void)
{
/* setup mips r4k timer */
mips_hpt_frequency = cpu_clock_freq / 2;
}
static unsigned long __init mips_rtc_get_time(void)
unsigned long read_persistent_clock(void)
{
return mc146818_get_cmos_time();
}
......@@ -89,9 +89,6 @@ void __init plat_mem_setup(void)
mips_reboot_setup();
board_time_init = loongson2e_time_init;
rtc_mips_get_time = mips_rtc_get_time;
__wbflush = wbflush_loongson2e;
add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
......
......@@ -35,8 +35,6 @@
#include <asm/traps.h>
extern void mips_reboot_setup(void);
extern void mips_time_init(void);
extern unsigned long mips_rtc_get_time(void);
#ifdef CONFIG_KGDB
extern void kgdb_config(void);
......@@ -63,9 +61,6 @@ void __init plat_mem_setup(void)
kgdb_config();
#endif
mips_reboot_setup();
board_time_init = mips_time_init;
rtc_mips_get_time = mips_rtc_get_time;
}
static void __init serial_init(void)
......
......@@ -224,12 +224,12 @@ static unsigned int __init estimate_cpu_frequency(void)
return count;
}
unsigned long __init mips_rtc_get_time(void)
unsigned long read_persistent_clock(void)
{
return mc146818_get_cmos_time();
}
void __init mips_time_init(void)
void __init plat_time_init(void)
{
unsigned int est_freq;
......
......@@ -36,7 +36,6 @@
#endif
extern void mips_reboot_setup(void);
extern void mips_time_init(void);
extern unsigned long mips_rtc_get_time(void);
#ifdef CONFIG_KGDB
......@@ -185,7 +184,4 @@ void __init plat_mem_setup(void)
#endif
#endif
mips_reboot_setup();
board_time_init = mips_time_init;
rtc_mips_get_time = mips_rtc_get_time;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment