summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/bootm.c3
-rw-r--r--common/cli_hush.c8
-rw-r--r--common/cmd_fitupd.c14
-rw-r--r--common/dlmalloc.c5
-rw-r--r--common/image-fdt.c4
-rw-r--r--common/image-fit.c3
-rw-r--r--common/image.c1
-rw-r--r--common/lcd.c24
-rw-r--r--common/stdio.c1
-rw-r--r--common/usb.c19
-rw-r--r--common/usb_hub.c39
-rw-r--r--common/usb_kbd.c95
-rw-r--r--common/usb_storage.c7
13 files changed, 75 insertions, 148 deletions
diff --git a/common/bootm.c b/common/bootm.c
index 81e3261..6b3ea8c 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -167,7 +167,8 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
}
/* If we have a valid setup.bin, we will use that for entry (x86) */
- if (images.os.arch == IH_ARCH_I386) {
+ if (images.os.arch == IH_ARCH_I386 ||
+ images.os.arch == IH_ARCH_X86_64) {
ulong len;
ret = boot_get_setup(&images, IH_ARCH_I386, &images.ep, &len);
diff --git a/common/cli_hush.c b/common/cli_hush.c
index 2b654b7..d643912 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -3162,7 +3162,7 @@ static int parse_stream_outer(struct in_str *inp, int flag)
o_string temp=NULL_O_STRING;
int rcode;
#ifdef __U_BOOT__
- int code = 0;
+ int code = 1;
#endif
do {
ctx.type = flag;
@@ -3217,7 +3217,7 @@ static int parse_stream_outer(struct in_str *inp, int flag)
}
b_free(&temp);
/* loop on syntax errors, return on EOF */
- } while (rcode != -1 && !(flag & FLAG_EXIT_FROM_LOOP) &&
+ } while (rcode != 1 && !(flag & FLAG_EXIT_FROM_LOOP) &&
(inp->peek != static_peek || b_peek(inp)));
#ifndef __U_BOOT__
return 0;
@@ -3236,8 +3236,10 @@ int parse_string_outer(const char *s, int flag)
#ifdef __U_BOOT__
char *p = NULL;
int rcode;
- if ( !s || !*s)
+ if (!s)
return 1;
+ if (!*s)
+ return 0;
if (!(p = strchr(s, '\n')) || *++p) {
p = xmalloc(strlen(s) + 2);
strcpy(p, s);
diff --git a/common/cmd_fitupd.c b/common/cmd_fitupd.c
index e811473..b045974 100644
--- a/common/cmd_fitupd.c
+++ b/common/cmd_fitupd.c
@@ -1,12 +1,8 @@
-de <net.h>
-
-#if !defined(CONFIG_UPDATE_TFTP)
-#error "CONFIG_UPDATE_TFTP required"
-#endif
-
-static int do_fitupd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
- ulong addr = 0Un the root directory of the source tree for details.
+/*
+ * (C) Copyright 2011
+ * Andreas Pretzsch, carpe noctem engineering, apr@cn-eng.de
+ *
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index f987339..991229d 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1533,6 +1533,9 @@ void mem_malloc_init(ulong start, ulong size)
mem_malloc_end = start + size;
mem_malloc_brk = start;
+ debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start,
+ mem_malloc_end);
+
memset((void *)mem_malloc_start, 0, size);
malloc_bin_reloc();
@@ -2181,7 +2184,7 @@ Void_t* mALLOc(bytes) size_t bytes;
INTERNAL_SIZE_T nb;
#ifdef CONFIG_SYS_MALLOC_F_LEN
- if (!(gd->flags & GD_FLG_RELOC)) {
+ if (gd && !(gd->flags & GD_FLG_RELOC)) {
ulong new_ptr;
void *ptr;
diff --git a/common/image-fdt.c b/common/image-fdt.c
index a2342fa..a39ae1b 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -413,11 +413,11 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
}
} else {
debug("## No Flattened Device Tree\n");
- return 0;
+ goto error;
}
} else {
debug("## No Flattened Device Tree\n");
- return 0;
+ goto error;
}
*of_flat_tree = fdt_blob;
diff --git a/common/image-fit.c b/common/image-fit.c
index a272ea2..4ffc5aa 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1114,7 +1114,8 @@ int fit_image_check_arch(const void *fit, int noffset, uint8_t arch)
if (fit_image_get_arch(fit, noffset, &image_arch))
return 0;
- return (arch == image_arch);
+ return (arch == image_arch) ||
+ (arch == IH_ARCH_I386 && image_arch == IH_ARCH_X86_64);
}
/**
diff --git a/common/image.c b/common/image.c
index eb92e63..b75a5ce 100644
--- a/common/image.c
+++ b/common/image.c
@@ -85,6 +85,7 @@ static const table_entry_t uimage_arch[] = {
{ IH_ARCH_SANDBOX, "sandbox", "Sandbox", },
{ IH_ARCH_ARM64, "arm64", "AArch64", },
{ IH_ARCH_ARC, "arc", "ARC", },
+ { IH_ARCH_X86_64, "x86_64", "AMD x86_64", },
{ -1, "", "", },
};
diff --git a/common/lcd.c b/common/lcd.c
index 787d80e..37147af 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -881,7 +881,7 @@ static void lcd_display_rle8_bitmap(bmp_image_t *bmp, ushort *cmap, uchar *fb,
}
#endif
-#if defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
+#if defined(CONFIG_MPC823)
#define FB_PUT_BYTE(fb, from) *(fb)++ = (255 - *(from)++)
#else
#define FB_PUT_BYTE(fb, from) *(fb)++ = *(from)++
@@ -906,9 +906,7 @@ static inline void fb_put_word(uchar **fb, uchar **from)
int lcd_display_bitmap(ulong bmp_image, int x, int y)
{
-#if !defined(CONFIG_MCC200)
ushort *cmap = NULL;
-#endif
ushort *cmap_base = NULL;
ushort i, j;
uchar *fb;
@@ -956,8 +954,6 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
debug("Display-bmp: %d x %d with %d colors\n",
(int)width, (int)height, (int)colors);
-#if !defined(CONFIG_MCC200)
- /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
if (bmp_bpix == 8) {
cmap = configuration_get_cmap();
cmap_base = cmap;
@@ -985,24 +981,6 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
#endif
}
}
-#endif
- /*
- * BMP format for Monochrome assumes that the state of a
- * pixel is described on a per Bit basis, not per Byte.
- * So, in case of Monochrome BMP we should align widths
- * on a byte boundary and convert them from Bit to Byte
- * units.
- * Probably, PXA250 and MPC823 process 1bpp BMP images in
- * their own ways, so make the converting to be MCC200
- * specific.
- */
-#if defined(CONFIG_MCC200)
- if (bpix == 1) {
- width = ((width + 7) & ~7) >> 3;
- x = ((x + 7) & ~7) >> 3;
- pwidth= ((pwidth + 7) & ~7) >> 3;
- }
-#endif
padded_width = (width & 0x3 ? (width & ~0x3) + 4 : width);
diff --git a/common/stdio.c b/common/stdio.c
index 68c595d..adbfc89 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -197,6 +197,7 @@ int stdio_deregister_dev(struct stdio_dev *dev, int force)
}
list_del(&(dev->list));
+ free(dev);
/* reassign Device list */
list_for_each(pos, &(devs.list)) {
diff --git a/common/usb.c b/common/usb.c
index bd0f8d5..7d33a0f 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -927,7 +927,6 @@ int usb_new_device(struct usb_device *dev)
* thread_id=5729457&forum_id=5398
*/
__maybe_unused struct usb_device_descriptor *desc;
- int port = -1;
struct usb_device *parent = dev->parent;
unsigned short portstatus;
@@ -965,24 +964,10 @@ int usb_new_device(struct usb_device *dev)
#endif
if (parent) {
- int j;
-
- /* find the port number we're at */
- for (j = 0; j < parent->maxchild; j++) {
- if (parent->children[j] == dev) {
- port = j;
- break;
- }
- }
- if (port < 0) {
- printf("usb_new_device:cannot locate device's port.\n");
- return 1;
- }
-
/* reset the port for the second time */
- err = hub_port_reset(dev->parent, port, &portstatus);
+ err = hub_port_reset(dev->parent, dev->portnr - 1, &portstatus);
if (err < 0) {
- printf("\n Couldn't reset port %i\n", port);
+ printf("\n Couldn't reset port %i\n", dev->portnr);
return 1;
}
}
diff --git a/common/usb_hub.c b/common/usb_hub.c
index c416e5e..0f1eab4 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -86,50 +86,11 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
int i;
struct usb_device *dev;
unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2;
- ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1);
- unsigned short portstatus;
- int ret;
dev = hub->pusb_dev;
- /*
- * Enable power to the ports:
- * Here we Power-cycle the ports: aka,
- * turning them off and turning on again.
- */
debug("enabling power on all ports\n");
for (i = 0; i < dev->maxchild; i++) {
- usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);
- debug("port %d returns %lX\n", i + 1, dev->status);
- }
-
- /* Wait at least 2*bPwrOn2PwrGood for PP to change */
- mdelay(pgood_delay);
-
- for (i = 0; i < dev->maxchild; i++) {
- ret = usb_get_port_status(dev, i + 1, portsts);
- if (ret < 0) {
- debug("port %d: get_port_status failed\n", i + 1);
- continue;
- }
-
- /*
- * Check to confirm the state of Port Power:
- * xHCI says "After modifying PP, s/w shall read
- * PP and confirm that it has reached the desired state
- * before modifying it again, undefined behavior may occur
- * if this procedure is not followed".
- * EHCI doesn't say anything like this, but no harm in keeping
- * this.
- */
- portstatus = le16_to_cpu(portsts->wPortStatus);
- if (portstatus & (USB_PORT_STAT_POWER << 1)) {
- debug("port %d: Port power change failed\n", i + 1);
- continue;
- }
- }
-
- for (i = 0; i < dev->maxchild; i++) {
usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);
debug("port %d returns %lX\n", i + 1, dev->status);
}
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index fdc083c..bc7145e 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -99,6 +99,11 @@ static const unsigned char usb_kbd_arrow[] = {
#define USB_KBD_BOOT_REPORT_SIZE 8
struct usb_kbd_pdata {
+ unsigned long intpipe;
+ int intpktsize;
+ int intinterval;
+ struct int_queue *intq;
+
uint32_t repeat_delay;
uint32_t usb_in_pointer;
@@ -116,32 +121,6 @@ extern int __maybe_unused net_busy_flag;
/* The period of time between two calls of usb_kbd_testc(). */
static unsigned long __maybe_unused kbd_testc_tms;
-/* Generic keyboard event polling. */
-void usb_kbd_generic_poll(void)
-{
- struct stdio_dev *dev;
- struct usb_device *usb_kbd_dev;
- struct usb_kbd_pdata *data;
- struct usb_interface *iface;
- struct usb_endpoint_descriptor *ep;
- int pipe;
- int maxp;
-
- /* Get the pointer to USB Keyboard device pointer */
- dev = stdio_get_by_name(DEVNAME);
- usb_kbd_dev = (struct usb_device *)dev->priv;
- data = usb_kbd_dev->privptr;
- iface = &usb_kbd_dev->config.if_desc[0];
- ep = &iface->ep_desc[0];
- pipe = usb_rcvintpipe(usb_kbd_dev, ep->bEndpointAddress);
-
- /* Submit a interrupt transfer request */
- maxp = usb_maxpacket(usb_kbd_dev, pipe);
- usb_submit_int_msg(usb_kbd_dev, pipe, data->new,
- min(maxp, USB_KBD_BOOT_REPORT_SIZE),
- ep->bInterval);
-}
-
/* Puts character in the queue and sets up the in and out pointer. */
static void usb_kbd_put_queue(struct usb_kbd_pdata *data, char c)
{
@@ -331,23 +310,11 @@ static int usb_kbd_irq(struct usb_device *dev)
static inline void usb_kbd_poll_for_event(struct usb_device *dev)
{
#if defined(CONFIG_SYS_USB_EVENT_POLL)
- struct usb_interface *iface;
- struct usb_endpoint_descriptor *ep;
- struct usb_kbd_pdata *data;
- int pipe;
- int maxp;
-
- /* Get the pointer to USB Keyboard device pointer */
- data = dev->privptr;
- iface = &dev->config.if_desc[0];
- ep = &iface->ep_desc[0];
- pipe = usb_rcvintpipe(dev, ep->bEndpointAddress);
+ struct usb_kbd_pdata *data = dev->privptr;
/* Submit a interrupt transfer request */
- maxp = usb_maxpacket(dev, pipe);
- usb_submit_int_msg(dev, pipe, &data->new[0],
- min(maxp, USB_KBD_BOOT_REPORT_SIZE),
- ep->bInterval);
+ usb_submit_int_msg(dev, data->intpipe, &data->new[0], data->intpktsize,
+ data->intinterval);
usb_kbd_irq_worker(dev);
#elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP)
@@ -358,6 +325,15 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev)
1, 0, data->new, USB_KBD_BOOT_REPORT_SIZE);
if (memcmp(data->old, data->new, USB_KBD_BOOT_REPORT_SIZE))
usb_kbd_irq_worker(dev);
+#elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE)
+ struct usb_kbd_pdata *data = dev->privptr;
+ if (poll_int_queue(dev, data->intq)) {
+ usb_kbd_irq_worker(dev);
+ /* We've consumed all queued int packets, create new */
+ destroy_int_queue(dev, data->intq);
+ data->intq = create_int_queue(dev, data->intpipe, 1,
+ USB_KBD_BOOT_REPORT_SIZE, data->new);
+ }
#endif
}
@@ -415,7 +391,6 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
struct usb_interface *iface;
struct usb_endpoint_descriptor *ep;
struct usb_kbd_pdata *data;
- int pipe, maxp;
if (dev->descriptor.bNumConfigurations != 1)
return 0;
@@ -464,8 +439,10 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
/* Set IRQ handler */
dev->irq_handle = usb_kbd_irq;
- pipe = usb_rcvintpipe(dev, ep->bEndpointAddress);
- maxp = usb_maxpacket(dev, pipe);
+ data->intpipe = usb_rcvintpipe(dev, ep->bEndpointAddress);
+ data->intpktsize = min(usb_maxpacket(dev, data->intpipe),
+ USB_KBD_BOOT_REPORT_SIZE);
+ data->intinterval = ep->bInterval;
/* We found a USB Keyboard, install it. */
usb_set_protocol(dev, iface->desc.bInterfaceNumber, 0);
@@ -474,9 +451,14 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
usb_set_idle(dev, iface->desc.bInterfaceNumber, REPEAT_RATE, 0);
debug("USB KBD: enable interrupt pipe...\n");
- if (usb_submit_int_msg(dev, pipe, data->new,
- min(maxp, USB_KBD_BOOT_REPORT_SIZE),
- ep->bInterval) < 0) {
+#ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
+ data->intq = create_int_queue(dev, data->intpipe, 1,
+ USB_KBD_BOOT_REPORT_SIZE, data->new);
+ if (!data->intq) {
+#else
+ if (usb_submit_int_msg(dev, data->intpipe, data->new, data->intpktsize,
+ data->intinterval) < 0) {
+#endif
printf("Failed to get keyboard state from device %04x:%04x\n",
dev->descriptor.idVendor, dev->descriptor.idProduct);
/* Abort, we don't want to use that non-functional keyboard. */
@@ -550,9 +532,22 @@ int drv_usb_kbd_init(void)
int usb_kbd_deregister(int force)
{
#ifdef CONFIG_SYS_STDIO_DEREGISTER
- int ret = stdio_deregister(DEVNAME, force);
- if (ret && ret != -ENODEV)
- return ret;
+ struct stdio_dev *dev;
+ struct usb_device *usb_kbd_dev;
+ struct usb_kbd_pdata *data;
+
+ dev = stdio_get_by_name(DEVNAME);
+ if (dev) {
+ usb_kbd_dev = (struct usb_device *)dev->priv;
+ data = usb_kbd_dev->privptr;
+ if (stdio_deregister_dev(dev, force) != 0)
+ return 1;
+#ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
+ destroy_int_queue(usb_kbd_dev, data->intq);
+#endif
+ free(data->new);
+ free(data);
+ }
return 0;
#else
diff --git a/common/usb_storage.c b/common/usb_storage.c
index eb7706c..1411737 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -1351,8 +1351,11 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
perq = usb_stor_buf[0];
modi = usb_stor_buf[1];
- if ((perq & 0x1f) == 0x1f) {
- /* skip unknown devices */
+ /*
+ * Skip unknown devices (0x1f) and enclosure service devices (0x0d),
+ * they would not respond to test_unit_ready .
+ */
+ if (((perq & 0x1f) == 0x1f) || ((perq & 0x1f) == 0x0d)) {
return 0;
}
if ((modi&0x80) == 0x80) {