Skip to content

Instantly share code, notes, and snippets.

@notro
Last active December 26, 2015 01:19
Show Gist options
  • Save notro/7070491 to your computer and use it in GitHub Desktop.
Save notro/7070491 to your computer and use it in GitHub Desktop.
Tried to add USB with Device Tree. Didn't work. Memory region and IRQ is the same as with non-DT.
Boot messages using Device Tree
===============================
Uncompressing Linux... done, booting the kernel.
[ 0.000000] Linux version 3.10.12+ (pi@raspi1) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG 1.15.2) ) #86 Sun Oct 20 14:22:03 CEST 2013
[ 0.000000] Machine: BCM2708, model: v31 Raspberry Pi Model B
[ 0.182321] create child: /axi/usb
[ 0.182434] of_irq_map_one: dev=/axi/usb, index=0
[ 0.182472] intspec=2 intlen=2
[ 0.182505] intsize=2 intlen=2
[ 0.182534] of_irq_map_raw: par=/axi/interrupt-controller,intspec=[0x00000002 0x00000000...],ointsize=2
[ 0.182580] of_irq_map_raw: ipar=/axi/interrupt-controller, size=2
[ 0.182613] -> addrsize=1
[ 0.182635] -> got it !
[ 0.182659] irq_find_host(c0b93398)
[ 0.182686] h: da8b1b40, h->ops->match: (null)
[ 0.182716] irq: irq_create_mapping(0xda8b1b40, 0x20)
[ 0.182744] irq: -> using domain @da8b1b40
[ 0.182775] irq_domain_legacy_revmap(domain=da8b1b40, hwirq=32): first_hwirq=0, size=330
[ 0.182813] irq: -> existing mapping on virq 32
[ 0.182841] of_irq_map_one: dev=/axi/usb, index=1
[ 0.182869] intspec=2 intlen=2
[ 0.182898] intsize=2 intlen=2
[ 0.182942] of_irq_map_one: dev=/axi/usb, index=0
[ 0.182972] intspec=2 intlen=2
[ 0.183000] intsize=2 intlen=2
[ 0.183028] of_irq_map_raw: par=/axi/interrupt-controller,intspec=[0x00000002 0x00000000...],ointsize=2
[ 0.183072] of_irq_map_raw: ipar=/axi/interrupt-controller, size=2
[ 0.183104] -> addrsize=1
[ 0.183126] -> got it !
[ 0.183149] irq_find_host(c0b93398)
[ 0.183174] h: da8b1b40, h->ops->match: (null)
[ 0.183201] irq: irq_create_mapping(0xda8b1b40, 0x20)
[ 0.183228] irq: -> using domain @da8b1b40
[ 0.183258] irq_domain_legacy_revmap(domain=da8b1b40, hwirq=32): first_hwirq=0, size=330
[ 0.183296] irq: -> existing mapping on virq 32
[ 3.692740] usbcore: registered new interface driver usbfs
[ 3.698813] usbcore: registered new interface driver hub
[ 3.704882] usbcore: registered new device driver usb
[ 4.473446] pinctrl-bcm2708 20200000.gpio: read 00048024 (6 => gpio_out)
[ 5.239076] usbcore: registered new interface driver ax88179_178a
[ 5.247421] usbcore: registered new interface driver smsc95xx
[ 5.255391] usbcore: registered new interface driver cdc_ncm
[ 5.262567] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[ 5.269868] __request_region(parent=c068ce14, start=0x20980000, n=0x20000, name=dwc_otg, flags=0x0): res=da9ca7c0
[ 5.283047] __request_region(parent=c068ce14, start=0x20006000, n=0x1000, name=dwc_otg, flags=0x0): res=da9ca7e0
[ 5.496285] Core Release: 2.80a
[ 5.500894] Setting default values for core params
[ 5.507200] Finished setting default values for core params
[ 5.714371] Using Buffer DMA mode
[ 5.719202] Periodic Transfer Interrupt Enhancement - disabled
[ 5.726589] Multiprocessor Interrupt Enhancement - disabled
[ 5.733737] OTG VER PARAM: 0, OTG VER FLAG: 0
[ 5.739631] Dedicated Tx FIFOs mode
[ 5.745299] dwc_otg: Microframe scheduler enabled
[ 5.751856] dwc_otg 20980000.usb: DWC OTG Controller
[ 5.758332] dwc_otg 20980000.usb: new USB bus registered, assigned bus number 1
[ 5.767218] dwc_otg 20980000.usb: irq 32, io mem 0x00000000
[ 5.774292] Init: Port Power? op_state=1
[ 5.779589] Init: Power Port (0)
[ 5.784318] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 5.792653] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 5.801397] usb usb1: Product: DWC OTG Controller
[ 5.807534] usb usb1: Manufacturer: Linux 3.10.12+ dwc_otg_hcd
[ 5.814803] usb usb1: SerialNumber: 20980000.usb
[ 5.822730] hub 1-0:1.0: USB hub found
[ 5.827914] hub 1-0:1.0: 1 port detected
[ 5.834099] dwc_otg: FIQ enabled
[ 5.838681] dwc_otg: NAK holdoff enabled
[ 5.843919] dwc_otg: FIQ split fix enabled
[ 5.849260] Module dwc_common_port init
[ 5.855302] usbcore: registered new interface driver usb-storage
[ 6.087344] Indeed it is in host mode hprt0 = 00021501
[ 6.335915] usb 1-1: new high-speed USB device number 2 using dwc_otg
[ 6.485177] Indeed it is in host mode hprt0 = 00001101
[ 6.615046] usbcore: registered new interface driver usbhid
[ 6.622272] usbhid: USB HID core driver
[ 6.677214] usb 1-1: device descriptor read/64, error -32
[ 6.806050] Indeed it is in host mode hprt0 = 00001101
[ 6.991058] usb 1-1: device descriptor read/64, error -32
[ 7.101151] Indeed it is in host mode hprt0 = 00001101
[ 7.281196] usb 1-1: new high-speed USB device number 3 using dwc_otg
[ 7.290143] Indeed it is in host mode hprt0 = 00001101
[ 7.471062] usb 1-1: device descriptor read/64, error -32
[ 7.581606] Indeed it is in host mode hprt0 = 00001101
[ 7.761178] usb 1-1: device descriptor read/64, error -32
[ 7.871146] Indeed it is in host mode hprt0 = 00001101
[ 8.051092] usb 1-1: new high-speed USB device number 4 using dwc_otg
[ 8.481200] usb 1-1: device not accepting address 4, error -32
[ 8.488977] Indeed it is in host mode hprt0 = 00001101
[ 8.671151] usb 1-1: new high-speed USB device number 5 using dwc_otg
[ 9.101194] usb 1-1: device not accepting address 5, error -32
[ 9.108944] hub 1-0:1.0: unable to enumerate USB device on port 1
Boot messages non-DT
====================
Uncompressing Linux... done, booting the kernel.
[ 0.000000] Linux version 3.10.12+ (pi@raspi1) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG 1.15.2) ) #85 Sat Oct 19 19:49:42 CEST 2013
[ 0.000000] Machine: BCM2708, model: v31 Raspberry Pi Model B
[ 3.571956] usbcore: registered new interface driver usbfs
[ 3.578092] usbcore: registered new interface driver hub
[ 3.584119] usbcore: registered new device driver usb
[ 5.105905] usbcore: registered new interface driver ax88179_178a
[ 5.114270] usbcore: registered new interface driver smsc95xx
[ 5.122234] usbcore: registered new interface driver cdc_ncm
[ 5.129343] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[ 5.136643] __request_region(parent=c068ce14, start=0x20980000, n=0x20000, name=dwc_otg, flags=0x0): res=da9ca7c0
[ 5.149828] __request_region(parent=c068ce14, start=0x20006000, n=0x1000, name=dwc_otg, flags=0x0): res=da9ca7e0
[ 5.363067] Core Release: 2.80a
[ 5.367676] Setting default values for core params
[ 5.373980] Finished setting default values for core params
[ 5.581193] Using Buffer DMA mode
[ 5.586023] Periodic Transfer Interrupt Enhancement - disabled
[ 5.593408] Multiprocessor Interrupt Enhancement - disabled
[ 5.600552] OTG VER PARAM: 0, OTG VER FLAG: 0
[ 5.606445] Dedicated Tx FIFOs mode
[ 5.612124] dwc_otg: Microframe scheduler enabled
[ 5.618603] dwc_otg bcm2708_usb: DWC OTG Controller
[ 5.625098] dwc_otg bcm2708_usb: new USB bus registered, assigned bus number 1
[ 5.633907] dwc_otg bcm2708_usb: irq 32, io mem 0x00000000
[ 5.640888] Init: Port Power? op_state=1
[ 5.646182] Init: Power Port (0)
[ 5.650917] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 5.659196] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 5.667922] usb usb1: Product: DWC OTG Controller
[ 5.674107] usb usb1: Manufacturer: Linux 3.10.12+ dwc_otg_hcd
[ 5.681389] usb usb1: SerialNumber: bcm2708_usb
[ 5.689201] hub 1-0:1.0: USB hub found
[ 5.694455] hub 1-0:1.0: 1 port detected
[ 5.700678] dwc_otg: FIQ enabled
[ 5.705261] dwc_otg: NAK holdoff enabled
[ 5.710482] dwc_otg: FIQ split fix enabled
[ 5.715820] Module dwc_common_port init
[ 5.721861] usbcore: registered new interface driver usb-storage
[ 6.160286] usb 1-1: new high-speed USB device number 2 using dwc_otg
[ 6.399334] hidraw: raw HID events driver (C) Jiri Kosina
[ 6.407817] usbcore: registered new interface driver usbhid
[ 6.415020] usbhid: USB HID core driver
[ 6.526503] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
[ 6.534894] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 6.594355] hub 1-1:1.0: USB hub found
[ 6.599946] hub 1-1:1.0: 5 ports detected
[ 6.910477] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[ 7.031463] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[ 7.040020] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 7.053963] smsc95xx v1.0.4
[ 7.130726] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:39:78:8f
diff --git a/drivers/usb/host/dwc_otg/dwc_otg_driver.c b/drivers/usb/host/dwc_otg/dwc_otg_driver.c
index 4735f51..87f3290 100644
--- a/drivers/usb/host/dwc_otg/dwc_otg_driver.c
+++ b/drivers/usb/host/dwc_otg/dwc_otg_driver.c
@@ -48,6 +49,7 @@
* device.
*/
+#include <linux/of_device.h>
#include "dwc_otg_os_dep.h"
#include "dwc_os.h"
#include "dwc_otg_dbg.h"
@@ -1034,6 +1037,14 @@ static struct pci_driver dwc_otg_driver = {
},
};
#elif defined(PLATFORM_INTERFACE)
+static const struct of_device_id dwc_otg_match[] = {
+ {
+ .compatible = "snps,dwc",
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(of, dwc_otg_match);
+
static struct platform_device_id platform_ids[] = {
{
.name = "bcm2708_usb",
@@ -1046,6 +1057,7 @@ MODULE_DEVICE_TABLE(platform, platform_ids);
static struct platform_driver dwc_otg_driver = {
.driver = {
.name = (char *)dwc_driver_name,
+ .of_match_table = dwc_otg_match,
},
.id_table = platform_ids,
usb {
compatible = "brcm,bcm2835-usb", "snps,dwc";
reg = <0x7e980000 0x20000>, <0x7e006000 0x1000>;
interrupts = <2 0>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment