From patchwork Thu Jul 4 07:07:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?546L5a6H6Iiq?= X-Patchwork-Id: 256808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9FAD62C0636 for ; Thu, 4 Jul 2013 17:08:21 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uude2-0007hd-3c; Thu, 04 Jul 2013 07:07:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uude0-000056-4P; Thu, 04 Jul 2013 07:07:56 +0000 Received: from mail-oa0-x230.google.com ([2607:f8b0:4003:c02::230]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uuddx-0008VG-Fe; Thu, 04 Jul 2013 07:07:54 +0000 Received: by mail-oa0-f48.google.com with SMTP id f4so1450282oah.21 for ; Thu, 04 Jul 2013 00:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=gxE0WDHfCcD0BhkoDdccCylbltY8HyzyVm2RgUR7kfA=; b=aDh9Q99VjsgaGuieS4Jv0+Rg6pEKCSPJJnTPqPlDaU9bwxBTcr4gov/UUlqV0tXc4J uSCjLIbrJBrYCgmS+2b7Uw0FZuidekRN+qiVU2Aku7mAP8fht/G/cCursK90G83saHjq bkzCoEcIMGDMOPgpOAibLBL8759Q0VKBNKCvhdlufgOY/FHn9TsJgT8dHyZKDwO6Azxh oyk7WfjgzKw3fZ9r6aT6go/h44rUzY4TqJJsHjAO418tlSrl4brL37Wxt0/d+Ltvf73K PMzr6pmQaey+kH66g6J67iroXLG6SFluEB5Gke4x6KahcNXA5HJNb+KdKylBFm2ObRad UBXQ== MIME-Version: 1.0 X-Received: by 10.60.137.225 with SMTP id ql1mr4582895oeb.48.1372921652014; Thu, 04 Jul 2013 00:07:32 -0700 (PDT) Received: by 10.182.73.170 with HTTP; Thu, 4 Jul 2013 00:07:31 -0700 (PDT) Date: Thu, 4 Jul 2013 15:07:31 +0800 Message-ID: Subject: SPI : DUAL/QUAD support From: =?GB2312?B?zfXT7rq9?= To: linux-mtd@lists.infradead.org, spi-devel-general@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, broonie@kernel.org, grant.likely@secretlab.ca X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130704_030753_614531_DE714AA3 X-CRM114-Status: GOOD ( 12.44 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (wangyuhang2014[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (wangyuhang2014[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hi Now some SPI controllers and Slave Devices have supported DUAL and QUAD transfer mode. But SPI controller driver in kernel has no member to deliver this information from Slave to Master. So in my opinion, adding transfer mode members to deal with the problem. In my SPI system, slave device is a Nor-Flash chip(s25fl129p) which use m25p80 driver. My patch below aims to make spi controller know the way that the slave want. Firstly user provides the SPI slave information into spi_board_info, including tx_bitwidth and rx_bitwidth. When the SPI slave is registered, information in spi_board_info is delivered to spi_device. Then SPI slave driver will add the transfer mode information into the spi_tranfer package and send it out to SPI controller driver. SPI controller driver will analyse the transfer package and set the certain transfer mode to its register. This patch do not support device tree.... Signed-off-by: wangyuhang --- drivers/mtd/devices/m25p80.c | 2 ++ drivers/spi/spi.c | 2 ++ include/linux/spi/spi.h | 8 ++++++++ 3 files changed, 12 insertions(+) -- 1.7.9.5 Best regards Jay diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 5b6b072..1411678 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -354,6 +354,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, t[1].rx_buf = buf; t[1].len = len; + t[1].bitwidth = flash->spi->rx_bitwidth; spi_message_add_tail(&t[1], &m); mutex_lock(&flash->lock); @@ -409,6 +410,7 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len, spi_message_add_tail(&t[0], &m); t[1].tx_buf = buf; + t[1].bitwidth = flash->spi->tx_bitwidth; spi_message_add_tail(&t[1], &m); mutex_lock(&flash->lock); diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 004b10f..cd99022 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -452,6 +452,8 @@ struct spi_device *spi_new_device(struct spi_master *master, proxy->irq = chip->irq; strlcpy(proxy->modalias, chip->modalias, sizeof(proxy->modalias)); proxy->dev.platform_data = (void *) chip->platform_data; + proxy->rx_bitwidth = chip->rx_bitwidth; + proxy->tx_bitwidth = chip->tx_bitwidth; proxy->controller_data = chip->controller_data; proxy->controller_state = NULL; diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 38c2b92..ddcf308 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -93,6 +93,8 @@ struct spi_device { void *controller_data; char modalias[SPI_NAME_SIZE]; int cs_gpio; /* chip select gpio */ + u8 rx_bitwidth; + u8 tx_bitwidth; /* * likely need more hooks for more protocol options affecting how @@ -511,6 +513,10 @@ struct spi_transfer { dma_addr_t rx_dma; unsigned cs_change:1; + u8 bitwidth; +#define SPI_BITWIDTH_SINGLE 0x01; /* 1bit transfer */ +#define SPI_BITWIDTH_DUAL 0x02; /* 2bits transfer */ +#define SPI_BITWIDTH_QUAD 0x03; /* 4bits transfer */ u8 bits_per_word; u16 delay_usecs; u32 speed_hz; @@ -859,6 +865,8 @@ struct spi_board_info { * where the default of SPI_CS_HIGH = 0 is wrong. */ u8 mode; + u8 rx_bitwidth; + u8 tx_bitwidth; /* ... may need additional spi_device chip config data here. * avoid stuff protocol drivers can set; but include stuff