From patchwork Fri Mar 17 05:03:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Ungerer X-Patchwork-Id: 740143 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vktXC5CySz9s0Z for ; Fri, 17 Mar 2017 16:03:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="u7YoYx+j"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7pus9MMDNvLNkttcNoXtiaRSsQSxi6C5m3wRxu8XElI=; b=u7YoYx+jerofskLSgzhaM+2HK2 +30qvnj40whEQKxjQZQQ/6R8URQN9+JaqwBe62adg3yQj7z1S1pA65t4zi9X6NAK3/hCdd+pIxYcu 4BKAecJixVzQhYRPBFTsdTwEiU93hVGIzSyi19AliwAChUTA1d0AzFUXM/dsvWmYUIoOR/YFvh+yc 29rWEPUYGq3jXMEjWH6znQUNKfMjkynAd3sLvtbas74T1iBjQ2AxzG9TkR11jl/lgYMNjMI1dG/MR nWPB5Z/IKxXqAdjxg6ptJEoWOUR8EBzxOLAm7w/664Svn+Adj6tf5aOdj5aXLWURDhliYo3j4mNiC i4Zw812w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cok2p-0006d5-GU; Fri, 17 Mar 2017 05:03:19 +0000 Received: from icp-osb-irony-out1.external.iinet.net.au ([203.59.1.210]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cok2k-0006aT-4z for linux-arm-kernel@lists.infradead.org; Fri, 17 Mar 2017 05:03:16 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BfBACfbctY/zXSMGddGwEBAQMBAQEJAQEBg1GBa4MUmwkBAQEGlFOEHRqGCAKDBlcBAgEBAQEBAmsohRYGeRAYJxJXBxKJcwy0ByYCiioBAQgohgmPbQWcRAGSQIprhjxIkwVXgQQjFggkCIUYHYF1LjWJVwEBAQ X-IPAS-Result: A2BfBACfbctY/zXSMGddGwEBAQMBAQEJAQEBg1GBa4MUmwkBAQEGlFOEHRqGCAKDBlcBAgEBAQEBAmsohRYGeRAYJxJXBxKJcwy0ByYCiioBAQgohgmPbQWcRAGSQIprhjxIkwVXgQQjFggkCIUYHYF1LjWJVwEBAQ X-IronPort-AV: E=Sophos;i="5.36,175,1486396800"; d="scan'208";a="179878456" Received: from unknown (HELO goober.accelecon.com) ([103.48.210.53]) by icp-osb-irony-out1.iinet.net.au with ESMTP; 17 Mar 2017 13:02:49 +0800 From: Greg Ungerer To: linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] spi: imx: set correct chip_select in platform setup Date: Fri, 17 Mar 2017 15:03:02 +1000 Message-Id: <1489726983-17706-2-git-send-email-gerg@linux-m68k.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1489726983-17706-1-git-send-email-gerg@linux-m68k.org> References: <1489726983-17706-1-git-send-email-gerg@linux-m68k.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170316_220314_698797_4B4E036A X-CRM114-Status: GOOD ( 14.07 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [203.59.1.210 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [203.59.1.210 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fabio.estevam@nxp.com, shawnguo@kernel.org, Greg Ungerer , kernel@pengutronix.de MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Some platform based configuration setup of spi-imx SPI devices does not set the "chip_select" to the actual hardware chip select used. This works because the cs_gpio mapping that is associated with this platform setup maps the chip_select offset used to the appropriate hardware chip select. The spi-imx driver uses the chip_select as an index into the cs_gpio array and ultimately gets the correct hardware chip select for its hardware setup. The motivation is to be able to eventually modify the spi-imx code to use the "chip_select" directly for harwdare setup instead of indirectly via the cs_gpio mapping array. This change only affects platforms using the hardware chip select addressing method for their SPI devices (sometimes called native chip select). The majority of devices using the spi-imx driver use the GPIO addressing method. The change to use the correct "chip_select" is strait forward. But the cs_gpio mapping arrary also needs to be modifed to match that change. In simple terms the cs_gpio mapping should always have the hardware chip select number at its same index offset. There is no functional change with these patches. The three affected platforms should work exactly as before. However I don't have any of these platforms (or access to them) and so I can't test them. So this patch is compile tested only. Signed-off-by: Greg Ungerer --- arch/arm/mach-imx/mach-mx31_3ds.c | 7 +++++-- arch/arm/mach-imx/mach-mx31moboard.c | 4 ++-- arch/arm/mach-imx/mach-pcm037_eet.c | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c index 558e5f8..68c3f07 100644 --- a/arch/arm/mach-imx/mach-mx31_3ds.c +++ b/arch/arm/mach-imx/mach-mx31_3ds.c @@ -375,6 +375,8 @@ static void mx31_3ds_sdhc1_setpower(struct device *dev, unsigned int vdd) /* SPI */ static int spi0_internal_chipselect[] = { + MXC_SPI_CS(0), + MXC_SPI_CS(1), MXC_SPI_CS(2), }; @@ -385,6 +387,7 @@ static void mx31_3ds_sdhc1_setpower(struct device *dev, unsigned int vdd) static int spi1_internal_chipselect[] = { MXC_SPI_CS(0), + MXC_SPI_CS(1), MXC_SPI_CS(2), }; @@ -398,7 +401,7 @@ static void mx31_3ds_sdhc1_setpower(struct device *dev, unsigned int vdd) .modalias = "mc13783", .max_speed_hz = 1000000, .bus_num = 1, - .chip_select = 1, /* SS2 */ + .chip_select = 2, /* SS2 */ .platform_data = &mc13783_pdata, /* irq number is run-time assigned */ .mode = SPI_CS_HIGH, @@ -406,7 +409,7 @@ static void mx31_3ds_sdhc1_setpower(struct device *dev, unsigned int vdd) .modalias = "l4f00242t03", .max_speed_hz = 5000000, .bus_num = 0, - .chip_select = 0, /* SS2 */ + .chip_select = 2, /* SS2 */ .platform_data = &mx31_3ds_l4f00242t03_pdata, }, }; diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c index cc86768..bde9a9a 100644 --- a/arch/arm/mach-imx/mach-mx31moboard.c +++ b/arch/arm/mach-imx/mach-mx31moboard.c @@ -296,14 +296,14 @@ static void __init moboard_uart0_init(void) /* irq number is run-time assigned */ .max_speed_hz = 300000, .bus_num = 1, - .chip_select = 0, + .chip_select = 1, .platform_data = &moboard_pmic, .mode = SPI_CS_HIGH, }, }; static int moboard_spi2_cs[] = { - MXC_SPI_CS(1), + MXC_SPI_CS(0), MXC_SPI_CS(1), }; static const struct spi_imx_master moboard_spi2_pdata __initconst = { diff --git a/arch/arm/mach-imx/mach-pcm037_eet.c b/arch/arm/mach-imx/mach-pcm037_eet.c index 8fd8255..95bd977 100644 --- a/arch/arm/mach-imx/mach-pcm037_eet.c +++ b/arch/arm/mach-imx/mach-pcm037_eet.c @@ -50,13 +50,13 @@ .modalias = "dac124s085", .max_speed_hz = 400000, .bus_num = 0, - .chip_select = 0, /* Index in pcm037_spi1_cs[] */ + .chip_select = 1, /* Index in pcm037_spi1_cs[] */ .mode = SPI_CPHA, }, }; /* Platform Data for MXC CSPI */ -static int pcm037_spi1_cs[] = {MXC_SPI_CS(1), IOMUX_TO_GPIO(MX31_PIN_KEY_COL7)}; +static int pcm037_spi1_cs[] = { MXC_SPI_CS(0), MXC_SPI_CS(1), }; static const struct spi_imx_master pcm037_spi1_pdata __initconst = { .chipselect = pcm037_spi1_cs,