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