Skip to contentSkip to conversation

AHCI Add the AHCI SATA feature on MX53 platforms

PATCH Superseded Richard Zhu 3 participants 6 messages Apr 11, 2011

Subsystems (4)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 AHCI Add the AHCI SATA feature on MX53 platforms

---
 arch/arm/mach-mx5/clock-mx51-mx53.c             |   11 +++++
 arch/arm/mach-mx5/devices-imx53.h               |    4 ++
 arch/arm/plat-mxc/Makefile                      |    1 +
 arch/arm/plat-mxc/ahci_sata.c                   |   43 ++++++++++++++++++
 arch/arm/plat-mxc/devices/Kconfig               |    4 ++
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   55 +++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/ahci_sata.h      |   52 +++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++++
 9 files changed, 181 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-mxc/ahci_sata.c
 create mode 100644 arch/arm/plat-mxc/devices/platform-ahci-imx.c
 create mode 100644 arch/arm/plat-mxc/include/mach/ahci_sata.h
arch/arm/mach-mx5/clock-mx51-mx53.c +11 -0
index 652ace4..8bf2bab 100644
@@ -1380,6 +1380,14 @@ static struct clk esdhc4_mx53_clk = {
 	.secondary = &esdhc4_ipg_clk,
 };
 
+static struct clk sata_clk = {
+	.parent = &ipg_clk,
+	.enable = _clk_max_enable,
+	.enable_reg = MXC_CCM_CCGR4,
+	.enable_shift = MXC_CCM_CCGRx_CG1_OFFSET,
+	.disable = _clk_max_disable,
+};
+
 DEFINE_CLOCK(mipi_esc_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG5_OFFSET, NULL, NULL, NULL, &pll2_sw_clk);
 DEFINE_CLOCK(mipi_hsc2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG4_OFFSET, NULL, NULL, &mipi_esc_clk, &pll2_sw_clk);
 DEFINE_CLOCK(mipi_hsc1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG3_OFFSET, NULL, NULL, &mipi_hsc2_clk, &pll2_sw_clk);
@@ -1468,6 +1476,9 @@ static struct clk_lookup mx53_lookups[] = {
 	_REGISTER_CLOCK("imx53-cspi.0", NULL, cspi_clk)
 	_REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk)
 	_REGISTER_CLOCK("imx2-wdt.1", NULL, dummy_clk)
+	_REGISTER_CLOCK("ahci.0", NULL, sata_clk)
+	_REGISTER_CLOCK(NULL, "usb_phy1", usb_phy1_clk)
+	_REGISTER_CLOCK(NULL, "ahb", ahb_clk)
 };
 
 static void clk_tree_init(void)
arch/arm/mach-mx5/devices-imx53.h +4 -0
index 9251008..09ebb43 100644
@@ -33,3 +33,7 @@ extern const struct imx_spi_imx_data imx53_ecspi_data[] __initconst;
 extern const struct imx_imx2_wdt_data imx53_imx2_wdt_data[] __initconst;
 #define imx53_add_imx2_wdt(id, pdata)	\
 	imx_add_imx2_wdt(&imx53_imx2_wdt_data[id])
+
+extern const struct imx_ahci_imx_data imx53_ahci_imx_data[] __initconst;
+#define imx53_add_ahci_imx(id, pdata)   \
+	imx_add_ahci_imx(&imx53_ahci_imx_data[id], pdata)
arch/arm/plat-mxc/Makefile +1 -0
index a138787..4f308c6 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o
 obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o
 obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
 obj-$(CONFIG_CPU_FREQ_IMX)    += cpufreq.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_SATA_AHCI)	+= ahci_sata.o
 ifdef CONFIG_SND_IMX_SOC
 obj-y += ssi-fiq.o
 obj-y += ssi-fiq-ksym.o
arch/arm/plat-mxc/ahci_sata.c new file +43 -0

43 lines not on this page · raw message

arch/arm/plat-mxc/devices/Kconfig +4 -0
index b9ab1d5..087595a 100644
@@ -71,3 +71,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 
 config IMX_HAVE_PLATFORM_SPI_IMX
 	bool
+
+config IMX_HAVE_PLATFORM_SATA_AHCI
+	bool
+	default y if SOC_IMX53
arch/arm/plat-mxc/devices/Makefile +1 -0
index 75cd2ec..e0b7fa3 100644
@@ -22,3 +22,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RNGA) += platform-mxc_rnga.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_W1) += platform-mxc_w1.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX) += platform-sdhci-esdhc-imx.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) +=  platform-spi_imx.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_SATA_AHCI) +=  platform-ahci-imx.o
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +55 -0

55 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/ahci_sata.h new file +52 -0

52 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/devices-common.h +10 -0
index 8658c9c..81baca6 100644
@@ -264,3 +264,13 @@ struct imx_spi_imx_data {
 struct platform_device *__init imx_add_spi_imx(
 		const struct imx_spi_imx_data *data,
 		const struct spi_imx_master *pdata);
+
+#include <linux/ahci_platform.h>
+struct imx_ahci_imx_data {
+	int id;
+	resource_size_t iobase;
+	resource_size_t irq;
+};
+struct platform_device *__init imx_add_ahci_imx(
+		const struct imx_ahci_imx_data *data,
+		const struct ahci_platform_data *pdata);
Signature · 1 line
1.7.1
#1 lore raw

PATCH v3 2/2 MX53 Enable the AHCI SATA on MX53 LOCO

---
 arch/arm/mach-mx5/board-mx53_loco.c |   76 +++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)
arch/arm/mach-mx5/board-mx53_loco.c +76 -0
index 0a18f8d..489830a 100644
@@ -23,11 +23,13 @@
 #include <linux/fec.h>
 #include <linux/delay.h>
 #include <linux/gpio.h>
+#include <linux/ahci_platform.h>
 
 #include <mach/common.h>
 #include <mach/hardware.h>
 #include <mach/imx-uart.h>
 #include <mach/iomux-mx53.h>
+#include <mach/ahci_sata.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -38,6 +40,8 @@
 
 #define LOCO_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
 
+static struct clk *sata_clk, *sata_ref_clk;
+
 static iomux_v3_cfg_t mx53_loco_pads[] = {
 	/* FEC */
 	MX53_PAD_FEC_MDC__FEC_MDC,
@@ -203,6 +207,77 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+/* HW Initialization, if return 0, initialization is successful. */
+static int mx53_loco_sata_init(struct device *dev, void __iomem *addr)
+{
+	int ret = 0;
+	struct clk *clk;
+
+	sata_clk = clk_get(dev, NULL);
+	if (IS_ERR(sata_clk)) {
+		dev_err(dev, "no sata clock.\n");
+		return PTR_ERR(sata_clk);
+	}
+	ret = clk_enable(sata_clk);
+	if (ret) {
+		dev_err(dev, "can't enable sata clock.\n");
+		clk_put(sata_clk);
+		return ret;
+	}
+
+	/* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
+	sata_ref_clk = clk_get(NULL, "usb_phy1");
+	if (IS_ERR(sata_ref_clk)) {
+		dev_err(dev, "no sata ref clock.\n");
+		ret = PTR_ERR(sata_ref_clk);
+		goto release_sata_clk;
+	}
+	ret = clk_enable(sata_ref_clk);
+	if (ret) {
+		dev_err(dev, "can't enable sata ref clock.\n");
+		clk_put(sata_ref_clk);
+		goto release_sata_clk;
+	}
+
+	/* Get the AHB clock rate, and configure the TIMER1MS reg later */
+	clk = clk_get(NULL, "ahb");
+	if (IS_ERR(clk)) {
+		dev_err(dev, "no ahb clock.\n");
+		ret = PTR_ERR(clk);
+		goto release_sata_ref_clk;
+	}
+
+	sata_init(addr, clk);
+
+	clk = NULL;
+	return ret;
+
+release_sata_ref_clk:
+	clk_disable(sata_ref_clk);
+	clk_put(sata_ref_clk);
+
+release_sata_clk:
+	clk_disable(sata_clk);
+	clk_put(sata_clk);
+
+	clk = NULL;
+	return ret;
+}
+
+static void sata_exit(struct device *dev)
+{
+	clk_disable(sata_ref_clk);
+	clk_put(sata_ref_clk);
+
+	clk_disable(sata_clk);
+	clk_put(sata_clk);
+}
+
+static struct ahci_platform_data sata_data = {
+	.init = mx53_loco_sata_init,
+	.exit = sata_exit,
+};
+
 static void __init mx53_loco_board_init(void)
 {
 	mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,
@@ -215,6 +290,7 @@ static void __init mx53_loco_board_init(void)
 	imx53_add_imx_i2c(1, &mx53_loco_i2c_data);
 	imx53_add_sdhci_esdhc_imx(0, NULL);
 	imx53_add_sdhci_esdhc_imx(2, NULL);
+	imx53_add_ahci_imx(0, &sata_data);
 }
 
 static void __init mx53_loco_timer_init(void)
Signature · 1 line
1.7.1
#2 lore raw

PATCH v3 2/2 MX53 Enable the AHCI SATA on MX53 LOCO

Quoted 10 lines · Richard Zhu
---
 arch/arm/mach-mx5/board-mx53_loco.c |   76 +++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)
arch/arm/mach-mx5/board-mx53_loco.c +0 -0
index 0a18f8d..489830a 100644

arch/arm/mach-mx5/board-mx53_loco.c line 26

Quoted 4 lines
arch/arm/mach-mx5/board-mx53_loco.c +1 -0
@@ -23,11 +23,13 @@
 #include <linux/fec.h>
 #include <linux/delay.h>
 #include <linux/gpio.h>
+#include <linux/ahci_platform.h>

this shouldn't be needed, as devices-common already #includes it.

Quoted 55 lines
arch/arm/mach-mx5/board-mx53_loco.c +36 -0
 #include <mach/common.h>
 #include <mach/hardware.h>
 #include <mach/imx-uart.h>
 #include <mach/iomux-mx53.h>
+#include <mach/ahci_sata.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -38,6 +40,8 @@
 
 #define LOCO_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
 
+static struct clk *sata_clk, *sata_ref_clk;
+
 static iomux_v3_cfg_t mx53_loco_pads[] = {
 	/* FEC */
 	MX53_PAD_FEC_MDC__FEC_MDC,
@@ -203,6 +207,77 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+/* HW Initialization, if return 0, initialization is successful. */
+static int mx53_loco_sata_init(struct device *dev, void __iomem *addr)
+{
+	int ret = 0;
+	struct clk *clk;
+
+	sata_clk = clk_get(dev, NULL);
+	if (IS_ERR(sata_clk)) {
+		dev_err(dev, "no sata clock.\n");
+		return PTR_ERR(sata_clk);
+	}
+	ret = clk_enable(sata_clk);
+	if (ret) {
+		dev_err(dev, "can't enable sata clock.\n");
+		clk_put(sata_clk);
+		return ret;
+	}
+
+	/* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
+	sata_ref_clk = clk_get(NULL, "usb_phy1");
+	if (IS_ERR(sata_ref_clk)) {
+		dev_err(dev, "no sata ref clock.\n");
+		ret = PTR_ERR(sata_ref_clk);
+		goto release_sata_clk;
+	}
+	ret = clk_enable(sata_ref_clk);
+	if (ret) {
+		dev_err(dev, "can't enable sata ref clock.\n");
+		clk_put(sata_ref_clk);
+		goto release_sata_clk;
+	}
+
+	/* Get the AHB clock rate, and configure the TIMER1MS reg later */

arch/arm/mach-mx5/board-mx53_loco.c static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = { · line 252

Quoted 10 lines
arch/arm/mach-mx5/board-mx53_loco.c +10 -0
+	clk = clk_get(NULL, "ahb");
+	if (IS_ERR(clk)) {
+		dev_err(dev, "no ahb clock.\n");
+		ret = PTR_ERR(clk);
+		goto release_sata_ref_clk;
+	}
+
+	sata_init(addr, clk);
+
+	clk = NULL;

This isn't needed. And ah, there is the clk_get. This looks all strange. If sata_ref_clk is needed to have ahci working it should be enabled automatically (maybe by making it a secondary clk?) Otherwise it's always on. Same for sata_ref_clk -> sata_clk.

arch/arm/mach-mx5/board-mx53_loco.c static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = { · line 263

Quoted 11 lines
arch/arm/mach-mx5/board-mx53_loco.c +11 -0
+	return ret;
+
+release_sata_ref_clk:
+	clk_disable(sata_ref_clk);
+	clk_put(sata_ref_clk);
+
+release_sata_clk:
+	clk_disable(sata_clk);
+	clk_put(sata_clk);
+
+	clk = NULL;

not needed

arch/arm/mach-mx5/board-mx53_loco.c static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = { · line 267

Quoted 4 lines
arch/arm/mach-mx5/board-mx53_loco.c +4 -0
+	return ret;
+}
+
+static void sata_exit(struct device *dev)

mx53_loco_sata_exit?

Quoted 22 lines
arch/arm/mach-mx5/board-mx53_loco.c +14 -0
+{
+	clk_disable(sata_ref_clk);
+	clk_put(sata_ref_clk);
+
+	clk_disable(sata_clk);
+	clk_put(sata_clk);
+}
+
+static struct ahci_platform_data sata_data = {
+	.init = mx53_loco_sata_init,
+	.exit = sata_exit,
+};
+
 static void __init mx53_loco_board_init(void)
 {
 	mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,
@@ -215,6 +290,7 @@ static void __init mx53_loco_board_init(void)
 	imx53_add_imx_i2c(1, &mx53_loco_i2c_data);
 	imx53_add_sdhci_esdhc_imx(0, NULL);
 	imx53_add_sdhci_esdhc_imx(2, NULL);
+	imx53_add_ahci_imx(0, &sata_data);
 }
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#3 lore raw

PATCH v3 2/2 MX53 Enable the AHCI SATA on MX53 LOCO

Hi Uwe:
Thanks for your comments.

Best Regards
Richard Zhu

Quoted 16 lines

-----Original Message-----
From: Uwe Kleine-K?nig [mailto:u.kleine-koenig at pengutronix.de]
Sent: Monday, April 11, 2011 4:22 PM
To: Zhu Richard-R65037
Cc: linux-arm-kernel at lists.infradead.org; jgarzik at pobox.com; kernel at pengutronix.de; linux-ide at vger.kernel.org; avorontsov at ru.mvista.com; eric at eukrea.com; eric.miao at linaro.org
Subject: Re: [PATCH V3 2/2] MX53 Enable the AHCI SATA on MX53 LOCO

Quoted 3 lines · Richard Zhu
---
 arch/arm/mach-mx5/board-mx53_loco.c |   76

+++++++++++++++++++++++++++++++++++

Quoted 2 lines
 1 files changed, 76 insertions(+), 0 deletions(-)
Quoted 11 lines

arch/arm/mach-mx5/board-mx53_loco.c line 26

Quoted 10 lines
arch/arm/mach-mx5/board-mx53_loco.c +1 -0
index 0a18f8d..489830a 100644
@@ -23,11 +23,13 @@
 #include <linux/fec.h>
 #include <linux/delay.h>
 #include <linux/gpio.h>
+#include <linux/ahci_platform.h>

this shouldn't be needed, as devices-common already #includes it.

Accepted.

Quoted 63 lines

arch/arm/mach-mx5/board-mx53_loco.c static const struct imxi2c_platform_data

Quoted 20 lines
arch/arm/mach-mx5/board-mx53_loco.c +3 -0
 #include <mach/common.h>
 #include <mach/hardware.h>
 #include <mach/imx-uart.h>
 #include <mach/iomux-mx53.h>
+#include <mach/ahci_sata.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -38,6 +40,8 @@
 
 #define LOCO_FEC_PHY_RST           IMX_GPIO_NR(7, 6)
 
+static struct clk *sata_clk, *sata_ref_clk;
+
 static iomux_v3_cfg_t mx53_loco_pads[] = {
    /* FEC */
    MX53_PAD_FEC_MDC__FEC_MDC,
@@ -203,6 +207,77 @@ static const struct imxi2c_platform_data

mx53_loco_i2c_data __initconst = {

Quoted 42 lines
arch/arm/mach-mx5/board-mx53_loco.c +39 -0
    .bitrate = 100000,
 };
 
+/* HW Initialization, if return 0, initialization is successful. */
+static int mx53_loco_sata_init(struct device *dev, void __iomem
+*addr) {
+   int ret = 0;
+   struct clk *clk;
+
+   sata_clk = clk_get(dev, NULL);
+   if (IS_ERR(sata_clk)) {
+           dev_err(dev, "no sata clock.\n");
+           return PTR_ERR(sata_clk);
+   }
+   ret = clk_enable(sata_clk);
+   if (ret) {
+           dev_err(dev, "can't enable sata clock.\n");
+           clk_put(sata_clk);
+           return ret;
+   }
+
+   /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
+   sata_ref_clk = clk_get(NULL, "usb_phy1");
+   if (IS_ERR(sata_ref_clk)) {
+           dev_err(dev, "no sata ref clock.\n");
+           ret = PTR_ERR(sata_ref_clk);
+           goto release_sata_clk;
+   }
+   ret = clk_enable(sata_ref_clk);
+   if (ret) {
+           dev_err(dev, "can't enable sata ref clock.\n");
+           clk_put(sata_ref_clk);
+           goto release_sata_clk;
+   }
+
+   /* Get the AHB clock rate, and configure the TIMER1MS reg later */
+   clk = clk_get(NULL, "ahb");
+   if (IS_ERR(clk)) {
+           dev_err(dev, "no ahb clock.\n");
+           ret = PTR_ERR(clk);
+           goto release_sata_ref_clk;
+   }
Quoted 9 lines

arch/arm/mach-mx5/board-mx53_loco.c static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = { · line 252

Quoted 4 lines
arch/arm/mach-mx5/board-mx53_loco.c +4 -0
+
+   sata_init(addr, clk);
+
+   clk = NULL;

This isn't needed. And ah, there is the clk_get. This looks all strange. If sata_ref_clk is needed to have ahci working it should be enabled automatically (maybe by making it a secondary clk?) Otherwise it's always on. Same for sata_ref_clk -> sata_clk.

Accepted. The clk get/put symmetric issue would be fixed later.
About the sata_ref_clk.
Different MX53 boards have the different clks resources.
Some boards need both the sata_clk and usb_phy1 clks, but some other boards don't need usb_phy1 clk. So it's better that don't let it a secondary clk of sata.

Quoted 4 lines
Quoted 4 lines
arch/arm/mach-mx5/board-mx53_loco.c +4 -0
+   return ret;
+
+release_sata_ref_clk:
+   clk_disable(sata_ref_clk);
Quoted 8 lines

arch/arm/mach-mx5/board-mx53_loco.c static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = { · line 263

Quoted 7 lines
arch/arm/mach-mx5/board-mx53_loco.c +7 -0
+   clk_put(sata_ref_clk);
+
+release_sata_clk:
+   clk_disable(sata_clk);
+   clk_put(sata_clk);
+
+   clk = NULL;

not needed

Accepted.

Quoted 7 lines

arch/arm/mach-mx5/board-mx53_loco.c static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = { · line 267

Quoted 5 lines
arch/arm/mach-mx5/board-mx53_loco.c +4 -0
+   return ret;
+}
+
+static void sata_exit(struct device *dev)

mx53_loco_sata_exit?

Accepted.

Quoted 27 lines
Quoted 16 lines
arch/arm/mach-mx5/board-mx53_loco.c +13 -0
+{
+   clk_disable(sata_ref_clk);
+   clk_put(sata_ref_clk);
+
+   clk_disable(sata_clk);
+   clk_put(sata_clk);
+}
+
+static struct ahci_platform_data sata_data = {
+   .init = mx53_loco_sata_init,
+   .exit = sata_exit,
+};
+
 static void __init mx53_loco_board_init(void)  {
    mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,

arch/arm/mach-mx5/board-mx53_loco.c static void __init mx53_loco_board_init(void) · line 294

Quoted 5 lines
arch/arm/mach-mx5/board-mx53_loco.c +1 -0
@@ -215,6 +290,7 @@ static void __init mx53_loco_board_init(void)
    imx53_add_imx_i2c(1, &mx53_loco_i2c_data);
    imx53_add_sdhci_esdhc_imx(0, NULL);
    imx53_add_sdhci_esdhc_imx(2, NULL);
+   imx53_add_ahci_imx(0, &sata_data);
 }

--
Pengutronix e.K. | Uwe Kleine-K?nig
|
Industrial Linux Solutions | http://www.pengutronix.de/
|

#4 lore raw

PATCH v3 1/2 AHCI Add the AHCI SATA feature on MX53 platforms

In reply to Richard Zhu

Hello Richard,

Quoted 50 lines · Richard Zhu
---
 arch/arm/mach-mx5/clock-mx51-mx53.c             |   11 +++++
 arch/arm/mach-mx5/devices-imx53.h               |    4 ++
 arch/arm/plat-mxc/Makefile                      |    1 +
 arch/arm/plat-mxc/ahci_sata.c                   |   43 ++++++++++++++++++
 arch/arm/plat-mxc/devices/Kconfig               |    4 ++
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   55 +++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/ahci_sata.h      |   52 +++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++++
 9 files changed, 181 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-mxc/ahci_sata.c
 create mode 100644 arch/arm/plat-mxc/devices/platform-ahci-imx.c
 create mode 100644 arch/arm/plat-mxc/include/mach/ahci_sata.h
arch/arm/mach-mx5/clock-mx51-mx53.c +11 -0
index 652ace4..8bf2bab 100644
@@ -1380,6 +1380,14 @@ static struct clk esdhc4_mx53_clk = {
 	.secondary = &esdhc4_ipg_clk,
 };
 
+static struct clk sata_clk = {
+	.parent = &ipg_clk,
+	.enable = _clk_max_enable,
+	.enable_reg = MXC_CCM_CCGR4,
+	.enable_shift = MXC_CCM_CCGRx_CG1_OFFSET,
+	.disable = _clk_max_disable,
+};
+
 DEFINE_CLOCK(mipi_esc_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG5_OFFSET, NULL, NULL, NULL, &pll2_sw_clk);
 DEFINE_CLOCK(mipi_hsc2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG4_OFFSET, NULL, NULL, &mipi_esc_clk, &pll2_sw_clk);
 DEFINE_CLOCK(mipi_hsc1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG3_OFFSET, NULL, NULL, &mipi_hsc2_clk, &pll2_sw_clk);
@@ -1468,6 +1476,9 @@ static struct clk_lookup mx53_lookups[] = {
 	_REGISTER_CLOCK("imx53-cspi.0", NULL, cspi_clk)
 	_REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk)
 	_REGISTER_CLOCK("imx2-wdt.1", NULL, dummy_clk)
+	_REGISTER_CLOCK("ahci.0", NULL, sata_clk)
+	_REGISTER_CLOCK(NULL, "usb_phy1", usb_phy1_clk)
+	_REGISTER_CLOCK(NULL, "ahb", ahb_clk)
 };
 
 static void clk_tree_init(void)
arch/arm/mach-mx5/devices-imx53.h +0 -0
index 9251008..09ebb43 100644

arch/arm/mach-mx5/devices-imx53.h extern const struct imx_spi_imx_data imx53_ecspi_data[] __initconst; · line 39

Quoted 7 lines
arch/arm/mach-mx5/devices-imx53.h +4 -0
@@ -33,3 +33,7 @@ extern const struct imx_spi_imx_data imx53_ecspi_data[] __initconst;
 extern const struct imx_imx2_wdt_data imx53_imx2_wdt_data[] __initconst;
 #define imx53_add_imx2_wdt(id, pdata)	\
 	imx_add_imx2_wdt(&imx53_imx2_wdt_data[id])
+
+extern const struct imx_ahci_imx_data imx53_ahci_imx_data[] __initconst;
+#define imx53_add_ahci_imx(id, pdata)   \
+	imx_add_ahci_imx(&imx53_ahci_imx_data[id], pdata)

The platform device name is "ahci", so please use imx(53)?_add_ahci(...) here.

arch/arm/plat-mxc/Makefile obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o · line 22

Quoted 9 lines
arch/arm/plat-mxc/Makefile +1 -0
index a138787..4f308c6 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o
 obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o
 obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
 obj-$(CONFIG_CPU_FREQ_IMX)    += cpufreq.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_SATA_AHCI)	+= ahci_sata.o

CONFIG_IMX_HAVE_PLATFORM_AHCI for the same reason.

Quoted 15 lines
arch/arm/plat-mxc/Makefile +0 -0
 ifdef CONFIG_SND_IMX_SOC
 obj-y += ssi-fiq.o
 obj-y += ssi-fiq-ksym.o
arch/arm/plat-mxc/ahci_sata.c new file +6 -0
new file mode 100644
index 0000000..49cbb68
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your

arch/arm/plat-mxc/ahci_sata.c line 16

Quoted 10 lines
arch/arm/plat-mxc/ahci_sata.c new file +10 -0
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

this address isn't valid anymore.

Quoted 13 lines
arch/arm/plat-mxc/ahci_sata.c new file +13 -0
+ */
+
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <mach/ahci_sata.h>
+
+/* AHCI module Initialization, if return 0, initialization is successful. */
+int sata_init(void __iomem *addr, struct clk *clk)
+{
+	u32 tmpdata;
+
+	tmpdata = readl(addr + HOST_CAP);
+	if (!(tmpdata & HOST_CAP_SSS)) {

arch/arm/plat-mxc/ahci_sata.c line 39

Quoted 10 lines
arch/arm/plat-mxc/ahci_sata.c new file +10 -0
+		tmpdata |= HOST_CAP_SSS;
+		writel(tmpdata, addr + HOST_CAP);
+	}
+
+	if (!(readl(addr + HOST_PORTS_IMPL) & 0x1))
+		writel((readl(addr + HOST_PORTS_IMPL) | 0x1),
+			addr + HOST_PORTS_IMPL);
+
+	tmpdata = clk_get_rate(clk) / 1000;
+	clk_put(clk);

Where is the symmetric clk_get?

Quoted 9 lines
arch/arm/plat-mxc/ahci_sata.c new file +4 -0
+	writel(tmpdata, addr + HOST_TIMER1MS);
+
+	return 0;
+}
arch/arm/plat-mxc/devices/Kconfig +0 -0
index b9ab1d5..087595a 100644

arch/arm/plat-mxc/devices/Kconfig config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX · line 77

Quoted 7 lines
arch/arm/plat-mxc/devices/Kconfig +4 -0
@@ -71,3 +71,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 
 config IMX_HAVE_PLATFORM_SPI_IMX
 	bool
+
+config IMX_HAVE_PLATFORM_SATA_AHCI
+	bool
+	default y if SOC_IMX53

Can you please keep this file sorted by config name?
Do all i.MX53 have ahci? If so, consider registration as it is done for mxc_rnga. If not, please let the machines that really use it select IMX_HAVE_PLATFORM_AHCI.

arch/arm/plat-mxc/devices/Makefile obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RNGA) += platform-mxc_rnga.o · line 25

Quoted 9 lines
arch/arm/plat-mxc/devices/Makefile +1 -0
index 75cd2ec..e0b7fa3 100644
@@ -22,3 +22,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RNGA) += platform-mxc_rnga.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_W1) += platform-mxc_w1.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX) += platform-sdhci-esdhc-imx.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) +=  platform-spi_imx.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_SATA_AHCI) +=  platform-ahci-imx.o

This file is sorted, too.

Quoted 30 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +24 -0
new file mode 100644
index 0000000..d6da344
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+

arch/arm/plat-mxc/devices/platform-ahci-imx.c line 34

Quoted 10 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +10 -0
+#define imx_ahci_data_entry_single(soc)					\
+	{								\
+		.iobase = soc ## _SATA_BASE_ADDR,			\
+		.irq = soc ## _INT_SATA,				\
+	}
+
+#ifdef CONFIG_SOC_IMX53
+const struct imx_ahci_imx_data imx53_ahci_imx_data __initconst =
+	imx_ahci_data_entry_single(MX53);
+#endif

arch/arm/mach-mx5/devices-imx53.h declares this to be an array.

Quoted 10 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +10 -0
+
+struct platform_device *__init imx_add_ahci_imx(
+		const struct imx_ahci_imx_data *data,
+		const struct ahci_platform_data *pdata)
+{
+	struct resource res[] = {
+		{
+			.start = data->iobase,
+			.end = data->iobase + SZ_4K - 1,
+			.flags = IORESOURCE_MEM,

arch/arm/plat-mxc/devices/platform-ahci-imx.c line 54

Quoted 10 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +10 -0
+		}, {
+			.start = data->irq,
+			.end = data->irq,
+			.flags = IORESOURCE_IRQ,
+		},
+	};
+
+	return imx_add_platform_device_dmamask("ahci", 0,
+			res, ARRAY_SIZE(res),
+			pdata, sizeof(*pdata),  DMA_BIT_MASK(32));

s/ / /

Quoted 67 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +1 -0
+}
arch/arm/plat-mxc/include/mach/ahci_sata.h new file +52 -0
new file mode 100644
index 0000000..6adf67a
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __PLAT_MXC_AHCI_SATA_H__
+#define __PLAT_MXC_AHCI_SATA_H__
+
+enum {
+	HOST_CAP = 0x00,
+	HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */
+	HOST_PORTS_IMPL	= 0x0c,
+	HOST_TIMER1MS = 0xe0, /* Timer 1-ms */
+	/* Offest used to control the MPLL input clk */
+	PHY_CR_CLOCK_FREQ_OVRD = 0x12,
+	/* Port0 SATA Status */
+	PORT_SATA_SR = 0x128,
+	/* Port0 PHY Control */
+	PORT_PHY_CTL = 0x178,
+	/* PORT_PHY_CTL bits */
+	PORT_PHY_CTL_CAP_ADR_LOC = 0x10000,
+	PORT_PHY_CTL_CAP_DAT_LOC = 0x20000,
+	PORT_PHY_CTL_WRITE_LOC = 0x40000,
+	PORT_PHY_CTL_READ_LOC = 0x80000,
+	/* Port0 PHY Status */
+	PORT_PHY_SR = 0x17c,
+	/* PORT_PHY_SR */
+	PORT_PHY_STAT_DATA_LOC = 0,
+	PORT_PHY_STAT_ACK_LOC = 18,
+	/* SATA PHY Register */
+	SATA_PHY_CR_CLOCK_CRCMP_LT_LIMIT = 0x0001,
+	SATA_PHY_CR_CLOCK_DAC_CTL = 0x0008,
+	SATA_PHY_CR_CLOCK_RTUNE_CTL = 0x0009,
+	SATA_PHY_CR_CLOCK_ADC_OUT = 0x000A,
+	SATA_PHY_CR_CLOCK_MPLL_TST = 0x0017,
+};
+
+extern int sata_init(void __iomem *addr, struct clk *clk);
+#endif /* __PLAT_MXC_AHCI_SATA_H__ */
arch/arm/plat-mxc/include/mach/devices-common.h +0 -0
index 8658c9c..81baca6 100644
@@ -264,3 +264,13 @@ struct imx_spi_imx_data {
 struct platform_device *__init imx_add_spi_imx(
 		const struct imx_spi_imx_data *data,
 		const struct spi_imx_master *pdata);

arch/arm/plat-mxc/include/mach/devices-common.h struct imx_spi_imx_data { · line 276

Quoted 10 lines
arch/arm/plat-mxc/include/mach/devices-common.h +10 -0
+
+#include <linux/ahci_platform.h>
+struct imx_ahci_imx_data {
+	int id;
+	resource_size_t iobase;
+	resource_size_t irq;
+};
+struct platform_device *__init imx_add_ahci_imx(
+		const struct imx_ahci_imx_data *data,
+		const struct ahci_platform_data *pdata);

this file is sorted, too.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#5 lore raw

PATCH v3 1/2 AHCI Add the AHCI SATA feature on MX53 platforms

Hi Uwe:
Thanks for your comments.

Best Regards
Richard Zhu

Quoted 78 lines

-----Original Message-----
From: Uwe Kleine-K?nig [mailto:u.kleine-koenig at pengutronix.de]
Sent: Monday, April 11, 2011 4:17 PM
To: Zhu Richard-R65037
Cc: linux-arm-kernel at lists.infradead.org; jgarzik at pobox.com; kernel at pengutronix.de; linux-ide at vger.kernel.org; avorontsov at ru.mvista.com; eric at eukrea.com; eric.miao at linaro.org
Subject: Re: [PATCH V3 1/2] AHCI Add the AHCI SATA feature on MX53 platforms

Hello Richard,

Quoted 6 lines · Richard Zhu
---
 arch/arm/mach-mx5/clock-mx51-mx53.c             |   11 +++++
 arch/arm/mach-mx5/devices-imx53.h               |    4 ++
 arch/arm/plat-mxc/Makefile                      |    1 +
 arch/arm/plat-mxc/ahci_sata.c                   |   43

++++++++++++++++++

Quoted 3 lines
 arch/arm/plat-mxc/devices/Kconfig               |    4 ++
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   55

+++++++++++++++++++++++

Quoted 1 line
 arch/arm/plat-mxc/include/mach/ahci_sata.h      |   52

+++++++++++++++++++++

Quoted 26 lines
 arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++++
 9 files changed, 181 insertions(+), 0 deletions(-)  create mode
100644 arch/arm/plat-mxc/ahci_sata.c  create mode 100644
arch/arm/plat-mxc/devices/platform-ahci-imx.c
 create mode 100644 arch/arm/plat-mxc/include/mach/ahci_sata.h
arch/arm/mach-mx5/clock-mx51-mx53.c +8 -0
index 652ace4..8bf2bab 100644
@@ -1380,6 +1380,14 @@ static struct clk esdhc4_mx53_clk = {
    .secondary = &esdhc4_ipg_clk,
 };
 
+static struct clk sata_clk = {
+   .parent = &ipg_clk,
+   .enable = _clk_max_enable,
+   .enable_reg = MXC_CCM_CCGR4,
+   .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET,
+   .disable = _clk_max_disable,
+};
+
 DEFINE_CLOCK(mipi_esc_clk, 0, MXC_CCM_CCGR4,
 MXC_CCM_CCGRx_CG5_OFFSET, NULL, NULL, NULL, &pll2_sw_clk);
 DEFINE_CLOCK(mipi_hsc2_clk, 0, MXC_CCM_CCGR4,
Quoted 1 line

MXC_CCM_CCGRx_CG4_OFFSET, NULL, NULL, &mipi_esc_clk, &pll2_sw_clk);

DEFINE_CLOCK(mipi_hsc1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG3_OFFSET, NULL, NULL, &mipi_hsc2_clk, &pll2_sw_clk); @@ -1468,6 +1476,9 @@ static struct clk_lookup mx53_lookups[] = {

Quoted 15 lines
    _REGISTER_CLOCK("imx53-cspi.0", NULL, cspi_clk)
    _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk)
    _REGISTER_CLOCK("imx2-wdt.1", NULL, dummy_clk)
arch/arm/mach-mx5/clock-mx51-mx53.c +3 -0
+   _REGISTER_CLOCK("ahci.0", NULL, sata_clk)
+   _REGISTER_CLOCK(NULL, "usb_phy1", usb_phy1_clk)
+   _REGISTER_CLOCK(NULL, "ahb", ahb_clk)
 };
 
 static void clk_tree_init(void)
arch/arm/mach-mx5/devices-imx53.h +0 -0
index 9251008..09ebb43 100644
@@ -33,3 +33,7 @@ extern const struct imx_spi_imx_data
Quoted 1 line

imx53_ecspi_data[] __initconst; extern const struct imx_imx2_wdt_data

imx53_imx2_wdt_data[] __initconst;

arch/arm/mach-mx5/devices-imx53.h

Quoted 4 lines
 #define imx53_add_imx2_wdt(id, pdata)      \
    imx_add_imx2_wdt(&imx53_imx2_wdt_data[id])
arch/arm/mach-mx5/devices-imx53.h +2 -0
+
+extern const struct imx_ahci_imx_data imx53_ahci_imx_data[]

__initconst;

Quoted 4 lines

arch/arm/mach-mx5/devices-imx53.h extern const struct imx_spi_imx_data imx53_ecspi_data[] __initconst; · line 39

Quoted 2 lines
arch/arm/mach-mx5/devices-imx53.h +2 -0
+#define imx53_add_ahci_imx(id, pdata)   \
+   imx_add_ahci_imx(&imx53_ahci_imx_data[id], pdata)

The platform device name is "ahci", so please use imx(53)?_add_ahci(...) here.

Accepted.

Quoted 11 lines

arch/arm/plat-mxc/Makefile obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o · line 22

Quoted 10 lines
arch/arm/plat-mxc/Makefile +1 -0
index a138787..4f308c6 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o
 obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o
 obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
 obj-$(CONFIG_CPU_FREQ_IMX)    += cpufreq.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_SATA_AHCI)  += ahci_sata.o

CONFIG_IMX_HAVE_PLATFORM_AHCI for the same reason.

Accepted.

Quoted 27 lines

arch/arm/plat-mxc/ahci_sata.c line 2

Quoted 12 lines
arch/arm/plat-mxc/Makefile +0 -0
 ifdef CONFIG_SND_IMX_SOC
 obj-y += ssi-fiq.o
 obj-y += ssi-fiq-ksym.o
(quoted diff) +0 -0

b/arch/arm/plat-mxc/ahci_sata.c new file mode 100644 index 0000000..49cbb68

arch/arm/plat-mxc/ahci_sata.c new file +2 -0
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights

Reserved.

Quoted 14 lines
arch/arm/plat-mxc/ahci_sata.c new file +14 -0
+ *
+ * This program is free software; you can redistribute it and/or
+modify it
+ * under the terms of the GNU General Public License as published by
+the
+ * Free Software Foundation; either version 2 of the License, or (at
+your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
Quoted 9 lines

arch/arm/plat-mxc/ahci_sata.c line 16

Quoted 7 lines
arch/arm/plat-mxc/ahci_sata.c new file +7 -0
+License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

this address isn't valid anymore.

Accepted. Would be replaced later.

Quoted 15 lines
Quoted 15 lines
arch/arm/plat-mxc/ahci_sata.c new file +15 -0
+ */
+
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <mach/ahci_sata.h>
+
+/* AHCI module Initialization, if return 0, initialization is
+successful. */ int sata_init(void __iomem *addr, struct clk *clk) {
+   u32 tmpdata;
+
+   tmpdata = readl(addr + HOST_CAP);
+   if (!(tmpdata & HOST_CAP_SSS)) {
+           tmpdata |= HOST_CAP_SSS;
+           writel(tmpdata, addr + HOST_CAP);
+   }
Quoted 8 lines

arch/arm/plat-mxc/ahci_sata.c line 39

Quoted 7 lines
arch/arm/plat-mxc/ahci_sata.c new file +7 -0
+
+   if (!(readl(addr + HOST_PORTS_IMPL) & 0x1))
+           writel((readl(addr + HOST_PORTS_IMPL) | 0x1),
+                   addr + HOST_PORTS_IMPL);
+
+   tmpdata = clk_get_rate(clk) / 1000;
+   clk_put(clk);

Where is the symmetric clk_get?

I would change the codes later.

Quoted 12 lines
Quoted 12 lines
arch/arm/plat-mxc/ahci_sata.c new file +4 -0
+   writel(tmpdata, addr + HOST_TIMER1MS);
+
+   return 0;
+}
arch/arm/plat-mxc/devices/Kconfig +0 -0
index b9ab1d5..087595a 100644
@@ -71,3 +71,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 
Quoted 11 lines

arch/arm/plat-mxc/devices/Kconfig config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX · line 77

Quoted 6 lines
arch/arm/plat-mxc/devices/Kconfig +4 -0
 config IMX_HAVE_PLATFORM_SPI_IMX
    bool
+
+config IMX_HAVE_PLATFORM_SATA_AHCI
+   bool
+   default y if SOC_IMX53

Can you please keep this file sorted by config name?
Do all i.MX53 have ahci? If so, consider registration as it is done for mxc_rnga. If not, please let the machines that really use it select IMX_HAVE_PLATFORM_AHCI.

Accepted. All MX53 have ahci. Would change it later.

Quoted 5 lines
Quoted 5 lines
arch/arm/plat-mxc/devices/Makefile +0 -0
index 75cd2ec..e0b7fa3 100644
Quoted 9 lines
Quoted 7 lines
arch/arm/plat-mxc/devices/Makefile +0 -0
@@ -22,3 +22,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RNGA) +=

platform-mxc_rnga.o
obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_W1) += platform-mxc_w1.o obj-$(CONFIG_IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX) +=
platform-sdhci-esdhc-imx.o
obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_SATA_AHCI) += platform-ahci-imx.o

This file is sorted, too.

Accepted.

Quoted 39 lines

arch/arm/plat-mxc/devices/platform-ahci-imx.c line 2

Quoted 9 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +2 -0
new file mode 100644
index 0000000..d6da344
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights

Reserved.

Quoted 29 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +29 -0
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or
+modify
+ * it under the terms of the GNU General Public License as published
+by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ along
+ * with this program; if not, write to the Free Software Foundation,
+ Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+#define imx_ahci_data_entry_single(soc)                                    \
+   {                                                               \
+           .iobase = soc ## _SATA_BASE_ADDR,                       \
Quoted 9 lines

arch/arm/plat-mxc/devices/platform-ahci-imx.c line 34

Quoted 7 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +7 -0
+           .irq = soc ## _INT_SATA,                                \
+   }
+
+#ifdef CONFIG_SOC_IMX53
+const struct imx_ahci_imx_data imx53_ahci_imx_data __initconst =
+   imx_ahci_data_entry_single(MX53);
+#endif

arch/arm/mach-mx5/devices-imx53.h declares this to be an array.

Accepted. Array type would be removed, since only one AHCI is contained.

Quoted 100 lines
Quoted 9 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +9 -0
+
+struct platform_device *__init imx_add_ahci_imx(
+           const struct imx_ahci_imx_data *data,
+           const struct ahci_platform_data *pdata) {
+   struct resource res[] = {
+           {
+                   .start = data->iobase,
+                   .end = data->iobase + SZ_4K - 1,
+                   .flags = IORESOURCE_MEM,

arch/arm/plat-mxc/devices/platform-ahci-imx.c line 54

Quoted 10 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +10 -0
+           }, {
+                   .start = data->irq,
+                   .end = data->irq,
+                   .flags = IORESOURCE_IRQ,
+           },
+   };
+
+   return imx_add_platform_device_dmamask("ahci", 0,
+                   res, ARRAY_SIZE(res),
+                   pdata, sizeof(*pdata),  DMA_BIT_MASK(32));

s/ / /

arch/arm/plat-mxc/include/mach/ahci_sata.h line 2

Quoted 10 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +1 -0
+}
arch/arm/plat-mxc/include/mach/ahci_sata.h new file +2 -0
new file mode 100644
index 0000000..6adf67a
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights

Reserved.

Quoted 68 lines
arch/arm/plat-mxc/include/mach/ahci_sata.h new file +56 -0
+ *
+ * This program is free software; you can redistribute it and/or
+modify it
+ * under the terms of the GNU General Public License as published by
+the
+ * Free Software Foundation; either version 2 of the License, or (at
+your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __PLAT_MXC_AHCI_SATA_H__
+#define __PLAT_MXC_AHCI_SATA_H__
+
+enum {
+   HOST_CAP = 0x00,
+   HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */
+   HOST_PORTS_IMPL = 0x0c,
+   HOST_TIMER1MS = 0xe0, /* Timer 1-ms */
+   /* Offest used to control the MPLL input clk */
+   PHY_CR_CLOCK_FREQ_OVRD = 0x12,
+   /* Port0 SATA Status */
+   PORT_SATA_SR = 0x128,
+   /* Port0 PHY Control */
+   PORT_PHY_CTL = 0x178,
+   /* PORT_PHY_CTL bits */
+   PORT_PHY_CTL_CAP_ADR_LOC = 0x10000,
+   PORT_PHY_CTL_CAP_DAT_LOC = 0x20000,
+   PORT_PHY_CTL_WRITE_LOC = 0x40000,
+   PORT_PHY_CTL_READ_LOC = 0x80000,
+   /* Port0 PHY Status */
+   PORT_PHY_SR = 0x17c,
+   /* PORT_PHY_SR */
+   PORT_PHY_STAT_DATA_LOC = 0,
+   PORT_PHY_STAT_ACK_LOC = 18,
+   /* SATA PHY Register */
+   SATA_PHY_CR_CLOCK_CRCMP_LT_LIMIT = 0x0001,
+   SATA_PHY_CR_CLOCK_DAC_CTL = 0x0008,
+   SATA_PHY_CR_CLOCK_RTUNE_CTL = 0x0009,
+   SATA_PHY_CR_CLOCK_ADC_OUT = 0x000A,
+   SATA_PHY_CR_CLOCK_MPLL_TST = 0x0017, };
+
+extern int sata_init(void __iomem *addr, struct clk *clk); #endif /*
+__PLAT_MXC_AHCI_SATA_H__ */
arch/arm/plat-mxc/include/mach/devices-common.h +3 -0
index 8658c9c..81baca6 100644
@@ -264,3 +264,13 @@ struct imx_spi_imx_data {  struct platform_device
 *__init imx_add_spi_imx(
            const struct imx_spi_imx_data *data,
            const struct spi_imx_master *pdata);
+
+#include <linux/ahci_platform.h>
+struct imx_ahci_imx_data {
Quoted 9 lines

arch/arm/plat-mxc/include/mach/devices-common.h struct imx_spi_imx_data { · line 276

Quoted 7 lines
arch/arm/plat-mxc/include/mach/devices-common.h +7 -0
+   int id;
+   resource_size_t iobase;
+   resource_size_t irq;
+};
+struct platform_device *__init imx_add_ahci_imx(
+           const struct imx_ahci_imx_data *data,
+           const struct ahci_platform_data *pdata);

this file is sorted, too.

Accepted.

Quoted 8 lines

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig
|
Industrial Linux Solutions | http://www.pengutronix.de/
|