Re: [PATCH] net: designware: eqos: remove done TODO

2019-12-04 Thread Sascha Hauer
Hi Ahmad,

On Wed, Dec 04, 2019 at 02:05:36PM +0100, Ahmad Fatoum wrote:
> Hello Sascha,
> 
> On 11/15/19 2:33 PM, Sascha Hauer wrote:
> > On Thu, Nov 14, 2019 at 02:28:08PM +0100, Ahmad Fatoum wrote:
> >> The todo split comment is a left-over from refactoring. Remove it.
> >>
> >> Signed-off-by: Ahmad Fatoum 
> >> ---
> >>  drivers/net/designware_stm32.c | 1 -
> >>  1 file changed, 1 deletion(-)
> > 
> > Applied, thanks
> 
> I can't find this commit in upstream/next and the string still exists.
> Could you take a look?

Hm, indeed. I don't know where it got lost. I applied it now.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] ARM: i.MX: rebuild .imximg if DCD table in .imxcfg changes

2019-12-04 Thread Ahmad Fatoum
So far changing the DCD table didn't trigger a rerun of the i.MX
image utility. To fix this, we need to have the DCD table as prerequisite
to the .imximg rule. The file name is contained in $(CFG_$(@F)), but
can't be used directly because $@ (and by extension @F) has no value
when first expanded in the read-in phase. If we expand a second time
during the target-update phase however, we would get the correct value.

GNU make provides .SECONDEXPANSION to expand all following prerequisites
a second time. Use it to have changes to the DCD table rebuild the
image.

Because we are now using imx_image_rule to generate the target, we must
escape each $ one more time to arrive at (CFG_(@F)).

In the final step, we replace (@F) with %.imximg, so we support the
rules not ending in .imximg as well.

Dependency file generation is still broken however and changed to headers
included in DCD tables won't be caught, but this functionality can be
fixed in a separate patch.

Signed-off-by: Ahmad Fatoum 
---
 images/Makefile.imx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/images/Makefile.imx b/images/Makefile.imx
index 078b6b9d6a93..c34d72eb1b59 100644
--- a/images/Makefile.imx
+++ b/images/Makefile.imx
@@ -23,8 +23,9 @@ endef
 # %.imximg - convert into i.MX image
 # 
 
+.SECONDEXPANSION:
 define imx_image_rule
-$$(obj)/%.$(strip $(1)): $$(obj)/% FORCE
+$$(obj)/%.$(strip $(1)): $$(obj)/% (CFG_%.imximg) FORCE
$$(call if_changed,imx_image,$$(CFG_$$(patsubst %.$(strip 
$(1)),%.imximg,$$(@F))),$(strip $(2)))
 endef
 
@@ -36,7 +37,6 @@ $(eval $(call imx_image_rule,usimximg, -u -s))
 $(eval $(call imx_image_rule,esimximg, -e -s))
 $(eval $(call imx_image_rule,esimximg.dek, -e -s))
 
-.SECONDEXPANSION:
 $(obj)/%.img.dek: $(obj)/$$(FILE_$$(@F))
$(Q)if [ -z $(FILE_$(@F)) ]; then echo "FILE_$(@F) empty!"; false; fi
$(call if_changed,shipped)
-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/3] ARM: i.MX: introduce imx_image_rule variable for code deduplication

2019-12-04 Thread Ahmad Fatoum
The next patch will add the .imxcfg file as a rule prerequisite, so the
target is rebuilt if it changes. Instead of duplicating it in all rules,
factor out the common parts into a imx_image_rule variable.

No functional change.

Signed-off-by: Ahmad Fatoum 
---
 images/Makefile.imx | 32 +++-
 1 file changed, 11 insertions(+), 21 deletions(-)

diff --git a/images/Makefile.imx b/images/Makefile.imx
index 53d4ac8202c5..078b6b9d6a93 100644
--- a/images/Makefile.imx
+++ b/images/Makefile.imx
@@ -23,28 +23,18 @@ endef
 # %.imximg - convert into i.MX image
 # 
 
-$(obj)/%.imximg: $(obj)/% FORCE
-   $(call if_changed,imx_image,$(CFG_$(@F)),)
-
-$(obj)/%.pimximg: $(obj)/% FORCE
-   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.pimximg,%.imximg,$(@F))),\
-   -p $($(patsubst $(obj)/%.pblb,PBL_MEMORY_SIZE_%,$<)))
-
-$(obj)/%.psimximg: $(obj)/% FORCE
-   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.psimximg,%.imximg,$(@F))),\
-   -p $($(patsubst $(obj)/%.pblb,PBL_MEMORY_SIZE_%,$<)) -s)
-
-$(obj)/%.simximg: $(obj)/% FORCE
-   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.simximg,%.imximg,$(@F))),-s)
-
-$(obj)/%.usimximg: $(obj)/% FORCE
-   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.usimximg,%.imximg,$(@F))),-u -s)
-
-$(obj)/%.esimximg: $(obj)/% FORCE
-   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.esimximg,%.imximg,$(@F))),-e -s)
+define imx_image_rule
+$$(obj)/%.$(strip $(1)): $$(obj)/% FORCE
+   $$(call if_changed,imx_image,$$(CFG_$$(patsubst %.$(strip 
$(1)),%.imximg,$$(@F))),$(strip $(2)))
+endef
 
-$(obj)/%.esimximg.dek: $(obj)/% FORCE
-   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.esimximg,%.imximg,$(@F))),-e -s)
+$(eval $(call imx_image_rule,imximg))
+$(eval $(call imx_image_rule,pimximg, -p $($(patsubst 
$(obj)/%.pblb,PBL_MEMORY_SIZE_%,$<
+$(eval $(call imx_image_rule,psimximg, -p $($(patsubst 
$(obj)/%.pblb,PBL_MEMORY_SIZE_%,$<)) -s))
+$(eval $(call imx_image_rule,simximg, -s))
+$(eval $(call imx_image_rule,usimximg, -u -s))
+$(eval $(call imx_image_rule,esimximg, -e -s))
+$(eval $(call imx_image_rule,esimximg.dek, -e -s))
 
 .SECONDEXPANSION:
 $(obj)/%.img.dek: $(obj)/$$(FILE_$$(@F))
-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/3] images: i.MX: rearrange image rules in preparation for boilerplate removal

2019-12-04 Thread Ahmad Fatoum
The following commit will introduce a variable define to remove the
duplication in the different [supe]*imximg rules.

Prepare for this by rearranging the command line flags to line up with
the letters in the extension (i.e. -e -s for esimximg instead of -s -e)
and by splitting off a multi-target rule into two.

The former improves readability when the define is introduced, as it is
then easy to see the correspondence between extension and arguments.

The latter is needed because we will call the variable for each target.

No functional change.

Signed-off-by: Ahmad Fatoum 
---
 images/Makefile.imx | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/images/Makefile.imx b/images/Makefile.imx
index 6572474e19c8..53d4ac8202c5 100644
--- a/images/Makefile.imx
+++ b/images/Makefile.imx
@@ -31,17 +31,20 @@ $(obj)/%.pimximg: $(obj)/% FORCE
-p $($(patsubst $(obj)/%.pblb,PBL_MEMORY_SIZE_%,$<)))
 
 $(obj)/%.psimximg: $(obj)/% FORCE
-   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.psimximg,%.imximg,$(@F))),-s \
-   -p $($(patsubst $(obj)/%.pblb,PBL_MEMORY_SIZE_%,$<)))
+   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.psimximg,%.imximg,$(@F))),\
+   -p $($(patsubst $(obj)/%.pblb,PBL_MEMORY_SIZE_%,$<)) -s)
 
 $(obj)/%.simximg: $(obj)/% FORCE
$(call if_changed,imx_image,$(CFG_$(patsubst 
%.simximg,%.imximg,$(@F))),-s)
 
 $(obj)/%.usimximg: $(obj)/% FORCE
-   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.usimximg,%.imximg,$(@F))),-s -u)
+   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.usimximg,%.imximg,$(@F))),-u -s)
+
+$(obj)/%.esimximg: $(obj)/% FORCE
+   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.esimximg,%.imximg,$(@F))),-e -s)
 
-$(obj)/%.esimximg $(obj)/%.esimximg.dek: $(obj)/% FORCE
-   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.esimximg,%.imximg,$(@F))),-s -e)
+$(obj)/%.esimximg.dek: $(obj)/% FORCE
+   $(call if_changed,imx_image,$(CFG_$(patsubst 
%.esimximg,%.imximg,$(@F))),-e -s)
 
 .SECONDEXPANSION:
 $(obj)/%.img.dek: $(obj)/$$(FILE_$$(@F))
-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 0/2] bus: efi: add basic ACPI bus infrastructure

2019-12-04 Thread Ahmad Fatoum
On 12/4/19 3:07 PM, Ahmad Fatoum wrote:
> BIOS and barebox would only need to implement the H/W.

s{H/W}{interface}


-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | https://www.pengutronix.de/ |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/2] bus: efi: add basic ACPI bus infrastructure

2019-12-04 Thread Ahmad Fatoum
It makes sense to support some ACPI tables like the WDAT (Watchdog
Action Table) in barebox. To facilitate this add a ACPI bus and
the necessary bits to integrate ACPI tables into the barebox
device/driver model as devices. These devices are identified by the
four byte signature, which drivers can then match against and the
system description table (SDT) of the device is then available as a
device memory resource.

Even without drivers, with this patch, devinfo and md can now be used
to view the ACPI system description tables, which can be useful
during UEFI payload development.

Support for the ACPI Machine Language and ACPI 5.1 _DSD (Device
Specific Data) is not implemented.

Signed-off-by: Ahmad Fatoum 
---
 drivers/bus/Kconfig  |   8 ++
 drivers/bus/Makefile |   1 +
 drivers/bus/acpi.c   | 255 +++
 include/acpi.h   |  73 +
 4 files changed, 337 insertions(+)
 create mode 100644 drivers/bus/acpi.c
 create mode 100644 include/acpi.h

diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig
index 219982d878a8..1a2ff9129e8e 100644
--- a/drivers/bus/Kconfig
+++ b/drivers/bus/Kconfig
@@ -25,4 +25,12 @@ config MVEBU_MBUS
  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 ba5cee40636b..518689a1eabe 100644
--- a/drivers/bus/Makefile
+++ b/drivers/bus/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_BUS_OMAP_GPMC) += omap-gpmc.o
 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 ..2515b6633b33
--- /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", "

[PATCH 0/2] bus: efi: add basic ACPI bus infrastructure

2019-12-04 Thread Ahmad Fatoum
Microsoft specifies an ACPI Watchdog Action Table for its server
offerings that abstracts away hardware-specifics of watchdog devices.
This can be an alternative to implementing many different watchdog
driver in barebox for x86 H/W, as the driver is implemented in the
BIOS and barebox would only need to implement the H/W.

Unfortunately, I don't H/W handy that provides the WDAT table.
I've implemented the ACPI bus nevertheless, so here's the patch.

I haven't found anything else I'd like to do with ACPI, so I wrote a
sample driver to test the API. Not sure if it should go into the tree,
but I'd be in favor of adding it till there is a real user of the ACPI
bus (besides devinfo).

Cheers
Ahmad

Ahmad Fatoum (2):
  bus: efi: add basic ACPI bus infrastructure
  misc: add ACPI test driver

 drivers/bus/Kconfig  |   8 ++
 drivers/bus/Makefile |   1 +
 drivers/bus/acpi.c   | 255 +++
 drivers/misc/Kconfig |   6 +
 drivers/misc/Makefile|   1 +
 drivers/misc/acpi-test.c |  61 ++
 include/acpi.h   |  73 +++
 7 files changed, 405 insertions(+)
 create mode 100644 drivers/bus/acpi.c
 create mode 100644 drivers/misc/acpi-test.c
 create mode 100644 include/acpi.h

-- 
2.20.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] misc: add ACPI test driver

2019-12-04 Thread Ahmad Fatoum
We have a bus driver for ACPI, but no drivers yet. Add a simple (rather
useless) driver that exercises the API, which future drivers can be
based on. As soon as we have proper ACPI drivers, this driver could be
removed again.

Signed-off-by: Ahmad Fatoum 
---
 drivers/misc/Kconfig |  6 
 drivers/misc/Makefile|  1 +
 drivers/misc/acpi-test.c | 61 
 3 files changed, 68 insertions(+)
 create mode 100644 drivers/misc/acpi-test.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 0f736f8bded3..b76198b10af5 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -35,4 +35,10 @@ config UBOOTVAR
  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 bc1c01ea4d67..4d92465a1e5e 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_SRAM)  += sram.o
 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 ..970b435a0eec
--- /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);
-- 
2.20.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 3/3] remoteproc: add .stop device parameter for stopping remote processor

2019-12-04 Thread Ahmad Fatoum
Hello Sascha,

On 11/25/19 9:28 AM, Sascha Hauer wrote:
> I would assume that when I can stop the remote processor with this
> parameter I should be able to start it here as well, no?

I've yet to think some more about this, but could you merge the first
two commits now?

Cheers
Ahmad


-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | https://www.pengutronix.de/ |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] net: designware: eqos: remove done TODO

2019-12-04 Thread Ahmad Fatoum
Hello Sascha,

On 11/15/19 2:33 PM, Sascha Hauer wrote:
> On Thu, Nov 14, 2019 at 02:28:08PM +0100, Ahmad Fatoum wrote:
>> The todo split comment is a left-over from refactoring. Remove it.
>>
>> Signed-off-by: Ahmad Fatoum 
>> ---
>>  drivers/net/designware_stm32.c | 1 -
>>  1 file changed, 1 deletion(-)
> 
> Applied, thanks

I can't find this commit in upstream/next and the string still exists.
Could you take a look?

Thanks,
Ahmad


-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | https://www.pengutronix.de/ |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 9/9] serial: add support for PCI NS16550 UARTs

2019-12-04 Thread Ahmad Fatoum
This ports over the Linux v5.4 8250_pci driver. Unlike Linux, the
barebox ns16550 implementation provides less hooks for covering all the
quirky behavior of all the different 8250-"compatible" hardware blocks.

The barebox driver matches against all serial port the Linux driver does,
but for hardware with quirks that can't be expressed in the current barebox
n16550 API, the probe fails with -ENOSYS and an appropriate message
telling that the quirk handling is missing. This should make future
extension of the driver straight-forward.

Unlike the kernel variant of the driver, most ->exit quirk callbacks can
be dropped in barebox as they often disable IRQs, which we do in the
->init anyway.

This was tested with the EFI PCI driver on qemu with the options:

  -device pci-serial,chardev=cdev0 -chardev file,id=cdev0,path=COM

Signed-off-by: Ahmad Fatoum 
---
 drivers/serial/Kconfig  |8 +
 drivers/serial/Makefile |1 +
 drivers/serial/serial_ns16550_pci.c | 5311 +++
 3 files changed, 5320 insertions(+)
 create mode 100644 drivers/serial/serial_ns16550_pci.c

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 7a411d456e51..bd02fe2137c4 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -97,6 +97,14 @@ config DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
help
  Say Y here if you are using OMAP extensions to NS16550
 
+config DRIVER_SERIAL_NS16550_PCI
+   depends on DRIVER_SERIAL_NS16550
+   depends on PCI
+   default y
+   bool "NS16550 PCI serial driver"
+   help
+ Enable this to get support for NS16550 UARTs connected over PCI
+
 config DRIVER_SERIAL_PL010
depends on ARCH_EP93XX
default y
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 6f9e3b78350d..8a2abbbe45cf 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_DRIVER_SERIAL_LINUX_CONSOLE)   += 
linux_console.o
 obj-$(CONFIG_DRIVER_SERIAL_MPC5XXX)+= serial_mpc5xxx.o
 obj-$(CONFIG_DRIVER_SERIAL_CLPS711X)   += serial_clps711x.o
 obj-$(CONFIG_DRIVER_SERIAL_NS16550)+= serial_ns16550.o
+obj-$(CONFIG_DRIVER_SERIAL_NS16550_PCI)+= serial_ns16550_pci.o
 obj-$(CONFIG_DRIVER_SERIAL_PL010)  += serial_pl010.o
 obj-$(CONFIG_DRIVER_SERIAL_S3C)+= serial_s3c.o
 obj-$(CONFIG_DRIVER_SERIAL_STM32)  += serial_stm32.o
diff --git a/drivers/serial/serial_ns16550_pci.c 
b/drivers/serial/serial_ns16550_pci.c
new file mode 100644
index ..d4b5bd8898b7
--- /dev/null
+++ b/drivers/serial/serial_ns16550_pci.c
@@ -0,0 +1,5311 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ *  Probe module for 8250/16550-type PCI serial ports.
+ *
+ *  Based on Linux drivers/tty/serial/8250_pci.c
+ *  Itself based on Linux drivers/char/serial.c, by Linus Torvalds, Theodore 
Ts'o.
+ *
+ *  Copyright (C) 2001 Russell King, All Rights Reserved.
+ *  Copyright (C) 2019 Ahmad Fatoum, Pengutronix
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include "serial_ns16550.h"
+
+#define PCI_NUM_BAR_RESOURCES  6
+
+#define FL_BASE_MASK   0x0007
+#define FL_BASE0   0x
+#define FL_BASE1   0x0001
+#define FL_BASE2   0x0002
+#define FL_BASE3   0x0003
+#define FL_BASE4   0x0004
+#define FL_GET_BASE(x) (x & FL_BASE_MASK)
+
+/* Use successive BARs (PCI base address registers),
+   else use offset into some specified BAR */
+#define FL_BASE_BARS   0x0008
+
+/* do not assign an irq; no-op, we use no irqs */
+#define FL_NOIRQ   0x0080
+
+/* Use the Base address register size to cap number of ports */
+#define FL_REGION_SZ_CAP   0x0100
+
+
+struct uart_8250_port {
+   struct NS16550_plat *pdata;
+   struct resource resource;
+
+};
+
+struct pciserial_board {
+   unsigned int flags;
+   unsigned int num_ports;
+   unsigned int base_baud;
+   unsigned int uart_offset;
+   unsigned int reg_shift;
+   unsigned int first_offset;
+};
+
+struct serial_private;
+
+/*
+ * init function returns:
+ *  > 0 - number of ports
+ *  = 0 - use board->num_ports
+ *  < 0 - error
+ */
+struct pci_serial_quirk {
+   u32 vendor;
+   u32 device;
+   u32 subvendor;
+   u32 subdevice;
+   int (*probe)(struct pci_dev *dev);
+   int (*init)(struct pci_dev *dev);
+   int (*setup)(struct serial_private *,
+const struct pciserial_board *,
+struct uart_8250_port *, int);
+   void(*exit)(struct pci_dev *dev);
+};
+
+#define PCI_NUM_BAR_RESOURCES  6
+
+struct serial_private {
+   struct pci_dev  *dev;
+   unsigned intnr;
+   struct pci_serial_quirk *quirk;
+   const struct pciserial_board *board;
+  

[PATCH 6/9] PCI: copy over some Linux PCI helpers

2019-12-04 Thread Ahmad Fatoum
Linux PCI drivers, like the incoming 8250_pci, make use of these
helpers. Port them over from Linux v5.4.

Signed-off-by: Ahmad Fatoum 
---
 drivers/pci/bus.c   | 26 ++
 include/linux/pci.h | 34 ++
 2 files changed, 60 insertions(+)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index ac1562330788..251be4fffa6e 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -23,6 +23,32 @@ pci_match_one_device(const struct pci_device_id *id, const 
struct pci_dev *dev)
return NULL;
 }
 
+/**
+ * pci_match_id - See if a pci device matches a given pci_id table
+ * @ids: array of PCI device id structures to search in
+ * @dev: the PCI device structure to match against.
+ *
+ * Used by a driver to check whether a PCI device present in the
+ * system is in its list of supported devices.  Returns the matching
+ * pci_device_id structure or %NULL if there is no match.
+ *
+ * Deprecated, don't use this as it will not catch any dynamic ids
+ * that a driver might want to check for.
+ */
+const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
+struct pci_dev *dev)
+{
+   if (ids) {
+   while (ids->vendor || ids->subvendor || ids->class_mask) {
+   if (pci_match_one_device(ids, dev))
+   return ids;
+   ids++;
+   }
+   }
+   return NULL;
+}
+EXPORT_SYMBOL(pci_match_id);
+
 static int pci_match(struct device_d *dev, struct driver_d *drv)
 {
struct pci_dev *pdev = to_pci_dev(dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d92d70b6bd68..c742570e3684 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -115,6 +115,17 @@ struct pci_dev {
 };
 #defineto_pci_dev(d) container_of(d, struct pci_dev, dev)
 
+#define pci_resource_start(dev, bar)   ((dev)->resource[(bar)].start)
+#define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end)
+#define pci_resource_flags(dev, bar)   ((dev)->resource[(bar)].flags)
+#define pci_resource_len(dev,bar) \
+   ((pci_resource_start((dev), (bar)) == 0 &&  \
+ pci_resource_end((dev), (bar)) == \
+ pci_resource_start((dev), (bar))) ? 0 :   \
+   \
+(pci_resource_end((dev), (bar)) -  \
+ pci_resource_start((dev), (bar)) + 1))
+
 enum {
PCI_BUS_RESOURCE_IO = 0,
PCI_BUS_RESOURCE_MEM = 1,
@@ -210,6 +221,20 @@ struct pci_driver {
.vendor = (vend), .device = (dev), \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
 
+/**
+ * PCI_DEVICE_SUB - macro used to describe a specific PCI device with subsystem
+ * @vend: the 16 bit PCI Vendor ID
+ * @dev: the 16 bit PCI Device ID
+ * @subvend: the 16 bit PCI Subvendor ID
+ * @subdev: the 16 bit PCI Subdevice ID
+ *
+ * This macro is used to create a struct pci_device_id that matches a
+ * specific device with subsystem information.
+ */
+#define PCI_DEVICE_SUB(vend, dev, subvend, subdev) \
+   .vendor = (vend), .device = (dev), \
+   .subvendor = (subvend), .subdevice = (subdev)
+
 /**
  * PCI_DEVICE_CLASS - macro used to describe a specific pci device class
  * @dev_class: the class, subclass, prog-if triple for this device
@@ -350,4 +375,13 @@ enum pci_fixup_pass {
 
 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
 
+#ifdef CONFIG_PCI
+const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
+struct pci_dev *dev);
+#else
+static inline const struct pci_device_id *pci_match_id(const struct 
pci_device_id *ids,
+struct pci_dev *dev)
+{ return NULL; }
+#endif
+
 #endif /* LINUX_PCI_H */
-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 5/9] PCI: add driver_data member to struct pci_device_id

2019-12-04 Thread Ahmad Fatoum
Linux drivers have a driver data member in the struct to associate
variant specific driver data with each device id. Do likewise in
barebox.

Signed-off-by: Ahmad Fatoum 
---
 include/linux/mod_devicetable.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index d8125214a04a..1fbb3dc5c182 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -15,6 +15,7 @@ struct pci_device_id {
__u32 vendor, device;   /* Vendor and device ID or PCI_ANY_ID*/
__u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
__u32 class, class_mask;/* (class,subclass,prog-if) triplet */
+   unsigned long driver_data;  /* Data private to the driver */
 };
 
 #define SPI_NAME_SIZE 32
-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/9] efi: add and use new efi_device_has_guid helper

2019-12-04 Thread Ahmad Fatoum
We have at least two places where we check if a efidev has a particular
guid and a follow-up commit will introduce a third place.

So lets factor it out into a helper.

Signed-off-by: Ahmad Fatoum 
---
 drivers/block/efi-block-io.c | 11 ++-
 drivers/efi/efi-device.c | 11 ++-
 include/efi/efi-device.h | 12 
 3 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/block/efi-block-io.c b/drivers/block/efi-block-io.c
index 39dbfb0f7ada..30db486876a8 100644
--- a/drivers/block/efi-block-io.c
+++ b/drivers/block/efi-block-io.c
@@ -131,16 +131,9 @@ static void efi_bio_print_info(struct efi_bio_priv *priv)
media->optimal_transfer_length_granularity);
 }
 
-static int is_bio_usbdev(struct efi_device *efidev)
+static bool is_bio_usbdev(struct efi_device *efidev)
 {
-   int i;
-
-   for (i = 0; i < efidev->num_guids; i++) {
-   if (!efi_guidcmp(efidev->guids[i], EFI_USB_IO_PROTOCOL_GUID))
-   return 1;
-   }
-
-   return 0;
+   return efi_device_has_guid(efidev, EFI_USB_IO_PROTOCOL_GUID);
 }
 
 static int efi_bio_probe(struct efi_device *efidev)
diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c
index a1aac2dd31be..ac035dcfacbb 100644
--- a/drivers/efi/efi-device.c
+++ b/drivers/efi/efi-device.c
@@ -386,16 +386,9 @@ static int efi_is_setup_mode(void)
return ret != 1;
 }
 
-static int is_bio_usbdev(struct efi_device *efidev)
+static bool is_bio_usbdev(struct efi_device *efidev)
 {
-   int i;
-
-   for (i = 0; i < efidev->num_guids; i++) {
-   if (!efi_guidcmp(efidev->guids[i], EFI_USB_IO_PROTOCOL_GUID))
-   return 1;
-   }
-
-   return 0;
+   return efi_device_has_guid(efidev, EFI_USB_IO_PROTOCOL_GUID);
 }
 
 static struct efi_device *bootdev;
diff --git a/include/efi/efi-device.h b/include/efi/efi-device.h
index 5eaf1f260d56..5ec59a8a2ddd 100644
--- a/include/efi/efi-device.h
+++ b/include/efi/efi-device.h
@@ -45,4 +45,16 @@ int efi_connect_all(void);
 void efi_register_devices(void);
 struct efi_device *efi_get_bootsource(void);
 
+static inline bool efi_device_has_guid(struct efi_device *efidev, efi_guid_t 
guid)
+{
+   int i;
+
+   for (i = 0; i < efidev->num_guids; i++) {
+   if (!efi_guidcmp(efidev->guids[i], guid))
+   return true;
+   }
+
+   return false;
+}
+
 #endif /* __EFI_EFI_DEVICE_H */
-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 8/9] pci: add EFI PCI root bridge IO protocol driver

2019-12-04 Thread Ahmad Fatoum
UEFI 2.1D specifies two protocols for abstracting both the PCI host bus
controller and for PCI devices. The protocol for PCI devices provides
function pointers for accessing IO Port, Memory and PCI configuration
space, among others. The protocol for bus controllers provides the
ability to read the root bridge's PCI configuration space and to query
resources.

In barebox, we would want to reuse existing PCI drivers unmodified, so
we utilize the root bridge protocol, unlike most other EFI payloads.

We still utilize the PCI (device) IO protocol, but not for core
functionality: EFI has already enumerated the bus for us and allocated
the EFI handles. It thus makes sense to have the new pci device have the
EFI handle as parent and the controller as grand parent instead of
being sibling with the EFI handles. This is done with an early PCI fixup
that patches the device's parent pointer after consulting the PCI IO
GetLocation.

Signed-off-by: Ahmad Fatoum 
---
 drivers/efi/Kconfig   |   1 +
 drivers/pci/Kconfig   |   5 +
 drivers/pci/Makefile  |   1 +
 drivers/pci/pci-efi.c | 311 +++
 drivers/pci/pci-efi.h | 331 ++
 5 files changed, 649 insertions(+)
 create mode 100644 drivers/pci/pci-efi.c
 create mode 100644 drivers/pci/pci-efi.h

diff --git a/drivers/efi/Kconfig b/drivers/efi/Kconfig
index cca1a2e1d632..80d9e6f0c5eb 100644
--- a/drivers/efi/Kconfig
+++ b/drivers/efi/Kconfig
@@ -2,3 +2,4 @@ config EFI_BOOTUP
bool
select BLOCK
select PARTITION_DISK
+   select HW_HAS_PCI
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 025c418f2bcf..32153cda1809 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -54,6 +54,11 @@ config PCI_LAYERSCAPE
select OF_PCI
select PCI
 
+config PCI_EFI
+   bool "EFI PCI protocol"
+   depends on EFI_BOOTUP
+   select PCI
+
 endmenu
 
 endif
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 3ca6708657be..5843957b1925 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o
 obj-$(CONFIG_PCIE_DW) += pcie-designware.o pcie-designware-host.o
 obj-$(CONFIG_PCI_IMX6) += pci-imx6.o
 obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o
+obj-$(CONFIG_PCI_EFI) += pci-efi.o
diff --git a/drivers/pci/pci-efi.c b/drivers/pci/pci-efi.c
new file mode 100644
index ..80d13d906fe9
--- /dev/null
+++ b/drivers/pci/pci-efi.c
@@ -0,0 +1,311 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019 Ahmad Fatoum 
+ */
+#define pr_fmt(fmt) "pci-efi: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "pci-efi.h"
+
+struct efi_pci_priv {
+   struct efi_pci_root_bridge_io_protocol *protocol;
+   struct device_d *dev;
+   struct pci_controller pci;
+   struct resource mem;
+   struct resource io;
+   struct list_head children;
+};
+
+struct pci_child_id {
+   size_t segmentno;
+   size_t busno;
+   size_t devno;
+   size_t funcno;
+};
+
+struct pci_child {
+   struct efi_pci_io_protocol *protocol;
+   struct device_d *dev;
+   struct list_head list;
+   struct pci_child_id id;
+};
+
+static inline bool pci_child_id_equal(struct pci_child_id *a, struct 
pci_child_id *b)
+{
+   return a->segmentno == b->segmentno
+   && a->busno == b->busno
+   && a->devno == b->devno
+   && a->funcno == b->funcno;
+}
+
+#define host_to_efi_pci(host) container_of(host, struct efi_pci_priv, pci)
+
+static inline u64 efi_pci_addr(struct pci_bus *bus, u32 devfn, int where)
+{
+   return EFI_PCI_ADDRESS(bus->number,
+  PCI_SLOT(devfn), PCI_FUNC(devfn),
+  where);
+}
+
+static int efi_pci_rd_conf(struct pci_bus *bus, u32 devfn, int where,
+  int size, u32 *val)
+{
+   struct efi_pci_priv *priv = host_to_efi_pci(bus->host);
+   efi_status_t efiret;
+   u32 value;
+   enum efi_pci_protocol_width width;
+
+   switch (size) {
+   case 4:
+   width = EFI_PCI_WIDTH_U32;
+   break;
+   case 2:
+   width = EFI_PCI_WIDTH_U16;
+   break;
+   case 1:
+   width = EFI_PCI_WIDTH_U8;
+   break;
+   default:
+   return PCIBIOS_BAD_REGISTER_NUMBER;
+   }
+
+   efiret = priv->protocol->pci.read(priv->protocol, width,
+   efi_pci_addr(bus, devfn, where),
+   1, &value);
+
+   *val = 0x;
+
+   if (EFI_ERROR(efiret))
+   return PCIBIOS_BAD_REGISTER_NUMBER;
+
+   *val = value;
+
+   return PCIBIOS_SUCCESSFUL;
+}
+
+static int efi_pci_wr_conf(struct pci_bus *bus, u32 devfn, int where,
+  int size, u32 val)
+{
+   struct efi_pci_priv *priv = host_to_efi_pci(bus->host);
+   efi_s

[PATCH 2/9] driver: add missing parentheses around macro argument

2019-12-04 Thread Ahmad Fatoum
Currently, the macro can't be used for more complex expressions
like &pci_dev->dev. Fix this by adding the missing parentheses.

Signed-off-by: Ahmad Fatoum 
---
 include/driver.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/driver.h b/include/driver.h
index 300603fa3277..ad59ce90c3a3 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -155,12 +155,12 @@ int unregister_device(struct device_d *);
 /* Iterate over a devices children
  */
 #define device_for_each_child(dev, child) \
-   list_for_each_entry(child, &dev->children, sibling)
+   list_for_each_entry(child, &(dev)->children, sibling)
 
 /* Iterate over a devices children - Safe against removal version
  */
 #define device_for_each_child_safe(dev, tmpdev, child) \
-   list_for_each_entry_safe(child, tmpdev, &dev->children, sibling)
+   list_for_each_entry_safe(child, tmpdev, &(dev)->children, sibling)
 
 /* Iterate through the devices of a given type. if last is NULL, the
  * first device of this type is returned. Put this pointer in as
-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/9] efi: fix off-by-one in mem_malloc_init(..., end)

2019-12-04 Thread Ahmad Fatoum
The second (end) parameter of mem_malloc_init() denotes the last address
in the malloc region, so we need to subtract one from the current value
to arrive at the correct end. So far this went not noticed, because iomem
doesn't yet display barebox malloc memory region.

Signed-off-by: Ahmad Fatoum 
---
 common/efi/efi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/efi/efi.c b/common/efi/efi.c
index 73cea3703695..ed8158355020 100644
--- a/common/efi/efi.c
+++ b/common/efi/efi.c
@@ -361,7 +361,7 @@ efi_status_t efi_main(efi_handle_t image, 
efi_system_table_t *sys_table)
if (EFI_ERROR(efiret))
panic("failed to allocate malloc pool: %s\n",
  efi_strerror(efiret));
-   mem_malloc_init((void *)mem, (void *)mem + memsize);
+   mem_malloc_init((void *)mem, (void *)mem + memsize - 1);
 
start_barebox();
 
-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 4/9] x86: efi: lds: don't discard any relocation sections

2019-12-04 Thread Ahmad Fatoum
The incoming EFI PCI root bridge IO protocol driver will register
PCI fixups. Executing them will fail because the hook function's
relocation information is stripped from the final barebox.efi binary.

Instead of adding each section by name, just keep all .rela* sections
in the final binary.

This doesn't yet increase the size of the resulting barebox (yet).

Signed-off-by: Ahmad Fatoum 
---
 arch/x86/mach-efi/elf_x86_64_efi.lds.S | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/x86/mach-efi/elf_x86_64_efi.lds.S 
b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
index 40a942503475..ed79118a3615 100644
--- a/arch/x86/mach-efi/elf_x86_64_efi.lds.S
+++ b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
@@ -58,12 +58,7 @@ SECTIONS
. = ALIGN(4096);
 
.rela : {
-   *(.rela.data*)
-   *(.rela.barebox*)
-   *(.rela.initcall*)
-   *(.rela.exitcall*)
-   *(.rela.got)
-   *(.rela.stab)
+   *(.rela*)
}
 
. = ALIGN(4096);
-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 7/9] efi: turn set of defines into enumerations

2019-12-04 Thread Ahmad Fatoum
This allows us to use enum types instead of plain integers ttypes to
hold the values, which is done in a follow up commit.

Signed-off-by: Ahmad Fatoum 
---
 include/efi.h | 42 +++---
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/include/efi.h b/include/efi.h
index 166803a58f39..43c05939513d 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -91,21 +91,23 @@ typedef struct {
  */
 
 /* Memory types: */
-#define EFI_RESERVED_TYPE   0
-#define EFI_LOADER_CODE 1
-#define EFI_LOADER_DATA 2
-#define EFI_BOOT_SERVICES_CODE  3
-#define EFI_BOOT_SERVICES_DATA  4
-#define EFI_RUNTIME_SERVICES_CODE   5
-#define EFI_RUNTIME_SERVICES_DATA   6
-#define EFI_CONVENTIONAL_MEMORY 7
-#define EFI_UNUSABLE_MEMORY 8
-#define EFI_ACPI_RECLAIM_MEMORY 9
-#define EFI_ACPI_MEMORY_NVS10
-#define EFI_MEMORY_MAPPED_IO   11
-#define EFI_MEMORY_MAPPED_IO_PORT_SPACE12
-#define EFI_PAL_CODE   13
-#define EFI_MAX_MEMORY_TYPE14
+enum efi_memory_type {
+   EFI_RESERVED_TYPE,
+   EFI_LOADER_CODE,
+   EFI_LOADER_DATA,
+   EFI_BOOT_SERVICES_CODE,
+   EFI_BOOT_SERVICES_DATA,
+   EFI_RUNTIME_SERVICES_CODE,
+   EFI_RUNTIME_SERVICES_DATA,
+   EFI_CONVENTIONAL_MEMORY,
+   EFI_UNUSABLE_MEMORY,
+   EFI_ACPI_RECLAIM_MEMORY,
+   EFI_ACPI_MEMORY_NVS,
+   EFI_MEMORY_MAPPED_IO,
+   EFI_MEMORY_MAPPED_IO_PORT_SPACE,
+   EFI_PAL_CODE,
+   EFI_MAX_MEMORY_TYPE
+};
 
 /* Attribute values: */
 #define EFI_MEMORY_UC  ((u64)0x0001ULL)/* uncached */
@@ -124,10 +126,12 @@ typedef   struct {
 /*
  * Allocation types for calls to boottime->allocate_pages.
  */
-#define EFI_ALLOCATE_ANY_PAGES 0
-#define EFI_ALLOCATE_MAX_ADDRESS   1
-#define EFI_ALLOCATE_ADDRESS   2
-#define EFI_MAX_ALLOCATE_TYPE  3
+enum efi_allocate_type {
+   EFI_ALLOCATE_ANY_PAGES,
+   EFI_ALLOCATE_MAX_ADDRESS,
+   EFI_ALLOCATE_ADDRESS,
+   EFI_MAX_ALLOCATE_TYPE
+};
 
 typedef int (*efi_freemem_callback_t) (u64 start, u64 end, void *arg);
 
-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 0/9] efi: add PCI controller driver

2019-12-04 Thread Ahmad Fatoum
This series adds support for reusing existing barebox PCI drivers under
EFI. This means implementation of the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID,
instead of EFI_PCI_IO_PROTOCOL_GUID, which abstracts the devices and
handles enumeration.

This was tested with the default QEMU x86_64 machine and OVMF (Tianocore)
as UEFI firmware and an emulated 8250_pci (driver included in this
series):

qemu-system-x86_64 -pflash OVMF.fd -device pci-serial,chardev=cdev0 \
-chardev file,id=cdev0,path=COM -nographic /dev/sdb

Driver is written against UEFI Specification 2.1D. This is my first
dabble with PCI controllers, so please take a more thorough look.

Thanks!
Ahmad


Ahmad Fatoum (9):
  efi: add and use new efi_device_has_guid helper
  driver: add missing parentheses around macro argument
  efi: fix off-by-one in mem_malloc_init(..., end)
  x86: efi: lds: don't discard any relocation sections
  PCI: add driver_data member to struct pci_device_id
  PCI: copy over some Linux PCI helpers
  efi: turn set of defines into enumerations
  pci: add EFI PCI root bridge IO protocol driver
  serial: add support for PCI NS16550 UARTs

 arch/x86/mach-efi/elf_x86_64_efi.lds.S |7 +-
 common/efi/efi.c   |2 +-
 drivers/block/efi-block-io.c   |   11 +-
 drivers/efi/Kconfig|1 +
 drivers/efi/efi-device.c   |   11 +-
 drivers/pci/Kconfig|5 +
 drivers/pci/Makefile   |1 +
 drivers/pci/bus.c  |   26 +
 drivers/pci/pci-efi.c  |  311 ++
 drivers/pci/pci-efi.h  |  331 ++
 drivers/serial/Kconfig |8 +
 drivers/serial/Makefile|1 +
 drivers/serial/serial_ns16550_pci.c| 5311 
 include/driver.h   |4 +-
 include/efi.h  |   42 +-
 include/efi/efi-device.h   |   12 +
 include/linux/mod_devicetable.h|1 +
 include/linux/pci.h|   34 +
 18 files changed, 6073 insertions(+), 46 deletions(-)
 create mode 100644 drivers/pci/pci-efi.c
 create mode 100644 drivers/pci/pci-efi.h
 create mode 100644 drivers/serial/serial_ns16550_pci.c

-- 
2.24.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 00/12] Share i.MX ESDHC PBL and PIO code

2019-12-04 Thread Sascha Hauer
On Mon, Dec 02, 2019 at 07:19:42AM -0800, Andrey Smirnov wrote:
> Everyone:
> 
> This series is an attempt to share as much functionality between PBL
> ESDHC code and PIO case of regular ESDHC driver as possible, since
> both implementations are identical in a lot of ways.
> 
> Tested on RDU2 (i.MX6) and RDU3 (i.MX8MQ)
> 
> Feedback is welcome!

Looks good. I gave it some testing on a Phytec board, both with PBL and
non PBL. Works as expected. I have merged it to next, let's see if it
survives my compile tests.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox