From owner-freebsd-arm@FreeBSD.ORG Mon Nov 20 22:04:05 2006 Return-Path: X-Original-To: freebsd-arm@freebsd.org Delivered-To: freebsd-arm@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F208016A416 for ; Mon, 20 Nov 2006 22:04:05 +0000 (UTC) (envelope-from Danovitsch@vitsch.net) Received: from amsfep12-int.chello.nl (amsfep17-int.chello.nl [213.46.243.15]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6CBE843D49 for ; Mon, 20 Nov 2006 22:03:44 +0000 (GMT) (envelope-from Danovitsch@vitsch.net) Received: from Tuinhuisje.Vitsch.net ([62.195.87.223]) by amsfep12-int.chello.nl (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20061120220401.UCYW1928.amsfep12-int.chello.nl@Tuinhuisje.Vitsch.net>; Mon, 20 Nov 2006 23:04:01 +0100 Received: from self (f23025.upc-f.chello.nl [80.56.23.25]) (authenticated bits=0) by Tuinhuisje.Vitsch.net (8.13.1/8.13.1) with ESMTP id kAKM3iOx061057; Mon, 20 Nov 2006 23:03:49 +0100 (CET) (envelope-from Danovitsch@vitsch.net) From: "Daan Vreeken [PA4DAN]" Organization: Vitsch Electronics To: "M. Warner Losh" Date: Mon, 20 Nov 2006 23:03:52 +0100 User-Agent: KMail/1.9.1 References: <7380637.post@talk.nabble.com> <20061116.093638.63053940.imp@bsdimp.com> In-Reply-To: <20061116.093638.63053940.imp@bsdimp.com> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_IZiYFkN+IcqicJ4" Message-Id: <200611202303.52817.Danovitsch@vitsch.net> Cc: freebsd-arm@freebsd.org Subject: Re: At91rm9200 how to start with FreeBSD X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Nov 2006 22:04:06 -0000 --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 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 #include #include +#include #include +#include #include #include #include @@ -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--