Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5718465imu; Tue, 13 Nov 2018 10:37:22 -0800 (PST) X-Google-Smtp-Source: AJdET5eKs4oT+d70GX0P2wm2ckEBuOIHVeRfgJxsTJAGp6W10DuYFpdIvVgtJNNsrbNegczC8Yjj X-Received: by 2002:a63:4c04:: with SMTP id z4mr5793517pga.312.1542134242591; Tue, 13 Nov 2018 10:37:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542134242; cv=none; d=google.com; s=arc-20160816; b=Mfvlwfc9flnivmjTExlhLKV/yTUVpCihS7t9y35hHKr8+SDx3S2yZ9xMRVUzDl3ovW Xl1Q+JazvdX0D/Tsyc6czRBleLcG6oNUIP7Szt/MeRgf1J3l5/ooCYtaz6HM12io52A8 XQSSHqBmr0nFJ5D+wEiBeTWe4gWpSvRCPXfq9iQZek3LOZQMo79bqdLrITUZLIACp1bV DOJFYCN0gp+qswH5An//mY06rTRpIUTU7CTzXEkscNQ+z9O4PEdFGgwyqyYixR8zgxSh Z9jKPEufrOMnhkIeWjCS4nm5JsuRZ+BKaBQnvlbc5Y5DQiBRqOZeucwou2Nez306kaR+ G6rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=OSuenFzkZBtgaOD9SE04NZNOhTdUroCJUkTcTsREdRI=; b=Xq36lvlxwMghVxkmwAMr6eyeo8aAzAFsgx77cse3hds70AGIQcV9xMsQNdIUlv91Dt rUm5ikiW6lgdbiHoW0YbgYGjuzBkEGkHE3cSCyGTGP+2jLbzhPKiPPwX1dTc7zy17L2L yougvYXOAd1bw02Rg4N7CzFAW6unDHUtbcNkPV1a+1DHMicAoiiCdA2KDY1MRvqu9+mM 7flIx/4t6jkLT9ReHoc3eYEFIyo9gu7mdtweS+fEOgYUWQx6WssHUAHZTGpMjIOPRPNz IAIvq43pJAv0Mk2qphuCPT3OsVD49sPKFeyd+KHm9nQWj9+odJKl4rSgd93ViRrPB/bY 7I3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=bCPKtJt1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8-v6si12418756pli.79.2018.11.13.10.36.46; Tue, 13 Nov 2018 10:37:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=bCPKtJt1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730936AbeKNEe7 (ORCPT + 99 others); Tue, 13 Nov 2018 23:34:59 -0500 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:45820 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726695AbeKNEe7 (ORCPT ); Tue, 13 Nov 2018 23:34:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OSuenFzkZBtgaOD9SE04NZNOhTdUroCJUkTcTsREdRI=; b=bCPKtJt10Xl/c+Cj9V//7CpD/ cZbgYJ9vw9srwwsa38ojtiIwnjLTJ5bUmn/n6+sSM5qDt8GH75lpPLLzDouhSqutvDZ9qPXVAziI3 k0rSG+zszLdEkmPrTrdTEjw9TZ215ITX/O3TvMPghgbWPu5On1nO/FbI5q9b97KXCvn9k=; Received: from [64.114.255.97] (helo=finisterre.ee.mobilebroadband) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gMdXB-0002QI-MP; Tue, 13 Nov 2018 18:35:33 +0000 Received: by finisterre.ee.mobilebroadband (Postfix, from userid 1000) id 5C6B3440078; Tue, 13 Nov 2018 18:35:27 +0000 (GMT) Date: Tue, 13 Nov 2018 10:35:27 -0800 From: Mark Brown To: Emil Renner Berthing Cc: linux-spi@vger.kernel.org, Rob Herring , Mark Rutland , Palmer Dabbelt , devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] spi: add driver for the SiFive SPI controller Message-ID: <20181113183527.GG2089@sirena.org.uk> References: <20181112142736.15009-1-kernel@esmil.dk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="df+09Je9rNq3P+GE" Content-Disposition: inline In-Reply-To: <20181112142736.15009-1-kernel@esmil.dk> X-Cookie: No Canadian coins. User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --df+09Je9rNq3P+GE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Nov 12, 2018 at 03:27:36PM +0100, Emil Renner Berthing wrote: > I know the discussions about the sifive devicetree compatible > strings haven't come to a conclusion, so I'm sending this as > an RFC to get some feedback on the rest of the code. I've not seen any of these discussions or earlier versions of this driver so I've no idea what's going on here :( > +Optional properties: > +- sifive,fifo-depth : Depth of hardware queues; defaults to 8 > +- sifive,max-bits-per-word : Maximum bits per word; defaults to 8 > + If the hardware isn't fixed yet making these enumerable from the hardware would be good... > @@ -0,0 +1,442 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * SiFive SPI controller driver (master mode only) > + * Please make the entire comment a C++ one to make this look more intentinal. > +/* for consistency we need this symbol */ > +#ifdef REG_FMT > +#undef REG_FMT > +#endif We do? For consistency with what? > +static void sifive_spi_init(struct sifive_spi *spi) > +{ > + /* Set CS/SCK Delays and Inactive Time to defaults */ > + > + /* Exit specialized memory-mapped SPI flash mode */ ...or not? > + /* Set frame format */ > + cr = FMT_LEN(t->bits_per_word); > + switch (mode) { > + case SPI_NBITS_QUAD: > + cr |= FMT_PROTO_QUAD; > + break; Some namespacing on the driver #defines would be a bit safer against the possibility of collision with future changes in headers. > +static void sifive_spi_wait(struct sifive_spi *spi, u32 bit, int poll) > +{ > + if (poll) { > + u32 cr; > + do cr = sifive_spi_read(spi, REG_IP); > + while (!(cr & bit)); Please add some braces, indentation or something to make it more clear that the read is part of a do/while loop - right now it's not immediately obvious that this is correct. > +static int sifive_spi_transfer_one(struct spi_master *master, > + struct spi_device *device, struct spi_transfer *t) > +{ > + struct sifive_spi *spi = spi_master_get_devdata(master); > + int poll = sifive_spi_prep_transfer(spi, device, t); > + > + sifive_spi_execute(spi, t, poll); > + Why not just inline the execute function here? It's the only caller AFAICT. > +static void sifive_spi_set_cs(struct spi_device *device, bool is_high) > +{ > + struct sifive_spi *spi = spi_master_get_devdata(device->master); > + > + /* Reverse polarity is handled by SCMR/CPOL. Not inverted CS. */ > + if (device->mode & SPI_CS_HIGH) > + is_high = !is_high; spi_set_cs() will handle CS_HIGH for you. > + master->bits_per_word_mask = SPI_BPW_MASK(8); I thought the device supported other bits per word values? > + /* If mmc_spi sees a dma_mask, it starts using dma mapped buffers. > + * Probably it should rely on the SPI core auto mapping instead. > + */ > + pdev->dev.dma_mask = NULL; If this is a problem please fix it in the MMC core, don't bodge it like this. > +static const struct of_device_id sifive_spi_of_match[] = { > + { .compatible = "sifive,spi0", }, > + {} > +}; > +MODULE_DEVICE_TABLE(of, sifive_spi_of_match); spi0 is a *weird* compatible name. --df+09Je9rNq3P+GE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlvrGW4ACgkQJNaLcl1U h9Afuwf/Y1cjBT6JU+ydckCZJW0OKyMIVU51jBKHs7/iW9J/d/All96iTXJxDSik NwWuGbuQ9J0npiReDRWdPFv86Cx+vaDJP7W4Sh5n0t65wgIsYe2/GF47guIRTaaz 6Z1s0inTYuu50N35m8rIfstMtkPVb42BRpEYnSZV1t1eGBEl8K/tDoxgxDv6ecHv ohTAo3k/4Ol4XFYfcIN4rYqL83e+dg1AMfNfdPqxPSWDuKbLh5/23jrhdqmaJIsf gEtyDHuRoEmC2Jud3Upt7iGtbA3Ezfa11yZ+wlAG6nBnB53FjusLylyrlDlsp0om qX/8rsCTyN0pMK1cCu1sDzOsVfn+SA== =fZ/2 -----END PGP SIGNATURE----- --df+09Je9rNq3P+GE--