Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754033AbbETO4N (ORCPT ); Wed, 20 May 2015 10:56:13 -0400 Received: from mail-bl2on0053.outbound.protection.outlook.com ([65.55.169.53]:5366 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752596AbbETO4I (ORCPT ); Wed, 20 May 2015 10:56:08 -0400 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; gmail.com; dkim=none (message not signed) header.d=none; Date: Wed, 20 May 2015 07:55:53 -0700 From: =?utf-8?B?U8O2cmVu?= Brinkmann To: Ranjit Waghmode CC: , , , , , , , , , , , , , Subject: Re: [RFC PATCH 2/2] spi: Add support for Zynq Ultrascale+ MPSoC GQSPI controller Message-ID: <20150520145552.GV31550@xsjsorenbubuntu> References: <1432106871-27232-1-git-send-email-ranjit.waghmode@xilinx.com> <1432106871-27232-2-git-send-email-ranjit.waghmode@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1432106871-27232-2-git-send-email-ranjit.waghmode@xilinx.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21556.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD044;1:ondsIbxJjL3g4UCTKeatlBzdb0mvSejpjM8Exb9nPKcg/++sQ+a1UtJwm59KOTHBluOML94mTYWe6yTi1URv8PHDFE7IiL6LpdC3s2tcr+DNo1DzGjxKdDVf3Hew4+FFzqK/Zy53H/fY4jWsIHD330+tDg7dzdfAKUbwNYyiKlIAmdzIufNaNi5G6zGzUgG/xbuvzZnJ/Qhv8+dKLKtAPpMdI9SyRosyaRf/+RPGPpJ819TRpB0QgbG1vkhTUIJJ4A2ss0D9t59fYohnksJKYohRlYAEg1YFjb8NqpDvidH9WprQSjr2BMdJwrbLZ2AE X-Forefront-Antispam-Report: CIP:149.199.60.83;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(438002)(189002)(24454002)(164054003)(199003)(51704005)(377424004)(63266004)(76506005)(50986999)(57986006)(87936001)(92566002)(85182001)(77156002)(62966003)(50466002)(33656002)(77096005)(189998001)(110136002)(5001960100002)(81156007)(4001540100001)(4001350100001)(5001830100001)(64706001)(47776003)(5001860100001)(19580395003)(19580405001)(86362001)(6806004)(54356999)(2950100001)(76176999)(36386004)(106466001)(85202003)(46102003)(33716001)(83506001)(23676002)(107986001)(4001450100001)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2FFO11HUB032;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;PTR:unknown-60-83.xilinx.com;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11HUB032;2:OBsVVUJQfRbKL6wFLHjjoGXrKs9ub+6JsgkCGLBMSLQxhb3+ECH42TmUGMG9o9Qj;2:1W0/ZS3uDXVMMYYBfM/KAr87wXjKQfHzwBH3KgkqjPxfDIBbph8C/QyrN8tZogY0GQ7eESqcvjWNBpKujSWW79xN3ft0la9mXfUUpxegpgzCvuee2/zgj6ej78OymfWu6xRbGY1G5983D87O99VHwgXCl8viMmn3GVvlNjLt5ykivDK+em/OblKh4SSsa24ZPc3UhFjidZgfyWw95kK5p/gS+s+9AyjaqitfUxwtkGk=;6:tIHy7DY34EiGYSfjvv5xnGdAgEtnBiA3ZT9+MS4iNToBCEcacU1MfJsDEshZYOV2HRstPgpue+Gtpd8KRks0zvyn+n3Y7Cy3mgNM/tATIp0fZMUJMb/szHxY3p3UdlNVsuYJkdeIUW9R8oFoRTB8WbzUxaKpafF/H75+I7Uq0L08QhLSbMWbSlmKkmY+ZKJqTMFuxRCFxV9jnKbedxEDvCdOPHvVTIdUa769vYobhyCAd4fhK061OZFP+LYcDCfsXgOMDNVY5NaOfrslfDItrcituQ8T/PyJ7tB/cxdiFDwcgKP1qlj7nf16UFqIVauBr0LLlZ7Yh46KZTQ3msD7A75dCq+uQONFNq/nNwDfTEGKVD+c4QxNw0dUixrlAb5ge/8TAhxfSjsjC0+3A+nqVGohayHRQ6++4eSu9NTfr2Tfs02BQxiecxgXutaYbFvvtt8KCJVRsllgSQA4oJ/hvp/eMbr50l5JPmygo985bzzPqKkgTi/QNRyklRz7cDQB X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2FFO11HUB032; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BY2FFO11HUB032;BCL:0;PCL:0;RULEID:;SRVR:BY2FFO11HUB032; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11HUB032;3:lKMMHOG8sB6dR8JmJUjOS5+xGCpcdRSMUL6ocrKdTd9UuI1780hXEr1SUEzsGDnZy5xlH3ojb/7y+oEJpdgL7mvfuD3XfLOJlhzIyHz+Z3THobEmZt4XpwVwgMpgEeYyjC1lVgSJSy3ZkU7Jj/yiql4PLIpVGy/MibvWc4M8PD+A4MPlIrRGW29wwpY7tmG/n34aQgH8vgMyj539TmC2QSr5KtNAqx2Fad/+risfr+MjPY4Yr6TTO1ZIsQ4E+ONoqnlDcbjYURu/EJj5E6AQHlTzknAU/zPrcWFLxIRlic0= X-Forefront-PRVS: 0582641F53 X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJGRk8xMUhVQjAzMjs5OlZaWEQzMUkwbExXc050QW04aWd1eENTc3JH?= =?utf-8?B?MGVaT2djQjBxTXJ4Wmo5ellxclpNYkxRRUJoY3pFY0pIZEJjN1Q3RHA3b1Ra?= =?utf-8?B?Vjd0NjgrK0RFQWpHYnFoelJpRUZlZ2lWdVo2UnZucH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: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2015 14:56:04.6934 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2FFO11HUB032 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5324 Lines: 173 Hi Ranjit, On Wed, 2015-05-20 at 12:57PM +0530, Ranjit Waghmode wrote: > This patch adds support for GQSPI controller driver used by > Zynq Ultrascale+ MPSoC > > Signed-off-by: Ranjit Waghmode > --- [...] > +/** > + * zynqmp_gqspi_read: For GQSPI controller read operation > + * @xqspi: Pointer to the zynqmp_qspi structure > + * @offset: Offset from where to read > + */ > +static u32 zynqmp_gqspi_read(struct zynqmp_qspi *xqspi, u32 offset) > +{ > + return readl_relaxed(xqspi->regs + offset); > +} > + > +/** > + * zynqmp_gqspi_write: For GQSPI controller write operation > + * @xqspi: Pointer to the zynqmp_qspi structure > + * @offset: Offset where to write > + * @val: Value to be written > + */ > +static inline void zynqmp_gqspi_write(struct zynqmp_qspi *xqspi, u32 offset, > + u32 val) > +{ > + writel_relaxed(val, (xqspi->regs + offset)); > +} why are you wrapping (readl|writel)_relaxed? [...] > +/** > + * zynqmp_qspi_copy_read_data: Copy data to RX buffer > + * @xqspi: Pointer to the zynqmp_qspi structure > + * @data: The 32 bit variable where data is stored > + * @size: Number of bytes to be copied from data to RX buffer > + */ > +static void zynqmp_qspi_copy_read_data(struct zynqmp_qspi *xqspi, > + u32 data, u8 size) > +{ > + memcpy(xqspi->rxbuf, ((u8 *) &data), size); Is this cast really needed? IIRC, memcpy takes (void *). The outer parentheses for that argument are not needed. > + xqspi->rxbuf += size; > + xqspi->bytes_to_receive -= size; > +} > + > +/** > + * zynqmp_prepare_transfer_hardware: Prepares hardware for transfer. > + * @master: Pointer to the spi_master structure which provides > + * information about the controller. > + * > + * This function enables SPI master controller. > + * > + * Return: Always 0 > + */ > +static int zynqmp_prepare_transfer_hardware(struct spi_master *master) > +{ > + struct zynqmp_qspi *xqspi = spi_master_get_devdata(master); > + > + clk_enable(xqspi->refclk); > + clk_enable(xqspi->pclk); Did you consider using runtime_pm? Then this would just bit pm_runtime_get_sync(...) > + zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, GQSPI_EN_MASK); > + return 0; > +} > + > +/** > + * zynqmp_unprepare_transfer_hardware: Relaxes hardware after transfer > + * @master: Pointer to the spi_master structure which provides > + * information about the controller. > + * > + * This function disables the SPI master controller. > + * > + * Return: Always 0 > + */ > +static int zynqmp_unprepare_transfer_hardware(struct spi_master *master) > +{ > + struct zynqmp_qspi *xqspi = spi_master_get_devdata(master); > + > + zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, 0x0); > + clk_disable(xqspi->refclk); > + clk_disable(xqspi->pclk); and this would become pm_runtime_put() [...] > +/** > + * zynqmp_qspi_filltxfifo: Fills the TX FIFO as long as there is room in > + * the FIFO or the bytes required to be > + * transmitted. > + * @xqspi: Pointer to the zynqmp_qspi structure > + * @size: Number of bytes to be copied from TX buffer to TX FIFO > + */ > +static void zynqmp_qspi_filltxfifo(struct zynqmp_qspi *xqspi, int size) > +{ > + u32 count = 0; > + > + while ((xqspi->bytes_to_transfer > 0) && (count < size)) { > + writel(*((u32 *) xqspi->txbuf), xqspi->regs + GQSPI_TXD_OFST); Here the writel wrapper is not used. Is there a reason, then it would probably deserve a comment. [...] > +/** > + * zynqmp_process_dma_irq: Handler for DMA done interrupt of QSPI > + * controller > + * @xqspi: zynqmp_qspi instance pointer > + * > + * This function handles DMA interrupt only. > + */ > +static void zynqmp_process_dma_irq(struct zynqmp_qspi *xqspi) > +{ > + u32 config_reg, genfifoentry; > + > + dma_unmap_single(xqspi->dev, xqspi->dma_addr, > + xqspi->dma_rx_bytes, DMA_FROM_DEVICE); > + xqspi->rxbuf += xqspi->dma_rx_bytes; > + xqspi->bytes_to_receive -= xqspi->dma_rx_bytes; > + xqspi->dma_rx_bytes = 0; > + > + /* Disabling the DMA interrupts */ > + writel(GQSPI_QSPIDMA_DST_I_EN_DONE_MASK, > + xqspi->regs + GQSPI_QSPIDMA_DST_I_DIS_OFST); > + > + if (xqspi->bytes_to_receive > 0) { > + /* Switch to IO mode,for remaining bytes to receive */ > + config_reg = readl(xqspi->regs + GQSPI_CONFIG_OFST); > + config_reg &= ~GQSPI_CFG_MODE_EN_MASK; > + writel(config_reg, xqspi->regs + GQSPI_CONFIG_OFST); > + > + /* Initiate the transfer of remaining bytes */ > + genfifoentry = xqspi->genfifoentry; > + genfifoentry |= xqspi->bytes_to_receive; > + writel(genfifoentry, > + xqspi->regs + GQSPI_GEN_FIFO_OFST); > + > + /* Dummy generic FIFO entry */ > + writel(0x0, xqspi->regs + GQSPI_GEN_FIFO_OFST); not using wrapper? > + > + /* Manual start */ > + zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, > + (readl(xqspi->regs + GQSPI_CONFIG_OFST) | not using wrapper? Overall: The usage of those readl/writel wrappers seems inconsistent to me. I usually prefer not wrapping things like that at all but at least it should be consistent. And I believe the handling of clocks would benefit from using of the runtime_pm framework. Thanks, Sören -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/