acpi_pld: Make it easier to define the ACPI USB device groups
The Linux kernel can use the ACPI _PLD group information to determine peer ports. Currently to define the group information the devicetree must provide a complete _PLD structure. This change pulls the group information into a separate structure that can be defined in devicetree. This makes it easier to set for USB devices in devicetree that do not need a full custom PLD. This was tested on a sarien board with the USB devices defined by verifying that the USB 2/3 ports are correctly identified with their peer in sysfs. Change-Id: Ifd4cadf0f6c901eb3832ad4e1395904f99c2f5a0 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://review.coreboot.org/c/29998 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
		
				
					committed by
					
						
						Duncan Laurie
					
				
			
			
				
	
			
			
			
						parent
						
							1e64d2386a
						
					
				
				
					commit
					e1eca1d91c
				
			@@ -18,7 +18,8 @@
 | 
				
			|||||||
#include <arch/acpi.h>
 | 
					#include <arch/acpi.h>
 | 
				
			||||||
#include <arch/acpi_pld.h>
 | 
					#include <arch/acpi_pld.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int acpi_pld_fill_usb(struct acpi_pld *pld, enum acpi_upc_type type)
 | 
					int acpi_pld_fill_usb(struct acpi_pld *pld, enum acpi_upc_type type,
 | 
				
			||||||
 | 
							      struct acpi_pld_group *group)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (!pld)
 | 
						if (!pld)
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
@@ -32,6 +33,8 @@ int acpi_pld_fill_usb(struct acpi_pld *pld, enum acpi_upc_type type)
 | 
				
			|||||||
	pld->horizontal_position = PLD_HORIZONTAL_POSITION_CENTER;
 | 
						pld->horizontal_position = PLD_HORIZONTAL_POSITION_CENTER;
 | 
				
			||||||
	pld->rotation = PLD_ROTATE_0;
 | 
						pld->rotation = PLD_ROTATE_0;
 | 
				
			||||||
	pld->visible = 1;
 | 
						pld->visible = 1;
 | 
				
			||||||
 | 
						pld->group.token = group->token;
 | 
				
			||||||
 | 
						pld->group.position = group->position;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Set the shape based on port type */
 | 
						/* Set the shape based on port type */
 | 
				
			||||||
	switch (type) {
 | 
						switch (type) {
 | 
				
			||||||
@@ -114,16 +117,16 @@ int acpi_pld_to_buffer(const struct acpi_pld *pld, uint8_t *buf, int buf_len)
 | 
				
			|||||||
	/* [77:74] Shape */
 | 
						/* [77:74] Shape */
 | 
				
			||||||
	buf[9] |= (pld->shape & 0xf) << 2;
 | 
						buf[9] |= (pld->shape & 0xf) << 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* [78] Group Orientation */
 | 
						/* [78] Orientation */
 | 
				
			||||||
	buf[9] |= (pld->group_orientation & 0x1) << 6;
 | 
						buf[9] |= (pld->orientation & 0x1) << 6;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* [86:79] Group Token (incorrectly defined as 1 bit in ACPI 6.2A) */
 | 
						/* [86:79] Group Token (incorrectly defined as 1 bit in ACPI 6.2A) */
 | 
				
			||||||
	buf[9] |= (pld->group_token & 0x1) << 7;
 | 
						buf[9] |= (pld->group.token & 0x1) << 7;
 | 
				
			||||||
	buf[10] |= (pld->group_token >> 0x1) & 0x7f;
 | 
						buf[10] |= (pld->group.token >> 0x1) & 0x7f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* [94:87] Group Position */
 | 
						/* [94:87] Group Position */
 | 
				
			||||||
	buf[10] |= (pld->group_position & 0x1) << 7;
 | 
						buf[10] |= (pld->group.position & 0x1) << 7;
 | 
				
			||||||
	buf[11] |= (pld->group_position >> 0x1) & 0x7f;
 | 
						buf[11] |= (pld->group.position >> 0x1) & 0x7f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* [95] Bay */
 | 
						/* [95] Bay */
 | 
				
			||||||
	buf[11] |= (pld->bay & 0x1) << 7;
 | 
						buf[11] |= (pld->bay & 0x1) << 7;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,6 +75,17 @@ enum acpi_pld_rotate {
 | 
				
			|||||||
	PLD_ROTATE_315
 | 
						PLD_ROTATE_315
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define ACPI_PLD_GROUP(__token, __position)	\
 | 
				
			||||||
 | 
						{					\
 | 
				
			||||||
 | 
							.token = __token,		\
 | 
				
			||||||
 | 
							.position = __position,		\
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct acpi_pld_group {
 | 
				
			||||||
 | 
						uint8_t token;
 | 
				
			||||||
 | 
						uint8_t position;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct acpi_pld {
 | 
					struct acpi_pld {
 | 
				
			||||||
	/* Color field can be explicitly ignored */
 | 
						/* Color field can be explicitly ignored */
 | 
				
			||||||
	bool ignore_color;
 | 
						bool ignore_color;
 | 
				
			||||||
@@ -100,9 +111,8 @@ struct acpi_pld {
 | 
				
			|||||||
	enum acpi_pld_rotate rotation;
 | 
						enum acpi_pld_rotate rotation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Port grouping */
 | 
						/* Port grouping */
 | 
				
			||||||
	enum acpi_pld_orientation group_orientation;
 | 
						enum acpi_pld_orientation orientation;
 | 
				
			||||||
	uint8_t group_token;
 | 
						struct acpi_pld_group group;
 | 
				
			||||||
	uint8_t group_position;
 | 
					 | 
				
			||||||
	uint8_t draw_order;
 | 
						uint8_t draw_order;
 | 
				
			||||||
	uint8_t cabinet_number;
 | 
						uint8_t cabinet_number;
 | 
				
			||||||
	uint8_t card_cage_number;
 | 
						uint8_t card_cage_number;
 | 
				
			||||||
@@ -112,7 +122,8 @@ struct acpi_pld {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Fill out PLD structure with defaults based on USB port type */
 | 
					/* Fill out PLD structure with defaults based on USB port type */
 | 
				
			||||||
int acpi_pld_fill_usb(struct acpi_pld *pld, enum acpi_upc_type type);
 | 
					int acpi_pld_fill_usb(struct acpi_pld *pld, enum acpi_upc_type type,
 | 
				
			||||||
 | 
							      struct acpi_pld_group *group);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Turn PLD structure into a 20 byte ACPI buffer */
 | 
					/* Turn PLD structure into a 20 byte ACPI buffer */
 | 
				
			||||||
int acpi_pld_to_buffer(const struct acpi_pld *pld, uint8_t *buf, int buf_len);
 | 
					int acpi_pld_to_buffer(const struct acpi_pld *pld, uint8_t *buf, int buf_len);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,13 @@ struct drivers_usb_acpi_config {
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
	enum acpi_upc_type type;
 | 
						enum acpi_upc_type type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Define a custom physical location for the port */
 | 
						/* Group peer ports */
 | 
				
			||||||
 | 
						struct acpi_pld_group group;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Define a custom physical location for the port.
 | 
				
			||||||
 | 
						 * If enabled, this takes precedence over the 'group' field.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	bool use_custom_pld;
 | 
						bool use_custom_pld;
 | 
				
			||||||
	struct acpi_pld custom_pld;
 | 
						struct acpi_pld custom_pld;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,7 +57,7 @@ static void usb_acpi_fill_ssdt_generator(struct device *dev)
 | 
				
			|||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		/* Fill PLD strucutre based on port type */
 | 
							/* Fill PLD strucutre based on port type */
 | 
				
			||||||
		struct acpi_pld pld;
 | 
							struct acpi_pld pld;
 | 
				
			||||||
		acpi_pld_fill_usb(&pld, config->type);
 | 
							acpi_pld_fill_usb(&pld, config->type, &config->group);
 | 
				
			||||||
		acpigen_write_pld(&pld);
 | 
							acpigen_write_pld(&pld);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user