linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Jason Wang <jason77.wang@gmail.com>,
	linux-arm-kernel@lists.infradead.org, grant.likely@secretlab.ca,
	amit.kucheria@canonical.com,
	spi-devel-general@lists.sourceforge.net
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 4/6] ARM: mx51: Add spi clock and spi_imx device registration
Date: Thu,  2 Sep 2010 16:42:01 +0200	[thread overview]
Message-ID: <1283438523-19697-4-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20100902143908.GK14214@pengutronix.de>

From: Sascha Hauer <s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/mach-mx5/clock-mx51.c               |   42 ++++++++++++++++++++++++++
 arch/arm/mach-mx5/devices-imx51.h            |   18 +++++++++++
 arch/arm/plat-mxc/devices/platform-spi_imx.c |   17 ++++++++++
 3 files changed, 77 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-mx5/devices-imx51.h

diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index 6af69de..9ab4d17 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -762,6 +762,29 @@ static struct clk kpp_clk = {
 	.id = 0,
 };
 
+static unsigned long clk_cspi_get_rate(struct clk *clk)
+{
+	u32 reg, prediv, podf;
+	unsigned long rate;
+
+	reg = __raw_readl(MXC_CCM_CSCDR2);
+	prediv = ((reg & MXC_CCM_CSCDR2_CSPI_CLK_PRED_MASK) >>
+		  MXC_CCM_CSCDR2_CSPI_CLK_PRED_OFFSET) + 1;
+	if (prediv == 1)
+		BUG();
+	podf = ((reg & MXC_CCM_CSCDR2_CSPI_CLK_PODF_MASK) >>
+		MXC_CCM_CSCDR2_CSPI_CLK_PODF_OFFSET) + 1;
+
+	rate = clk_get_rate(clk->parent) / (prediv * podf);
+
+	return rate;
+}
+
+static struct clk cspi_main_clk = {
+	.parent = &pll3_sw_clk,
+	.get_rate = clk_cspi_get_rate,
+};
+
 #define DEFINE_CLOCK(name, i, er, es, gr, sr, p, s)	\
 	static struct clk name = {			\
 		.id		= i,			\
@@ -810,6 +833,22 @@ DEFINE_CLOCK(i2c2_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG10_OFFSET,
 DEFINE_CLOCK(hsi2c_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG11_OFFSET,
 	NULL, NULL, &ipg_clk, NULL);
 
+/* SPI */
+DEFINE_CLOCK(cspi1_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET,
+	NULL, NULL, &ipg_clk, &spba_clk);
+DEFINE_CLOCK(cspi1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG10_OFFSET,
+	NULL, NULL, &cspi_main_clk, &cspi1_ipg_clk);
+
+DEFINE_CLOCK(cspi2_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG11_OFFSET,
+	NULL, NULL, &ipg_clk, &spba_clk);
+DEFINE_CLOCK(cspi2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG12_OFFSET,
+	NULL, NULL, &cspi_main_clk, &cspi2_ipg_clk);
+
+DEFINE_CLOCK(cspi3_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET,
+	NULL, NULL, &ipg_clk, &aips_tz2_clk);
+DEFINE_CLOCK(cspi3_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG13_OFFSET,
+	NULL, NULL, &cspi_main_clk, &cspi3_ipg_clk);
+
 /* FEC */
 DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET,
 	NULL,  NULL, &ipg_clk, NULL);
@@ -837,6 +876,9 @@ static struct clk_lookup lookups[] = {
 	_REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk)
 	_REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk)
 	_REGISTER_CLOCK("imx-keypad.0", NULL, kpp_clk)
+	_REGISTER_CLOCK("spi_imx.0", NULL, cspi1_clk)
+	_REGISTER_CLOCK("spi_imx.1", NULL, cspi2_clk)
+	_REGISTER_CLOCK("spi_imx.2", NULL, cspi3_clk)
 };
 
 static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/devices-imx51.h b/arch/arm/mach-mx5/devices-imx51.h
new file mode 100644
index 0000000..3901f59
--- /dev/null
+++ b/arch/arm/mach-mx5/devices-imx51.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2010 Pengutronix
+ * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <mach/mx51.h>
+#include <mach/devices-common.h>
+
+extern const struct imx_spi_imx_data imx51_cspi_imx_data __initconst;
+#define imx51_add_cspi_imx(pdata)	\
+	imx_add_spi_imx(&imx51_cspi_imx_data, pdata)
+
+extern struct imx_spi_imx_data imx51_ecspi_imx_data[] __initconst;
+#define imx51_add_ecspi_imx(id, pdata)	\
+	imx_add_spi_imx(&imx51_ecspi_imx_data[id], pdata)
diff --git a/arch/arm/plat-mxc/devices/platform-spi_imx.c b/arch/arm/plat-mxc/devices/platform-spi_imx.c
index 7b7b005..077f936 100644
--- a/arch/arm/plat-mxc/devices/platform-spi_imx.c
+++ b/arch/arm/plat-mxc/devices/platform-spi_imx.c
@@ -67,6 +67,23 @@ const struct imx_spi_imx_data imx35_spi_imx_data[] __initconst = {
 };
 #endif /* ifdef CONFIG_ARCH_MX35 */
 
+#ifdef CONFIG_ARCH_MX51
+/*
+ * until the imx-spi supports platform-ids, the cspi device has to use a
+ * different id than the ecspi devices above.  The driver currently hardcodes 2
+ * for the cspi device.
+ */
+const struct imx_spi_imx_data imx51_cspi_imx_data __initconst =
+	imx_spi_imx_data_entry_single(MX51, CSPI, "imx51-cspi", 2, , SZ_4K);
+
+const struct imx_spi_imx_data imx51_ecspi_imx_data[] __initconst = {
+#define imx51_ecspi_imx_data_entry(_id, _hwid)				\
+	imx_spi_imx_data_entry(MX51, ECSPI, "imx51-ecspi", _id, _hwid, SZ_4K)
+	imx51_ecspi_imx_data_entry(0, 1),
+	imx51_ecspi_imx_data_entry(1, 2),
+};
+#endif /* ifdef CONFIG_ARCH_MX51 */
+
 struct platform_device *__init imx_add_spi_imx(
 		const struct imx_spi_imx_data *data,
 		const struct spi_imx_master *pdata)
-- 
1.7.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2010-09-02 14:42 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-02  7:51 [PATCH 0/6] add spi support for i.MX51 in the existing spi_imx driver Jason Wang
2010-09-02  7:51 ` [PATCH 1/6] spi-imx: add CSPI and eCSPI support for i.MX51 MCU Jason Wang
2010-09-02  7:52   ` [PATCH 2/6] i.MX5/clock: add eCSPI and CSPI clock definitions Jason Wang
2010-09-02  7:52     ` [PATCH 3/6] mx5: add support to dynamically register spi_imx devices (imx51 3ds) Jason Wang
2010-09-02  7:52       ` [PATCH 4/6] mx5/iomux: add iomux definitions for eCSPI2 on the imx51_3ds board Jason Wang
2010-09-02  7:52         ` [PATCH 5/6] mx51_3ds: add eCSPI2 support " Jason Wang
2010-09-02  7:52           ` [PATCH 6/6] mx51_3ds: add SPI NOR flash in the board init stage Jason Wang
2010-09-02 15:05           ` [PATCH 5/6] mx51_3ds: add eCSPI2 support on the imx51_3ds board Uwe Kleine-König
2010-09-03  6:24             ` Jason Wang
2010-09-02 15:02       ` [PATCH 3/6] mx5: add support to dynamically register spi_imx devices (imx51 3ds) Uwe Kleine-König
2010-09-03  6:22         ` Jason Wang
2010-09-02 15:01     ` [PATCH 2/6] i.MX5/clock: add eCSPI and CSPI clock definitions Uwe Kleine-König
2010-09-03  6:22       ` Jason Wang
2010-09-10  9:47         ` Uwe Kleine-König
     [not found]           ` <20100910094714.GF30558-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-09-10 10:04             ` Lothar Waßmann
2010-09-13  3:31           ` Jason Wang
2010-09-02 14:53   ` [PATCH 1/6] spi-imx: add CSPI and eCSPI support for i.MX51 MCU Uwe Kleine-König
2010-09-02 15:11     ` Lothar Waßmann
2010-09-02 17:29       ` Baruch Siach
2010-09-02 17:57         ` Uwe Kleine-König
2010-09-03  8:49         ` Lothar Waßmann
2010-09-03  6:16     ` Jason Wang
2010-09-03  7:54       ` Uwe Kleine-König
2010-09-02  8:27 ` [PATCH 0/6] add spi support for i.MX51 in the existing spi_imx driver Uwe Kleine-König
2010-09-02 10:07   ` Jason Wang
2010-09-02 14:39     ` Uwe Kleine-König
2010-09-02 14:41       ` [PATCH 1/6] ARM: mx51: clean up mx51 header Uwe Kleine-König
2010-09-02 14:41       ` [PATCH 2/6] ARM: mx51: fix naming of spi related defines Uwe Kleine-König
2010-09-02 14:42       ` [PATCH 3/6] ARM: imx: change the way spi-imx devices are registered Uwe Kleine-König
2010-09-02 14:42       ` Uwe Kleine-König [this message]
     [not found]         ` <1283438523-19697-4-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-09-03  5:46           ` [PATCH 4/6] ARM: mx51: Add spi clock and spi_imx device registration Jason Wang
2010-09-02 14:42       ` [PATCH 5/6] spi-imx: Add i.MX51 support Uwe Kleine-König
2010-09-09  5:33         ` Grant Likely
2010-09-09  7:27           ` Uwe Kleine-König
2010-09-02 14:42       ` [PATCH 6/6] ARM: mx5/mx51_babbage: Add spi support Uwe Kleine-König
2010-09-03  3:18       ` [PATCH 0/6] add spi support for i.MX51 in the existing spi_imx driver Jason Wang
2010-09-03  6:41         ` Amit Kucheria
2010-09-03  9:34           ` Robert Schwebel
2010-09-17  9:52       ` Uwe Kleine-König
2010-09-17  9:54         ` [PATCH 01/16] spi/imx: default to m on platforms that have such devices Uwe Kleine-König
2010-09-17  9:54         ` [PATCH 03/16] spi/imx: get rid of more ifs depending on the used cpu Uwe Kleine-König
     [not found]         ` <20100917095247.GB30441-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-09-17  9:54           ` [PATCH 02/16] spi/imx: convert driver to use platform ids Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 04/16] spi/imx: save the spi chip select in config struct, not the gpio to use Uwe Kleine-König
     [not found]             ` <1284717274-12850-4-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-09-17 11:11               ` Lothar Waßmann
2010-09-17 11:20                 ` Russell King - ARM Linux
2010-09-19  8:47                   ` Jason Wang
2010-09-17  9:54           ` [PATCH 05/16] spi/imx: add support for imx51's eCSPI and CSPI Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 06/16] ARM: imx: change the way spi-imx devices are registered Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 07/16] ARM: imx: use platform ids for spi_imx devices Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 08/16] ARM: mx51: clean up mx51 header Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 09/16] ARM: mx51: fix naming of spi related defines Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 10/16] ARM: mx5: add spi_imx device registration Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 11/16] ARM: mx5/clock-mx51: refactor ccgr callbacks to use common code Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 13/16] ARM: mx5/clock-mx51: add spi clocks Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 14/16] ARM: mx5/iomux-mx51: add iomux definitions for eCSPI2 on the imx51_3ds board Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 15/16] ARM: mx5/mx51_3ds: add eCSPI2 support " Uwe Kleine-König
2010-09-17  9:54           ` [PATCH 16/16] ARM: mx5/mx51_3ds: add SPI NOR flash in the board init stage Uwe Kleine-König
2010-09-17  9:54         ` [PATCH 12/16] ARM: mx5/clock-mx51: new macro that defines a clk with all members Uwe Kleine-König
2010-09-19  8:53         ` [PATCH 0/6] add spi support for i.MX51 in the existing spi_imx driver Jason Wang
2010-09-20 15:33           ` Uwe Kleine-König
2010-09-21  1:39             ` Jason Wang
2010-09-24  7:00         ` Grant Likely
2010-09-24  9:11           ` Uwe Kleine-König
2010-09-24 16:12             ` Grant Likely
2010-09-24 18:18               ` Uwe Kleine-König
     [not found]       ` <20100902143908.GK14214-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-10-08  9:24         ` [PATCH 7/6] spi/imx: Support different fifo sizes Uwe Kleine-König
     [not found]           ` <1286529841-20800-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-10-08 16:39             ` Grant Likely

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=1283438523-19697-4-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=amit.kucheria@canonical.com \
    --cc=grant.likely@secretlab.ca \
    --cc=jason77.wang@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    --cc=spi-devel-general@lists.sourceforge.net \
    /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).