bc092b
From d11ced1e1fb93676942e51618eb53c140f541890 Mon Sep 17 00:00:00 2001
bc092b
From: Vladimir Serbinenko <phcoder@gmail.com>
bc092b
Date: Mon, 8 May 2017 22:14:28 +0200
31cddd
Subject: [PATCH] arm_coreboot: Support EHCI.
bc092b
bc092b
---
bc092b
 grub-core/Makefile.core.def  |  2 ++
bc092b
 grub-core/bus/usb/ehci-fdt.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
bc092b
 grub-core/bus/usb/usbtrans.c |  2 +-
bc092b
 include/grub/usb.h           |  4 ++++
ec4acb
 gentpl.py                    |  2 +-
bc092b
 5 files changed, 53 insertions(+), 2 deletions(-)
bc092b
 create mode 100644 grub-core/bus/usb/ehci-fdt.c
bc092b
bc092b
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
ec4acb
index 4745eb4d93e..5ce506597a6 100644
bc092b
--- a/grub-core/Makefile.core.def
bc092b
+++ b/grub-core/Makefile.core.def
bc092b
@@ -593,8 +593,10 @@ module = {
bc092b
 module = {
bc092b
   name = ehci;
bc092b
   common = bus/usb/ehci.c;
bc092b
+  arm_coreboot = bus/usb/ehci-fdt.c;
bc092b
   pci = bus/usb/ehci-pci.c;
bc092b
   enable = pci;
bc092b
+  enable = arm_coreboot;
bc092b
 };
bc092b
 
bc092b
 module = {
bc092b
diff --git a/grub-core/bus/usb/ehci-fdt.c b/grub-core/bus/usb/ehci-fdt.c
bc092b
new file mode 100644
ec4acb
index 00000000000..29b50bdd5c3
bc092b
--- /dev/null
bc092b
+++ b/grub-core/bus/usb/ehci-fdt.c
bc092b
@@ -0,0 +1,45 @@
bc092b
+/* ehci.c - EHCI Support.  */
bc092b
+/*
bc092b
+ *  GRUB  --  GRand Unified Bootloader
bc092b
+ *  Copyright (C) 2011  Free Software Foundation, Inc.
bc092b
+ *
bc092b
+ *  GRUB is free software: you can redistribute it and/or modify
bc092b
+ *  it under the terms of the GNU General Public License as published by
bc092b
+ *  the Free Software Foundation, either version 3 of the License, or
bc092b
+ *  (at your option) any later version.
bc092b
+ *
bc092b
+ *  GRUB is distributed in the hope that it will be useful,
bc092b
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
bc092b
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
bc092b
+ *  GNU General Public License for more details.
bc092b
+ *
bc092b
+ *  You should have received a copy of the GNU General Public License
bc092b
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
bc092b
+ */
bc092b
+
bc092b
+#include <grub/misc.h>
bc092b
+#include <grub/mm.h>
bc092b
+#include <grub/time.h>
bc092b
+#include <grub/usb.h>
bc092b
+#include <grub/fdtbus.h>
bc092b
+
bc092b
+static grub_err_t
bc092b
+ehci_attach(const struct grub_fdtbus_dev *dev)
bc092b
+{
bc092b
+  grub_dprintf ("ehci", "Found generic-ehci\n");
bc092b
+
bc092b
+  grub_ehci_init_device (grub_fdtbus_map_reg (dev, 0, 0));
bc092b
+  return 0;
bc092b
+}
bc092b
+
bc092b
+struct grub_fdtbus_driver ehci =
bc092b
+{
bc092b
+  .compatible = "generic-ehci",
bc092b
+  .attach = ehci_attach
bc092b
+};
bc092b
+
bc092b
+void
bc092b
+grub_ehci_pci_scan (void)
bc092b
+{
bc092b
+  grub_fdtbus_register (&ehci);
bc092b
+}
bc092b
diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c
ec4acb
index 9266e49311c..85f081fffb3 100644
bc092b
--- a/grub-core/bus/usb/usbtrans.c
bc092b
+++ b/grub-core/bus/usb/usbtrans.c
bc092b
@@ -18,7 +18,7 @@
bc092b
  */
bc092b
 
bc092b
 #include <grub/dl.h>
bc092b
-#include <grub/pci.h>
bc092b
+#include <grub/dma.h>
bc092b
 #include <grub/mm.h>
bc092b
 #include <grub/misc.h>
bc092b
 #include <grub/usb.h>
bc092b
diff --git a/include/grub/usb.h b/include/grub/usb.h
ec4acb
index 11d96481ff6..512ae1dd0e6 100644
bc092b
--- a/include/grub/usb.h
bc092b
+++ b/include/grub/usb.h
bc092b
@@ -321,5 +321,9 @@ grub_usb_err_t
bc092b
 grub_usb_check_transfer (grub_usb_transfer_t trans, grub_size_t *actual);
bc092b
 void
bc092b
 grub_usb_cancel_transfer (grub_usb_transfer_t trans);
bc092b
+void
bc092b
+grub_ehci_init_device (volatile void *regs);
bc092b
+void
bc092b
+grub_ehci_pci_scan (void);
bc092b
 
bc092b
 #endif /* GRUB_USB_H */
ec4acb
diff --git a/gentpl.py b/gentpl.py
ec4acb
index ed268178b4d..da67965a41a 100644
ec4acb
--- a/gentpl.py
ec4acb
+++ b/gentpl.py
ec4acb
@@ -63,7 +63,7 @@ GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_loongson", "mips_qemu_mips",
ec4acb
                                      "sparc64_ieee1275", "powerpc_ieee1275"]
ec4acb
 GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi");
ec4acb
 GROUPS["pci"]      = GROUPS["x86"] + ["mips_loongson"]
ec4acb
-GROUPS["usb"]      = GROUPS["pci"]
ec4acb
+GROUPS["usb"]      = GROUPS["pci"] + ["arm_coreboot"]
ec4acb
 
ec4acb
 # If gfxterm is main output console integrate it into kernel
ec4acb
 GROUPS["videoinkernel"] = ["mips_loongson", "i386_coreboot", "arm_coreboot" ]