Skip to contentSkip to conversation

USB: make usb_kbd obey USB DMA alignment requirements

PATCH New Allen Martin 2 participants 4 messages Oct 24, 2012 Tegra architecture support

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/3 USB: make usb_kbd obey USB DMA alignment requirements

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.

---
v4: dynamically allocate xfer buffer, add alignment and roundup to buffer
instead of entire pdata struct
v3: add comment about alignemnt requirement
v2: use memalign instead of __align()

---
 common/usb_kbd.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
common/usb_kbd.c +4 -1
index 19f01db..24467ce 100644
@@ -112,7 +112,7 @@ struct usb_kbd_pdata {
 	uint32_t	usb_out_pointer;
 	uint8_t		usb_kbd_buffer[USB_KBD_BUFFER_LEN];
 
-	uint8_t		new[8];
+	uint8_t		*new;
 	uint8_t		old[8];
 
 	uint8_t		flags;
@@ -435,6 +435,9 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
 	/* Clear private data */
 	memset(data, 0, sizeof(struct usb_kbd_pdata));
 
+	/* allocate input buffer aligned and sized to USB DMA alignment */
+	data->new = memalign(USB_DMA_MINALIGN, roundup(8, USB_DMA_MINALIGN));
+
 	/* Insert private data into USB device structure */
 	dev->privptr = data;
 
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v4 2/3 tegra: move TEGRA_DEVICE_SETTINGS to tegra-common-post.h

Move environment settings for stdin/stdout/stderr to tegra-common-post.h and generate them automaticaly based on input device selection.

---
v4: no changes
v3: no changes
v2: new patch

---
 include/configs/seaboard.h          |    5 -----
 include/configs/tegra-common-post.h |   19 +++++++++++++++++++
 include/configs/tegra20-common.h    |    4 ----
 3 files changed, 19 insertions(+), 9 deletions(-)
include/configs/seaboard.h +0 -5
index 0727a4c..2cb3ac9 100644
@@ -98,11 +98,6 @@
 #define CONFIG_TEGRA_KEYBOARD
 #define CONFIG_KEYBOARD
 
-#undef TEGRA_DEVICE_SETTINGS
-#define TEGRA_DEVICE_SETTINGS	"stdin=serial,tegra-kbc\0" \
-				"stdout=serial\0" \
-				"stderr=serial\0"
-
 #include "tegra-common-post.h"
 
 /* NAND support */
include/configs/tegra-common-post.h +19 -0
index 9698c23..8d21d9c 100644
@@ -140,6 +140,25 @@
 
 #endif
 
+#ifdef CONFIG_TEGRA_KEYBOARD
+#define STDIN_KBD_KBC ",tegra-kbc"
+#else
+#define STDIN_KBD_KBC ""
+#endif
+
+#ifdef CONFIG_USB_KEYBOARD
+#define STDIN_KBD_USB ",usbkbd"
+#define CONFIG_SYS_USB_EVENT_POLL
+#define CONFIG_PREBOOT			"usb start"
+#else
+#define STDIN_KBD_USB ""
+#endif
+
+#define TEGRA_DEVICE_SETTINGS \
+	"stdin=serial" STDIN_KBD_KBC STDIN_KBD_USB "\0" \
+	"stdout=serial\0" \
+	"stderr=serial\0" \
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	TEGRA_DEVICE_SETTINGS \
 	"fdt_load=0x01000000\0" \
include/configs/tegra20-common.h +0 -4
index 9d532f4..c3bd7ca 100644
@@ -124,12 +124,8 @@
 
 #define CONFIG_SYS_NO_FLASH
 
-/* Environment information, boards can override if required */
 #define CONFIG_CONSOLE_MUX
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
-#define TEGRA_DEVICE_SETTINGS	"stdin=serial\0" \
-				"stdout=serial\0" \
-				"stderr=serial\0"
 
 #define CONFIG_LOADADDR		0x408000	/* def. location for kernel */
 #define CONFIG_BOOTDELAY	2		/* -1 to disable auto boot */
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v4 3/3 tegra: Enable USB keyboard

In reply to Allen Martin

Enable USB keyboard for seaboard and ventana

---
v4: no changes
v3: no changes
v2: added ventana

---
 include/configs/seaboard.h |    3 +++
 include/configs/ventana.h  |    3 +++
 2 files changed, 6 insertions(+)
include/configs/seaboard.h +3 -0
index 2cb3ac9..332970c 100644
@@ -98,6 +98,9 @@
 #define CONFIG_TEGRA_KEYBOARD
 #define CONFIG_KEYBOARD
 
+/* USB keyboard */
+#define CONFIG_USB_KEYBOARD
+
 #include "tegra-common-post.h"
 
 /* NAND support */
include/configs/ventana.h +3 -0
index b751d58..4c9b31c 100644
@@ -75,6 +75,9 @@
 #define CONFIG_CMD_NET
 #define CONFIG_CMD_DHCP
 
+/* USB keyboard */
+#define CONFIG_USB_KEYBOARD
+
 #include "tegra-common-post.h"
 
 #endif /* __CONFIG_H */
Signature · 1 line
1.7.10.4