mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/4] SPI i.MX: Add support for i.MX6
Date: Tue, 31 Jul 2012 20:01:47 +0200	[thread overview]
Message-ID: <1343757710-12659-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1343757710-12659-1-git-send-email-s.hauer@pengutronix.de>

The i.MX5 does not have a valid function to get the spi clock. This
patch introduces a function for i.MX6, and moves the bogus spi clock
speed to the speed-imx5*.c. Not nice, but preserves the current status
quo for i.MX5

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/include/mach/devices-imx6.h |    5 +++++
 arch/arm/mach-imx/speed-imx51.c               |    5 +++++
 arch/arm/mach-imx/speed-imx53.c               |    5 +++++
 arch/arm/mach-imx/speed-imx6.c                |    5 +++++
 drivers/spi/Kconfig                           |    2 +-
 drivers/spi/imx_spi.c                         |    6 +++---
 6 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-imx/include/mach/devices-imx6.h b/arch/arm/mach-imx/include/mach/devices-imx6.h
index e4a72ac..ca063c5 100644
--- a/arch/arm/mach-imx/include/mach/devices-imx6.h
+++ b/arch/arm/mach-imx/include/mach/devices-imx6.h
@@ -44,3 +44,8 @@ static inline struct device_d *imx6_add_fec(struct fec_platform_data *pdata)
 {
 	return imx_add_fec((void *)MX6_ENET_BASE_ADDR, pdata);
 }
+
+static inline struct device_d *imx6_add_spi0(struct spi_imx_master *pdata)
+{
+	return imx_add_spi((void *)MX6_ECSPI1_BASE_ADDR, 0, pdata);
+}
diff --git a/arch/arm/mach-imx/speed-imx51.c b/arch/arm/mach-imx/speed-imx51.c
index 87fbc75..288fe1a 100644
--- a/arch/arm/mach-imx/speed-imx51.c
+++ b/arch/arm/mach-imx/speed-imx51.c
@@ -228,6 +228,11 @@ unsigned long imx_get_usbclk(void)
 	return rate / (prediv * podf);
 }
 
+unsigned long imx_get_cspiclk(void)
+{
+	return 166000000; /* FIXME: bogus value */
+}
+
 /*
  * Set the divider of the CLKO pin. Returns
  * the new divider (which may be smaller
diff --git a/arch/arm/mach-imx/speed-imx53.c b/arch/arm/mach-imx/speed-imx53.c
index 653dae3..ede5ffd 100644
--- a/arch/arm/mach-imx/speed-imx53.c
+++ b/arch/arm/mach-imx/speed-imx53.c
@@ -217,6 +217,11 @@ unsigned long imx_get_mmcclk(void)
 	return rate / (prediv * podf);
 }
 
+unsigned long imx_get_cspiclk(void)
+{
+	return 166000000; /* FIXME: bogus value */
+}
+
 void imx_dump_clocks(void)
 {
 	printf("pll1: %ld\n", pll1_main_get_rate());
diff --git a/arch/arm/mach-imx/speed-imx6.c b/arch/arm/mach-imx/speed-imx6.c
index 4cc9fdb..df24545 100644
--- a/arch/arm/mach-imx/speed-imx6.c
+++ b/arch/arm/mach-imx/speed-imx6.c
@@ -332,6 +332,11 @@ u32 imx_get_fecclk(void)
 	return __get_ipg_clk();
 }
 
+u32 imx_get_cspiclk(void)
+{
+	return __get_cspi_clk();
+}
+
 void imx_dump_clocks(void)
 {
 	u32 freq;
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 609bafd..a249b81 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -21,7 +21,7 @@ config DRIVER_SPI_IMX_0_7
 
 config DRIVER_SPI_IMX_2_3
 	bool
-	depends on ARCH_IMX51 || ARCH_IMX53
+	depends on ARCH_IMX51 || ARCH_IMX53 || ARCH_IMX6
 	default y
 
 config DRIVER_SPI_ALTERA
diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index 42358f2..2e59b3c 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -374,7 +374,7 @@ static void cspi_2_3_chipselect(struct spi_device *spi, int is_active)
 
 	if (!is_active) {
 		if (gpio >= 0)
-			gpio_set_value(gpio, !gpio_cs);
+			gpio_direction_output(gpio, !gpio_cs);
 		return;
 	}
 
@@ -384,7 +384,7 @@ static void cspi_2_3_chipselect(struct spi_device *spi, int is_active)
 	ctrl |= CSPI_2_3_CTRL_MODE(cs);
 
 	/* set clock speed */
-	ctrl |= cspi_2_3_clkdiv(166000000, spi->max_speed_hz);
+	ctrl |= cspi_2_3_clkdiv(imx_get_cspiclk(), spi->max_speed_hz);
 
 	/* set chip select to use */
 	ctrl |= CSPI_2_3_CTRL_CS(cs);
@@ -521,7 +521,7 @@ static int imx_spi_probe(struct device_d *dev)
 		version = SPI_IMX_VER_0_7;
 #endif
 #ifdef CONFIG_DRIVER_SPI_IMX_2_3
-	if (cpu_is_mx51() || cpu_is_mx53())
+	if (cpu_is_mx51() || cpu_is_mx53() || cpu_is_mx6())
 		version = SPI_IMX_VER_2_3;
 #endif
 	imx->chipselect = spi_imx_devtype_data[version].chipselect;
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-07-31 18:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-31 18:01 [PATCH] Freescale sabrelite support Sascha Hauer
2012-07-31 18:01 ` Sascha Hauer [this message]
2012-07-31 18:01 ` [PATCH 2/4] ARM i.MX: Add support for internal serial boot mode Sascha Hauer
2012-07-31 18:01 ` [PATCH 3/4] ARM i.MX: Add support for the Freescale i.MX6 sabrelite board Sascha Hauer
2012-07-31 18:01 ` [PATCH 4/4] ARM i.MX: Add defconfig for Freescale i.MX6 Sabre Lite board Sascha Hauer

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=1343757710-12659-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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