1 /* 2 * SPDX-License-Identifier: GPL-2.0-or-later 3 * Copyright (C) 2019 IBM Corp. 4 * 5 * IBM Common FRU Access Macro 6 */ 7 #ifndef FSI_LBUS_H 8 #define FSI_LBUS_H 9 10 #include "exec/memory.h" 11 #include "hw/qdev-core.h" 12 13 #include "hw/fsi/bits.h" 14 15 #define ENGINE_CONFIG_NEXT BE_BIT(0) 16 #define ENGINE_CONFIG_VPD BE_BIT(1) 17 #define ENGINE_CONFIG_SLOTS BE_GENMASK(8, 15) 18 #define ENGINE_CONFIG_VERSION BE_GENMASK(16, 19) 19 #define ENGINE_CONFIG_TYPE BE_GENMASK(20, 27) 20 #define ENGINE_CONFIG_TYPE_PEEK (0x02 << 4) 21 #define ENGINE_CONFIG_TYPE_FSI (0x03 << 4) 22 #define ENGINE_CONFIG_TYPE_SCRATCHPAD (0x06 << 4) 23 #define ENGINE_CONFIG_CRC BE_GENMASK(28, 31) 24 25 #define TYPE_CFAM_CONFIG "cfam.config" 26 #define CFAM_CONFIG(obj) \ 27 OBJECT_CHECK(CFAMConfig, (obj), TYPE_CFAM_CONFIG) 28 /* P9-ism */ 29 #define CFAM_CONFIG_NR_REGS 0x28 30 31 typedef struct CFAMState CFAMState; 32 33 /* TODO: Generalise this accommodate different CFAM configurations */ 34 typedef struct CFAMConfig { 35 DeviceState parent; 36 37 MemoryRegion iomem; 38 } CFAMConfig; 39 40 #define TYPE_CFAM_PEEK "cfam.peek" 41 #define CFAM_PEEK(obj) \ 42 OBJECT_CHECK(CFAMPeek, (obj), TYPE_CFAM_PEEK) 43 #define CFAM_PEEK_NR_REGS ((0x130 >> 2) + 1) 44 45 typedef struct CFAMPeek { 46 DeviceState parent; 47 48 MemoryRegion iomem; 49 } CFAMPeek; 50 51 #define TYPE_LBUS_DEVICE "lbus.device" 52 #define LBUS_DEVICE(obj) \ 53 OBJECT_CHECK(LBusDevice, (obj), TYPE_LBUS_DEVICE) 54 #define LBUS_DEVICE_CLASS(klass) \ 55 OBJECT_CLASS_CHECK(LBusDeviceClass, (klass), TYPE_LBUS_DEVICE) 56 #define LBUS_DEVICE_GET_CLASS(obj) \ 57 OBJECT_GET_CLASS(LBusDeviceClass, (obj), TYPE_LBUS_DEVICE) 58 59 typedef struct LBusDevice { 60 DeviceState parent; 61 62 MemoryRegion iomem; 63 uint32_t address; 64 } LBusDevice; 65 66 typedef struct LBusDeviceClass { 67 DeviceClass parent; 68 69 uint32_t config; 70 } LBusDeviceClass; 71 72 typedef struct LBusNode { 73 LBusDevice *ldev; 74 75 QLIST_ENTRY(LBusNode) next; 76 } LBusNode; 77 78 #define TYPE_LBUS "lbus" 79 #define LBUS(obj) OBJECT_CHECK(LBus, (obj), TYPE_LBUS) 80 #define LBUS_CLASS(klass) \ 81 OBJECT_CLASS_CHECK(LBusClass, (klass), TYPE_LBUS) 82 #define LBUS_GET_CLASS(obj) \ 83 OBJECT_GET_CLASS(LBusClass, (obj), TYPE_LBUS) 84 85 typedef struct LBus { 86 BusState bus; 87 88 MemoryRegion mr; 89 90 QLIST_HEAD(, LBusNode) devices; 91 } LBus; 92 93 DeviceState *lbus_create_device(LBus *bus, const char *type, uint32_t addr); 94 int lbus_add_device(LBus *bus, LBusDevice *dev); 95 #endif /* FSI_LBUS_H */ 96