blob: 1236a9d6146a686a60285c8173346535fd10275a [file] [log] [blame]
Michael Ellerman19657462006-02-10 15:47:36 +11001/*
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
Michael Ellerman19657462006-02-10 15:47:36 +110024
25#include <asm/firmware.h>
26#include <asm/prom.h>
will schmidtaa39be02007-10-30 06:24:19 +110027#include <asm/udbg.h>
Michael Ellerman19657462006-02-10 15:47:36 +110028
Michael Ellerman3ff19992008-05-08 14:27:21 +100029#include "pseries.h"
Michael Ellerman19657462006-02-10 15:47:36 +110030
31typedef struct {
32 unsigned long val;
33 char * name;
34} firmware_feature_t;
35
Michael Neuling2f1d4ea2012-11-06 14:49:15 +000036/*
37 * The names in this table match names in rtas/ibm,hypertas-functions. If the
38 * entry ends in a '*', only upto the '*' is matched. Otherwise the entire
39 * string must match.
40 */
Michael Ellerman19657462006-02-10 15:47:36 +110041static __initdata firmware_feature_t
Nathan Fontenot43c0ea62013-04-24 05:55:08 +000042firmware_features_table[] = {
Michael Ellerman19657462006-02-10 15:47:36 +110043 {FW_FEATURE_PFT, "hcall-pft"},
44 {FW_FEATURE_TCE, "hcall-tce"},
45 {FW_FEATURE_SPRG0, "hcall-sprg0"},
46 {FW_FEATURE_DABR, "hcall-dabr"},
47 {FW_FEATURE_COPY, "hcall-copy"},
48 {FW_FEATURE_ASR, "hcall-asr"},
49 {FW_FEATURE_DEBUG, "hcall-debug"},
50 {FW_FEATURE_PERF, "hcall-perf"},
51 {FW_FEATURE_DUMP, "hcall-dump"},
52 {FW_FEATURE_INTERRUPT, "hcall-interrupt"},
53 {FW_FEATURE_MIGRATE, "hcall-migrate"},
54 {FW_FEATURE_PERFMON, "hcall-perfmon"},
55 {FW_FEATURE_CRQ, "hcall-crq"},
56 {FW_FEATURE_VIO, "hcall-vio"},
57 {FW_FEATURE_RDMA, "hcall-rdma"},
58 {FW_FEATURE_LLAN, "hcall-lLAN"},
Anton Blanchardb6dcde52009-10-11 21:47:34 +000059 {FW_FEATURE_BULK_REMOVE, "hcall-bulk"},
Michael Ellerman19657462006-02-10 15:47:36 +110060 {FW_FEATURE_XDABR, "hcall-xdabr"},
61 {FW_FEATURE_MULTITCE, "hcall-multi-tce"},
62 {FW_FEATURE_SPLPAR, "hcall-splpar"},
Jesse Larrew36f567b2010-11-09 13:24:48 +000063 {FW_FEATURE_VPHN, "hcall-vphn"},
Ian Munsied8f48ec2012-11-06 16:15:17 +110064 {FW_FEATURE_SET_MODE, "hcall-set-mode"},
Michael Neuling0388c792012-11-06 14:49:16 +000065 {FW_FEATURE_BEST_ENERGY, "hcall-best-energy-1*"},
Michael Ellerman19657462006-02-10 15:47:36 +110066};
67
68/* Build up the firmware features bitmask using the contents of
69 * device-tree/ibm,hypertas-functions. Ultimately this functionality may
70 * be moved into prom.c prom_init().
71 */
Michael Neulingca8ffc92007-07-19 07:56:32 +100072void __init fw_feature_init(const char *hypertas, unsigned long len)
Michael Ellerman19657462006-02-10 15:47:36 +110073{
Michael Neulingca8ffc92007-07-19 07:56:32 +100074 const char *s;
75 int i;
Michael Ellerman19657462006-02-10 15:47:36 +110076
Michael Ellermanf7ebf352008-04-24 15:13:19 +100077 pr_debug(" -> fw_feature_init()\n");
Michael Ellerman19657462006-02-10 15:47:36 +110078
Michael Ellerman19657462006-02-10 15:47:36 +110079 for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) {
Nathan Fontenot43c0ea62013-04-24 05:55:08 +000080 for (i = 0; i < ARRAY_SIZE(firmware_features_table); i++) {
Michael Neuling2f1d4ea2012-11-06 14:49:15 +000081 const char *name = firmware_features_table[i].name;
82 size_t size;
Nathan Fontenot43c0ea62013-04-24 05:55:08 +000083
Michael Neuling2f1d4ea2012-11-06 14:49:15 +000084 /*
85 * If there is a '*' at the end of name, only check
86 * upto there
87 */
88 size = strlen(name);
89 if (size && name[size - 1] == '*') {
90 if (strncmp(name, s, size - 1))
91 continue;
92 } else if (strcmp(name, s))
Michael Ellerman19657462006-02-10 15:47:36 +110093 continue;
94
95 /* we have a match */
Michael Ellermand0160bf2006-03-27 14:26:25 +110096 powerpc_firmware_features |=
Michael Ellerman19657462006-02-10 15:47:36 +110097 firmware_features_table[i].val;
98 break;
99 }
100 }
101
Michael Ellermanf7ebf352008-04-24 15:13:19 +1000102 pr_debug(" <- fw_feature_init()\n");
Michael Ellerman19657462006-02-10 15:47:36 +1100103}