[U-Boot] [PATCH v3 1/3] USB: make usb_kbd obey USB DMA alignment requirements

Allen Martin amartin at nvidia.com
Tue Oct 23 23:37:52 CEST 2012


Change usb_kbd driver to obey alignment requirements for USB DMA on
the buffer used for data transfer.  This is necessary for
architectures that enable dcache and enable USB DMA.

Signed-off-by: Allen Martin <amartin at nvidia.com>
Tested-by: Stephen Warren <swarren at nvidia.com>
---
v3: add comment about alignemnt requirement
v2: use memalign instead of __align()
---
 common/usb_kbd.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 19f01db..be5e8bc 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -105,16 +105,20 @@ static const unsigned char usb_kbd_num_keypad[] = {
 #define USB_KBD_LEDMASK		\
 	(USB_KBD_NUMLOCK | USB_KBD_CAPSLOCK | USB_KBD_SCROLLLOCK)
 
+/*
+ * This structure must be aligned to USB_DMA_MINALIGN to allow DMA to
+ * buffer "new" below.
+ */
 struct usb_kbd_pdata {
+	uint8_t		new[8];
+	uint8_t		old[8];
+
 	uint32_t	repeat_delay;
 
 	uint32_t	usb_in_pointer;
 	uint32_t	usb_out_pointer;
 	uint8_t		usb_kbd_buffer[USB_KBD_BUFFER_LEN];
 
-	uint8_t		new[8];
-	uint8_t		old[8];
-
 	uint8_t		flags;
 };
 
@@ -426,7 +430,7 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
 
 	USB_KBD_PRINTF("USB KBD: found set protocol...\n");
 
-	data = malloc(sizeof(struct usb_kbd_pdata));
+	data = memalign(USB_DMA_MINALIGN, sizeof(struct usb_kbd_pdata));
 	if (!data) {
 		printf("USB KBD: Error allocating private data\n");
 		return 0;
-- 
1.7.10.4



More information about the U-Boot mailing list