Skip to content

Commit a28aad6

Browse files
bebarinogregkh
authored andcommitted
firmware: coreboot: Collapse platform drivers into bus core
The DT based and ACPI based platform drivers here do the same thing; map some memory and hand it over to the coreboot bus to populate devices. The only major difference is that the DT based driver doesn't map the coreboot table header to figure out how large of a region to map for the whole coreboot table and it uses of_iomap() instead of ioremap_cache(). A cached or non-cached mapping shouldn't matter here and mapping some smaller region first before mapping the whole table is just more work but should be OK. In the end, we can remove two files and combine the code all in one place making it easier to reason about things. We leave the old Kconfigs in place for a little while longer but make them hidden and select the previously hidden config option. This way users can upgrade without having to know to reselect this config in the future. Later on we can remove the old hidden configs. Cc: Wei-Ning Huang <wnhuang@chromium.org> Cc: Julius Werner <jwerner@chromium.org> Cc: Brian Norris <briannorris@chromium.org> Cc: Samuel Holland <samuel@sholland.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b81e314 commit a28aad6

6 files changed

Lines changed: 72 additions & 176 deletions

File tree

‎drivers/firmware/google/Kconfig‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,22 @@ config GOOGLE_SMI
1919
variables.
2020

2121
config GOOGLE_COREBOOT_TABLE
22-
tristate
23-
depends on GOOGLE_COREBOOT_TABLE_ACPI || GOOGLE_COREBOOT_TABLE_OF
24-
25-
config GOOGLE_COREBOOT_TABLE_ACPI
26-
tristate "Coreboot Table Access - ACPI"
27-
depends on ACPI
28-
select GOOGLE_COREBOOT_TABLE
22+
tristate "Coreboot Table Access"
23+
depends on ACPI || OF
2924
help
3025
This option enables the coreboot_table module, which provides other
31-
firmware modules to access to the coreboot table. The coreboot table
32-
pointer is accessed through the ACPI "GOOGCB00" object.
26+
firmware modules access to the coreboot table. The coreboot table
27+
pointer is accessed through the ACPI "GOOGCB00" object or the
28+
device tree node /firmware/coreboot.
3329
If unsure say N.
3430

31+
config GOOGLE_COREBOOT_TABLE_ACPI
32+
tristate
33+
select GOOGLE_COREBOOT_TABLE
34+
3535
config GOOGLE_COREBOOT_TABLE_OF
36-
tristate "Coreboot Table Access - Device Tree"
37-
depends on OF
36+
tristate
3837
select GOOGLE_COREBOOT_TABLE
39-
help
40-
This option enable the coreboot_table module, which provide other
41-
firmware modules to access coreboot table. The coreboot table pointer
42-
is accessed through the device tree node /firmware/coreboot.
43-
If unsure say N.
4438

4539
config GOOGLE_MEMCONSOLE
4640
tristate

‎drivers/firmware/google/Makefile‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
obj-$(CONFIG_GOOGLE_SMI) += gsmi.o
44
obj-$(CONFIG_GOOGLE_COREBOOT_TABLE) += coreboot_table.o
5-
obj-$(CONFIG_GOOGLE_COREBOOT_TABLE_ACPI) += coreboot_table-acpi.o
6-
obj-$(CONFIG_GOOGLE_COREBOOT_TABLE_OF) += coreboot_table-of.o
75
obj-$(CONFIG_GOOGLE_FRAMEBUFFER_COREBOOT) += framebuffer-coreboot.o
86
obj-$(CONFIG_GOOGLE_MEMCONSOLE) += memconsole.o
97
obj-$(CONFIG_GOOGLE_MEMCONSOLE_COREBOOT) += memconsole-coreboot.o

‎drivers/firmware/google/coreboot_table-acpi.c‎

Lines changed: 0 additions & 88 deletions
This file was deleted.

‎drivers/firmware/google/coreboot_table-of.c‎

Lines changed: 0 additions & 60 deletions
This file was deleted.

‎drivers/firmware/google/coreboot_table.c‎

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
* GNU General Public License for more details.
1717
*/
1818

19+
#include <linux/acpi.h>
1920
#include <linux/device.h>
2021
#include <linux/err.h>
2122
#include <linux/init.h>
2223
#include <linux/io.h>
2324
#include <linux/kernel.h>
2425
#include <linux/module.h>
26+
#include <linux/of.h>
27+
#include <linux/platform_device.h>
2528
#include <linux/slab.h>
2629

2730
#include "coreboot_table.h"
@@ -91,7 +94,7 @@ void coreboot_driver_unregister(struct coreboot_driver *driver)
9194
}
9295
EXPORT_SYMBOL(coreboot_driver_unregister);
9396

94-
int coreboot_table_init(struct device *dev, void __iomem *ptr)
97+
static int coreboot_table_init(struct device *dev, void __iomem *ptr)
9598
{
9699
int i, ret;
97100
void *ptr_entry;
@@ -144,9 +147,38 @@ int coreboot_table_init(struct device *dev, void __iomem *ptr)
144147
iounmap(ptr);
145148
return ret;
146149
}
147-
EXPORT_SYMBOL(coreboot_table_init);
148150

149-
int coreboot_table_exit(void)
151+
static int coreboot_table_probe(struct platform_device *pdev)
152+
{
153+
phys_addr_t phyaddr;
154+
resource_size_t len;
155+
struct coreboot_table_header __iomem *header = NULL;
156+
struct resource *res;
157+
void __iomem *ptr = NULL;
158+
159+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
160+
if (!res)
161+
return -EINVAL;
162+
163+
len = resource_size(res);
164+
if (!res->start || !len)
165+
return -EINVAL;
166+
167+
phyaddr = res->start;
168+
header = ioremap_cache(phyaddr, sizeof(*header));
169+
if (header == NULL)
170+
return -ENOMEM;
171+
172+
ptr = ioremap_cache(phyaddr,
173+
header->header_bytes + header->table_bytes);
174+
iounmap(header);
175+
if (!ptr)
176+
return -ENOMEM;
177+
178+
return coreboot_table_init(&pdev->dev, ptr);
179+
}
180+
181+
static int coreboot_table_remove(struct platform_device *pdev)
150182
{
151183
if (ptr_header) {
152184
bus_unregister(&coreboot_bus_type);
@@ -155,7 +187,33 @@ int coreboot_table_exit(void)
155187

156188
return 0;
157189
}
158-
EXPORT_SYMBOL(coreboot_table_exit);
159190

191+
#ifdef CONFIG_ACPI
192+
static const struct acpi_device_id cros_coreboot_acpi_match[] = {
193+
{ "GOOGCB00", 0 },
194+
{ "BOOT0000", 0 },
195+
{ }
196+
};
197+
MODULE_DEVICE_TABLE(acpi, cros_coreboot_acpi_match);
198+
#endif
199+
200+
#ifdef CONFIG_OF
201+
static const struct of_device_id coreboot_of_match[] = {
202+
{ .compatible = "coreboot" },
203+
{}
204+
};
205+
MODULE_DEVICE_TABLE(of, coreboot_of_match);
206+
#endif
207+
208+
static struct platform_driver coreboot_table_driver = {
209+
.probe = coreboot_table_probe,
210+
.remove = coreboot_table_remove,
211+
.driver = {
212+
.name = "coreboot_table",
213+
.acpi_match_table = ACPI_PTR(cros_coreboot_acpi_match),
214+
.of_match_table = of_match_ptr(coreboot_of_match),
215+
},
216+
};
217+
module_platform_driver(coreboot_table_driver);
160218
MODULE_AUTHOR("Google, Inc.");
161219
MODULE_LICENSE("GPL");

‎drivers/firmware/google/coreboot_table.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,4 @@ int coreboot_driver_register(struct coreboot_driver *driver);
9191
/* Unregister a driver that uses the data from a coreboot table. */
9292
void coreboot_driver_unregister(struct coreboot_driver *driver);
9393

94-
/* Initialize coreboot table module given a pointer to iomem */
95-
int coreboot_table_init(struct device *dev, void __iomem *ptr);
96-
97-
/* Cleanup coreboot table module */
98-
int coreboot_table_exit(void);
99-
10094
#endif /* __COREBOOT_TABLE_H */

0 commit comments

Comments
 (0)