diff options
author | Paul Mackerras <paulus@samba.org> | 2005-10-26 03:05:24 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-10-26 03:05:24 -0400 |
commit | 033ef338b6e007dc081c6282a4f2a9dd761f8cd2 (patch) | |
tree | 3c77fad71c3d9ba04ddcdaea33063aaf7520ddb0 /arch/powerpc/platforms | |
parent | f9bd170a87948a9e077149b70fb192c563770fdf (diff) |
powerpc: Merge rtas.c into arch/powerpc/kernel
This splits arch/ppc64/kernel/rtas.c into arch/powerpc/kernel/rtas.c,
which contains generic RTAS functions useful on any CHRP platform,
and arch/powerpc/platforms/pseries/rtas-fw.[ch], which contain
some pSeries-specific firmware flashing bits. The parts of rtas.c
that are to do with pSeries-specific error logging are protected
by a new CONFIG_RTAS_ERROR_LOGGING symbol. The inclusion of rtas.o
is controlled by the CONFIG_PPC_RTAS symbol, and the relevant
platforms select that.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r-- | arch/powerpc/platforms/pseries/Kconfig | 5 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/Makefile | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/rtas-fw.c | 138 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/rtas-fw.h | 3 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/setup.c | 10 |
5 files changed, 148 insertions, 10 deletions
diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index 7a3b6fc4d976..2d57f588151d 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig | |||
@@ -21,11 +21,6 @@ config EEH | |||
21 | depends on PPC_PSERIES | 21 | depends on PPC_PSERIES |
22 | default y if !EMBEDDED | 22 | default y if !EMBEDDED |
23 | 23 | ||
24 | config PPC_RTAS | ||
25 | bool | ||
26 | depends on PPC_PSERIES || PPC_BPA | ||
27 | default y | ||
28 | |||
29 | config RTAS_PROC | 24 | config RTAS_PROC |
30 | bool "Proc interface to RTAS" | 25 | bool "Proc interface to RTAS" |
31 | depends on PPC_RTAS | 26 | depends on PPC_RTAS |
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index 4c817304fc21..d5c160b789e3 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | obj-y := pci.o lpar.o hvCall.o nvram.o reconfig.o \ | 1 | obj-y := pci.o lpar.o hvCall.o nvram.o reconfig.o \ |
2 | setup.o iommu.o ras.o | 2 | setup.o iommu.o rtas-fw.o ras.o |
3 | obj-$(CONFIG_SMP) += smp.o | 3 | obj-$(CONFIG_SMP) += smp.o |
4 | obj-$(CONFIG_IBMVIO) += vio.o | 4 | obj-$(CONFIG_IBMVIO) += vio.o |
diff --git a/arch/powerpc/platforms/pseries/rtas-fw.c b/arch/powerpc/platforms/pseries/rtas-fw.c new file mode 100644 index 000000000000..15d81d758ca0 --- /dev/null +++ b/arch/powerpc/platforms/pseries/rtas-fw.c | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Procedures for firmware flash updates on pSeries systems. | ||
4 | * | ||
5 | * Peter Bergner, IBM March 2001. | ||
6 | * Copyright (C) 2001 IBM. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <stdarg.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/types.h> | ||
17 | #include <linux/spinlock.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/init.h> | ||
20 | |||
21 | #include <asm/prom.h> | ||
22 | #include <asm/rtas.h> | ||
23 | #include <asm/semaphore.h> | ||
24 | #include <asm/machdep.h> | ||
25 | #include <asm/page.h> | ||
26 | #include <asm/param.h> | ||
27 | #include <asm/system.h> | ||
28 | #include <asm/abs_addr.h> | ||
29 | #include <asm/udbg.h> | ||
30 | #include <asm/delay.h> | ||
31 | #include <asm/uaccess.h> | ||
32 | #include <asm/systemcfg.h> | ||
33 | |||
34 | #include "rtas-fw.h" | ||
35 | |||
36 | struct flash_block_list_header rtas_firmware_flash_list = {0, NULL}; | ||
37 | |||
38 | #define FLASH_BLOCK_LIST_VERSION (1UL) | ||
39 | |||
40 | static void rtas_flash_firmware(void) | ||
41 | { | ||
42 | unsigned long image_size; | ||
43 | struct flash_block_list *f, *next, *flist; | ||
44 | unsigned long rtas_block_list; | ||
45 | int i, status, update_token; | ||
46 | |||
47 | update_token = rtas_token("ibm,update-flash-64-and-reboot"); | ||
48 | if (update_token == RTAS_UNKNOWN_SERVICE) { | ||
49 | printk(KERN_ALERT "FLASH: ibm,update-flash-64-and-reboot is not available -- not a service partition?\n"); | ||
50 | printk(KERN_ALERT "FLASH: firmware will not be flashed\n"); | ||
51 | return; | ||
52 | } | ||
53 | |||
54 | /* NOTE: the "first" block list is a global var with no data | ||
55 | * blocks in the kernel data segment. We do this because | ||
56 | * we want to ensure this block_list addr is under 4GB. | ||
57 | */ | ||
58 | rtas_firmware_flash_list.num_blocks = 0; | ||
59 | flist = (struct flash_block_list *)&rtas_firmware_flash_list; | ||
60 | rtas_block_list = virt_to_abs(flist); | ||
61 | if (rtas_block_list >= 4UL*1024*1024*1024) { | ||
62 | printk(KERN_ALERT "FLASH: kernel bug...flash list header addr above 4GB\n"); | ||
63 | return; | ||
64 | } | ||
65 | |||
66 | printk(KERN_ALERT "FLASH: preparing saved firmware image for flash\n"); | ||
67 | /* Update the block_list in place. */ | ||
68 | image_size = 0; | ||
69 | for (f = flist; f; f = next) { | ||
70 | /* Translate data addrs to absolute */ | ||
71 | for (i = 0; i < f->num_blocks; i++) { | ||
72 | f->blocks[i].data = (char *)virt_to_abs(f->blocks[i].data); | ||
73 | image_size += f->blocks[i].length; | ||
74 | } | ||
75 | next = f->next; | ||
76 | /* Don't translate NULL pointer for last entry */ | ||
77 | if (f->next) | ||
78 | f->next = (struct flash_block_list *)virt_to_abs(f->next); | ||
79 | else | ||
80 | f->next = NULL; | ||
81 | /* make num_blocks into the version/length field */ | ||
82 | f->num_blocks = (FLASH_BLOCK_LIST_VERSION << 56) | ((f->num_blocks+1)*16); | ||
83 | } | ||
84 | |||
85 | printk(KERN_ALERT "FLASH: flash image is %ld bytes\n", image_size); | ||
86 | printk(KERN_ALERT "FLASH: performing flash and reboot\n"); | ||
87 | rtas_progress("Flashing \n", 0x0); | ||
88 | rtas_progress("Please Wait... ", 0x0); | ||
89 | printk(KERN_ALERT "FLASH: this will take several minutes. Do not power off!\n"); | ||
90 | status = rtas_call(update_token, 1, 1, NULL, rtas_block_list); | ||
91 | switch (status) { /* should only get "bad" status */ | ||
92 | case 0: | ||
93 | printk(KERN_ALERT "FLASH: success\n"); | ||
94 | break; | ||
95 | case -1: | ||
96 | printk(KERN_ALERT "FLASH: hardware error. Firmware may not be not flashed\n"); | ||
97 | break; | ||
98 | case -3: | ||
99 | printk(KERN_ALERT "FLASH: image is corrupt or not correct for this platform. Firmware not flashed\n"); | ||
100 | break; | ||
101 | case -4: | ||
102 | printk(KERN_ALERT "FLASH: flash failed when partially complete. System may not reboot\n"); | ||
103 | break; | ||
104 | default: | ||
105 | printk(KERN_ALERT "FLASH: unknown flash return code %d\n", status); | ||
106 | break; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | void rtas_flash_bypass_warning(void) | ||
111 | { | ||
112 | printk(KERN_ALERT "FLASH: firmware flash requires a reboot\n"); | ||
113 | printk(KERN_ALERT "FLASH: the firmware image will NOT be flashed\n"); | ||
114 | } | ||
115 | |||
116 | |||
117 | void rtas_fw_restart(char *cmd) | ||
118 | { | ||
119 | if (rtas_firmware_flash_list.next) | ||
120 | rtas_flash_firmware(); | ||
121 | rtas_restart(cmd); | ||
122 | } | ||
123 | |||
124 | void rtas_fw_power_off(void) | ||
125 | { | ||
126 | if (rtas_firmware_flash_list.next) | ||
127 | rtas_flash_bypass_warning(); | ||
128 | rtas_power_off(); | ||
129 | } | ||
130 | |||
131 | void rtas_fw_halt(void) | ||
132 | { | ||
133 | if (rtas_firmware_flash_list.next) | ||
134 | rtas_flash_bypass_warning(); | ||
135 | rtas_halt(); | ||
136 | } | ||
137 | |||
138 | EXPORT_SYMBOL(rtas_firmware_flash_list); | ||
diff --git a/arch/powerpc/platforms/pseries/rtas-fw.h b/arch/powerpc/platforms/pseries/rtas-fw.h new file mode 100644 index 000000000000..e70fa69974a3 --- /dev/null +++ b/arch/powerpc/platforms/pseries/rtas-fw.h | |||
@@ -0,0 +1,3 @@ | |||
1 | void rtas_fw_restart(char *cmd); | ||
2 | void rtas_fw_power_off(void); | ||
3 | void rtas_fw_halt(void); | ||
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 0fa5beae6d1b..7e7e556e6b48 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/arch/ppc/kernel/setup.c | 2 | * 64-bit pSeries and RS/6000 setup code. |
3 | * | 3 | * |
4 | * Copyright (C) 1995 Linus Torvalds | 4 | * Copyright (C) 1995 Linus Torvalds |
5 | * Adapted from 'alpha' version by Gary Thomas | 5 | * Adapted from 'alpha' version by Gary Thomas |
@@ -67,6 +67,8 @@ | |||
67 | #include <asm/i8259.h> | 67 | #include <asm/i8259.h> |
68 | #include <asm/udbg.h> | 68 | #include <asm/udbg.h> |
69 | 69 | ||
70 | #include "rtas-fw.h" | ||
71 | |||
70 | #ifdef DEBUG | 72 | #ifdef DEBUG |
71 | #define DBG(fmt...) udbg_printf(fmt) | 73 | #define DBG(fmt...) udbg_printf(fmt) |
72 | #else | 74 | #else |
@@ -589,9 +591,9 @@ struct machdep_calls __initdata pSeries_md = { | |||
589 | .pcibios_fixup = pSeries_final_fixup, | 591 | .pcibios_fixup = pSeries_final_fixup, |
590 | .pci_probe_mode = pSeries_pci_probe_mode, | 592 | .pci_probe_mode = pSeries_pci_probe_mode, |
591 | .irq_bus_setup = pSeries_irq_bus_setup, | 593 | .irq_bus_setup = pSeries_irq_bus_setup, |
592 | .restart = rtas_restart, | 594 | .restart = rtas_fw_restart, |
593 | .power_off = rtas_power_off, | 595 | .power_off = rtas_fw_power_off, |
594 | .halt = rtas_halt, | 596 | .halt = rtas_fw_halt, |
595 | .panic = rtas_os_term, | 597 | .panic = rtas_os_term, |
596 | .cpu_die = pSeries_mach_cpu_die, | 598 | .cpu_die = pSeries_mach_cpu_die, |
597 | .get_boot_time = rtas_get_boot_time, | 599 | .get_boot_time = rtas_get_boot_time, |