blob: d9850c2b9bf21275fb6e2de0ba69842a6c35b723 [file] [log] [blame]
Adrian Bunkb00dc832008-05-19 16:52:27 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * p1275.c: Sun IEEE 1275 PROM low level interface routines
3 *
4 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5 */
6
7#include <linux/kernel.h>
8#include <linux/init.h>
9#include <linux/sched.h>
10#include <linux/smp.h>
11#include <linux/string.h>
12#include <linux/spinlock.h>
13
14#include <asm/openprom.h>
15#include <asm/oplib.h>
16#include <asm/system.h>
17#include <asm/spitfire.h>
18#include <asm/pstate.h>
David S. Miller4f0234f2007-07-13 16:03:42 -070019#include <asm/ldc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21struct {
22 long prom_callback; /* 0x00 */
23 void (*prom_cif_handler)(long *); /* 0x08 */
24 unsigned long prom_cif_stack; /* 0x10 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070025} p1275buf;
26
27extern void prom_world(int);
28
David S. Miller25edd692010-08-23 23:10:57 -070029extern void prom_cif_direct(unsigned long *args);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030extern void prom_cif_callback(void);
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032/*
David S. Miller8a4fd1e2010-03-03 09:06:03 -080033 * This provides SMP safety on the p1275buf.
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 */
David S. Miller8a4fd1e2010-03-03 09:06:03 -080035DEFINE_RAW_SPINLOCK(prom_entry_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
David S. Miller25edd692010-08-23 23:10:57 -070037void p1275_cmd_direct(unsigned long *args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070038{
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
David S. Miller8a4fd1e2010-03-03 09:06:03 -080041 raw_local_save_flags(flags);
David Howellsdf9ee292010-10-07 14:08:55 +010042 raw_local_irq_restore((unsigned long)PIL_NMI);
David S. Miller8a4fd1e2010-03-03 09:06:03 -080043 raw_spin_lock(&prom_entry_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 prom_world(1);
David S. Miller25edd692010-08-23 23:10:57 -070046 prom_cif_direct(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 prom_world(0);
48
David S. Miller8a4fd1e2010-03-03 09:06:03 -080049 raw_spin_unlock(&prom_entry_lock);
50 raw_local_irq_restore(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051}
52
53void prom_cif_init(void *cif_handler, void *cif_stack)
54{
55 p1275buf.prom_cif_handler = (void (*)(long *))cif_handler;
56 p1275buf.prom_cif_stack = (unsigned long)cif_stack;
57}