diff --git a/README b/README index dada97c..d8077d2 100644 --- a/README +++ b/README @@ -225,6 +225,21 @@ people. +Contributing +------------ + +For any questions regarding Barebox, send a mail to the mailing list at +. The archives for this list are available +publicly at and +. + +The same list should also be used to send patches. Barebox uses a similar +process as the Linux kernel, so most of the Linux guide for submitting patches + also +applies to Barebox (except the step for selecting your recipient - we don't +have a MAINTAINERS file, instead all patches go to the list). + + License ------- diff --git a/arch/arm/boards/embedsky-e9/board.c b/arch/arm/boards/embedsky-e9/board.c index 0f47677..e5f9263 100644 --- a/arch/arm/boards/embedsky-e9/board.c +++ b/arch/arm/boards/embedsky-e9/board.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -102,8 +101,4 @@ return 0; } -/* - * Do this before the fec initializes but after our - * gpios are available. - */ coredevice_initcall(e9_coredevices_init); diff --git a/arch/arm/boards/freescale-mx6-sabresd/board.c b/arch/arm/boards/freescale-mx6-sabresd/board.c index 595b1ea..a505983 100644 --- a/arch/arm/boards/freescale-mx6-sabresd/board.c +++ b/arch/arm/boards/freescale-mx6-sabresd/board.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -84,8 +83,4 @@ return 0; } -/* - * Do this before the fec initializes but after our - * gpios are available. - */ coredevice_initcall(sabresd_coredevices_init); diff --git a/arch/mips/Makefile b/arch/mips/Makefile index ee465dc..1c10db5 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -52,9 +52,7 @@ cflags-$(CONFIG_CPU_MIPS32_R2) += $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) -Wa,-mips32r2 -Wa,--trap cflags-$(CONFIG_CPU_MIPS64_R1) += $(call cc-option,-march=mips64,-mips64 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) -Wa,-mips64 -Wa,--trap cflags-$(CONFIG_CPU_MIPS64_R2) += $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) -Wa,-mips64r2 -Wa,--trap -cflags-$(CONFIG_CPU_LOONGSON1) += \ - $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) \ - -Wa,-mips32r2 -Wa,--trap +cflags-$(CONFIG_CPU_LOONGSON1) += $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) -Wa,-mips32r2 -Wa,--trap CPPFLAGS += -DTEXT_BASE=$(CONFIG_TEXT_BASE) diff --git a/arch/mips/mach-ath79/art.c b/arch/mips/mach-ath79/art.c index 2a2099e..44118c1 100644 --- a/arch/mips/mach-ath79/art.c +++ b/arch/mips/mach-ath79/art.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2. +// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2018 Oleksij Rempel */ diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig index 219982d..1a2ff91 100644 --- a/drivers/bus/Kconfig +++ b/drivers/bus/Kconfig @@ -25,4 +25,12 @@ Driver needed for the MBus configuration on Marvell EBU SoCs (Kirkwood, Dove, Orion5x, MV78XX0 and Armada 370/XP). +config ACPI + bool "Advanced Configuration and Power Interface (ACPI)" + default y + depends on EFI_BOOTUP + help + Driver needed for supporting drivers probed from ACPI tables. + The root SDT is found via UEFI. + endmenu diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile index ba5cee4..518689a 100644 --- a/drivers/bus/Makefile +++ b/drivers/bus/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_IMX_WEIM) += imx-weim.o obj-$(CONFIG_MVEBU_MBUS) += mvebu-mbus.o obj-$(CONFIG_TI_SYSC) += ti-sysc.o +obj-$(CONFIG_ACPI) += acpi.o diff --git a/drivers/bus/acpi.c b/drivers/bus/acpi.c new file mode 100644 index 0000000..2515b66 --- /dev/null +++ b/drivers/bus/acpi.c @@ -0,0 +1,255 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 Ahmad Fatoum + */ + +#include +#include +#include +#include +#include +#include + +static struct sig_desc { + const char sig[4]; + const char *desc; +} signatures[] = { + /* ACPI 6.3 Table 5-29, Defined DESCRIPTION_HEADER Signatures */ + { "APIC", "Multiple APIC Description" }, + { "BERT", "Boot Error Record" }, + { "BGRT", "Boot Graphics Resource" }, + { "CPEP", "Corrected Platform Error Polling" }, + { "DSDT", "Differentiated System Description" }, + { "ECDT", "Embedded Controller Boot Resource" }, + { "EINJ", "Error Injection" }, + { "ERST", "Error Record Serialization" }, + { "FACP", "Fixed ACPI Description" }, + { "FACS", "Firmware ACPI Control Structure" }, + { "FPDT", "Firmware Performance Data" }, + { "GTDT", "Generic Timer Description" }, + { "HEST", "Hardware Error Source" }, + { "MSCT", "Maximum System Characteristics" }, + { "MPST", "Memory Power State" }, + { "NFIT", "NVDIMM Firmware Interface" }, + { "OEM\0", "OEM Specific Information" }, + { "PCCT", "Platform Communications Channel" }, + { "PMTT", "Platform Memory Topology" }, + { "PSDT", "Persistent System Description" }, + { "RASF", "ACPI RAS Feature" }, + { "RSDT", "Root System Description" }, + { "SBST", "Smart Battery Specification" }, + { "SDEV", "Secure Devices" }, + { "SLIT", "System Locality Distance Information" }, + { "SRAT", "System Resource Affinity" }, + { "SSDT", "Secondary System Description" }, + { "XSDT", "Extended System Description" }, + + /* ACPI 6.3 Table 5-30, Reserved DESCRIPTION_HEADER Signatures */ + { "BOOT", "Simple BOOT Flag" }, + { "CSRT", "Core System Resource" }, + { "DBG2", "Microsoft Debug Port 2" }, + { "DBGP", "Debug Port" }, + { "DMAR", "DMA Remapping" }, + { "DPPT", "DMA Protection Policy" }, + { "DRTM", "Dynamic Root of Trust for Measurement" }, + { "ETDT", "(Obsolete) Event Timer Description" }, + { "HPET", "IA-PC High Precision Event Timer" }, + { "IBFT", "iSCSI Boot Firmware" }, + { "IORT", "I/O Remapping" }, + { "IVRS", "I/O Virtualization Reporting Structure" }, + { "LPIT", "Low Power Idle" }, + { "MCFG", "PCI Express memory mapped configuration" }, + { "MCHI", "Management Controller Host Interface" }, + { "MSDM", "Microsoft Data Management" }, + { "SDEI", "Software Delegated Exceptions Interface" }, + { "SLIC", "Microsoft Software Licensing Specification" }, + { "SPCR", "Serial Port Console Redirection" }, + { "SPMI", "Server Platform Management Interface" }, + { "STAO", "_STA Override" }, + { "TCPA", "Trusted Computing Platform Alliance Capabilities" }, + { "TPM2", "Trusted Platform Module 2" }, + { "UEFI", "UEFI ACPI Data" }, + { "WAET", "Windows ACPI Emulated Devices" }, + { "WDAT", "Watch Dog Action" }, + { "WDRT", "Watchdog Resource" }, + { "WPBT", "Platform Binary" }, + { "WSMT", "Windows SMM Security Mitigation" }, + { "XENV", "Xen Project" }, + + /* Others */ + { "NHLT", "Non-HD Audio" }, + { "ASF!", "Alert Standard Format" }, + + { /* sentinel */ } +}; + +static struct acpi_sdt *acpi_get_dev_sdt(struct device_d *dev) +{ + int i; + + for (i = 0; i < dev->num_resources; i++) { + if (!strcmp(dev->resource[i].name, "SDT")) + return (struct acpi_sdt *)dev->resource[i].start; + } + + return NULL; +} + +static void acpi_devinfo(struct device_d *dev) +{ + struct acpi_sdt *sdt = acpi_get_dev_sdt(dev); + struct sig_desc *sig_desc; + + printf("Signature: %.4s", sdt->signature); + + for (sig_desc = signatures; sig_desc->desc; sig_desc++) { + size_t len = strnlen(sig_desc->sig, 4); + + if (!memcmp(sdt->signature, sig_desc->sig, len)) { + printf(" (%s Table)", sig_desc->desc); + break; + } + } + + printf("\nRevision: %u\n", sdt->revision); + printf("OemId: %.6s\n", sdt->oem_id); + printf("OemTableId: %.8s\n", sdt->oem_table_id); + printf("OemRevision: %u\n", sdt->oem_revision); + printf("CreatorId: 0x%08x\n", sdt->creator_id); + printf("CreatorRevision: %u\n", sdt->creator_revision); +} + +static int acpi_register_device(struct device_d *dev, struct acpi_sdt *sdt) +{ + int ret; + + ret = register_device(dev); + if (ret) + return ret; + + device_add_resource(dev, "SDT", (resource_size_t)sdt, sdt->len, + IORESOURCE_MEM | IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY); + + dev_dbg(dev, "registered as ACPI device\n"); + + return 0; +} + +static struct device_d *acpi_add_device(struct bus_type *bus, + acpi_sig_t signature) +{ + struct device_d *dev; + + dev = xzalloc(sizeof(*dev)); + + dev->bus = bus; + dev->parent = bus->dev; + dev->id = DEVICE_ID_DYNAMIC; + dev->info = acpi_devinfo; + + dev_set_name(dev, "acpi-%.4s", signature); + + return dev; +} + +static int acpi_register_devices(struct bus_type *bus) +{ + efi_config_table_t *table = bus->dev->priv; + struct acpi_rsdp *rsdp; + struct acpi_rsdt *root; + size_t entry_count; + const char *sig; + int i; + + rsdp = (struct acpi_rsdp *)table->table; + + if (!rsdp) + return -EFAULT; + + /* ACPI specification v6.3 + * 5.2.5.2 Finding the RSDP on UEFI Enabled Systems + */ + if (memcmp("RSD PTR ", rsdp->signature, sizeof(rsdp->signature))) { + dev_dbg(bus->dev, "unexpected signature at start of config table: '%.8s'\n", + rsdp->signature); + return -ENODEV; + } + + if (rsdp->revision < 0x02) { + sig = "RSDT"; + root = (struct acpi_rsdt *)(unsigned long)rsdp->rsdt_addr; + entry_count = (root->sdt.len - sizeof(struct acpi_rsdt)) / sizeof(u32); + } else { + sig = "XSDT"; + root = (struct acpi_rsdt *)((struct acpi2_rsdp *)rsdp)->xsdt_addr; + entry_count = (root->sdt.len - sizeof(struct acpi_rsdt)) / sizeof(u64); + } + + if (acpi_sigcmp(sig, root->sdt.signature)) { + dev_err(bus->dev, "Expected %s, but found '%.4s'.\n", + sig, root->sdt.signature); + return -EIO; + } + + dev_info(bus->dev, "Found %s (OEM: %.8s) with %lu entries\n", + sig, root->sdt.oem_id, entry_count); + + for (i = 0; i < entry_count; i++) { + struct acpi_sdt *sdt = root->entries[i]; + acpi_register_device(acpi_add_device(bus, sdt->signature), sdt); + } + + return 0; +} + +static int acpi_bus_match(struct device_d *dev, struct driver_d *drv) +{ + struct acpi_driver *acpidrv = to_acpi_driver(drv); + struct acpi_sdt *sdt = acpi_get_dev_sdt(dev); + + return acpi_sigcmp(acpidrv->signature, sdt->signature); +} + +static int acpi_bus_probe(struct device_d *dev) +{ + return dev->driver->probe(dev); +} + +static void acpi_bus_remove(struct device_d *dev) +{ + if (dev->driver->remove) + dev->driver->remove(dev); +} + +struct bus_type acpi_bus = { + .match = acpi_bus_match, + .probe = acpi_bus_probe, + .remove = acpi_bus_remove, +}; + +static int efi_acpi_probe(void) +{ + efi_config_table_t *table = NULL; + int i; + + for (i = 0; i < efi_sys_table->nr_tables; i++) { + efi_config_table_t *ect = &efi_sys_table->tables[i]; + /* take ACPI < 2 table only if no ACPI 2.0 is available */ + if (!efi_guidcmp(ect->guid, EFI_ACPI_20_TABLE_GUID)) { + acpi_bus.name = "acpi2"; + table = ect; + } else if (!table && !efi_guidcmp(ect->guid, EFI_ACPI_TABLE_GUID)) { + acpi_bus.name = "acpi"; + table = ect; + } + } + + if (!table) + return 0; + + bus_register(&acpi_bus); + acpi_bus.dev->priv = table; + + return acpi_register_devices(&acpi_bus); +} +postcore_initcall(efi_acpi_probe); diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 5ab43fe..7ccdb0b 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -94,8 +94,8 @@ if (!IS_ENABLED(CONFIG_OFDEVICE)) return -ENODEV; - pdata->sda_pin = of_get_named_gpio_flags(np, "sda-gpios", 0, NULL); - pdata->scl_pin = of_get_named_gpio_flags(np, "scl-gpios", 0, NULL); + pdata->sda_pin = of_get_named_gpio(np, "sda-gpios", 0); + pdata->scl_pin = of_get_named_gpio(np, "scl-gpios", 0); if ((!gpio_is_valid(pdata->sda_pin) || !gpio_is_valid(pdata->scl_pin)) && (of_gpio_count(np) >= 2)) { diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 0f736f8..b76198b 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -35,4 +35,10 @@ While it can be used standalone, it is best when coupled with corresponding filesystem driver. +config ACPI_TEST + bool "ACPI Test driver" + depends on ACPI + help + This is a simple Test driver to test the ACPI bus. + endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index bc1c01e..4d92465 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_STATE_DRV) += state.o obj-$(CONFIG_DEV_MEM) += mem.o obj-$(CONFIG_UBOOTVAR) += ubootvar.o +obj-$(CONFIG_ACPI_TEST) += acpi-test.o diff --git a/drivers/misc/acpi-test.c b/drivers/misc/acpi-test.c new file mode 100644 index 0000000..970b435 --- /dev/null +++ b/drivers/misc/acpi-test.c @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 Ahmad Fatoum + */ + +#include +#include +#include + +static const char *profiles[] = { + "Unspecified", + "Desktop", + "Mobile", + "Workstation", + "Enterprise Server", + "SOHO Server", + "Applicance PC", + "Performance Server", + "Tablet", +}; + +static int acpi_test_probe(struct device_d *dev) +{ + const char *profile = "reserved"; + u8 *sdt; + u8 profileno; + + dev_dbg(dev, "driver initializing...\n"); + + sdt = (u8 __force *)dev_request_mem_region_by_name(dev, "SDT"); + if (IS_ERR(sdt)) { + dev_err(dev, "no SDT resource available: %s\n", strerrorp(sdt)); + return PTR_ERR(sdt); + } + + dev_dbg(dev, "SDT is at 0x%p\n", sdt); + + profileno = sdt[45]; + + if (profileno < ARRAY_SIZE(profiles)) + profile = profiles[profileno]; + + dev_info(dev, "PM profile is for '%s'\n", profile); + + return 0; +} + +static void acpi_test_remove(struct device_d *dev) +{ + dev_info(dev, "FADT driver removed\n"); +} + +static struct acpi_driver acpi_test_driver = { + .signature = "FACP", + .driver = { + .name = "acpi-test", + .probe = acpi_test_probe, + .remove = acpi_test_remove, + } +}; +device_acpi_driver(acpi_test_driver); diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index b251035..1e1b696 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -677,6 +677,8 @@ SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "is25lp016d", INFO(0x9d6015, 0, 64 * 1024, 32, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "is25lp01g", INFO(0x9d601b, 0, 64 * 1024, 2048, + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "is25lp080d", INFO(0x9d6014, 0, 64 * 1024, 16, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "is25lp032", INFO(0x9d6016, 0, 64 * 1024, 64, diff --git a/drivers/net/designware_stm32.c b/drivers/net/designware_stm32.c index 9acdf11..4c682a5 100644 --- a/drivers/net/designware_stm32.c +++ b/drivers/net/designware_stm32.c @@ -174,7 +174,6 @@ return 0; } -// todo split! static struct eqos_ops stm32_ops = { .init = eqos_init_stm32, .get_ethaddr = eqos_get_ethaddr, diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 82a202c..35c4b8c 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -861,7 +861,7 @@ if (filetype == filetype_ubi) { fastboot_tx_print(f_fb, FASTBOOT_MSG_INFO, - "This is an UBI image..."); + "This is a UBI image..."); return 1; } else { fastboot_tx_print(f_fb, FASTBOOT_MSG_FAIL, diff --git a/include/acpi.h b/include/acpi.h new file mode 100644 index 0000000..2d5fd30 --- /dev/null +++ b/include/acpi.h @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 Ahmad Fatoum + */ + +#ifndef __ACPI_H_ +#define __ACPI_H_ + +#include +#include + +typedef char acpi_sig_t[4]; + +struct __packed acpi_rsdp { /* root system description pointer */ + char signature[8]; + u8 checksum; + u8 oem_id[6]; + u8 revision; + u32 rsdt_addr; +}; + +struct __packed acpi2_rsdp { /* root system description */ + struct acpi_rsdp acpi1; + u32 length; + u64 xsdt_addr; + u8 extended_checksum; + u8 reserved[3]; +}; + +struct __packed acpi_sdt { /* system description table header */ + acpi_sig_t signature; + u32 len; + u8 revision; + u8 checksum; + char oem_id[6]; + char oem_table_id[8]; + u32 oem_revision; + u32 creator_id; + u32 creator_revision; +}; + +struct __packed acpi_rsdt { /* system description table header */ + struct acpi_sdt sdt; + struct acpi_sdt * __aligned(8) entries[]; +}; + +struct acpi_driver { + struct driver_d driver; + acpi_sig_t signature; +}; + +extern struct bus_type acpi_bus; + +static inline struct acpi_driver *to_acpi_driver(struct driver_d *drv) +{ + return container_of(drv, struct acpi_driver, driver); +} + +#define device_acpi_driver(drv) \ + register_driver_macro(device, acpi, drv) + +static inline int acpi_driver_register(struct acpi_driver *acpidrv) +{ + acpidrv->driver.bus = &acpi_bus; + return register_driver(&acpidrv->driver); +} + +static inline int acpi_sigcmp(const acpi_sig_t sig_a, const acpi_sig_t sig_b) +{ + return memcmp(sig_a, sig_b, sizeof(acpi_sig_t)); +} + +#endif