From owner-freebsd-embedded@FreeBSD.ORG Tue Mar 18 12:55:34 2014 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 397516E2 for ; Tue, 18 Mar 2014 12:55:34 +0000 (UTC) Received: from mail-qc0-x22b.google.com (mail-qc0-x22b.google.com [IPv6:2607:f8b0:400d:c01::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id EE39AC98 for ; Tue, 18 Mar 2014 12:55:33 +0000 (UTC) Received: by mail-qc0-f171.google.com with SMTP id c9so1821962qcz.30 for ; Tue, 18 Mar 2014 05:55:33 -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:content-type; bh=bzk/LJLcO+rEzJL78yIzoeSzpiVexTB75rC/Zo23+ws=; b=gflOUVNWdErpAQLmwdLMq4ZyU6q6223zU1qlQwq7SfT5rSi/hQr2J4uVJAzNHH2DXl HQsPWrz0sG8MSCvGHz9gBaYXCXJe4XxHvUeQ91wtfoOEY3zmGdnDyGaALyDSVUroWWyM SxnKwuaTUbc2aQcZJc0T0ypQg6VN5HtJM+KloJdBKEm7Zqznp/KgHVa46NGpZjk7Hgdu VbJD4DiDEHrj2v+D9Fm7EhOhXXTauQmHx93dADa/+911x2J2Inix+ZiKbdQ5HJiQKS3a IPve+6uoS1vqGWNkcYx9hGtBCsoprXQattAg/LJ4Im2EPdpl/6j04pSSE39tifTDibuC U9Pw== MIME-Version: 1.0 X-Received: by 10.140.42.9 with SMTP id b9mr10062518qga.87.1395147333183; Tue, 18 Mar 2014 05:55:33 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.224.8.137 with HTTP; Tue, 18 Mar 2014 05:55:33 -0700 (PDT) In-Reply-To: References: Date: Tue, 18 Mar 2014 05:55:33 -0700 X-Google-Sender-Auth: WDWU9PYE-0yYoTZxI1lQlnNWb7g Message-ID: Subject: Re: nand controller - how should one handle controllers that want the command+address bits together? From: Adrian Chadd To: "freebsd-embedded@freebsd.org" Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Mar 2014 12:55:34 -0000 .. wow. So, this gets even more problematic. The AR934x NAND controller does DMA for the read/program phases as well as command results (eg READID.) Now, I can likely easily hack around it for simple commands like READID by overloading the nfc_start_command() method. For the read phase, I'd have to do a copy out of the buffer into the buffer supplied to the NAND bus code. Cool, that's just highly inefficient (why aren't we doing buffer IO here again? Bueller?) but that's a different story. For the write phase though, it's totally horrible. I'd have to buffer the command byte(s), the address byte(s) and the NAND bus write (which would copy it into the outgoing buffer), then issue it all at once. So, at first glance: * why aren't these (command; address; address; start) method runs just wrapped up into a command method that looks vaguely like (command, command2, row, column, id, buffer) and let the controller code either unravel it into serialised writes out, or in the case of the ar934x NAND controller, use all that information to setup a DMA transfer; * .. and for reads/writes, the buffer is supplied here, so they can also be used to setup the DMA transfer, else they're just serialised out via port banging for dumber NAND controller latches. I really want to try and bring this flash chip up (even without hardware ECC) but I'm kinda worried that in order to do this cleanly I'm going to have to overhaul nandbus/nfc and a couple of NAND controllers I don't have (and currently don't want) hardware for. So, any help/ideas? Thanks, -a On 18 March 2014 04:35, Adrian Chadd wrote: > Hiya, > > I've got the atheros ar934x nand controller bits looking like they're > working on freebsd-head enough to send/receive a READID command with > an address of 0x0. However, the NAND controller sends commands with > the cmd and address phases as part of the command, rather than calling > send_command / send_address methods called multiple times. > > It seems like our nandbus and nand controller layer is a very thin > shim over what the NAND control messages look like, rather than some > higher level 'thing' that allows for slightly more intelligent (read: > DMA/ECC capable) hardware. > > So, what gives? > > > -a