linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Packham <chris.packham@alliedtelesis.co.nz>
To: broonie@kernel.org, andy.shevchenko@gmail.com,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	rmallon@gmail.com, shawnguo@kernel.org
Cc: Fabio Estevam <fabio.estevam@nxp.com>,
	Chris Packham <chris.packham@alliedtelesis.co.nz>,
	linux@armlinux.org.uk, Sascha Hauer <kernel@pengutronix.de>,
	linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 3/5] ARM: imx: add gpiod_lookup_table for spi chip-selects
Date: Thu, 25 May 2017 16:30:41 +1200	[thread overview]
Message-ID: <20170525043043.1930-4-chris.packham@alliedtelesis.co.nz> (raw)
In-Reply-To: <20170525043043.1930-1-chris.packham@alliedtelesis.co.nz>

This is a preparatory step which will allow the conversion of
spi-imx.c to gpiod.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
 arch/arm/mach-imx/mach-mx27_3ds.c | 21 +++++++++++++++++++++
 arch/arm/mach-imx/mach-pca100.c   | 13 +++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/arch/arm/mach-imx/mach-mx27_3ds.c b/arch/arm/mach-imx/mach-mx27_3ds.c
index 45e16bd7e2f2..46d67be124f0 100644
--- a/arch/arm/mach-imx/mach-mx27_3ds.c
+++ b/arch/arm/mach-imx/mach-mx27_3ds.c
@@ -22,6 +22,7 @@
 
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
+#include <linux/gpio/machine.h>
 #include <linux/irq.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/ulpi.h>
@@ -313,6 +314,15 @@ static struct imx_ssi_platform_data mx27_3ds_ssi_pdata = {
 };
 
 /* SPI */
+static struct gpiod_lookup_table spi1_cs_gpio_table = {
+	.dev_id = "spi.0",
+	.table = {
+		GPIO_LOOKUP("gpio-mxc", SPI1_SS0,
+			    "spi-cs", GPIO_ACTIVE_HIGH),
+		{ },
+	},
+};
+
 static int spi1_chipselect[] = {SPI1_SS0};
 
 static const struct spi_imx_master spi1_pdata __initconst = {
@@ -320,6 +330,15 @@ static const struct spi_imx_master spi1_pdata __initconst = {
 	.num_chipselect	= ARRAY_SIZE(spi1_chipselect),
 };
 
+static struct gpiod_lookup_table spi2_cs_gpio_table = {
+	.dev_id = "spi.1",
+	.table = {
+		GPIO_LOOKUP("gpio-mxc", SPI2_SS0,
+			    "spi-cs", GPIO_ACTIVE_HIGH),
+		{ },
+	},
+};
+
 static int spi2_chipselect[] = {SPI2_SS0};
 
 static const struct spi_imx_master spi2_pdata __initconst = {
@@ -398,7 +417,9 @@ static void __init mx27pdk_init(void)
 	imx27_add_imx_keypad(&mx27_3ds_keymap_data);
 	imx27_add_imx2_wdt();
 
+	gpiod_add_lookup_table(&spi2_cs_gpio_table);
 	imx27_add_spi_imx1(&spi2_pdata);
+	gpiod_add_lookup_table(&spi1_cs_gpio_table);
 	imx27_add_spi_imx0(&spi1_pdata);
 
 	imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data);
diff --git a/arch/arm/mach-imx/mach-pca100.c b/arch/arm/mach-imx/mach-pca100.c
index ed675863655b..8a2b5860f327 100644
--- a/arch/arm/mach-imx/mach-pca100.c
+++ b/arch/arm/mach-imx/mach-pca100.c
@@ -27,6 +27,7 @@
 #include <linux/irq.h>
 #include <linux/delay.h>
 #include <linux/gpio.h>
+#include <linux/gpio/machine.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/ulpi.h>
 
@@ -202,6 +203,17 @@ static struct spi_board_info pca100_spi_board_info[] __initdata = {
 	},
 };
 
+static struct gpiod_lookup_table pca100_spi_cs_gpio_table = {
+	.dev_id = "spi.0",
+	.table = {
+		GPIO_LOOKUP_IDX("gpio-mxc", SPI1_SS0,
+				"spi-cs", 0, GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP_IDX("gpio-mxc", SPI1_SS1,
+				"spi-cs", 1, GPIO_ACTIVE_HIGH),
+		{ },
+	},
+};
+
 static int pca100_spi_cs[] = {SPI1_SS0, SPI1_SS1};
 
 static const struct spi_imx_master pca100_spi0_data __initconst = {
@@ -376,6 +388,7 @@ static void __init pca100_init(void)
 	mxc_gpio_mode(GPIO_PORTD | 27 | GPIO_GPIO | GPIO_IN);
 	spi_register_board_info(pca100_spi_board_info,
 				ARRAY_SIZE(pca100_spi_board_info));
+	gpiod_add_lookup_table(&pca100_spi_cs_gpio_table);
 	imx27_add_spi_imx0(&pca100_spi0_data);
 
 	imx27_add_imx_fb(&pca100_fb_data);
-- 
2.13.0

  parent reply	other threads:[~2017-05-25  4:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-25  4:30 [RFC PATCH 0/5] spi: moving to struct gpio_desc Chris Packham
2017-05-25  4:30 ` [RFC PATCH 1/5] spi: use gpio_desc instead of numeric gpio Chris Packham
2017-05-25  4:30 ` [RFC PATCH 2/5] ARM: ep93xx: add gpiod_lookup_table for spi chip-selects Chris Packham
2017-05-25  4:30 ` Chris Packham [this message]
2017-05-25  4:30 ` [RFC PATCH 4/5] spi: core: convert spi_master to use gpio_desc Chris Packham
2017-05-25  4:30 ` [RFC PATCH 5/5] ARM: ep93xx: remove chipselect from ep93xx_spi_info Chris Packham
     [not found] ` <20170525043043.1930-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
2017-05-29 13:36   ` [RFC PATCH 0/5] spi: moving to struct gpio_desc Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170525043043.1930-4-chris.packham@alliedtelesis.co.nz \
    --to=chris.packham@alliedtelesis.co.nz \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=fabio.estevam@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=rmallon@gmail.com \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).