From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751776AbbCVLZb (ORCPT ); Sun, 22 Mar 2015 07:25:31 -0400 Received: from kiutl.biot.com ([31.172.244.210]:47248 "EHLO kiutl.biot.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751283AbbCVLZa (ORCPT ); Sun, 22 Mar 2015 07:25:30 -0400 Message-ID: <550EA6A4.6010206@biot.com> Date: Sun, 22 Mar 2015 12:25:24 +0100 From: Bert Vermeulen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Mark Brown CC: ralf@linux-mips.org, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: Re: [PATCH 1/2] spi: Add SPI driver for Mikrotik RB4xx series boards References: <1426853793-24454-1-git-send-email-bert@biot.com> <1426853793-24454-2-git-send-email-bert@biot.com> <20150320125139.GJ2869@sirena.org.uk> In-Reply-To: <20150320125139.GJ2869@sirena.org.uk> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/20/2015 01:51 PM, Mark Brown wrote: Mark, Thanks very much for your detailed review. I'll fix things according to your comments. However... > On Fri, Mar 20, 2015 at 01:16:32PM +0100, Bert Vermeulen wrote: >> +static void do_spi_byte(void __iomem *base, unsigned char byte) >> +{ >> + do_spi_clk(base, byte >> 7); >> + do_spi_clk(base, byte >> 6); >> + do_spi_clk(base, byte >> 5); >> + do_spi_clk(base, byte >> 4); >> + do_spi_clk(base, byte >> 3); >> + do_spi_clk(base, byte >> 2); >> + do_spi_clk(base, byte >> 1); >> + do_spi_clk(base, byte); > > This looks awfully like it's bitbanging the value out, can we not use > spi-bitbang here? > [...] >> +static inline void do_spi_clk_fast(void __iomem *base, unsigned bit1, >> + unsigned bit2) > > Why would we ever want the slow version? It is bitbanging, at least on write. The hardware has a shift register that is uses for reads. The generic spi for this board's architecture (ath79) indeed uses spi-bitbang. This "fast SPI" thing is what makes this one different: the boot flash and MMC use regular SPI on the same bus as the CPLD. This CPLD needs this fast SPI: a mode where it shifts in two bits per clock. The second bit is apparently sent via the CS2 pin. So I don't think spi-bitbang will do. I need to see about reworking things to use less custom queueing -- I'm not that familiar with this yet. -- Bert Vermeulen bert@biot.com email/xmpp