blob: db808ce45a9f9272052bca61c9a8f7771377f002 [file] [log] [blame]
Lean Sheng Tan5352d222022-01-07 13:48:13 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
Maximilian Brune97a86732022-10-07 18:29:29 +02003#include <console/console.h>
Angel Pons56c1c4d2023-03-22 13:25:09 +01004#include <device/device.h>
Maximilian Brune97a86732022-10-07 18:29:29 +02005#include <gpio.h>
David Milosevic0f5b87c2022-10-20 16:47:48 +02006#include <smbios.h>
Angel Pons56c1c4d2023-03-22 13:25:09 +01007#include <string.h>
8#include <types.h>
Lean Sheng Tan5352d222022-01-07 13:48:13 +01009
10#include "gpio.h"
Angel Pons56c1c4d2023-03-22 13:25:09 +010011#include "vpd.h"
Lean Sheng Tan5352d222022-01-07 13:48:13 +010012
David Milosevic0f5b87c2022-10-20 16:47:48 +020013void smbios_fill_dimm_locator(const struct dimm_info *dimm, struct smbios_type17 *t)
14{
15 const u8 mc = dimm->ctrlr_num;
16 const u8 ch = dimm->channel_num;
17 const u8 mm = dimm->dimm_num;
18
19 char dev_loc[40] = { "\x00" };
20 snprintf(dev_loc, sizeof(dev_loc), "SO-DIMM %c%u", 'A' + mc, mm);
21 t->device_locator = smbios_add_string(t->eos, dev_loc);
22
23 char bnk_loc[40] = { "\x00" };
24 snprintf(bnk_loc, sizeof(bnk_loc), "BANK-%u-%u-%u", mc, ch, mm);
25 t->bank_locator = smbios_add_string(t->eos, bnk_loc);
26}
27
28void smbios_fill_dimm_asset_tag(const struct dimm_info *dimm, struct smbios_type17 *t)
29{
30 const u8 mc = dimm->ctrlr_num;
31 const u8 ch = dimm->channel_num;
32 const u8 mm = dimm->dimm_num;
33
34 char tag[40] = { "\x00" };
35 snprintf(tag, sizeof(tag), "MC-%u-CH-%u-DIMM-%u", mc, ch, mm);
36 t->asset_tag = smbios_add_string(t->eos, tag);
37}
38
Maximilian Brune97a86732022-10-07 18:29:29 +020039static uint8_t get_hsid(void)
40{
41 const gpio_t hsid_gpios[] = {
42 GPP_A8,
43 GPP_F19,
44 GPP_H23,
45 GPP_H19,
46 };
47 return gpio_base2_value(hsid_gpios, ARRAY_SIZE(hsid_gpios));
48}
49
Lean Sheng Tan5352d222022-01-07 13:48:13 +010050static void mainboard_init(void *chip_info)
51{
52 configure_gpio_pads();
Maximilian Brune97a86732022-10-07 18:29:29 +020053 printk(BIOS_INFO, "HSID: 0x%x\n", get_hsid());
Lean Sheng Tan5352d222022-01-07 13:48:13 +010054}
55
Angel Pons56c1c4d2023-03-22 13:25:09 +010056static const char *get_formatted_pn(void)
57{
58 static char buffer[32 + ATLAS_SN_PN_LENGTH] = {0};
59 const char *prefix = "P/N: ";
60 snprintf(buffer, sizeof(buffer), "%s%s", prefix, get_emi_eeprom_vpd()->part_number);
61 return buffer;
62}
63
64static void mainboard_smbios_strings(struct device *dev, struct smbios_type11 *t)
65{
66 t->count = smbios_add_string(t->eos, get_formatted_pn());
67}
68
69static void mainboard_enable(struct device *dev)
70{
71 dev->ops->get_smbios_strings = mainboard_smbios_strings;
72}
73
Lean Sheng Tan5352d222022-01-07 13:48:13 +010074struct chip_operations mainboard_ops = {
Angel Pons56c1c4d2023-03-22 13:25:09 +010075 .init = mainboard_init,
76 .enable_dev = mainboard_enable,
Lean Sheng Tan5352d222022-01-07 13:48:13 +010077};