Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2143094iof; Tue, 7 Jun 2022 21:11:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWtYSprZbmWpV2PImBsP23AxbxR1908jxryfj0gqlScKoLSQR7wKYPa0CV76+QYX1/qRDJ X-Received: by 2002:a62:38d7:0:b0:51c:4c30:3aef with SMTP id f206-20020a6238d7000000b0051c4c303aefmr3670846pfa.5.1654661482749; Tue, 07 Jun 2022 21:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661482; cv=none; d=google.com; s=arc-20160816; b=zg1kdPPH2JXjn0+dcL8Ry2uPojijnbceEBpi1WMY3aoLj16XqRkc4yI3Dy202ICbgY JoatDGouVLBmzXKWAIl0vHEp68yDmqqB15DC0boSeXb8o/erYfy3SSdeJ+mGY5XZaXlD RIAdNm+4mwy6HizPqU+VJfXoIIWEAhNW+imX9Ix6SW8msiwGDNKeyGF60/KoQCPP3zuU CVpT19TeiWTeMWGiJ6nLKY9XHs97vV7o7J36YjmjrjhiHGR7/ZdGayZRPZd1z7V7QDy8 ZUaLGfNey0ErdYOmI+PRDQRml42KpMikZ2sGc7wkV0UFC1IJOHzuRauoRtxdH1Jq7H05 ByHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x0RiaqU0onEbHLNcsg3kBTH0SbEfv214kCErA7/BLYI=; b=1F0OUgeoBXn/UUsxZu38wV6+9v6R9lobJ1qsE4DRkmWEvA5xjE29jUfFQyKrOC+beW mXiCJODbwsocSuaBnLu4zu4nmUiykrdxEHBY55A8M+B2rhz6XoIpDJwulhpvrn7jXq6T P0iNtAFY+SUSw6j7i/gi+2A/8Ej+BXWI4NDJP2s1z8R+414PkgAxE82baBqJBsi6P7OJ HXCEKUOWvXsdRlJda6bQ7Lg/m5PEzQ6LbH3tKsKibRs9YjJ/lRV04ZADCLkHMHDvgjUx TIlFeCgKnpxWaPxeXUV1vvjuFfOw5NcUYEwNirLZTgeXjihyvA9B0RahPg2LV0naEHpw h9LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CxceSfW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q13-20020a632a0d000000b003fcaa41c494si25327930pgq.175.2022.06.07.21.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:11:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CxceSfW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3BB8F92D37; Tue, 7 Jun 2022 20:42:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377817AbiFGVAP (ORCPT + 99 others); Tue, 7 Jun 2022 17:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357763AbiFGTzu (ORCPT ); Tue, 7 Jun 2022 15:55:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A6B4A7E18; Tue, 7 Jun 2022 11:23:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9634611B9; Tue, 7 Jun 2022 18:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFEFFC385A2; Tue, 7 Jun 2022 18:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654626227; bh=TY/+PwTvpEYxQkMo3I5D4CqBoTzcVkJcSgad3CTPxNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CxceSfW42WgyQccB8xvLyLC4UWKY3KVe5d4ll6F34PA8ahd0PR0D0O/JHykOpbLRr 18Y+fftaMi6szTNbpNj6+uDtTS4oZFz0jXf2le82BkerlVrGCILA0gue4rLT+y2HkA QMhj2TSdI5hIjcUl/uHYqW8mQiTtQXie932mnxk8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Lin , Mark Brown , Sasha Levin Subject: [PATCH 5.17 295/772] spi: rockchip: Preset cs-high and clk polarity in setup progress Date: Tue, 7 Jun 2022 18:58:07 +0200 Message-Id: <20220607164957.716198963@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jon Lin [ Upstream commit 3a4bf922d42efa4e9a3dc803d1fd786d43e8a501 ] After power up, the cs and clock is in default status, and the cs-high and clock polarity dts property configuration will take no effect until the calling of rockchip_spi_config in the first transmission. So preset them to make sure a correct voltage before the first transmission coming. Signed-off-by: Jon Lin Link: https://lore.kernel.org/r/20220216014028.8123-5-jon.lin@rock-chips.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-rockchip.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 5ecd0692cca1..83da8fdb3c02 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -713,6 +713,29 @@ static bool rockchip_spi_can_dma(struct spi_controller *ctlr, return xfer->len / bytes_per_word >= rs->fifo_len; } +static int rockchip_spi_setup(struct spi_device *spi) +{ + struct rockchip_spi *rs = spi_controller_get_devdata(spi->controller); + u32 cr0; + + pm_runtime_get_sync(rs->dev); + + cr0 = readl_relaxed(rs->regs + ROCKCHIP_SPI_CTRLR0); + + cr0 &= ~(0x3 << CR0_SCPH_OFFSET); + cr0 |= ((spi->mode & 0x3) << CR0_SCPH_OFFSET); + if (spi->mode & SPI_CS_HIGH && spi->chip_select <= 1) + cr0 |= BIT(spi->chip_select) << CR0_SOI_OFFSET; + else if (spi->chip_select <= 1) + cr0 &= ~(BIT(spi->chip_select) << CR0_SOI_OFFSET); + + writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0); + + pm_runtime_put(rs->dev); + + return 0; +} + static int rockchip_spi_probe(struct platform_device *pdev) { int ret; @@ -840,6 +863,7 @@ static int rockchip_spi_probe(struct platform_device *pdev) ctlr->min_speed_hz = rs->freq / BAUDR_SCKDV_MAX; ctlr->max_speed_hz = min(rs->freq / BAUDR_SCKDV_MIN, MAX_SCLK_OUT); + ctlr->setup = rockchip_spi_setup; ctlr->set_cs = rockchip_spi_set_cs; ctlr->transfer_one = rockchip_spi_transfer_one; ctlr->max_transfer_size = rockchip_spi_max_transfer_size; -- 2.35.1