1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2020 Google LLC
4  */
5 
6 #include <common.h>
7 #include <acpi/acpigen.h>
8 #include <acpi/acpi_table.h>
9 #include <asm/acpigen.h>
10 
acpigen_write_empty_pct(struct acpi_ctx * ctx)11 void acpigen_write_empty_pct(struct acpi_ctx *ctx)
12 {
13 	/*
14 	 * Name (_PCT, Package (0x02)
15 	 * {
16 	 *	ResourceTemplate ()
17 	 *	{
18 	 *		Register (FFixedHW,
19 	 *			0x00,               // Bit Width
20 	 *			0x00,               // Bit Offset
21 	 *			0x0000000000000000, // Address
22 	 *			,)
23 	 *	},
24 	 *
25 	 *	ResourceTemplate ()
26 	 *	{
27 	 *		Register (FFixedHW,
28 	 *			0x00,               // Bit Width
29 	 *			0x00,               // Bit Offset
30 	 *			0x0000000000000000, // Address
31 	 *			,)
32 	 *	}
33 	 * })
34 	 */
35 	static char stream[] = {
36 		/* 00000030    "0._PCT.," */
37 		0x08, 0x5f, 0x50, 0x43, 0x54, 0x12, 0x2c,
38 		/* 00000038    "........" */
39 		0x02, 0x11, 0x14, 0x0a, 0x11, 0x82, 0x0c, 0x00,
40 		/* 00000040    "........" */
41 		0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 		/* 00000048    "....y..." */
43 		0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x11, 0x14,
44 		/* 00000050    "........" */
45 		0x0a, 0x11, 0x82, 0x0c, 0x00, 0x7f, 0x00, 0x00,
46 		/* 00000058    "........" */
47 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48 		0x00, 0x79, 0x00
49 	};
50 	acpigen_emit_stream(ctx, stream, ARRAY_SIZE(stream));
51 }
52 
acpigen_write_empty_ptc(struct acpi_ctx * ctx)53 void acpigen_write_empty_ptc(struct acpi_ctx *ctx)
54 {
55 	/*
56 	 * Name (_PTC, Package (0x02)
57 	 * {
58 	 *	ResourceTemplate ()
59 	 *	{
60 	 *		Register (FFixedHW,
61 	 *			0x00,               // Bit Width
62 	 *			0x00,               // Bit Offset
63 	 *			0x0000000000000000, // Address
64 	 *			,)
65 	 *	},
66 	 *
67 	 *	ResourceTemplate ()
68 	 *	{
69 	 *		Register (FFixedHW,
70 	 *			0x00,               // Bit Width
71 	 *			0x00,               // Bit Offset
72 	 *			0x0000000000000000, // Address
73 	 *			,)
74 	 *	}
75 	 * })
76 	 */
77 	struct acpi_gen_regaddr addr = {
78 		.space_id    = ACPI_ADDRESS_SPACE_FIXED,
79 		.bit_width   = 0,
80 		.bit_offset  = 0,
81 		.access_size = 0,
82 		.addrl       = 0,
83 		.addrh       = 0,
84 	};
85 
86 	acpigen_write_name(ctx, "_PTC");
87 	acpigen_write_package(ctx, 2);
88 
89 	/* ControlRegister */
90 	acpigen_write_register_resource(ctx, &addr);
91 
92 	/* StatusRegister */
93 	acpigen_write_register_resource(ctx, &addr);
94 
95 	acpigen_pop_len(ctx);
96 }
97