1 /**
2  * Copyright (c) 2019 YADRO
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <skiboot.h>
18 #include <device.h>
19 #include <ipmi.h>
20 
21 #include "astbmc.h"
22 
23 #define CHIP_ID_CPU0 0x00
24 #define CHIP_ID_CPU1 0x08
25 
26 ST_PLUGGABLE(nicole_backplane0, "Backplane0 (16x)");
27 ST_PLUGGABLE(nicole_backplane1, "Backplane1 (16x)");
28 
29 ST_BUILTIN_DEV(nicole_builtin_net, "Builtin Network");
30 ST_BUILTIN_DEV(nicole_builtin_ssd0, "Builtin SSD0");
31 ST_BUILTIN_DEV(nicole_builtin_ssd1, "Builtin SSD1");
32 ST_BUILTIN_DEV(nicole_builtin_vga, "Builtin VGA");
33 ST_BUILTIN_DEV(nicole_builtin_usb, "Builtin USB");
34 
35 static const struct slot_table_entry nicole_phb_table[] = {
36 	ST_PHB_ENTRY(CHIP_ID_CPU0, 0, nicole_backplane0),
37 	ST_PHB_ENTRY(CHIP_ID_CPU0, 1, nicole_builtin_net),
38 	ST_PHB_ENTRY(CHIP_ID_CPU0, 2, nicole_builtin_ssd0),
39 	ST_PHB_ENTRY(CHIP_ID_CPU0, 3, nicole_backplane1),
40 
41 	ST_PHB_ENTRY(CHIP_ID_CPU1, 3, nicole_builtin_ssd1),
42 	ST_PHB_ENTRY(CHIP_ID_CPU1, 4, nicole_builtin_vga),
43 	ST_PHB_ENTRY(CHIP_ID_CPU1, 5, nicole_builtin_usb),
44 
45 	{ .etype = st_end },
46 };
47 
nicole_probe(void)48 static bool nicole_probe(void)
49 {
50 	if (!dt_node_is_compatible(dt_root, "YADRO,nicole"))
51 		return false;
52 
53 	/* Lot of common early inits here */
54 	astbmc_early_init();
55 
56 	/* Setup UART for use by OPAL (Linux hvc) */
57 	uart_set_console_policy(UART_CONSOLE_OPAL);
58 
59 	slot_table_init(nicole_phb_table);
60 
61 	return true;
62 }
63 
64 DECLARE_PLATFORM(nicole) = {
65 	.name			= "Nicole",
66 	.probe			= nicole_probe,
67 	.init			= astbmc_init,
68 	.start_preload_resource	= flash_start_preload_resource,
69 	.resource_loaded	= flash_resource_loaded,
70 	.bmc			= &bmc_plat_ast2500_openbmc,
71 	.pci_get_slot_info	= slot_table_get_slot_info,
72 	.pci_probe_complete	= check_all_slot_table,
73 	.cec_power_down         = astbmc_ipmi_power_down,
74 	.cec_reboot             = astbmc_ipmi_reboot,
75 	.elog_commit		= ipmi_elog_commit,
76 	.exit			= astbmc_exit,
77 	.terminate		= ipmi_terminate,
78 };
79