From patchwork Wed Apr 25 18:28:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 10364149 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 960B2601D3 for ; Wed, 25 Apr 2018 18:28:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84A1A287BA for ; Wed, 25 Apr 2018 18:28:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7908E287EA; Wed, 25 Apr 2018 18:28:55 +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 28B75287BA for ; Wed, 25 Apr 2018 18:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756152AbeDYS2m (ORCPT ); Wed, 25 Apr 2018 14:28:42 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:40817 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756307AbeDYS2Q (ORCPT ); Wed, 25 Apr 2018 14:28:16 -0400 Received: by mail-qk0-f195.google.com with SMTP id o64so23413559qkl.7; Wed, 25 Apr 2018 11:28:16 -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=Y7GEtu5kc/50aolN6ZOCcOUiBI/W46g8ey5ac7RGqO8=; b=Bb1b6hAROR4yEsdxZz56pBSzLomYXcgcJw2HdUMlkjggAii28ZV+vH4MAvj7vfGCz1 gldIXkWu68ludCmxBhka/ooVFSFkarlxcRDoJIe4wwsAZs/uMGUWSnGKvlqwy8BN17ue MuWRlf42dwlAfSK+cJF4sNwiDnszgWpdksHQlQ0jIy+lLYCPO2L8j+yS2rgl/FPRM2sl zlvh7BfLbxIfnlkaBNRd+i4MJw4CvIZ+xXEy63rfDeI4+HFCZydDlUrxUXBQE9o49Aez LUeInnz0nBdIhpzxXc+t944STV5WLJg+qQetb1puhx38OPViPksKcQ34Ma/dJlEGKPli jB6A== 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=Y7GEtu5kc/50aolN6ZOCcOUiBI/W46g8ey5ac7RGqO8=; b=M6tDfutelWMiJHHSogfxcAIijFd32RhUD0Z0FvtTQXPTi/vnwoM/bXTnWLJ3OvZh+S wQd1w2trNuDtTp1HLrjWqWswZe2/bl3YdhgA5fag6VjrIVOiRBvnwQ4VMxSYAyA4JTAK bfIIX81VdbkLty/Sll2hsJQPdVG5GBhTkmph60H9TDe6lWpt5aYXm7hY6H+/NGVC7Qly +dmg0DFrUYxi3pwISHrDek8ENqgQLv0pL5+eAcxlpAZCB06qbGBrFG0oAIag2s/Zq2/S VIo+LYLUBadLaxAWqE6VAlvhtsM73aaM8xvTHeBrtFN1sextlEnlzB4zNDhuKePkKKFO 6FRQ== X-Gm-Message-State: ALQs6tBkgveUwvYgFTxaLMqJOxPADmW8Joe6FxvXCgfmGQiAmYM/86xx T/UHChaKejKEHrxnmCc0AJ9K2w== X-Google-Smtp-Source: AIpwx4+EWz5bryOF1a7y+QS3J2AWgVlyQ3re5QHUv9utzSsx9/p9ckNYOXCRPn3lFKK+Er8HBsvl5g== X-Received: by 10.55.119.196 with SMTP id s187mr31177677qkc.171.1524680895927; Wed, 25 Apr 2018 11:28:15 -0700 (PDT) Received: from mail.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id x28-v6sm1980695qtx.95.2018.04.25.11.28.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Apr 2018 11:28:15 -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 v1 1/2] spi: bcm-qspi: Avoid setting MSPI_CDRAM_PCS for spi-nor master Date: Wed, 25 Apr 2018 14:28:04 -0400 Message-Id: <1524680885-4600-2-git-send-email-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524680885-4600-1-git-send-email-kdasu.kdev@gmail.com> References: <1524680885-4600-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. 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);