ACPI / platform: Use common ACPI device resource parsing routines
Use common routines in drivers/acpi/resource.c to parse ACPI device resources while creating platform device objects. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
@@ -29,21 +29,20 @@ static acpi_status acpi_platform_count_resources(struct acpi_resource *res,
|
|||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct acpi_resource_extended_irq *acpi_xirq;
|
struct acpi_resource_extended_irq *acpi_xirq;
|
||||||
|
struct acpi_resource_irq *acpi_irq;
|
||||||
struct resource_info *ri = data;
|
struct resource_info *ri = data;
|
||||||
|
|
||||||
switch (res->type) {
|
switch (res->type) {
|
||||||
case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
|
|
||||||
case ACPI_RESOURCE_TYPE_IRQ:
|
case ACPI_RESOURCE_TYPE_IRQ:
|
||||||
ri->n++;
|
acpi_irq = &res->data.irq;
|
||||||
|
ri->n += acpi_irq->interrupt_count;
|
||||||
break;
|
break;
|
||||||
case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
|
case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
|
||||||
acpi_xirq = &res->data.extended_irq;
|
acpi_xirq = &res->data.extended_irq;
|
||||||
ri->n += acpi_xirq->interrupt_count;
|
ri->n += acpi_xirq->interrupt_count;
|
||||||
break;
|
break;
|
||||||
case ACPI_RESOURCE_TYPE_ADDRESS32:
|
default:
|
||||||
if (res->data.address32.resource_type == ACPI_IO_RANGE)
|
|
||||||
ri->n++;
|
ri->n++;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return AE_OK;
|
return AE_OK;
|
||||||
@@ -52,71 +51,26 @@ static acpi_status acpi_platform_count_resources(struct acpi_resource *res,
|
|||||||
static acpi_status acpi_platform_add_resources(struct acpi_resource *res,
|
static acpi_status acpi_platform_add_resources(struct acpi_resource *res,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct acpi_resource_fixed_memory32 *acpi_mem;
|
|
||||||
struct acpi_resource_address32 *acpi_add32;
|
|
||||||
struct acpi_resource_extended_irq *acpi_xirq;
|
|
||||||
struct acpi_resource_irq *acpi_irq;
|
|
||||||
struct resource_info *ri = data;
|
struct resource_info *ri = data;
|
||||||
struct resource *r;
|
struct resource *r;
|
||||||
int irq, i;
|
|
||||||
|
|
||||||
switch (res->type) {
|
r = ri->res + ri->cur;
|
||||||
case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
|
if (acpi_dev_resource_memory(res, r)
|
||||||
acpi_mem = &res->data.fixed_memory32;
|
|| acpi_dev_resource_io(res, r)
|
||||||
r = &ri->res[ri->cur++];
|
|| acpi_dev_resource_address_space(res, r)
|
||||||
|
|| acpi_dev_resource_ext_address_space(res, r)) {
|
||||||
r->start = acpi_mem->address;
|
ri->cur++;
|
||||||
r->end = r->start + acpi_mem->address_length - 1;
|
return AE_OK;
|
||||||
r->flags = IORESOURCE_MEM;
|
|
||||||
|
|
||||||
dev_dbg(ri->dev, "Memory32Fixed %pR\n", r);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACPI_RESOURCE_TYPE_ADDRESS32:
|
|
||||||
acpi_add32 = &res->data.address32;
|
|
||||||
|
|
||||||
if (acpi_add32->resource_type == ACPI_IO_RANGE) {
|
|
||||||
r = &ri->res[ri->cur++];
|
|
||||||
r->start = acpi_add32->minimum;
|
|
||||||
r->end = r->start + acpi_add32->address_length - 1;
|
|
||||||
r->flags = IORESOURCE_IO;
|
|
||||||
dev_dbg(ri->dev, "Address32 %pR\n", r);
|
|
||||||
}
|
}
|
||||||
break;
|
if (acpi_dev_resource_interrupt(res, 0, r)) {
|
||||||
|
int i;
|
||||||
|
|
||||||
case ACPI_RESOURCE_TYPE_IRQ:
|
r++;
|
||||||
acpi_irq = &res->data.irq;
|
for (i = 1; acpi_dev_resource_interrupt(res, i, r); i++)
|
||||||
r = &ri->res[ri->cur++];
|
r++;
|
||||||
|
|
||||||
irq = acpi_register_gsi(ri->dev,
|
ri->cur += i;
|
||||||
acpi_irq->interrupts[0],
|
|
||||||
acpi_irq->triggering,
|
|
||||||
acpi_irq->polarity);
|
|
||||||
|
|
||||||
r->start = r->end = irq;
|
|
||||||
r->flags = IORESOURCE_IRQ;
|
|
||||||
|
|
||||||
dev_dbg(ri->dev, "IRQ %pR\n", r);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
|
|
||||||
acpi_xirq = &res->data.extended_irq;
|
|
||||||
|
|
||||||
for (i = 0; i < acpi_xirq->interrupt_count; i++, ri->cur++) {
|
|
||||||
r = &ri->res[ri->cur];
|
|
||||||
irq = acpi_register_gsi(ri->dev,
|
|
||||||
acpi_xirq->interrupts[i],
|
|
||||||
acpi_xirq->triggering,
|
|
||||||
acpi_xirq->polarity);
|
|
||||||
|
|
||||||
r->start = r->end = irq;
|
|
||||||
r->flags = IORESOURCE_IRQ;
|
|
||||||
|
|
||||||
dev_dbg(ri->dev, "Interrupt %pR\n", r);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return AE_OK;
|
return AE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,9 +119,6 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WARN_ON(ri.n != ri.cur))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the ACPI node has a parent and that parent has a physical device
|
* If the ACPI node has a parent and that parent has a physical device
|
||||||
* attached to it, that physical device should be the parent of the
|
* attached to it, that physical device should be the parent of the
|
||||||
@@ -189,7 +140,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
|
|||||||
mutex_unlock(&acpi_parent->physical_node_lock);
|
mutex_unlock(&acpi_parent->physical_node_lock);
|
||||||
}
|
}
|
||||||
pdev = platform_device_register_resndata(parent, dev_name(&adev->dev),
|
pdev = platform_device_register_resndata(parent, dev_name(&adev->dev),
|
||||||
-1, ri.res, ri.n, NULL, 0);
|
-1, ri.res, ri.cur, NULL, 0);
|
||||||
if (IS_ERR(pdev)) {
|
if (IS_ERR(pdev)) {
|
||||||
dev_err(&adev->dev, "platform device creation failed: %ld\n",
|
dev_err(&adev->dev, "platform device creation failed: %ld\n",
|
||||||
PTR_ERR(pdev));
|
PTR_ERR(pdev));
|
||||||
|
|||||||
Reference in New Issue
Block a user