Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1862881rwb; Fri, 2 Dec 2022 02:06:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5lYPocimhbEC+e744crWp0Bhy+soVQRGGKvYnsYz2x/ATr7gPTRO2KRvjxUYRHt2GuSVAS X-Received: by 2002:a63:ff63:0:b0:477:8d4f:3dda with SMTP id s35-20020a63ff63000000b004778d4f3ddamr47306308pgk.552.1669975575548; Fri, 02 Dec 2022 02:06:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669975575; cv=none; d=google.com; s=arc-20160816; b=j2cmtSa/H7KIb/yNmB39Q8LrUtG3qkG7vVb98FgaOR1hPR2XirYm2Id/KzOz0QP3DW XBYCb7umvRwzwnixyxi/LQ5id9Ytxq4rwokpXopdzPTazivZJEh1OKL4eDLHXrcb/qEW kGEeSAz5/z8i34/s+w7HKU+R6t+NT/aGdN8cPXE/cAyzeWBRR2NaTu0rc/S9QN1SYOr7 TJbgWngrsJlt0S+lbMfOv9sQpUzdxf9b/JYdcOlWJ3AABrwd55e/6h934Bf4eik/gBZk 6mbzC+WYTExzBs3cNm3rneidexkrHaV2dTnE43CLyi+T4744E2JlXeqm9Y/J2GC5KJR0 6vlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from; bh=im2rRR5PJvk82DFIGFS4nynO0MOwr166wWWAaXSEtaA=; b=nPEvqA8Aduz+xNOEt7HuXFV/ovQP/O6fsoukf9PVZ2A+2bs1g6pjT0G06xxwNTk7+Z L7HXeba9HD7P54lCSkwryFlKW7qzebslIAGSY9MAmO0qjEooJQQhgJtEA54YU6VdJZcF VjFHpGAQXeWN60JIIQZVXttAxg99PnY1WjOeSZQ7cQcn3VofOseKR80vrfZj6TAGLJwg Pca0XOvY3k8VAoIfdG8Pp3ek4rvR4aP59IcrllU5tXk30uj+6SuUYS2ikupSr6U2W6so 7jk7pZAO/IPB6o+2gQ0ZProUysvd+4qyNvhWzXkhKPeISecHKOmaFQ4jJ3hmjLX7SGQF Jt+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o16-20020a056a0015d000b00537d8aa3bc3si7418614pfu.200.2022.12.02.02.06.04; Fri, 02 Dec 2022 02:06:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233155AbiLBJtr (ORCPT + 83 others); Fri, 2 Dec 2022 04:49:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232887AbiLBJtj (ORCPT ); Fri, 2 Dec 2022 04:49:39 -0500 Received: from mx1.emlix.com (mx1.emlix.com [136.243.223.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 228C6C934F for ; Fri, 2 Dec 2022 01:49:37 -0800 (PST) Received: from mailer.emlix.com (p5098be52.dip0.t-ipconnect.de [80.152.190.82]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id C60E05FF10; Fri, 2 Dec 2022 10:49:35 +0100 (CET) From: Edmund Berenson Cc: Edmund Berenson , Lukasz Zemla , Serge Semin , Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] spi: dw: Write chip configuration before cs is set Date: Fri, 2 Dec 2022 10:49:34 +0100 Message-Id: <20221202094934.9420-1-edmund.berenson@emlix.com> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using chips with different cpol, causes first communication to fail on cpol change. To avoid this issue write cr0 register before cs is set. Suggested-by: Lukasz Zemla Signed-off-by: Edmund Berenson --- drivers/spi/spi-dw-core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 57c9e384d6d4..c3da4fe3e510 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -93,6 +93,7 @@ static inline void dw_spi_debugfs_remove(struct dw_spi *dws) void dw_spi_set_cs(struct spi_device *spi, bool enable) { struct dw_spi *dws = spi_controller_get_devdata(spi->controller); + struct dw_spi_chip_data *chip = spi_get_ctldata(spi); bool cs_high = !!(spi->mode & SPI_CS_HIGH); u8 enable_cs = 0; @@ -106,8 +107,13 @@ void dw_spi_set_cs(struct spi_device *spi, bool enable) * Enable register no matter whether the SPI core is configured to * support active-high or active-low CS level. */ - if (cs_high == enable) + if (cs_high == enable) { + dw_spi_enable_chip(dws, 0); + dw_writel(dws, DW_SPI_CTRLR0, chip->cr0); + dw_spi_enable_chip(dws, 1); + dw_writel(dws, DW_SPI_SER, BIT(enable_cs)); + } else dw_writel(dws, DW_SPI_SER, 0); } -- 2.37.4