Makefile.inc: Update 3rdparty/intel-microcode on USE_BLOBS
[coreboot.git] / src / acpi / sata.c
blobec0d505ca0207c52eb0a4c22274dc09b29dce23e
1 /*
2 * Copyright (C) 2015 Alexander Couzens <lynxis@fe80.eu>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include "sata.h"
16 #include <arch/acpi.h>
17 #include <arch/acpigen.h>
19 /* e.g.
20 * generate_sata_ssdt_ports("\_SB.PCI0.SATA", 0x3);
21 * generates:
22 * Scope (\_SB.PCI0.SATA)
23 * {
24 * Device (PR00)
25 * {
26 * Name (_ADR, 0x0000FFFF) // _ADR: Address
27 * }
29 * Device (PR01)
30 * {
31 * Name (_ADR, 0x0001FFFF) // _ADR: Address
32 * }
33 * }
36 void generate_sata_ssdt_ports(const char *scope, uint32_t enable_map)
38 int i;
39 uint32_t bit;
40 char port_name[4] = "PR00";
42 acpigen_write_scope(scope);
44 /* generate a device for every enabled port */
45 for (i = 0; i < 32; i++) {
46 bit = 1 << i;
47 if (!(bit & enable_map))
48 continue;
50 port_name[2] = '0' + i / 10;
51 port_name[3] = '0' + i % 10;
53 acpigen_write_device(port_name);
55 acpigen_write_name_dword("_ADR", 0xffff + i * 0x10000);
56 acpigen_pop_len(); /* close PRT%d */
59 acpigen_pop_len(); /* close scope */