From owner-freebsd-mips@FreeBSD.ORG Thu Feb 23 20:16:03 2012 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B453E106567A for ; Thu, 23 Feb 2012 20:16:03 +0000 (UTC) (envelope-from pkelsey@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 51A028FC23 for ; Thu, 23 Feb 2012 20:16:02 +0000 (UTC) Received: by vbbfa15 with SMTP id fa15so1570859vbb.13 for ; Thu, 23 Feb 2012 12:16:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=TlA0vCumqSPuwUhK1k8yaxZfg7UazG2CB5weQ8hYodM=; b=q/5SPC/TnFy3u1+R3J96zh1Hp74OxdB2FnuhT/0O+sOgS3rvers2wtrTMfnBEQ1LSF uPn0N7E8KfUnwIhSbSby4pJA8lp47q7pQX+PsD55GdVegLNmYavtCBoj97A+fhVPleZ5 71aVgmZg1IjU1qopqyCVc1mqYg4sg2HO/QmoQ= MIME-Version: 1.0 Received: by 10.220.151.5 with SMTP id a5mr1644627vcw.8.1330028162487; Thu, 23 Feb 2012 12:16:02 -0800 (PST) Sender: pkelsey@gmail.com Received: by 10.220.188.7 with HTTP; Thu, 23 Feb 2012 12:16:02 -0800 (PST) In-Reply-To: References: Date: Thu, 23 Feb 2012 15:16:02 -0500 X-Google-Sender-Auth: _4jUvq8SgDIAjRVi_eu4IFGZWyM Message-ID: From: Patrick Kelsey To: Adrian Chadd Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-mips@freebsd.org Subject: Re: ar71xx SPI speed X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2012 20:16:03 -0000 On Thu, Feb 23, 2012 at 1:57 PM, Adrian Chadd wrote: > > If you take a look at the source code, IIRC reads are done via the > hardware but the writes are done via bit banging. > > Are you looking at SPI read, SPI write, or a mix of both? > > Yes, the writes are bitbanged out, and on each clock that is generated on the bus by a bit write, a read bit is clocked in. At the end of bitbanging a byte out, the accumulated read bits are retrieved from a register with one operation. I'm looking at the SPI bus itself and measuring the clock, which appears to be limited by the rate at which one can do the series of register writes involved in bitbanging each byte out. > You can increase the hardware SPI clock by correct fondling of the > right registers but I haven't got any spare cycles to go grovelling > through the AR7100 datasheet at the moment. Sorry. Poke me in a few > days. > > I have working code that correctly programs the clock divider in AR71XX_SPI_CTRL. When programmed for clock rates below about 7 MHz or so, the observed clock on the bus tracks with what I program in that register. Divider values that should result in something faster than about 7 MHz don't actually, I suppose because the SPI unit itself is on some slow secondary bus, or has internals running on a relatively slow derivative of the system clock. Not having a datasheet, one thing I'm wondering is if there is something configurable in the SoC clock tree that would allow the SPI unit register accesses to complete more quickly if they are in fact the limiting factor here. Thanks, Patrick