Compare commits

...

6 Commits

Author SHA1 Message Date
Vladimir Serbinenko
6e4e4ee33f dwc2 counterpart of previous patch 2016-03-01 20:09:54 +01:00
Vladimir Serbinenko
e1444e5399 Rename portstatus to reset_port.
The way we currently use portstatus always uses
enable=1 and we use it for its reset side effect.
Change confusing name and remove unused parameter.
2016-03-01 20:09:47 +01:00
Vladimir Serbinenko
ef57ad6164 detect_dev 2016-03-01 19:59:52 +01:00
Vladimir Serbinenko
72bd5756af dwc2 skeleton 2016-02-27 16:15:43 +01:00
Vladimir Serbinenko
295e041189 clone ehci to dwc1 2016-02-25 19:55:39 +01:00
Vladimir Serbinenko
3f6f84f9e0 fix mkimage.c split 2016-02-25 19:52:46 +01:00
9 changed files with 1861 additions and 52 deletions

View File

@@ -598,6 +598,13 @@ module = {
enable = arm_coreboot;
};
module = {
name = dwc2;
common = bus/usb/dwc2.c;
arm_coreboot = bus/usb/dwc2-fdt.c;
enable = arm_coreboot;
};
module = {
name = pci;
common = bus/pci.c;

View File

@@ -0,0 +1,45 @@
/* ehci.c - EHCI Support. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/time.h>
#include <grub/usb.h>
#include <grub/fdtbus.h>
static grub_err_t
dwc2_attach(const struct grub_fdtbus_dev *dev)
{
grub_dprintf ("dwc2", "Found snps-dwc2\n");
grub_dwc2_init_device (grub_fdtbus_map_reg (dev, 0, 0));
return 0;
}
struct grub_fdtbus_driver dwc2 =
{
.compatible = "snps,dwc2",
.attach = dwc2_attach
};
void
grub_dwc2_pci_scan (void)
{
grub_fdtbus_register (&dwc2);
}

1791
grub-core/bus/usb/dwc2.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1579,8 +1579,8 @@ grub_ehci_hubports (grub_usb_controller_t dev)
}
static grub_usb_err_t
grub_ehci_portstatus (grub_usb_controller_t dev,
unsigned int port, unsigned int enable)
grub_ehci_reset_port (grub_usb_controller_t dev,
unsigned int port)
{
struct grub_ehci *e = (struct grub_ehci *) dev->data;
grub_uint64_t endtime;
@@ -1602,14 +1602,6 @@ grub_ehci_portstatus (grub_usb_controller_t dev,
if (grub_get_time_ms () > endtime)
return GRUB_USB_ERR_TIMEOUT;
if (!enable) /* We don't need reset port */
{
grub_dprintf ("ehci", "portstatus: Disabled.\n");
grub_dprintf ("ehci", "portstatus: end, status=0x%02x\n",
grub_ehci_port_read (e, port));
return GRUB_USB_ERR_NONE;
}
grub_dprintf ("ehci", "portstatus: enable\n");
grub_boot_time ("Resetting port %d", port);
@@ -1810,7 +1802,7 @@ static struct grub_usb_controller_dev usb_controller = {
.check_transfer = grub_ehci_check_transfer,
.cancel_transfer = grub_ehci_cancel_transfer,
.hubports = grub_ehci_hubports,
.portstatus = grub_ehci_portstatus,
.reset_port = grub_ehci_reset_port,
.detect_dev = grub_ehci_detect_dev,
/* estimated max. count of TDs for one bulk transfer */
.max_bulk_tds = GRUB_EHCI_N_TD * 3 / 4

View File

@@ -1224,8 +1224,8 @@ grub_ohci_cancel_transfer (grub_usb_controller_t dev,
}
static grub_usb_err_t
grub_ohci_portstatus (grub_usb_controller_t dev,
unsigned int port, unsigned int enable)
grub_ohci_rest_port (grub_usb_controller_t dev,
unsigned int port)
{
struct grub_ohci *o = (struct grub_ohci *) dev->data;
grub_uint64_t endtime;
@@ -1233,22 +1233,6 @@ grub_ohci_portstatus (grub_usb_controller_t dev,
grub_dprintf ("ohci", "begin of portstatus=0x%02x\n",
grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port));
if (!enable) /* We don't need reset port */
{
/* Disable the port and wait for it. */
grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port,
GRUB_OHCI_CLEAR_PORT_ENABLE);
endtime = grub_get_time_ms () + 1000;
while ((grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port)
& (1 << 1)))
if (grub_get_time_ms () > endtime)
return GRUB_USB_ERR_TIMEOUT;
grub_dprintf ("ohci", "end of portstatus=0x%02x\n",
grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port));
return GRUB_USB_ERR_NONE;
}
/* OHCI does one reset signal 10ms long but USB spec.
* requests 50ms for root hub (no need to be continuous).
@@ -1438,7 +1422,7 @@ static struct grub_usb_controller_dev usb_controller =
.check_transfer = grub_ohci_check_transfer,
.cancel_transfer = grub_ohci_cancel_transfer,
.hubports = grub_ohci_hubports,
.portstatus = grub_ohci_portstatus,
.reset_port = grub_ohci_reset_port,
.detect_dev = grub_ohci_detect_dev,
/* estimated max. count of TDs for one bulk transfer */
.max_bulk_tds = GRUB_OHCI_TDS * 3 / 4

View File

@@ -710,8 +710,8 @@ grub_uhci_iterate (grub_usb_controller_iterate_hook_t hook, void *hook_data)
}
static grub_usb_err_t
grub_uhci_portstatus (grub_usb_controller_t dev,
unsigned int port, unsigned int enable)
grub_uhci_reset_port (grub_usb_controller_t dev,
unsigned int port)
{
struct grub_uhci *u = (struct grub_uhci *) dev->data;
int reg;
@@ -731,21 +731,6 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
status = grub_uhci_readreg16 (u, reg);
grub_dprintf ("uhci", "detect=0x%02x\n", status);
if (!enable) /* We don't need reset port */
{
/* Disable the port. */
grub_uhci_writereg16 (u, reg, 0 << 2);
grub_dprintf ("uhci", "waiting for the port to be disabled\n");
endtime = grub_get_time_ms () + 1000;
while ((grub_uhci_readreg16 (u, reg) & (1 << 2)))
if (grub_get_time_ms () > endtime)
return GRUB_USB_ERR_TIMEOUT;
status = grub_uhci_readreg16 (u, reg);
grub_dprintf ("uhci", ">3detect=0x%02x\n", status);
return GRUB_USB_ERR_NONE;
}
/* Reset the port. */
status = grub_uhci_readreg16 (u, reg) & ~GRUB_UHCI_PORTSC_RWC;
@@ -843,7 +828,7 @@ static struct grub_usb_controller_dev usb_controller =
.check_transfer = grub_uhci_check_transfer,
.cancel_transfer = grub_uhci_cancel_transfer,
.hubports = grub_uhci_hubports,
.portstatus = grub_uhci_portstatus,
.reset_port = grub_uhci_reset_port,
.detect_dev = grub_uhci_detect_dev,
/* estimated max. count of TDs for one bulk transfer */
.max_bulk_tds = N_TD * 3 / 4

View File

@@ -207,8 +207,8 @@ attach_root_port (struct grub_usb_hub *hub, int portno,
grub_boot_time ("After detect_dev");
/* Enable the port. */
err = hub->controller->dev->portstatus (hub->controller, portno, 1);
/* Reset port. */
err = hub->controller->dev->reset_port (hub->controller, portno);
if (err)
return;
hub->controller->dev->pending_reset = grub_get_time_ms () + 5000;

View File

@@ -116,8 +116,7 @@ struct grub_usb_controller_dev
int (*hubports) (grub_usb_controller_t dev);
grub_usb_err_t (*portstatus) (grub_usb_controller_t dev, unsigned int port,
unsigned int enable);
grub_usb_err_t (*reset_port) (grub_usb_controller_t dev, unsigned int port);
grub_usb_speed_t (*detect_dev) (grub_usb_controller_t dev, int port, int *changed);
@@ -325,5 +324,9 @@ void
grub_ehci_init_device (volatile void *regs);
void
grub_ehci_pci_scan (void);
void
grub_dwc2_init_device (volatile void *regs);
void
grub_dwc2_pci_scan (void);
#endif /* GRUB_USB_H */

View File

@@ -56,6 +56,8 @@
#define TARGET_NO_FIELD 0xffffffff
#pragma GCC diagnostic ignored "-Wcast-align"
/* use 2015-01-01T00:00:00+0000 as a stock timestamp */
#define STABLE_EMBEDDING_TIMESTAMP 1420070400