From owner-freebsd-embedded@freebsd.org Tue Mar 29 21:39:15 2016 Return-Path: Delivered-To: freebsd-embedded@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 9FFE3AE24A7 for ; Tue, 29 Mar 2016 21:39:15 +0000 (UTC) (envelope-from admin182@z182.najnx.com) Received: from z182.najnx.com (z182.najnx.com [161.123.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id 3E40B1345 for ; Tue, 29 Mar 2016 21:39:14 +0000 (UTC) (envelope-from admin182@z182.najnx.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; s=najnx; d=z182.najnx.com; h=Date:From:To:Subject:Message-ID:Mime-Version:Content-Type; i=admin182@z182.najnx.com; bh=h9ujrNnC6TQiNhD665Z9JheRX8U=; b=qL9+dS+nd4wImTQ5NrOHIFR7b/aeTSnGNkbG9CfdERot+agM4yIwAbdIGYSIcnkhDQKSddtm59Fa +FuPrdCtOJDtpa7QoWXqn2e5UspXCcf2u3ivEELUz384w8tVBN4wy6zjnLiT91Q9mJQyMNnAJa21 8Jgv894YEBPopXdSEZI= DomainKey-Signature: a=rsa-sha1; c=nofws; q=dns; s=najnx; d=z182.najnx.com; b=Nu2mUnfy9Vsb6vW4d6socPMZHt5hm+5PFmAaUPTKB7b9o0Nhmwvuq5NAhKl061EFOTK7MOOrsZIq XEk9pyMjmKZRtVZAdgIzB1N4r2xny5z6lRIRAXRF8URvFrZK96Cs0PYVgDblmZFPYceF7rdRrUNe m0aQwEp8VTXmpUcIwmI=; Date: Wed, 30 Mar 2016 05:29:23 +0800 From: "Rayban" To: Subject: Up to 60% Off and Free Shipping from Factory Message-ID: <20160330052936580187@z182.najnx.com> X-mailer: Foxmail 6, 13, 102, 15 [cn] Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2016 21:39:15 -0000 DQoNCllvdSdyZSByZWNlaXZpbmcgdGhpcyBuZXdzbGV0dGVyIGJlY2F1c2UgeW91IHN1YnNjcmli ZWQgZnJvbSBvdXIgd2Vic2l0ZS4NCkhhdmluZyB0cm91YmxlIHJlYWRpbmcgdGhpcyBlbWFpbD8g VmlldyBpdCBpbiB5b3VyIGJyb3dzZXIuIE5vdCBpbnRlcmVzdGVkIGFueW1vcmU/IFVuc3Vic2Ny aWJlIGluc3RhbnRseS4gDQoNCiAgRlJFRSBTSElQUElORyAqICBGcmVlIFJldHVybiAqIA0KDQoN CkJlc3QgU2VsbGVycyBDb2xsZWN0aW9ucyBKdWxpZXQgT3ZhbCBGcmFtZSBUeXBlcyBDb21taXQg U3EgRmFzdCBKYWNrZXQgTmV3IEFycml2YWxzIA0KDQpEaXNjb3VudCBSYXkgQmFuIFN1bmdsYXNz ZXMgDQpXZWxjb21lIHRvIG15IHN1bmdsYXNzZXMgc3RvcmUgDQo4MCANCg0KRVZFUllUSElORyAN CiVPRkYgDQoNClBMVVMgJDgwRlJFRSBTSElQSU5HIE9OIEFMTE9SREVSUyANCk9ha2xleSBTdW5n bGFzcyANClJheSBCYW4gU3VuZ2xhc3MgDQoNCg0KDQoNClByaXZhY3kgUG9saWN5IFNoaXBwaW5n IFJldHVybnMgQ29uZGl0aW9ucyBvZiBVc2UgDQoNCg0KDQpUbyBiZSBzdXJlIHRoYXQgeW91IHdp bGwgcmVjZWl2ZSBvdXIgb2ZmZXJzLCB3ZSBzdWdnZXN0IHRoYXQgeW91IGFkZCBvdXIgZW1haWwg YWRkcmVzcywgY3VzdG9tZXJzZXJ2aWNlMjRob3VyQGhvdG1haWwuY29tIHRvIHlvdXIgYWRkcmVz cyBib29rLiBJbiBhY2NvcmRhbmNlIHdpdGggdGhlIEZyZW5jaCBsYXcgb2YgSmFudWFyeSA2LCAx OTc4LCBjb3JyZWN0IGFueSBpbmZvcm1hdGlvbiBoZWxkIGJ5IDIwMTVzdW5nbGFzc3ZpcC5jb20g dGhhdCBjb25jZXJucyB5b3UuIA0KDQpPdXIgcHJvbWlzZXM6DQoNCi0gMTAwIGRheXMgdG8gcmV0 dXJuIG9yIGV4Y2hhbmdlIGFuIGl0ZW0NCi0gU2FtZS1kYXkgZGlzcGF0Y2ggZm9yIG9yZGVycyBw bGFjZWQgYmVmb3JlIDcgRGF5cy4qDQotIEN1c3RvbWVyIHNhdGlzZmFjdGlvbiBpcyBvdXIgdG9w IHByaW9yaXR5IA0KDQpidXlpbmcgYSBnaWZ0LCBvciBsb29raW5nIGZvciBhIHByYWN0aWNhbCBw YWlyIG9mIHN1bmdsYXNzZXMsIHlvdSdyZSBzdXJlIHRvIGZpbmQgd2hhdCB5b3UncmUgYWZ0ZXIg aW4gUkIgb25saW5lIHN0b3JlIGh1Z2Ugc2VsZWN0aW9uLiB0b3AgZmFzaGlvbiBzZWxlY3Rpb24u IFdoZXRoZXIgeW91J3JlIGxvb2tpbmcgZm9yIHRoZSBsYXRlc3QgdHJlbmRzIG9yIHRpbWVsZXNz IGNsYXNzaWNzLCAyMDE1c3VuZ2xhc3N2aXAgb2ZmZXJzIGh1bmRyZWRzIG9mIGVzdGFibGlzaGVk IHByb2R1Y3QgbGlrZSBzdW5nbGFzc2VzIGp1c3QgZm9yIHlvdS4gDQoNCipUd2VudHktZm91ciBo b3VycyBhIGRheSwgZGVwZW5kZW50IHVwb24gcGF5bWVudCB2YWxpZGF0aW9uDQoqU2VlIHRlcm1z IGFuZCBjb25kaXRpb25zIA0KDQoNCkNvcHlyaWdodCAyMDA5LTIwMTUgUmF5IEJhbiBTdW5nbGFz c2VzIEFsbCBSaWdodHMgUmVzZXJ2ZWQuIA== From owner-freebsd-embedded@freebsd.org Fri Apr 1 21:12:12 2016 Return-Path: Delivered-To: freebsd-embedded@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 A931AB009FB for ; Fri, 1 Apr 2016 21:12:12 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 873431FF4 for ; Fri, 1 Apr 2016 21:12:12 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id 86806B009FA; Fri, 1 Apr 2016 21:12:12 +0000 (UTC) Delivered-To: embedded@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 86183B009F9 for ; Fri, 1 Apr 2016 21:12:12 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-ig0-x22b.google.com (mail-ig0-x22b.google.com [IPv6:2607:f8b0:4001:c05::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 4B8E61FE6; Fri, 1 Apr 2016 21:12:09 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-ig0-x22b.google.com with SMTP id l20so3746279igf.0; Fri, 01 Apr 2016 14:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=toz+6fhfLru2ToC4twZiWx4sJyir6CtnsIoDj3zvr9c=; b=RAUaRzexqJT+RiVsCGvgt6kfWjb98GN+bEkL0YcMORdJVP14/l7Lh5DER0K0mO7c4Y x5rm/syxdoevLbjnYkwXpayKao8vYDwTKKH2T08DrsycMBVnNJc1giGpVQ1FhsUhuGWP GEJ5YiMrdM6gg/RbFxY8N9m+kkOeyqF6sytNFrj2XZ9TleSE8hLbapVbRmKPNSv6F++C y8rV1RNcUM1yOUWg+1IHRD0er6EPzaECI9TH5WPe2FTHSYoHn2xnH+fCgtw+eyVLq88M ziKLf1YIpH4GjrWizi3wBThw4FarIRfa8iKGNGFt+5q8KrMDXW/IGUFXRYZ9QYgWdYHN DBOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=toz+6fhfLru2ToC4twZiWx4sJyir6CtnsIoDj3zvr9c=; b=bcOEimGX5h8QyS1ba8XGn6ntx8DKDKdGf+zhg3GnlHA/Hh+n0+Gv6sjELkR0h2+srr wWWlJwpBhfwBDim/eKFPmnfMCnxI8wuUAfsyxSxSisUZAS6mVKVv4eBEjQidQPPdc2hY EsRDD7xt7tLQBOdAEvo8Ss1P+HVR7ei6JgCryzEQmGa0bY1C1zmcLSQ0KrI0s2vm36h4 P2zSJKOP76tQCT0oNZOqnlSpaZopHRiRNIiAhIlVNEv/Jm6qj0i7quVjmf6WJgNZpHqF lvj34mjjVJPU+ZH+UzzEpwjwpY/fL7oS8xahOzIdMAIavyABe8QcUkevb8rbRodJKMdA lwmQ== X-Gm-Message-State: AD7BkJIoF+HZvZYsUKHWBm7FVjLAQ8hDgKyQyzp1mqKp+3syGd4ehW5m1Wmdt/ukIVFbjXlTmOfBVMKGGq5/HA== MIME-Version: 1.0 X-Received: by 10.50.43.134 with SMTP id w6mr938717igl.22.1459545128579; Fri, 01 Apr 2016 14:12:08 -0700 (PDT) Received: by 10.36.14.19 with HTTP; Fri, 1 Apr 2016 14:12:08 -0700 (PDT) In-Reply-To: References: <20150817160423.GB3078@gmail.com> Date: Fri, 1 Apr 2016 14:12:08 -0700 Message-ID: Subject: Re: spigen(4) SPI Generic IO interface -- need comments From: Adrian Chadd To: Brian Fundakowski Feldman Cc: Warner Losh , Luiz Otavio O Souza , "freebsd-embedded@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2016 21:12:12 -0000 hihi! ok, I'd now like to resurrect this - I'll take a look and see what's missing before we throw it into the tree. I'd like to use this for the atheros MIPS SPI stuff so i can more efficiently speak to an LCD. :P Thanks! -adrian On 22 August 2015 at 17:27, Brian Fundakowski Feldman wrote: > You know, now you're making me wonder if the edge behavior shouldn't also be > configurable per-spigen/per-transfer. Chip select polarity seems far too > dangerous to expose that way. The only SPI device I have lying around so far > is an MCP3008. > > > On Sat, Aug 22, 2015, 8:17 PM Warner Losh wrote: >> >> I've worked on one set of flash that had simple commands for identifying >> it, which were clocked at one rate (slow, to be compatible with older >> members of the family), and other commands that were data transfer that were >> clocked faster to match the data coming from internal pipelines in the part. >> I don't know how common this arrangement is in the wild, though. >> >> And all of this is from memory of something I worked on maybe 10 years ago >> now, so I'm not sure how relevant it is today. I do know NAND flash chips >> have similar behavior, but those don't have a SPI bus. >> >> Warner >> >> >> On Sat, Aug 22, 2015 at 6:09 PM, Brian Fundakowski Feldman >> wrote: >>> >>> That's something I want feedback on: are there scenarios where you want >>> to >>> regularly vary the clock to a specific SPI device, as opposed to varying >>> it >>> among several? It would be easy to add to the transfer ioctls if you have >>> a >>> use case (for example, manual chip select control with more devices than >>> chip select pins in your low-level SPI implementation.) Certainly from a >>> runtime cost perspective it would be no burden. >>> >>> Thanks for taking a look! >>> -- >>> green >>> >>> On Sat, Aug 22, 2015, 5:55 PM Adrian Chadd >>> wrote: >>> >>> > Hi! >>> > >>> > This looks cool! Is there any reason why the clock isn't per >>> > transaction? >>> > >>> > >>> > -a >>> > >>> > >>> > On 22 August 2015 at 11:23, Brian Fundakowski Feldman >>> > wrote: >>> > > I've added a couple more features: >>> > > * clock adjustment via ioctl, independent per spigenN device >>> > > * mmap(2) support for very low latency >>> > > >>> > > On Tue, Aug 18, 2015 at 6:47 PM, Brian Fundakowski Feldman < >>> > > brianfundakowskifeldman@gmail.com> wrote: >>> > > >>> > >> On Mon, Aug 17, 2015 at 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 >>> > >> >>> > >> >>> > >> I've iterated a bit on this to try to make some more sensible API, >>> > >> behaving reasonably about being able to set the SPI clock speed. >>> > >> I'm >>> > going >>> > >> to implement an mmap handler so I can have my low-latency operation >>> > mode, >>> > >> as well. I don't like the Linux APIs one bit because it's just not >>> > safe to >>> > >> allow all those configuration changes on a per-transfer basis... >>> > >> >>> > >> Moving this to -embedded because it's more apt than -hackers. >>> > >> >>> > > >>> > > _______________________________________________ >>> > > freebsd-embedded@freebsd.org mailing list >>> > > https://lists.freebsd.org/mailman/listinfo/freebsd-embedded >>> > > To unsubscribe, send any mail to " >>> > freebsd-embedded-unsubscribe@freebsd.org" >>> > >>> _______________________________________________ >>> freebsd-embedded@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/freebsd-embedded >>> To unsubscribe, send any mail to >>> "freebsd-embedded-unsubscribe@freebsd.org" >> >> > From owner-freebsd-embedded@freebsd.org Fri Apr 1 21:23:19 2016 Return-Path: Delivered-To: freebsd-embedded@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 652E7B00C89 for ; Fri, 1 Apr 2016 21:23:19 +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 40729135D for ; Fri, 1 Apr 2016 21:23:19 +0000 (UTC) (envelope-from brianfundakowskifeldman@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id 3FAE3B00C88; Fri, 1 Apr 2016 21:23:19 +0000 (UTC) Delivered-To: embedded@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 3F45BB00C87 for ; Fri, 1 Apr 2016 21:23:19 +0000 (UTC) (envelope-from brianfundakowskifeldman@gmail.com) Received: from mail-qg0-x233.google.com (mail-qg0-x233.google.com [IPv6:2607:f8b0:400d:c04::233]) (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 E62EC135C; Fri, 1 Apr 2016 21:23:18 +0000 (UTC) (envelope-from brianfundakowskifeldman@gmail.com) Received: by mail-qg0-x233.google.com with SMTP id f52so10611452qga.3; Fri, 01 Apr 2016 14:23:18 -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; bh=VOFgQCa4L/bT+OZGfXvkZ1CHQ/3NOK9ZQde5knij0Rg=; b=pnoztgaHtEvjIpe3/ApDm4+sXjYAAYu+58Uej0Pis//fJr3nWnecl4Fq1yMKtab0VR g3izw+R2ZDUBlgAenokojA2k/+bqw/nmVXXYiyEZNX+H5RJpBlwXmYypBynZ6PdjMCLW gpu057sGt5lKqcAFnivp1jvacOM0IIxE9gDg3GP3YHrE4gDtnnikAHRnvAu8U8eRFoZy tKUqpWds1dEVveL6JEsVLE5xzma75hb1LF3guxtXyrxOzmB8V6yEdfiuhT4/mCaf8DfG YY4JCu9+Wimavh2zRdPUcmcUPnP81J89gVROE6tNkXfKlJwg9UaKQ7RTqgDYLqHvkHV4 cXXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VOFgQCa4L/bT+OZGfXvkZ1CHQ/3NOK9ZQde5knij0Rg=; b=Viv+mFTljEe4Jlvv3WLQocOHeEJrcWLyVGqjunSnIPQPib4pY1ws+SJGVJABALnG1H L0JbYSH9t5YqqKadjcN0o3vijmjPQ1kRU/DqPQLm5AV58h9uTAxhmle8PdMABBRDV3AE hF0p9BMwUwLlw33684PpaYJ2uFVPGTE0egCtCWxfC4pF7SqMpZfHxvhD9ujcfrJAFMm+ FI9zv7devhEkn/msPxSslvsdtIGxs0GjmR/xVrlJWolilF87ae/+tmDjS2FNDtbvl/qS mpRWLePgw9K2KUgWVgTIvaHQgNn67iupCXuhnlFZ5qmx6KiGnPOhJN26/cwYmpJ9eCU2 4xKQ== X-Gm-Message-State: AD7BkJIRaw7/pPUng/NMA+RW22z9/4OG11XKETLH3ra/elz2BGxPfM5TIZEq+nqelywuIEfBNjk1HuTguk0rHw== X-Received: by 10.140.170.70 with SMTP id q67mr29615321qhq.8.1459545797695; Fri, 01 Apr 2016 14:23:17 -0700 (PDT) MIME-Version: 1.0 References: <20150817160423.GB3078@gmail.com> In-Reply-To: From: Brian Fundakowski Feldman Date: Fri, 01 Apr 2016 21:23:08 +0000 Message-ID: Subject: Re: spigen(4) SPI Generic IO interface -- need comments To: Adrian Chadd Cc: Warner Losh , Luiz Otavio O Souza , "freebsd-embedded@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2016 21:23:19 -0000 Great! I think the last part I wanted to have was a manpage that covered configuring the device tree (dump, edit, rebuild) because that was fairly non-obvious to me. I have only tested it on the RPi2 myself. On Fri, Apr 1, 2016, 5:12 PM Adrian Chadd wrote: > hihi! > > ok, I'd now like to resurrect this - I'll take a look and see what's > missing before we throw it into the tree. I'd like to use this for the > atheros MIPS SPI stuff so i can more efficiently speak to an LCD. :P > > Thanks! > > > -adrian > > > On 22 August 2015 at 17:27, Brian Fundakowski Feldman > wrote: > > You know, now you're making me wonder if the edge behavior shouldn't > also be > > configurable per-spigen/per-transfer. Chip select polarity seems far too > > dangerous to expose that way. The only SPI device I have lying around so > far > > is an MCP3008. > > > > > > On Sat, Aug 22, 2015, 8:17 PM Warner Losh wrote: > >> > >> I've worked on one set of flash that had simple commands for identifying > >> it, which were clocked at one rate (slow, to be compatible with older > >> members of the family), and other commands that were data transfer that > were > >> clocked faster to match the data coming from internal pipelines in the > part. > >> I don't know how common this arrangement is in the wild, though. > >> > >> And all of this is from memory of something I worked on maybe 10 years > ago > >> now, so I'm not sure how relevant it is today. I do know NAND flash > chips > >> have similar behavior, but those don't have a SPI bus. > >> > >> Warner > >> > >> > >> On Sat, Aug 22, 2015 at 6:09 PM, Brian Fundakowski Feldman > >> wrote: > >>> > >>> That's something I want feedback on: are there scenarios where you want > >>> to > >>> regularly vary the clock to a specific SPI device, as opposed to > varying > >>> it > >>> among several? It would be easy to add to the transfer ioctls if you > have > >>> a > >>> use case (for example, manual chip select control with more devices > than > >>> chip select pins in your low-level SPI implementation.) Certainly > from a > >>> runtime cost perspective it would be no burden. > >>> > >>> Thanks for taking a look! > >>> -- > >>> green > >>> > >>> On Sat, Aug 22, 2015, 5:55 PM Adrian Chadd > >>> wrote: > >>> > >>> > Hi! > >>> > > >>> > This looks cool! Is there any reason why the clock isn't per > >>> > transaction? > >>> > > >>> > > >>> > -a > >>> > > >>> > > >>> > On 22 August 2015 at 11:23, Brian Fundakowski Feldman > >>> > wrote: > >>> > > I've added a couple more features: > >>> > > * clock adjustment via ioctl, independent per spigenN device > >>> > > * mmap(2) support for very low latency > >>> > > > >>> > > On Tue, Aug 18, 2015 at 6:47 PM, Brian Fundakowski Feldman < > >>> > > brianfundakowskifeldman@gmail.com> wrote: > >>> > > > >>> > >> On Mon, Aug 17, 2015 at 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 > >>> > >> > >>> > >> > >>> > >> I've iterated a bit on this to try to make some more sensible API, > >>> > >> behaving reasonably about being able to set the SPI clock speed. > >>> > >> I'm > >>> > going > >>> > >> to implement an mmap handler so I can have my low-latency > operation > >>> > mode, > >>> > >> as well. I don't like the Linux APIs one bit because it's just > not > >>> > safe to > >>> > >> allow all those configuration changes on a per-transfer basis... > >>> > >> > >>> > >> Moving this to -embedded because it's more apt than -hackers. > >>> > >> > >>> > > > >>> > > _______________________________________________ > >>> > > freebsd-embedded@freebsd.org mailing list > >>> > > https://lists.freebsd.org/mailman/listinfo/freebsd-embedded > >>> > > To unsubscribe, send any mail to " > >>> > freebsd-embedded-unsubscribe@freebsd.org" > >>> > > >>> _______________________________________________ > >>> freebsd-embedded@freebsd.org mailing list > >>> https://lists.freebsd.org/mailman/listinfo/freebsd-embedded > >>> To unsubscribe, send any mail to > >>> "freebsd-embedded-unsubscribe@freebsd.org" > >> > >> > > > From owner-freebsd-embedded@freebsd.org Sat Apr 2 00:06:55 2016 Return-Path: Delivered-To: freebsd-embedded@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 02C1CB00B62 for ; Sat, 2 Apr 2016 00:06:55 +0000 (UTC) (envelope-from adrian.chadd@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 D363E1289 for ; Sat, 2 Apr 2016 00:06:54 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id CF088B00B61; Sat, 2 Apr 2016 00:06:54 +0000 (UTC) Delivered-To: embedded@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 CEA20B00B60 for ; Sat, 2 Apr 2016 00:06:54 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-ig0-x233.google.com (mail-ig0-x233.google.com [IPv6:2607:f8b0:4001:c05::233]) (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 955641287; Sat, 2 Apr 2016 00:06:54 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-ig0-x233.google.com with SMTP id f1so6765042igr.1; Fri, 01 Apr 2016 17:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=DdoB7LoeTMQdmfqqgtsVJ7feMtMqVG1VuuDUd1L1Lmo=; b=0iLKEe2XBH6A2eIN63J1wCXXy9esCm6Np99O1tUwjxya6CvKEYjxyOfIJGvqpEPIPH NN9YTUDPI78s3DsaDKWvTmQydadM3EwSmxrFisD+J1fw1fWoEoauNCGYuZa0qsJtKX0o XpKWxZiwuXztymW4H1tTbHJKVt9Vom3APbsfkqoqHoDw07T8QUb8T/Hh8eomHVq1tw8a cRYYP0K5UYhBxPaANC4+8s+nRm3dDgicHPOo1T+J7o6dmAWztl6pIhjl7MNtRNtUQFPK kGFK7fiYMXTl6OfkF4GAjypRVX6EF7eIvbc+xZAcyqVBTqCWnwQVz4ei+3gBaa9Efx0Q D7og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=DdoB7LoeTMQdmfqqgtsVJ7feMtMqVG1VuuDUd1L1Lmo=; b=VkGQ47JzwRuRlkHVJnGywbcg49myMQt6iaXWpVY7H92CFcDmpM06jwDC7yb0l3HjJ4 WGpHWZYRB3BhOiuu7A6lABY9YyRVqI/jQNqE9V9pP+9CgX07ThiukKVW2wbg/kVNa/PD QcSlMoSpJjM2ZSMD17tM0BmnGjWhjjZlAh2+ZXViERmwxMMRzrj2d5Fn38uhV17nh27O 69+P2xaJOHlNr8qfSZHAlECIFlSBiZ08sm4h6llgfIuvOaWy1PpwRObC1PMwInIr1lh/ FKExCyUYBe+OZtZ9Z01iCj5Wxdwa9EjFwjGo7fCVMiL/MpBKHbwqLbkDPACbPENEXQMq As2g== X-Gm-Message-State: AD7BkJKOg1/ZSfUfO/psJFqy8l7Rr/JTrYPXdx+fSmLBEAQ3fsdyAmz7yVw4ZY33i5fJEiO8JkyRkL00e3uJ+w== MIME-Version: 1.0 X-Received: by 10.107.134.166 with SMTP id q38mr13276252ioi.165.1459555613796; Fri, 01 Apr 2016 17:06:53 -0700 (PDT) Received: by 10.36.14.19 with HTTP; Fri, 1 Apr 2016 17:06:53 -0700 (PDT) In-Reply-To: References: <20150817160423.GB3078@gmail.com> Date: Fri, 1 Apr 2016 17:06:53 -0700 Message-ID: Subject: Re: spigen(4) SPI Generic IO interface -- need comments From: Adrian Chadd To: Brian Fundakowski Feldman Cc: Warner Losh , Luiz Otavio O Souza , "freebsd-embedded@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2016 00:06:55 -0000 ok. So this just attaches to each spibus that is found, right? Can you share your example program(s)? I'd like to see how you used the mmap version. -adrian On 1 April 2016 at 14:23, Brian Fundakowski Feldman wrote: > Great! I think the last part I wanted to have was a manpage that covered > configuring the device tree (dump, edit, rebuild) because that was fairly > non-obvious to me. I have only tested it on the RPi2 myself. > > > On Fri, Apr 1, 2016, 5:12 PM Adrian Chadd wrote: >> >> hihi! >> >> ok, I'd now like to resurrect this - I'll take a look and see what's >> missing before we throw it into the tree. I'd like to use this for the >> atheros MIPS SPI stuff so i can more efficiently speak to an LCD. :P >> >> Thanks! >> >> >> -adrian >> >> >> On 22 August 2015 at 17:27, Brian Fundakowski Feldman >> wrote: >> > You know, now you're making me wonder if the edge behavior shouldn't >> > also be >> > configurable per-spigen/per-transfer. Chip select polarity seems far too >> > dangerous to expose that way. The only SPI device I have lying around so >> > far >> > is an MCP3008. >> > >> > >> > On Sat, Aug 22, 2015, 8:17 PM Warner Losh wrote: >> >> >> >> I've worked on one set of flash that had simple commands for >> >> identifying >> >> it, which were clocked at one rate (slow, to be compatible with older >> >> members of the family), and other commands that were data transfer that >> >> were >> >> clocked faster to match the data coming from internal pipelines in the >> >> part. >> >> I don't know how common this arrangement is in the wild, though. >> >> >> >> And all of this is from memory of something I worked on maybe 10 years >> >> ago >> >> now, so I'm not sure how relevant it is today. I do know NAND flash >> >> chips >> >> have similar behavior, but those don't have a SPI bus. >> >> >> >> Warner >> >> >> >> >> >> On Sat, Aug 22, 2015 at 6:09 PM, Brian Fundakowski Feldman >> >> wrote: >> >>> >> >>> That's something I want feedback on: are there scenarios where you >> >>> want >> >>> to >> >>> regularly vary the clock to a specific SPI device, as opposed to >> >>> varying >> >>> it >> >>> among several? It would be easy to add to the transfer ioctls if you >> >>> have >> >>> a >> >>> use case (for example, manual chip select control with more devices >> >>> than >> >>> chip select pins in your low-level SPI implementation.) Certainly >> >>> from a >> >>> runtime cost perspective it would be no burden. >> >>> >> >>> Thanks for taking a look! >> >>> -- >> >>> green >> >>> >> >>> On Sat, Aug 22, 2015, 5:55 PM Adrian Chadd >> >>> wrote: >> >>> >> >>> > Hi! >> >>> > >> >>> > This looks cool! Is there any reason why the clock isn't per >> >>> > transaction? >> >>> > >> >>> > >> >>> > -a >> >>> > >> >>> > >> >>> > On 22 August 2015 at 11:23, Brian Fundakowski Feldman >> >>> > wrote: >> >>> > > I've added a couple more features: >> >>> > > * clock adjustment via ioctl, independent per spigenN device >> >>> > > * mmap(2) support for very low latency >> >>> > > >> >>> > > On Tue, Aug 18, 2015 at 6:47 PM, Brian Fundakowski Feldman < >> >>> > > brianfundakowskifeldman@gmail.com> wrote: >> >>> > > >> >>> > >> On Mon, Aug 17, 2015 at 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 >> >>> > >> >> >>> > >> >> >>> > >> I've iterated a bit on this to try to make some more sensible >> >>> > >> API, >> >>> > >> behaving reasonably about being able to set the SPI clock speed. >> >>> > >> I'm >> >>> > going >> >>> > >> to implement an mmap handler so I can have my low-latency >> >>> > >> operation >> >>> > mode, >> >>> > >> as well. I don't like the Linux APIs one bit because it's just >> >>> > >> not >> >>> > safe to >> >>> > >> allow all those configuration changes on a per-transfer basis... >> >>> > >> >> >>> > >> Moving this to -embedded because it's more apt than -hackers. >> >>> > >> >> >>> > > >> >>> > > _______________________________________________ >> >>> > > freebsd-embedded@freebsd.org mailing list >> >>> > > https://lists.freebsd.org/mailman/listinfo/freebsd-embedded >> >>> > > To unsubscribe, send any mail to " >> >>> > freebsd-embedded-unsubscribe@freebsd.org" >> >>> > >> >>> _______________________________________________ >> >>> freebsd-embedded@freebsd.org mailing list >> >>> https://lists.freebsd.org/mailman/listinfo/freebsd-embedded >> >>> To unsubscribe, send any mail to >> >>> "freebsd-embedded-unsubscribe@freebsd.org" >> >> >> >> >> >