From owner-freebsd-embedded@FreeBSD.ORG Mon Apr 27 03:06:04 2015 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B6C9BB0C for ; Mon, 27 Apr 2015 03:06:04 +0000 (UTC) Received: from mail-ig0-x234.google.com (mail-ig0-x234.google.com [IPv6:2607:f8b0:4001:c05::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8160A136F for ; Mon, 27 Apr 2015 03:06:04 +0000 (UTC) Received: by igblo3 with SMTP id lo3so51423478igb.0 for ; Sun, 26 Apr 2015 20:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=nTAFc4E9gT0tmyAqi5DTbFOAh8XGtIDohYAWzPMBVJM=; b=PBmeq2/fdmrVUp1F1QTrm7DN2GxzLF5SSdcvua1TR34Jyg+a/G7eUvqe25t2FJ9MB7 eRRf8NNaxeyGFNa9amJ6Kc99tUEc7HBEUSwpayfsqlmKzC9BnZQcFxpz0dE3apJADE03 u2VuI/RTS+CA5q0NXXAxU9pIXX5Lovqmh3ZqRar+mjWcbOhBZf78FDFUpO55O5mtk98y UWuUJ/WpgskTdtm/8sEUH3YESt1/MuaPhYFmMXeChwTsTmgLACS+4UdJwLVA7RRKYnAR E1KpyoDv9S+dfYmMuy4zAaX6k8Z/EKDOs282JgVryBiALYbW7tlPeYTWSb0KSiqRjSiO DrRA== MIME-Version: 1.0 X-Received: by 10.42.20.197 with SMTP id h5mr10176098icb.22.1430103963926; Sun, 26 Apr 2015 20:06:03 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.36.38.133 with HTTP; Sun, 26 Apr 2015 20:06:03 -0700 (PDT) In-Reply-To: <20150426203344.GA27490@gmail.com> References: <20150426203344.GA27490@gmail.com> Date: Sun, 26 Apr 2015 20:06:03 -0700 X-Google-Sender-Auth: RDSv4t8N0Qt0I2-7xTVsY6E4now Message-ID: Subject: Re: SPI User Space Interface From: Adrian Chadd To: Tom Jones Cc: "freebsd-embedded@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2015 03:06:04 -0000 Hey, this is cool! What can we do to spibus to make it better? -adrian On 26 April 2015 at 13:33, Tom Jones wrote: > This atteched patch adds user space access to spi drivers. Access is possible > via read, write and an ioctl call. I have tested this patch on a raspberry-pi B > against an avr running a simple program and a small monochrome oled screen > based on the ssd1306 display driver. > > The ioctl requires the use of two new structs. The spi_rdwr_data struct takes a > number of spi_ioc_transfer structs, this is modeled on the iic driver. The > spi_ioc_transfer struct is compatible with the linux spidev implementation. > > There is no support for ioctls to set spi device settings are there is in > linux, this is due to the limited driver interface in spibus. Only the buffer > and length options are used from the spi_ioc_transfer struct, this is from the > lack of driver interface on spibus. > > struct spi_ioc_transfer { > void *tx_buf; > void *rx_buf; > > uint32_t len; > uint32_t speed_hz; > > uint16_t delay_usecs; > uint8_t bits_per_word; > uint8_t cs_change; > uint32_t pad; > }; > > struct spi_rdwr_data { > struct spi_ioc_transfer *msgs; > uint32_t nmsgs; > }; > > #define SPIRDWR _IOW('S', 1, struct spi_rdwr_data) > > I have only managed to test this code on one platform and against a limited > number of spi devices. I think it needs more testing against real hardware, I > don't have any lying around. > > -- > Tom > @adventureloop > adventurist.me > > :wq > > _______________________________________________ > freebsd-embedded@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-embedded > To unsubscribe, send any mail to "freebsd-embedded-unsubscribe@freebsd.org"