Michael Ellerman | 1965746 | 2006-02-10 15:47:36 +1100 | [diff] [blame] | 1 | /* |
| 2 | * pSeries firmware setup code. |
| 3 | * |
| 4 | * Portions from arch/powerpc/platforms/pseries/setup.c: |
| 5 | * Copyright (C) 1995 Linus Torvalds |
| 6 | * Adapted from 'alpha' version by Gary Thomas |
| 7 | * Modified by Cort Dougan (cort@cs.nmt.edu) |
| 8 | * Modified by PPC64 Team, IBM Corp |
| 9 | * |
| 10 | * Portions from arch/powerpc/kernel/firmware.c |
| 11 | * Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org) |
| 12 | * Modifications for ppc64: |
| 13 | * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com> |
| 14 | * Copyright (C) 2005 Stephen Rothwell, IBM Corporation |
| 15 | * |
| 16 | * Copyright 2006 IBM Corporation. |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or |
| 19 | * modify it under the terms of the GNU General Public License |
| 20 | * as published by the Free Software Foundation; either version |
| 21 | * 2 of the License, or (at your option) any later version. |
| 22 | */ |
| 23 | |
| 24 | #undef DEBUG |
| 25 | |
| 26 | #include <asm/firmware.h> |
| 27 | #include <asm/prom.h> |
| 28 | |
| 29 | #ifdef DEBUG |
| 30 | #define DBG(fmt...) udbg_printf(fmt) |
| 31 | #else |
| 32 | #define DBG(fmt...) |
| 33 | #endif |
| 34 | |
| 35 | typedef struct { |
| 36 | unsigned long val; |
| 37 | char * name; |
| 38 | } firmware_feature_t; |
| 39 | |
| 40 | static __initdata firmware_feature_t |
| 41 | firmware_features_table[FIRMWARE_MAX_FEATURES] = { |
| 42 | {FW_FEATURE_PFT, "hcall-pft"}, |
| 43 | {FW_FEATURE_TCE, "hcall-tce"}, |
| 44 | {FW_FEATURE_SPRG0, "hcall-sprg0"}, |
| 45 | {FW_FEATURE_DABR, "hcall-dabr"}, |
| 46 | {FW_FEATURE_COPY, "hcall-copy"}, |
| 47 | {FW_FEATURE_ASR, "hcall-asr"}, |
| 48 | {FW_FEATURE_DEBUG, "hcall-debug"}, |
| 49 | {FW_FEATURE_PERF, "hcall-perf"}, |
| 50 | {FW_FEATURE_DUMP, "hcall-dump"}, |
| 51 | {FW_FEATURE_INTERRUPT, "hcall-interrupt"}, |
| 52 | {FW_FEATURE_MIGRATE, "hcall-migrate"}, |
| 53 | {FW_FEATURE_PERFMON, "hcall-perfmon"}, |
| 54 | {FW_FEATURE_CRQ, "hcall-crq"}, |
| 55 | {FW_FEATURE_VIO, "hcall-vio"}, |
| 56 | {FW_FEATURE_RDMA, "hcall-rdma"}, |
| 57 | {FW_FEATURE_LLAN, "hcall-lLAN"}, |
| 58 | {FW_FEATURE_BULK, "hcall-bulk"}, |
| 59 | {FW_FEATURE_XDABR, "hcall-xdabr"}, |
| 60 | {FW_FEATURE_MULTITCE, "hcall-multi-tce"}, |
| 61 | {FW_FEATURE_SPLPAR, "hcall-splpar"}, |
| 62 | }; |
| 63 | |
| 64 | /* Build up the firmware features bitmask using the contents of |
| 65 | * device-tree/ibm,hypertas-functions. Ultimately this functionality may |
| 66 | * be moved into prom.c prom_init(). |
| 67 | */ |
| 68 | void __init fw_feature_init(void) |
| 69 | { |
| 70 | struct device_node *dn; |
| 71 | char *hypertas, *s; |
| 72 | int len, i; |
| 73 | |
| 74 | DBG(" -> fw_feature_init()\n"); |
| 75 | |
| 76 | dn = of_find_node_by_path("/rtas"); |
| 77 | if (dn == NULL) { |
| 78 | printk(KERN_ERR "WARNING! Cannot find RTAS in device-tree!\n"); |
| 79 | goto out; |
| 80 | } |
| 81 | |
| 82 | hypertas = get_property(dn, "ibm,hypertas-functions", &len); |
| 83 | if (hypertas == NULL) |
| 84 | goto out; |
| 85 | |
| 86 | for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) { |
| 87 | for (i = 0; i < FIRMWARE_MAX_FEATURES; i++) { |
| 88 | /* check value against table of strings */ |
| 89 | if (!firmware_features_table[i].name || |
| 90 | strcmp(firmware_features_table[i].name, s)) |
| 91 | continue; |
| 92 | |
| 93 | /* we have a match */ |
| 94 | ppc64_firmware_features |= |
| 95 | firmware_features_table[i].val; |
| 96 | break; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | out: |
| 101 | of_node_put(dn); |
| 102 | DBG(" <- fw_feature_init()\n"); |
| 103 | } |