From owner-freebsd-arm@FreeBSD.ORG Sun Aug 25 14:14:05 2013 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E0F43746 for ; Sun, 25 Aug 2013 14:14:04 +0000 (UTC) (envelope-from fabiodive@gmail.com) Received: from mail-ee0-x22f.google.com (mail-ee0-x22f.google.com [IPv6:2a00:1450:4013:c00::22f]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 742112F83 for ; Sun, 25 Aug 2013 14:14:04 +0000 (UTC) Received: by mail-ee0-f47.google.com with SMTP id d49so1114041eek.6 for ; Sun, 25 Aug 2013 07:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=t8/2snbkfGvBS9o9SYl7A9j3StsDuMvffOXat4HBZKs=; b=zg34gx5nyVcFPQmYaecoH0HClwAnT2eQNCSwkY05G860GvoPwfB+xQ41gMD2d3mnOy EUEAUSqUurUYpF06RMglIaXA1ryNKtI8UCYBCE+OnhbwwWKAiX8HqUv06QGa/IRWFQts UMpKM8+iI0+xK/Mx3qDWUmxImqLqBH4DBXP7WRaRketMJ6kutFceoMqJemTWAkrlxMj5 oNKuQ5O4t1eNgcW5P5Yl08QYL1dgRNCi+brp9507FmmQ+ydbXTdgzrtFUYMrgmxr4NZp j2qYkMfrpssyhMZry+FCZIIML/Zzmgu6c2sGSQg/xQ3lpIZmL4SWL3nqGSFRYkT/R35B 7mvA== X-Received: by 10.14.88.65 with SMTP id z41mr17007753eee.38.1377440041083; Sun, 25 Aug 2013 07:14:01 -0700 (PDT) Received: from [192.168.113.40] (135.Red-80-24-42.staticIP.rima-tde.net. [80.24.42.135]) by mx.google.com with ESMTPSA id z12sm14267281eev.6.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 25 Aug 2013 07:14:00 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: SPI driver for RPi From: fabiodive In-Reply-To: <126AAEEA-1F99-42E4-9620-9CB4F3610671@gmail.com> Date: Sun, 25 Aug 2013 15:13:58 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <8EC76E61-99BF-40E6-A39F-3E03FBDC1F30@gmail.com> References: <126AAEEA-1F99-42E4-9620-9CB4F3610671@gmail.com> To: Luiz Otavio O Souza X-Mailer: Apple Mail (2.1508) Cc: freebsd-arm@freebsd.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2013 14:14:05 -0000 pardon=85the autocorrector=85 should I use "device spi"=20 thank you f. On Aug 22, 2013, at 2:57 PM, Luiz Otavio O Souza = wrote: > Hello, >=20 > Here is a SPI driver for RPi. >=20 > It has been tested with a hardware loopback (MOSI wired to MISO) and = with a s25fl032 spansion flash (removed from a wr941nd router). >=20 > I've tested the reading from the flash up to 10Mhz of clock and = surprisingly my (simple) wiring support it without any fail. >=20 > At boot the SPI clock is set to 500Khz, not fast and not too slow (as = the 3.814Khz default): >=20 > # dd if=3D/dev/flash/spi0 of=3Dflash-wr941nd-2 bs=3D64k > 64+0 records in > 64+0 records out > 4194304 bytes transferred in 75.632316 secs (55457 bytes/sec) > # diff flash-wr941nd flash-wr941nd-2 > # sysctl dev.spi.0.clock=3D1000000 > dev.spi.0.clock: 500000 -> 1000000 > # dd if=3D/dev/flash/spi0 of=3Dflash-wr941nd-2 bs=3D64k > 64+0 records in > 64+0 records out > 4194304 bytes transferred in 37.896805 secs (110677 bytes/sec) > # diff flash-wr941nd flash-wr941nd-2 =20 > # sysctl dev.spi.0.clock=3D2000000 =20 > dev.spi.0.clock: 1000000 -> 2016129 > # dd if=3D/dev/flash/spi0 of=3Dflash-wr941nd-2 bs=3D64k > 64+0 records in > 64+0 records out > 4194304 bytes transferred in 18.879980 secs (222156 bytes/sec) > # diff flash-wr941nd flash-wr941nd-2 =20 > # sysctl dev.spi.0.clock=3D4000000 =20 > dev.spi.0.clock: 2016129 -> 4032258 > # dd if=3D/dev/flash/spi0 of=3Dflash-wr941nd-2 bs=3D64k > 64+0 records in > 64+0 records out > 4194304 bytes transferred in 9.642490 secs (434981 bytes/sec) > # diff flash-wr941nd flash-wr941nd-2 =20 > # sysctl dev.spi.0.clock=3D10000000 =20 > dev.spi.0.clock: 4032258 -> 10416666 > # dd if=3D/dev/flash/spi0 of=3Dflash-wr941nd-2 bs=3D64k > 64+0 records in > 64+0 records out > 4194304 bytes transferred in 4.317743 secs (971411 bytes/sec) > # diff flash-wr941nd flash-wr941nd-2 =20 >=20 >=20 > It export a few handy sysctl knobs: >=20 > # sysctl dev.spi > dev.spi.0.%desc: BCM2708/2835 SPI controller > dev.spi.0.%driver: spi > dev.spi.0.%parent: simplebus0 > dev.spi.0.clock: 500000 > dev.spi.0.cpol: 0 > dev.spi.0.cpha: 0 > dev.spi.0.cspol0: 0 > dev.spi.0.cspol1: 0 >=20 >=20 > About the patches: >=20 > - bcm2835_spi.diff implements the SPI driver, the dts and kernel = changes; >=20 > - ofw_spibus.diff adds the OFW SPI bus glue to attach the SPI children = as described in the FDT. >=20 > - mx25l-fdt-intr.diff adds the support for FDT and configure a intr = hook so the device identification runs only when the interrupts are = active (the SPI driver is interrupt based); >=20 > - rpi-mx25l-dts.diff the change i did to add my mx25l on the rpi dts = (only as reference). >=20 >=20 > Luiz >=20 >=20 >=20 >=20 > = _______________________________________________ > freebsd-arm@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arm > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org"