From patchwork Mon Nov 18 04:57:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: luhua xu X-Patchwork-Id: 11248857 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB27C1393 for ; Mon, 18 Nov 2019 04:58:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC7CE20727 for ; Mon, 18 Nov 2019 04:58:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Gy1YUg4y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726551AbfKRE6M (ORCPT ); Sun, 17 Nov 2019 23:58:12 -0500 Received: from Mailgw01.mediatek.com ([1.203.163.78]:50761 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726347AbfKRE6L (ORCPT ); Sun, 17 Nov 2019 23:58:11 -0500 X-UUID: 6c1f2ecea9d246268c902867d4192d9e-20191118 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=cFCudjariDZ9dPYX7zDkbr0ezd58dL0l8GffmHcsUbk=; b=Gy1YUg4yZ/+Bnu6nAXh7hrtcRoFHKfEEuWpZGgg6bFwBw0WU5fIqiLH5tcjnXmQCs11ypaxVYZqpRMzMm1We1IdbpVc0MCuFUpR1PK6aL2Bq/DhQ310rdAHFr2B1v0DqXpD92rK2x7Wt+c2ijxK2bnuNT+5+ODcoA3UYDYY7oXo=; X-UUID: 6c1f2ecea9d246268c902867d4192d9e-20191118 Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 390284999; Mon, 18 Nov 2019 12:57:53 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 18 Nov 2019 12:57:06 +0800 Received: from localhost.localdomain (10.15.20.246) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 18 Nov 2019 12:57:43 +0800 From: Luhua Xu To: Mark Brown , Matthias Brugger , Allison Randal , Enrico Weigelt , Kate Stewart , Leilk Liu , Thomas Gleixner CC: , , , , Luhua Xu Subject: [PATCH 1/2] spi: mediatek: add SPI_CS_HIGH support Date: Mon, 18 Nov 2019 12:57:16 +0800 Message-ID: <1574053037-26721-2-git-send-email-luhua.xu@mediatek.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1574053037-26721-1-git-send-email-luhua.xu@mediatek.com> References: <1574053037-26721-1-git-send-email-luhua.xu@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: DE1900F93D357E82F39EBE3D6EC1C540731BF3D8A546E01EB95384160FCD19D02000:8 X-MTK: N Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Change to use SPI_CS_HIGH to support spi CS polarity setting for chips support enhance_timing. Signed-off-by: Luhua Xu --- drivers/spi/spi-mt65xx.c | 12 ++++++++++-- include/linux/platform_data/spi-mt65xx.h | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 6888a4d..f599cce 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -139,7 +139,6 @@ static const struct mtk_spi_compatible mt8183_compat = { * supplies it. */ static const struct mtk_chip_config mtk_default_chip_info = { - .cs_pol = 0, .sample_sel = 0, }; @@ -230,10 +229,12 @@ static int mtk_spi_prepare_message(struct spi_master *master, #endif if (mdata->dev_comp->enhance_timing) { - if (chip_config->cs_pol) + /* set CS polarity */ + if (spi->mode & SPI_CS_HIGH) reg_val |= SPI_CMD_CS_POL; else reg_val &= ~SPI_CMD_CS_POL; + if (chip_config->sample_sel) reg_val |= SPI_CMD_SAMPLE_SEL; else @@ -264,6 +265,9 @@ static void mtk_spi_set_cs(struct spi_device *spi, bool enable) u32 reg_val; struct mtk_spi *mdata = spi_master_get_devdata(spi->master); + if (spi->mode & SPI_CS_HIGH) + enable = !enable; + reg_val = readl(mdata->base + SPI_CMD_REG); if (!enable) { reg_val |= SPI_CMD_PAUSE_EN; @@ -647,6 +651,10 @@ static int mtk_spi_probe(struct platform_device *pdev) mdata = spi_master_get_devdata(master); mdata->dev_comp = of_id->data; + + if (mdata->dev_comp->enhance_timing) + master->mode_bits |= SPI_CS_HIGH; + if (mdata->dev_comp->must_tx) master->flags = SPI_MASTER_MUST_TX; diff --git a/include/linux/platform_data/spi-mt65xx.h b/include/linux/platform_data/spi-mt65xx.h index f0e6d64..65fd5ffd2 100644 --- a/include/linux/platform_data/spi-mt65xx.h +++ b/include/linux/platform_data/spi-mt65xx.h @@ -11,7 +11,6 @@ /* Board specific platform_data */ struct mtk_chip_config { - u32 cs_pol; u32 sample_sel; }; #endif