From patchwork Thu Oct 8 14:45:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 7353261 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AC1099F1B9 for ; Thu, 8 Oct 2015 14:46:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CDF3020522 for ; Thu, 8 Oct 2015 14:46:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEBF32051D for ; Thu, 8 Oct 2015 14:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933489AbbJHOpF (ORCPT ); Thu, 8 Oct 2015 10:45:05 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:33997 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933456AbbJHOpE (ORCPT ); Thu, 8 Oct 2015 10:45:04 -0400 Received: by wicfx3 with SMTP id fx3so31843967wic.1 for ; Thu, 08 Oct 2015 07:45:03 -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:subject:to:organization:message-id:date :user-agent:mime-version:content-type:content-transfer-encoding; bh=HMt72KEmqG3xnsbESHO+w/F3HYpO9drXymrCdU/BcXo=; b=MhmlZAY8yIm+9r7ai0te6XS28tRm9LD/se8Sfy9IkVeybF9EiTLnRCMCXPbdLv3TV4 82wxnKQrBjPiCBuEB2sSQHjyQB2fLTL12DLEP0jekESk74BiO8zflQpsOzyLwLCngUvi Ck/CGcyTXpv+DgFu2AYaIwdfFELsaB77ARueeaDRPS28VBn1FRPt2aE7ik19HeSIHGh3 32XwlaCTmF12ywdc1o17zbOw/p1+SmYNU8lKMkATVzYtG/7YMBuCz6+M+uLUtKVmnU5G EtnVvIHQ0ZU6MlCvFVx5ARHRJ/Gv+h+Gfyo+T6hEhtPyGZLQInZFaUCnnwbN1ZDQru8P fKFQ== X-Gm-Message-State: ALoCoQnGFi7Aq8y2G4nHziO40y2LzgB0mj+XkzlpH1RCyLZodJRRscNym56UYN4HnvPnl/XTWB9o X-Received: by 10.180.207.235 with SMTP id lz11mr2057444wic.1.1444315502954; Thu, 08 Oct 2015 07:45:02 -0700 (PDT) Received: from [192.168.2.52] (LPoitiers-656-1-62-228.w90-63.abo.wanadoo.fr. [90.63.143.228]) by smtp.gmail.com with ESMTPSA id lv4sm46594576wjb.43.2015.10.08.07.45.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Oct 2015 07:45:02 -0700 (PDT) From: Neil Armstrong Subject: [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message To: Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Welling , Fionn Cleary , Wolfram Sang , Jarkko Nikula , Sebastian Reichel Organization: Baylibre Message-ID: <5616816C.9020904@baylibre.com> Date: Thu, 8 Oct 2015 16:45:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 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 Since the "Switch driver to use transfer_one" change, the cs_change behavior has changed and a channel chip select can still be asserted when changing channel from a previous last transfer in s message having the cs_change attribute. Since there is no sense having multiple chip select being asserted at the same time, disable all the remaining forces chip selects in a the prepare_message called right before a spi_transfer_one_message call. This is also a bug fix found in the McSPI into a DM8168 SoC, hanging all the other channels transfers when a CHCONF_FORCE is present. Signed-off-by: Neil Armstrong --- drivers/spi/spi-omap2-mcspi.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) This is a patch RFC following the bug report : 'McSPI hangs with cs_change after "Switch driver to use transfer_one" change' http://permalink.gmane.org/gmane.linux.kernel/2056841 diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 3d09e0b..db1b655 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -1217,6 +1217,33 @@ out: return status; } +static int omap2_mcspi_prepare_message(struct spi_master *master, + struct spi_message *msg) +{ + struct omap2_mcspi *mcspi = spi_master_get_devdata(master); + struct omap2_mcspi_regs *ctx = &mcspi->ctx; + struct omap2_mcspi_cs *cs; + + /* Only a single channel can have the FORCE bit enabled + * in its chconf0 register. + * Scan all channels and disable them. + * A FORCE can remain from a last transfer having cs_change enabled + */ + + /* Ignore message */ + (void)msg; + + list_for_each_entry(cs, &ctx->cs, node) { + if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE)) { + cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE; + writel_relaxed(cs->chconf0, + cs->base + OMAP2_MCSPI_CHCONF0); + } + } + + return 0; +} + static int omap2_mcspi_transfer_one(struct spi_master *master, struct spi_device *spi, struct spi_transfer *t) { @@ -1344,6 +1371,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev) master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32); master->setup = omap2_mcspi_setup; master->auto_runtime_pm = true; + master->prepare_message = omap2_mcspi_prepare_message; master->transfer_one = omap2_mcspi_transfer_one; master->set_cs = omap2_mcspi_set_cs; master->cleanup = omap2_mcspi_cleanup;