From patchwork Mon Apr 6 21:29:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Bresticker X-Patchwork-Id: 6166191 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 19651BF4A6 for ; Mon, 6 Apr 2015 21:37:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BEBD20320 for ; Mon, 6 Apr 2015 21:37:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43BC320303 for ; Mon, 6 Apr 2015 21:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753093AbbDFVhX (ORCPT ); Mon, 6 Apr 2015 17:37:23 -0400 Received: from mail-vn0-f73.google.com ([209.85.216.73]:34078 "EHLO mail-vn0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753086AbbDFVhX (ORCPT ); Mon, 6 Apr 2015 17:37:23 -0400 Received: by vnbf62 with SMTP id f62so2377138vnb.1 for ; Mon, 06 Apr 2015 14:37:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ve5uQrOYCt4q8VX2Bx1dWfIfk8HBT0XpZcfrVYSwE08=; b=dIC58wmCHG1sMQP9mdrSy9hhYmSWeDGMbET3NdJGyi60rORjRQiG0XGlvL5COiiHWz 1SDfsvC7zyHIKVZAgkG44l1eGtvEkswuMuWxfmjCuiYzsxTLJBE/OtVTsSlQMNszrpBB eHKWSCtT8Y/su0DYL1bAURM571u4fGnURbr96eFCj3UwrK5cmLbnMVpXbF5D2o7x1hTo O00xM8wgClvPMVJ9/8myBE6YrtKb7N0gNXl6lTYAQYXZT2ZbOCb9paxlTue6gsrsyWYG rvzAt4I/Plj76vUEEWsc2sCntmakzbsOyX0XvKyBlRf44GMqWkSuX+1dZMsr8BW4ByFN E7PA== X-Gm-Message-State: ALoCoQn2QRlllmTh+rczFN5CRS05WVXU/HrHkFf16WCs5DuqOZc+LHJJxmskPXq+W972zKotElQC X-Received: by 10.236.110.7 with SMTP id t7mr14481567yhg.14.1428355749697; Mon, 06 Apr 2015 14:29:09 -0700 (PDT) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id z21si247447yhc.5.2015.04.06.14.29.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 14:29:09 -0700 (PDT) Received: from abrestic.mtv.corp.google.com ([172.22.65.70]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id tfxy5tIn.1; Mon, 06 Apr 2015 14:29:09 -0700 Received: by abrestic.mtv.corp.google.com (Postfix, from userid 137652) id A608A220DA7; Mon, 6 Apr 2015 14:29:08 -0700 (PDT) From: Andrew Bresticker To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Ezequiel Garcia , Andrew Bresticker Subject: [PATCH 2/5] spi: img-spfi: Implement a prepare_message() callback Date: Mon, 6 Apr 2015 14:29:04 -0700 Message-Id: <1428355747-16822-2-git-send-email-abrestic@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1428355747-16822-1-git-send-email-abrestic@chromium.org> References: <1428355747-16822-1-git-send-email-abrestic@chromium.org> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ezequiel Garcia In preparation for switching to using the SPI core's CS GPIO handling, move setup of the PORT_STATE register, which must be configured before CS is asserted, to a prepare_message() callback. Signed-off-by: Ezequiel Garcia Signed-off-by: Andrew Bresticker --- drivers/spi/spi-img-spfi.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c index 7d18bec..b1c0165 100644 --- a/drivers/spi/spi-img-spfi.c +++ b/drivers/spi/spi-img-spfi.c @@ -397,6 +397,25 @@ stop_dma: return -EIO; } +static int img_spfi_prepare(struct spi_master *master, struct spi_message *msg) +{ + struct img_spfi *spfi = spi_master_get_devdata(master); + u32 val; + + val = spfi_readl(spfi, SPFI_PORT_STATE); + if (msg->spi->mode & SPI_CPHA) + val |= SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select); + else + val &= ~SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select); + if (msg->spi->mode & SPI_CPOL) + val |= SPFI_PORT_STATE_CK_POL(msg->spi->chip_select); + else + val &= ~SPFI_PORT_STATE_CK_POL(msg->spi->chip_select); + spfi_writel(spfi, val, SPFI_PORT_STATE); + + return 0; +} + static void img_spfi_config(struct spi_master *master, struct spi_device *spi, struct spi_transfer *xfer) { @@ -434,18 +453,6 @@ static void img_spfi_config(struct spi_master *master, struct spi_device *spi, &master->cur_msg->transfers)) val |= SPFI_CONTROL_CONTINUE; spfi_writel(spfi, val, SPFI_CONTROL); - - val = spfi_readl(spfi, SPFI_PORT_STATE); - if (spi->mode & SPI_CPHA) - val |= SPFI_PORT_STATE_CK_PHASE(spi->chip_select); - else - val &= ~SPFI_PORT_STATE_CK_PHASE(spi->chip_select); - if (spi->mode & SPI_CPOL) - val |= SPFI_PORT_STATE_CK_POL(spi->chip_select); - else - val &= ~SPFI_PORT_STATE_CK_POL(spi->chip_select); - spfi_writel(spfi, val, SPFI_PORT_STATE); - spfi_writel(spfi, xfer->len << SPFI_TRANSACTION_TSIZE_SHIFT, SPFI_TRANSACTION); } @@ -599,6 +606,7 @@ static int img_spfi_probe(struct platform_device *pdev) master->set_cs = img_spfi_set_cs; master->transfer_one = img_spfi_transfer_one; + master->prepare_message = img_spfi_prepare; spfi->tx_ch = dma_request_slave_channel(spfi->dev, "tx"); spfi->rx_ch = dma_request_slave_channel(spfi->dev, "rx");