xref: /openbmc/qemu/hw/ppc/fw_cfg.c (revision 8dc7fd56dd4f56ab8ff1df3765ae6b5d3ac11c5e)
1*d632b9deSPhilippe Mathieu-Daudé /*
2*d632b9deSPhilippe Mathieu-Daudé  * fw_cfg helpers (PPC specific)
3*d632b9deSPhilippe Mathieu-Daudé  *
4*d632b9deSPhilippe Mathieu-Daudé  * Copyright (c) 2019 Red Hat, Inc.
5*d632b9deSPhilippe Mathieu-Daudé  *
6*d632b9deSPhilippe Mathieu-Daudé  * Author:
7*d632b9deSPhilippe Mathieu-Daudé  *   Philippe Mathieu-Daudé <philmd@redhat.com>
8*d632b9deSPhilippe Mathieu-Daudé  *
9*d632b9deSPhilippe Mathieu-Daudé  * SPDX-License-Identifier: GPL-2.0-or-later
10*d632b9deSPhilippe Mathieu-Daudé  *
11*d632b9deSPhilippe Mathieu-Daudé  * This work is licensed under the terms of the GNU GPL, version 2 or later.
12*d632b9deSPhilippe Mathieu-Daudé  * See the COPYING file in the top-level directory.
13*d632b9deSPhilippe Mathieu-Daudé  */
14*d632b9deSPhilippe Mathieu-Daudé 
15*d632b9deSPhilippe Mathieu-Daudé #include "qemu/osdep.h"
16*d632b9deSPhilippe Mathieu-Daudé #include "hw/ppc/ppc.h"
17*d632b9deSPhilippe Mathieu-Daudé #include "hw/nvram/fw_cfg.h"
18*d632b9deSPhilippe Mathieu-Daudé 
fw_cfg_arch_key_name(uint16_t key)19*d632b9deSPhilippe Mathieu-Daudé const char *fw_cfg_arch_key_name(uint16_t key)
20*d632b9deSPhilippe Mathieu-Daudé {
21*d632b9deSPhilippe Mathieu-Daudé     static const struct {
22*d632b9deSPhilippe Mathieu-Daudé         uint16_t key;
23*d632b9deSPhilippe Mathieu-Daudé         const char *name;
24*d632b9deSPhilippe Mathieu-Daudé     } fw_cfg_arch_wellknown_keys[] = {
25*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_WIDTH, "width"},
26*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_HEIGHT, "height"},
27*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_DEPTH, "depth"},
28*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_TBFREQ, "tbfreq"},
29*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_CLOCKFREQ, "clockfreq"},
30*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_IS_KVM, "is_kvm"},
31*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_KVM_HC, "kvm_hc"},
32*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_KVM_PID, "pid"},
33*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_NVRAM_ADDR, "nvram_addr"},
34*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_BUSFREQ, "busfreq"},
35*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_NVRAM_FLAT, "nvram_flat"},
36*d632b9deSPhilippe Mathieu-Daudé         {FW_CFG_PPC_VIACONFIG, "viaconfig"},
37*d632b9deSPhilippe Mathieu-Daudé     };
38*d632b9deSPhilippe Mathieu-Daudé 
39*d632b9deSPhilippe Mathieu-Daudé     for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) {
40*d632b9deSPhilippe Mathieu-Daudé         if (fw_cfg_arch_wellknown_keys[i].key == key) {
41*d632b9deSPhilippe Mathieu-Daudé             return fw_cfg_arch_wellknown_keys[i].name;
42*d632b9deSPhilippe Mathieu-Daudé         }
43*d632b9deSPhilippe Mathieu-Daudé     }
44*d632b9deSPhilippe Mathieu-Daudé     return NULL;
45*d632b9deSPhilippe Mathieu-Daudé }
46