Skip to content

Commit

Permalink
powerpc: Merge machdep.h
Browse files Browse the repository at this point in the history
A few things change for consistency between ppc32 and ppc64:
idle functions return void; *_get_boot_time functions return
unsigned long (i.e. time_t) rather than filling in a struct rtc_time
(since that's useful to the callers and easier for pmac to
generate); *_get_rtc_time and *_set_rtc_time functions take
a struct rtc_time; irq_canonicalize is gone; nvram_sync returns
void.

Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Paul Mackerras committed Oct 19, 2005
1 parent 7ed476d commit 143a1de
Show file tree
Hide file tree
Showing 17 changed files with 176 additions and 74 deletions.
12 changes: 8 additions & 4 deletions arch/powerpc/platforms/iseries/mf.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/bcd.h>
#include <linux/rtc.h>

#include <asm/time.h>
#include <asm/uaccess.h>
Expand Down Expand Up @@ -1307,11 +1308,14 @@ int iSeries_set_rtc_time(struct rtc_time *tm)
return 0;
}

void iSeries_get_boot_time(struct rtc_time *tm)
unsigned long iSeries_get_boot_time(void)
{
struct rtc_time tm;

if (piranha_simulator)
return;
return 0;

mf_get_boot_rtc(tm);
tm->tm_mon -= 1;
mf_get_boot_rtc(&tm);
return mktime(tm.tm_year + 1900, tm.tm_mon, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
}
12 changes: 4 additions & 8 deletions arch/powerpc/platforms/iseries/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ extern void hvlog(char *fmt, ...);
extern void ppcdbg_initialize(void);

static void build_iSeries_Memory_Map(void);
static int iseries_shared_idle(void);
static int iseries_dedicated_idle(void);
static void iseries_shared_idle(void);
static void iseries_dedicated_idle(void);
#ifdef CONFIG_PCI
extern void iSeries_pci_final_fixup(void);
#else
Expand Down Expand Up @@ -693,7 +693,7 @@ static void yield_shared_processor(void)
process_iSeries_events();
}

static int iseries_shared_idle(void)
static void iseries_shared_idle(void)
{
while (1) {
while (!need_resched() && !hvlpevent_is_pending()) {
Expand All @@ -715,11 +715,9 @@ static int iseries_shared_idle(void)

schedule();
}

return 0;
}

static int iseries_dedicated_idle(void)
static void iseries_dedicated_idle(void)
{
long oldval;

Expand Down Expand Up @@ -749,8 +747,6 @@ static int iseries_dedicated_idle(void)
ppc64_runlatch_on();
schedule();
}

return 0;
}

#ifndef CONFIG_PCI
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/iseries/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef __ISERIES_SETUP_H__
#define __ISERIES_SETUP_H__

extern void iSeries_get_boot_time(struct rtc_time *tm);
extern unsigned long iSeries_get_boot_time(void);
extern int iSeries_set_rtc_time(struct rtc_time *tm);
extern void iSeries_get_rtc_time(struct rtc_time *tm);

Expand Down
7 changes: 5 additions & 2 deletions arch/powerpc/platforms/powermac/pmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
* pmac_* files. Mostly for use by pmac_setup
*/

struct rtc_time;

extern long pmac_time_init(void);
extern unsigned long pmac_get_rtc_time(void);
extern int pmac_set_rtc_time(unsigned long nowtime);
extern unsigned long pmac_get_boot_time(void);
extern void pmac_get_rtc_time(struct rtc_time *);
extern int pmac_set_rtc_time(struct rtc_time *);
extern void pmac_read_rtc_time(void);
extern void pmac_calibrate_decr(void);
extern void pmac_pcibios_fixup(void);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/powermac/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,6 @@ void __init pmac_init(void)
ppc_md.setup_arch = pmac_setup_arch;
ppc_md.show_cpuinfo = pmac_show_cpuinfo;
ppc_md.show_percpuinfo = pmac_show_percpuinfo;
ppc_md.irq_canonicalize = NULL;
ppc_md.init_IRQ = pmac_pic_init;
ppc_md.get_irq = pmac_get_irq; /* Changed later on ... */

Expand All @@ -578,6 +577,7 @@ void __init pmac_init(void)
ppc_md.time_init = pmac_time_init;
ppc_md.set_rtc_time = pmac_set_rtc_time;
ppc_md.get_rtc_time = pmac_get_rtc_time;
ppc_md.get_boot_time = pmac_get_boot_time;
ppc_md.calibrate_decr = pmac_calibrate_decr;

ppc_md.feature_call = pmac_do_feature_call;
Expand Down
24 changes: 18 additions & 6 deletions arch/powerpc/platforms/powermac/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ pmac_time_init(void)
#endif
}

unsigned long
pmac_get_rtc_time(void)
unsigned long pmac_get_boot_time(void)
{
#if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU)
struct adb_request req;
Expand Down Expand Up @@ -118,20 +117,33 @@ pmac_get_rtc_time(void)
return 0;
}

int
pmac_set_rtc_time(unsigned long nowtime)
void pmac_get_rtc_time(struct rtc_time *tm)
{
unsigned long now;

now = pmac_get_boot_time();
to_tm(now, tm);
tm->tm_year -= 1900;
tm->tm_mon -= 1; /* month is 0-based */
}

int pmac_set_rtc_time(struct rtc_time *tm)
{
unsigned long nowtime;
#if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU)
struct adb_request req;
#endif

nowtime = mktime(tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
nowtime += RTC_OFFSET;

switch (sys_ctrler) {
#ifdef CONFIG_ADB_CUDA
case SYS_CTRLER_CUDA:
if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
nowtime >> 24, nowtime >> 16, nowtime >> 8, nowtime) < 0)
nowtime >> 24, nowtime >> 16, nowtime >> 8,
nowtime) < 0)
return 0;
while (!req.complete)
cuda_poll();
Expand Down Expand Up @@ -221,7 +233,7 @@ time_sleep_notify(struct pmu_sleep_notifier *self, int when)
case PBOOK_SLEEP_NOW:
do {
seq = read_seqbegin_irqsave(&xtime_lock, flags);
time_diff = xtime.tv_sec - pmac_get_rtc_time();
time_diff = xtime.tv_sec - pmac_get_boot_time();
} while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
break;
case PBOOK_WAKE:
Expand Down
12 changes: 5 additions & 7 deletions arch/powerpc/platforms/pseries/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ int fwnmi_active; /* TRUE if an FWNMI handler is present */
extern void pSeries_system_reset_exception(struct pt_regs *regs);
extern int pSeries_machine_check_exception(struct pt_regs *regs);

static int pseries_shared_idle(void);
static int pseries_dedicated_idle(void);
static void pseries_shared_idle(void);
static void pseries_dedicated_idle(void);

static volatile void __iomem * chrp_int_ack_special;
struct mpic *pSeries_mpic;
Expand Down Expand Up @@ -488,8 +488,8 @@ static inline void dedicated_idle_sleep(unsigned int cpu)
}
}

static int pseries_dedicated_idle(void)
{
static void pseries_dedicated_idle(void)
{
long oldval;
struct paca_struct *lpaca = get_paca();
unsigned int cpu = smp_processor_id();
Expand Down Expand Up @@ -544,7 +544,7 @@ static int pseries_dedicated_idle(void)
}
}

static int pseries_shared_idle(void)
static void pseries_shared_idle(void)
{
struct paca_struct *lpaca = get_paca();
unsigned int cpu = smp_processor_id();
Expand Down Expand Up @@ -586,8 +586,6 @@ static int pseries_shared_idle(void)
if (cpu_is_offline(cpu) && system_state == SYSTEM_RUNNING)
cpu_die();
}

return 0;
}

static int pSeries_pci_probe_mode(struct pci_bus *bus)
Expand Down
8 changes: 2 additions & 6 deletions arch/ppc64/kernel/idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

extern void power4_idle(void);

int default_idle(void)
void default_idle(void)
{
long oldval;
unsigned int cpu = smp_processor_id();
Expand Down Expand Up @@ -64,11 +64,9 @@ int default_idle(void)
if (cpu_is_offline(cpu) && system_state == SYSTEM_RUNNING)
cpu_die();
}

return 0;
}

int native_idle(void)
void native_idle(void)
{
while (1) {
ppc64_runlatch_off();
Expand All @@ -85,8 +83,6 @@ int native_idle(void)
system_state == SYSTEM_RUNNING)
cpu_die();
}

return 0;
}

void cpu_idle(void)
Expand Down
2 changes: 1 addition & 1 deletion arch/ppc64/kernel/maple_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

extern int maple_set_rtc_time(struct rtc_time *tm);
extern void maple_get_rtc_time(struct rtc_time *tm);
extern void maple_get_boot_time(struct rtc_time *tm);
extern unsigned long maple_get_boot_time(void);
extern void maple_calibrate_decr(void);
extern void maple_pci_init(void);
extern void maple_pcibios_fixup(void);
Expand Down
7 changes: 5 additions & 2 deletions arch/ppc64/kernel/maple_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ int maple_set_rtc_time(struct rtc_time *tm)
return 0;
}

void __init maple_get_boot_time(struct rtc_time *tm)
unsigned long __init maple_get_boot_time(void)
{
struct rtc_time tm;
struct device_node *rtcs;

rtcs = find_compatible_devices("rtc", "pnpPNP,b00");
Expand All @@ -170,6 +171,8 @@ void __init maple_get_boot_time(struct rtc_time *tm)
"legacy address (0x%x)\n", maple_rtc_addr);
}

maple_get_rtc_time(tm);
maple_get_rtc_time(&tm);
return mktime(time->tm_year+1900, time->tm_mon+1, time->tm_mday,
time->tm_hour, time->tm_min, time->tm_sec);
}

2 changes: 1 addition & 1 deletion arch/ppc64/kernel/pmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* pmac_* files. Mostly for use by pmac_setup
*/

extern void pmac_get_boot_time(struct rtc_time *tm);
extern unsigned long pmac_get_boot_time(void);
extern void pmac_get_rtc_time(struct rtc_time *tm);
extern int pmac_set_rtc_time(struct rtc_time *tm);
extern void pmac_read_rtc_time(void);
Expand Down
4 changes: 1 addition & 3 deletions arch/ppc64/kernel/pmac_nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ static int amd_write_bank(int bank, u8* datas)
}


static int core99_nvram_sync(void)
static void core99_nvram_sync(void)
{
struct core99_header* hdr99;
unsigned long flags;
Expand Down Expand Up @@ -369,8 +369,6 @@ static int core99_nvram_sync(void)
printk("nvram: Error writing bank %d\n", core99_bank);
bail:
spin_unlock_irqrestore(&nv_lock, flags);

return 0;
}

int __init pmac_nvram_init(void)
Expand Down
21 changes: 6 additions & 15 deletions arch/ppc64/kernel/pmac_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/adb.h>
#include <linux/pmu.h>
#include <linux/interrupt.h>
#include <linux/rtc.h>

#include <asm/sections.h>
#include <asm/prom.h>
Expand Down Expand Up @@ -135,23 +136,13 @@ int pmac_set_rtc_time(struct rtc_time *tm)
}
}

void __init pmac_get_boot_time(struct rtc_time *tm)
unsigned long __init pmac_get_boot_time(void)
{
pmac_get_rtc_time(tm);
struct rtc_time tm;

#ifdef disabled__CONFIG_NVRAM
s32 delta = 0;
int dst;

delta = ((s32)pmac_xpram_read(PMAC_XPRAM_MACHINE_LOC + 0x9)) << 16;
delta |= ((s32)pmac_xpram_read(PMAC_XPRAM_MACHINE_LOC + 0xa)) << 8;
delta |= pmac_xpram_read(PMAC_XPRAM_MACHINE_LOC + 0xb);
if (delta & 0x00800000UL)
delta |= 0xFF000000UL;
dst = ((pmac_xpram_read(PMAC_XPRAM_MACHINE_LOC + 0x8) & 0x80) != 0);
printk("GMT Delta read from XPRAM: %d minutes, DST: %s\n", delta/60,
dst ? "on" : "off");
#endif
pmac_get_rtc_time(&tm);
return mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
}

/*
Expand Down
1 change: 1 addition & 0 deletions arch/ppc64/kernel/rtas-proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/init.h>
#include <linux/seq_file.h>
#include <linux/bitops.h>
#include <linux/rtc.h>

#include <asm/uaccess.h>
#include <asm/processor.h>
Expand Down
11 changes: 3 additions & 8 deletions arch/ppc64/kernel/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ static int rtc_read_proc(char *page, char **start, off_t off,
#ifdef CONFIG_PPC_RTAS
#define MAX_RTC_WAIT 5000 /* 5 sec */
#define RTAS_CLOCK_BUSY (-2)
void rtas_get_boot_time(struct rtc_time *rtc_tm)
unsigned long rtas_get_boot_time(void)
{
int ret[8];
int error, wait_time;
Expand All @@ -285,15 +285,10 @@ void rtas_get_boot_time(struct rtc_time *rtc_tm)
if (error != 0 && printk_ratelimit()) {
printk(KERN_WARNING "error: reading the clock failed (%d)\n",
error);
return;
return 0;
}

rtc_tm->tm_sec = ret[5];
rtc_tm->tm_min = ret[4];
rtc_tm->tm_hour = ret[3];
rtc_tm->tm_mday = ret[2];
rtc_tm->tm_mon = ret[1] - 1;
rtc_tm->tm_year = ret[0] - 1900;
return mktime(ret[0], ret[1], ret[2], ret[3], ret[4], ret[5]);
}

/* NOTE: get_rtc_time will get an error if executed in interrupt context
Expand Down
Loading

0 comments on commit 143a1de

Please sign in to comment.