USB: make usb_kbd obey USB DMA alignment requirements
PATCH 1/2 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.
--- common/usb_kbd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
common/usb_kbd.c +5 -4
@@ -28,6 +28,7 @@#include <malloc.h> #include <stdio_dev.h> #include <asm/byteorder.h> +#include <linux/compiler.h> #include <usb.h>
@@ -106,17 +107,17 @@ static const unsigned char usb_kbd_num_keypad[] = { (USB_KBD_NUMLOCK | USB_KBD_CAPSLOCK | USB_KBD_SCROLLLOCK)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; -}; +}__aligned(USB_DMA_MINALIGN) ;/* Generic keyboard event polling. */ void usb_kbd_generic_poll (void )
Signature · 1 line
1.7.10.4
PATCH 2/2 tegra: seaboard: Enable USB keyboard
Enable USB keyboard for the springbank variant of seaboard
--- include/configs/seaboard.h | 5 ++++- include/configs/tegra20-common.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-)
include/configs/seaboard.h +4 -1
@@ -33,6 +33,9 @@#define CONFIG_TPS6586X_POWER #define CONFIG_TEGRA_CLOCK_SCALING +/* Enable USB keyboard */ +#define CONFIG_USB_KEYBOARD +#include "tegra20-common.h" /* Enable fdt support for Seaboard. Flash the image in u-boot-dtb.bin */
@@ -99,7 +102,7 @@#define CONFIG_KEYBOARD #undef TEGRA_DEVICE_SETTINGS -#define TEGRA_DEVICE_SETTINGS "stdin=serial,tegra-kbc\0" \ +#define TEGRA_DEVICE_SETTINGS "stdin=serial,tegra-kbc,usbkbd\0" \ "stdout=serial\0" \ "stderr=serial\0"
include/configs/tegra20-common.h +5 -0
@@ -102,6 +102,11 @@#define CONFIG_EHCI_IS_TDI #define CONFIG_EHCI_DCACHE +#ifdef CONFIG_USB_KEYBOARD +#define CONFIG_SYS_USB_EVENT_POLL +#define CONFIG_PREBOOT "usb start" +#endif /* CONFIG_USB_KEYBOARD */ +/* Total I2C ports on Tegra20 */ #define TEGRA_I2C_NUM_CONTROLLERS 4
Signature · 1 line
1.7.10.4
PATCH 2/2 tegra: seaboard: Enable USB keyboard
Quoted 1 line · Allen Martin
Enable USB keyboard for the springbank variant of seaboard
This sounds nice!
include/configs/seaboard.h line 107
Quoted 7 lines
include/configs/seaboard.h +1
-1#undef TEGRA_DEVICE_SETTINGS -#define TEGRA_DEVICE_SETTINGS "stdin=serial,tegra-kbc\0" \ +#define TEGRA_DEVICE_SETTINGS "stdin=serial,tegra-kbc,usbkbd\0" \ "stdout=serial\0" \ "stderr=serial\0"
Rather than duplicating this everywhere (and I imagine now that this support works, most Tegra boards will want to turn on USB keyboard), can't we do something automatic in tegra-common-post.h, like:
#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"
#else
#define STDIN_KBD_USB ""
#endif
#define TEGRA_DEVICE_SETTINGS \ "stdin=serial" STDIN_KBD_KBC STDIN_KBD_USB "\" \ ...
By the way, does tegra-kbc work now/yet? The last time I tried it, I don't think it did.
include/configs/tegra20-common.h line 108
Quoted 6 lines
include/configs/tegra20-common.h +4
-0+#ifdef CONFIG_USB_KEYBOARD +#define CONFIG_SYS_USB_EVENT_POLL +#define CONFIG_PREBOOT "usb start" +#endif /* CONFIG_USB_KEYBOARD */
Similarly, we could also e.g. turn on CONFIG_KEYBOARD whenever CONFIG_TEGRA_KEYBOARD is turned on, and perhaps a bunch of other similar things, like moving much of the partition/filesystem/command/... support into the Tegra common files. That would be something for another patch though.
PATCH 1/2 USB: make usb_kbd obey USB DMA alignment requirements
In reply to Allen MartinQuoted 12 lines · Allen Martin
Change
usb_kbddriver 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.common/usb_kbd.c +3
-0struct usb_kbd_pdata { +uint8_t new[8 ]; +uint8_t old[8 ]; +uint32_t repeat_delay;
common/usb_kbd.c static const unsigned char usb_kbd_num_keypad[] = { · line 120
Quoted 10 lines
common/usb_kbd.c +1
-4uint32_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; -}; +}__aligned(USB_DMA_MINALIGN) ;
Surely you need to edit the malloc() call in usb_kbd_probe() instead of adding __aligned to the type; does the alignment on the type really get propagated into malloc(), or as custom code at the call-site somehow?
PATCH 1/2 USB: make usb_kbd obey USB DMA alignment requirements
Quoted 17 lines · Stephen Warren
Quoted 16 lines · Allen Martin
Change
usb_kbddriver 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.common/usb_kbd.c +3
-0struct 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 ];
Quoted 10 lines
common/usb_kbd.c static const unsigned char usb_kbd_num_keypad[] = { · line 120
Quoted 6 lines
common/usb_kbd.c +1
-4-uint8_t new[8 ]; -uint8_t old[8 ]; -uint8_t flags; -}; +}__aligned(USB_DMA_MINALIGN) ;Surely you need to edit the
malloc()call inusb_kbd_probe()instead of adding__alignedto the type; does the alignment on the type really get propagated intomalloc(), or as custom code at the call-site somehow?
Yes, you're right. I misread the code and thought it came from a static allocation. I got reassured when I added the change and the cache flush alignment warnings went away, but I guess these alignment things are always a crapshoot anyway.
I'll fix, thanks for finding that.
-Allen
Signature · 1 line
nvpublic
PATCH 2/2 tegra: seaboard: Enable USB keyboard
In reply to Stephen WarrenQuoted 29 lines · Stephen Warren
Quoted 1 line · Allen Martin
Enable USB keyboard for the springbank variant of seaboard
This sounds nice!
include/configs/seaboard.h line 107
Quoted 7 lines
include/configs/seaboard.h +1
-1#undef TEGRA_DEVICE_SETTINGS -#define TEGRA_DEVICE_SETTINGS "stdin=serial,tegra-kbc\0" \ +#define TEGRA_DEVICE_SETTINGS "stdin=serial,tegra-kbc,usbkbd\0" \ "stdout=serial\0" \ "stderr=serial\0"Rather than duplicating this everywhere (and I imagine now that this support works, most Tegra boards will want to turn on USB keyboard), can't we do something automatic in
tegra-common-post.h, like:#ifdef
CONFIG_TEGRA_KEYBOARD
#defineSTDIN_KBD_KBC",tegra-kbc"
#else
#defineSTDIN_KBD_KBC""
#endif#ifdef
CONFIG_USB_KEYBOARD
#defineSTDIN_KBD_USB",usbkbd"
#else
#defineSTDIN_KBD_USB""
#endif
Quoted 3 lines
#define TEGRA_DEVICE_SETTINGS \ "stdin=serial" STDIN_KBD_KBC STDIN_KBD_USB "\" \ ...
The only issue I see with that is TEGRA_DEVICE_SETTINGS can be used by boards today to add additional environment as well as override stdin/stdout/stderr. I don't think any boards actually do though, so we could just make a TEGRA_EXTRA_DEVICE_SETTINGS if that need comes up.
We might as well just put this directly in CONFIG_EXTRA_ENV_SETTINGS because if TEGRA_DEVICE_SETTINGS is private to tegra-common-post.h there's really no reason for it to exist.
Quoted 3 lines
By the way, does tegra-kbc work now/yet? The last time I tried it, I don't think it did.
It was working at one point, but I haven't tried it recently.
Quoted 13 lines
include/configs/tegra20-common.h line 108
Quoted 7 lines
include/configs/tegra20-common.h +4
-0+#ifdef CONFIG_USB_KEYBOARD +#define CONFIG_SYS_USB_EVENT_POLL +#define CONFIG_PREBOOT "usb start" +#endif /* CONFIG_USB_KEYBOARD */ Similarly, we could also e.g. turn on
CONFIG_KEYBOARDwheneverCONFIG_TEGRA_KEYBOARDis turned on, and perhaps a bunch of other similar things, like moving much of the partition/filesystem/command/... support into the Tegra common files. That would be something for another patch though.
Sure, looks like there's pleny of room for commonizing more stuff from the board confgs and triggering off tegra feature defines like CONFIG_TEGRA_I2C, CONFIG_TEGRA_MMC, CONFIG_USB_EHCI_TEGRA, CONFIG_TEGRA_KEYBOARD.
I'll look at making a separate patch for that.
-Allen
Signature · 1 line
nvpublic
PATCH 2/2 tegra: seaboard: Enable USB keyboard
Quoted 34 lines · Allen Martin
Quoted 29 lines · Stephen Warren
Quoted 1 line · Allen Martin
Enable USB keyboard for the springbank variant of seaboard
This sounds nice!
include/configs/seaboard.h line 107
Quoted 7 lines
include/configs/seaboard.h +1
-1#undef TEGRA_DEVICE_SETTINGS -#define TEGRA_DEVICE_SETTINGS "stdin=serial,tegra-kbc\0" \ +#define TEGRA_DEVICE_SETTINGS "stdin=serial,tegra-kbc,usbkbd\0" \ "stdout=serial\0" \ "stderr=serial\0"Rather than duplicating this everywhere (and I imagine now that this support works, most Tegra boards will want to turn on USB keyboard), can't we do something automatic in
tegra-common-post.h, like:#ifdef
CONFIG_TEGRA_KEYBOARD
#defineSTDIN_KBD_KBC",tegra-kbc"
#else
#defineSTDIN_KBD_KBC""
#endif#ifdef
CONFIG_USB_KEYBOARD
#defineSTDIN_KBD_USB",usbkbd"
#else
#defineSTDIN_KBD_USB""
#endifQuoted 3 lines
#define TEGRA_DEVICE_SETTINGS \ "stdin=serial" STDIN_KBD_KBC STDIN_KBD_USB "\" \ ...
Quoted 5 lines
The only issue I see with that is
TEGRA_DEVICE_SETTINGScan be used by boards today to add additional environment as well as override stdin/stdout/stderr. I don't think any boards actually do though, so we could just make aTEGRA_EXTRA_DEVICE_SETTINGSif that need comes up.
The common file could always only #define TEGRA_DEVICE_SETTINGS if the board didn't already define a custom version.
Quoted 3 lines
We might as well just put this directly in
CONFIG_EXTRA_ENV_SETTINGSbecause ifTEGRA_DEVICE_SETTINGSis private totegra-common-post.hthere's really no reason for it to exist.
It may be useful to keep it; I separated out MEM_LAYOUT_ENV_SETTINGS and BOOTCMDS_COMMON for example just so that EXTRA_ENV_SETTINGS could be built out of a few smaller and hence more manageable pieces.