Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754775AbdCGI2O (ORCPT ); Tue, 7 Mar 2017 03:28:14 -0500 Received: from mail-bn3nam01on0074.outbound.protection.outlook.com ([104.47.33.74]:64240 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750788AbdCGI2G (ORCPT ); Tue, 7 Mar 2017 03:28:06 -0500 From: Artur Jedrysek To: Boris Brezillon CC: "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Cyrille Pitchen , Marek Vasut , David Woodhouse , Brian Norris , Richard Weinberger Subject: RE: [PATCH 2/3] mtd: spi-nor: Add Octal SPI support to Cadence QSPI driver. Thread-Topic: [PATCH 2/3] mtd: spi-nor: Add Octal SPI support to Cadence QSPI driver. Thread-Index: AQHSlnXFsTcS4a0Qw0O3mL3dGT5XAqGIUkQAgAC3ayA= Date: Tue, 7 Mar 2017 08:26:36 +0000 Message-ID: References: <1488803545-22461-1-git-send-email-jartur@cadence.com> <20170306222118.6cfca9f7@bbrezillon> In-Reply-To: <20170306222118.6cfca9f7@bbrezillon> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-dg-ref: PG1ldGE+PGF0IG5tPSJib2R5LnR4dCIgcD0iYzpcdXNlcnNcamFydHVyXGFwcGRhdGFccm9hbWluZ1wwOWQ4NDliNi0zMmQzLTRhNDAtODVlZS02Yjg0YmEyOWUzNWJcbXNnc1xtc2ctYzc4YTJlZjgtMDMwZi0xMWU3LWI3NTEtMDAwNTlhM2M3YTAwXGFtZS10ZXN0XGM3OGEyZWY5LTAzMGYtMTFlNy1iNzUxLTAwMDU5YTNjN2EwMGJvZHkudHh0IiBzej0iNTI1NSIgdD0iMTMxMzMzNDg3OTc1NzU0MjY4IiBoPSIxenl5RjludjdaT24vZ0NpTXM2OUprS1c5YjA9IiBpZD0iIiBibD0iMCIgYm89IjEiLz48L21ldGE+ authentication-results: free-electrons.com; dkim=none (message not signed) header.d=none;free-electrons.com; dmarc=none action=none header.from=cadence.com; x-originating-ip: [213.131.238.28] x-ms-office365-filtering-correlation-id: 1b705a62-7522-4d14-a701-08d46533abeb x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR07MB2779; x-microsoft-exchange-diagnostics: 1;DM5PR07MB2779;7:8DMtehgCtgbHmW9WhI0A+PQBPYRWdPz2Gw1/k2Al/RMjoB5ZIumIHV2rrFjS72xsxTZr/+2xko01jCrmR/zg/NQtcwqc7NLI9aMCM+s4HiDIHXMKhQVsnzlN3PwxhdHC5L898NYSlC1wHX0mmDwuHdO1Q+FaiE9pfMdJnEEdnQDEGj8p3/ASSeuJYcACD1anEXmJDbJn7OeaAkppcLsd3LLjIDZxFmpU6LXH/9lv/KeZgYJPiCc6MCUkopacezp8XWOKnWVZ/YIrsZOJnpaqQXLyKZ73rIasshKZFcI87TuCqYiOinyE5yc5O96bR7uFHJhyuyKe+TuCtnbPs+c3cQ==;20:TN22qok0qQU/V9fSN9sk37+RvFCCxme4wt67ee5SDLCdhl1xeFB0GJVEaLOkrpQ4u1shDIgk5H1Iqxgd8Iu1bZmqW8zqqvUEfmBETCPZm5SxICqTe2QtuwJUyM0t8MBlmBfeLMSLzSvmg6RRPZk9a1DSE3egW2gb34adxdh2s/MNVPjoyw7fM8TOSK17KPsjO7OHeEcrG8zPd9SQW0hPzjRTOsPROPgOiOxZznfzHcQXFMFoC1UjLZwqECRFOdra x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(58145275503218)(72806322054110); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123558025)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(6072148);SRVR:DM5PR07MB2779;BCL:0;PCL:0;RULEID:;SRVR:DM5PR07MB2779; x-forefront-prvs: 0239D46DB6 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(39450400003)(36092001)(24454002)(77096006)(9686003)(7696004)(106116001)(106356001)(54906002)(3660700001)(110136004)(102836003)(6506006)(66066001)(6116002)(229853002)(2906002)(5660300001)(3846002)(345774005)(25786008)(6436002)(3280700002)(50986999)(7736002)(53936002)(92566002)(2900100001)(55016002)(305945005)(99286003)(76176999)(74316002)(54356999)(81166006)(4326008)(38730400002)(189998001)(86362001)(39060400002)(6246003)(122556002)(575784001)(8936002)(33656002)(2950100002)(6916009)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR07MB2779;H:DM5PR07MB2780.namprd07.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2017 08:26:36.6216 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB2779 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v278SImv006869 Content-Length: 5016 Lines: 134 From: Boris Brezillon [mailto:boris.brezillon@free-electrons.com] Sent: 6 march 2017 22:21 > On Mon, 6 Mar 2017 12:32:25 +0000 > Artur Jedrysek wrote: > > > Recent versions of Cadence QSPI controller support Octal SPI transfers > > as well. This patch updates existing driver to support such feature. > > > > It is not possible to determine whether or not octal mode is supported > > just by looking at revision register alone. To solve that, an > > additional property in Device Tree is added to indicate such capability. > > Both (revision and DT property) are used to determine, which mode to > > pass to spi_nor_scan() call. > > Hm, can we add a new compatible instead? Adding extra properties to describe the set of > functionalities supported by an IP is usually a bad idea. > Thank you for the suggestion. I will try that approach, and if it succeeds, I will use it in the next version of the patch. > > > > Additionally, the driver works on Xtensa CPU, hence Kconfig update. > > This should be done in a separate commit (it has nothing to do with octal mode support). > It will be done in separate commit in the next version of the patch. > > > > Signed-off-by: Artur Jedrysek > > --- > > drivers/mtd/spi-nor/Kconfig | 2 +- > > drivers/mtd/spi-nor/cadence-quadspi.c | 40 > > ++++++++++++++++++++++++++++++++++- > > 2 files changed, 40 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig > > index 7252087..f195749 100644 > > --- a/drivers/mtd/spi-nor/Kconfig > > +++ b/drivers/mtd/spi-nor/Kconfig > > @@ -50,7 +50,7 @@ config SPI_ATMEL_QUADSPI > > > > config SPI_CADENCE_QUADSPI > > tristate "Cadence Quad SPI controller" > > - depends on OF && (ARM || COMPILE_TEST) > > + depends on OF && (ARM || XTENSA || COMPILE_TEST) > > help > > Enable support for the Cadence Quad SPI Flash controller. > > > > diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c > > b/drivers/mtd/spi-nor/cadence-quadspi.c > > index 9f8102d..5c06102 100644 > > --- a/drivers/mtd/spi-nor/cadence-quadspi.c > > +++ b/drivers/mtd/spi-nor/cadence-quadspi.c > > @@ -87,6 +87,7 @@ struct cqspi_st { > > #define CQSPI_INST_TYPE_SINGLE 0 > > #define CQSPI_INST_TYPE_DUAL 1 > > #define CQSPI_INST_TYPE_QUAD 2 > > +#define CQSPI_INST_TYPE_OCTAL 3 > > > > #define CQSPI_DUMMY_CLKS_PER_BYTE 8 > > #define CQSPI_DUMMY_BYTES_MAX 4 > > @@ -204,6 +205,14 @@ struct cqspi_st { > > #define CQSPI_REG_CMDWRITEDATALOWER 0xA8 > > #define CQSPI_REG_CMDWRITEDATAUPPER 0xAC > > > > +#define CQSPI_REG_MODULEID 0xFC > > +#define CQSPI_REG_MODULEID_CONF_ID_MASK 0x3 > > +#define CQSPI_REG_MODULEID_CONF_ID_LSB 0 > > +#define CQSPI_REG_MODULEID_CONF_ID_OCTAL_PHY 0x0 > > +#define CQSPI_REG_MODULEID_CONF_ID_OCTAL 0x1 > > +#define CQSPI_REG_MODULEID_CONF_ID_QUAD_PHY 0x2 > > +#define CQSPI_REG_MODULEID_CONF_ID_QUAD 0x3 > > + > > /* Interrupt status bits */ > > #define CQSPI_REG_IRQ_MODE_ERR BIT(0) > > #define CQSPI_REG_IRQ_UNDERFLOW BIT(1) > > @@ -866,6 +875,9 @@ static int cqspi_set_protocol(struct spi_nor *nor, const int read) > > case SPI_NOR_QUAD: > > f_pdata->data_width = CQSPI_INST_TYPE_QUAD; > > break; > > + case SPI_NOR_OCTAL: > > + f_pdata->data_width = CQSPI_INST_TYPE_OCTAL; > > + break; > > default: > > return -EINVAL; > > } > > @@ -1074,9 +1086,35 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np) > > struct cqspi_flash_pdata *f_pdata; > > struct spi_nor *nor; > > struct mtd_info *mtd; > > + enum read_mode mode; > > + enum read_mode dt_mode = SPI_NOR_QUAD; > > unsigned int cs; > > + unsigned int rev_reg; > > int i, ret; > > > > + /* Determine, whether or not octal transfer MAY be supported */ > > + rev_reg = readl(cqspi->iobase + CQSPI_REG_MODULEID); > > + dev_info(dev, "CQSPI Module id %x\n", rev_reg); > > + > > + switch (rev_reg & CQSPI_REG_MODULEID_CONF_ID_MASK) { > > + case CQSPI_REG_MODULEID_CONF_ID_OCTAL_PHY: > > + case CQSPI_REG_MODULEID_CONF_ID_OCTAL: > > + mode = SPI_NOR_OCTAL; > > + break; > > + case CQSPI_REG_MODULEID_CONF_ID_QUAD: > > + case CQSPI_REG_MODULEID_CONF_ID_QUAD_PHY: > > + mode = SPI_NOR_QUAD; > > + break; > > + } > > + > > + if (of_property_read_bool(np, "cdns,octal-controller")) > > + dt_mode = SPI_NOR_OCTAL; > > + > > + if (mode == SPI_NOR_QUAD && dt_mode == SPI_NOR_OCTAL) > > + dev_warn(dev, "Requested octal mode is not supported by the device."); > > + else if (mode == SPI_NOR_OCTAL && dt_mode == SPI_NOR_QUAD) > > + mode = SPI_NOR_QUAD; > > + > > /* Get flash device data */ > > for_each_available_child_of_node(dev->of_node, np) { > > ret = of_property_read_u32(np, "reg", &cs); @@ -1123,7 +1161,7 @@ > > static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np) > > goto err; > > } > > > > - ret = spi_nor_scan(nor, NULL, SPI_NOR_QUAD); > > + ret = spi_nor_scan(nor, NULL, mode); > > if (ret) > > goto err; > >