1 /* Copyright 2013-2016 IBM Corp. 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 * implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 18 #ifndef __ASTBMC_H 19 #define __ASTBMC_H 20 21 #include <platform.h> 22 23 #define ST_LOC_PHB(chip_id, phb_idx) ((chip_id) << 16 | (phb_idx)) 24 #define ST_LOC_DEVFN(dev, fn) ((dev) << 3 | (fn)) 25 /* 26 * NPU groups are used to allocate device numbers. There is a 1 to 1 27 * correlation between a NPU group and a physical GPU. Links within a group 28 * are allocated as functions within a device, so groups must be numbered 29 * sequentially starting at 0. 30 */ 31 #define ST_LOC_NPU_GROUP(group_id) (group_id << 3) 32 33 struct slot_table_entry { 34 enum slot_table_etype { 35 st_end, /* End of list */ 36 st_phb, 37 st_pluggable_slot, 38 st_builtin_dev, 39 st_npu_slot 40 } etype; 41 uint32_t location; 42 const char *name; 43 const struct slot_table_entry *children; 44 uint8_t power_limit; 45 }; 46 47 /* 48 * Helper to reduce the noise in the PHB table 49 */ 50 #define ST_PHB_ENTRY(chip_id, phb_id, child_table) \ 51 { \ 52 .etype = st_phb, \ 53 .location = ST_LOC_PHB(chip_id, phb_id), \ 54 .children = child_table \ 55 } 56 57 /* 58 * For the most part the "table" isn't really a table and only contains 59 * a single real entry and the etype = st_end terminator. In these cases 60 * we can use these helpers. If you need something special in the slot 61 * table for each slot (e.g. power limit, devfn != 0) then you need to 62 * define the actual structure. 63 */ 64 #define ST_BUILTIN_DEV(st_name, slot_name) \ 65 static struct slot_table_entry st_name[] = \ 66 { \ 67 { \ 68 .etype = st_pluggable_slot, \ 69 .name = slot_name, \ 70 }, \ 71 { .etype = st_end }, \ 72 } 73 74 #define ST_PLUGGABLE(st_name, slot_name) \ 75 static struct slot_table_entry st_name[] = \ 76 { \ 77 { \ 78 .etype = st_pluggable_slot, \ 79 .name = slot_name, \ 80 }, \ 81 { .etype = st_end }, \ 82 } 83 84 #define SW_PLUGGABLE(slot_name, port, ...) \ 85 { \ 86 .etype = st_pluggable_slot, \ 87 .name = slot_name, \ 88 .location = ST_LOC_DEVFN(port, 0), \ 89 ##__VA_ARGS__ \ 90 } 91 92 extern const struct bmc_hw_config bmc_hw_ast2400; 93 extern const struct bmc_hw_config bmc_hw_ast2500; 94 extern const struct bmc_platform bmc_plat_ast2400_ami; 95 extern const struct bmc_platform bmc_plat_ast2500_ami; 96 extern const struct bmc_platform bmc_plat_ast2500_openbmc; 97 98 extern void astbmc_early_init(void); 99 extern int64_t astbmc_ipmi_reboot(void); 100 extern int64_t astbmc_ipmi_power_down(uint64_t request); 101 extern void astbmc_init(void); 102 extern void astbmc_ext_irq_serirq_cpld(unsigned int chip_id); 103 extern int pnor_init(void); 104 extern void check_all_slot_table(void); 105 extern void astbmc_exit(void); 106 extern void astbmc_seeprom_update(void); 107 108 extern void slot_table_init(const struct slot_table_entry *top_table); 109 extern void slot_table_get_slot_info(struct phb *phb, struct pci_device * pd); 110 void slot_table_add_slot_info(struct pci_device *pd, 111 const struct slot_table_entry *ent); 112 113 void dt_slot_get_slot_info(struct phb *phb, struct pci_device *pd); 114 115 #endif /* __ASTBMC_H */ 116