From patchwork Sun Apr 19 19:23:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 214741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B04C1C38A30 for ; Sun, 19 Apr 2020 19:26:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8935821473 for ; Sun, 19 Apr 2020 19:26:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KHrhNz9e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726181AbgDST0O (ORCPT ); Sun, 19 Apr 2020 15:26:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbgDST0N (ORCPT ); Sun, 19 Apr 2020 15:26:13 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4822C061A0C; Sun, 19 Apr 2020 12:26:13 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id x26so3945351pgc.10; Sun, 19 Apr 2020 12:26:13 -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=MryED8uai1n3gclYsGl5qk+GTHUCazZ5O/sEZ7i7aTw=; b=KHrhNz9eW2SEE10dN9YUDkj+Ug7Reo0bS49H4hagifMITN32wf7w38RTWZh8FgBLzp Ze8EXPb7NdEYMbBLJlMO+wc+CfhSvGJ0NM3kdOa7K1ttzItHClDETecWsi/eQ2UGGA4P eQpxI+w+bRUKdGBkKMTOGPU/r6sVcZJZ3mZ11jpIQZzXmFBQim0yemDodqOGOz3+n49J u1oDBQYQHRunfftqt/321rwt4f2d9RabY8OdJe+KpqEanDUlv2WBq64eIRiIRHYgixgd abjoJwce/1rVuIxVG0w0Jo3WwM5AwgMNPKsqdwCFfMlDIqMbvY2gYx6etyhTvfdgo5C5 lvyw== 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=MryED8uai1n3gclYsGl5qk+GTHUCazZ5O/sEZ7i7aTw=; b=RpEFTTdj9108n/uvKfEOnzXKRPH4qdkvWwJ6B2YDYWZ4lBJzSSIF+JqrBYDJQUOjCR tirZ22SPszYEK3CCDufTZZesZ/Ye7M3euFT6krby9mC4bVLbqRJvq4nMU65Pk0bogTRi hs1pCNCdd3eht1rWiws1B6B84IXMHggsafYkOmLL0zg4BiyDxIfTswTFwoRdpgnmw91L 1IElPgFShe/GQcOxDK7Sbzlg9TDub2VFr9JRqH2wthTzUmAfoINmJA1WqCjgu1TcCGKs YfHXat38d06M38RD3R5S2N0ZW9IOSazRHVbZyKkMAe/JuYb01pEcyfQcNi8sRVPIy9NF 5BBQ== X-Gm-Message-State: AGi0PuYdjhAbStRIdYC0BpFqS1nPIfVphc2lBCPJ7lunYaxWvHFLZ8WD frcIYYD1WAgYQibEOyqKXE4= X-Google-Smtp-Source: APiQypJq57LDtDw5YkhAyu3co9ZJlm0e2Zx8UQb5qRrl36rguXOG17PZM06e+tqpYWCqGOa438Wv0A== X-Received: by 2002:a62:5b02:: with SMTP id p2mr14019001pfb.14.1587324373535; Sun, 19 Apr 2020 12:26:13 -0700 (PDT) Received: from mail.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id x16sm22724383pfm.146.2020.04.19.12.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 12:26:13 -0700 (PDT) From: Kamal Dasu To: Kamal Dasu , bcm-kernel-feedback-list@broadcom.com, Mark Brown Cc: Florian Fainelli , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Patch v2 1/9] spi: bcm-qspi: Handle clock probe deferral Date: Sun, 19 Apr 2020 15:23:30 -0400 Message-Id: <20200419192339.32023-2-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200419192339.32023-1-kdasu.kdev@gmail.com> References: <20200419192339.32023-1-kdasu.kdev@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org From: Florian Fainelli The clock provider may not be ready by the time spi-bcm-qspi gets probed, handle probe deferral using devm_clk_get_optional(). Signed-off-by: Florian Fainelli Signed-off-by: Kamal Dasu --- drivers/spi/spi-bcm-qspi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c index 23d295f36c80..74f4579c3f6a 100644 --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -1222,6 +1222,11 @@ int bcm_qspi_probe(struct platform_device *pdev, } qspi = spi_master_get_devdata(master); + + qspi->clk = devm_clk_get_optional(&pdev->dev, NULL); + if (IS_ERR(qspi->clk)) + return PTR_ERR(qspi->clk); + qspi->pdev = pdev; qspi->trans_pos.trans = NULL; qspi->trans_pos.byte = 0; @@ -1335,13 +1340,6 @@ int bcm_qspi_probe(struct platform_device *pdev, qspi->soc_intc = NULL; } - qspi->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(qspi->clk)) { - dev_warn(dev, "unable to get clock\n"); - ret = PTR_ERR(qspi->clk); - goto qspi_probe_err; - } - ret = clk_prepare_enable(qspi->clk); if (ret) { dev_err(dev, "failed to prepare clock\n"); From patchwork Sun Apr 19 19:23:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 214740 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E80B7C38A30 for ; Sun, 19 Apr 2020 19:26:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C825021473 for ; Sun, 19 Apr 2020 19:26:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XT+jzKHa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbgDST0Z (ORCPT ); Sun, 19 Apr 2020 15:26:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbgDST0Z (ORCPT ); Sun, 19 Apr 2020 15:26:25 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC1AC061A0C; Sun, 19 Apr 2020 12:26:24 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id z6so3109204plk.10; Sun, 19 Apr 2020 12:26:24 -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=EIIHKZMgTWABWvESzFrAqsSQGXH1JTpkYBryS5d6Pco=; b=XT+jzKHaK5SVWB6gicZu+lr91WVIW4wWf0r+vrst293ul4N0j0jjek4P0QbjtGL4GF Y/xaBs23rrJbRn+SlLDP4T3wOuO0Vcq5XwjaIyXpKNsWOcK23VQ3XRtDs0gvWxneBFIR QwQgvDhVGFucgrxOhHGRk0ln58AP6hHZXxpJW5c3RqDJZfloIpO5EBWmPpl8pnFadUSZ PMF6Wc9+YptU/hPKuqMogc6cHh19RIo2SFtSvOFPS6CY011wfwMGucigRngWhuaVKzip 71CB4osOMiMLPNl9fqZisXnCmc/n4yW1rWPXQ4TrMTeIN+aVZdfPqmoGwTvEPYMyCh9n wDIQ== 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=EIIHKZMgTWABWvESzFrAqsSQGXH1JTpkYBryS5d6Pco=; b=uXNhGAWluGFfPeteru0Oc6fTWrunvi8o8HXpyqUbj7qS4mHQxWXRgZqFN5Yr6/slnf 3XbN3+op/aVRDeo56h/gFjwT6emJvRy1D9+/wPOA92c+Jvl3vD3esj5GO0sIvkEsX6GI b/aDhue4/jndZeE/OaJeGVaKLNbgF49+tvZY32WdjuzghPrcowR3j+sC+XHHADO7CiLC XIW9QbsuEIctNeWlIhBFmndNluatFcq7+cjBOftxd422/Sc+eg10ymItuKpjK1z/Hr1P hmzyIXaJj4vPl6uSI0MKncWvevCsjTq/ktcD3QhEvKAtFnZFaDcWOnOWJKUDw8iw0++S ZNDw== X-Gm-Message-State: AGi0PuYw8c0cbrSqkmeLPvBCwbOjNT2/7v5dBiRS5jVjeWlGXNJK2sKa zxEzIfeQ3xRXh1u6XEH60c2x7HSb7DY= X-Google-Smtp-Source: APiQypLyQ5do3SL+G7zAadYK6KCsVBohPJxwZuNCSVdeZkRJeBDto2hYQNAv3EcNORlBYQUvvPkMjA== X-Received: by 2002:a17:90a:94c8:: with SMTP id j8mr17770173pjw.155.1587324384521; Sun, 19 Apr 2020 12:26:24 -0700 (PDT) Received: from mail.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id x16sm22724383pfm.146.2020.04.19.12.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 12:26:24 -0700 (PDT) From: Kamal Dasu To: Kamal Dasu , bcm-kernel-feedback-list@broadcom.com, Mark Brown Cc: Florian Fainelli , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Patch v2 3/9] spi: bcm-qspi: Handle lack of MSPI_REV offset Date: Sun, 19 Apr 2020 15:23:32 -0400 Message-Id: <20200419192339.32023-4-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200419192339.32023-1-kdasu.kdev@gmail.com> References: <20200419192339.32023-1-kdasu.kdev@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Older MIPS chips have a QSPI/MSPI controller that does not have the MSPI_REV offset, reading from that offset will cause a bus error. Match their compatible string and do not perform a read from that register in that case. Signed-off-by: Florian Fainelli Signed-off-by: Kamal Dasu --- drivers/spi/spi-bcm-qspi.c | 50 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c index 74f4579c3f6a..d901dcb10d06 100644 --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -91,6 +91,7 @@ #define MSPI_MSPI_STATUS 0x020 #define MSPI_CPTQP 0x024 #define MSPI_SPCR3 0x028 +#define MSPI_REV 0x02c #define MSPI_TXRAM 0x040 #define MSPI_RXRAM 0x0c0 #define MSPI_CDRAM 0x140 @@ -217,6 +218,8 @@ struct bcm_qspi { struct bcm_qspi_dev_id *dev_ids; struct completion mspi_done; struct completion bspi_done; + u8 mspi_maj_rev; + u8 mspi_min_rev; }; static inline bool has_bspi(struct bcm_qspi *qspi) @@ -1190,8 +1193,35 @@ static const struct spi_controller_mem_ops bcm_qspi_mem_ops = { .exec_op = bcm_qspi_exec_mem_op, }; +struct bcm_qspi_data { + bool has_mspi_rev; +}; + +static const struct bcm_qspi_data bcm_qspi_no_rev_data = { + .has_mspi_rev = false, +}; + +static const struct bcm_qspi_data bcm_qspi_rev_data = { + .has_mspi_rev = true, +}; + static const struct of_device_id bcm_qspi_of_match[] = { - { .compatible = "brcm,spi-bcm-qspi" }, + { + .compatible = "brcm,spi-bcm7425-qspi", + .data = &bcm_qspi_no_rev_data, + }, + { + .compatible = "brcm,spi-bcm7429-qspi", + .data = &bcm_qspi_no_rev_data, + }, + { + .compatible = "brcm,spi-bcm7435-qspi", + .data = &bcm_qspi_no_rev_data, + }, + { + .compatible = "brcm,spi-bcm-qspi", + .data = &bcm_qspi_rev_data, + }, {}, }; MODULE_DEVICE_TABLE(of, bcm_qspi_of_match); @@ -1199,12 +1229,15 @@ MODULE_DEVICE_TABLE(of, bcm_qspi_of_match); int bcm_qspi_probe(struct platform_device *pdev, struct bcm_qspi_soc_intc *soc_intc) { + const struct of_device_id *of_id = NULL; + const struct bcm_qspi_data *data; struct device *dev = &pdev->dev; struct bcm_qspi *qspi; struct spi_master *master; struct resource *res; int irq, ret = 0, num_ints = 0; u32 val; + u32 rev = 0; const char *name = NULL; int num_irqs = ARRAY_SIZE(qspi_irq_tab); @@ -1212,9 +1245,12 @@ int bcm_qspi_probe(struct platform_device *pdev, if (!dev->of_node) return -ENODEV; - if (!of_match_node(bcm_qspi_of_match, dev->of_node)) + of_id = of_match_node(bcm_qspi_of_match, dev->of_node); + if (!of_id) return -ENODEV; + data = of_id->data; + master = spi_alloc_master(dev, sizeof(struct bcm_qspi)); if (!master) { dev_err(dev, "error allocating spi_master\n"); @@ -1349,6 +1385,16 @@ int bcm_qspi_probe(struct platform_device *pdev, qspi->base_clk = clk_get_rate(qspi->clk); qspi->max_speed_hz = qspi->base_clk / (QSPI_SPBR_MIN * 2); + if (data->has_mspi_rev) { + rev = bcm_qspi_read(qspi, MSPI, MSPI_REV); + /* some older revs do not have a MSPI_REV register */ + if ((rev & 0xff) == 0xff) + rev = 0; + } + + qspi->mspi_maj_rev = (rev >> 4) & 0xf; + qspi->mspi_min_rev = rev & 0xf; + bcm_qspi_hw_init(qspi); init_completion(&qspi->mspi_done); init_completion(&qspi->bspi_done); From patchwork Sun Apr 19 19:23:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 214739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52E7DC3A5A9 for ; Sun, 19 Apr 2020 19:26:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3330421473 for ; Sun, 19 Apr 2020 19:26:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SbNR+P3+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726639AbgDST0d (ORCPT ); Sun, 19 Apr 2020 15:26:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbgDST0c (ORCPT ); Sun, 19 Apr 2020 15:26:32 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2FC4C061A0C; Sun, 19 Apr 2020 12:26:32 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id g6so3940316pgs.9; Sun, 19 Apr 2020 12:26:32 -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=ZyjxQT2w1tfyUymmhQNajH9/aDxm1dT9gvQiJybw7YI=; b=SbNR+P3+DzUaYoMTXySguBEbHaoi7SjpqNp5dYAr3yiGKfJL4gvu/P/IXx2ODmQtHk pIUIQ69qeNi17uHyLJZPdbqHymXPzlk7MZAXM6huy1FClnOaW4en3tmUrizjOOqS318c tTfSEA/3HJuZUffpMdWzQ/XDubaAVpPzPNB0f93746/MczPL14OwrYwX4jLjN8NA7YLX JZg4nNqN7Uqhb9XgvzJsKfFkKbS2a+w0htvWcqzCG657zCkUdStuYO65OQHR99MBv9Fz D1cAdkDq+n+NF01Gyl6WCPANyz1tgzm2IRbkZhntx2Tdhwqm4LG1UJdrOFUgYjAO8y6R 0wfQ== 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=ZyjxQT2w1tfyUymmhQNajH9/aDxm1dT9gvQiJybw7YI=; b=fIvREhUY1RayoYHV0Qm3jAo2XSdpMuqDyj49bq00iBU9gZXDmPvh5tdYBgQW4pYo6Q HM4D2NQkeNWuwISCyZmW99swfc+Z3yUWrcmpGiVFG13fsykV+8VRiOL7UJjvtlihMRv+ 70T8eUIVaoNJkOhZIH3Bp7elqcTtfP/qP4oKpN8pguHIRmAYY5rnCC4sBWDipngYuNBQ YKH392Oy9tKcbzrT8BQ5OhKOln2ux6GE7SRTXdWcMk2NDJ345oqeVfjweD3E2sBH6tXm UHashSFeniUPM71D9AqE1pK9up6HbtUQXZGvVSonCnsYw8PorIa9rJnymuQMTOFHpBEU +RrQ== X-Gm-Message-State: AGi0PuaPmIVzGncQrD9YleZSN7N1uCIZC3oqqcTXPMJmscAtPs159CBN +Ev/+LgxfZpSVrthTX8hwOI= X-Google-Smtp-Source: APiQypKsdOTntybjWMD089prmwm7q76XargHK9vFToamg6AnCEAsLZsfFjVNZMNyoOwnxbTtMHv/Lg== X-Received: by 2002:a62:3784:: with SMTP id e126mr13474412pfa.303.1587324392241; Sun, 19 Apr 2020 12:26:32 -0700 (PDT) Received: from mail.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id x16sm22724383pfm.146.2020.04.19.12.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 12:26:31 -0700 (PDT) From: Kamal Dasu To: Kamal Dasu , bcm-kernel-feedback-list@broadcom.com, Mark Brown Cc: Justin Chen , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Patch v2 5/9] spi: bcm-qspi: when tx/rx buffer is NULL set to 0 Date: Sun, 19 Apr 2020 15:23:34 -0400 Message-Id: <20200419192339.32023-6-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200419192339.32023-1-kdasu.kdev@gmail.com> References: <20200419192339.32023-1-kdasu.kdev@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org From: Justin Chen Currently we set the tx/rx buffer to 0xff when NULL. This causes problems with some spi slaves where 0xff is a valid command. Looking at other drivers, the tx/rx buffer is usually set to 0x00 when NULL. Following this convention solves the issue. Fixes: fa236a7ef240 ("spi: bcm-qspi: Add Broadcom MSPI driver") Signed-off-by: Justin Chen Signed-off-by: Kamal Dasu --- drivers/spi/spi-bcm-qspi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c index c48c399dce53..e00208801c8b 100644 --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -669,7 +669,7 @@ static void read_from_hw(struct bcm_qspi *qspi, int slots) if (buf) buf[tp.byte] = read_rxram_slot_u8(qspi, slot); dev_dbg(&qspi->pdev->dev, "RD %02x\n", - buf ? buf[tp.byte] : 0xff); + buf ? buf[tp.byte] : 0x0); } else { u16 *buf = tp.trans->rx_buf; @@ -677,7 +677,7 @@ static void read_from_hw(struct bcm_qspi *qspi, int slots) buf[tp.byte / 2] = read_rxram_slot_u16(qspi, slot); dev_dbg(&qspi->pdev->dev, "RD %04x\n", - buf ? buf[tp.byte] : 0xffff); + buf ? buf[tp.byte / 2] : 0x0); } update_qspi_trans_byte_count(qspi, &tp, @@ -732,13 +732,13 @@ static int write_to_hw(struct bcm_qspi *qspi, struct spi_device *spi) while (!tstatus && slot < MSPI_NUM_CDRAM) { if (tp.trans->bits_per_word <= 8) { const u8 *buf = tp.trans->tx_buf; - u8 val = buf ? buf[tp.byte] : 0xff; + u8 val = buf ? buf[tp.byte] : 0x00; write_txram_slot_u8(qspi, slot, val); dev_dbg(&qspi->pdev->dev, "WR %02x\n", val); } else { const u16 *buf = tp.trans->tx_buf; - u16 val = buf ? buf[tp.byte / 2] : 0xffff; + u16 val = buf ? buf[tp.byte / 2] : 0x0000; write_txram_slot_u16(qspi, slot, val); dev_dbg(&qspi->pdev->dev, "WR %04x\n", val); From patchwork Sun Apr 19 19:23:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 214738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22F7BC54F70 for ; Sun, 19 Apr 2020 19:26:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01D2C21927 for ; Sun, 19 Apr 2020 19:26:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lpQPoGP4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726710AbgDST0j (ORCPT ); Sun, 19 Apr 2020 15:26:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbgDST0j (ORCPT ); Sun, 19 Apr 2020 15:26:39 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 185D2C061A0C; Sun, 19 Apr 2020 12:26:39 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id b8so3867982pfp.8; Sun, 19 Apr 2020 12:26:39 -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=4OZ96LAcwn+BELPZteh+FF1ZZG0PwSRcuJ8BBRDIlsU=; b=lpQPoGP4sSuN9BOnLgX6l3QtHRrFIChBDmplJ++Qin3OrDe/KRWlOLKowP19c9hgcP 7+8X10P5ogvOFrqOT4r2UQkhDEhLaAEETFHNAGMn+rXiBcLx6d2Ifr+L2ax00//UHLTo 4ZrOxCRwKB95ghv0d9+Wj/pi0NWPhNpZWSQRsP+0y2A2za3TKaJRBLwa9OjfZr+Tel4e KxlCbM1HX6QBU7mdERGvblNZim73WtXyvIe6YY65Ia2QnGB2aM0PEtDaFKwFtNqahBJZ iKQQxuQdMPjAjuuUIvIhXP2WLERyb24mbHcknjxv8zilqjjTflDfTARkKfCPdmk8EdwL LcfQ== 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=4OZ96LAcwn+BELPZteh+FF1ZZG0PwSRcuJ8BBRDIlsU=; b=qYUExDJ6a9GxZtMjNogYlJz/lyN3R6IOs8bHmedbSTwB4t7HVyJNQd2Uy1u48YFb5M bF2AMD3q53OA2LPNqIvzzMWYmV9MBNIxLPNDBYV+6YZd/ucjZVyU5Rs7RlV5NIoPN10F bQnEZ1FrBkUzLt8LRcz4UEZrsY08HwI0fL1oRyBQmi55xHM2V0Cwj0IXO//Z++BicfEo NCDLbIsIpgYATPAa7G4Xi4cm0mOcmWN6IWGSHXoVHC42TrCP9V6mDtIWDo+xsKAVZMAZ P9MPmS1hlvo5jxqkEyF7hEE7d96ZRPwFBDetGl5ISIT6jP4z5Jy9TF13yL8fLvDM3SfB bP4w== X-Gm-Message-State: AGi0Pubac326E6Fki24LTwuKnCrc9aA3hnyUbCAQ2z/AxaLgspygEK45 gkFU8jcPGMtssyuhRMHwBqUsfY3qhnQ= X-Google-Smtp-Source: APiQypIN48L/jVi9aEb2qodYvtrNzFJyIefmIMSrZWapjBe8dFtWmtBhPRQifVBEuf9Tm0pO+lKQVw== X-Received: by 2002:a63:ff49:: with SMTP id s9mr13479049pgk.46.1587324398385; Sun, 19 Apr 2020 12:26:38 -0700 (PDT) Received: from mail.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id x16sm22724383pfm.146.2020.04.19.12.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 12:26:38 -0700 (PDT) From: Kamal Dasu To: Kamal Dasu , bcm-kernel-feedback-list@broadcom.com, Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Patch v2 7/9] spi: bcm-qspi: Use fastbr setting to allow faster MSPI speeds Date: Sun, 19 Apr 2020 15:23:36 -0400 Message-Id: <20200419192339.32023-8-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200419192339.32023-1-kdasu.kdev@gmail.com> References: <20200419192339.32023-1-kdasu.kdev@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Setting MSPI_SPCR3.fastbr=1 allows using clock divider (SPBR) values of 1-7, while the default value prohibits these values and requires a minimum clock divider value of 8. Signed-off-by: Kamal Dasu --- drivers/spi/spi-bcm-qspi.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c index a3936ae5a860..edc601dbf221 100644 --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -107,13 +107,15 @@ #define MSPI_SPCR2_SPE BIT(6) #define MSPI_SPCR2_CONT_AFTER_CMD BIT(7) +#define MSPI_SPCR3_FASTBR BIT(0) +#define MSPI_SPCR3_FASTDT BIT(1) + #define MSPI_MSPI_STATUS_SPIF BIT(0) #define INTR_BASE_BIT_SHIFT 0x02 #define INTR_COUNT 0x07 #define NUM_CHIPSELECT 4 -#define QSPI_SPBR_MIN 8U #define QSPI_SPBR_MAX 255U #define OPCODE_DIOR 0xBB @@ -227,6 +229,25 @@ static inline bool has_bspi(struct bcm_qspi *qspi) return qspi->bspi_mode; } +/* hardware supports spcr3 and fast baud-rate */ +static inline bool bcm_qspi_has_fastbr(struct bcm_qspi *qspi) +{ + if (!has_bspi(qspi) && + ((qspi->mspi_maj_rev >= 1) && + (qspi->mspi_min_rev >= 5))) + return true; + + return false; +} + +static inline int bcm_qspi_spbr_min(struct bcm_qspi *qspi) +{ + if (bcm_qspi_has_fastbr(qspi)) + return 1; + else + return 8; +} + /* Read qspi controller register*/ static inline u32 bcm_qspi_read(struct bcm_qspi *qspi, enum base_type type, unsigned int offset) @@ -534,7 +555,7 @@ static void bcm_qspi_hw_set_parms(struct bcm_qspi *qspi, if (xp->speed_hz) spbr = qspi->base_clk / (2 * xp->speed_hz); - spcr = clamp_val(spbr, QSPI_SPBR_MIN, QSPI_SPBR_MAX); + spcr = clamp_val(spbr, bcm_qspi_spbr_min(qspi), QSPI_SPBR_MAX); bcm_qspi_write(qspi, MSPI, MSPI_SPCR0_LSB, spcr); spcr = MSPI_MASTER_BIT; @@ -544,6 +565,14 @@ static void bcm_qspi_hw_set_parms(struct bcm_qspi *qspi, spcr |= xp->mode & 3; bcm_qspi_write(qspi, MSPI, MSPI_SPCR0_MSB, spcr); + if (bcm_qspi_has_fastbr(qspi)) { + spcr = 0; + + /* enable fastbr */ + spcr |= MSPI_SPCR3_FASTBR; + bcm_qspi_write(qspi, MSPI, MSPI_SPCR3, spcr); + } + qspi->last_parms = *xp; } @@ -1388,7 +1417,6 @@ int bcm_qspi_probe(struct platform_device *pdev, } qspi->base_clk = clk_get_rate(qspi->clk); - qspi->max_speed_hz = qspi->base_clk / (QSPI_SPBR_MIN * 2); if (data->has_mspi_rev) { rev = bcm_qspi_read(qspi, MSPI, MSPI_REV); @@ -1400,6 +1428,8 @@ int bcm_qspi_probe(struct platform_device *pdev, qspi->mspi_maj_rev = (rev >> 4) & 0xf; qspi->mspi_min_rev = rev & 0xf; + qspi->max_speed_hz = qspi->base_clk / (bcm_qspi_spbr_min(qspi) * 2); + bcm_qspi_hw_init(qspi); init_completion(&qspi->mspi_done); init_completion(&qspi->bspi_done); From patchwork Sun Apr 19 19:23:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 214737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 774FCC3A5A9 for ; Sun, 19 Apr 2020 19:26:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53AF621927 for ; Sun, 19 Apr 2020 19:26:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UlBQrYXL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726756AbgDST0p (ORCPT ); Sun, 19 Apr 2020 15:26:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726743AbgDST0p (ORCPT ); Sun, 19 Apr 2020 15:26:45 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09438C061A0C; Sun, 19 Apr 2020 12:26:45 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a22so3464899pjk.5; Sun, 19 Apr 2020 12:26:45 -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=pMhdquAr/HzwmzyKmiKytwMMb3XOVcxGDwBpxb4EVIg=; b=UlBQrYXLrdkGZ0G70SpLh4Q4zMV+/d8t+uiaDHD9q4axnbr0qlg85uy/xlPPPGwg/K d9GWK1QnkWSDbYzAOGgD653D3GY/kVmCCFPmmnsmax3a+ntw2LoNSZMr6eM1RrfunqbQ oOXOrQ9VJUKrRmZgOeHr7hEUEDiP0UQnHseBgOcvdbP7wbOJN8Qj4p/OyQXzFiZPRQld WJH28TWhCGh/hYlE2n0e+sQp2jcczEzB8RpxsJQOKR/0CKZFKI2KyI86GeytmpGj63fg rvAIR5+l5gbk8IHMKqHD8egXd2ZtreQFjlaN2KMA/9lBXEo6Sa0JqAA5/ibOKZWgTAoQ JrAg== 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=pMhdquAr/HzwmzyKmiKytwMMb3XOVcxGDwBpxb4EVIg=; b=JF5HwfXQS+h5O+o7Qmrl5Duh0GxABFFYe4YeyKyYK9wbgtlH9catu/tfsnWHDSsHAE qtCggMuzlFOOXAjBL9S87WN3WXOaeUnod+viW+jUiuOrAYsOP8SmLczsduLimGwf7T05 +r9ziOjrp62XLoUL+hLvyeO5atyklcwBNdhaxmehA83/Upo7UWq1jcPC80E/hrx24SmW VKr/23aIVwy5JPcJP5mORkBtPr0VwE1Udv/0VS04UDQqfTvzcbPgqUST/S8ZPqchG8kY +cYErOMJ2gXNIe61FdzGIIhFra0AZdae1CNo5iCqS5uP2Nte6AcJsAIcnYMyn44D+EYS u7uQ== X-Gm-Message-State: AGi0PubW0e0VGpZhni/IZk2/nx1Y72ncdCr8rGZa1s0umqCrU/beBEAf j5FsJ4bFcuuY2LsXz/D2nJka8szDbt8= X-Google-Smtp-Source: APiQypJUCOnxdO12HZ7x4lmV0A3J9bRJMfas4lrJHVXpUZxKRi5IWl8oNDtC8PSwDtMu4uWwKPsB6A== X-Received: by 2002:a17:90a:d3ca:: with SMTP id d10mr4836977pjw.24.1587324404651; Sun, 19 Apr 2020 12:26:44 -0700 (PDT) Received: from mail.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id x16sm22724383pfm.146.2020.04.19.12.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 12:26:44 -0700 (PDT) From: Kamal Dasu To: Kamal Dasu , bcm-kernel-feedback-list@broadcom.com, Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Patch v2 9/9] spi: bcm-qspi: MSPI_SPCR0_MSB MSTR bit exists only on legacy controllers Date: Sun, 19 Apr 2020 15:23:38 -0400 Message-Id: <20200419192339.32023-10-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200419192339.32023-1-kdasu.kdev@gmail.com> References: <20200419192339.32023-1-kdasu.kdev@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Set MASTER bit on the MSPI_SPCR0_MSB only for legacy MSPI and HIF_MSPI controllers. Fixes: fa236a7ef240 ("spi: bcm-qspi: Add Broadcom MSPI driver") Signed-off-by: Kamal Dasu --- drivers/spi/spi-bcm-qspi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c index 99f2cfcbb50c..681d09085175 100644 --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -576,11 +576,17 @@ static void bcm_qspi_hw_set_parms(struct bcm_qspi *qspi, spcr = clamp_val(spbr, bcm_qspi_spbr_min(qspi), QSPI_SPBR_MAX); bcm_qspi_write(qspi, MSPI, MSPI_SPCR0_LSB, spcr); - spcr = MSPI_MASTER_BIT; + if (!qspi->mspi_maj_rev) + /* legacy controller */ + spcr = MSPI_MASTER_BIT; + else + spcr = 0; + /* for 16 bit the data should be zero */ if (xp->bits_per_word != 16) spcr |= xp->bits_per_word << 2; spcr |= xp->mode & 3; + bcm_qspi_write(qspi, MSPI, MSPI_SPCR0_MSB, spcr); if (bcm_qspi_has_fastbr(qspi)) {