Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Nov 2006 23:03:52 +0100
From:      "Daan Vreeken [PA4DAN]" <Danovitsch@vitsch.net>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        freebsd-arm@freebsd.org
Subject:   Re: At91rm9200 how to start with FreeBSD
Message-ID:  <200611202303.52817.Danovitsch@vitsch.net>
In-Reply-To: <20061116.093638.63053940.imp@bsdimp.com>
References:  <7380637.post@talk.nabble.com> <20061116.093638.63053940.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--Boundary-00=_IZiYFkN+IcqicJ4
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi Warner (and the list),

On Thursday 16 November 2006 17:36, M. Warner Losh wrote:
> In message: <7380637.post@talk.nabble.com>
>
>             Zuy <zaitsevbros@mail.ru> writes:
> : How I'm soldering board based on AT91RM9200 with 16mb SDRAM and othe
> : standartpPeripherals(USB, SD, UART ...). I'm going to run FreeBSD on this
> : board, but unfortunately I do not know how to start.
> : I havn't found any files connected with AT91RM9200 in FreeBSD6.0 Stable
> : source files directory.
> : I found from this board that freebsd works on at91rm9200.
>
> Yes.  It does.  FreeBSD-current has the most up to date tested code
> for this platform.  FreeBSD 6.2 will contain the tools you need to
> build it, as well as a slightly less advanced version (the freeze date
> for 6.2 was a while ago).  6.3 is likely to have even more advanced
> support.
...
> Here's the broad outlines.

... followed by a very nice ARM-introduction :) ...

> Feel free to ask questions.  the more people that ask, the bigger my
> collection of email on the topic gets, and the easier it will be for
> me to synthesize a tutorial.  Also, if there are areas that I've been
> vague, please don't hesitate to let me know.

This email got me to dust-off the KB9202B board my company bought a while back 
for a project that hasn't started (yet). With your email it was quite easy to 
get the board to work. I now use the original Kwikbyte boot loader to load 
the kernel with tftp. After that the kernel mounts root over NFS and 
everything works like a charm.
If I am going to use this board in the project it was intended for, we will 
need USB support, so I took a shot at getting USB working...

o updated hints.at91rm9200 (ohci controller is on ASB)


crash in usbd_transfer() because of missing device->bus->buffer_dmatag

o allocate dma tags in ohci_atmelarm_attach()
  (inspired by ohci_pci.c)
o destroy dma tags in ohc_atmelarm_detach()


--Boundary-00=_IZiYFkN+IcqicJ4
Content-Type: text/plain; charset="iso-8859-1"; name="daan_usb_patch.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="daan_usb_patch.diff"

--- sys/arm/at91/ohci_atmelarm.c.org	Mon Nov 20 16:32:05 2006
+++ sys/arm/at91/ohci_atmelarm.c	Mon Nov 20 17:45:03 2006
@@ -28,7 +28,9 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
+#include <sys/lock.h>
 #include <sys/module.h>
+#include <sys/mutex.h>
 #include <sys/bus.h>
 #include <sys/queue.h>
 #include <machine/bus.h>
@@ -99,6 +101,30 @@
 	}
 	device_set_ivars(sc->sc_ohci.sc_bus.bdev, &sc->sc_ohci.sc_bus);
 
+	/* Allocate a parent dma tag for DMA maps */
+	err = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0,
+	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+	    BUS_SPACE_MAXSIZE_32BIT, USB_DMA_NSEG, BUS_SPACE_MAXSIZE_32BIT, 0,
+	    NULL, NULL, &sc->sc_ohci.sc_bus.parent_dmatag);
+	if (err) {
+		device_printf(dev, "Could not allocate parent DMA tag (%d)\n",
+		    err);
+		err = ENXIO;
+		goto error;
+	}
+
+	/* Allocate a dma tag for transfer buffers */
+	err = bus_dma_tag_create(sc->sc_ohci.sc_bus.parent_dmatag, 1, 0,
+	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+	    BUS_SPACE_MAXSIZE_32BIT, USB_DMA_NSEG, BUS_SPACE_MAXSIZE_32BIT, 0,
+	    busdma_lock_mutex, &Giant, &sc->sc_ohci.sc_bus.buffer_dmatag);
+	if (err) {
+		device_printf(dev, "Could not allocate transfer tag (%d)\n",
+		    err);
+		err = ENXIO;
+		goto error;
+	}
+
 	err = bus_setup_intr(dev, sc->sc_ohci.irq_res, INTR_TYPE_BIO, ohci_intr, sc,
 	    &sc->sc_ohci.ih);
 	if (err) {
@@ -158,6 +184,12 @@
 		bus_teardown_intr(dev, sc->sc_ohci.irq_res, sc->sc_ohci.ih);
 		sc->sc_ohci.ih = NULL;
 	}
+
+	if (sc->sc_ohci.sc_bus.parent_dmatag != NULL)
+		bus_dma_tag_destroy(sc->sc_ohci.sc_bus.parent_dmatag);
+	if (sc->sc_ohci.sc_bus.buffer_dmatag != NULL)
+		bus_dma_tag_destroy(sc->sc_ohci.sc_bus.buffer_dmatag);
+
 	if (sc->sc_ohci.sc_bus.bdev) {
 		device_delete_child(dev, sc->sc_ohci.sc_bus.bdev);
 		sc->sc_ohci.sc_bus.bdev = NULL;
--- sys/arm/at91/kb920x_machdep.c.org	Mon Nov 20 16:24:03 2006
+++ sys/arm/at91/kb920x_machdep.c	Mon Nov 20 19:08:39 2006
@@ -167,14 +167,14 @@
 	 * initialization is done. However, the AT91 resource allocation
 	 * system doesn't know how to use pmap_mapdev() yet.
 	 */
-#if 0
+#if 1
 	{
 		/*
 		 * Add the ohci controller, and anything else that might be
 		 * on this chip select for a VA/PA mapping.
 		 */
 		AT91RM92_OHCI_BASE,
-		AT91RM92_OHCI_BASE,
+		AT91RM92_OHCI_PA_BASE,
 		AT91RM92_OHCI_SIZE,
 		VM_PROT_READ|VM_PROT_WRITE,                             
 		PTE_NOCACHE,
--- sys/arm/at91/hints.at91rm9200.org	Mon Nov 20 16:33:33 2006
+++ sys/arm/at91/hints.at91rm9200	Mon Nov 20 22:29:20 2006
@@ -64,5 +64,5 @@
 
 # USB host (ohci)
 #??? maybe this needs to be on asb instead of apb
-hint.ohci.at="apb"
+hint.ohci.at="asb"
 hint.ohci.maddr="0x00300000"
--- sys/arm/at91/at91rm92reg.h.org	Mon Nov 20 22:52:56 2006
+++ sys/arm/at91/at91rm92reg.h	Mon Nov 20 19:13:26 2006
@@ -337,6 +337,7 @@
 #define AT91RM92_TC1C2_BASE	0xffa4080
 
 #define AT91RM92_OHCI_BASE	0xdfe00000
+#define AT91RM92_OHCI_PA_BASE	0x00300000
 #define AT91RM92_OHCI_SIZE	0x00100000
 
 #define AT91C_MASTER_CLOCK	60000000
--- sys/arm/conf/KB920X.org	Fri Nov 17 16:06:37 2006
+++ sys/arm/conf/KB920X	Mon Nov 20 22:05:16 2006
@@ -82,3 +82,18 @@
 # device	at91_twi		# TWI: Two Wire Interface
 device		at91_spi		# SPI:
 device		spibus
+
+
+device		usb
+device		ohci
+
+#device		ugen
+
+#device		scbus
+#device		da
+#device		umass
+
+device		axe
+#device		bpf
+
+

--Boundary-00=_IZiYFkN+IcqicJ4--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611202303.52817.Danovitsch>