cbfstool: cut down on the debug output
[coreboot.git] / src / acpi / sata.c
blob60c79921023744e33a024e0aef3ac44bea3c82db
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.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc.
18 #include "sata.h"
20 #include <arch/acpi.h>
21 #include <arch/acpigen.h>
23 /* e.g.
24 * generate_sata_ssdt_ports("\_SB.PCI0.SATA", 0x3);
25 * generates:
26 * Scope (\_SB.PCI0.SATA)
27 * {
28 * Device (PR00)
29 * {
30 * Name (_ADR, 0x0000FFFF) // _ADR: Address
31 * }
33 * Device (PR01)
34 * {
35 * Name (_ADR, 0x0001FFFF) // _ADR: Address
36 * }
37 * }
40 void generate_sata_ssdt_ports(const char *scope, uint32_t enable_map)
42 int i;
43 uint32_t bit;
44 char port_name[4] = "PR00";
46 acpigen_write_scope(scope);
48 /* generate a device for every enabled port */
49 for (i = 0; i < 32; i++) {
50 bit = 1 << i;
51 if (!(bit & enable_map))
52 continue;
54 port_name[2] = '0' + i / 10;
55 port_name[3] = '0' + i % 10;
57 acpigen_write_device(port_name);
59 acpigen_write_name_dword("_ADR", 0xffff + i * 0x10000);
60 acpigen_pop_len(); /* close PRT%d */
63 acpigen_pop_len(); /* close scope */