blob: b2340f008ae06a27614f2fc1c78e3b45b36946b0 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <linux/sched.h>
9#include <linux/smp.h>
10#include <linux/string.h>
11#include <linux/spinlock.h>
David S. Millerbdcf81b2014-10-10 15:49:16 -040012#include <linux/irqflags.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14#include <asm/openprom.h>
15#include <asm/oplib.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/spitfire.h>
17#include <asm/pstate.h>
David S. Miller4f0234f2007-07-13 16:03:42 -070018#include <asm/ldc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20struct {
21 long prom_callback; /* 0x00 */
22 void (*prom_cif_handler)(long *); /* 0x08 */
23 unsigned long prom_cif_stack; /* 0x10 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070024} p1275buf;
25
26extern void prom_world(int);
27
David S. Miller25edd692010-08-23 23:10:57 -070028extern void prom_cif_direct(unsigned long *args);
Linus Torvalds1da177e2005-04-16 15:20:36 -070029extern void prom_cif_callback(void);
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031/*
David S. Miller8a4fd1e2010-03-03 09:06:03 -080032 * This provides SMP safety on the p1275buf.
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 */
David S. Miller8a4fd1e2010-03-03 09:06:03 -080034DEFINE_RAW_SPINLOCK(prom_entry_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
David S. Miller25edd692010-08-23 23:10:57 -070036void p1275_cmd_direct(unsigned long *args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037{
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
David S. Millerbdcf81b2014-10-10 15:49:16 -040040 local_save_flags(flags);
41 local_irq_restore((unsigned long)PIL_NMI);
David S. Miller8a4fd1e2010-03-03 09:06:03 -080042 raw_spin_lock(&prom_entry_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 prom_world(1);
David S. Miller25edd692010-08-23 23:10:57 -070045 prom_cif_direct(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 prom_world(0);
47
David S. Miller8a4fd1e2010-03-03 09:06:03 -080048 raw_spin_unlock(&prom_entry_lock);
David S. Millerbdcf81b2014-10-10 15:49:16 -040049 local_irq_restore(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
52void prom_cif_init(void *cif_handler, void *cif_stack)
53{
54 p1275buf.prom_cif_handler = (void (*)(long *))cif_handler;
55 p1275buf.prom_cif_stack = (unsigned long)cif_stack;
56}