From patchwork Thu Apr 26 18:48:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 10366687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4C3C9602DC for ; Thu, 26 Apr 2018 18:48:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CE6228AFB for ; Thu, 26 Apr 2018 18:48:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3122228B7A; Thu, 26 Apr 2018 18:48:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE18C28AFB for ; Thu, 26 Apr 2018 18:48:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755029AbeDZSs1 (ORCPT ); Thu, 26 Apr 2018 14:48:27 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:37209 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753145AbeDZSsZ (ORCPT ); Thu, 26 Apr 2018 14:48:25 -0400 Received: by mail-qk0-f194.google.com with SMTP id d74so26442669qkg.4; Thu, 26 Apr 2018 11:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gHyQ5b97I/YU6oZFdIQ/NWwKv5tMMfAaNN3XyDN5D4w=; b=hgOUmHSZS9QEu+RMnIOaWqhZDVpLuVvr44FaZrKluDuuv23527/83cGbVpSX9Sczxb cVNeC98QmoRu1b8k3ikKoqcMj8v+N+f3GzYfH3CLjpFLdW7snCbpDvDFpEGnb072h+PU BFOy0bP5y/UCh7AE7gvbcbPof/mvW44nWEfe5S3Wr6ZfzuAgWJtes3u5DRsK0+BCfqCW /hrFXTFSSUUdxgkZJsGZCP+Z1sZzOVHxK0s4OXYnCZ1yrhg2RbCQswfcrObONc1m6k5l YN+gqDjoCFoHT/DZiqzykHdoGgS6UGtCMtoAyg7o6Rb6vXPLHl8J8MyymvBVy1/t4D5B hPHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gHyQ5b97I/YU6oZFdIQ/NWwKv5tMMfAaNN3XyDN5D4w=; b=p1E9NzdEHYq3OsOo8brUHmXb4Eq7KB45C4jClIEuxl25Eb5z/LCw99DaWKS2KxwmJo EgapwLu9FUMWqYSy4wk0pLZTiRlmCPRZN4Nj7cN2nxkTik1DqoBtOdbZFvAjjOCotxx7 FdLTxPNA+fzm0ycPsd1WgdOj1U+viHojZNIxelZJFU0SG+YmYytBAVMDpPqHGF0i84ux 5VCJZ3NCQ7mHJdEL6SvBcqMMHpm2UuKUB6fvQvz0RN/qbJxYaBzvgJ8vCgHZbtQfbER0 oUsaS3yjLiCnQxqXdNLUS/K+qp2X6ZhbsDxwkOzdZ6AW2WAjJb8V23KvvgFrcURd7S+Z Lpag== X-Gm-Message-State: ALQs6tDbz05Z8/JbgQA4xk4groiGqFqG1SyqKdLLtCD+qkbsocB6lr8g Y4lKbRoTSrqr6lJjVBXXscc= X-Google-Smtp-Source: AB8JxZof+dRsZYe0niXm8hlR8aJk0o/wWPCwDQsQzRGd4k7h3wBfUJTDdQ1aeRCHWvYNhTUAININYA== X-Received: by 10.55.132.130 with SMTP id g124mr37386525qkd.226.1524768504496; Thu, 26 Apr 2018 11:48:24 -0700 (PDT) Received: from mail.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id k43-v6sm17970058qtc.5.2018.04.26.11.48.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Apr 2018 11:48:23 -0700 (PDT) From: Kamal Dasu To: broonie@kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, jon.mason@broadcom.com, yendapally.reddy@broadcom.com, Kamal Dasu Subject: [PATCH v2 1/2] spi: bcm-qspi: Avoid setting MSPI_CDRAM_PCS for spi-nor master Date: Thu, 26 Apr 2018 14:48:00 -0400 Message-Id: <1524768481-16347-2-git-send-email-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524768481-16347-1-git-send-email-kdasu.kdev@gmail.com> References: <1524768481-16347-1-git-send-email-kdasu.kdev@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added fix for probing of spi-nor device non-zero chip selects. Set MSPI_CDRAM_PCS (peripheral chip select) with spi master for MSPI controller and not for MSPI/BSPI spi-nor master controller. Ensure setting of cs bit in chip select register on chip select change. Fixes: fa236a7ef24048 ("spi: bcm-qspi: Add Broadcom MSPI driver") Signed-off-by: Kamal Dasu --- drivers/spi/spi-bcm-qspi.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c index 1596d35..2946989 100644 --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -519,16 +519,19 @@ static void bcm_qspi_disable_bspi(struct bcm_qspi *qspi) static void bcm_qspi_chip_select(struct bcm_qspi *qspi, int cs) { - u32 data = 0; + u32 rd = 0; + u32 wr = 0; - if (qspi->curr_cs == cs) - return; if (qspi->base[CHIP_SELECT]) { - data = bcm_qspi_read(qspi, CHIP_SELECT, 0); - data = (data & ~0xff) | (1 << cs); - bcm_qspi_write(qspi, CHIP_SELECT, 0, data); + rd = bcm_qspi_read(qspi, CHIP_SELECT, 0); + wr = (rd & ~0xff) | (1 << cs); + if (rd == wr) + return; + bcm_qspi_write(qspi, CHIP_SELECT, 0, wr); usleep_range(10, 20); } + + dev_dbg(&qspi->pdev->dev, "using cs:%d\n", cs); qspi->curr_cs = cs; } @@ -755,8 +758,13 @@ static int write_to_hw(struct bcm_qspi *qspi, struct spi_device *spi) dev_dbg(&qspi->pdev->dev, "WR %04x\n", val); } mspi_cdram = MSPI_CDRAM_CONT_BIT; - mspi_cdram |= (~(1 << spi->chip_select) & - MSPI_CDRAM_PCS); + + if (has_bspi(qspi)) + mspi_cdram &= ~1; + else + mspi_cdram |= (~(1 << spi->chip_select) & + MSPI_CDRAM_PCS); + mspi_cdram |= ((tp.trans->bits_per_word <= 8) ? 0 : MSPI_CDRAM_BITSE_BIT);