diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-11-14 18:30:12 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-11-14 18:30:12 -0500 |
commit | 97d69dc061e968b5e9e56f48bb223b9ab7764b48 (patch) | |
tree | 27067a75daa9b663b6f601f1236e6921971eda20 | |
parent | 046d9ce6820e99087e81511284045eada94950e8 (diff) |
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>
-rw-r--r-- | drivers/acpi/acpi_platform.c | 89 |
1 files changed, 20 insertions, 69 deletions
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index dbb31d61e310..bcbb00ce6d99 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c | |||
@@ -29,21 +29,20 @@ static acpi_status acpi_platform_count_resources(struct acpi_resource *res, | |||
29 | void *data) | 29 | void *data) |
30 | { | 30 | { |
31 | struct acpi_resource_extended_irq *acpi_xirq; | 31 | struct acpi_resource_extended_irq *acpi_xirq; |
32 | struct acpi_resource_irq *acpi_irq; | ||
32 | struct resource_info *ri = data; | 33 | struct resource_info *ri = data; |
33 | 34 | ||
34 | switch (res->type) { | 35 | switch (res->type) { |
35 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | ||
36 | case ACPI_RESOURCE_TYPE_IRQ: | 36 | case ACPI_RESOURCE_TYPE_IRQ: |
37 | ri->n++; | 37 | acpi_irq = &res->data.irq; |
38 | ri->n += acpi_irq->interrupt_count; | ||
38 | break; | 39 | break; |
39 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: | 40 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
40 | acpi_xirq = &res->data.extended_irq; | 41 | acpi_xirq = &res->data.extended_irq; |
41 | ri->n += acpi_xirq->interrupt_count; | 42 | ri->n += acpi_xirq->interrupt_count; |
42 | break; | 43 | break; |
43 | case ACPI_RESOURCE_TYPE_ADDRESS32: | 44 | default: |
44 | if (res->data.address32.resource_type == ACPI_IO_RANGE) | 45 | ri->n++; |
45 | ri->n++; | ||
46 | break; | ||
47 | } | 46 | } |
48 | 47 | ||
49 | return AE_OK; | 48 | return AE_OK; |
@@ -52,71 +51,26 @@ static acpi_status acpi_platform_count_resources(struct acpi_resource *res, | |||
52 | static acpi_status acpi_platform_add_resources(struct acpi_resource *res, | 51 | static acpi_status acpi_platform_add_resources(struct acpi_resource *res, |
53 | void *data) | 52 | void *data) |
54 | { | 53 | { |
55 | struct acpi_resource_fixed_memory32 *acpi_mem; | ||
56 | struct acpi_resource_address32 *acpi_add32; | ||
57 | struct acpi_resource_extended_irq *acpi_xirq; | ||
58 | struct acpi_resource_irq *acpi_irq; | ||
59 | struct resource_info *ri = data; | 54 | struct resource_info *ri = data; |
60 | struct resource *r; | 55 | struct resource *r; |
61 | int irq, i; | ||
62 | |||
63 | switch (res->type) { | ||
64 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | ||
65 | acpi_mem = &res->data.fixed_memory32; | ||
66 | r = &ri->res[ri->cur++]; | ||
67 | 56 | ||
68 | r->start = acpi_mem->address; | 57 | r = ri->res + ri->cur; |
69 | r->end = r->start + acpi_mem->address_length - 1; | 58 | if (acpi_dev_resource_memory(res, r) |
70 | r->flags = IORESOURCE_MEM; | 59 | || acpi_dev_resource_io(res, r) |
71 | 60 | || acpi_dev_resource_address_space(res, r) | |
72 | dev_dbg(ri->dev, "Memory32Fixed %pR\n", r); | 61 | || acpi_dev_resource_ext_address_space(res, r)) { |
73 | break; | 62 | ri->cur++; |
74 | 63 | return AE_OK; | |
75 | case ACPI_RESOURCE_TYPE_ADDRESS32: | 64 | } |
76 | acpi_add32 = &res->data.address32; | 65 | if (acpi_dev_resource_interrupt(res, 0, r)) { |
77 | 66 | int i; | |
78 | if (acpi_add32->resource_type == ACPI_IO_RANGE) { | ||
79 | r = &ri->res[ri->cur++]; | ||
80 | r->start = acpi_add32->minimum; | ||
81 | r->end = r->start + acpi_add32->address_length - 1; | ||
82 | r->flags = IORESOURCE_IO; | ||
83 | dev_dbg(ri->dev, "Address32 %pR\n", r); | ||
84 | } | ||
85 | break; | ||
86 | |||
87 | case ACPI_RESOURCE_TYPE_IRQ: | ||
88 | acpi_irq = &res->data.irq; | ||
89 | r = &ri->res[ri->cur++]; | ||
90 | |||
91 | irq = acpi_register_gsi(ri->dev, | ||
92 | acpi_irq->interrupts[0], | ||
93 | acpi_irq->triggering, | ||
94 | acpi_irq->polarity); | ||
95 | |||
96 | r->start = r->end = irq; | ||
97 | r->flags = IORESOURCE_IRQ; | ||
98 | |||
99 | dev_dbg(ri->dev, "IRQ %pR\n", r); | ||
100 | break; | ||
101 | |||
102 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: | ||
103 | acpi_xirq = &res->data.extended_irq; | ||
104 | |||
105 | for (i = 0; i < acpi_xirq->interrupt_count; i++, ri->cur++) { | ||
106 | r = &ri->res[ri->cur]; | ||
107 | irq = acpi_register_gsi(ri->dev, | ||
108 | acpi_xirq->interrupts[i], | ||
109 | acpi_xirq->triggering, | ||
110 | acpi_xirq->polarity); | ||
111 | 67 | ||
112 | r->start = r->end = irq; | 68 | r++; |
113 | r->flags = IORESOURCE_IRQ; | 69 | for (i = 1; acpi_dev_resource_interrupt(res, i, r); i++) |
70 | r++; | ||
114 | 71 | ||
115 | dev_dbg(ri->dev, "Interrupt %pR\n", r); | 72 | ri->cur += i; |
116 | } | ||
117 | break; | ||
118 | } | 73 | } |
119 | |||
120 | return AE_OK; | 74 | return AE_OK; |
121 | } | 75 | } |
122 | 76 | ||
@@ -165,9 +119,6 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev) | |||
165 | goto out; | 119 | goto out; |
166 | } | 120 | } |
167 | 121 | ||
168 | if (WARN_ON(ri.n != ri.cur)) | ||
169 | goto out; | ||
170 | |||
171 | /* | 122 | /* |
172 | * If the ACPI node has a parent and that parent has a physical device | 123 | * If the ACPI node has a parent and that parent has a physical device |
173 | * attached to it, that physical device should be the parent of the | 124 | * 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) | |||
189 | mutex_unlock(&acpi_parent->physical_node_lock); | 140 | mutex_unlock(&acpi_parent->physical_node_lock); |
190 | } | 141 | } |
191 | pdev = platform_device_register_resndata(parent, dev_name(&adev->dev), | 142 | pdev = platform_device_register_resndata(parent, dev_name(&adev->dev), |
192 | -1, ri.res, ri.n, NULL, 0); | 143 | -1, ri.res, ri.cur, NULL, 0); |
193 | if (IS_ERR(pdev)) { | 144 | if (IS_ERR(pdev)) { |
194 | dev_err(&adev->dev, "platform device creation failed: %ld\n", | 145 | dev_err(&adev->dev, "platform device creation failed: %ld\n", |
195 | PTR_ERR(pdev)); | 146 | PTR_ERR(pdev)); |