Adrian Bunk | b00dc83 | 2008-05-19 16:52:27 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/sched.h> |
| 9 | #include <linux/smp.h> |
| 10 | #include <linux/string.h> |
| 11 | #include <linux/spinlock.h> |
David S. Miller | bdcf81b | 2014-10-10 15:49:16 -0400 | [diff] [blame^] | 12 | #include <linux/irqflags.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | #include <asm/openprom.h> |
| 15 | #include <asm/oplib.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/spitfire.h> |
| 17 | #include <asm/pstate.h> |
David S. Miller | 4f0234f | 2007-07-13 16:03:42 -0700 | [diff] [blame] | 18 | #include <asm/ldc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | struct { |
| 21 | long prom_callback; /* 0x00 */ |
| 22 | void (*prom_cif_handler)(long *); /* 0x08 */ |
| 23 | unsigned long prom_cif_stack; /* 0x10 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | } p1275buf; |
| 25 | |
| 26 | extern void prom_world(int); |
| 27 | |
David S. Miller | 25edd69 | 2010-08-23 23:10:57 -0700 | [diff] [blame] | 28 | extern void prom_cif_direct(unsigned long *args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | extern void prom_cif_callback(void); |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | /* |
David S. Miller | 8a4fd1e | 2010-03-03 09:06:03 -0800 | [diff] [blame] | 32 | * This provides SMP safety on the p1275buf. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | */ |
David S. Miller | 8a4fd1e | 2010-03-03 09:06:03 -0800 | [diff] [blame] | 34 | DEFINE_RAW_SPINLOCK(prom_entry_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
David S. Miller | 25edd69 | 2010-08-23 23:10:57 -0700 | [diff] [blame] | 36 | void p1275_cmd_direct(unsigned long *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
David S. Miller | bdcf81b | 2014-10-10 15:49:16 -0400 | [diff] [blame^] | 40 | local_save_flags(flags); |
| 41 | local_irq_restore((unsigned long)PIL_NMI); |
David S. Miller | 8a4fd1e | 2010-03-03 09:06:03 -0800 | [diff] [blame] | 42 | raw_spin_lock(&prom_entry_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | prom_world(1); |
David S. Miller | 25edd69 | 2010-08-23 23:10:57 -0700 | [diff] [blame] | 45 | prom_cif_direct(args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | prom_world(0); |
| 47 | |
David S. Miller | 8a4fd1e | 2010-03-03 09:06:03 -0800 | [diff] [blame] | 48 | raw_spin_unlock(&prom_entry_lock); |
David S. Miller | bdcf81b | 2014-10-10 15:49:16 -0400 | [diff] [blame^] | 49 | local_irq_restore(flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | void 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 | } |