From owner-freebsd-hackers@freebsd.org Mon Aug 17 17:14:03 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D05209BB594 for ; Mon, 17 Aug 2015 17:14:03 +0000 (UTC) (envelope-from brianfundakowskifeldman@gmail.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id B10B61D86 for ; Mon, 17 Aug 2015 17:14:03 +0000 (UTC) (envelope-from brianfundakowskifeldman@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id AF8E99BB593; Mon, 17 Aug 2015 17:14:03 +0000 (UTC) Delivered-To: hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 953E89BB592 for ; Mon, 17 Aug 2015 17:14:03 +0000 (UTC) (envelope-from brianfundakowskifeldman@gmail.com) Received: from mail-la0-x22b.google.com (mail-la0-x22b.google.com [IPv6:2a00:1450:4010:c03::22b]) (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 1F7601D84 for ; Mon, 17 Aug 2015 17:14:03 +0000 (UTC) (envelope-from brianfundakowskifeldman@gmail.com) Received: by lagz9 with SMTP id z9so83391759lag.3 for ; Mon, 17 Aug 2015 10:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=4cENo0CXslhFFET2Bhm/v3k2ucmkWSzm0MEU0bNdKI8=; b=NsxHiQKW5njxT0hKujq0gGlOFtXCk2r7O9TmScvs0ugjFhdhcVSNzARaHMcKqcMweJ 6WB/fcvkn30pepdtDb2plkXtj92D+HiG4HugVNiYuDZbVM+m0dzIVnCpCDqyWPdUqA+v Bhn2e9NK8K+j29RCK2Xg4gmt1KOs3ptYgc2VfVFHViTRpzj83GtCCgCaK7W3MW/KLgK3 ZZ919AJ+VZl9ZWs6fahEVM39ZIrykZdhanuz3JRp6yJ+b7Di7kYa2zTfN67orwn4zU7a oHkJt0hxqNfnZy2X+32mCmHKK4MveKXPKyrFJ+ZfaPthHatFZCDS+vzQKQgoRU1BDkHe 7Szg== X-Received: by 10.152.234.75 with SMTP id uc11mr1924438lac.20.1439831641228; Mon, 17 Aug 2015 10:14:01 -0700 (PDT) MIME-Version: 1.0 References: <20150817160423.GB3078@gmail.com> In-Reply-To: <20150817160423.GB3078@gmail.com> From: Brian Fundakowski Feldman Date: Mon, 17 Aug 2015 17:13:51 +0000 Message-ID: Subject: Re: spigen(4) SPI Generic IO interface -- need comments To: Tom Jones Cc: hackers@freebsd.org X-Mailman-Approved-At: Mon, 17 Aug 2015 18:25:32 +0000 Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Aug 2015 17:14:03 -0000 Oh, no, I couldn't find that in the search but maybe I need to subscribe to -embedded now that I'm interested in circuit hacking with my Pi. I am interested in also doing an i2c interface so I can use an I/O multiplexer as well. I'll have to take a look at your code, maybe try and shape them up into something good enough to commit -- I think I want to have a root-owned sysctl dictating the maximum transfer lengths (and hence pinned memory). On Mon, Aug 17, 2015, 12:04 PM Tom Jones wrote: > On Mon, Aug 17, 2015 at 10:00:26AM -0400, Brian Fundakowski Feldman wrote: > > I'm woefully out-of-practice with my kernel hackery (but still pretty > > proficient in jiggery-pokery) so I would like to get comments on a little > > driver I just made for interfacing arbitrarily in userland with SPI > > components. The only thing I'm exposing is a /dev/spigenN node with a > > single transfer ioctl and I put together a test circuit and program with > an > > MCP3008 10-bit ADC IC to validate that it basically works, other than the > > limitation that the transfers must be octet-multiply-sized, but I haven't > > looked at the SoC's (I'm using a Raspberry Pi 2) data sheet to tell > whether > > that's just a limit on the spibus(4) interface or the Broadcom SPI driver > > or the Broadcom SoC itself. > > > > I hit one snag in development where I simply called the ioctl wrong and > > found copyin(9) to page fault HARD if given a bogus user address to copy > > from, and panic the kernel. I can post up the test program if anyone > wants > > but it's very trivial: I just align the start bit and the command data > into > > the least significant bits of the first octet, shift it up two positions > so > > the NULs get clocked out as part of the command field, and provide two > > octets for the data field to retrieve back the 10-bit digital value. > > Oh, cool. > > I did the same earlier this year, have you seen[1]?. > > The FreeBSD i2c api is the same/very similar the linux one[2][3]. Have you > considered adding some of the ioctls[3] or the data structures to make it > easier to port code? > > [1]: > https://lists.freebsd.org/pipermail/freebsd-embedded/2015-April/002466.html > [2]: https://www.kernel.org/doc/Documentation/i2c/dev-interface > [3]: > https://www.freebsd.org/cgi/man.cgi?query=iic&apropos=0&sektion=0&manpath=FreeBSD+10.2-RELEASE&arch=default&format=html > [4]: https://www.kernel.org/doc/Documentation/spi/spidev > > - tj >