Skip to content

Commit

Permalink
[MIPS] Deforest the function pointer jungle in the time code.
Browse files Browse the repository at this point in the history
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: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
ralfbaechle committed Oct 11, 2007
1 parent f5ff0a2 commit 4b55048
Show file tree
Hide file tree
Showing 44 changed files with 114 additions and 209 deletions.
2 changes: 0 additions & 2 deletions arch/mips/au1000/common/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions arch/mips/au1000/common/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,3 @@ void __init plat_timer_setup(struct irqaction *irq)

#endif
}

void __init au1xxx_time_init(void)
{
}
5 changes: 1 addition & 4 deletions arch/mips/basler/excite/excite_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion arch/mips/bcm47xx/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

3 changes: 1 addition & 2 deletions arch/mips/bcm47xx/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 0 additions & 4 deletions arch/mips/dec/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
12 changes: 4 additions & 8 deletions arch/mips/dec/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions arch/mips/emma2rh/markeins/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions arch/mips/gt64120/wrppmc/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/gt64120/wrppmc/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions arch/mips/jmr3927/rbhma3100/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
45 changes: 14 additions & 31 deletions arch/mips/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
6 changes: 3 additions & 3 deletions arch/mips/lasat/ds1603.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions arch/mips/lasat/ds1603.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions arch/mips/lasat/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions arch/mips/lasat/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <linux/mutex.h>
#include <linux/uaccess.h>

#include <asm/time.h>

#include "sysctl.h"
#include "ds1603.h"

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions arch/mips/lemote/lm2e/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 4b55048

Please sign in to comment.