Skip to content

Commit

Permalink
ACPICA: ACPI 6.4: add CSI2Bus resource template
Browse files Browse the repository at this point in the history
This commit the result of squashing the following:
ACPICA commit 21a316fdaa46b3fb245a1920f3829cb05d6ced6e
ACPICA commit f5506fc7dad08c2a25ef52cf836c2d67385a612c

Link: acpica/acpica@21a316fd
Link: acpica/acpica@f5506fc7
Signed-off-by: Bob Moore <[email protected]>
Signed-off-by: Erik Kaneda <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
acpibob authored and rafaeljw committed Apr 7, 2021
1 parent cca97d4 commit a2befbb
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 8 deletions.
4 changes: 4 additions & 0 deletions drivers/acpi/acpica/acresrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef enum {
ACPI_RSC_1BITFLAG,
ACPI_RSC_2BITFLAG,
ACPI_RSC_3BITFLAG,
ACPI_RSC_6BITFLAG,
ACPI_RSC_ADDRESS,
ACPI_RSC_BITMASK,
ACPI_RSC_BITMASK16,
Expand Down Expand Up @@ -102,6 +103,7 @@ typedef enum {
ACPI_RSD_1BITFLAG,
ACPI_RSD_2BITFLAG,
ACPI_RSD_3BITFLAG,
ACPI_RSD_6BITFLAG,
ACPI_RSD_ADDRESS,
ACPI_RSD_DWORDLIST,
ACPI_RSD_LITERAL,
Expand Down Expand Up @@ -295,6 +297,7 @@ extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
extern struct acpi_rsconvert_info acpi_rs_convert_gpio[];
extern struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[];
extern struct acpi_rsconvert_info acpi_rs_convert_csi2_serial_bus[];
extern struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[];
extern struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[];
extern struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[];
Expand Down Expand Up @@ -349,6 +352,7 @@ extern struct acpi_rsdump_info acpi_rs_dump_gpio[];
extern struct acpi_rsdump_info acpi_rs_dump_pin_function[];
extern struct acpi_rsdump_info acpi_rs_dump_fixed_dma[];
extern struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[];
extern struct acpi_rsdump_info acpi_rs_dump_csi2_serial_bus[];
extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[];
extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[];
extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[];
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/acpica/acutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern const char *acpi_gbl_max_decode[];
extern const char *acpi_gbl_mem_decode[];
extern const char *acpi_gbl_min_decode[];
extern const char *acpi_gbl_mtp_decode[];
extern const char *acpi_gbl_phy_decode[];
extern const char *acpi_gbl_rng_decode[];
extern const char *acpi_gbl_rw_decode[];
extern const char *acpi_gbl_shr_decode[];
Expand Down
19 changes: 18 additions & 1 deletion drivers/acpi/acpica/amlresrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#define ACPI_RESTAG_IORESTRICTION "_IOR"
#define ACPI_RESTAG_LENGTH "_LEN"
#define ACPI_RESTAG_LINE "_LIN"
#define ACPI_RESTAG_LOCALPORT "_PRT"
#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
#define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
#define ACPI_RESTAG_MAXADDR "_MAX"
Expand All @@ -49,6 +50,7 @@
#define ACPI_RESTAG_MODE "_MOD"
#define ACPI_RESTAG_PARITY "_PAR"
#define ACPI_RESTAG_PHASE "_PHA"
#define ACPI_RESTAG_PHYTYPE "_PHY"
#define ACPI_RESTAG_PIN "_PIN"
#define ACPI_RESTAG_PINCONFIG "_PPI"
#define ACPI_RESTAG_PINCONFIG_TYPE "_TYP"
Expand Down Expand Up @@ -316,12 +318,26 @@ struct aml_resource_gpio {
#define AML_RESOURCE_I2C_SERIALBUSTYPE 1
#define AML_RESOURCE_SPI_SERIALBUSTYPE 2
#define AML_RESOURCE_UART_SERIALBUSTYPE 3
#define AML_RESOURCE_MAX_SERIALBUSTYPE 3
#define AML_RESOURCE_CSI2_SERIALBUSTYPE 4
#define AML_RESOURCE_MAX_SERIALBUSTYPE 4
#define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */

struct aml_resource_common_serialbus {
AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON};

struct aml_resource_csi2_serialbus {
AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON
/*
* Optional fields follow immediately:
* 1) Vendor Data bytes
* 2) Resource Source String
*/
};

#define AML_RESOURCE_CSI2_REVISION 1 /* ACPI 6.4 */
#define AML_RESOURCE_CSI2_TYPE_REVISION 1 /* ACPI 6.4 */
#define AML_RESOURCE_CSI2_MIN_DATA_LEN 0 /* ACPI 6.4 */

struct aml_resource_i2c_serialbus {
AML_RESOURCE_LARGE_HEADER_COMMON
AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
Expand Down Expand Up @@ -510,6 +526,7 @@ union aml_resource {
struct aml_resource_i2c_serialbus i2c_serial_bus;
struct aml_resource_spi_serialbus spi_serial_bus;
struct aml_resource_uart_serialbus uart_serial_bus;
struct aml_resource_csi2_serialbus csi2_serial_bus;
struct aml_resource_common_serialbus common_serial_bus;
struct aml_resource_pin_function pin_function;
struct aml_resource_pin_config pin_config;
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/acpica/rscalc.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,10 @@ acpi_rs_get_list_length(u8 *aml_buffer,
*size_needed += buffer_size;

ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"Type %.2X, AmlLength %.2X InternalLength %.2X\n",
"Type %.2X, AmlLength %.2X InternalLength %.2X%8X\n",
acpi_ut_get_resource_type(aml_buffer),
acpi_ut_get_descriptor_length(aml_buffer),
buffer_size));
ACPI_FORMAT_UINT64(*size_needed)));

/*
* Point to the next resource within the AML stream using the length
Expand Down
8 changes: 8 additions & 0 deletions drivers/acpi/acpica/rsdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
("Invalid descriptor type (%X) in resource list\n",
resource_list->type);
return;
} else if (!resource_list->type) {
ACPI_ERROR((AE_INFO, "Invalid Zero Resource Type"));
return;
}

/* Sanity check the length. It must not be zero, or we loop forever */
Expand Down Expand Up @@ -258,6 +261,11 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
table->pointer[*target & 0x07]);
break;

case ACPI_RSD_6BITFLAG:

acpi_rs_out_integer8(name, (ACPI_GET8(target) & 0x3F));
break;

case ACPI_RSD_SHORTLIST:
/*
* Short byte list (single line output) for DMA and IRQ resources
Expand Down
26 changes: 26 additions & 0 deletions drivers/acpi/acpica/rsdumpinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,32 @@ struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[11] = {
ACPI_RS_DUMP_COMMON_SERIAL_BUS
};

struct acpi_rsdump_info acpi_rs_dump_csi2_serial_bus[11] = {
{ ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_csi2_serial_bus),
"Camera Serial Bus", NULL },
{ ACPI_RSD_UINT8, ACPI_RSD_OFFSET(csi2_serial_bus.revision_id),
"RevisionId", NULL },
{ ACPI_RSD_UINT8, ACPI_RSD_OFFSET(csi2_serial_bus.type), "Type",
acpi_gbl_sbt_decode },
{ ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(csi2_serial_bus.producer_consumer),
"ProducerConsumer", acpi_gbl_consume_decode },
{ ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(csi2_serial_bus.slave_mode),
"SlaveMode", acpi_gbl_sm_decode },
{ ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(csi2_serial_bus.phy_type),
"PhyType", acpi_gbl_phy_decode },
{ ACPI_RSD_6BITFLAG,
ACPI_RSD_OFFSET(csi2_serial_bus.local_port_instance),
"LocalPortInstance", NULL },
{ ACPI_RSD_UINT8, ACPI_RSD_OFFSET(csi2_serial_bus.type_revision_id),
"TypeRevisionId", NULL },
{ ACPI_RSD_UINT16, ACPI_RSD_OFFSET(csi2_serial_bus.vendor_length),
"VendorLength", NULL },
{ ACPI_RSD_SHORTLISTX, ACPI_RSD_OFFSET(csi2_serial_bus.vendor_data),
"VendorData", NULL },
{ ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(csi2_serial_bus.resource_source),
"ResourceSource", NULL },
};

struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[14] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus),
"I2C Serial Bus", NULL},
Expand Down
6 changes: 5 additions & 1 deletion drivers/acpi/acpica/rsinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = {
acpi_rs_convert_pin_group_config, /* 0x12, ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG */
};

/* Subtype table for serial_bus -- I2C, SPI, and UART */
/* Subtype table for serial_bus -- I2C, SPI, UART, and CSI2 */

struct acpi_rsconvert_info *acpi_gbl_convert_resource_serial_bus_dispatch[] = {
NULL,
acpi_rs_convert_i2c_serial_bus,
acpi_rs_convert_spi_serial_bus,
acpi_rs_convert_uart_serial_bus,
acpi_rs_convert_csi2_serial_bus
};

#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER)
Expand Down Expand Up @@ -142,6 +143,7 @@ struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[] = {
acpi_rs_dump_i2c_serial_bus, /* AML_RESOURCE_I2C_BUS_TYPE */
acpi_rs_dump_spi_serial_bus, /* AML_RESOURCE_SPI_BUS_TYPE */
acpi_rs_dump_uart_serial_bus, /* AML_RESOURCE_UART_BUS_TYPE */
acpi_rs_dump_csi2_serial_bus, /* AML_RESOURCE_CSI2_BUS_TYPE */
};
#endif

Expand Down Expand Up @@ -226,11 +228,13 @@ const u8 acpi_gbl_aml_resource_serial_bus_sizes[] = {
sizeof(struct aml_resource_i2c_serialbus),
sizeof(struct aml_resource_spi_serialbus),
sizeof(struct aml_resource_uart_serialbus),
sizeof(struct aml_resource_csi2_serialbus),
};

const u8 acpi_gbl_resource_struct_serial_bus_sizes[] = {
0,
ACPI_RS_SIZE(struct acpi_resource_i2c_serialbus),
ACPI_RS_SIZE(struct acpi_resource_spi_serialbus),
ACPI_RS_SIZE(struct acpi_resource_uart_serialbus),
ACPI_RS_SIZE(struct acpi_resource_csi2_serialbus),
};
9 changes: 7 additions & 2 deletions drivers/acpi/acpica/rslist.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ acpi_rs_convert_aml_to_resources(u8 * aml,
AML_RESOURCE_MAX_SERIALBUSTYPE) {
conversion_table = NULL;
} else {
/* This is an I2C, SPI, or UART serial_bus descriptor */
/* This is an I2C, SPI, UART, or CSI2 serial_bus descriptor */

conversion_table =
acpi_gbl_convert_resource_serial_bus_dispatch
Expand Down Expand Up @@ -89,6 +89,11 @@ acpi_rs_convert_aml_to_resources(u8 * aml,
return_ACPI_STATUS(status);
}

if (!resource->length) {
ACPI_EXCEPTION((AE_INFO, status,
"Zero-length resource returned from RsConvertAmlToResource"));
}

ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"Type %.2X, AmlLength %.2X InternalLength %.2X\n",
acpi_ut_get_resource_type(aml), length,
Expand Down Expand Up @@ -158,7 +163,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
AML_RESOURCE_MAX_SERIALBUSTYPE) {
conversion_table = NULL;
} else {
/* This is an I2C, SPI, or UART serial_bus descriptor */
/* This is an I2C, SPI, UART or CSI2 serial_bus descriptor */

conversion_table =
acpi_gbl_convert_resource_serial_bus_dispatch
Expand Down
19 changes: 19 additions & 0 deletions drivers/acpi/acpica/rsmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
*/
count = INIT_TABLE_LENGTH(info);
while (count) {
target = NULL;

/*
* Source is the external AML byte stream buffer,
* destination is the internal resource descriptor
Expand Down Expand Up @@ -120,6 +122,14 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
((ACPI_GET8(source) >> info->value) & 0x07));
break;

case ACPI_RSC_6BITFLAG:
/*
* Mask and shift the flag bits
*/
ACPI_SET8(destination,
((ACPI_GET8(source) >> info->value) & 0x3F));
break;

case ACPI_RSC_COUNT:

item_count = ACPI_GET8(source);
Expand Down Expand Up @@ -509,6 +519,15 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
value));
break;

case ACPI_RSC_6BITFLAG:
/*
* Mask and shift the flag bits
*/
ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
((ACPI_GET8(source) & 0x3F) << info->
value));
break;

case ACPI_RSC_COUNT:

item_count = ACPI_GET8(source);
Expand Down
75 changes: 75 additions & 0 deletions drivers/acpi/acpica/rsserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,81 @@ struct acpi_rsconvert_info acpi_rs_convert_pin_function[13] = {
0},
};

/*******************************************************************************
*
* acpi_rs_convert_csi2_serial_bus
*
******************************************************************************/

struct acpi_rsconvert_info acpi_rs_convert_csi2_serial_bus[14] = {
{ ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
ACPI_RS_SIZE(struct acpi_resource_csi2_serialbus),
ACPI_RSC_TABLE_SIZE(acpi_rs_convert_csi2_serial_bus) },

{ ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
sizeof(struct aml_resource_csi2_serialbus),
0 },

{ ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
AML_OFFSET(common_serial_bus.revision_id),
1 },

{ ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.csi2_serial_bus.type),
AML_OFFSET(csi2_serial_bus.type),
1 },

{ ACPI_RSC_1BITFLAG,
ACPI_RS_OFFSET(data.csi2_serial_bus.producer_consumer),
AML_OFFSET(csi2_serial_bus.flags),
1 },

{ ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.csi2_serial_bus.slave_mode),
AML_OFFSET(csi2_serial_bus.flags),
0 },

{ ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.csi2_serial_bus.phy_type),
AML_OFFSET(csi2_serial_bus.type_specific_flags),
0 },

{ ACPI_RSC_6BITFLAG,
ACPI_RS_OFFSET(data.csi2_serial_bus.local_port_instance),
AML_OFFSET(csi2_serial_bus.type_specific_flags),
2 },

{ ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.csi2_serial_bus.type_revision_id),
AML_OFFSET(csi2_serial_bus.type_revision_id),
1 },

/* Vendor data */

{ ACPI_RSC_COUNT_SERIAL_VEN,
ACPI_RS_OFFSET(data.csi2_serial_bus.vendor_length),
AML_OFFSET(csi2_serial_bus.type_data_length),
AML_RESOURCE_CSI2_MIN_DATA_LEN },

{ ACPI_RSC_MOVE_SERIAL_VEN,
ACPI_RS_OFFSET(data.csi2_serial_bus.vendor_data),
0,
sizeof(struct aml_resource_csi2_serialbus) },

/* Resource Source */

{ ACPI_RSC_MOVE8,
ACPI_RS_OFFSET(data.csi2_serial_bus.resource_source.index),
AML_OFFSET(csi2_serial_bus.res_source_index),
1 },

{ ACPI_RSC_COUNT_SERIAL_RES,
ACPI_RS_OFFSET(data.csi2_serial_bus.resource_source.string_length),
AML_OFFSET(csi2_serial_bus.type_data_length),
sizeof(struct aml_resource_csi2_serialbus) },

{ ACPI_RSC_MOVE_SERIAL_RES,
ACPI_RS_OFFSET(data.csi2_serial_bus.resource_source.string_ptr),
AML_OFFSET(csi2_serial_bus.type_data_length),
sizeof(struct aml_resource_csi2_serialbus) },
};

/*******************************************************************************
*
* acpi_rs_convert_i2c_serial_bus
Expand Down
10 changes: 9 additions & 1 deletion drivers/acpi/acpica/utresdecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ const char *acpi_gbl_mtp_decode[] = {
"AddressRangeNVS"
};

const char *acpi_gbl_phy_decode[] = {
"Type C",
"Type D",
"Unknown Type",
"Unknown Type"
};

const char *acpi_gbl_rng_decode[] = {
"InvalidRanges",
"NonISAOnlyRanges",
Expand Down Expand Up @@ -161,7 +168,8 @@ const char *acpi_gbl_sbt_decode[] = {
"/* UNKNOWN serial bus type */",
"I2C",
"SPI",
"UART"
"UART",
"CSI2"
};

/* I2C serial bus access mode */
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/acpica/utresrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const u8 acpi_gbl_resource_aml_serial_bus_sizes[] = {
ACPI_AML_SIZE_LARGE(struct aml_resource_i2c_serialbus),
ACPI_AML_SIZE_LARGE(struct aml_resource_spi_serialbus),
ACPI_AML_SIZE_LARGE(struct aml_resource_uart_serialbus),
ACPI_AML_SIZE_LARGE(struct aml_resource_csi2_serialbus),
};

/*
Expand Down
Loading

0 comments on commit a2befbb

Please sign in to comment.