Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5483274rwd; Wed, 24 May 2023 02:23:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ525nbaQEYoD3Pog65PvWtpml7M83/Hy1nyhDo8hdWCoq/I+adZXCL0bJyJ6/+L25DNHpTR X-Received: by 2002:a17:90b:4c41:b0:255:b1d9:a206 with SMTP id np1-20020a17090b4c4100b00255b1d9a206mr3799230pjb.22.1684920199005; Wed, 24 May 2023 02:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684920198; cv=none; d=google.com; s=arc-20160816; b=KwIf/ST+8ObHP7mC5ISc/PtFvrPx7fNOqzD9bh9ux8sXwqzrCQPxT2Dipm1+uJkui9 Yl5bCeYOet0O650NWzxANbyxGXDrurbfnwlKCmLkj/vU01Da24mb5qaemXNLYMkiijrX tZKfll2IbGXIUJ+icbyoW4g3KI6oOOw05p6auVc48edy2jPQYLJ4Ljq6L9OLyEZURAlC suChpA2adnNaLaoSy5py4qw8zOd/njeVH1jtP4/gCjf/3syNPlXtICmC5cE3r6UYFbWF rfOCkmpNP+/aYDvx6sFIdJ2X3PtK0dadM/SkYhY73LzOqQdS7th8qVMRrl+oCxBzm68T NVLw== 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 :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=8/xRPtd2AmjbmXpgou4sQlZTgH09nz9cR2dZE8lQL3E=; b=MeNNj/3k6UDdGI8kVbbDkToHyNVG5Hrzz9mQhPif8RtoSvWNXhbD5RxMpZNUrj3HBE l5uytUlPhrOdJV4zEbPIFexvEMjtwWyI361HiLnf3CO4EcOGM2TkTAA46T2jo6Gduiev V89mK8KGdw4jJNM24LAG6e3ByV1fxJopuemhyybAAf2gFDreIH/v5BANkz67PkpILhZo 0ieU3BhQt7CGaWXEyyqw7dlwZWVcWggyGLhcV6gtn5aaVMnKy0CgikKgV+hnfjUghUm4 c1A+9GKDR2gdVzBERb+QR3RrIWj5oiDP9/BR7WIfAOGRURIsRxX+6d4cVIjKKxsRNF9I VMYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20221208 header.b=PPtskXMB; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qe10-20020a17090b4f8a00b0024e33c63ed5si1097759pjb.15.2023.05.24.02.23.04; Wed, 24 May 2023 02:23:18 -0700 (PDT) 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; dkim=fail header.i=@gmail.com header.s=20221208 header.b=PPtskXMB; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240657AbjEXJVC (ORCPT + 99 others); Wed, 24 May 2023 05:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240636AbjEXJU5 (ORCPT ); Wed, 24 May 2023 05:20:57 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D1E0FC; Wed, 24 May 2023 02:20:52 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-510b7b6ef59so1689625a12.3; Wed, 24 May 2023 02:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684920050; x=1687512050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8/xRPtd2AmjbmXpgou4sQlZTgH09nz9cR2dZE8lQL3E=; b=PPtskXMBVcYltGkT+VrqN9E+v3cEyV6+544dMX+xoe1iClmJetzSs7Bs6ON/ySpouZ NCeMuYoojyfioAV/tXwL+MQaKkjDlZk42y+VRAK/rmGj5ZJQ7v20k0kpi7yauOAlK9XY wAlIVf3gO9r5KHISM9/VrOCUQDL4P0N00GsnlWZ7nvO/VA9q6Tk/dx5Up9yxR8GGl2/i NVBrR2EYOE6CrKvLeBNSRmsBddDLbmo1MRrnOLkMgrWwAgxYbSqTLWnkYdsdwrgqWMkz bXKdXA73poVgAsLl8sUoPKwtEU2exVXfOBZEEosJOrB4zPlM4m5iQi8I4L7qlJS7uMdM zR3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684920050; x=1687512050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8/xRPtd2AmjbmXpgou4sQlZTgH09nz9cR2dZE8lQL3E=; b=lJVBBu6AX7TtUKkxfmbmBG47MyCxPqi9lRHxFNKE62gCBEW7hyhw8w2wjo3GTrNlLI 7R4Kqdnuvxh0M9/OcU97xLkQLAexMA1N6qX6teTemI1S6T3iYG2Q97aYUhJNbnKvxxrJ +MdhiXmdpxvZLMRwf2xQa4hl9bbttqOQjhBh/WoCcoZGdKjy3+YzYFHRmJg1RQMUxs2e duN0ubYb8F7NI6oJDP0Zi1O79gEBQ1/HICsoES8hlZiHjFhp4RpI6d6Zhbv6ihdgc8Zi 8PbgVWJwhqadC3uZYpYWB/GS3pjT0eLET3egbxC5xbwbi9XleQoZMo9Tagitdp3TiM/D eilA== X-Gm-Message-State: AC+VfDwUs80IWPAwcSqNvqMz36h5bd4DFgnCgJd6GATA40PnDr3uxqxt dpf56c+BwgkhZrUEqi/c0N8= X-Received: by 2002:a17:907:96a1:b0:959:bbda:fa51 with SMTP id hd33-20020a17090796a100b00959bbdafa51mr18565467ejc.41.1684920050496; Wed, 24 May 2023 02:20:50 -0700 (PDT) Received: from wslxew193.ultratronik.de (p200300c78700c900fd67df8b3b199594.dip0.t-ipconnect.de. [2003:c7:8700:c900:fd67:df8b:3b19:9594]) by smtp.gmail.com with ESMTPSA id jy22-20020a170907763600b0096fbc516a93sm4579527ejc.211.2023.05.24.02.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 02:20:50 -0700 (PDT) From: Boerge Struempfel Cc: boerge.struempfel@gmail.com, bstruempfel@ultratronik.de, andy.shevchenko@gmail.com, festevam@gmail.com, amit.kumar-mahapatra@amd.com, broonie@kernel.org, Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , NXP Linux Team , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/5] spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit Date: Wed, 24 May 2023 11:19:45 +0200 Message-Id: <20230524091948.41779-3-boerge.struempfel@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524091948.41779-1-boerge.struempfel@gmail.com> References: <20230524091948.41779-1-boerge.struempfel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 By default, the spi-imx controller pulls the mosi line high, whenever it is idle. This behaviour can be inverted per CS by setting the corresponding DATA_CTL bit in the config register of the controller. Also, since the controller mode-bits have to be touched anyways, the SPI_CPOL and SPI_CPHA are replaced by the combined SPI_MODE_X_MASK flag. Signed-off-by: Boerge Struempfel --- drivers/spi/spi-imx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 34e5f81ec431..1c4172fcba2d 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -281,6 +281,7 @@ static bool spi_imx_can_dma(struct spi_controller *controller, struct spi_device #define MX51_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs & 3) + 4)) #define MX51_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs & 3) + 8)) #define MX51_ECSPI_CONFIG_SSBPOL(cs) (1 << ((cs & 3) + 12)) +#define MX51_ECSPI_CONFIG_DATACTL(cs) (1 << ((cs & 3) + 16)) #define MX51_ECSPI_CONFIG_SCLKCTL(cs) (1 << ((cs & 3) + 20)) #define MX51_ECSPI_INT 0x10 @@ -573,6 +574,11 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx, cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(spi_get_chipselect(spi, 0)); } + if (spi->mode & SPI_MOSI_IDLE_LOW) + cfg |= MX51_ECSPI_CONFIG_DATACTL(spi_get_chipselect(spi, 0)); + else + cfg &= ~MX51_ECSPI_CONFIG_DATACTL(spi_get_chipselect(spi, 0)); + if (spi->mode & SPI_CS_HIGH) cfg |= MX51_ECSPI_CONFIG_SSBPOL(spi_get_chipselect(spi, 0)); else @@ -1743,7 +1749,8 @@ static int spi_imx_probe(struct platform_device *pdev) spi_imx->controller->prepare_message = spi_imx_prepare_message; spi_imx->controller->unprepare_message = spi_imx_unprepare_message; spi_imx->controller->slave_abort = spi_imx_slave_abort; - spi_imx->controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_NO_CS; + spi_imx->controller->mode_bits = SPI_MODE_X_MASK | SPI_CS_HIGH | SPI_NO_CS | + SPI_MOSI_IDLE_LOW; if (is_imx35_cspi(spi_imx) || is_imx51_ecspi(spi_imx) || is_imx53_ecspi(spi_imx)) -- 2.40.1