All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-08-30  9:56 ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-30  9:56 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: jgarzik, kernel, linux-ide, avorontsov, eric, eric.miao, Richard Zhu

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
---
 arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
 arch/arm/mach-mx5/devices-imx53.h               |    4 +
 arch/arm/plat-mxc/Makefile                      |    1 +
 arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
 arch/arm/plat-mxc/devices/Kconfig               |    4 +
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
 arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
 9 files changed, 242 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

diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
index 7f20308..e1fadaf 100644
--- a/arch/arm/mach-mx5/clock-mx51-mx53.c
+++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
@@ -1397,6 +1397,22 @@ 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,
+};
+
+static struct clk ahci_phy_clk = {
+	.parent = &usb_phy1_clk,
+};
+
+static struct clk ahci_dma_clk = {
+	.parent = &ahb_clk,
+};
+
 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);
@@ -1503,6 +1519,9 @@ static struct clk_lookup mx53_lookups[] = {
 	_REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
 	_REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
 	_REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk)
 };
 
 static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/devices-imx53.h b/arch/arm/mach-mx5/devices-imx53.h
index c27fe8b..bcb3af1 100644
--- a/arch/arm/mach-mx5/devices-imx53.h
+++ b/arch/arm/mach-mx5/devices-imx53.h
@@ -40,3 +40,7 @@ extern const struct imx_imx_ssi_data imx53_imx_ssi_data[];
 extern const struct imx_imx_keypad_data imx53_imx_keypad_data;
 #define imx53_add_imx_keypad(pdata)	\
 	imx_add_imx_keypad(&imx53_imx_keypad_data, pdata)
+
+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, pdata)
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index d53c35f..cc8e65a 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -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_AHCI)	+= ahci_sata.o
 ifdef CONFIG_SND_IMX_SOC
 obj-y += ssi-fiq.o
 obj-y += ssi-fiq-ksym.o
diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
new file mode 100644
index 0000000..4f54816
--- /dev/null
+++ b/arch/arm/plat-mxc/ahci_sata.c
@@ -0,0 +1,104 @@
+/*
+ * 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 <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/device.h>
+#include <mach/ahci_sata.h>
+
+static struct clk *sata_clk, *sata_ref_clk;
+
+/* AHCI module Initialization, if return 0, initialization is successful. */
+int sata_init(struct device *dev, void __iomem *addr)
+{
+	u32 tmpdata;
+	int ret = 0;
+	struct clk *clk;
+
+	sata_clk = clk_get(dev, "ahci");
+	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");
+		goto put_sata_clk;
+	}
+
+	/* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
+	sata_ref_clk = clk_get(dev, "ahci_phy");
+	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");
+		goto put_sata_ref_clk;
+	}
+
+	/* Get the AHB clock rate, and configure the TIMER1MS reg later */
+	clk = clk_get(dev, "ahci_dma");
+	if (IS_ERR(clk)) {
+		dev_err(dev, "no dma clock.\n");
+		ret = PTR_ERR(clk);
+		goto release_sata_ref_clk;
+	}
+	tmpdata = clk_get_rate(clk) / 1000;
+	clk_put(clk);
+
+	writel(tmpdata, addr + HOST_TIMER1MS);
+
+	tmpdata = readl(addr + HOST_CAP);
+	if (!(tmpdata & HOST_CAP_SSS)) {
+		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);
+
+	return 0;
+
+release_sata_ref_clk:
+	clk_disable(sata_ref_clk);
+put_sata_ref_clk:
+	clk_put(sata_ref_clk);
+release_sata_clk:
+	clk_disable(sata_clk);
+put_sata_clk:
+	clk_put(sata_clk);
+
+	return ret;
+}
+
+void sata_exit(struct device *dev)
+{
+	clk_disable(sata_ref_clk);
+	clk_put(sata_ref_clk);
+
+	clk_disable(sata_clk);
+	clk_put(sata_clk);
+
+}
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index bd294ad..f63887b 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 
 config IMX_HAVE_PLATFORM_SPI_IMX
 	bool
+
+config IMX_HAVE_PLATFORM_AHCI
+	bool
+	default y if ARCH_MX53
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index b41bf97..e858ad9 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.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_AHCI) +=  platform-ahci-imx.o
diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
new file mode 100644
index 0000000..9e1b460
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
@@ -0,0 +1,66 @@
+/*
+ * 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 <linux/dma-mapping.h>
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+#include <mach/ahci_sata.h>
+
+#define imx_ahci_imx_data_entry_single(soc, _devid)		\
+	{								\
+		.devid = _devid,					\
+		.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_imx_data_entry_single(MX53, "imx53-ahci");
+#endif
+
+static struct ahci_platform_data default_sata_pdata = {
+	.init = sata_init,
+	.exit = sata_exit,
+};
+
+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,
+		}, {
+			.start = data->irq,
+			.end = data->irq,
+			.flags = IORESOURCE_IRQ,
+		},
+	};
+
+	if (pdata == NULL)
+		pdata = &default_sata_pdata;
+
+	return imx_add_platform_device_dmamask(data->devid, 0,
+			res, ARRAY_SIZE(res),
+			pdata, sizeof(*pdata),  DMA_BIT_MASK(32));
+}
diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
new file mode 100644
index 0000000..ba297e1
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#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 */
+};
+
+extern int sata_init(struct device *dev, void __iomem *addr);
+extern void sata_exit(struct device *dev);
+#endif /* __PLAT_MXC_AHCI_SATA_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 524538a..f04e063 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
 struct platform_device *imx_add_imx_dma(void);
 struct platform_device *imx_add_imx_sdma(char *name,
 	resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
+
+#include <linux/ahci_platform.h>
+struct imx_ahci_imx_data {
+	const char *devid;
+	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);
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-08-30  9:56 ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-30  9:56 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
---
 arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
 arch/arm/mach-mx5/devices-imx53.h               |    4 +
 arch/arm/plat-mxc/Makefile                      |    1 +
 arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
 arch/arm/plat-mxc/devices/Kconfig               |    4 +
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
 arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
 9 files changed, 242 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

diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
index 7f20308..e1fadaf 100644
--- a/arch/arm/mach-mx5/clock-mx51-mx53.c
+++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
@@ -1397,6 +1397,22 @@ 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,
+};
+
+static struct clk ahci_phy_clk = {
+	.parent = &usb_phy1_clk,
+};
+
+static struct clk ahci_dma_clk = {
+	.parent = &ahb_clk,
+};
+
 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);
@@ -1503,6 +1519,9 @@ static struct clk_lookup mx53_lookups[] = {
 	_REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
 	_REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
 	_REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk)
 };
 
 static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/devices-imx53.h b/arch/arm/mach-mx5/devices-imx53.h
index c27fe8b..bcb3af1 100644
--- a/arch/arm/mach-mx5/devices-imx53.h
+++ b/arch/arm/mach-mx5/devices-imx53.h
@@ -40,3 +40,7 @@ extern const struct imx_imx_ssi_data imx53_imx_ssi_data[];
 extern const struct imx_imx_keypad_data imx53_imx_keypad_data;
 #define imx53_add_imx_keypad(pdata)	\
 	imx_add_imx_keypad(&imx53_imx_keypad_data, pdata)
+
+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, pdata)
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index d53c35f..cc8e65a 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -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_AHCI)	+= ahci_sata.o
 ifdef CONFIG_SND_IMX_SOC
 obj-y += ssi-fiq.o
 obj-y += ssi-fiq-ksym.o
diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
new file mode 100644
index 0000000..4f54816
--- /dev/null
+++ b/arch/arm/plat-mxc/ahci_sata.c
@@ -0,0 +1,104 @@
+/*
+ * 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 <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/device.h>
+#include <mach/ahci_sata.h>
+
+static struct clk *sata_clk, *sata_ref_clk;
+
+/* AHCI module Initialization, if return 0, initialization is successful. */
+int sata_init(struct device *dev, void __iomem *addr)
+{
+	u32 tmpdata;
+	int ret = 0;
+	struct clk *clk;
+
+	sata_clk = clk_get(dev, "ahci");
+	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");
+		goto put_sata_clk;
+	}
+
+	/* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
+	sata_ref_clk = clk_get(dev, "ahci_phy");
+	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");
+		goto put_sata_ref_clk;
+	}
+
+	/* Get the AHB clock rate, and configure the TIMER1MS reg later */
+	clk = clk_get(dev, "ahci_dma");
+	if (IS_ERR(clk)) {
+		dev_err(dev, "no dma clock.\n");
+		ret = PTR_ERR(clk);
+		goto release_sata_ref_clk;
+	}
+	tmpdata = clk_get_rate(clk) / 1000;
+	clk_put(clk);
+
+	writel(tmpdata, addr + HOST_TIMER1MS);
+
+	tmpdata = readl(addr + HOST_CAP);
+	if (!(tmpdata & HOST_CAP_SSS)) {
+		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);
+
+	return 0;
+
+release_sata_ref_clk:
+	clk_disable(sata_ref_clk);
+put_sata_ref_clk:
+	clk_put(sata_ref_clk);
+release_sata_clk:
+	clk_disable(sata_clk);
+put_sata_clk:
+	clk_put(sata_clk);
+
+	return ret;
+}
+
+void sata_exit(struct device *dev)
+{
+	clk_disable(sata_ref_clk);
+	clk_put(sata_ref_clk);
+
+	clk_disable(sata_clk);
+	clk_put(sata_clk);
+
+}
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index bd294ad..f63887b 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 
 config IMX_HAVE_PLATFORM_SPI_IMX
 	bool
+
+config IMX_HAVE_PLATFORM_AHCI
+	bool
+	default y if ARCH_MX53
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index b41bf97..e858ad9 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.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_AHCI) +=  platform-ahci-imx.o
diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
new file mode 100644
index 0000000..9e1b460
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
@@ -0,0 +1,66 @@
+/*
+ * 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 <linux/dma-mapping.h>
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+#include <mach/ahci_sata.h>
+
+#define imx_ahci_imx_data_entry_single(soc, _devid)		\
+	{								\
+		.devid = _devid,					\
+		.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_imx_data_entry_single(MX53, "imx53-ahci");
+#endif
+
+static struct ahci_platform_data default_sata_pdata = {
+	.init = sata_init,
+	.exit = sata_exit,
+};
+
+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,
+		}, {
+			.start = data->irq,
+			.end = data->irq,
+			.flags = IORESOURCE_IRQ,
+		},
+	};
+
+	if (pdata == NULL)
+		pdata = &default_sata_pdata;
+
+	return imx_add_platform_device_dmamask(data->devid, 0,
+			res, ARRAY_SIZE(res),
+			pdata, sizeof(*pdata),  DMA_BIT_MASK(32));
+}
diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
new file mode 100644
index 0000000..ba297e1
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#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 */
+};
+
+extern int sata_init(struct device *dev, void __iomem *addr);
+extern void sata_exit(struct device *dev);
+#endif /* __PLAT_MXC_AHCI_SATA_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 524538a..f04e063 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
 struct platform_device *imx_add_imx_dma(void);
 struct platform_device *imx_add_imx_sdma(char *name,
 	resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
+
+#include <linux/ahci_platform.h>
+struct imx_ahci_imx_data {
+	const char *devid;
+	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);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH V7 2/5] ahci_plt Add the board_ids and pi refer to different features
  2011-08-30  9:56 ` Richard Zhu
@ 2011-08-30  9:56   ` Richard Zhu
  -1 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-30  9:56 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: jgarzik, kernel, linux-ide, avorontsov, eric, eric.miao, Richard Zhu

On imx53 AHCI, soft reset fails with IPMS set when PMP
is enabled but SATA HDD/ODD is connected to SATA port,
do soft reset again to port 0.
So the 'ahci_pmp_retry_srst_ops' is required when imx53
ahci is present.

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
---
 drivers/ata/ahci_platform.c |   44 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 6fef1fa..c03277d 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -23,6 +23,41 @@
 #include <linux/ahci_platform.h>
 #include "ahci.h"
 
+enum ahci_type {
+	AHCI,		/* standard platform ahci */
+	IMX53_AHCI,	/* ahci on i.mx53 */
+};
+
+static struct platform_device_id ahci_devtype[] = {
+	{
+		.name = "ahci",
+		.driver_data = AHCI,
+	}, {
+		.name = "imx53-ahci",
+		.driver_data = IMX53_AHCI,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(platform, ahci_devtype);
+
+
+static const struct ata_port_info ahci_port_info[] = {
+	/* by features */
+	[AHCI] = {
+		.flags		= AHCI_FLAG_COMMON,
+		.pio_mask	= ATA_PIO4,
+		.udma_mask	= ATA_UDMA6,
+		.port_ops	= &ahci_ops,
+	},
+	[IMX53_AHCI] = {
+		.flags		= AHCI_FLAG_COMMON,
+		.pio_mask	= ATA_PIO4,
+		.udma_mask	= ATA_UDMA6,
+		.port_ops	= &ahci_pmp_retry_srst_ops,
+	},
+};
+
 static struct scsi_host_template ahci_platform_sht = {
 	AHCI_SHT("ahci_platform"),
 };
@@ -31,12 +66,8 @@ static int __init ahci_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct ahci_platform_data *pdata = dev->platform_data;
-	struct ata_port_info pi = {
-		.flags		= AHCI_FLAG_COMMON,
-		.pio_mask	= ATA_PIO4,
-		.udma_mask	= ATA_UDMA6,
-		.port_ops	= &ahci_ops,
-	};
+	const struct platform_device_id *id = platform_get_device_id(pdev);
+	struct ata_port_info pi = ahci_port_info[id->driver_data];
 	const struct ata_port_info *ppi[] = { &pi, NULL };
 	struct ahci_host_priv *hpriv;
 	struct ata_host *host;
@@ -177,6 +208,7 @@ static struct platform_driver ahci_driver = {
 		.name = "ahci",
 		.owner = THIS_MODULE,
 	},
+	.id_table	= ahci_devtype,
 };
 
 static int __init ahci_init(void)
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH V7 2/5] ahci_plt Add the board_ids and pi refer to different features
@ 2011-08-30  9:56   ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-30  9:56 UTC (permalink / raw)
  To: linux-arm-kernel

On imx53 AHCI, soft reset fails with IPMS set when PMP
is enabled but SATA HDD/ODD is connected to SATA port,
do soft reset again to port 0.
So the 'ahci_pmp_retry_srst_ops' is required when imx53
ahci is present.

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
---
 drivers/ata/ahci_platform.c |   44 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 6fef1fa..c03277d 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -23,6 +23,41 @@
 #include <linux/ahci_platform.h>
 #include "ahci.h"
 
+enum ahci_type {
+	AHCI,		/* standard platform ahci */
+	IMX53_AHCI,	/* ahci on i.mx53 */
+};
+
+static struct platform_device_id ahci_devtype[] = {
+	{
+		.name = "ahci",
+		.driver_data = AHCI,
+	}, {
+		.name = "imx53-ahci",
+		.driver_data = IMX53_AHCI,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(platform, ahci_devtype);
+
+
+static const struct ata_port_info ahci_port_info[] = {
+	/* by features */
+	[AHCI] = {
+		.flags		= AHCI_FLAG_COMMON,
+		.pio_mask	= ATA_PIO4,
+		.udma_mask	= ATA_UDMA6,
+		.port_ops	= &ahci_ops,
+	},
+	[IMX53_AHCI] = {
+		.flags		= AHCI_FLAG_COMMON,
+		.pio_mask	= ATA_PIO4,
+		.udma_mask	= ATA_UDMA6,
+		.port_ops	= &ahci_pmp_retry_srst_ops,
+	},
+};
+
 static struct scsi_host_template ahci_platform_sht = {
 	AHCI_SHT("ahci_platform"),
 };
@@ -31,12 +66,8 @@ static int __init ahci_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct ahci_platform_data *pdata = dev->platform_data;
-	struct ata_port_info pi = {
-		.flags		= AHCI_FLAG_COMMON,
-		.pio_mask	= ATA_PIO4,
-		.udma_mask	= ATA_UDMA6,
-		.port_ops	= &ahci_ops,
-	};
+	const struct platform_device_id *id = platform_get_device_id(pdev);
+	struct ata_port_info pi = ahci_port_info[id->driver_data];
 	const struct ata_port_info *ppi[] = { &pi, NULL };
 	struct ahci_host_priv *hpriv;
 	struct ata_host *host;
@@ -177,6 +208,7 @@ static struct platform_driver ahci_driver = {
 		.name = "ahci",
 		.owner = THIS_MODULE,
 	},
+	.id_table	= ahci_devtype,
 };
 
 static int __init ahci_init(void)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH V7 3/5] MX53 Enable the AHCI SATA on MX53 ARD board
  2011-08-30  9:56 ` Richard Zhu
@ 2011-08-30  9:56   ` Richard Zhu
  -1 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-30  9:56 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: jgarzik, kernel, linux-ide, avorontsov, eric, eric.miao, Richard Zhu

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
---
 arch/arm/mach-mx5/board-mx53_ard.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mx5/board-mx53_ard.c b/arch/arm/mach-mx5/board-mx53_ard.c
index 76a67c4..f7cbbc0 100644
--- a/arch/arm/mach-mx5/board-mx53_ard.c
+++ b/arch/arm/mach-mx5/board-mx53_ard.c
@@ -234,6 +234,7 @@ static void __init mx53_ard_board_init(void)
 	imx53_add_imx_i2c(1, &mx53_ard_i2c2_data);
 	imx53_add_imx_i2c(2, &mx53_ard_i2c3_data);
 	imx_add_gpio_keys(&ard_button_data);
+	imx53_add_ahci_imx(0, NULL);
 }
 
 static void __init mx53_ard_timer_init(void)
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH V7 3/5] MX53 Enable the AHCI SATA on MX53 ARD board
@ 2011-08-30  9:56   ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-30  9:56 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
---
 arch/arm/mach-mx5/board-mx53_ard.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mx5/board-mx53_ard.c b/arch/arm/mach-mx5/board-mx53_ard.c
index 76a67c4..f7cbbc0 100644
--- a/arch/arm/mach-mx5/board-mx53_ard.c
+++ b/arch/arm/mach-mx5/board-mx53_ard.c
@@ -234,6 +234,7 @@ static void __init mx53_ard_board_init(void)
 	imx53_add_imx_i2c(1, &mx53_ard_i2c2_data);
 	imx53_add_imx_i2c(2, &mx53_ard_i2c3_data);
 	imx_add_gpio_keys(&ard_button_data);
+	imx53_add_ahci_imx(0, NULL);
 }
 
 static void __init mx53_ard_timer_init(void)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH V7 4/5] MX53 Enable the AHCI SATA on MX53 LOCO board
  2011-08-30  9:56 ` Richard Zhu
@ 2011-08-30  9:56   ` Richard Zhu
  -1 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-30  9:56 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: jgarzik, kernel, linux-ide, avorontsov, eric, eric.miao, Richard Zhu

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
---
 arch/arm/mach-mx5/board-mx53_loco.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c
index 4e1d51d..76a7af7 100644
--- a/arch/arm/mach-mx5/board-mx53_loco.c
+++ b/arch/arm/mach-mx5/board-mx53_loco.c
@@ -273,6 +273,7 @@ static void __init mx53_loco_board_init(void)
 	imx53_add_sdhci_esdhc_imx(2, &mx53_loco_sd3_data);
 	imx_add_gpio_keys(&loco_button_data);
 	gpio_led_register_device(-1, &mx53loco_leds_data);
+	imx53_add_ahci_imx(0, NULL);
 }
 
 static void __init mx53_loco_timer_init(void)
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH V7 4/5] MX53 Enable the AHCI SATA on MX53 LOCO board
@ 2011-08-30  9:56   ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-30  9:56 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
---
 arch/arm/mach-mx5/board-mx53_loco.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c
index 4e1d51d..76a7af7 100644
--- a/arch/arm/mach-mx5/board-mx53_loco.c
+++ b/arch/arm/mach-mx5/board-mx53_loco.c
@@ -273,6 +273,7 @@ static void __init mx53_loco_board_init(void)
 	imx53_add_sdhci_esdhc_imx(2, &mx53_loco_sd3_data);
 	imx_add_gpio_keys(&loco_button_data);
 	gpio_led_register_device(-1, &mx53loco_leds_data);
+	imx53_add_ahci_imx(0, NULL);
 }
 
 static void __init mx53_loco_timer_init(void)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH V7 5/5] MX53 Enable the AHCI SATA on MX53 SMD board
  2011-08-30  9:56 ` Richard Zhu
@ 2011-08-30  9:56   ` Richard Zhu
  -1 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-30  9:56 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: jgarzik, kernel, linux-ide, avorontsov, eric, eric.miao, Richard Zhu

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
---
 arch/arm/mach-mx5/board-mx53_smd.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mx5/board-mx53_smd.c b/arch/arm/mach-mx5/board-mx53_smd.c
index bc02894..3005c7c 100644
--- a/arch/arm/mach-mx5/board-mx53_smd.c
+++ b/arch/arm/mach-mx5/board-mx53_smd.c
@@ -26,6 +26,7 @@
 #include <mach/common.h>
 #include <mach/hardware.h>
 #include <mach/iomux-mx53.h>
+#include <mach/ahci_sata.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -35,6 +36,7 @@
 #include "devices-imx53.h"
 
 #define SMD_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
+#define MX53_SMD_SATA_PWR_EN    IMX_GPIO_NR(3, 3)
 
 static iomux_v3_cfg_t mx53_smd_pads[] = {
 	MX53_PAD_CSI0_DAT10__UART1_TXD_MUX,
@@ -111,6 +113,35 @@ static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+static int mx53_smd_sata_init(struct device *dev, void __iomem *addr)
+{
+	int ret;
+
+	/* Enable SATA PWR */
+	ret = gpio_request(MX53_SMD_SATA_PWR_EN, "ahci-sata-pwr");
+	if (ret) {
+		printk(KERN_ERR "failed to get SATA_PWR_EN: %d\n", ret);
+		return ret;
+	}
+	gpio_direction_output(MX53_SMD_SATA_PWR_EN, 1);
+
+	return sata_init(dev, addr);
+}
+
+void mx53_smd_sata_exit(struct device *dev)
+{
+	sata_exit(dev);
+
+	/* Disable SATA PWR */
+	gpio_direction_output(MX53_SMD_SATA_PWR_EN, 0);
+	gpio_free(MX53_SMD_SATA_PWR_EN);
+}
+
+static struct ahci_platform_data sata_data = {
+	.init = mx53_smd_sata_init,
+	.exit = mx53_smd_sata_exit,
+};
+
 static void __init mx53_smd_board_init(void)
 {
 	imx53_soc_init();
@@ -125,6 +156,7 @@ static void __init mx53_smd_board_init(void)
 	imx53_add_sdhci_esdhc_imx(0, NULL);
 	imx53_add_sdhci_esdhc_imx(1, NULL);
 	imx53_add_sdhci_esdhc_imx(2, NULL);
+	imx53_add_ahci_imx(0, &sata_data);
 }
 
 static void __init mx53_smd_timer_init(void)
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH V7 5/5] MX53 Enable the AHCI SATA on MX53 SMD board
@ 2011-08-30  9:56   ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-30  9:56 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
---
 arch/arm/mach-mx5/board-mx53_smd.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mx5/board-mx53_smd.c b/arch/arm/mach-mx5/board-mx53_smd.c
index bc02894..3005c7c 100644
--- a/arch/arm/mach-mx5/board-mx53_smd.c
+++ b/arch/arm/mach-mx5/board-mx53_smd.c
@@ -26,6 +26,7 @@
 #include <mach/common.h>
 #include <mach/hardware.h>
 #include <mach/iomux-mx53.h>
+#include <mach/ahci_sata.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -35,6 +36,7 @@
 #include "devices-imx53.h"
 
 #define SMD_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
+#define MX53_SMD_SATA_PWR_EN    IMX_GPIO_NR(3, 3)
 
 static iomux_v3_cfg_t mx53_smd_pads[] = {
 	MX53_PAD_CSI0_DAT10__UART1_TXD_MUX,
@@ -111,6 +113,35 @@ static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+static int mx53_smd_sata_init(struct device *dev, void __iomem *addr)
+{
+	int ret;
+
+	/* Enable SATA PWR */
+	ret = gpio_request(MX53_SMD_SATA_PWR_EN, "ahci-sata-pwr");
+	if (ret) {
+		printk(KERN_ERR "failed to get SATA_PWR_EN: %d\n", ret);
+		return ret;
+	}
+	gpio_direction_output(MX53_SMD_SATA_PWR_EN, 1);
+
+	return sata_init(dev, addr);
+}
+
+void mx53_smd_sata_exit(struct device *dev)
+{
+	sata_exit(dev);
+
+	/* Disable SATA PWR */
+	gpio_direction_output(MX53_SMD_SATA_PWR_EN, 0);
+	gpio_free(MX53_SMD_SATA_PWR_EN);
+}
+
+static struct ahci_platform_data sata_data = {
+	.init = mx53_smd_sata_init,
+	.exit = mx53_smd_sata_exit,
+};
+
 static void __init mx53_smd_board_init(void)
 {
 	imx53_soc_init();
@@ -125,6 +156,7 @@ static void __init mx53_smd_board_init(void)
 	imx53_add_sdhci_esdhc_imx(0, NULL);
 	imx53_add_sdhci_esdhc_imx(1, NULL);
 	imx53_add_sdhci_esdhc_imx(2, NULL);
+	imx53_add_ahci_imx(0, &sata_data);
 }
 
 static void __init mx53_smd_timer_init(void)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-08-30  9:56 ` Richard Zhu
@ 2011-08-30 10:37   ` Wolfram Sang
  -1 siblings, 0 replies; 54+ messages in thread
From: Wolfram Sang @ 2011-08-30 10:37 UTC (permalink / raw)
  To: Richard Zhu
  Cc: linux-arm-kernel, jgarzik, kernel, linux-ide, avorontsov, eric,
	eric.miao

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

Hi Richard,

again, please use --cover-letter when sending a new series and say
what has changed since last time. Otherwise you force reviewers to find
out for themselves (which easily makes them ignore the series)

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-08-30 10:37   ` Wolfram Sang
  0 siblings, 0 replies; 54+ messages in thread
From: Wolfram Sang @ 2011-08-30 10:37 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Richard,

again, please use --cover-letter when sending a new series and say
what has changed since last time. Otherwise you force reviewers to find
out for themselves (which easily makes them ignore the series)

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110830/2c701449/attachment.sig>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-08-30  9:56 ` Richard Zhu
@ 2011-08-30 10:43   ` Hector Oron
  -1 siblings, 0 replies; 54+ messages in thread
From: Hector Oron @ 2011-08-30 10:43 UTC (permalink / raw)
  To: Richard Zhu
  Cc: linux-arm-kernel, kernel, eric.miao, linux-ide, eric, avorontsov,
	jgarzik

Hello,

2011/8/30 Richard Zhu <richard.zhu@linaro.org>:
> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
> ---
>  arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
>  arch/arm/mach-mx5/devices-imx53.h               |    4 +
>  arch/arm/plat-mxc/Makefile                      |    1 +
>  arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
>  arch/arm/plat-mxc/devices/Kconfig               |    4 +
>  arch/arm/plat-mxc/devices/Makefile              |    1 +
>  arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
>  arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
>  arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
>  9 files changed, 242 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

The good news are that I have tested this patch series on i.MX53 LOCO
board and it seems to work fine here. Thanks.


Tested-By: Hector Oron Martinez <hector.oron@gmail.com>

-- 
 Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-08-30 10:43   ` Hector Oron
  0 siblings, 0 replies; 54+ messages in thread
From: Hector Oron @ 2011-08-30 10:43 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

2011/8/30 Richard Zhu <richard.zhu@linaro.org>:
> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
> ---
> ?arch/arm/mach-mx5/clock-mx51-mx53.c ? ? ? ? ? ? | ? 19 ++++
> ?arch/arm/mach-mx5/devices-imx53.h ? ? ? ? ? ? ? | ? ?4 +
> ?arch/arm/plat-mxc/Makefile ? ? ? ? ? ? ? ? ? ? ?| ? ?1 +
> ?arch/arm/plat-mxc/ahci_sata.c ? ? ? ? ? ? ? ? ? | ?104 +++++++++++++++++++++++
> ?arch/arm/plat-mxc/devices/Kconfig ? ? ? ? ? ? ? | ? ?4 +
> ?arch/arm/plat-mxc/devices/Makefile ? ? ? ? ? ? ?| ? ?1 +
> ?arch/arm/plat-mxc/devices/platform-ahci-imx.c ? | ? 66 ++++++++++++++
> ?arch/arm/plat-mxc/include/mach/ahci_sata.h ? ? ?| ? 33 +++++++
> ?arch/arm/plat-mxc/include/mach/devices-common.h | ? 10 ++
> ?9 files changed, 242 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

The good news are that I have tested this patch series on i.MX53 LOCO
board and it seems to work fine here. Thanks.


Tested-By: Hector Oron Martinez <hector.oron@gmail.com>

-- 
?H?ctor Or?n ?-.. . -... .. .- -. ? -.. . ...- . .-.. --- .--. . .-.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-08-30 10:43   ` Hector Oron
@ 2011-08-31  2:08     ` Richard Zhu
  -1 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-31  2:08 UTC (permalink / raw)
  To: Hector Oron, Wolfram Sang
  Cc: eric, eric.miao, linux-ide, kernel, avorontsov, jgarzik,
	linux-arm-kernel

Hi Wolfram:
Thanks for your suggestions.
Accepted.

Hi Hector:
Thanks for your help to tests these patches.

Best Regards
Richard Zhu

On 30 August 2011 18:43, Hector Oron <hector.oron@gmail.com> wrote:
> Hello,
>
> 2011/8/30 Richard Zhu <richard.zhu@linaro.org>:
>> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
>> ---
>>  arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
>>  arch/arm/mach-mx5/devices-imx53.h               |    4 +
>>  arch/arm/plat-mxc/Makefile                      |    1 +
>>  arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
>>  arch/arm/plat-mxc/devices/Kconfig               |    4 +
>>  arch/arm/plat-mxc/devices/Makefile              |    1 +
>>  arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
>>  arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
>>  arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
>>  9 files changed, 242 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
>
> The good news are that I have tested this patch series on i.MX53 LOCO
> board and it seems to work fine here. Thanks.
>
>
> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
>
> --
>  Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-08-31  2:08     ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-31  2:08 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Wolfram:
Thanks for your suggestions.
Accepted.

Hi Hector:
Thanks for your help to tests these patches.

Best Regards
Richard Zhu

On 30 August 2011 18:43, Hector Oron <hector.oron@gmail.com> wrote:
> Hello,
>
> 2011/8/30 Richard Zhu <richard.zhu@linaro.org>:
>> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
>> ---
>> ?arch/arm/mach-mx5/clock-mx51-mx53.c ? ? ? ? ? ? | ? 19 ++++
>> ?arch/arm/mach-mx5/devices-imx53.h ? ? ? ? ? ? ? | ? ?4 +
>> ?arch/arm/plat-mxc/Makefile ? ? ? ? ? ? ? ? ? ? ?| ? ?1 +
>> ?arch/arm/plat-mxc/ahci_sata.c ? ? ? ? ? ? ? ? ? | ?104 +++++++++++++++++++++++
>> ?arch/arm/plat-mxc/devices/Kconfig ? ? ? ? ? ? ? | ? ?4 +
>> ?arch/arm/plat-mxc/devices/Makefile ? ? ? ? ? ? ?| ? ?1 +
>> ?arch/arm/plat-mxc/devices/platform-ahci-imx.c ? | ? 66 ++++++++++++++
>> ?arch/arm/plat-mxc/include/mach/ahci_sata.h ? ? ?| ? 33 +++++++
>> ?arch/arm/plat-mxc/include/mach/devices-common.h | ? 10 ++
>> ?9 files changed, 242 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
>
> The good news are that I have tested this patch series on i.MX53 LOCO
> board and it seems to work fine here. Thanks.
>
>
> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
>
> --
> ?H?ctor Or?n ?-.. . -... .. .- -. ? -.. . ...- . .-.. --- .--. . .-.
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-08-31  2:08     ` Richard Zhu
@ 2011-08-31 12:57       ` Hector Oron
  -1 siblings, 0 replies; 54+ messages in thread
From: Hector Oron @ 2011-08-31 12:57 UTC (permalink / raw)
  To: Richard Zhu
  Cc: Wolfram Sang, linux-arm-kernel, kernel, eric.miao, linux-ide,
	eric, avorontsov, jgarzik

Hello,

2011/8/31 Richard Zhu <richard.zhu@linaro.org>:
> Hi Hector:
> Thanks for your help to tests these patches.

Note I rebased this patches against 'imx-features' branch on Sascha's tree.
I am noticing some obscure (to me) messages from kernel:

[    6.874694] Adding 9767516k swap on /dev/sda3.  Priority:-1
extents:1 across:9767516k
[    7.073106] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro
[    7.708399] ata1.00: exception Emask 0x12 SAct 0x3 SErr 0x1280500
action 0x6 frozen
[    7.716219] ata1.00: irq_stat 0x08000000, interface fatal error
[    7.722216] ata1: SError: { UnrecovData Proto 10B8B BadCRC TrStaTrns }
[    7.728780] ata1.00: failed command: READ FPDMA QUEUED
[    7.733995] ata1.00: cmd 60/00:00:f2:11:32/01:00:00:00:00/40 tag 0
ncq 131072 in
[    7.734002]          res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[    7.749468] ata1.00: status: { DRDY }
[    7.753176] ata1.00: failed command: READ FPDMA QUEUED
[    7.758356] ata1.00: cmd 60/18:08:c2:14:32/00:00:00:00:00/40 tag 1
ncq 12288 in
[    7.758363]          res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[    7.773739] ata1.00: status: { DRDY }
[    7.777448] ata1: hard resetting link
[    8.750427] ata1: softreset failed (device not ready)
[    8.755551] ata1: applying PMP SRST workaround and retrying
[    8.960435] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[    8.981938] ata1.00: configured for UDMA/133
[    8.986535] ata1: EH complete
[   12.147912] eth0: Freescale FEC PHY driver [Generic PHY]
(mii_bus:phy_addr=1:00, irq=-1)
[   12.521870] ata1.00: exception Emask 0x12 SAct 0xf SErr 0x800500
action 0x6 frozen
[   12.529518] ata1.00: irq_stat 0x08000000, interface fatal error
[   12.535546] ata1: SError: { UnrecovData Proto LinkSeq }
[   12.540851] ata1.00: failed command: READ FPDMA QUEUED
[   12.546039] ata1.00: cmd 60/00:00:a2:19:2c/01:00:00:00:00/40 tag 0
ncq 131072 in
[   12.546046]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[   12.561519] ata1.00: status: { DRDY }
[   12.565209] ata1.00: failed command: READ FPDMA QUEUED
[   12.570419] ata1.00: cmd 60/00:08:1a:e9:2c/01:00:00:00:00/40 tag 1
ncq 131072 in
[   12.570426]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[   12.585890] ata1.00: status: { DRDY }
[   12.589578] ata1.00: failed command: READ FPDMA QUEUED
[   12.594776] ata1.00: cmd 60/00:10:7a:aa:2c/01:00:00:00:00/40 tag 2
ncq 131072 in
[   12.594783]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[   12.610240] ata1.00: status: { DRDY }
[   12.613945] ata1.00: failed command: READ FPDMA QUEUED
[   12.619118] ata1.00: cmd 60/e0:18:1a:10:2c/00:00:00:00:00/40 tag 3
ncq 114688 in
[   12.619125]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[   12.634583] ata1.00: status: { DRDY }
[   12.638292] ata1: hard resetting link
[   13.790424] ata1: softreset failed (device not ready)
[   13.795543] ata1: applying PMP SRST workaround and retrying
[   14.000437] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[   14.021749] ata1.00: configured for UDMA/133
[   14.026836] ata1: EH complete
[   14.140774] PHY: 1:00 - Link is Up - 100/Full


Best regards,
-- 
 Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-08-31 12:57       ` Hector Oron
  0 siblings, 0 replies; 54+ messages in thread
From: Hector Oron @ 2011-08-31 12:57 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

2011/8/31 Richard Zhu <richard.zhu@linaro.org>:
> Hi Hector:
> Thanks for your help to tests these patches.

Note I rebased this patches against 'imx-features' branch on Sascha's tree.
I am noticing some obscure (to me) messages from kernel:

[    6.874694] Adding 9767516k swap on /dev/sda3.  Priority:-1
extents:1 across:9767516k
[    7.073106] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro
[    7.708399] ata1.00: exception Emask 0x12 SAct 0x3 SErr 0x1280500
action 0x6 frozen
[    7.716219] ata1.00: irq_stat 0x08000000, interface fatal error
[    7.722216] ata1: SError: { UnrecovData Proto 10B8B BadCRC TrStaTrns }
[    7.728780] ata1.00: failed command: READ FPDMA QUEUED
[    7.733995] ata1.00: cmd 60/00:00:f2:11:32/01:00:00:00:00/40 tag 0
ncq 131072 in
[    7.734002]          res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[    7.749468] ata1.00: status: { DRDY }
[    7.753176] ata1.00: failed command: READ FPDMA QUEUED
[    7.758356] ata1.00: cmd 60/18:08:c2:14:32/00:00:00:00:00/40 tag 1
ncq 12288 in
[    7.758363]          res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[    7.773739] ata1.00: status: { DRDY }
[    7.777448] ata1: hard resetting link
[    8.750427] ata1: softreset failed (device not ready)
[    8.755551] ata1: applying PMP SRST workaround and retrying
[    8.960435] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[    8.981938] ata1.00: configured for UDMA/133
[    8.986535] ata1: EH complete
[   12.147912] eth0: Freescale FEC PHY driver [Generic PHY]
(mii_bus:phy_addr=1:00, irq=-1)
[   12.521870] ata1.00: exception Emask 0x12 SAct 0xf SErr 0x800500
action 0x6 frozen
[   12.529518] ata1.00: irq_stat 0x08000000, interface fatal error
[   12.535546] ata1: SError: { UnrecovData Proto LinkSeq }
[   12.540851] ata1.00: failed command: READ FPDMA QUEUED
[   12.546039] ata1.00: cmd 60/00:00:a2:19:2c/01:00:00:00:00/40 tag 0
ncq 131072 in
[   12.546046]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[   12.561519] ata1.00: status: { DRDY }
[   12.565209] ata1.00: failed command: READ FPDMA QUEUED
[   12.570419] ata1.00: cmd 60/00:08:1a:e9:2c/01:00:00:00:00/40 tag 1
ncq 131072 in
[   12.570426]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[   12.585890] ata1.00: status: { DRDY }
[   12.589578] ata1.00: failed command: READ FPDMA QUEUED
[   12.594776] ata1.00: cmd 60/00:10:7a:aa:2c/01:00:00:00:00/40 tag 2
ncq 131072 in
[   12.594783]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[   12.610240] ata1.00: status: { DRDY }
[   12.613945] ata1.00: failed command: READ FPDMA QUEUED
[   12.619118] ata1.00: cmd 60/e0:18:1a:10:2c/00:00:00:00:00/40 tag 3
ncq 114688 in
[   12.619125]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
0x12 (ATA bus error)
[   12.634583] ata1.00: status: { DRDY }
[   12.638292] ata1: hard resetting link
[   13.790424] ata1: softreset failed (device not ready)
[   13.795543] ata1: applying PMP SRST workaround and retrying
[   14.000437] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[   14.021749] ata1.00: configured for UDMA/133
[   14.026836] ata1: EH complete
[   14.140774] PHY: 1:00 - Link is Up - 100/Full


Best regards,
-- 
?H?ctor Or?n ?-.. . -... .. .- -. ? -.. . ...- . .-.. --- .--. . .-.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-08-31 12:57       ` Hector Oron
@ 2011-09-01  3:09         ` Richard Zhu
  -1 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-09-01  3:09 UTC (permalink / raw)
  To: Hector Oron
  Cc: Wolfram Sang, linux-arm-kernel, kernel, eric.miao, linux-ide,
	eric, avorontsov, jgarzik

Hi Hector:
What's happen before "> [    7.073106] EXT4-fs (sda2): re-mounted.
Opts: errors=remount-ro"?
I re-based the patches to Sascha's imx-features branch, my sata device can work.
Test sw environment:  Sascha's imx-features branch,
Test hw environment: iMX53 loco board, 32G sandisk ssd, tftp download
the kernel image,
 and the nfs type rootfs is mounted.

loop: module loaded
ahci: SSS flag set, parallel bus scan disabled
ahci imx53-ahci.0: AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl platform mode
ahci imx53-ahci.0: flags: ncq sntf stag pm led clo only pmp pio slum part ccc
scsi0 : ahci_platform
ata1: SATA max UDMA/133 mmio [mem 0x10000000-0x10000fff] port 0x100 irq 28
FEC Ethernet Driver
fec_enet_mii_bus: probed
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
mousedev: PS/2 mouse device common for all mice
input: mma8450 as /devices/virtual/input/input0
i2c /dev entries driver
imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled. timeout=60s (nowayout=0)
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
mmc0: no vmmc regulator found
mmc0: SDHCI controller on sdhci-esdhc-imx53.0 [sdhci-esdhc-imx53.0] using DMA
mmc1: no vmmc regulator found
mmc1: SDHCI controller on sdhci-esdhc-imx53.2 [sdhci-esdhc-imx53.2] using DMA
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP cubic registered
NET: Registered protocol family 17
Registering the dns_resolver key type
VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2
input: gpio-keys as /devices/platform/gpio-keys/input/input1
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
eth0: Freescale FEC PHY driver [SMSC LAN8710/LAN8720]
(mii_bus:phy_addr=1:00, irq=-1)
mmc0: host does not support reading read-only switch. assuming write-enable.
mmc0: new high speed SDHC card at address 0001
mmcblk0: mmc0:0001 00000 3.79 GiB
 mmcblk0: p1 p2 p3
ata1: softreset failed (device not ready)
ata1: applying PMP SRST workaround and retrying
ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
ata1.00: ATA-8: SanDisk SSD P4 32GB, SSD 8.00, max UDMA/133
ata1.00: 62533296 sectors, multi 1: LBA48
ata1.00: configured for UDMA/133
scsi 0:0:0:0: Direct-Access     ATA      SanDisk SSD P4 3 SSD  PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] 62533296 512-byte logical blocks: (32.0 GB/29.8 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
support DPO or FUA
 sda: sda1 sda2
sd 0:0:0:0: [sda] Attached SCSI disk
PHY: 1:00 - Link is Up - 100/Full
Sending DHCP requests ., OK

Best Regards
Richard Zhu

On 31 August 2011 20:57, Hector Oron <hector.oron@gmail.com> wrote:
> Hello,
>
> 2011/8/31 Richard Zhu <richard.zhu@linaro.org>:
>> Hi Hector:
>> Thanks for your help to tests these patches.
>
> Note I rebased this patches against 'imx-features' branch on Sascha's tree.
> I am noticing some obscure (to me) messages from kernel:
>
> [    6.874694] Adding 9767516k swap on /dev/sda3.  Priority:-1
> extents:1 across:9767516k
> [    7.073106] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro
> [    7.708399] ata1.00: exception Emask 0x12 SAct 0x3 SErr 0x1280500
> action 0x6 frozen
> [    7.716219] ata1.00: irq_stat 0x08000000, interface fatal error
> [    7.722216] ata1: SError: { UnrecovData Proto 10B8B BadCRC TrStaTrns }
> [    7.728780] ata1.00: failed command: READ FPDMA QUEUED
> [    7.733995] ata1.00: cmd 60/00:00:f2:11:32/01:00:00:00:00/40 tag 0
> ncq 131072 in
> [    7.734002]          res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [    7.749468] ata1.00: status: { DRDY }
> [    7.753176] ata1.00: failed command: READ FPDMA QUEUED
> [    7.758356] ata1.00: cmd 60/18:08:c2:14:32/00:00:00:00:00/40 tag 1
> ncq 12288 in
> [    7.758363]          res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [    7.773739] ata1.00: status: { DRDY }
> [    7.777448] ata1: hard resetting link
> [    8.750427] ata1: softreset failed (device not ready)
> [    8.755551] ata1: applying PMP SRST workaround and retrying
> [    8.960435] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [    8.981938] ata1.00: configured for UDMA/133
> [    8.986535] ata1: EH complete
> [   12.147912] eth0: Freescale FEC PHY driver [Generic PHY]
> (mii_bus:phy_addr=1:00, irq=-1)
> [   12.521870] ata1.00: exception Emask 0x12 SAct 0xf SErr 0x800500
> action 0x6 frozen
> [   12.529518] ata1.00: irq_stat 0x08000000, interface fatal error
> [   12.535546] ata1: SError: { UnrecovData Proto LinkSeq }
> [   12.540851] ata1.00: failed command: READ FPDMA QUEUED
> [   12.546039] ata1.00: cmd 60/00:00:a2:19:2c/01:00:00:00:00/40 tag 0
> ncq 131072 in
> [   12.546046]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [   12.561519] ata1.00: status: { DRDY }
> [   12.565209] ata1.00: failed command: READ FPDMA QUEUED
> [   12.570419] ata1.00: cmd 60/00:08:1a:e9:2c/01:00:00:00:00/40 tag 1
> ncq 131072 in
> [   12.570426]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [   12.585890] ata1.00: status: { DRDY }
> [   12.589578] ata1.00: failed command: READ FPDMA QUEUED
> [   12.594776] ata1.00: cmd 60/00:10:7a:aa:2c/01:00:00:00:00/40 tag 2
> ncq 131072 in
> [   12.594783]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [   12.610240] ata1.00: status: { DRDY }
> [   12.613945] ata1.00: failed command: READ FPDMA QUEUED
> [   12.619118] ata1.00: cmd 60/e0:18:1a:10:2c/00:00:00:00:00/40 tag 3
> ncq 114688 in
> [   12.619125]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [   12.634583] ata1.00: status: { DRDY }
> [   12.638292] ata1: hard resetting link
> [   13.790424] ata1: softreset failed (device not ready)
> [   13.795543] ata1: applying PMP SRST workaround and retrying
> [   14.000437] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [   14.021749] ata1.00: configured for UDMA/133
> [   14.026836] ata1: EH complete
> [   14.140774] PHY: 1:00 - Link is Up - 100/Full
>
>
> Best regards,
> --
>  Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-01  3:09         ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-09-01  3:09 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Hector:
What's happen before "> [    7.073106] EXT4-fs (sda2): re-mounted.
Opts: errors=remount-ro"?
I re-based the patches to Sascha's imx-features branch, my sata device can work.
Test sw environment:  Sascha's imx-features branch,
Test hw environment: iMX53 loco board, 32G sandisk ssd, tftp download
the kernel image,
 and the nfs type rootfs is mounted.

loop: module loaded
ahci: SSS flag set, parallel bus scan disabled
ahci imx53-ahci.0: AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl platform mode
ahci imx53-ahci.0: flags: ncq sntf stag pm led clo only pmp pio slum part ccc
scsi0 : ahci_platform
ata1: SATA max UDMA/133 mmio [mem 0x10000000-0x10000fff] port 0x100 irq 28
FEC Ethernet Driver
fec_enet_mii_bus: probed
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
mousedev: PS/2 mouse device common for all mice
input: mma8450 as /devices/virtual/input/input0
i2c /dev entries driver
imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled. timeout=60s (nowayout=0)
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
mmc0: no vmmc regulator found
mmc0: SDHCI controller on sdhci-esdhc-imx53.0 [sdhci-esdhc-imx53.0] using DMA
mmc1: no vmmc regulator found
mmc1: SDHCI controller on sdhci-esdhc-imx53.2 [sdhci-esdhc-imx53.2] using DMA
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP cubic registered
NET: Registered protocol family 17
Registering the dns_resolver key type
VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2
input: gpio-keys as /devices/platform/gpio-keys/input/input1
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
eth0: Freescale FEC PHY driver [SMSC LAN8710/LAN8720]
(mii_bus:phy_addr=1:00, irq=-1)
mmc0: host does not support reading read-only switch. assuming write-enable.
mmc0: new high speed SDHC card at address 0001
mmcblk0: mmc0:0001 00000 3.79 GiB
 mmcblk0: p1 p2 p3
ata1: softreset failed (device not ready)
ata1: applying PMP SRST workaround and retrying
ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
ata1.00: ATA-8: SanDisk SSD P4 32GB, SSD 8.00, max UDMA/133
ata1.00: 62533296 sectors, multi 1: LBA48
ata1.00: configured for UDMA/133
scsi 0:0:0:0: Direct-Access     ATA      SanDisk SSD P4 3 SSD  PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] 62533296 512-byte logical blocks: (32.0 GB/29.8 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
support DPO or FUA
 sda: sda1 sda2
sd 0:0:0:0: [sda] Attached SCSI disk
PHY: 1:00 - Link is Up - 100/Full
Sending DHCP requests ., OK

Best Regards
Richard Zhu

On 31 August 2011 20:57, Hector Oron <hector.oron@gmail.com> wrote:
> Hello,
>
> 2011/8/31 Richard Zhu <richard.zhu@linaro.org>:
>> Hi Hector:
>> Thanks for your help to tests these patches.
>
> Note I rebased this patches against 'imx-features' branch on Sascha's tree.
> I am noticing some obscure (to me) messages from kernel:
>
> [ ? ?6.874694] Adding 9767516k swap on /dev/sda3. ?Priority:-1
> extents:1 across:9767516k
> [ ? ?7.073106] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro
> [ ? ?7.708399] ata1.00: exception Emask 0x12 SAct 0x3 SErr 0x1280500
> action 0x6 frozen
> [ ? ?7.716219] ata1.00: irq_stat 0x08000000, interface fatal error
> [ ? ?7.722216] ata1: SError: { UnrecovData Proto 10B8B BadCRC TrStaTrns }
> [ ? ?7.728780] ata1.00: failed command: READ FPDMA QUEUED
> [ ? ?7.733995] ata1.00: cmd 60/00:00:f2:11:32/01:00:00:00:00/40 tag 0
> ncq 131072 in
> [ ? ?7.734002] ? ? ? ? ?res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [ ? ?7.749468] ata1.00: status: { DRDY }
> [ ? ?7.753176] ata1.00: failed command: READ FPDMA QUEUED
> [ ? ?7.758356] ata1.00: cmd 60/18:08:c2:14:32/00:00:00:00:00/40 tag 1
> ncq 12288 in
> [ ? ?7.758363] ? ? ? ? ?res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [ ? ?7.773739] ata1.00: status: { DRDY }
> [ ? ?7.777448] ata1: hard resetting link
> [ ? ?8.750427] ata1: softreset failed (device not ready)
> [ ? ?8.755551] ata1: applying PMP SRST workaround and retrying
> [ ? ?8.960435] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [ ? ?8.981938] ata1.00: configured for UDMA/133
> [ ? ?8.986535] ata1: EH complete
> [ ? 12.147912] eth0: Freescale FEC PHY driver [Generic PHY]
> (mii_bus:phy_addr=1:00, irq=-1)
> [ ? 12.521870] ata1.00: exception Emask 0x12 SAct 0xf SErr 0x800500
> action 0x6 frozen
> [ ? 12.529518] ata1.00: irq_stat 0x08000000, interface fatal error
> [ ? 12.535546] ata1: SError: { UnrecovData Proto LinkSeq }
> [ ? 12.540851] ata1.00: failed command: READ FPDMA QUEUED
> [ ? 12.546039] ata1.00: cmd 60/00:00:a2:19:2c/01:00:00:00:00/40 tag 0
> ncq 131072 in
> [ ? 12.546046] ? ? ? ? ?res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [ ? 12.561519] ata1.00: status: { DRDY }
> [ ? 12.565209] ata1.00: failed command: READ FPDMA QUEUED
> [ ? 12.570419] ata1.00: cmd 60/00:08:1a:e9:2c/01:00:00:00:00/40 tag 1
> ncq 131072 in
> [ ? 12.570426] ? ? ? ? ?res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [ ? 12.585890] ata1.00: status: { DRDY }
> [ ? 12.589578] ata1.00: failed command: READ FPDMA QUEUED
> [ ? 12.594776] ata1.00: cmd 60/00:10:7a:aa:2c/01:00:00:00:00/40 tag 2
> ncq 131072 in
> [ ? 12.594783] ? ? ? ? ?res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [ ? 12.610240] ata1.00: status: { DRDY }
> [ ? 12.613945] ata1.00: failed command: READ FPDMA QUEUED
> [ ? 12.619118] ata1.00: cmd 60/e0:18:1a:10:2c/00:00:00:00:00/40 tag 3
> ncq 114688 in
> [ ? 12.619125] ? ? ? ? ?res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
> 0x12 (ATA bus error)
> [ ? 12.634583] ata1.00: status: { DRDY }
> [ ? 12.638292] ata1: hard resetting link
> [ ? 13.790424] ata1: softreset failed (device not ready)
> [ ? 13.795543] ata1: applying PMP SRST workaround and retrying
> [ ? 14.000437] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [ ? 14.021749] ata1.00: configured for UDMA/133
> [ ? 14.026836] ata1: EH complete
> [ ? 14.140774] PHY: 1:00 - Link is Up - 100/Full
>
>
> Best regards,
> --
> ?H?ctor Or?n ?-.. . -... .. .- -. ? -.. . ...- . .-.. --- .--. . .-.
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-01  3:09         ` Richard Zhu
@ 2011-09-05 18:06           ` Eric Miao
  -1 siblings, 0 replies; 54+ messages in thread
From: Eric Miao @ 2011-09-05 18:06 UTC (permalink / raw)
  To: Hector Oron, Richard Zhu
  Cc: eric, Wolfram Sang, linux-ide, kernel, avorontsov, jgarzik,
	linux-arm-kernel

Hi Hector,

I don't have this issue either. Could you verify it's caused by something else?
You may try a different SSD.

- eric

On Wed, Aug 31, 2011 at 8:09 PM, Richard Zhu <richard.zhu@linaro.org> wrote:
> Hi Hector:
> What's happen before "> [    7.073106] EXT4-fs (sda2): re-mounted.
> Opts: errors=remount-ro"?
> I re-based the patches to Sascha's imx-features branch, my sata device can work.
> Test sw environment:  Sascha's imx-features branch,
> Test hw environment: iMX53 loco board, 32G sandisk ssd, tftp download
> the kernel image,
>  and the nfs type rootfs is mounted.
>
> loop: module loaded
> ahci: SSS flag set, parallel bus scan disabled
> ahci imx53-ahci.0: AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl platform mode
> ahci imx53-ahci.0: flags: ncq sntf stag pm led clo only pmp pio slum part ccc
> scsi0 : ahci_platform
> ata1: SATA max UDMA/133 mmio [mem 0x10000000-0x10000fff] port 0x100 irq 28
> FEC Ethernet Driver
> fec_enet_mii_bus: probed
> ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
> Initializing USB Mass Storage driver...
> usbcore: registered new interface driver usb-storage
> USB Mass Storage support registered.
> mousedev: PS/2 mouse device common for all mice
> input: mma8450 as /devices/virtual/input/input0
> i2c /dev entries driver
> imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled. timeout=60s (nowayout=0)
> sdhci: Secure Digital Host Controller Interface driver
> sdhci: Copyright(c) Pierre Ossman
> sdhci-pltfm: SDHCI platform and OF driver helper
> mmc0: no vmmc regulator found
> mmc0: SDHCI controller on sdhci-esdhc-imx53.0 [sdhci-esdhc-imx53.0] using DMA
> mmc1: no vmmc regulator found
> mmc1: SDHCI controller on sdhci-esdhc-imx53.2 [sdhci-esdhc-imx53.2] using DMA
> usbcore: registered new interface driver usbhid
> usbhid: USB HID core driver
> TCP cubic registered
> NET: Registered protocol family 17
> Registering the dns_resolver key type
> VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2
> input: gpio-keys as /devices/platform/gpio-keys/input/input1
> drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
> eth0: Freescale FEC PHY driver [SMSC LAN8710/LAN8720]
> (mii_bus:phy_addr=1:00, irq=-1)
> mmc0: host does not support reading read-only switch. assuming write-enable.
> mmc0: new high speed SDHC card at address 0001
> mmcblk0: mmc0:0001 00000 3.79 GiB
>  mmcblk0: p1 p2 p3
> ata1: softreset failed (device not ready)
> ata1: applying PMP SRST workaround and retrying
> ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> ata1.00: ATA-8: SanDisk SSD P4 32GB, SSD 8.00, max UDMA/133
> ata1.00: 62533296 sectors, multi 1: LBA48
> ata1.00: configured for UDMA/133
> scsi 0:0:0:0: Direct-Access     ATA      SanDisk SSD P4 3 SSD  PQ: 0 ANSI: 5
> sd 0:0:0:0: [sda] 62533296 512-byte logical blocks: (32.0 GB/29.8 GiB)
> sd 0:0:0:0: [sda] Write Protect is off
> sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
> support DPO or FUA
>  sda: sda1 sda2
> sd 0:0:0:0: [sda] Attached SCSI disk
> PHY: 1:00 - Link is Up - 100/Full
> Sending DHCP requests ., OK
>
> Best Regards
> Richard Zhu
>
> On 31 August 2011 20:57, Hector Oron <hector.oron@gmail.com> wrote:
>> Hello,
>>
>> 2011/8/31 Richard Zhu <richard.zhu@linaro.org>:
>>> Hi Hector:
>>> Thanks for your help to tests these patches.
>>
>> Note I rebased this patches against 'imx-features' branch on Sascha's tree.
>> I am noticing some obscure (to me) messages from kernel:
>>
>> [    6.874694] Adding 9767516k swap on /dev/sda3.  Priority:-1
>> extents:1 across:9767516k
>> [    7.073106] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro
>> [    7.708399] ata1.00: exception Emask 0x12 SAct 0x3 SErr 0x1280500
>> action 0x6 frozen
>> [    7.716219] ata1.00: irq_stat 0x08000000, interface fatal error
>> [    7.722216] ata1: SError: { UnrecovData Proto 10B8B BadCRC TrStaTrns }
>> [    7.728780] ata1.00: failed command: READ FPDMA QUEUED
>> [    7.733995] ata1.00: cmd 60/00:00:f2:11:32/01:00:00:00:00/40 tag 0
>> ncq 131072 in
>> [    7.734002]          res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [    7.749468] ata1.00: status: { DRDY }
>> [    7.753176] ata1.00: failed command: READ FPDMA QUEUED
>> [    7.758356] ata1.00: cmd 60/18:08:c2:14:32/00:00:00:00:00/40 tag 1
>> ncq 12288 in
>> [    7.758363]          res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [    7.773739] ata1.00: status: { DRDY }
>> [    7.777448] ata1: hard resetting link
>> [    8.750427] ata1: softreset failed (device not ready)
>> [    8.755551] ata1: applying PMP SRST workaround and retrying
>> [    8.960435] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
>> [    8.981938] ata1.00: configured for UDMA/133
>> [    8.986535] ata1: EH complete
>> [   12.147912] eth0: Freescale FEC PHY driver [Generic PHY]
>> (mii_bus:phy_addr=1:00, irq=-1)
>> [   12.521870] ata1.00: exception Emask 0x12 SAct 0xf SErr 0x800500
>> action 0x6 frozen
>> [   12.529518] ata1.00: irq_stat 0x08000000, interface fatal error
>> [   12.535546] ata1: SError: { UnrecovData Proto LinkSeq }
>> [   12.540851] ata1.00: failed command: READ FPDMA QUEUED
>> [   12.546039] ata1.00: cmd 60/00:00:a2:19:2c/01:00:00:00:00/40 tag 0
>> ncq 131072 in
>> [   12.546046]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [   12.561519] ata1.00: status: { DRDY }
>> [   12.565209] ata1.00: failed command: READ FPDMA QUEUED
>> [   12.570419] ata1.00: cmd 60/00:08:1a:e9:2c/01:00:00:00:00/40 tag 1
>> ncq 131072 in
>> [   12.570426]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [   12.585890] ata1.00: status: { DRDY }
>> [   12.589578] ata1.00: failed command: READ FPDMA QUEUED
>> [   12.594776] ata1.00: cmd 60/00:10:7a:aa:2c/01:00:00:00:00/40 tag 2
>> ncq 131072 in
>> [   12.594783]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [   12.610240] ata1.00: status: { DRDY }
>> [   12.613945] ata1.00: failed command: READ FPDMA QUEUED
>> [   12.619118] ata1.00: cmd 60/e0:18:1a:10:2c/00:00:00:00:00/40 tag 3
>> ncq 114688 in
>> [   12.619125]          res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [   12.634583] ata1.00: status: { DRDY }
>> [   12.638292] ata1: hard resetting link
>> [   13.790424] ata1: softreset failed (device not ready)
>> [   13.795543] ata1: applying PMP SRST workaround and retrying
>> [   14.000437] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
>> [   14.021749] ata1.00: configured for UDMA/133
>> [   14.026836] ata1: EH complete
>> [   14.140774] PHY: 1:00 - Link is Up - 100/Full
>>
>>
>> Best regards,
>> --
>>  Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.
>>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-05 18:06           ` Eric Miao
  0 siblings, 0 replies; 54+ messages in thread
From: Eric Miao @ 2011-09-05 18:06 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Hector,

I don't have this issue either. Could you verify it's caused by something else?
You may try a different SSD.

- eric

On Wed, Aug 31, 2011 at 8:09 PM, Richard Zhu <richard.zhu@linaro.org> wrote:
> Hi Hector:
> What's happen before "> [ ? ?7.073106] EXT4-fs (sda2): re-mounted.
> Opts: errors=remount-ro"?
> I re-based the patches to Sascha's imx-features branch, my sata device can work.
> Test sw environment: ?Sascha's imx-features branch,
> Test hw environment: iMX53 loco board, 32G sandisk ssd, tftp download
> the kernel image,
> ?and the nfs type rootfs is mounted.
>
> loop: module loaded
> ahci: SSS flag set, parallel bus scan disabled
> ahci imx53-ahci.0: AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl platform mode
> ahci imx53-ahci.0: flags: ncq sntf stag pm led clo only pmp pio slum part ccc
> scsi0 : ahci_platform
> ata1: SATA max UDMA/133 mmio [mem 0x10000000-0x10000fff] port 0x100 irq 28
> FEC Ethernet Driver
> fec_enet_mii_bus: probed
> ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
> Initializing USB Mass Storage driver...
> usbcore: registered new interface driver usb-storage
> USB Mass Storage support registered.
> mousedev: PS/2 mouse device common for all mice
> input: mma8450 as /devices/virtual/input/input0
> i2c /dev entries driver
> imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled. timeout=60s (nowayout=0)
> sdhci: Secure Digital Host Controller Interface driver
> sdhci: Copyright(c) Pierre Ossman
> sdhci-pltfm: SDHCI platform and OF driver helper
> mmc0: no vmmc regulator found
> mmc0: SDHCI controller on sdhci-esdhc-imx53.0 [sdhci-esdhc-imx53.0] using DMA
> mmc1: no vmmc regulator found
> mmc1: SDHCI controller on sdhci-esdhc-imx53.2 [sdhci-esdhc-imx53.2] using DMA
> usbcore: registered new interface driver usbhid
> usbhid: USB HID core driver
> TCP cubic registered
> NET: Registered protocol family 17
> Registering the dns_resolver key type
> VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2
> input: gpio-keys as /devices/platform/gpio-keys/input/input1
> drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
> eth0: Freescale FEC PHY driver [SMSC LAN8710/LAN8720]
> (mii_bus:phy_addr=1:00, irq=-1)
> mmc0: host does not support reading read-only switch. assuming write-enable.
> mmc0: new high speed SDHC card at address 0001
> mmcblk0: mmc0:0001 00000 3.79 GiB
> ?mmcblk0: p1 p2 p3
> ata1: softreset failed (device not ready)
> ata1: applying PMP SRST workaround and retrying
> ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> ata1.00: ATA-8: SanDisk SSD P4 32GB, SSD 8.00, max UDMA/133
> ata1.00: 62533296 sectors, multi 1: LBA48
> ata1.00: configured for UDMA/133
> scsi 0:0:0:0: Direct-Access ? ? ATA ? ? ?SanDisk SSD P4 3 SSD ?PQ: 0 ANSI: 5
> sd 0:0:0:0: [sda] 62533296 512-byte logical blocks: (32.0 GB/29.8 GiB)
> sd 0:0:0:0: [sda] Write Protect is off
> sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
> support DPO or FUA
> ?sda: sda1 sda2
> sd 0:0:0:0: [sda] Attached SCSI disk
> PHY: 1:00 - Link is Up - 100/Full
> Sending DHCP requests ., OK
>
> Best Regards
> Richard Zhu
>
> On 31 August 2011 20:57, Hector Oron <hector.oron@gmail.com> wrote:
>> Hello,
>>
>> 2011/8/31 Richard Zhu <richard.zhu@linaro.org>:
>>> Hi Hector:
>>> Thanks for your help to tests these patches.
>>
>> Note I rebased this patches against 'imx-features' branch on Sascha's tree.
>> I am noticing some obscure (to me) messages from kernel:
>>
>> [ ? ?6.874694] Adding 9767516k swap on /dev/sda3. ?Priority:-1
>> extents:1 across:9767516k
>> [ ? ?7.073106] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro
>> [ ? ?7.708399] ata1.00: exception Emask 0x12 SAct 0x3 SErr 0x1280500
>> action 0x6 frozen
>> [ ? ?7.716219] ata1.00: irq_stat 0x08000000, interface fatal error
>> [ ? ?7.722216] ata1: SError: { UnrecovData Proto 10B8B BadCRC TrStaTrns }
>> [ ? ?7.728780] ata1.00: failed command: READ FPDMA QUEUED
>> [ ? ?7.733995] ata1.00: cmd 60/00:00:f2:11:32/01:00:00:00:00/40 tag 0
>> ncq 131072 in
>> [ ? ?7.734002] ? ? ? ? ?res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [ ? ?7.749468] ata1.00: status: { DRDY }
>> [ ? ?7.753176] ata1.00: failed command: READ FPDMA QUEUED
>> [ ? ?7.758356] ata1.00: cmd 60/18:08:c2:14:32/00:00:00:00:00/40 tag 1
>> ncq 12288 in
>> [ ? ?7.758363] ? ? ? ? ?res 40/00:04:f2:11:32/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [ ? ?7.773739] ata1.00: status: { DRDY }
>> [ ? ?7.777448] ata1: hard resetting link
>> [ ? ?8.750427] ata1: softreset failed (device not ready)
>> [ ? ?8.755551] ata1: applying PMP SRST workaround and retrying
>> [ ? ?8.960435] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
>> [ ? ?8.981938] ata1.00: configured for UDMA/133
>> [ ? ?8.986535] ata1: EH complete
>> [ ? 12.147912] eth0: Freescale FEC PHY driver [Generic PHY]
>> (mii_bus:phy_addr=1:00, irq=-1)
>> [ ? 12.521870] ata1.00: exception Emask 0x12 SAct 0xf SErr 0x800500
>> action 0x6 frozen
>> [ ? 12.529518] ata1.00: irq_stat 0x08000000, interface fatal error
>> [ ? 12.535546] ata1: SError: { UnrecovData Proto LinkSeq }
>> [ ? 12.540851] ata1.00: failed command: READ FPDMA QUEUED
>> [ ? 12.546039] ata1.00: cmd 60/00:00:a2:19:2c/01:00:00:00:00/40 tag 0
>> ncq 131072 in
>> [ ? 12.546046] ? ? ? ? ?res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [ ? 12.561519] ata1.00: status: { DRDY }
>> [ ? 12.565209] ata1.00: failed command: READ FPDMA QUEUED
>> [ ? 12.570419] ata1.00: cmd 60/00:08:1a:e9:2c/01:00:00:00:00/40 tag 1
>> ncq 131072 in
>> [ ? 12.570426] ? ? ? ? ?res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [ ? 12.585890] ata1.00: status: { DRDY }
>> [ ? 12.589578] ata1.00: failed command: READ FPDMA QUEUED
>> [ ? 12.594776] ata1.00: cmd 60/00:10:7a:aa:2c/01:00:00:00:00/40 tag 2
>> ncq 131072 in
>> [ ? 12.594783] ? ? ? ? ?res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [ ? 12.610240] ata1.00: status: { DRDY }
>> [ ? 12.613945] ata1.00: failed command: READ FPDMA QUEUED
>> [ ? 12.619118] ata1.00: cmd 60/e0:18:1a:10:2c/00:00:00:00:00/40 tag 3
>> ncq 114688 in
>> [ ? 12.619125] ? ? ? ? ?res 40/00:14:7a:aa:2c/00:00:00:00:00/40 Emask
>> 0x12 (ATA bus error)
>> [ ? 12.634583] ata1.00: status: { DRDY }
>> [ ? 12.638292] ata1: hard resetting link
>> [ ? 13.790424] ata1: softreset failed (device not ready)
>> [ ? 13.795543] ata1: applying PMP SRST workaround and retrying
>> [ ? 14.000437] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
>> [ ? 14.021749] ata1.00: configured for UDMA/133
>> [ ? 14.026836] ata1: EH complete
>> [ ? 14.140774] PHY: 1:00 - Link is Up - 100/Full
>>
>>
>> Best regards,
>> --
>> ?H?ctor Or?n ?-.. . -... .. .- -. ? -.. . ...- . .-.. --- .--. . .-.
>>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-08-31 12:57       ` Hector Oron
@ 2011-09-05 19:25         ` Arnaud Patard (Rtp)
  -1 siblings, 0 replies; 54+ messages in thread
From: Arnaud Patard @ 2011-09-05 19:25 UTC (permalink / raw)
  To: Hector Oron
  Cc: Richard Zhu, eric, Wolfram Sang, eric.miao, linux-ide, kernel,
	avorontsov, jgarzik, linux-arm-kernel

Hector Oron <hector.oron@gmail.com> writes:

> Hello,

Hi,

>
> 2011/8/31 Richard Zhu <richard.zhu@linaro.org>:
>> Hi Hector:
>> Thanks for your help to tests these patches.
>
> Note I rebased this patches against 'imx-features' branch on Sascha's tree.
> I am noticing some obscure (to me) messages from kernel:

Currently testing with probably same checkout of imx-features branch
with a sata 3.5" drive. Running badblocks in non destructive write mode
and so far, so good (it's slow but it may comes from my drive).

Did you test if there was a bad cable or faulty drive PSU ?

Arnaud

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-05 19:25         ` Arnaud Patard (Rtp)
  0 siblings, 0 replies; 54+ messages in thread
From: Arnaud Patard (Rtp) @ 2011-09-05 19:25 UTC (permalink / raw)
  To: linux-arm-kernel

Hector Oron <hector.oron@gmail.com> writes:

> Hello,

Hi,

>
> 2011/8/31 Richard Zhu <richard.zhu@linaro.org>:
>> Hi Hector:
>> Thanks for your help to tests these patches.
>
> Note I rebased this patches against 'imx-features' branch on Sascha's tree.
> I am noticing some obscure (to me) messages from kernel:

Currently testing with probably same checkout of imx-features branch
with a sata 3.5" drive. Running badblocks in non destructive write mode
and so far, so good (it's slow but it may comes from my drive).

Did you test if there was a bad cable or faulty drive PSU ?

Arnaud

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-01  3:09         ` Richard Zhu
@ 2011-09-06  8:46           ` Hector Oron
  -1 siblings, 0 replies; 54+ messages in thread
From: Hector Oron @ 2011-09-06  8:46 UTC (permalink / raw)
  To: Richard Zhu
  Cc: Wolfram Sang, linux-arm-kernel, kernel, eric.miao, linux-ide,
	eric, avorontsov, jgarzik

Hi,

2011/9/1 Richard Zhu <richard.zhu@linaro.org>:
> Hi Hector:
> What's happen before "> [    7.073106] EXT4-fs (sda2): re-mounted.
> Opts: errors=remount-ro"?

Here is my complete dmesg. The system seems to work fine, it is a
1.0TB WD10TPVT SATA disk in a case which provides eSATA and connected
to mx53 LOCO with eSATA-to-SATA cable. I have around a Lacie eSATA
disk which I might attempt to connect.

Linux version 3.1.0-rc3-mx5 (zumbi@enorme) (gcc version 4.4.5 (Debian
4.4.5-8) ) #7 Tue Aug 30 13:17:14 BST 2011
CPU: ARMv7 Processor [412fc085] revision 5 (ARMv7), cr=10c53c7f
CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: Freescale MX53 LOCO Board
Ignoring RAM at b0000000-cfffffff (vmalloc region overlap).
Memory policy: ECC disabled, Data cache writeback
On node 0 totalpages: 131072
free_area_init_node: node 0, pgdat c0461e08, node_mem_map c04b2000
  Normal zone: 1024 pages used for memmap
  Normal zone: 0 pages reserved
  Normal zone: 130048 pages, LIFO batch:31
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttymxc0,115200 console=tty1
root=/dev/sda2 video=mxcdi1fb:GBR24,XGA di1_primary tve  printk.time=1
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 512MB = 512MB total
[    0.000000] Memory: 514948k/514948k available, 9340k reserved, 0K highmem
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
[    0.000000]     vmalloc : 0xe0800000 - 0xf4000000   ( 312 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc0412000   (4136 kB)
[    0.000000]       .init : 0xc0412000 - 0xc0437000   ( 148 kB)
[    0.000000]       .data : 0xc0438000 - 0xc0462480   ( 170 kB)
[    0.000000]        .bss : 0xc04624a4 - 0xc04b1380   ( 316 kB)
[    0.000000] SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0,
CPUs=1, Nodes=1
[    0.000000] NR_IRQS:400
[    0.000000] TrustZone Interrupt Controller (TZIC) initialized
[    0.000000] CPU identified as i.MX53, silicon rev 2.1
[    0.000000] sched_clock: 32 bits at 55MHz, resolution 18ns, wraps
every 77386ms
[    0.000000] Console: colour dummy device 80x30
[    0.000000] console [tty1] enabled
[    0.000556] Calibrating delay loop... 795.44 BogoMIPS (lpj=3977216)
[    0.040182] pid_max: default: 32768 minimum: 301
[    0.040450] Mount-cache hash table entries: 512
[    0.041059] CPU: Testing write buffer coherency: ok
[    0.042459] devtmpfs: initialized
[    0.044791] print_constraints: dummy:
[    0.045120] NET: Registered protocol family 16
[    0.065856] bio: create slab <bio-0> at 0
[    0.067168] SCSI subsystem initialized
[    0.067580] libata version 3.00 loaded.
[    0.067989] usbcore: registered new interface driver usbfs
[    0.068174] usbcore: registered new interface driver hub
[    0.068488] usbcore: registered new device driver usb
[    0.070182] Switching to clocksource mxc_timer1
[    0.080403] Switched to NOHz mode on CPU #0
[    0.088737] NET: Registered protocol family 2
[    0.089034] IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.089503] TCP established hash table entries: 16384 (order: 5,
131072 bytes)
[    0.089861] TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
[    0.090067] TCP: Hash tables configured (established 16384 bind 16384)
[    0.090096] TCP reno registered
[    0.090128] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.090168] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.090626] NET: Registered protocol family 1
[    0.091318] RPC: Registered named UNIX socket transport module.
[    0.091381] RPC: Registered udp transport module.
[    0.091407] RPC: Registered tcp transport module.
[    0.091429] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.115113] VFS: Disk quotas dquot_6.5.2
[    0.115483] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.120839] fuse init (API version 7.16)
[    0.121919] msgmni has been set to 1005
[    0.122544] Block layer SCSI generic (bsg) driver version 0.4
loaded (major 253)
[    0.122618] io scheduler noop registered
[    0.122646] io scheduler deadline registered
[    0.122920] io scheduler cfq registered (default)
[    0.123527] Serial: IMX driver
[    0.123787] imx21-uart.0: ttymxc0 at MMIO 0x53fbc000 (irq = 31) is a IMX
[    0.489212] console [ttymxc0] enabled
[    0.502624] brd: module loaded
[    0.511401] loop: module loaded
[    0.515060] nbd: registered device at major 43
[    0.532271] ahci: SSS flag set, parallel bus scan disabled
[    0.537878] ahci imx53-ahci.0: AHCI 0001.0100 32 slots 1 ports 3
Gbps 0x1 impl platform mode
[    0.546452] ahci imx53-ahci.0: flags: ncq sntf stag pm led clo only
pmp pio slum part ccc
[    0.556008] scsi0 : ahci_platform
[    0.560052] ata1: SATA max UDMA/133 mmio [mem
0x10000000-0x10000fff] port 0x100 irq 28
[    0.568788] FEC Ethernet Driver
[    0.575892] fec_enet_mii_bus: probed
[    0.580170] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.587109] Initializing USB Mass Storage driver...
[    0.592309] usbcore: registered new interface driver usb-storage
[    0.598353] USB Mass Storage support registered.
[    0.603499] mousedev: PS/2 mouse device common for all mice
[    0.609483] i2c /dev entries driver
[    0.614322] imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled.
timeout=60s (nowayout=0)
[    0.623615] device-mapper: uevent: version 1.0.3
[    0.629223] device-mapper: ioctl: 4.21.0-ioctl (2011-07-06)
initialised: dm-devel@redhat.com
[    0.637827] sdhci: Secure Digital Host Controller Interface driver
[    0.644080] sdhci: Copyright(c) Pierre Ossman
[    0.648461] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.654585] mmc0: no vmmc regulator found
[    0.658808] Registered led device: mmc0::
[    0.659016] mmc0: SDHCI controller on sdhci-esdhc-imx53.0
[sdhci-esdhc-imx53.0] using DMA
[    0.667691] mmc1: no vmmc regulator found
[    0.672020] Registered led device: mmc1::
[    0.672265] mmc1: SDHCI controller on sdhci-esdhc-imx53.2
[sdhci-esdhc-imx53.2] using DMA
[    0.681037] usbcore: registered new interface driver usbhid
[    0.686655] usbhid: USB HID core driver
[    0.790254] TCP cubic registered
[    0.793596] NET: Registered protocol family 17
[    0.798190] Registering the dns_resolver key type
[    0.803078] VFP support v0.3: implementor 41 architecture 3 part 30
variant c rev 2
[    0.813279] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    0.820805] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    0.863099] mmc0: host does not support reading read-only switch.
assuming write-enable.
[    0.970967] mmc0: new SD card at address 1234
[    1.540405] ata1: softreset failed (device not ready)
[    1.545514] ata1: applying PMP SRST workaround and retrying
[    1.750408] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[    1.764169] ata1.00: ATA-8: WDC WD10TPVT-00U4RT1, 01.01A01, max UDMA/133
[    1.770981] ata1.00: 1953525168 sectors, multi 0: LBA48 NCQ (depth 31/32)
[    1.786154] ata1.00: configured for UDMA/133
[    1.791272] scsi 0:0:0:0: Direct-Access     ATA      WDC
WD10TPVT-00U 01.0 PQ: 0 ANSI: 5
[    1.800460] sd 0:0:0:0: [sda] 1953525168 512-byte logical blocks:
(1.00 TB/931 GiB)
[    1.808190] sd 0:0:0:0: [sda] 4096-byte physical blocks
[    1.815016] sd 0:0:0:0: [sda] Write Protect is off
[    1.819878] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
[    1.820201] sd 0:0:0:0: [sda] Write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[    1.856631]  sda: sda1 sda2 sda3 sda4
[    1.863666] sd 0:0:0:0: [sda] Attached SCSI disk
[    1.880189] EXT3-fs (sda2): error: couldn't mount because of
unsupported optional features (240)
[    1.890482] EXT2-fs (sda2): error: couldn't mount because of
unsupported optional features (240)
[    1.932146] EXT4-fs (sda2): warning: maximal mount count reached,
running e2fsck is recommended
[    1.959428] EXT4-fs (sda2): mounted filesystem with ordered data
mode. Opts: (null)
[    1.967300] VFS: Mounted root (ext4 filesystem) on device 8:2.
[    1.989215] devtmpfs: mounted
[    1.992660] Freeing init memory: 148K
[    3.913577] udev[67]: starting version 164
[    4.877589] mmcblk0: mmc0:1234 SA02G 1.83 GiB
[    5.040661]  mmcblk0: p1 p2 p3
[    6.847039] Adding 9767516k swap on /dev/sda3.  Priority:-1
extents:1 across:9767516k
[    6.987841] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro
[   13.647889] kjournald starting.  Commit interval 5 seconds
[   13.654619] EXT3-fs (dm-0): using internal journal
[   13.659490] EXT3-fs (dm-0): mounted filesystem with ordered data mode
[   15.143077] eth0: Freescale FEC PHY driver [Generic PHY]
(mii_bus:phy_addr=1:00, irq=-1)
[   17.140873] PHY: 1:00 - Link is Up - 100/Full
[   17.329274] kjournald starting.  Commit interval 5 seconds
[   17.335840] EXT3-fs (dm-3): using internal journal
[   17.340799] EXT3-fs (dm-3): mounted filesystem with ordered data mode
[   33.313977] sshd (855): /proc/855/oom_adj is deprecated, please use
/proc/855/oom_score_adj instead.
[ 3867.337774] kjournald starting.  Commit interval 5 seconds
[ 3867.344328] EXT3-fs (dm-7): using internal journal
[ 3867.349195] EXT3-fs (dm-7): mounted filesystem with ordered data mode
[ 3882.857122] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x1280501
action 0x6 frozen
[ 3882.864931] ata1.00: irq_stat 0x08000000, interface fatal error
[ 3882.870928] ata1: SError: { RecovData UnrecovData Proto 10B8B
BadCRC TrStaTrns }
[ 3882.878367] ata1.00: failed command: READ FPDMA QUEUED
[ 3882.883582] ata1.00: cmd 60/c8:00:d0:8a:c4/00:00:0f:00:00/40 tag 0
ncq 102400 in
[ 3882.883590]          res 40/00:04:d0:8a:c4/00:00:0f:00:00/40 Emask
0x12 (ATA bus error)
[ 3882.899063] ata1.00: status: { DRDY }
[ 3882.902802] ata1: hard resetting link
[ 3883.870400] ata1: softreset failed (device not ready)
[ 3883.875515] ata1: applying PMP SRST workaround and retrying
[ 3884.080465] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[ 3884.102097] ata1.00: configured for UDMA/133
[ 3884.106635] ata1: EH complete
[ 3934.010542] ata1.00: exception Emask 0x0 SAct 0xff SErr 0x0 action 0x6 frozen
[ 3934.017759] ata1.00: failed command: READ FPDMA QUEUED
[ 3934.023030] ata1.00: cmd 60/88:00:18:66:c7/00:00:0f:00:00/40 tag 0
ncq 69632 in
[ 3934.023037]          res 40/00:04:d0:8a:c4/00:00:0f:00:00/40 Emask
0x4 (timeout)
[ 3934.038014] ata1.00: status: { DRDY }
[ 3934.041769] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.047042] ata1.00: cmd 61/38:08:d8:2c:5a/00:00:12:00:00/40 tag 1
ncq 28672 out
[ 3934.047051]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.062081] ata1.00: status: { DRDY }
[ 3934.065782] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.071103] ata1.00: cmd 61/20:10:90:67:90/00:00:09:00:00/40 tag 2
ncq 16384 out
[ 3934.071113]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.085984] ata1.00: status: { DRDY }
[ 3934.089671] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.094963] ata1.00: cmd 61/08:18:40:a7:8e/00:00:09:00:00/40 tag 3
ncq 4096 out
[ 3934.094971]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.109735] ata1.00: status: { DRDY }
[ 3934.113450] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.118711] ata1.00: cmd 61/08:20:40:27:8f/00:00:09:00:00/40 tag 4
ncq 4096 out
[ 3934.118721]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.133489] ata1.00: status: { DRDY }
[ 3934.137172] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.142457] ata1.00: cmd 61/08:28:40:67:8f/00:00:09:00:00/40 tag 5
ncq 4096 out
[ 3934.142465]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.157251] ata1.00: status: { DRDY }
[ 3934.160972] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.166239] ata1.00: cmd 61/08:30:40:a7:8f/00:00:09:00:00/40 tag 6
ncq 4096 out
[ 3934.166245]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.181013] ata1.00: status: { DRDY }
[ 3934.184700] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.189959] ata1.00: cmd 61/60:38:4a:f3:e1/00:00:02:00:00/40 tag 7
ncq 49152 out
[ 3934.189966]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.204822] ata1.00: status: { DRDY }
[ 3934.208535] ata1: hard resetting link
[ 3935.180443] ata1: softreset failed (device not ready)
[ 3935.185548] ata1: applying PMP SRST workaround and retrying
[ 3935.390417] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[ 3935.412020] ata1.00: configured for UDMA/133
[ 3935.416479] ata1.00: device reported invalid CHS sector 0
[ 3935.421985] ata1.00: device reported invalid CHS sector 0
[ 3935.427424] ata1.00: device reported invalid CHS sector 0
[ 3935.432893] ata1.00: device reported invalid CHS sector 0
[ 3935.438326] ata1.00: device reported invalid CHS sector 0
[ 3935.443788] ata1.00: device reported invalid CHS sector 0
[ 3935.449221] ata1.00: device reported invalid CHS sector 0
[ 3935.454728] ata1: EH complete
[ 3950.155859] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x80500
action 0x6 frozen
[ 3950.163510] ata1.00: irq_stat 0x08000000, interface fatal error
[ 3950.169469] ata1: SError: { UnrecovData Proto 10B8B }
[ 3950.174597] ata1.00: failed command: READ FPDMA QUEUED
[ 3950.179788] ata1.00: cmd 60/00:00:28:97:71/01:00:0f:00:00/40 tag 0
ncq 131072 in
[ 3950.179796]          res 40/00:04:28:97:71/00:00:0f:00:00/40 Emask
0x12 (ATA bus error)
[ 3950.195275] ata1.00: status: { DRDY }
[ 3950.198992] ata1: hard resetting link
[ 3951.380403] ata1: softreset failed (device not ready)
[ 3951.385523] ata1: applying PMP SRST workaround and retrying
[ 3951.590410] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[ 3951.612472] ata1.00: configured for UDMA/133
[ 3951.617042] ata1: EH complete
[ 3952.305676] ata1: limiting SATA link speed to 1.5 Gbps
[ 3952.310994] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x1280500
action 0x6 frozen
[ 3952.318692] ata1.00: irq_stat 0x08000000, interface fatal error
[ 3952.324685] ata1: SError: { UnrecovData Proto 10B8B BadCRC TrStaTrns }
[ 3952.331283] ata1.00: failed command: READ FPDMA QUEUED
[ 3952.336469] ata1.00: cmd 60/00:00:28:9f:71/01:00:0f:00:00/40 tag 0
ncq 131072 in
[ 3952.336477]          res 40/00:04:28:9f:71/00:00:0f:00:00/40 Emask
0x12 (ATA bus error)
[ 3952.351953] ata1.00: status: { DRDY }
[ 3952.355667] ata1: hard resetting link
[ 3953.360414] ata1: softreset failed (device not ready)
[ 3953.365537] ata1: applying PMP SRST workaround and retrying
[ 3953.570412] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[ 3953.592363] ata1.00: configured for UDMA/133
[ 3953.596938] ata1: EH complete
[ 4479.040495] ata1.00: exception Emask 0x0 SAct 0x2 SErr 0x0 action 0x6 frozen
[ 4479.047622] ata1.00: failed command: WRITE FPDMA QUEUED
[ 4479.052947] ata1.00: cmd 61/10:08:4a:f9:e1/00:00:02:00:00/40 tag 1
ncq 8192 out
[ 4479.052955]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 4479.067740] ata1.00: status: { DRDY }
[ 4479.071480] ata1: hard resetting link
[ 4480.040403] ata1: softreset failed (device not ready)
[ 4480.045513] ata1: applying PMP SRST workaround and retrying
[ 4480.250423] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[ 4480.272519] ata1.00: configured for UDMA/133
[ 4480.276866] ata1.00: device reported invalid CHS sector 0
[ 4480.282410] ata1: EH complete
[52367.370517] ata1.00: exception Emask 0x10 SAct 0x1 SErr 0x280100
action 0x6 frozen
[52367.378167] ata1.00: irq_stat 0x08000000, interface fatal error
[52367.384188] ata1: SError: { UnrecovData 10B8B BadCRC }
[52367.389366] ata1.00: failed command: READ FPDMA QUEUED
[52367.394582] ata1.00: cmd 60/00:00:fa:c6:36/02:00:00:00:00/40 tag 0
ncq 262144 in
[52367.394592]          res 40/00:04:fa:c6:36/00:00:00:00:00/40 Emask
0x10 (ATA bus error)
[52367.410065] ata1.00: status: { DRDY }
[52367.413800] ata1: hard resetting link
[52368.380402] ata1: softreset failed (device not ready)
[52368.385506] ata1: applying PMP SRST workaround and retrying
[52368.590410] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[52368.612592] ata1.00: configured for UDMA/133
[52368.617347] ata1: EH complete



Best regards,
-- 
 Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-06  8:46           ` Hector Oron
  0 siblings, 0 replies; 54+ messages in thread
From: Hector Oron @ 2011-09-06  8:46 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

2011/9/1 Richard Zhu <richard.zhu@linaro.org>:
> Hi Hector:
> What's happen before "> [ ? ?7.073106] EXT4-fs (sda2): re-mounted.
> Opts: errors=remount-ro"?

Here is my complete dmesg. The system seems to work fine, it is a
1.0TB WD10TPVT SATA disk in a case which provides eSATA and connected
to mx53 LOCO with eSATA-to-SATA cable. I have around a Lacie eSATA
disk which I might attempt to connect.

Linux version 3.1.0-rc3-mx5 (zumbi at enorme) (gcc version 4.4.5 (Debian
4.4.5-8) ) #7 Tue Aug 30 13:17:14 BST 2011
CPU: ARMv7 Processor [412fc085] revision 5 (ARMv7), cr=10c53c7f
CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: Freescale MX53 LOCO Board
Ignoring RAM at b0000000-cfffffff (vmalloc region overlap).
Memory policy: ECC disabled, Data cache writeback
On node 0 totalpages: 131072
free_area_init_node: node 0, pgdat c0461e08, node_mem_map c04b2000
  Normal zone: 1024 pages used for memmap
  Normal zone: 0 pages reserved
  Normal zone: 130048 pages, LIFO batch:31
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttymxc0,115200 console=tty1
root=/dev/sda2 video=mxcdi1fb:GBR24,XGA di1_primary tve  printk.time=1
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 512MB = 512MB total
[    0.000000] Memory: 514948k/514948k available, 9340k reserved, 0K highmem
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
[    0.000000]     vmalloc : 0xe0800000 - 0xf4000000   ( 312 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc0412000   (4136 kB)
[    0.000000]       .init : 0xc0412000 - 0xc0437000   ( 148 kB)
[    0.000000]       .data : 0xc0438000 - 0xc0462480   ( 170 kB)
[    0.000000]        .bss : 0xc04624a4 - 0xc04b1380   ( 316 kB)
[    0.000000] SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0,
CPUs=1, Nodes=1
[    0.000000] NR_IRQS:400
[    0.000000] TrustZone Interrupt Controller (TZIC) initialized
[    0.000000] CPU identified as i.MX53, silicon rev 2.1
[    0.000000] sched_clock: 32 bits at 55MHz, resolution 18ns, wraps
every 77386ms
[    0.000000] Console: colour dummy device 80x30
[    0.000000] console [tty1] enabled
[    0.000556] Calibrating delay loop... 795.44 BogoMIPS (lpj=3977216)
[    0.040182] pid_max: default: 32768 minimum: 301
[    0.040450] Mount-cache hash table entries: 512
[    0.041059] CPU: Testing write buffer coherency: ok
[    0.042459] devtmpfs: initialized
[    0.044791] print_constraints: dummy:
[    0.045120] NET: Registered protocol family 16
[    0.065856] bio: create slab <bio-0> at 0
[    0.067168] SCSI subsystem initialized
[    0.067580] libata version 3.00 loaded.
[    0.067989] usbcore: registered new interface driver usbfs
[    0.068174] usbcore: registered new interface driver hub
[    0.068488] usbcore: registered new device driver usb
[    0.070182] Switching to clocksource mxc_timer1
[    0.080403] Switched to NOHz mode on CPU #0
[    0.088737] NET: Registered protocol family 2
[    0.089034] IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.089503] TCP established hash table entries: 16384 (order: 5,
131072 bytes)
[    0.089861] TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
[    0.090067] TCP: Hash tables configured (established 16384 bind 16384)
[    0.090096] TCP reno registered
[    0.090128] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.090168] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.090626] NET: Registered protocol family 1
[    0.091318] RPC: Registered named UNIX socket transport module.
[    0.091381] RPC: Registered udp transport module.
[    0.091407] RPC: Registered tcp transport module.
[    0.091429] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.115113] VFS: Disk quotas dquot_6.5.2
[    0.115483] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.120839] fuse init (API version 7.16)
[    0.121919] msgmni has been set to 1005
[    0.122544] Block layer SCSI generic (bsg) driver version 0.4
loaded (major 253)
[    0.122618] io scheduler noop registered
[    0.122646] io scheduler deadline registered
[    0.122920] io scheduler cfq registered (default)
[    0.123527] Serial: IMX driver
[    0.123787] imx21-uart.0: ttymxc0 at MMIO 0x53fbc000 (irq = 31) is a IMX
[    0.489212] console [ttymxc0] enabled
[    0.502624] brd: module loaded
[    0.511401] loop: module loaded
[    0.515060] nbd: registered device at major 43
[    0.532271] ahci: SSS flag set, parallel bus scan disabled
[    0.537878] ahci imx53-ahci.0: AHCI 0001.0100 32 slots 1 ports 3
Gbps 0x1 impl platform mode
[    0.546452] ahci imx53-ahci.0: flags: ncq sntf stag pm led clo only
pmp pio slum part ccc
[    0.556008] scsi0 : ahci_platform
[    0.560052] ata1: SATA max UDMA/133 mmio [mem
0x10000000-0x10000fff] port 0x100 irq 28
[    0.568788] FEC Ethernet Driver
[    0.575892] fec_enet_mii_bus: probed
[    0.580170] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.587109] Initializing USB Mass Storage driver...
[    0.592309] usbcore: registered new interface driver usb-storage
[    0.598353] USB Mass Storage support registered.
[    0.603499] mousedev: PS/2 mouse device common for all mice
[    0.609483] i2c /dev entries driver
[    0.614322] imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled.
timeout=60s (nowayout=0)
[    0.623615] device-mapper: uevent: version 1.0.3
[    0.629223] device-mapper: ioctl: 4.21.0-ioctl (2011-07-06)
initialised: dm-devel at redhat.com
[    0.637827] sdhci: Secure Digital Host Controller Interface driver
[    0.644080] sdhci: Copyright(c) Pierre Ossman
[    0.648461] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.654585] mmc0: no vmmc regulator found
[    0.658808] Registered led device: mmc0::
[    0.659016] mmc0: SDHCI controller on sdhci-esdhc-imx53.0
[sdhci-esdhc-imx53.0] using DMA
[    0.667691] mmc1: no vmmc regulator found
[    0.672020] Registered led device: mmc1::
[    0.672265] mmc1: SDHCI controller on sdhci-esdhc-imx53.2
[sdhci-esdhc-imx53.2] using DMA
[    0.681037] usbcore: registered new interface driver usbhid
[    0.686655] usbhid: USB HID core driver
[    0.790254] TCP cubic registered
[    0.793596] NET: Registered protocol family 17
[    0.798190] Registering the dns_resolver key type
[    0.803078] VFP support v0.3: implementor 41 architecture 3 part 30
variant c rev 2
[    0.813279] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    0.820805] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    0.863099] mmc0: host does not support reading read-only switch.
assuming write-enable.
[    0.970967] mmc0: new SD card at address 1234
[    1.540405] ata1: softreset failed (device not ready)
[    1.545514] ata1: applying PMP SRST workaround and retrying
[    1.750408] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[    1.764169] ata1.00: ATA-8: WDC WD10TPVT-00U4RT1, 01.01A01, max UDMA/133
[    1.770981] ata1.00: 1953525168 sectors, multi 0: LBA48 NCQ (depth 31/32)
[    1.786154] ata1.00: configured for UDMA/133
[    1.791272] scsi 0:0:0:0: Direct-Access     ATA      WDC
WD10TPVT-00U 01.0 PQ: 0 ANSI: 5
[    1.800460] sd 0:0:0:0: [sda] 1953525168 512-byte logical blocks:
(1.00 TB/931 GiB)
[    1.808190] sd 0:0:0:0: [sda] 4096-byte physical blocks
[    1.815016] sd 0:0:0:0: [sda] Write Protect is off
[    1.819878] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
[    1.820201] sd 0:0:0:0: [sda] Write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[    1.856631]  sda: sda1 sda2 sda3 sda4
[    1.863666] sd 0:0:0:0: [sda] Attached SCSI disk
[    1.880189] EXT3-fs (sda2): error: couldn't mount because of
unsupported optional features (240)
[    1.890482] EXT2-fs (sda2): error: couldn't mount because of
unsupported optional features (240)
[    1.932146] EXT4-fs (sda2): warning: maximal mount count reached,
running e2fsck is recommended
[    1.959428] EXT4-fs (sda2): mounted filesystem with ordered data
mode. Opts: (null)
[    1.967300] VFS: Mounted root (ext4 filesystem) on device 8:2.
[    1.989215] devtmpfs: mounted
[    1.992660] Freeing init memory: 148K
[    3.913577] udev[67]: starting version 164
[    4.877589] mmcblk0: mmc0:1234 SA02G 1.83 GiB
[    5.040661]  mmcblk0: p1 p2 p3
[    6.847039] Adding 9767516k swap on /dev/sda3.  Priority:-1
extents:1 across:9767516k
[    6.987841] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro
[   13.647889] kjournald starting.  Commit interval 5 seconds
[   13.654619] EXT3-fs (dm-0): using internal journal
[   13.659490] EXT3-fs (dm-0): mounted filesystem with ordered data mode
[   15.143077] eth0: Freescale FEC PHY driver [Generic PHY]
(mii_bus:phy_addr=1:00, irq=-1)
[   17.140873] PHY: 1:00 - Link is Up - 100/Full
[   17.329274] kjournald starting.  Commit interval 5 seconds
[   17.335840] EXT3-fs (dm-3): using internal journal
[   17.340799] EXT3-fs (dm-3): mounted filesystem with ordered data mode
[   33.313977] sshd (855): /proc/855/oom_adj is deprecated, please use
/proc/855/oom_score_adj instead.
[ 3867.337774] kjournald starting.  Commit interval 5 seconds
[ 3867.344328] EXT3-fs (dm-7): using internal journal
[ 3867.349195] EXT3-fs (dm-7): mounted filesystem with ordered data mode
[ 3882.857122] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x1280501
action 0x6 frozen
[ 3882.864931] ata1.00: irq_stat 0x08000000, interface fatal error
[ 3882.870928] ata1: SError: { RecovData UnrecovData Proto 10B8B
BadCRC TrStaTrns }
[ 3882.878367] ata1.00: failed command: READ FPDMA QUEUED
[ 3882.883582] ata1.00: cmd 60/c8:00:d0:8a:c4/00:00:0f:00:00/40 tag 0
ncq 102400 in
[ 3882.883590]          res 40/00:04:d0:8a:c4/00:00:0f:00:00/40 Emask
0x12 (ATA bus error)
[ 3882.899063] ata1.00: status: { DRDY }
[ 3882.902802] ata1: hard resetting link
[ 3883.870400] ata1: softreset failed (device not ready)
[ 3883.875515] ata1: applying PMP SRST workaround and retrying
[ 3884.080465] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[ 3884.102097] ata1.00: configured for UDMA/133
[ 3884.106635] ata1: EH complete
[ 3934.010542] ata1.00: exception Emask 0x0 SAct 0xff SErr 0x0 action 0x6 frozen
[ 3934.017759] ata1.00: failed command: READ FPDMA QUEUED
[ 3934.023030] ata1.00: cmd 60/88:00:18:66:c7/00:00:0f:00:00/40 tag 0
ncq 69632 in
[ 3934.023037]          res 40/00:04:d0:8a:c4/00:00:0f:00:00/40 Emask
0x4 (timeout)
[ 3934.038014] ata1.00: status: { DRDY }
[ 3934.041769] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.047042] ata1.00: cmd 61/38:08:d8:2c:5a/00:00:12:00:00/40 tag 1
ncq 28672 out
[ 3934.047051]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.062081] ata1.00: status: { DRDY }
[ 3934.065782] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.071103] ata1.00: cmd 61/20:10:90:67:90/00:00:09:00:00/40 tag 2
ncq 16384 out
[ 3934.071113]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.085984] ata1.00: status: { DRDY }
[ 3934.089671] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.094963] ata1.00: cmd 61/08:18:40:a7:8e/00:00:09:00:00/40 tag 3
ncq 4096 out
[ 3934.094971]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.109735] ata1.00: status: { DRDY }
[ 3934.113450] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.118711] ata1.00: cmd 61/08:20:40:27:8f/00:00:09:00:00/40 tag 4
ncq 4096 out
[ 3934.118721]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.133489] ata1.00: status: { DRDY }
[ 3934.137172] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.142457] ata1.00: cmd 61/08:28:40:67:8f/00:00:09:00:00/40 tag 5
ncq 4096 out
[ 3934.142465]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.157251] ata1.00: status: { DRDY }
[ 3934.160972] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.166239] ata1.00: cmd 61/08:30:40:a7:8f/00:00:09:00:00/40 tag 6
ncq 4096 out
[ 3934.166245]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.181013] ata1.00: status: { DRDY }
[ 3934.184700] ata1.00: failed command: WRITE FPDMA QUEUED
[ 3934.189959] ata1.00: cmd 61/60:38:4a:f3:e1/00:00:02:00:00/40 tag 7
ncq 49152 out
[ 3934.189966]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 3934.204822] ata1.00: status: { DRDY }
[ 3934.208535] ata1: hard resetting link
[ 3935.180443] ata1: softreset failed (device not ready)
[ 3935.185548] ata1: applying PMP SRST workaround and retrying
[ 3935.390417] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[ 3935.412020] ata1.00: configured for UDMA/133
[ 3935.416479] ata1.00: device reported invalid CHS sector 0
[ 3935.421985] ata1.00: device reported invalid CHS sector 0
[ 3935.427424] ata1.00: device reported invalid CHS sector 0
[ 3935.432893] ata1.00: device reported invalid CHS sector 0
[ 3935.438326] ata1.00: device reported invalid CHS sector 0
[ 3935.443788] ata1.00: device reported invalid CHS sector 0
[ 3935.449221] ata1.00: device reported invalid CHS sector 0
[ 3935.454728] ata1: EH complete
[ 3950.155859] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x80500
action 0x6 frozen
[ 3950.163510] ata1.00: irq_stat 0x08000000, interface fatal error
[ 3950.169469] ata1: SError: { UnrecovData Proto 10B8B }
[ 3950.174597] ata1.00: failed command: READ FPDMA QUEUED
[ 3950.179788] ata1.00: cmd 60/00:00:28:97:71/01:00:0f:00:00/40 tag 0
ncq 131072 in
[ 3950.179796]          res 40/00:04:28:97:71/00:00:0f:00:00/40 Emask
0x12 (ATA bus error)
[ 3950.195275] ata1.00: status: { DRDY }
[ 3950.198992] ata1: hard resetting link
[ 3951.380403] ata1: softreset failed (device not ready)
[ 3951.385523] ata1: applying PMP SRST workaround and retrying
[ 3951.590410] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[ 3951.612472] ata1.00: configured for UDMA/133
[ 3951.617042] ata1: EH complete
[ 3952.305676] ata1: limiting SATA link speed to 1.5 Gbps
[ 3952.310994] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x1280500
action 0x6 frozen
[ 3952.318692] ata1.00: irq_stat 0x08000000, interface fatal error
[ 3952.324685] ata1: SError: { UnrecovData Proto 10B8B BadCRC TrStaTrns }
[ 3952.331283] ata1.00: failed command: READ FPDMA QUEUED
[ 3952.336469] ata1.00: cmd 60/00:00:28:9f:71/01:00:0f:00:00/40 tag 0
ncq 131072 in
[ 3952.336477]          res 40/00:04:28:9f:71/00:00:0f:00:00/40 Emask
0x12 (ATA bus error)
[ 3952.351953] ata1.00: status: { DRDY }
[ 3952.355667] ata1: hard resetting link
[ 3953.360414] ata1: softreset failed (device not ready)
[ 3953.365537] ata1: applying PMP SRST workaround and retrying
[ 3953.570412] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[ 3953.592363] ata1.00: configured for UDMA/133
[ 3953.596938] ata1: EH complete
[ 4479.040495] ata1.00: exception Emask 0x0 SAct 0x2 SErr 0x0 action 0x6 frozen
[ 4479.047622] ata1.00: failed command: WRITE FPDMA QUEUED
[ 4479.052947] ata1.00: cmd 61/10:08:4a:f9:e1/00:00:02:00:00/40 tag 1
ncq 8192 out
[ 4479.052955]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
0x4 (timeout)
[ 4479.067740] ata1.00: status: { DRDY }
[ 4479.071480] ata1: hard resetting link
[ 4480.040403] ata1: softreset failed (device not ready)
[ 4480.045513] ata1: applying PMP SRST workaround and retrying
[ 4480.250423] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[ 4480.272519] ata1.00: configured for UDMA/133
[ 4480.276866] ata1.00: device reported invalid CHS sector 0
[ 4480.282410] ata1: EH complete
[52367.370517] ata1.00: exception Emask 0x10 SAct 0x1 SErr 0x280100
action 0x6 frozen
[52367.378167] ata1.00: irq_stat 0x08000000, interface fatal error
[52367.384188] ata1: SError: { UnrecovData 10B8B BadCRC }
[52367.389366] ata1.00: failed command: READ FPDMA QUEUED
[52367.394582] ata1.00: cmd 60/00:00:fa:c6:36/02:00:00:00:00/40 tag 0
ncq 262144 in
[52367.394592]          res 40/00:04:fa:c6:36/00:00:00:00:00/40 Emask
0x10 (ATA bus error)
[52367.410065] ata1.00: status: { DRDY }
[52367.413800] ata1: hard resetting link
[52368.380402] ata1: softreset failed (device not ready)
[52368.385506] ata1: applying PMP SRST workaround and retrying
[52368.590410] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[52368.612592] ata1.00: configured for UDMA/133
[52368.617347] ata1: EH complete



Best regards,
-- 
?H?ctor Or?n ?-.. . -... .. .- -. ? -.. . ...- . .-.. --- .--. . .-.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-06  8:46           ` Hector Oron
@ 2011-09-06 13:25             ` Eric Miao
  -1 siblings, 0 replies; 54+ messages in thread
From: Eric Miao @ 2011-09-06 13:25 UTC (permalink / raw)
  To: Hector Oron
  Cc: Richard Zhu, eric, Wolfram Sang, linux-ide, kernel, avorontsov,
	jgarzik, linux-arm-kernel

On Tue, Sep 6, 2011 at 1:46 AM, Hector Oron <hector.oron@gmail.com> wrote:
> Hi,
>
> 2011/9/1 Richard Zhu <richard.zhu@linaro.org>:
>> Hi Hector:
>> What's happen before "> [    7.073106] EXT4-fs (sda2): re-mounted.
>> Opts: errors=remount-ro"?
>
> Here is my complete dmesg. The system seems to work fine, it is a
> 1.0TB WD10TPVT SATA disk in a case which provides eSATA and connected
> to mx53 LOCO with eSATA-to-SATA cable.

Is it possible that it's caused by this converter? Do you have a separate
SATA power supply that could help test the disk directly connected to
mx53loco?

> I have around a Lacie eSATA
> disk which I might attempt to connect.
>
> Linux version 3.1.0-rc3-mx5 (zumbi@enorme) (gcc version 4.4.5 (Debian
> 4.4.5-8) ) #7 Tue Aug 30 13:17:14 BST 2011
> CPU: ARMv7 Processor [412fc085] revision 5 (ARMv7), cr=10c53c7f
> CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
> Machine: Freescale MX53 LOCO Board
> Ignoring RAM at b0000000-cfffffff (vmalloc region overlap).
> Memory policy: ECC disabled, Data cache writeback
> On node 0 totalpages: 131072
> free_area_init_node: node 0, pgdat c0461e08, node_mem_map c04b2000
>  Normal zone: 1024 pages used for memmap
>  Normal zone: 0 pages reserved
>  Normal zone: 130048 pages, LIFO batch:31
> pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
> pcpu-alloc: [0] 0
> Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
> Kernel command line: console=ttymxc0,115200 console=tty1
> root=/dev/sda2 video=mxcdi1fb:GBR24,XGA di1_primary tve  printk.time=1
> [    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
> [    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
> [    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
> [    0.000000] Memory: 512MB = 512MB total
> [    0.000000] Memory: 514948k/514948k available, 9340k reserved, 0K highmem
> [    0.000000] Virtual kernel memory layout:
> [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
> [    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
> [    0.000000]     DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
> [    0.000000]     vmalloc : 0xe0800000 - 0xf4000000   ( 312 MB)
> [    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
> [    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
> [    0.000000]       .text : 0xc0008000 - 0xc0412000   (4136 kB)
> [    0.000000]       .init : 0xc0412000 - 0xc0437000   ( 148 kB)
> [    0.000000]       .data : 0xc0438000 - 0xc0462480   ( 170 kB)
> [    0.000000]        .bss : 0xc04624a4 - 0xc04b1380   ( 316 kB)
> [    0.000000] SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0,
> CPUs=1, Nodes=1
> [    0.000000] NR_IRQS:400
> [    0.000000] TrustZone Interrupt Controller (TZIC) initialized
> [    0.000000] CPU identified as i.MX53, silicon rev 2.1
> [    0.000000] sched_clock: 32 bits at 55MHz, resolution 18ns, wraps
> every 77386ms
> [    0.000000] Console: colour dummy device 80x30
> [    0.000000] console [tty1] enabled
> [    0.000556] Calibrating delay loop... 795.44 BogoMIPS (lpj=3977216)
> [    0.040182] pid_max: default: 32768 minimum: 301
> [    0.040450] Mount-cache hash table entries: 512
> [    0.041059] CPU: Testing write buffer coherency: ok
> [    0.042459] devtmpfs: initialized
> [    0.044791] print_constraints: dummy:
> [    0.045120] NET: Registered protocol family 16
> [    0.065856] bio: create slab <bio-0> at 0
> [    0.067168] SCSI subsystem initialized
> [    0.067580] libata version 3.00 loaded.
> [    0.067989] usbcore: registered new interface driver usbfs
> [    0.068174] usbcore: registered new interface driver hub
> [    0.068488] usbcore: registered new device driver usb
> [    0.070182] Switching to clocksource mxc_timer1
> [    0.080403] Switched to NOHz mode on CPU #0
> [    0.088737] NET: Registered protocol family 2
> [    0.089034] IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
> [    0.089503] TCP established hash table entries: 16384 (order: 5,
> 131072 bytes)
> [    0.089861] TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
> [    0.090067] TCP: Hash tables configured (established 16384 bind 16384)
> [    0.090096] TCP reno registered
> [    0.090128] UDP hash table entries: 256 (order: 0, 4096 bytes)
> [    0.090168] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
> [    0.090626] NET: Registered protocol family 1
> [    0.091318] RPC: Registered named UNIX socket transport module.
> [    0.091381] RPC: Registered udp transport module.
> [    0.091407] RPC: Registered tcp transport module.
> [    0.091429] RPC: Registered tcp NFSv4.1 backchannel transport module.
> [    0.115113] VFS: Disk quotas dquot_6.5.2
> [    0.115483] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
> [    0.120839] fuse init (API version 7.16)
> [    0.121919] msgmni has been set to 1005
> [    0.122544] Block layer SCSI generic (bsg) driver version 0.4
> loaded (major 253)
> [    0.122618] io scheduler noop registered
> [    0.122646] io scheduler deadline registered
> [    0.122920] io scheduler cfq registered (default)
> [    0.123527] Serial: IMX driver
> [    0.123787] imx21-uart.0: ttymxc0 at MMIO 0x53fbc000 (irq = 31) is a IMX
> [    0.489212] console [ttymxc0] enabled
> [    0.502624] brd: module loaded
> [    0.511401] loop: module loaded
> [    0.515060] nbd: registered device at major 43
> [    0.532271] ahci: SSS flag set, parallel bus scan disabled
> [    0.537878] ahci imx53-ahci.0: AHCI 0001.0100 32 slots 1 ports 3
> Gbps 0x1 impl platform mode
> [    0.546452] ahci imx53-ahci.0: flags: ncq sntf stag pm led clo only
> pmp pio slum part ccc
> [    0.556008] scsi0 : ahci_platform
> [    0.560052] ata1: SATA max UDMA/133 mmio [mem
> 0x10000000-0x10000fff] port 0x100 irq 28
> [    0.568788] FEC Ethernet Driver
> [    0.575892] fec_enet_mii_bus: probed
> [    0.580170] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
> [    0.587109] Initializing USB Mass Storage driver...
> [    0.592309] usbcore: registered new interface driver usb-storage
> [    0.598353] USB Mass Storage support registered.
> [    0.603499] mousedev: PS/2 mouse device common for all mice
> [    0.609483] i2c /dev entries driver
> [    0.614322] imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled.
> timeout=60s (nowayout=0)
> [    0.623615] device-mapper: uevent: version 1.0.3
> [    0.629223] device-mapper: ioctl: 4.21.0-ioctl (2011-07-06)
> initialised: dm-devel@redhat.com
> [    0.637827] sdhci: Secure Digital Host Controller Interface driver
> [    0.644080] sdhci: Copyright(c) Pierre Ossman
> [    0.648461] sdhci-pltfm: SDHCI platform and OF driver helper
> [    0.654585] mmc0: no vmmc regulator found
> [    0.658808] Registered led device: mmc0::
> [    0.659016] mmc0: SDHCI controller on sdhci-esdhc-imx53.0
> [sdhci-esdhc-imx53.0] using DMA
> [    0.667691] mmc1: no vmmc regulator found
> [    0.672020] Registered led device: mmc1::
> [    0.672265] mmc1: SDHCI controller on sdhci-esdhc-imx53.2
> [sdhci-esdhc-imx53.2] using DMA
> [    0.681037] usbcore: registered new interface driver usbhid
> [    0.686655] usbhid: USB HID core driver
> [    0.790254] TCP cubic registered
> [    0.793596] NET: Registered protocol family 17
> [    0.798190] Registering the dns_resolver key type
> [    0.803078] VFP support v0.3: implementor 41 architecture 3 part 30
> variant c rev 2
> [    0.813279] input: gpio-keys as /devices/platform/gpio-keys/input/input0
> [    0.820805] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
> [    0.863099] mmc0: host does not support reading read-only switch.
> assuming write-enable.
> [    0.970967] mmc0: new SD card at address 1234
> [    1.540405] ata1: softreset failed (device not ready)
> [    1.545514] ata1: applying PMP SRST workaround and retrying
> [    1.750408] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [    1.764169] ata1.00: ATA-8: WDC WD10TPVT-00U4RT1, 01.01A01, max UDMA/133
> [    1.770981] ata1.00: 1953525168 sectors, multi 0: LBA48 NCQ (depth 31/32)
> [    1.786154] ata1.00: configured for UDMA/133
> [    1.791272] scsi 0:0:0:0: Direct-Access     ATA      WDC
> WD10TPVT-00U 01.0 PQ: 0 ANSI: 5
> [    1.800460] sd 0:0:0:0: [sda] 1953525168 512-byte logical blocks:
> (1.00 TB/931 GiB)
> [    1.808190] sd 0:0:0:0: [sda] 4096-byte physical blocks
> [    1.815016] sd 0:0:0:0: [sda] Write Protect is off
> [    1.819878] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
> [    1.820201] sd 0:0:0:0: [sda] Write cache: enabled, read cache:
> enabled, doesn't support DPO or FUA
> [    1.856631]  sda: sda1 sda2 sda3 sda4
> [    1.863666] sd 0:0:0:0: [sda] Attached SCSI disk
> [    1.880189] EXT3-fs (sda2): error: couldn't mount because of
> unsupported optional features (240)
> [    1.890482] EXT2-fs (sda2): error: couldn't mount because of
> unsupported optional features (240)
> [    1.932146] EXT4-fs (sda2): warning: maximal mount count reached,
> running e2fsck is recommended
> [    1.959428] EXT4-fs (sda2): mounted filesystem with ordered data
> mode. Opts: (null)
> [    1.967300] VFS: Mounted root (ext4 filesystem) on device 8:2.
> [    1.989215] devtmpfs: mounted
> [    1.992660] Freeing init memory: 148K
> [    3.913577] udev[67]: starting version 164
> [    4.877589] mmcblk0: mmc0:1234 SA02G 1.83 GiB
> [    5.040661]  mmcblk0: p1 p2 p3
> [    6.847039] Adding 9767516k swap on /dev/sda3.  Priority:-1
> extents:1 across:9767516k
> [    6.987841] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro
> [   13.647889] kjournald starting.  Commit interval 5 seconds
> [   13.654619] EXT3-fs (dm-0): using internal journal
> [   13.659490] EXT3-fs (dm-0): mounted filesystem with ordered data mode
> [   15.143077] eth0: Freescale FEC PHY driver [Generic PHY]
> (mii_bus:phy_addr=1:00, irq=-1)
> [   17.140873] PHY: 1:00 - Link is Up - 100/Full
> [   17.329274] kjournald starting.  Commit interval 5 seconds
> [   17.335840] EXT3-fs (dm-3): using internal journal
> [   17.340799] EXT3-fs (dm-3): mounted filesystem with ordered data mode
> [   33.313977] sshd (855): /proc/855/oom_adj is deprecated, please use
> /proc/855/oom_score_adj instead.
> [ 3867.337774] kjournald starting.  Commit interval 5 seconds
> [ 3867.344328] EXT3-fs (dm-7): using internal journal
> [ 3867.349195] EXT3-fs (dm-7): mounted filesystem with ordered data mode
> [ 3882.857122] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x1280501
> action 0x6 frozen
> [ 3882.864931] ata1.00: irq_stat 0x08000000, interface fatal error
> [ 3882.870928] ata1: SError: { RecovData UnrecovData Proto 10B8B
> BadCRC TrStaTrns }
> [ 3882.878367] ata1.00: failed command: READ FPDMA QUEUED
> [ 3882.883582] ata1.00: cmd 60/c8:00:d0:8a:c4/00:00:0f:00:00/40 tag 0
> ncq 102400 in
> [ 3882.883590]          res 40/00:04:d0:8a:c4/00:00:0f:00:00/40 Emask
> 0x12 (ATA bus error)
> [ 3882.899063] ata1.00: status: { DRDY }
> [ 3882.902802] ata1: hard resetting link
> [ 3883.870400] ata1: softreset failed (device not ready)
> [ 3883.875515] ata1: applying PMP SRST workaround and retrying
> [ 3884.080465] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [ 3884.102097] ata1.00: configured for UDMA/133
> [ 3884.106635] ata1: EH complete
> [ 3934.010542] ata1.00: exception Emask 0x0 SAct 0xff SErr 0x0 action 0x6 frozen
> [ 3934.017759] ata1.00: failed command: READ FPDMA QUEUED
> [ 3934.023030] ata1.00: cmd 60/88:00:18:66:c7/00:00:0f:00:00/40 tag 0
> ncq 69632 in
> [ 3934.023037]          res 40/00:04:d0:8a:c4/00:00:0f:00:00/40 Emask
> 0x4 (timeout)
> [ 3934.038014] ata1.00: status: { DRDY }
> [ 3934.041769] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.047042] ata1.00: cmd 61/38:08:d8:2c:5a/00:00:12:00:00/40 tag 1
> ncq 28672 out
> [ 3934.047051]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.062081] ata1.00: status: { DRDY }
> [ 3934.065782] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.071103] ata1.00: cmd 61/20:10:90:67:90/00:00:09:00:00/40 tag 2
> ncq 16384 out
> [ 3934.071113]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.085984] ata1.00: status: { DRDY }
> [ 3934.089671] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.094963] ata1.00: cmd 61/08:18:40:a7:8e/00:00:09:00:00/40 tag 3
> ncq 4096 out
> [ 3934.094971]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.109735] ata1.00: status: { DRDY }
> [ 3934.113450] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.118711] ata1.00: cmd 61/08:20:40:27:8f/00:00:09:00:00/40 tag 4
> ncq 4096 out
> [ 3934.118721]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.133489] ata1.00: status: { DRDY }
> [ 3934.137172] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.142457] ata1.00: cmd 61/08:28:40:67:8f/00:00:09:00:00/40 tag 5
> ncq 4096 out
> [ 3934.142465]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.157251] ata1.00: status: { DRDY }
> [ 3934.160972] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.166239] ata1.00: cmd 61/08:30:40:a7:8f/00:00:09:00:00/40 tag 6
> ncq 4096 out
> [ 3934.166245]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.181013] ata1.00: status: { DRDY }
> [ 3934.184700] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.189959] ata1.00: cmd 61/60:38:4a:f3:e1/00:00:02:00:00/40 tag 7
> ncq 49152 out
> [ 3934.189966]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.204822] ata1.00: status: { DRDY }
> [ 3934.208535] ata1: hard resetting link
> [ 3935.180443] ata1: softreset failed (device not ready)
> [ 3935.185548] ata1: applying PMP SRST workaround and retrying
> [ 3935.390417] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [ 3935.412020] ata1.00: configured for UDMA/133
> [ 3935.416479] ata1.00: device reported invalid CHS sector 0
> [ 3935.421985] ata1.00: device reported invalid CHS sector 0
> [ 3935.427424] ata1.00: device reported invalid CHS sector 0
> [ 3935.432893] ata1.00: device reported invalid CHS sector 0
> [ 3935.438326] ata1.00: device reported invalid CHS sector 0
> [ 3935.443788] ata1.00: device reported invalid CHS sector 0
> [ 3935.449221] ata1.00: device reported invalid CHS sector 0
> [ 3935.454728] ata1: EH complete
> [ 3950.155859] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x80500
> action 0x6 frozen
> [ 3950.163510] ata1.00: irq_stat 0x08000000, interface fatal error
> [ 3950.169469] ata1: SError: { UnrecovData Proto 10B8B }
> [ 3950.174597] ata1.00: failed command: READ FPDMA QUEUED
> [ 3950.179788] ata1.00: cmd 60/00:00:28:97:71/01:00:0f:00:00/40 tag 0
> ncq 131072 in
> [ 3950.179796]          res 40/00:04:28:97:71/00:00:0f:00:00/40 Emask
> 0x12 (ATA bus error)
> [ 3950.195275] ata1.00: status: { DRDY }
> [ 3950.198992] ata1: hard resetting link
> [ 3951.380403] ata1: softreset failed (device not ready)
> [ 3951.385523] ata1: applying PMP SRST workaround and retrying
> [ 3951.590410] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [ 3951.612472] ata1.00: configured for UDMA/133
> [ 3951.617042] ata1: EH complete
> [ 3952.305676] ata1: limiting SATA link speed to 1.5 Gbps
> [ 3952.310994] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x1280500
> action 0x6 frozen
> [ 3952.318692] ata1.00: irq_stat 0x08000000, interface fatal error
> [ 3952.324685] ata1: SError: { UnrecovData Proto 10B8B BadCRC TrStaTrns }
> [ 3952.331283] ata1.00: failed command: READ FPDMA QUEUED
> [ 3952.336469] ata1.00: cmd 60/00:00:28:9f:71/01:00:0f:00:00/40 tag 0
> ncq 131072 in
> [ 3952.336477]          res 40/00:04:28:9f:71/00:00:0f:00:00/40 Emask
> 0x12 (ATA bus error)
> [ 3952.351953] ata1.00: status: { DRDY }
> [ 3952.355667] ata1: hard resetting link
> [ 3953.360414] ata1: softreset failed (device not ready)
> [ 3953.365537] ata1: applying PMP SRST workaround and retrying
> [ 3953.570412] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
> [ 3953.592363] ata1.00: configured for UDMA/133
> [ 3953.596938] ata1: EH complete
> [ 4479.040495] ata1.00: exception Emask 0x0 SAct 0x2 SErr 0x0 action 0x6 frozen
> [ 4479.047622] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 4479.052947] ata1.00: cmd 61/10:08:4a:f9:e1/00:00:02:00:00/40 tag 1
> ncq 8192 out
> [ 4479.052955]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 4479.067740] ata1.00: status: { DRDY }
> [ 4479.071480] ata1: hard resetting link
> [ 4480.040403] ata1: softreset failed (device not ready)
> [ 4480.045513] ata1: applying PMP SRST workaround and retrying
> [ 4480.250423] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
> [ 4480.272519] ata1.00: configured for UDMA/133
> [ 4480.276866] ata1.00: device reported invalid CHS sector 0
> [ 4480.282410] ata1: EH complete
> [52367.370517] ata1.00: exception Emask 0x10 SAct 0x1 SErr 0x280100
> action 0x6 frozen
> [52367.378167] ata1.00: irq_stat 0x08000000, interface fatal error
> [52367.384188] ata1: SError: { UnrecovData 10B8B BadCRC }
> [52367.389366] ata1.00: failed command: READ FPDMA QUEUED
> [52367.394582] ata1.00: cmd 60/00:00:fa:c6:36/02:00:00:00:00/40 tag 0
> ncq 262144 in
> [52367.394592]          res 40/00:04:fa:c6:36/00:00:00:00:00/40 Emask
> 0x10 (ATA bus error)
> [52367.410065] ata1.00: status: { DRDY }
> [52367.413800] ata1: hard resetting link
> [52368.380402] ata1: softreset failed (device not ready)
> [52368.385506] ata1: applying PMP SRST workaround and retrying
> [52368.590410] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
> [52368.612592] ata1.00: configured for UDMA/133
> [52368.617347] ata1: EH complete
>
>
>
> Best regards,
> --
>  Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-06 13:25             ` Eric Miao
  0 siblings, 0 replies; 54+ messages in thread
From: Eric Miao @ 2011-09-06 13:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 6, 2011 at 1:46 AM, Hector Oron <hector.oron@gmail.com> wrote:
> Hi,
>
> 2011/9/1 Richard Zhu <richard.zhu@linaro.org>:
>> Hi Hector:
>> What's happen before "> [ ? ?7.073106] EXT4-fs (sda2): re-mounted.
>> Opts: errors=remount-ro"?
>
> Here is my complete dmesg. The system seems to work fine, it is a
> 1.0TB WD10TPVT SATA disk in a case which provides eSATA and connected
> to mx53 LOCO with eSATA-to-SATA cable.

Is it possible that it's caused by this converter? Do you have a separate
SATA power supply that could help test the disk directly connected to
mx53loco?

> I have around a Lacie eSATA
> disk which I might attempt to connect.
>
> Linux version 3.1.0-rc3-mx5 (zumbi at enorme) (gcc version 4.4.5 (Debian
> 4.4.5-8) ) #7 Tue Aug 30 13:17:14 BST 2011
> CPU: ARMv7 Processor [412fc085] revision 5 (ARMv7), cr=10c53c7f
> CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
> Machine: Freescale MX53 LOCO Board
> Ignoring RAM at b0000000-cfffffff (vmalloc region overlap).
> Memory policy: ECC disabled, Data cache writeback
> On node 0 totalpages: 131072
> free_area_init_node: node 0, pgdat c0461e08, node_mem_map c04b2000
> ?Normal zone: 1024 pages used for memmap
> ?Normal zone: 0 pages reserved
> ?Normal zone: 130048 pages, LIFO batch:31
> pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
> pcpu-alloc: [0] 0
> Built 1 zonelists in Zone order, mobility grouping on. ?Total pages: 130048
> Kernel command line: console=ttymxc0,115200 console=tty1
> root=/dev/sda2 video=mxcdi1fb:GBR24,XGA di1_primary tve ?printk.time=1
> [ ? ?0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
> [ ? ?0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
> [ ? ?0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
> [ ? ?0.000000] Memory: 512MB = 512MB total
> [ ? ?0.000000] Memory: 514948k/514948k available, 9340k reserved, 0K highmem
> [ ? ?0.000000] Virtual kernel memory layout:
> [ ? ?0.000000] ? ? vector ?: 0xffff0000 - 0xffff1000 ? ( ? 4 kB)
> [ ? ?0.000000] ? ? fixmap ?: 0xfff00000 - 0xfffe0000 ? ( 896 kB)
> [ ? ?0.000000] ? ? DMA ? ? : 0xffc00000 - 0xffe00000 ? ( ? 2 MB)
> [ ? ?0.000000] ? ? vmalloc : 0xe0800000 - 0xf4000000 ? ( 312 MB)
> [ ? ?0.000000] ? ? lowmem ?: 0xc0000000 - 0xe0000000 ? ( 512 MB)
> [ ? ?0.000000] ? ? modules : 0xbf000000 - 0xc0000000 ? ( ?16 MB)
> [ ? ?0.000000] ? ? ? .text : 0xc0008000 - 0xc0412000 ? (4136 kB)
> [ ? ?0.000000] ? ? ? .init : 0xc0412000 - 0xc0437000 ? ( 148 kB)
> [ ? ?0.000000] ? ? ? .data : 0xc0438000 - 0xc0462480 ? ( 170 kB)
> [ ? ?0.000000] ? ? ? ?.bss : 0xc04624a4 - 0xc04b1380 ? ( 316 kB)
> [ ? ?0.000000] SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0,
> CPUs=1, Nodes=1
> [ ? ?0.000000] NR_IRQS:400
> [ ? ?0.000000] TrustZone Interrupt Controller (TZIC) initialized
> [ ? ?0.000000] CPU identified as i.MX53, silicon rev 2.1
> [ ? ?0.000000] sched_clock: 32 bits at 55MHz, resolution 18ns, wraps
> every 77386ms
> [ ? ?0.000000] Console: colour dummy device 80x30
> [ ? ?0.000000] console [tty1] enabled
> [ ? ?0.000556] Calibrating delay loop... 795.44 BogoMIPS (lpj=3977216)
> [ ? ?0.040182] pid_max: default: 32768 minimum: 301
> [ ? ?0.040450] Mount-cache hash table entries: 512
> [ ? ?0.041059] CPU: Testing write buffer coherency: ok
> [ ? ?0.042459] devtmpfs: initialized
> [ ? ?0.044791] print_constraints: dummy:
> [ ? ?0.045120] NET: Registered protocol family 16
> [ ? ?0.065856] bio: create slab <bio-0> at 0
> [ ? ?0.067168] SCSI subsystem initialized
> [ ? ?0.067580] libata version 3.00 loaded.
> [ ? ?0.067989] usbcore: registered new interface driver usbfs
> [ ? ?0.068174] usbcore: registered new interface driver hub
> [ ? ?0.068488] usbcore: registered new device driver usb
> [ ? ?0.070182] Switching to clocksource mxc_timer1
> [ ? ?0.080403] Switched to NOHz mode on CPU #0
> [ ? ?0.088737] NET: Registered protocol family 2
> [ ? ?0.089034] IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
> [ ? ?0.089503] TCP established hash table entries: 16384 (order: 5,
> 131072 bytes)
> [ ? ?0.089861] TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
> [ ? ?0.090067] TCP: Hash tables configured (established 16384 bind 16384)
> [ ? ?0.090096] TCP reno registered
> [ ? ?0.090128] UDP hash table entries: 256 (order: 0, 4096 bytes)
> [ ? ?0.090168] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
> [ ? ?0.090626] NET: Registered protocol family 1
> [ ? ?0.091318] RPC: Registered named UNIX socket transport module.
> [ ? ?0.091381] RPC: Registered udp transport module.
> [ ? ?0.091407] RPC: Registered tcp transport module.
> [ ? ?0.091429] RPC: Registered tcp NFSv4.1 backchannel transport module.
> [ ? ?0.115113] VFS: Disk quotas dquot_6.5.2
> [ ? ?0.115483] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
> [ ? ?0.120839] fuse init (API version 7.16)
> [ ? ?0.121919] msgmni has been set to 1005
> [ ? ?0.122544] Block layer SCSI generic (bsg) driver version 0.4
> loaded (major 253)
> [ ? ?0.122618] io scheduler noop registered
> [ ? ?0.122646] io scheduler deadline registered
> [ ? ?0.122920] io scheduler cfq registered (default)
> [ ? ?0.123527] Serial: IMX driver
> [ ? ?0.123787] imx21-uart.0: ttymxc0 at MMIO 0x53fbc000 (irq = 31) is a IMX
> [ ? ?0.489212] console [ttymxc0] enabled
> [ ? ?0.502624] brd: module loaded
> [ ? ?0.511401] loop: module loaded
> [ ? ?0.515060] nbd: registered device at major 43
> [ ? ?0.532271] ahci: SSS flag set, parallel bus scan disabled
> [ ? ?0.537878] ahci imx53-ahci.0: AHCI 0001.0100 32 slots 1 ports 3
> Gbps 0x1 impl platform mode
> [ ? ?0.546452] ahci imx53-ahci.0: flags: ncq sntf stag pm led clo only
> pmp pio slum part ccc
> [ ? ?0.556008] scsi0 : ahci_platform
> [ ? ?0.560052] ata1: SATA max UDMA/133 mmio [mem
> 0x10000000-0x10000fff] port 0x100 irq 28
> [ ? ?0.568788] FEC Ethernet Driver
> [ ? ?0.575892] fec_enet_mii_bus: probed
> [ ? ?0.580170] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
> [ ? ?0.587109] Initializing USB Mass Storage driver...
> [ ? ?0.592309] usbcore: registered new interface driver usb-storage
> [ ? ?0.598353] USB Mass Storage support registered.
> [ ? ?0.603499] mousedev: PS/2 mouse device common for all mice
> [ ? ?0.609483] i2c /dev entries driver
> [ ? ?0.614322] imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled.
> timeout=60s (nowayout=0)
> [ ? ?0.623615] device-mapper: uevent: version 1.0.3
> [ ? ?0.629223] device-mapper: ioctl: 4.21.0-ioctl (2011-07-06)
> initialised: dm-devel at redhat.com
> [ ? ?0.637827] sdhci: Secure Digital Host Controller Interface driver
> [ ? ?0.644080] sdhci: Copyright(c) Pierre Ossman
> [ ? ?0.648461] sdhci-pltfm: SDHCI platform and OF driver helper
> [ ? ?0.654585] mmc0: no vmmc regulator found
> [ ? ?0.658808] Registered led device: mmc0::
> [ ? ?0.659016] mmc0: SDHCI controller on sdhci-esdhc-imx53.0
> [sdhci-esdhc-imx53.0] using DMA
> [ ? ?0.667691] mmc1: no vmmc regulator found
> [ ? ?0.672020] Registered led device: mmc1::
> [ ? ?0.672265] mmc1: SDHCI controller on sdhci-esdhc-imx53.2
> [sdhci-esdhc-imx53.2] using DMA
> [ ? ?0.681037] usbcore: registered new interface driver usbhid
> [ ? ?0.686655] usbhid: USB HID core driver
> [ ? ?0.790254] TCP cubic registered
> [ ? ?0.793596] NET: Registered protocol family 17
> [ ? ?0.798190] Registering the dns_resolver key type
> [ ? ?0.803078] VFP support v0.3: implementor 41 architecture 3 part 30
> variant c rev 2
> [ ? ?0.813279] input: gpio-keys as /devices/platform/gpio-keys/input/input0
> [ ? ?0.820805] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
> [ ? ?0.863099] mmc0: host does not support reading read-only switch.
> assuming write-enable.
> [ ? ?0.970967] mmc0: new SD card at address 1234
> [ ? ?1.540405] ata1: softreset failed (device not ready)
> [ ? ?1.545514] ata1: applying PMP SRST workaround and retrying
> [ ? ?1.750408] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [ ? ?1.764169] ata1.00: ATA-8: WDC WD10TPVT-00U4RT1, 01.01A01, max UDMA/133
> [ ? ?1.770981] ata1.00: 1953525168 sectors, multi 0: LBA48 NCQ (depth 31/32)
> [ ? ?1.786154] ata1.00: configured for UDMA/133
> [ ? ?1.791272] scsi 0:0:0:0: Direct-Access ? ? ATA ? ? ?WDC
> WD10TPVT-00U 01.0 PQ: 0 ANSI: 5
> [ ? ?1.800460] sd 0:0:0:0: [sda] 1953525168 512-byte logical blocks:
> (1.00 TB/931 GiB)
> [ ? ?1.808190] sd 0:0:0:0: [sda] 4096-byte physical blocks
> [ ? ?1.815016] sd 0:0:0:0: [sda] Write Protect is off
> [ ? ?1.819878] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
> [ ? ?1.820201] sd 0:0:0:0: [sda] Write cache: enabled, read cache:
> enabled, doesn't support DPO or FUA
> [ ? ?1.856631] ?sda: sda1 sda2 sda3 sda4
> [ ? ?1.863666] sd 0:0:0:0: [sda] Attached SCSI disk
> [ ? ?1.880189] EXT3-fs (sda2): error: couldn't mount because of
> unsupported optional features (240)
> [ ? ?1.890482] EXT2-fs (sda2): error: couldn't mount because of
> unsupported optional features (240)
> [ ? ?1.932146] EXT4-fs (sda2): warning: maximal mount count reached,
> running e2fsck is recommended
> [ ? ?1.959428] EXT4-fs (sda2): mounted filesystem with ordered data
> mode. Opts: (null)
> [ ? ?1.967300] VFS: Mounted root (ext4 filesystem) on device 8:2.
> [ ? ?1.989215] devtmpfs: mounted
> [ ? ?1.992660] Freeing init memory: 148K
> [ ? ?3.913577] udev[67]: starting version 164
> [ ? ?4.877589] mmcblk0: mmc0:1234 SA02G 1.83 GiB
> [ ? ?5.040661] ?mmcblk0: p1 p2 p3
> [ ? ?6.847039] Adding 9767516k swap on /dev/sda3. ?Priority:-1
> extents:1 across:9767516k
> [ ? ?6.987841] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro
> [ ? 13.647889] kjournald starting. ?Commit interval 5 seconds
> [ ? 13.654619] EXT3-fs (dm-0): using internal journal
> [ ? 13.659490] EXT3-fs (dm-0): mounted filesystem with ordered data mode
> [ ? 15.143077] eth0: Freescale FEC PHY driver [Generic PHY]
> (mii_bus:phy_addr=1:00, irq=-1)
> [ ? 17.140873] PHY: 1:00 - Link is Up - 100/Full
> [ ? 17.329274] kjournald starting. ?Commit interval 5 seconds
> [ ? 17.335840] EXT3-fs (dm-3): using internal journal
> [ ? 17.340799] EXT3-fs (dm-3): mounted filesystem with ordered data mode
> [ ? 33.313977] sshd (855): /proc/855/oom_adj is deprecated, please use
> /proc/855/oom_score_adj instead.
> [ 3867.337774] kjournald starting. ?Commit interval 5 seconds
> [ 3867.344328] EXT3-fs (dm-7): using internal journal
> [ 3867.349195] EXT3-fs (dm-7): mounted filesystem with ordered data mode
> [ 3882.857122] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x1280501
> action 0x6 frozen
> [ 3882.864931] ata1.00: irq_stat 0x08000000, interface fatal error
> [ 3882.870928] ata1: SError: { RecovData UnrecovData Proto 10B8B
> BadCRC TrStaTrns }
> [ 3882.878367] ata1.00: failed command: READ FPDMA QUEUED
> [ 3882.883582] ata1.00: cmd 60/c8:00:d0:8a:c4/00:00:0f:00:00/40 tag 0
> ncq 102400 in
> [ 3882.883590] ? ? ? ? ?res 40/00:04:d0:8a:c4/00:00:0f:00:00/40 Emask
> 0x12 (ATA bus error)
> [ 3882.899063] ata1.00: status: { DRDY }
> [ 3882.902802] ata1: hard resetting link
> [ 3883.870400] ata1: softreset failed (device not ready)
> [ 3883.875515] ata1: applying PMP SRST workaround and retrying
> [ 3884.080465] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [ 3884.102097] ata1.00: configured for UDMA/133
> [ 3884.106635] ata1: EH complete
> [ 3934.010542] ata1.00: exception Emask 0x0 SAct 0xff SErr 0x0 action 0x6 frozen
> [ 3934.017759] ata1.00: failed command: READ FPDMA QUEUED
> [ 3934.023030] ata1.00: cmd 60/88:00:18:66:c7/00:00:0f:00:00/40 tag 0
> ncq 69632 in
> [ 3934.023037] ? ? ? ? ?res 40/00:04:d0:8a:c4/00:00:0f:00:00/40 Emask
> 0x4 (timeout)
> [ 3934.038014] ata1.00: status: { DRDY }
> [ 3934.041769] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.047042] ata1.00: cmd 61/38:08:d8:2c:5a/00:00:12:00:00/40 tag 1
> ncq 28672 out
> [ 3934.047051] ? ? ? ? ?res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.062081] ata1.00: status: { DRDY }
> [ 3934.065782] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.071103] ata1.00: cmd 61/20:10:90:67:90/00:00:09:00:00/40 tag 2
> ncq 16384 out
> [ 3934.071113] ? ? ? ? ?res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.085984] ata1.00: status: { DRDY }
> [ 3934.089671] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.094963] ata1.00: cmd 61/08:18:40:a7:8e/00:00:09:00:00/40 tag 3
> ncq 4096 out
> [ 3934.094971] ? ? ? ? ?res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.109735] ata1.00: status: { DRDY }
> [ 3934.113450] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.118711] ata1.00: cmd 61/08:20:40:27:8f/00:00:09:00:00/40 tag 4
> ncq 4096 out
> [ 3934.118721] ? ? ? ? ?res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.133489] ata1.00: status: { DRDY }
> [ 3934.137172] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.142457] ata1.00: cmd 61/08:28:40:67:8f/00:00:09:00:00/40 tag 5
> ncq 4096 out
> [ 3934.142465] ? ? ? ? ?res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.157251] ata1.00: status: { DRDY }
> [ 3934.160972] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.166239] ata1.00: cmd 61/08:30:40:a7:8f/00:00:09:00:00/40 tag 6
> ncq 4096 out
> [ 3934.166245] ? ? ? ? ?res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.181013] ata1.00: status: { DRDY }
> [ 3934.184700] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 3934.189959] ata1.00: cmd 61/60:38:4a:f3:e1/00:00:02:00:00/40 tag 7
> ncq 49152 out
> [ 3934.189966] ? ? ? ? ?res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 3934.204822] ata1.00: status: { DRDY }
> [ 3934.208535] ata1: hard resetting link
> [ 3935.180443] ata1: softreset failed (device not ready)
> [ 3935.185548] ata1: applying PMP SRST workaround and retrying
> [ 3935.390417] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [ 3935.412020] ata1.00: configured for UDMA/133
> [ 3935.416479] ata1.00: device reported invalid CHS sector 0
> [ 3935.421985] ata1.00: device reported invalid CHS sector 0
> [ 3935.427424] ata1.00: device reported invalid CHS sector 0
> [ 3935.432893] ata1.00: device reported invalid CHS sector 0
> [ 3935.438326] ata1.00: device reported invalid CHS sector 0
> [ 3935.443788] ata1.00: device reported invalid CHS sector 0
> [ 3935.449221] ata1.00: device reported invalid CHS sector 0
> [ 3935.454728] ata1: EH complete
> [ 3950.155859] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x80500
> action 0x6 frozen
> [ 3950.163510] ata1.00: irq_stat 0x08000000, interface fatal error
> [ 3950.169469] ata1: SError: { UnrecovData Proto 10B8B }
> [ 3950.174597] ata1.00: failed command: READ FPDMA QUEUED
> [ 3950.179788] ata1.00: cmd 60/00:00:28:97:71/01:00:0f:00:00/40 tag 0
> ncq 131072 in
> [ 3950.179796] ? ? ? ? ?res 40/00:04:28:97:71/00:00:0f:00:00/40 Emask
> 0x12 (ATA bus error)
> [ 3950.195275] ata1.00: status: { DRDY }
> [ 3950.198992] ata1: hard resetting link
> [ 3951.380403] ata1: softreset failed (device not ready)
> [ 3951.385523] ata1: applying PMP SRST workaround and retrying
> [ 3951.590410] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
> [ 3951.612472] ata1.00: configured for UDMA/133
> [ 3951.617042] ata1: EH complete
> [ 3952.305676] ata1: limiting SATA link speed to 1.5 Gbps
> [ 3952.310994] ata1.00: exception Emask 0x12 SAct 0x1 SErr 0x1280500
> action 0x6 frozen
> [ 3952.318692] ata1.00: irq_stat 0x08000000, interface fatal error
> [ 3952.324685] ata1: SError: { UnrecovData Proto 10B8B BadCRC TrStaTrns }
> [ 3952.331283] ata1.00: failed command: READ FPDMA QUEUED
> [ 3952.336469] ata1.00: cmd 60/00:00:28:9f:71/01:00:0f:00:00/40 tag 0
> ncq 131072 in
> [ 3952.336477] ? ? ? ? ?res 40/00:04:28:9f:71/00:00:0f:00:00/40 Emask
> 0x12 (ATA bus error)
> [ 3952.351953] ata1.00: status: { DRDY }
> [ 3952.355667] ata1: hard resetting link
> [ 3953.360414] ata1: softreset failed (device not ready)
> [ 3953.365537] ata1: applying PMP SRST workaround and retrying
> [ 3953.570412] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
> [ 3953.592363] ata1.00: configured for UDMA/133
> [ 3953.596938] ata1: EH complete
> [ 4479.040495] ata1.00: exception Emask 0x0 SAct 0x2 SErr 0x0 action 0x6 frozen
> [ 4479.047622] ata1.00: failed command: WRITE FPDMA QUEUED
> [ 4479.052947] ata1.00: cmd 61/10:08:4a:f9:e1/00:00:02:00:00/40 tag 1
> ncq 8192 out
> [ 4479.052955] ? ? ? ? ?res 40/00:00:00:00:00/00:00:00:00:00/00 Emask
> 0x4 (timeout)
> [ 4479.067740] ata1.00: status: { DRDY }
> [ 4479.071480] ata1: hard resetting link
> [ 4480.040403] ata1: softreset failed (device not ready)
> [ 4480.045513] ata1: applying PMP SRST workaround and retrying
> [ 4480.250423] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
> [ 4480.272519] ata1.00: configured for UDMA/133
> [ 4480.276866] ata1.00: device reported invalid CHS sector 0
> [ 4480.282410] ata1: EH complete
> [52367.370517] ata1.00: exception Emask 0x10 SAct 0x1 SErr 0x280100
> action 0x6 frozen
> [52367.378167] ata1.00: irq_stat 0x08000000, interface fatal error
> [52367.384188] ata1: SError: { UnrecovData 10B8B BadCRC }
> [52367.389366] ata1.00: failed command: READ FPDMA QUEUED
> [52367.394582] ata1.00: cmd 60/00:00:fa:c6:36/02:00:00:00:00/40 tag 0
> ncq 262144 in
> [52367.394592] ? ? ? ? ?res 40/00:04:fa:c6:36/00:00:00:00:00/40 Emask
> 0x10 (ATA bus error)
> [52367.410065] ata1.00: status: { DRDY }
> [52367.413800] ata1: hard resetting link
> [52368.380402] ata1: softreset failed (device not ready)
> [52368.385506] ata1: applying PMP SRST workaround and retrying
> [52368.590410] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
> [52368.612592] ata1.00: configured for UDMA/133
> [52368.617347] ata1: EH complete
>
>
>
> Best regards,
> --
> ?H?ctor Or?n ?-.. . -... .. .- -. ? -.. . ...- . .-.. --- .--. . .-.
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-06 13:25             ` Eric Miao
@ 2011-09-22  9:30               ` Hector Oron
  -1 siblings, 0 replies; 54+ messages in thread
From: Hector Oron @ 2011-09-22  9:30 UTC (permalink / raw)
  To: Eric Miao
  Cc: Richard Zhu, eric, Wolfram Sang, linux-ide, kernel, avorontsov,
	jgarzik, linux-arm-kernel

Hello,

  Apologies for late reply.

2011/9/6 Eric Miao <eric.miao@linaro.org>:
> On Tue, Sep 6, 2011 at 1:46 AM, Hector Oron <hector.oron@gmail.com> wrote:
>> 2011/9/1 Richard Zhu <richard.zhu@linaro.org>:

>> Here is my complete dmesg. The system seems to work fine, it is a
>> 1.0TB WD10TPVT SATA disk in a case which provides eSATA and connected
>> to mx53 LOCO with eSATA-to-SATA cable.

> Is it possible that it's caused by this converter? Do you have a separate
> SATA power supply that could help test the disk directly connected to
> mx53loco?

I think I had a bad configuration setup for my kernel. I have rebuilt
3.1.0-rc6 from Sascha's master git with this patches and now SATA is
working properly I do not see any issue as I did. So, from my side all
is OK now, and I assume I had some missing or conflicting module
setup.

Kind regards and apologies for inconveniences,
-- 
 Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-22  9:30               ` Hector Oron
  0 siblings, 0 replies; 54+ messages in thread
From: Hector Oron @ 2011-09-22  9:30 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

  Apologies for late reply.

2011/9/6 Eric Miao <eric.miao@linaro.org>:
> On Tue, Sep 6, 2011 at 1:46 AM, Hector Oron <hector.oron@gmail.com> wrote:
>> 2011/9/1 Richard Zhu <richard.zhu@linaro.org>:

>> Here is my complete dmesg. The system seems to work fine, it is a
>> 1.0TB WD10TPVT SATA disk in a case which provides eSATA and connected
>> to mx53 LOCO with eSATA-to-SATA cable.

> Is it possible that it's caused by this converter? Do you have a separate
> SATA power supply that could help test the disk directly connected to
> mx53loco?

I think I had a bad configuration setup for my kernel. I have rebuilt
3.1.0-rc6 from Sascha's master git with this patches and now SATA is
working properly I do not see any issue as I did. So, from my side all
is OK now, and I assume I had some missing or conflicting module
setup.

Kind regards and apologies for inconveniences,
-- 
?H?ctor Or?n ?-.. . -... .. .- -. ? -.. . ...- . .-.. --- .--. . .-.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-22  9:30               ` Hector Oron
@ 2011-09-22 12:19                 ` Eric Miao
  -1 siblings, 0 replies; 54+ messages in thread
From: Eric Miao @ 2011-09-22 12:19 UTC (permalink / raw)
  To: Hector Oron
  Cc: eric, Wolfram Sang, linux-ide, Richard Zhu, kernel, avorontsov,
	jgarzik, linux-arm-kernel

On Thu, Sep 22, 2011 at 5:30 PM, Hector Oron <hector.oron@gmail.com> wrote:
> Hello,
>
>  Apologies for late reply.
>
> 2011/9/6 Eric Miao <eric.miao@linaro.org>:
>> On Tue, Sep 6, 2011 at 1:46 AM, Hector Oron <hector.oron@gmail.com> wrote:
>>> 2011/9/1 Richard Zhu <richard.zhu@linaro.org>:
>
>>> Here is my complete dmesg. The system seems to work fine, it is a
>>> 1.0TB WD10TPVT SATA disk in a case which provides eSATA and connected
>>> to mx53 LOCO with eSATA-to-SATA cable.
>
>> Is it possible that it's caused by this converter? Do you have a separate
>> SATA power supply that could help test the disk directly connected to
>> mx53loco?
>
> I think I had a bad configuration setup for my kernel. I have rebuilt
> 3.1.0-rc6 from Sascha's master git with this patches and now SATA is
> working properly I do not see any issue as I did. So, from my side all
> is OK now, and I assume I had some missing or conflicting module
> setup.
>
> Kind regards and apologies for inconveniences,

That's great, Herton. Can we take it as a Tested-by?

> --
>  Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-22 12:19                 ` Eric Miao
  0 siblings, 0 replies; 54+ messages in thread
From: Eric Miao @ 2011-09-22 12:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 22, 2011 at 5:30 PM, Hector Oron <hector.oron@gmail.com> wrote:
> Hello,
>
> ?Apologies for late reply.
>
> 2011/9/6 Eric Miao <eric.miao@linaro.org>:
>> On Tue, Sep 6, 2011 at 1:46 AM, Hector Oron <hector.oron@gmail.com> wrote:
>>> 2011/9/1 Richard Zhu <richard.zhu@linaro.org>:
>
>>> Here is my complete dmesg. The system seems to work fine, it is a
>>> 1.0TB WD10TPVT SATA disk in a case which provides eSATA and connected
>>> to mx53 LOCO with eSATA-to-SATA cable.
>
>> Is it possible that it's caused by this converter? Do you have a separate
>> SATA power supply that could help test the disk directly connected to
>> mx53loco?
>
> I think I had a bad configuration setup for my kernel. I have rebuilt
> 3.1.0-rc6 from Sascha's master git with this patches and now SATA is
> working properly I do not see any issue as I did. So, from my side all
> is OK now, and I assume I had some missing or conflicting module
> setup.
>
> Kind regards and apologies for inconveniences,

That's great, Herton. Can we take it as a Tested-by?

> --
> ?H?ctor Or?n ?-.. . -... .. .- -. ? -.. . ...- . .-.. --- .--. . .-.
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-22 12:19                 ` Eric Miao
@ 2011-09-23  8:58                   ` Hector Oron
  -1 siblings, 0 replies; 54+ messages in thread
From: Hector Oron @ 2011-09-23  8:58 UTC (permalink / raw)
  To: Eric Miao
  Cc: eric, Wolfram Sang, linux-ide, Richard Zhu, kernel, avorontsov,
	jgarzik, linux-arm-kernel

Hello,

2011/9/22 Eric Miao <eric.miao@linaro.org>:
> That's great, Herton. Can we take it as a Tested-by?

Sure, but it's Hector ;-)

Tested-By: Hector Oron Martinez <hector.oron@gmail.com>

Cheers,
-- 
 Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-23  8:58                   ` Hector Oron
  0 siblings, 0 replies; 54+ messages in thread
From: Hector Oron @ 2011-09-23  8:58 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

2011/9/22 Eric Miao <eric.miao@linaro.org>:
> That's great, Herton. Can we take it as a Tested-by?

Sure, but it's Hector ;-)

Tested-By: Hector Oron Martinez <hector.oron@gmail.com>

Cheers,
-- 
?H?ctor Or?n ?-.. . -... .. .- -. ? -.. . ...- . .-.. --- .--. . .-.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-21  7:05         ` Richard Zhu
@ 2011-09-22 18:31           ` Anton Vorontsov
  -1 siblings, 0 replies; 54+ messages in thread
From: Anton Vorontsov @ 2011-09-22 18:31 UTC (permalink / raw)
  To: Richard Zhu
  Cc: Sascha Hauer, linux-arm-kernel, jgarzik, kernel, linux-ide, eric,
	eric.miao

Hi Richard,

On Wed, Sep 21, 2011 at 03:05:44PM +0800, Richard Zhu wrote:
> Hi Sascha:
> One proposal about how to convert the ahci driver to devicetree in future.
> ahci driver system can make a reference to the evolution of the sdhc driver.

You don't need to "convert" ahci driver to devicetree. IIRC,
the current ahci_platform driver should work almost* out of
the box with OF-enabled architectures, as OF subsystem
automatically populates memory and interrupt resources for
platform devices.

Someday you might need to implement OF-specific bindings
(e.g. get some property from the device tree and translate
it into port flags). When/if you'll need it, you can just
add it into the driver.

* Almost: you have to add of_match_table into 'struct
  platform_driver ahci_driver'.

> * separate the ahci to ahci common codes, ahci-pci driver and
> ahci-platform driver.

Done. Long time ago, actually.

> * create kinds of ahci vendor's own ahci platform driver refer to the
> sdhci-xxx driver solutions.

I think that this is viable, but personally I would like to
see platforms to just pass port flags and all needed hooks
via platform_data. That is, I'd leave the hooks in the arch/
code. Usually these hooks are very arch-specific (i.e. enable
these and these clocks, etc), so arch/ seems like a perfect
place for such things.

Not a strong opinion though, and if you like to go your route,
I'm also fine with this. It has its own pros (and cons).

Thanks,

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-22 18:31           ` Anton Vorontsov
  0 siblings, 0 replies; 54+ messages in thread
From: Anton Vorontsov @ 2011-09-22 18:31 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Richard,

On Wed, Sep 21, 2011 at 03:05:44PM +0800, Richard Zhu wrote:
> Hi Sascha:
> One proposal about how to convert the ahci driver to devicetree in future.
> ahci driver system can make a reference to the evolution of the sdhc driver.

You don't need to "convert" ahci driver to devicetree. IIRC,
the current ahci_platform driver should work almost* out of
the box with OF-enabled architectures, as OF subsystem
automatically populates memory and interrupt resources for
platform devices.

Someday you might need to implement OF-specific bindings
(e.g. get some property from the device tree and translate
it into port flags). When/if you'll need it, you can just
add it into the driver.

* Almost: you have to add of_match_table into 'struct
  platform_driver ahci_driver'.

> * separate the ahci to ahci common codes, ahci-pci driver and
> ahci-platform driver.

Done. Long time ago, actually.

> * create kinds of ahci vendor's own ahci platform driver refer to the
> sdhci-xxx driver solutions.

I think that this is viable, but personally I would like to
see platforms to just pass port flags and all needed hooks
via platform_data. That is, I'd leave the hooks in the arch/
code. Usually these hooks are very arch-specific (i.e. enable
these and these clocks, etc), so arch/ seems like a perfect
place for such things.

Not a strong opinion though, and if you like to go your route,
I'm also fine with this. It has its own pros (and cons).

Thanks,

-- 
Anton Vorontsov
Email: cbouatmailru at gmail.com

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-21  7:05         ` Richard Zhu
@ 2011-09-22 18:12           ` Jeff Garzik
  -1 siblings, 0 replies; 54+ messages in thread
From: Jeff Garzik @ 2011-09-22 18:12 UTC (permalink / raw)
  To: Richard Zhu
  Cc: Sascha Hauer, linux-arm-kernel, kernel, linux-ide, avorontsov,
	eric, eric.miao

On 09/21/2011 03:05 AM, Richard Zhu wrote:
> Hi Sascha:
> One proposal about how to convert the ahci driver to devicetree in future.
> ahci driver system can make a reference to the evolution of the sdhc driver.
>
> * separate the ahci to ahci common codes, ahci-pci driver and
> ahci-platform driver.

We already have this, with libahci.

"libahci" == ahci common code
"ahci" == AHCI PCI driver
"ahci-platform" == AHCI platform driver

	Jeff





^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-22 18:12           ` Jeff Garzik
  0 siblings, 0 replies; 54+ messages in thread
From: Jeff Garzik @ 2011-09-22 18:12 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/21/2011 03:05 AM, Richard Zhu wrote:
> Hi Sascha:
> One proposal about how to convert the ahci driver to devicetree in future.
> ahci driver system can make a reference to the evolution of the sdhc driver.
>
> * separate the ahci to ahci common codes, ahci-pci driver and
> ahci-platform driver.

We already have this, with libahci.

"libahci" == ahci common code
"ahci" == AHCI PCI driver
"ahci-platform" == AHCI platform driver

	Jeff

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-21  7:02         ` Sascha Hauer
@ 2011-09-21  7:32           ` Shawn Guo
  -1 siblings, 0 replies; 54+ messages in thread
From: Shawn Guo @ 2011-09-21  7:32 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: Richard Zhu, Shawn Guo, eric, eric.miao, linux-ide, kernel,
	avorontsov, jgarzik, linux-arm-kernel

On Wed, Sep 21, 2011 at 09:02:01AM +0200, Sascha Hauer wrote:
> On Wed, Sep 21, 2011 at 01:04:09PM +0800, Richard Zhu wrote:
> > Hi Sascha:
> > Thanks for your comments.
> > 
> > Best Regard
> > Richard Zhu
> > 
> > On 21 September 2011 04:30, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > > On Wed, Aug 31, 2011 at 11:50:31AM +0800, Richard Zhu wrote:
> > >> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
> > >> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
> > >> ---
> > >>  arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
> > >>  arch/arm/mach-mx5/devices-imx53.h               |    4 +
> > >>  arch/arm/plat-mxc/Makefile                      |    1 +
> > >>  arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
> > >>  arch/arm/plat-mxc/devices/Kconfig               |    4 +
> > >>  arch/arm/plat-mxc/devices/Makefile              |    1 +
> > >>  arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
> > >>  arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
> > >>  arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
> > >>  9 files changed, 242 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
> > >>
> > >> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
> > >> index 7f20308..e1fadaf 100644
> > >> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c
> > >> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
> > >> @@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
> > >>       .secondary = &esdhc4_ipg_clk,
> > >>  };
> > >>
> > >> diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
> > >> new file mode 100644
> > >> index 0000000..4f54816
> > >> --- /dev/null
> > >> +++ b/arch/arm/plat-mxc/ahci_sata.c
> > >> @@ -0,0 +1,104 @@
> > >> +/*
> > >> + * 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 <linux/io.h>
> > >> +#include <linux/clk.h>
> > >> +#include <linux/err.h>
> > >> +#include <linux/device.h>
> > >> +#include <mach/ahci_sata.h>
> > >> +
> > >> +static struct clk *sata_clk, *sata_ref_clk;
> > >
> > > These variables make the driver single instance only.
> > [Richard Zhu] In order to handle the clock enable/disable stuff, these
> > two variables are mandatory required.
> > Otherwise, new two struct clk members had to be added into
> > ahci_platform_data struct. Then the clks can
> > be transferred by the platform data.
> > The current is preferred, refer to the second choice.
> > >
> > >> +
> > >> +/* AHCI module Initialization, if return 0, initialization is successful. */
> > >> +int sata_init(struct device *dev, void __iomem *addr)
> > >
> > > A global function with such a generic name is not a good idea.
> > > Also I wonder how we want to convert this to devicetree when we
> > > implement this as a platform specific hook. It should be done in the
> > > driver.
> > >
> > [Richard Zhu] The name of these two func can be changed.
> > But I don't have a good idea to move out these two platform specific
> > hooks (->init, ->exit).
> > 
> > Refer to you comments, do you means that the ->init and ->exit should
> > be done in ahci_platform.c driver?
> > Different platform may have the different ->init and ->exit funcs to
> > handle it's own initialization and exit.
> > It would be a problem that handle all kinds of init in one driver
> > without the hooks.
> 
> Maybe Shawn can comment on the device tree topic. I just think that if
> we merge this without devicetree support it should at least be
> devicetree friendly. For example each platform could provide it's own
> platform driver glue code like it's done for the sdhci driver.
> 
+1

Though we have a way out for platform hooks if there is really no other
way around, using aux_data to pass a platform_data holding the hooks,
I really hate to see that.  And obviously, Sascha's suggestion seems
the right thing to do.
 
Regards,
Shawn

> > >> diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> > >> new file mode 100644
> > >> index 0000000..9e1b460
> > >> --- /dev/null
> > >> +++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> > >> @@ -0,0 +1,66 @@
> > >> +/*
> > >> + * 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 <linux/dma-mapping.h>
> > >> +#include <asm/sizes.h>
> > >> +#include <mach/hardware.h>
> > >> +#include <mach/devices-common.h>
> > >> +#include <mach/ahci_sata.h>
> > >> +
> > >> +#define imx_ahci_imx_data_entry_single(soc, _devid)          \
> > >> +     {                                                               \
> > >> +             .devid = _devid,                                        \
> > >> +             .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_imx_data_entry_single(MX53, "imx53-ahci");
> > >> +#endif
> > >> +
> > >> +static struct ahci_platform_data default_sata_pdata = {
> > >> +     .init = sata_init,
> > >> +     .exit = sata_exit,
> > >> +};
> 
> If we continue going the way you started, please add the
> sata_init/sata_exit functions as static functions to this file, ...
> 
> > >> +
> > >> +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,
> > >> +             }, {
> > >> +                     .start = data->irq,
> > >> +                     .end = data->irq,
> > >> +                     .flags = IORESOURCE_IRQ,
> > >> +             },
> > >> +     };
> > >> +
> > >> +     if (pdata == NULL)
> > >> +             pdata = &default_sata_pdata;
> 
> ...remove these two lines, and instead introduce a function like this:
> 
> struct platform_device *__init imx53_add_ahci_imx(void)
> {
> 	struct ahci_platform_data pdata = {
> 		.init = imx53_sata_init,
> 		.exit = imx53_sata_exit,
> 	};
> 
> 	return imx_add_ahci_imx(&imx53_ahci_imx_data, &pdata);
> }
> 
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-21  7:32           ` Shawn Guo
  0 siblings, 0 replies; 54+ messages in thread
From: Shawn Guo @ 2011-09-21  7:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 21, 2011 at 09:02:01AM +0200, Sascha Hauer wrote:
> On Wed, Sep 21, 2011 at 01:04:09PM +0800, Richard Zhu wrote:
> > Hi Sascha:
> > Thanks for your comments.
> > 
> > Best Regard
> > Richard Zhu
> > 
> > On 21 September 2011 04:30, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > > On Wed, Aug 31, 2011 at 11:50:31AM +0800, Richard Zhu wrote:
> > >> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
> > >> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
> > >> ---
> > >> ?arch/arm/mach-mx5/clock-mx51-mx53.c ? ? ? ? ? ? | ? 19 ++++
> > >> ?arch/arm/mach-mx5/devices-imx53.h ? ? ? ? ? ? ? | ? ?4 +
> > >> ?arch/arm/plat-mxc/Makefile ? ? ? ? ? ? ? ? ? ? ?| ? ?1 +
> > >> ?arch/arm/plat-mxc/ahci_sata.c ? ? ? ? ? ? ? ? ? | ?104 +++++++++++++++++++++++
> > >> ?arch/arm/plat-mxc/devices/Kconfig ? ? ? ? ? ? ? | ? ?4 +
> > >> ?arch/arm/plat-mxc/devices/Makefile ? ? ? ? ? ? ?| ? ?1 +
> > >> ?arch/arm/plat-mxc/devices/platform-ahci-imx.c ? | ? 66 ++++++++++++++
> > >> ?arch/arm/plat-mxc/include/mach/ahci_sata.h ? ? ?| ? 33 +++++++
> > >> ?arch/arm/plat-mxc/include/mach/devices-common.h | ? 10 ++
> > >> ?9 files changed, 242 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
> > >>
> > >> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
> > >> index 7f20308..e1fadaf 100644
> > >> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c
> > >> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
> > >> @@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
> > >> ? ? ? .secondary = &esdhc4_ipg_clk,
> > >> ?};
> > >>
> > >> diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
> > >> new file mode 100644
> > >> index 0000000..4f54816
> > >> --- /dev/null
> > >> +++ b/arch/arm/plat-mxc/ahci_sata.c
> > >> @@ -0,0 +1,104 @@
> > >> +/*
> > >> + * 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 <linux/io.h>
> > >> +#include <linux/clk.h>
> > >> +#include <linux/err.h>
> > >> +#include <linux/device.h>
> > >> +#include <mach/ahci_sata.h>
> > >> +
> > >> +static struct clk *sata_clk, *sata_ref_clk;
> > >
> > > These variables make the driver single instance only.
> > [Richard Zhu] In order to handle the clock enable/disable stuff, these
> > two variables are mandatory required.
> > Otherwise, new two struct clk members had to be added into
> > ahci_platform_data struct. Then the clks can
> > be transferred by the platform data.
> > The current is preferred, refer to the second choice.
> > >
> > >> +
> > >> +/* AHCI module Initialization, if return 0, initialization is successful. */
> > >> +int sata_init(struct device *dev, void __iomem *addr)
> > >
> > > A global function with such a generic name is not a good idea.
> > > Also I wonder how we want to convert this to devicetree when we
> > > implement this as a platform specific hook. It should be done in the
> > > driver.
> > >
> > [Richard Zhu] The name of these two func can be changed.
> > But I don't have a good idea to move out these two platform specific
> > hooks (->init, ->exit).
> > 
> > Refer to you comments, do you means that the ->init and ->exit should
> > be done in ahci_platform.c driver?
> > Different platform may have the different ->init and ->exit funcs to
> > handle it's own initialization and exit.
> > It would be a problem that handle all kinds of init in one driver
> > without the hooks.
> 
> Maybe Shawn can comment on the device tree topic. I just think that if
> we merge this without devicetree support it should at least be
> devicetree friendly. For example each platform could provide it's own
> platform driver glue code like it's done for the sdhci driver.
> 
+1

Though we have a way out for platform hooks if there is really no other
way around, using aux_data to pass a platform_data holding the hooks,
I really hate to see that.  And obviously, Sascha's suggestion seems
the right thing to do.
 
Regards,
Shawn

> > >> diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> > >> new file mode 100644
> > >> index 0000000..9e1b460
> > >> --- /dev/null
> > >> +++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> > >> @@ -0,0 +1,66 @@
> > >> +/*
> > >> + * 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 <linux/dma-mapping.h>
> > >> +#include <asm/sizes.h>
> > >> +#include <mach/hardware.h>
> > >> +#include <mach/devices-common.h>
> > >> +#include <mach/ahci_sata.h>
> > >> +
> > >> +#define imx_ahci_imx_data_entry_single(soc, _devid) ? ? ? ? ?\
> > >> + ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> > >> + ? ? ? ? ? ? .devid = _devid, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> > >> + ? ? ? ? ? ? .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_imx_data_entry_single(MX53, "imx53-ahci");
> > >> +#endif
> > >> +
> > >> +static struct ahci_platform_data default_sata_pdata = {
> > >> + ? ? .init = sata_init,
> > >> + ? ? .exit = sata_exit,
> > >> +};
> 
> If we continue going the way you started, please add the
> sata_init/sata_exit functions as static functions to this file, ...
> 
> > >> +
> > >> +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,
> > >> + ? ? ? ? ? ? }, {
> > >> + ? ? ? ? ? ? ? ? ? ? .start = data->irq,
> > >> + ? ? ? ? ? ? ? ? ? ? .end = data->irq,
> > >> + ? ? ? ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
> > >> + ? ? ? ? ? ? },
> > >> + ? ? };
> > >> +
> > >> + ? ? if (pdata == NULL)
> > >> + ? ? ? ? ? ? pdata = &default_sata_pdata;
> 
> ...remove these two lines, and instead introduce a function like this:
> 
> struct platform_device *__init imx53_add_ahci_imx(void)
> {
> 	struct ahci_platform_data pdata = {
> 		.init = imx53_sata_init,
> 		.exit = imx53_sata_exit,
> 	};
> 
> 	return imx_add_ahci_imx(&imx53_ahci_imx_data, &pdata);
> }
> 
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-21  5:04       ` Richard Zhu
@ 2011-09-21  7:05         ` Richard Zhu
  -1 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-09-21  7:05 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: linux-arm-kernel, jgarzik, kernel, linux-ide, avorontsov, eric,
	eric.miao

Hi Sascha:
One proposal about how to convert the ahci driver to devicetree in future.
ahci driver system can make a reference to the evolution of the sdhc driver.

* separate the ahci to ahci common codes, ahci-pci driver and
ahci-platform driver.
* create kinds of ahci vendor's own ahci platform driver refer to the
sdhci-xxx driver solutions.
* then we can convert the ahci driver to devicetree smoothly.

It's a long term evolution.

Hi Jeff:
Do you have any suggestions or advices about it?

Best Regard
Richard Zhu

On 21 September 2011 13:04, Richard Zhu <richard.zhu@linaro.org> wrote:
> Hi Sascha:
> Thanks for your comments.
>
> Best Regard
> Richard Zhu
>
> On 21 September 2011 04:30, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>> On Wed, Aug 31, 2011 at 11:50:31AM +0800, Richard Zhu wrote:
>>> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
>>> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
>>> ---
>>>  arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
>>>  arch/arm/mach-mx5/devices-imx53.h               |    4 +
>>>  arch/arm/plat-mxc/Makefile                      |    1 +
>>>  arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
>>>  arch/arm/plat-mxc/devices/Kconfig               |    4 +
>>>  arch/arm/plat-mxc/devices/Makefile              |    1 +
>>>  arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
>>>  arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
>>>  arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
>>>  9 files changed, 242 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
>>>
>>> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
>>> index 7f20308..e1fadaf 100644
>>> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c
>>> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
>>> @@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
>>>       .secondary = &esdhc4_ipg_clk,
>>>  };
>>>
>>> diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
>>> new file mode 100644
>>> index 0000000..4f54816
>>> --- /dev/null
>>> +++ b/arch/arm/plat-mxc/ahci_sata.c
>>> @@ -0,0 +1,104 @@
>>> +/*
>>> + * 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 <linux/io.h>
>>> +#include <linux/clk.h>
>>> +#include <linux/err.h>
>>> +#include <linux/device.h>
>>> +#include <mach/ahci_sata.h>
>>> +
>>> +static struct clk *sata_clk, *sata_ref_clk;
>>
>> These variables make the driver single instance only.
> [Richard Zhu] In order to handle the clock enable/disable stuff, these
> two variables are mandatory required.
> Otherwise, new two struct clk members had to be added into
> ahci_platform_data struct. Then the clks can
> be transferred by the platform data.
> The current is preferred, refer to the second choice.
>>
>>> +
>>> +/* AHCI module Initialization, if return 0, initialization is successful. */
>>> +int sata_init(struct device *dev, void __iomem *addr)
>>
>> A global function with such a generic name is not a good idea.
>> Also I wonder how we want to convert this to devicetree when we
>> implement this as a platform specific hook. It should be done in the
>> driver.
>>
> [Richard Zhu] The name of these two func can be changed.
> But I don't have a good idea to move out these two platform specific
> hooks (->init, ->exit).
>
> Refer to you comments, do you means that the ->init and ->exit should
> be done in ahci_platform.c driver?
> Different platform may have the different ->init and ->exit funcs to
> handle it's own initialization and exit.
> It would be a problem that handle all kinds of init in one driver
> without the hooks.
>
>>> +{
>>> +     u32 tmpdata;
>>> +     int ret = 0;
>>> +     struct clk *clk;
>>> +
>>> +     sata_clk = clk_get(dev, "ahci");
>>> +     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");
>>> +             goto put_sata_clk;
>>> +     }
>>> +
>>> +     /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
>>
>> So this function is loco specific or is the comment wrong?
> [Richard Zhu] Comments wrong, they're common codes and should't be
> specified by the exact
>  board, would be changed later.
>>
>>> +     sata_ref_clk = clk_get(dev, "ahci_phy");
>>> +     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");
>>> +             goto put_sata_ref_clk;
>>> +     }
>>> +
>>> +     /* Get the AHB clock rate, and configure the TIMER1MS reg later */
>>> +     clk = clk_get(dev, "ahci_dma");
>>> +     if (IS_ERR(clk)) {
>>> +             dev_err(dev, "no dma clock.\n");
>>> +             ret = PTR_ERR(clk);
>>> +             goto release_sata_ref_clk;
>>> +     }
>>> +     tmpdata = clk_get_rate(clk) / 1000;
>>> +     clk_put(clk);
>>> +
>>> +     writel(tmpdata, addr + HOST_TIMER1MS);
>>> +
>>> +     tmpdata = readl(addr + HOST_CAP);
>>> +     if (!(tmpdata & HOST_CAP_SSS)) {
>>> +             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);
>>> +
>>> +     return 0;
>>> +
>>> +release_sata_ref_clk:
>>> +     clk_disable(sata_ref_clk);
>>> +put_sata_ref_clk:
>>> +     clk_put(sata_ref_clk);
>>> +release_sata_clk:
>>> +     clk_disable(sata_clk);
>>> +put_sata_clk:
>>> +     clk_put(sata_clk);
>>> +
>>> +     return ret;
>>> +}
>>> +
>>> +void sata_exit(struct device *dev)
>>> +{
>>> +     clk_disable(sata_ref_clk);
>>> +     clk_put(sata_ref_clk);
>>> +
>>> +     clk_disable(sata_clk);
>>> +     clk_put(sata_clk);
>>> +
>>> +}
>>> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
>>> index bd294ad..f63887b 100644
>>> --- a/arch/arm/plat-mxc/devices/Kconfig
>>> +++ b/arch/arm/plat-mxc/devices/Kconfig
>>> @@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
>>>
>>>  config IMX_HAVE_PLATFORM_SPI_IMX
>>>       bool
>>> +
>>> +config IMX_HAVE_PLATFORM_AHCI
>>> +     bool
>>> +     default y if ARCH_MX53
>>> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
>>> index b41bf97..e858ad9 100644
>>> --- a/arch/arm/plat-mxc/devices/Makefile
>>> +++ b/arch/arm/plat-mxc/devices/Makefile
>>> @@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.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_AHCI) +=  platform-ahci-imx.o
>>> diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
>>> new file mode 100644
>>> index 0000000..9e1b460
>>> --- /dev/null
>>> +++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
>>> @@ -0,0 +1,66 @@
>>> +/*
>>> + * 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 <linux/dma-mapping.h>
>>> +#include <asm/sizes.h>
>>> +#include <mach/hardware.h>
>>> +#include <mach/devices-common.h>
>>> +#include <mach/ahci_sata.h>
>>> +
>>> +#define imx_ahci_imx_data_entry_single(soc, _devid)          \
>>> +     {                                                               \
>>> +             .devid = _devid,                                        \
>>> +             .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_imx_data_entry_single(MX53, "imx53-ahci");
>>> +#endif
>>> +
>>> +static struct ahci_platform_data default_sata_pdata = {
>>> +     .init = sata_init,
>>> +     .exit = sata_exit,
>>> +};
>>> +
>>> +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,
>>> +             }, {
>>> +                     .start = data->irq,
>>> +                     .end = data->irq,
>>> +                     .flags = IORESOURCE_IRQ,
>>> +             },
>>> +     };
>>> +
>>> +     if (pdata == NULL)
>>> +             pdata = &default_sata_pdata;
>>> +
>>> +     return imx_add_platform_device_dmamask(data->devid, 0,
>>> +                     res, ARRAY_SIZE(res),
>>> +                     pdata, sizeof(*pdata),  DMA_BIT_MASK(32));
>>> +}
>>> diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
>>> new file mode 100644
>>> index 0000000..ba297e1
>>> --- /dev/null
>>> +++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
>>> @@ -0,0 +1,33 @@
>>> +/*
>>> + * 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.
>>> + */
>>> +
>>> +#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 */
>>> +};
>>> +
>>> +extern int sata_init(struct device *dev, void __iomem *addr);
>>> +extern void sata_exit(struct device *dev);
>>> +#endif /* __PLAT_MXC_AHCI_SATA_H__ */
>>> diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
>>> index 524538a..f04e063 100644
>>> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
>>> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
>>> @@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
>>>  struct platform_device *imx_add_imx_dma(void);
>>>  struct platform_device *imx_add_imx_sdma(char *name,
>>>       resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
>>> +
>>> +#include <linux/ahci_platform.h>
>>> +struct imx_ahci_imx_data {
>>> +     const char *devid;
>>> +     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);
>>> --
>>> 1.7.1
>>>
>>>
>>>
>>
>> --
>> Pengutronix e.K.                           |                             |
>> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
>> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
>>
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-21  7:05         ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-09-21  7:05 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sascha:
One proposal about how to convert the ahci driver to devicetree in future.
ahci driver system can make a reference to the evolution of the sdhc driver.

* separate the ahci to ahci common codes, ahci-pci driver and
ahci-platform driver.
* create kinds of ahci vendor's own ahci platform driver refer to the
sdhci-xxx driver solutions.
* then we can convert the ahci driver to devicetree smoothly.

It's a long term evolution.

Hi Jeff:
Do you have any suggestions or advices about it?

Best Regard
Richard Zhu

On 21 September 2011 13:04, Richard Zhu <richard.zhu@linaro.org> wrote:
> Hi Sascha:
> Thanks for your comments.
>
> Best Regard
> Richard Zhu
>
> On 21 September 2011 04:30, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>> On Wed, Aug 31, 2011 at 11:50:31AM +0800, Richard Zhu wrote:
>>> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
>>> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
>>> ---
>>> ?arch/arm/mach-mx5/clock-mx51-mx53.c ? ? ? ? ? ? | ? 19 ++++
>>> ?arch/arm/mach-mx5/devices-imx53.h ? ? ? ? ? ? ? | ? ?4 +
>>> ?arch/arm/plat-mxc/Makefile ? ? ? ? ? ? ? ? ? ? ?| ? ?1 +
>>> ?arch/arm/plat-mxc/ahci_sata.c ? ? ? ? ? ? ? ? ? | ?104 +++++++++++++++++++++++
>>> ?arch/arm/plat-mxc/devices/Kconfig ? ? ? ? ? ? ? | ? ?4 +
>>> ?arch/arm/plat-mxc/devices/Makefile ? ? ? ? ? ? ?| ? ?1 +
>>> ?arch/arm/plat-mxc/devices/platform-ahci-imx.c ? | ? 66 ++++++++++++++
>>> ?arch/arm/plat-mxc/include/mach/ahci_sata.h ? ? ?| ? 33 +++++++
>>> ?arch/arm/plat-mxc/include/mach/devices-common.h | ? 10 ++
>>> ?9 files changed, 242 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
>>>
>>> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
>>> index 7f20308..e1fadaf 100644
>>> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c
>>> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
>>> @@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
>>> ? ? ? .secondary = &esdhc4_ipg_clk,
>>> ?};
>>>
>>> diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
>>> new file mode 100644
>>> index 0000000..4f54816
>>> --- /dev/null
>>> +++ b/arch/arm/plat-mxc/ahci_sata.c
>>> @@ -0,0 +1,104 @@
>>> +/*
>>> + * 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 <linux/io.h>
>>> +#include <linux/clk.h>
>>> +#include <linux/err.h>
>>> +#include <linux/device.h>
>>> +#include <mach/ahci_sata.h>
>>> +
>>> +static struct clk *sata_clk, *sata_ref_clk;
>>
>> These variables make the driver single instance only.
> [Richard Zhu] In order to handle the clock enable/disable stuff, these
> two variables are mandatory required.
> Otherwise, new two struct clk members had to be added into
> ahci_platform_data struct. Then the clks can
> be transferred by the platform data.
> The current is preferred, refer to the second choice.
>>
>>> +
>>> +/* AHCI module Initialization, if return 0, initialization is successful. */
>>> +int sata_init(struct device *dev, void __iomem *addr)
>>
>> A global function with such a generic name is not a good idea.
>> Also I wonder how we want to convert this to devicetree when we
>> implement this as a platform specific hook. It should be done in the
>> driver.
>>
> [Richard Zhu] The name of these two func can be changed.
> But I don't have a good idea to move out these two platform specific
> hooks (->init, ->exit).
>
> Refer to you comments, do you means that the ->init and ->exit should
> be done in ahci_platform.c driver?
> Different platform may have the different ->init and ->exit funcs to
> handle it's own initialization and exit.
> It would be a problem that handle all kinds of init in one driver
> without the hooks.
>
>>> +{
>>> + ? ? u32 tmpdata;
>>> + ? ? int ret = 0;
>>> + ? ? struct clk *clk;
>>> +
>>> + ? ? sata_clk = clk_get(dev, "ahci");
>>> + ? ? 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");
>>> + ? ? ? ? ? ? goto put_sata_clk;
>>> + ? ? }
>>> +
>>> + ? ? /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
>>
>> So this function is loco specific or is the comment wrong?
> [Richard Zhu] Comments wrong, they're common codes and should't be
> specified by the exact
> ?board, would be changed later.
>>
>>> + ? ? sata_ref_clk = clk_get(dev, "ahci_phy");
>>> + ? ? 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");
>>> + ? ? ? ? ? ? goto put_sata_ref_clk;
>>> + ? ? }
>>> +
>>> + ? ? /* Get the AHB clock rate, and configure the TIMER1MS reg later */
>>> + ? ? clk = clk_get(dev, "ahci_dma");
>>> + ? ? if (IS_ERR(clk)) {
>>> + ? ? ? ? ? ? dev_err(dev, "no dma clock.\n");
>>> + ? ? ? ? ? ? ret = PTR_ERR(clk);
>>> + ? ? ? ? ? ? goto release_sata_ref_clk;
>>> + ? ? }
>>> + ? ? tmpdata = clk_get_rate(clk) / 1000;
>>> + ? ? clk_put(clk);
>>> +
>>> + ? ? writel(tmpdata, addr + HOST_TIMER1MS);
>>> +
>>> + ? ? tmpdata = readl(addr + HOST_CAP);
>>> + ? ? if (!(tmpdata & HOST_CAP_SSS)) {
>>> + ? ? ? ? ? ? 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);
>>> +
>>> + ? ? return 0;
>>> +
>>> +release_sata_ref_clk:
>>> + ? ? clk_disable(sata_ref_clk);
>>> +put_sata_ref_clk:
>>> + ? ? clk_put(sata_ref_clk);
>>> +release_sata_clk:
>>> + ? ? clk_disable(sata_clk);
>>> +put_sata_clk:
>>> + ? ? clk_put(sata_clk);
>>> +
>>> + ? ? return ret;
>>> +}
>>> +
>>> +void sata_exit(struct device *dev)
>>> +{
>>> + ? ? clk_disable(sata_ref_clk);
>>> + ? ? clk_put(sata_ref_clk);
>>> +
>>> + ? ? clk_disable(sata_clk);
>>> + ? ? clk_put(sata_clk);
>>> +
>>> +}
>>> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
>>> index bd294ad..f63887b 100644
>>> --- a/arch/arm/plat-mxc/devices/Kconfig
>>> +++ b/arch/arm/plat-mxc/devices/Kconfig
>>> @@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
>>>
>>> ?config IMX_HAVE_PLATFORM_SPI_IMX
>>> ? ? ? bool
>>> +
>>> +config IMX_HAVE_PLATFORM_AHCI
>>> + ? ? bool
>>> + ? ? default y if ARCH_MX53
>>> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
>>> index b41bf97..e858ad9 100644
>>> --- a/arch/arm/plat-mxc/devices/Makefile
>>> +++ b/arch/arm/plat-mxc/devices/Makefile
>>> @@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.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_AHCI) += ?platform-ahci-imx.o
>>> diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
>>> new file mode 100644
>>> index 0000000..9e1b460
>>> --- /dev/null
>>> +++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
>>> @@ -0,0 +1,66 @@
>>> +/*
>>> + * 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 <linux/dma-mapping.h>
>>> +#include <asm/sizes.h>
>>> +#include <mach/hardware.h>
>>> +#include <mach/devices-common.h>
>>> +#include <mach/ahci_sata.h>
>>> +
>>> +#define imx_ahci_imx_data_entry_single(soc, _devid) ? ? ? ? ?\
>>> + ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
>>> + ? ? ? ? ? ? .devid = _devid, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
>>> + ? ? ? ? ? ? .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_imx_data_entry_single(MX53, "imx53-ahci");
>>> +#endif
>>> +
>>> +static struct ahci_platform_data default_sata_pdata = {
>>> + ? ? .init = sata_init,
>>> + ? ? .exit = sata_exit,
>>> +};
>>> +
>>> +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,
>>> + ? ? ? ? ? ? }, {
>>> + ? ? ? ? ? ? ? ? ? ? .start = data->irq,
>>> + ? ? ? ? ? ? ? ? ? ? .end = data->irq,
>>> + ? ? ? ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
>>> + ? ? ? ? ? ? },
>>> + ? ? };
>>> +
>>> + ? ? if (pdata == NULL)
>>> + ? ? ? ? ? ? pdata = &default_sata_pdata;
>>> +
>>> + ? ? return imx_add_platform_device_dmamask(data->devid, 0,
>>> + ? ? ? ? ? ? ? ? ? ? res, ARRAY_SIZE(res),
>>> + ? ? ? ? ? ? ? ? ? ? pdata, sizeof(*pdata), ?DMA_BIT_MASK(32));
>>> +}
>>> diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
>>> new file mode 100644
>>> index 0000000..ba297e1
>>> --- /dev/null
>>> +++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
>>> @@ -0,0 +1,33 @@
>>> +/*
>>> + * 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.
>>> + */
>>> +
>>> +#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 */
>>> +};
>>> +
>>> +extern int sata_init(struct device *dev, void __iomem *addr);
>>> +extern void sata_exit(struct device *dev);
>>> +#endif /* __PLAT_MXC_AHCI_SATA_H__ */
>>> diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
>>> index 524538a..f04e063 100644
>>> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
>>> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
>>> @@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
>>> ?struct platform_device *imx_add_imx_dma(void);
>>> ?struct platform_device *imx_add_imx_sdma(char *name,
>>> ? ? ? resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
>>> +
>>> +#include <linux/ahci_platform.h>
>>> +struct imx_ahci_imx_data {
>>> + ? ? const char *devid;
>>> + ? ? 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);
>>> --
>>> 1.7.1
>>>
>>>
>>>
>>
>> --
>> Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
>> Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
>> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 ? ?|
>> Amtsgericht Hildesheim, HRA 2686 ? ? ? ? ? | Fax: ? +49-5121-206917-5555 |
>>
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-21  5:04       ` Richard Zhu
@ 2011-09-21  7:02         ` Sascha Hauer
  -1 siblings, 0 replies; 54+ messages in thread
From: Sascha Hauer @ 2011-09-21  7:02 UTC (permalink / raw)
  To: Richard Zhu
  Cc: eric, eric.miao, linux-ide, kernel, avorontsov, jgarzik,
	linux-arm-kernel, Shawn Guo

On Wed, Sep 21, 2011 at 01:04:09PM +0800, Richard Zhu wrote:
> Hi Sascha:
> Thanks for your comments.
> 
> Best Regard
> Richard Zhu
> 
> On 21 September 2011 04:30, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > On Wed, Aug 31, 2011 at 11:50:31AM +0800, Richard Zhu wrote:
> >> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
> >> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
> >> ---
> >>  arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
> >>  arch/arm/mach-mx5/devices-imx53.h               |    4 +
> >>  arch/arm/plat-mxc/Makefile                      |    1 +
> >>  arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
> >>  arch/arm/plat-mxc/devices/Kconfig               |    4 +
> >>  arch/arm/plat-mxc/devices/Makefile              |    1 +
> >>  arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
> >>  arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
> >>  arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
> >>  9 files changed, 242 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
> >>
> >> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
> >> index 7f20308..e1fadaf 100644
> >> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c
> >> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
> >> @@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
> >>       .secondary = &esdhc4_ipg_clk,
> >>  };
> >>
> >> diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
> >> new file mode 100644
> >> index 0000000..4f54816
> >> --- /dev/null
> >> +++ b/arch/arm/plat-mxc/ahci_sata.c
> >> @@ -0,0 +1,104 @@
> >> +/*
> >> + * 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 <linux/io.h>
> >> +#include <linux/clk.h>
> >> +#include <linux/err.h>
> >> +#include <linux/device.h>
> >> +#include <mach/ahci_sata.h>
> >> +
> >> +static struct clk *sata_clk, *sata_ref_clk;
> >
> > These variables make the driver single instance only.
> [Richard Zhu] In order to handle the clock enable/disable stuff, these
> two variables are mandatory required.
> Otherwise, new two struct clk members had to be added into
> ahci_platform_data struct. Then the clks can
> be transferred by the platform data.
> The current is preferred, refer to the second choice.
> >
> >> +
> >> +/* AHCI module Initialization, if return 0, initialization is successful. */
> >> +int sata_init(struct device *dev, void __iomem *addr)
> >
> > A global function with such a generic name is not a good idea.
> > Also I wonder how we want to convert this to devicetree when we
> > implement this as a platform specific hook. It should be done in the
> > driver.
> >
> [Richard Zhu] The name of these two func can be changed.
> But I don't have a good idea to move out these two platform specific
> hooks (->init, ->exit).
> 
> Refer to you comments, do you means that the ->init and ->exit should
> be done in ahci_platform.c driver?
> Different platform may have the different ->init and ->exit funcs to
> handle it's own initialization and exit.
> It would be a problem that handle all kinds of init in one driver
> without the hooks.

Maybe Shawn can comment on the device tree topic. I just think that if
we merge this without devicetree support it should at least be
devicetree friendly. For example each platform could provide it's own
platform driver glue code like it's done for the sdhci driver.

> >> diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> >> new file mode 100644
> >> index 0000000..9e1b460
> >> --- /dev/null
> >> +++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> >> @@ -0,0 +1,66 @@
> >> +/*
> >> + * 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 <linux/dma-mapping.h>
> >> +#include <asm/sizes.h>
> >> +#include <mach/hardware.h>
> >> +#include <mach/devices-common.h>
> >> +#include <mach/ahci_sata.h>
> >> +
> >> +#define imx_ahci_imx_data_entry_single(soc, _devid)          \
> >> +     {                                                               \
> >> +             .devid = _devid,                                        \
> >> +             .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_imx_data_entry_single(MX53, "imx53-ahci");
> >> +#endif
> >> +
> >> +static struct ahci_platform_data default_sata_pdata = {
> >> +     .init = sata_init,
> >> +     .exit = sata_exit,
> >> +};

If we continue going the way you started, please add the
sata_init/sata_exit functions as static functions to this file, ...

> >> +
> >> +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,
> >> +             }, {
> >> +                     .start = data->irq,
> >> +                     .end = data->irq,
> >> +                     .flags = IORESOURCE_IRQ,
> >> +             },
> >> +     };
> >> +
> >> +     if (pdata == NULL)
> >> +             pdata = &default_sata_pdata;

...remove these two lines, and instead introduce a function like this:

struct platform_device *__init imx53_add_ahci_imx(void)
{
	struct ahci_platform_data pdata = {
		.init = imx53_sata_init,
		.exit = imx53_sata_exit,
	};

	return imx_add_ahci_imx(&imx53_ahci_imx_data, &pdata);
}


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-21  7:02         ` Sascha Hauer
  0 siblings, 0 replies; 54+ messages in thread
From: Sascha Hauer @ 2011-09-21  7:02 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 21, 2011 at 01:04:09PM +0800, Richard Zhu wrote:
> Hi Sascha:
> Thanks for your comments.
> 
> Best Regard
> Richard Zhu
> 
> On 21 September 2011 04:30, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > On Wed, Aug 31, 2011 at 11:50:31AM +0800, Richard Zhu wrote:
> >> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
> >> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
> >> ---
> >> ?arch/arm/mach-mx5/clock-mx51-mx53.c ? ? ? ? ? ? | ? 19 ++++
> >> ?arch/arm/mach-mx5/devices-imx53.h ? ? ? ? ? ? ? | ? ?4 +
> >> ?arch/arm/plat-mxc/Makefile ? ? ? ? ? ? ? ? ? ? ?| ? ?1 +
> >> ?arch/arm/plat-mxc/ahci_sata.c ? ? ? ? ? ? ? ? ? | ?104 +++++++++++++++++++++++
> >> ?arch/arm/plat-mxc/devices/Kconfig ? ? ? ? ? ? ? | ? ?4 +
> >> ?arch/arm/plat-mxc/devices/Makefile ? ? ? ? ? ? ?| ? ?1 +
> >> ?arch/arm/plat-mxc/devices/platform-ahci-imx.c ? | ? 66 ++++++++++++++
> >> ?arch/arm/plat-mxc/include/mach/ahci_sata.h ? ? ?| ? 33 +++++++
> >> ?arch/arm/plat-mxc/include/mach/devices-common.h | ? 10 ++
> >> ?9 files changed, 242 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
> >>
> >> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
> >> index 7f20308..e1fadaf 100644
> >> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c
> >> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
> >> @@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
> >> ? ? ? .secondary = &esdhc4_ipg_clk,
> >> ?};
> >>
> >> diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
> >> new file mode 100644
> >> index 0000000..4f54816
> >> --- /dev/null
> >> +++ b/arch/arm/plat-mxc/ahci_sata.c
> >> @@ -0,0 +1,104 @@
> >> +/*
> >> + * 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 <linux/io.h>
> >> +#include <linux/clk.h>
> >> +#include <linux/err.h>
> >> +#include <linux/device.h>
> >> +#include <mach/ahci_sata.h>
> >> +
> >> +static struct clk *sata_clk, *sata_ref_clk;
> >
> > These variables make the driver single instance only.
> [Richard Zhu] In order to handle the clock enable/disable stuff, these
> two variables are mandatory required.
> Otherwise, new two struct clk members had to be added into
> ahci_platform_data struct. Then the clks can
> be transferred by the platform data.
> The current is preferred, refer to the second choice.
> >
> >> +
> >> +/* AHCI module Initialization, if return 0, initialization is successful. */
> >> +int sata_init(struct device *dev, void __iomem *addr)
> >
> > A global function with such a generic name is not a good idea.
> > Also I wonder how we want to convert this to devicetree when we
> > implement this as a platform specific hook. It should be done in the
> > driver.
> >
> [Richard Zhu] The name of these two func can be changed.
> But I don't have a good idea to move out these two platform specific
> hooks (->init, ->exit).
> 
> Refer to you comments, do you means that the ->init and ->exit should
> be done in ahci_platform.c driver?
> Different platform may have the different ->init and ->exit funcs to
> handle it's own initialization and exit.
> It would be a problem that handle all kinds of init in one driver
> without the hooks.

Maybe Shawn can comment on the device tree topic. I just think that if
we merge this without devicetree support it should at least be
devicetree friendly. For example each platform could provide it's own
platform driver glue code like it's done for the sdhci driver.

> >> diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> >> new file mode 100644
> >> index 0000000..9e1b460
> >> --- /dev/null
> >> +++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> >> @@ -0,0 +1,66 @@
> >> +/*
> >> + * 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 <linux/dma-mapping.h>
> >> +#include <asm/sizes.h>
> >> +#include <mach/hardware.h>
> >> +#include <mach/devices-common.h>
> >> +#include <mach/ahci_sata.h>
> >> +
> >> +#define imx_ahci_imx_data_entry_single(soc, _devid) ? ? ? ? ?\
> >> + ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> >> + ? ? ? ? ? ? .devid = _devid, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> >> + ? ? ? ? ? ? .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_imx_data_entry_single(MX53, "imx53-ahci");
> >> +#endif
> >> +
> >> +static struct ahci_platform_data default_sata_pdata = {
> >> + ? ? .init = sata_init,
> >> + ? ? .exit = sata_exit,
> >> +};

If we continue going the way you started, please add the
sata_init/sata_exit functions as static functions to this file, ...

> >> +
> >> +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,
> >> + ? ? ? ? ? ? }, {
> >> + ? ? ? ? ? ? ? ? ? ? .start = data->irq,
> >> + ? ? ? ? ? ? ? ? ? ? .end = data->irq,
> >> + ? ? ? ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
> >> + ? ? ? ? ? ? },
> >> + ? ? };
> >> +
> >> + ? ? if (pdata == NULL)
> >> + ? ? ? ? ? ? pdata = &default_sata_pdata;

...remove these two lines, and instead introduce a function like this:

struct platform_device *__init imx53_add_ahci_imx(void)
{
	struct ahci_platform_data pdata = {
		.init = imx53_sata_init,
		.exit = imx53_sata_exit,
	};

	return imx_add_ahci_imx(&imx53_ahci_imx_data, &pdata);
}


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-09-20 20:30     ` Sascha Hauer
@ 2011-09-21  5:04       ` Richard Zhu
  -1 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-09-21  5:04 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: linux-arm-kernel, jgarzik, kernel, linux-ide, avorontsov, eric,
	eric.miao

Hi Sascha:
Thanks for your comments.

Best Regard
Richard Zhu

On 21 September 2011 04:30, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Wed, Aug 31, 2011 at 11:50:31AM +0800, Richard Zhu wrote:
>> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
>> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
>> ---
>>  arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
>>  arch/arm/mach-mx5/devices-imx53.h               |    4 +
>>  arch/arm/plat-mxc/Makefile                      |    1 +
>>  arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
>>  arch/arm/plat-mxc/devices/Kconfig               |    4 +
>>  arch/arm/plat-mxc/devices/Makefile              |    1 +
>>  arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
>>  arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
>>  arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
>>  9 files changed, 242 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
>>
>> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
>> index 7f20308..e1fadaf 100644
>> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c
>> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
>> @@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
>>       .secondary = &esdhc4_ipg_clk,
>>  };
>>
>> diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
>> new file mode 100644
>> index 0000000..4f54816
>> --- /dev/null
>> +++ b/arch/arm/plat-mxc/ahci_sata.c
>> @@ -0,0 +1,104 @@
>> +/*
>> + * 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 <linux/io.h>
>> +#include <linux/clk.h>
>> +#include <linux/err.h>
>> +#include <linux/device.h>
>> +#include <mach/ahci_sata.h>
>> +
>> +static struct clk *sata_clk, *sata_ref_clk;
>
> These variables make the driver single instance only.
[Richard Zhu] In order to handle the clock enable/disable stuff, these
two variables are mandatory required.
Otherwise, new two struct clk members had to be added into
ahci_platform_data struct. Then the clks can
be transferred by the platform data.
The current is preferred, refer to the second choice.
>
>> +
>> +/* AHCI module Initialization, if return 0, initialization is successful. */
>> +int sata_init(struct device *dev, void __iomem *addr)
>
> A global function with such a generic name is not a good idea.
> Also I wonder how we want to convert this to devicetree when we
> implement this as a platform specific hook. It should be done in the
> driver.
>
[Richard Zhu] The name of these two func can be changed.
But I don't have a good idea to move out these two platform specific
hooks (->init, ->exit).

Refer to you comments, do you means that the ->init and ->exit should
be done in ahci_platform.c driver?
Different platform may have the different ->init and ->exit funcs to
handle it's own initialization and exit.
It would be a problem that handle all kinds of init in one driver
without the hooks.

>> +{
>> +     u32 tmpdata;
>> +     int ret = 0;
>> +     struct clk *clk;
>> +
>> +     sata_clk = clk_get(dev, "ahci");
>> +     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");
>> +             goto put_sata_clk;
>> +     }
>> +
>> +     /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
>
> So this function is loco specific or is the comment wrong?
[Richard Zhu] Comments wrong, they're common codes and should't be
specified by the exact
 board, would be changed later.
>
>> +     sata_ref_clk = clk_get(dev, "ahci_phy");
>> +     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");
>> +             goto put_sata_ref_clk;
>> +     }
>> +
>> +     /* Get the AHB clock rate, and configure the TIMER1MS reg later */
>> +     clk = clk_get(dev, "ahci_dma");
>> +     if (IS_ERR(clk)) {
>> +             dev_err(dev, "no dma clock.\n");
>> +             ret = PTR_ERR(clk);
>> +             goto release_sata_ref_clk;
>> +     }
>> +     tmpdata = clk_get_rate(clk) / 1000;
>> +     clk_put(clk);
>> +
>> +     writel(tmpdata, addr + HOST_TIMER1MS);
>> +
>> +     tmpdata = readl(addr + HOST_CAP);
>> +     if (!(tmpdata & HOST_CAP_SSS)) {
>> +             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);
>> +
>> +     return 0;
>> +
>> +release_sata_ref_clk:
>> +     clk_disable(sata_ref_clk);
>> +put_sata_ref_clk:
>> +     clk_put(sata_ref_clk);
>> +release_sata_clk:
>> +     clk_disable(sata_clk);
>> +put_sata_clk:
>> +     clk_put(sata_clk);
>> +
>> +     return ret;
>> +}
>> +
>> +void sata_exit(struct device *dev)
>> +{
>> +     clk_disable(sata_ref_clk);
>> +     clk_put(sata_ref_clk);
>> +
>> +     clk_disable(sata_clk);
>> +     clk_put(sata_clk);
>> +
>> +}
>> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
>> index bd294ad..f63887b 100644
>> --- a/arch/arm/plat-mxc/devices/Kconfig
>> +++ b/arch/arm/plat-mxc/devices/Kconfig
>> @@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
>>
>>  config IMX_HAVE_PLATFORM_SPI_IMX
>>       bool
>> +
>> +config IMX_HAVE_PLATFORM_AHCI
>> +     bool
>> +     default y if ARCH_MX53
>> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
>> index b41bf97..e858ad9 100644
>> --- a/arch/arm/plat-mxc/devices/Makefile
>> +++ b/arch/arm/plat-mxc/devices/Makefile
>> @@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.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_AHCI) +=  platform-ahci-imx.o
>> diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
>> new file mode 100644
>> index 0000000..9e1b460
>> --- /dev/null
>> +++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
>> @@ -0,0 +1,66 @@
>> +/*
>> + * 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 <linux/dma-mapping.h>
>> +#include <asm/sizes.h>
>> +#include <mach/hardware.h>
>> +#include <mach/devices-common.h>
>> +#include <mach/ahci_sata.h>
>> +
>> +#define imx_ahci_imx_data_entry_single(soc, _devid)          \
>> +     {                                                               \
>> +             .devid = _devid,                                        \
>> +             .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_imx_data_entry_single(MX53, "imx53-ahci");
>> +#endif
>> +
>> +static struct ahci_platform_data default_sata_pdata = {
>> +     .init = sata_init,
>> +     .exit = sata_exit,
>> +};
>> +
>> +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,
>> +             }, {
>> +                     .start = data->irq,
>> +                     .end = data->irq,
>> +                     .flags = IORESOURCE_IRQ,
>> +             },
>> +     };
>> +
>> +     if (pdata == NULL)
>> +             pdata = &default_sata_pdata;
>> +
>> +     return imx_add_platform_device_dmamask(data->devid, 0,
>> +                     res, ARRAY_SIZE(res),
>> +                     pdata, sizeof(*pdata),  DMA_BIT_MASK(32));
>> +}
>> diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
>> new file mode 100644
>> index 0000000..ba297e1
>> --- /dev/null
>> +++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
>> @@ -0,0 +1,33 @@
>> +/*
>> + * 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.
>> + */
>> +
>> +#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 */
>> +};
>> +
>> +extern int sata_init(struct device *dev, void __iomem *addr);
>> +extern void sata_exit(struct device *dev);
>> +#endif /* __PLAT_MXC_AHCI_SATA_H__ */
>> diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
>> index 524538a..f04e063 100644
>> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
>> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
>> @@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
>>  struct platform_device *imx_add_imx_dma(void);
>>  struct platform_device *imx_add_imx_sdma(char *name,
>>       resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
>> +
>> +#include <linux/ahci_platform.h>
>> +struct imx_ahci_imx_data {
>> +     const char *devid;
>> +     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);
>> --
>> 1.7.1
>>
>>
>>
>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-21  5:04       ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-09-21  5:04 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sascha:
Thanks for your comments.

Best Regard
Richard Zhu

On 21 September 2011 04:30, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Wed, Aug 31, 2011 at 11:50:31AM +0800, Richard Zhu wrote:
>> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
>> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
>> ---
>> ?arch/arm/mach-mx5/clock-mx51-mx53.c ? ? ? ? ? ? | ? 19 ++++
>> ?arch/arm/mach-mx5/devices-imx53.h ? ? ? ? ? ? ? | ? ?4 +
>> ?arch/arm/plat-mxc/Makefile ? ? ? ? ? ? ? ? ? ? ?| ? ?1 +
>> ?arch/arm/plat-mxc/ahci_sata.c ? ? ? ? ? ? ? ? ? | ?104 +++++++++++++++++++++++
>> ?arch/arm/plat-mxc/devices/Kconfig ? ? ? ? ? ? ? | ? ?4 +
>> ?arch/arm/plat-mxc/devices/Makefile ? ? ? ? ? ? ?| ? ?1 +
>> ?arch/arm/plat-mxc/devices/platform-ahci-imx.c ? | ? 66 ++++++++++++++
>> ?arch/arm/plat-mxc/include/mach/ahci_sata.h ? ? ?| ? 33 +++++++
>> ?arch/arm/plat-mxc/include/mach/devices-common.h | ? 10 ++
>> ?9 files changed, 242 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
>>
>> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
>> index 7f20308..e1fadaf 100644
>> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c
>> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
>> @@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
>> ? ? ? .secondary = &esdhc4_ipg_clk,
>> ?};
>>
>> diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
>> new file mode 100644
>> index 0000000..4f54816
>> --- /dev/null
>> +++ b/arch/arm/plat-mxc/ahci_sata.c
>> @@ -0,0 +1,104 @@
>> +/*
>> + * 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 <linux/io.h>
>> +#include <linux/clk.h>
>> +#include <linux/err.h>
>> +#include <linux/device.h>
>> +#include <mach/ahci_sata.h>
>> +
>> +static struct clk *sata_clk, *sata_ref_clk;
>
> These variables make the driver single instance only.
[Richard Zhu] In order to handle the clock enable/disable stuff, these
two variables are mandatory required.
Otherwise, new two struct clk members had to be added into
ahci_platform_data struct. Then the clks can
be transferred by the platform data.
The current is preferred, refer to the second choice.
>
>> +
>> +/* AHCI module Initialization, if return 0, initialization is successful. */
>> +int sata_init(struct device *dev, void __iomem *addr)
>
> A global function with such a generic name is not a good idea.
> Also I wonder how we want to convert this to devicetree when we
> implement this as a platform specific hook. It should be done in the
> driver.
>
[Richard Zhu] The name of these two func can be changed.
But I don't have a good idea to move out these two platform specific
hooks (->init, ->exit).

Refer to you comments, do you means that the ->init and ->exit should
be done in ahci_platform.c driver?
Different platform may have the different ->init and ->exit funcs to
handle it's own initialization and exit.
It would be a problem that handle all kinds of init in one driver
without the hooks.

>> +{
>> + ? ? u32 tmpdata;
>> + ? ? int ret = 0;
>> + ? ? struct clk *clk;
>> +
>> + ? ? sata_clk = clk_get(dev, "ahci");
>> + ? ? 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");
>> + ? ? ? ? ? ? goto put_sata_clk;
>> + ? ? }
>> +
>> + ? ? /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
>
> So this function is loco specific or is the comment wrong?
[Richard Zhu] Comments wrong, they're common codes and should't be
specified by the exact
 board, would be changed later.
>
>> + ? ? sata_ref_clk = clk_get(dev, "ahci_phy");
>> + ? ? 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");
>> + ? ? ? ? ? ? goto put_sata_ref_clk;
>> + ? ? }
>> +
>> + ? ? /* Get the AHB clock rate, and configure the TIMER1MS reg later */
>> + ? ? clk = clk_get(dev, "ahci_dma");
>> + ? ? if (IS_ERR(clk)) {
>> + ? ? ? ? ? ? dev_err(dev, "no dma clock.\n");
>> + ? ? ? ? ? ? ret = PTR_ERR(clk);
>> + ? ? ? ? ? ? goto release_sata_ref_clk;
>> + ? ? }
>> + ? ? tmpdata = clk_get_rate(clk) / 1000;
>> + ? ? clk_put(clk);
>> +
>> + ? ? writel(tmpdata, addr + HOST_TIMER1MS);
>> +
>> + ? ? tmpdata = readl(addr + HOST_CAP);
>> + ? ? if (!(tmpdata & HOST_CAP_SSS)) {
>> + ? ? ? ? ? ? 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);
>> +
>> + ? ? return 0;
>> +
>> +release_sata_ref_clk:
>> + ? ? clk_disable(sata_ref_clk);
>> +put_sata_ref_clk:
>> + ? ? clk_put(sata_ref_clk);
>> +release_sata_clk:
>> + ? ? clk_disable(sata_clk);
>> +put_sata_clk:
>> + ? ? clk_put(sata_clk);
>> +
>> + ? ? return ret;
>> +}
>> +
>> +void sata_exit(struct device *dev)
>> +{
>> + ? ? clk_disable(sata_ref_clk);
>> + ? ? clk_put(sata_ref_clk);
>> +
>> + ? ? clk_disable(sata_clk);
>> + ? ? clk_put(sata_clk);
>> +
>> +}
>> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
>> index bd294ad..f63887b 100644
>> --- a/arch/arm/plat-mxc/devices/Kconfig
>> +++ b/arch/arm/plat-mxc/devices/Kconfig
>> @@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
>>
>> ?config IMX_HAVE_PLATFORM_SPI_IMX
>> ? ? ? bool
>> +
>> +config IMX_HAVE_PLATFORM_AHCI
>> + ? ? bool
>> + ? ? default y if ARCH_MX53
>> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
>> index b41bf97..e858ad9 100644
>> --- a/arch/arm/plat-mxc/devices/Makefile
>> +++ b/arch/arm/plat-mxc/devices/Makefile
>> @@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.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_AHCI) += ?platform-ahci-imx.o
>> diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
>> new file mode 100644
>> index 0000000..9e1b460
>> --- /dev/null
>> +++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
>> @@ -0,0 +1,66 @@
>> +/*
>> + * 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 <linux/dma-mapping.h>
>> +#include <asm/sizes.h>
>> +#include <mach/hardware.h>
>> +#include <mach/devices-common.h>
>> +#include <mach/ahci_sata.h>
>> +
>> +#define imx_ahci_imx_data_entry_single(soc, _devid) ? ? ? ? ?\
>> + ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
>> + ? ? ? ? ? ? .devid = _devid, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
>> + ? ? ? ? ? ? .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_imx_data_entry_single(MX53, "imx53-ahci");
>> +#endif
>> +
>> +static struct ahci_platform_data default_sata_pdata = {
>> + ? ? .init = sata_init,
>> + ? ? .exit = sata_exit,
>> +};
>> +
>> +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,
>> + ? ? ? ? ? ? }, {
>> + ? ? ? ? ? ? ? ? ? ? .start = data->irq,
>> + ? ? ? ? ? ? ? ? ? ? .end = data->irq,
>> + ? ? ? ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
>> + ? ? ? ? ? ? },
>> + ? ? };
>> +
>> + ? ? if (pdata == NULL)
>> + ? ? ? ? ? ? pdata = &default_sata_pdata;
>> +
>> + ? ? return imx_add_platform_device_dmamask(data->devid, 0,
>> + ? ? ? ? ? ? ? ? ? ? res, ARRAY_SIZE(res),
>> + ? ? ? ? ? ? ? ? ? ? pdata, sizeof(*pdata), ?DMA_BIT_MASK(32));
>> +}
>> diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
>> new file mode 100644
>> index 0000000..ba297e1
>> --- /dev/null
>> +++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
>> @@ -0,0 +1,33 @@
>> +/*
>> + * 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.
>> + */
>> +
>> +#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 */
>> +};
>> +
>> +extern int sata_init(struct device *dev, void __iomem *addr);
>> +extern void sata_exit(struct device *dev);
>> +#endif /* __PLAT_MXC_AHCI_SATA_H__ */
>> diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
>> index 524538a..f04e063 100644
>> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
>> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
>> @@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
>> ?struct platform_device *imx_add_imx_dma(void);
>> ?struct platform_device *imx_add_imx_sdma(char *name,
>> ? ? ? resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
>> +
>> +#include <linux/ahci_platform.h>
>> +struct imx_ahci_imx_data {
>> + ? ? const char *devid;
>> + ? ? 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);
>> --
>> 1.7.1
>>
>>
>>
>
> --
> Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
> Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 ? ?|
> Amtsgericht Hildesheim, HRA 2686 ? ? ? ? ? | Fax: ? +49-5121-206917-5555 |
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-08-31  3:50   ` Richard Zhu
@ 2011-09-20 20:30     ` Sascha Hauer
  -1 siblings, 0 replies; 54+ messages in thread
From: Sascha Hauer @ 2011-09-20 20:30 UTC (permalink / raw)
  To: Richard Zhu
  Cc: linux-arm-kernel, jgarzik, kernel, linux-ide, avorontsov, eric,
	eric.miao

On Wed, Aug 31, 2011 at 11:50:31AM +0800, Richard Zhu wrote:
> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
> ---
>  arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
>  arch/arm/mach-mx5/devices-imx53.h               |    4 +
>  arch/arm/plat-mxc/Makefile                      |    1 +
>  arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
>  arch/arm/plat-mxc/devices/Kconfig               |    4 +
>  arch/arm/plat-mxc/devices/Makefile              |    1 +
>  arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
>  arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
>  arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
>  9 files changed, 242 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
> 
> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
> index 7f20308..e1fadaf 100644
> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c
> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
> @@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
>  	.secondary = &esdhc4_ipg_clk,
>  };
>  
> diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
> new file mode 100644
> index 0000000..4f54816
> --- /dev/null
> +++ b/arch/arm/plat-mxc/ahci_sata.c
> @@ -0,0 +1,104 @@
> +/*
> + * 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 <linux/io.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/device.h>
> +#include <mach/ahci_sata.h>
> +
> +static struct clk *sata_clk, *sata_ref_clk;

These variables make the driver single instance only.

> +
> +/* AHCI module Initialization, if return 0, initialization is successful. */
> +int sata_init(struct device *dev, void __iomem *addr)

A global function with such a generic name is not a good idea.
Also I wonder how we want to convert this to devicetree when we
implement this as a platform specific hook. It should be done in the
driver.

> +{
> +	u32 tmpdata;
> +	int ret = 0;
> +	struct clk *clk;
> +
> +	sata_clk = clk_get(dev, "ahci");
> +	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");
> +		goto put_sata_clk;
> +	}
> +
> +	/* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */

So this function is loco specific or is the comment wrong?

> +	sata_ref_clk = clk_get(dev, "ahci_phy");
> +	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");
> +		goto put_sata_ref_clk;
> +	}
> +
> +	/* Get the AHB clock rate, and configure the TIMER1MS reg later */
> +	clk = clk_get(dev, "ahci_dma");
> +	if (IS_ERR(clk)) {
> +		dev_err(dev, "no dma clock.\n");
> +		ret = PTR_ERR(clk);
> +		goto release_sata_ref_clk;
> +	}
> +	tmpdata = clk_get_rate(clk) / 1000;
> +	clk_put(clk);
> +
> +	writel(tmpdata, addr + HOST_TIMER1MS);
> +
> +	tmpdata = readl(addr + HOST_CAP);
> +	if (!(tmpdata & HOST_CAP_SSS)) {
> +		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);
> +
> +	return 0;
> +
> +release_sata_ref_clk:
> +	clk_disable(sata_ref_clk);
> +put_sata_ref_clk:
> +	clk_put(sata_ref_clk);
> +release_sata_clk:
> +	clk_disable(sata_clk);
> +put_sata_clk:
> +	clk_put(sata_clk);
> +
> +	return ret;
> +}
> +
> +void sata_exit(struct device *dev)
> +{
> +	clk_disable(sata_ref_clk);
> +	clk_put(sata_ref_clk);
> +
> +	clk_disable(sata_clk);
> +	clk_put(sata_clk);
> +
> +}
> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
> index bd294ad..f63887b 100644
> --- a/arch/arm/plat-mxc/devices/Kconfig
> +++ b/arch/arm/plat-mxc/devices/Kconfig
> @@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
>  
>  config IMX_HAVE_PLATFORM_SPI_IMX
>  	bool
> +
> +config IMX_HAVE_PLATFORM_AHCI
> +	bool
> +	default y if ARCH_MX53
> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
> index b41bf97..e858ad9 100644
> --- a/arch/arm/plat-mxc/devices/Makefile
> +++ b/arch/arm/plat-mxc/devices/Makefile
> @@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.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_AHCI) +=  platform-ahci-imx.o
> diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> new file mode 100644
> index 0000000..9e1b460
> --- /dev/null
> +++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> @@ -0,0 +1,66 @@
> +/*
> + * 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 <linux/dma-mapping.h>
> +#include <asm/sizes.h>
> +#include <mach/hardware.h>
> +#include <mach/devices-common.h>
> +#include <mach/ahci_sata.h>
> +
> +#define imx_ahci_imx_data_entry_single(soc, _devid)		\
> +	{								\
> +		.devid = _devid,					\
> +		.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_imx_data_entry_single(MX53, "imx53-ahci");
> +#endif
> +
> +static struct ahci_platform_data default_sata_pdata = {
> +	.init = sata_init,
> +	.exit = sata_exit,
> +};
> +
> +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,
> +		}, {
> +			.start = data->irq,
> +			.end = data->irq,
> +			.flags = IORESOURCE_IRQ,
> +		},
> +	};
> +
> +	if (pdata == NULL)
> +		pdata = &default_sata_pdata;
> +
> +	return imx_add_platform_device_dmamask(data->devid, 0,
> +			res, ARRAY_SIZE(res),
> +			pdata, sizeof(*pdata),  DMA_BIT_MASK(32));
> +}
> diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
> new file mode 100644
> index 0000000..ba297e1
> --- /dev/null
> +++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
> @@ -0,0 +1,33 @@
> +/*
> + * 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.
> + */
> +
> +#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 */
> +};
> +
> +extern int sata_init(struct device *dev, void __iomem *addr);
> +extern void sata_exit(struct device *dev);
> +#endif /* __PLAT_MXC_AHCI_SATA_H__ */
> diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
> index 524538a..f04e063 100644
> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
> @@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
>  struct platform_device *imx_add_imx_dma(void);
>  struct platform_device *imx_add_imx_sdma(char *name,
>  	resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
> +
> +#include <linux/ahci_platform.h>
> +struct imx_ahci_imx_data {
> +	const char *devid;
> +	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);
> -- 
> 1.7.1
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-09-20 20:30     ` Sascha Hauer
  0 siblings, 0 replies; 54+ messages in thread
From: Sascha Hauer @ 2011-09-20 20:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 31, 2011 at 11:50:31AM +0800, Richard Zhu wrote:
> Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
> Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
> ---
>  arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
>  arch/arm/mach-mx5/devices-imx53.h               |    4 +
>  arch/arm/plat-mxc/Makefile                      |    1 +
>  arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
>  arch/arm/plat-mxc/devices/Kconfig               |    4 +
>  arch/arm/plat-mxc/devices/Makefile              |    1 +
>  arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
>  arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
>  arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
>  9 files changed, 242 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
> 
> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
> index 7f20308..e1fadaf 100644
> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c
> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
> @@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = {
>  	.secondary = &esdhc4_ipg_clk,
>  };
>  
> diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
> new file mode 100644
> index 0000000..4f54816
> --- /dev/null
> +++ b/arch/arm/plat-mxc/ahci_sata.c
> @@ -0,0 +1,104 @@
> +/*
> + * 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 <linux/io.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/device.h>
> +#include <mach/ahci_sata.h>
> +
> +static struct clk *sata_clk, *sata_ref_clk;

These variables make the driver single instance only.

> +
> +/* AHCI module Initialization, if return 0, initialization is successful. */
> +int sata_init(struct device *dev, void __iomem *addr)

A global function with such a generic name is not a good idea.
Also I wonder how we want to convert this to devicetree when we
implement this as a platform specific hook. It should be done in the
driver.

> +{
> +	u32 tmpdata;
> +	int ret = 0;
> +	struct clk *clk;
> +
> +	sata_clk = clk_get(dev, "ahci");
> +	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");
> +		goto put_sata_clk;
> +	}
> +
> +	/* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */

So this function is loco specific or is the comment wrong?

> +	sata_ref_clk = clk_get(dev, "ahci_phy");
> +	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");
> +		goto put_sata_ref_clk;
> +	}
> +
> +	/* Get the AHB clock rate, and configure the TIMER1MS reg later */
> +	clk = clk_get(dev, "ahci_dma");
> +	if (IS_ERR(clk)) {
> +		dev_err(dev, "no dma clock.\n");
> +		ret = PTR_ERR(clk);
> +		goto release_sata_ref_clk;
> +	}
> +	tmpdata = clk_get_rate(clk) / 1000;
> +	clk_put(clk);
> +
> +	writel(tmpdata, addr + HOST_TIMER1MS);
> +
> +	tmpdata = readl(addr + HOST_CAP);
> +	if (!(tmpdata & HOST_CAP_SSS)) {
> +		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);
> +
> +	return 0;
> +
> +release_sata_ref_clk:
> +	clk_disable(sata_ref_clk);
> +put_sata_ref_clk:
> +	clk_put(sata_ref_clk);
> +release_sata_clk:
> +	clk_disable(sata_clk);
> +put_sata_clk:
> +	clk_put(sata_clk);
> +
> +	return ret;
> +}
> +
> +void sata_exit(struct device *dev)
> +{
> +	clk_disable(sata_ref_clk);
> +	clk_put(sata_ref_clk);
> +
> +	clk_disable(sata_clk);
> +	clk_put(sata_clk);
> +
> +}
> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
> index bd294ad..f63887b 100644
> --- a/arch/arm/plat-mxc/devices/Kconfig
> +++ b/arch/arm/plat-mxc/devices/Kconfig
> @@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
>  
>  config IMX_HAVE_PLATFORM_SPI_IMX
>  	bool
> +
> +config IMX_HAVE_PLATFORM_AHCI
> +	bool
> +	default y if ARCH_MX53
> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
> index b41bf97..e858ad9 100644
> --- a/arch/arm/plat-mxc/devices/Makefile
> +++ b/arch/arm/plat-mxc/devices/Makefile
> @@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.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_AHCI) +=  platform-ahci-imx.o
> diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> new file mode 100644
> index 0000000..9e1b460
> --- /dev/null
> +++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
> @@ -0,0 +1,66 @@
> +/*
> + * 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 <linux/dma-mapping.h>
> +#include <asm/sizes.h>
> +#include <mach/hardware.h>
> +#include <mach/devices-common.h>
> +#include <mach/ahci_sata.h>
> +
> +#define imx_ahci_imx_data_entry_single(soc, _devid)		\
> +	{								\
> +		.devid = _devid,					\
> +		.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_imx_data_entry_single(MX53, "imx53-ahci");
> +#endif
> +
> +static struct ahci_platform_data default_sata_pdata = {
> +	.init = sata_init,
> +	.exit = sata_exit,
> +};
> +
> +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,
> +		}, {
> +			.start = data->irq,
> +			.end = data->irq,
> +			.flags = IORESOURCE_IRQ,
> +		},
> +	};
> +
> +	if (pdata == NULL)
> +		pdata = &default_sata_pdata;
> +
> +	return imx_add_platform_device_dmamask(data->devid, 0,
> +			res, ARRAY_SIZE(res),
> +			pdata, sizeof(*pdata),  DMA_BIT_MASK(32));
> +}
> diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
> new file mode 100644
> index 0000000..ba297e1
> --- /dev/null
> +++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
> @@ -0,0 +1,33 @@
> +/*
> + * 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.
> + */
> +
> +#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 */
> +};
> +
> +extern int sata_init(struct device *dev, void __iomem *addr);
> +extern void sata_exit(struct device *dev);
> +#endif /* __PLAT_MXC_AHCI_SATA_H__ */
> diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
> index 524538a..f04e063 100644
> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
> @@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
>  struct platform_device *imx_add_imx_dma(void);
>  struct platform_device *imx_add_imx_sdma(char *name,
>  	resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
> +
> +#include <linux/ahci_platform.h>
> +struct imx_ahci_imx_data {
> +	const char *devid;
> +	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);
> -- 
> 1.7.1
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-08-31 10:03     ` Arnaud Patard (Rtp)
@ 2011-08-31 11:04       ` Eric Miao
  -1 siblings, 0 replies; 54+ messages in thread
From: Eric Miao @ 2011-08-31 11:04 UTC (permalink / raw)
  To: Arnaud Patard (Rtp)
  Cc: Richard Zhu, eric, eric.miao, linux-ide, kernel, avorontsov,
	jgarzik, linux-arm-kernel

Hi Arnaud,

You can just use Linus tree v3.1-rc4 as the base for this.

Sent from my iPhone

On Aug 31, 2011, at 6:03 PM, Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org> wrote:

> Richard Zhu <richard.zhu@linaro.org> writes:
> Hi,
> 
> 
>> @@ -1503,6 +1519,9 @@ static struct clk_lookup mx53_lookups[] = {
>>    _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
>>    _REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
>>    _REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
>> +    _REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk)
>> +    _REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk)
>> +    _REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk)
>> };
>> 
>> static void clk_tree_init(void)
> 
> Which tree has been used for this patch ? For instance, on current
> imx-features branch of Sascha's tree, there's a pata_imx clock defined
> here (see [1]). Should I try to apply it on top of some other branch ?
> 
> Arnaud
> 
> [1] http://git.pengutronix.de/?p=imx/linux-2.6.git;a=commit;h=03b20b07be130e44faf29f787c66ce5cce5afb2a
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-08-31 11:04       ` Eric Miao
  0 siblings, 0 replies; 54+ messages in thread
From: Eric Miao @ 2011-08-31 11:04 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Arnaud,

You can just use Linus tree v3.1-rc4 as the base for this.

Sent from my iPhone

On Aug 31, 2011, at 6:03 PM, Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org> wrote:

> Richard Zhu <richard.zhu@linaro.org> writes:
> Hi,
> 
> 
>> @@ -1503,6 +1519,9 @@ static struct clk_lookup mx53_lookups[] = {
>>    _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
>>    _REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
>>    _REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
>> +    _REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk)
>> +    _REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk)
>> +    _REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk)
>> };
>> 
>> static void clk_tree_init(void)
> 
> Which tree has been used for this patch ? For instance, on current
> imx-features branch of Sascha's tree, there's a pata_imx clock defined
> here (see [1]). Should I try to apply it on top of some other branch ?
> 
> Arnaud
> 
> [1] http://git.pengutronix.de/?p=imx/linux-2.6.git;a=commit;h=03b20b07be130e44faf29f787c66ce5cce5afb2a
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-08-31  3:50   ` Richard Zhu
@ 2011-08-31 10:03     ` Arnaud Patard (Rtp)
  -1 siblings, 0 replies; 54+ messages in thread
From: Arnaud Patard @ 2011-08-31 10:03 UTC (permalink / raw)
  To: Richard Zhu
  Cc: linux-arm-kernel, kernel, eric.miao, linux-ide, eric, avorontsov,
	jgarzik

Richard Zhu <richard.zhu@linaro.org> writes:
Hi,


> @@ -1503,6 +1519,9 @@ static struct clk_lookup mx53_lookups[] = {
>  	_REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
>  	_REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
>  	_REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
> +	_REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk)
> +	_REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk)
> +	_REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk)
>  };
>  
>  static void clk_tree_init(void)

Which tree has been used for this patch ? For instance, on current
imx-features branch of Sascha's tree, there's a pata_imx clock defined
here (see [1]). Should I try to apply it on top of some other branch ?

Arnaud

[1] http://git.pengutronix.de/?p=imx/linux-2.6.git;a=commit;h=03b20b07be130e44faf29f787c66ce5cce5afb2a

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-08-31 10:03     ` Arnaud Patard (Rtp)
  0 siblings, 0 replies; 54+ messages in thread
From: Arnaud Patard (Rtp) @ 2011-08-31 10:03 UTC (permalink / raw)
  To: linux-arm-kernel

Richard Zhu <richard.zhu@linaro.org> writes:
Hi,


> @@ -1503,6 +1519,9 @@ static struct clk_lookup mx53_lookups[] = {
>  	_REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
>  	_REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
>  	_REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
> +	_REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk)
> +	_REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk)
> +	_REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk)
>  };
>  
>  static void clk_tree_init(void)

Which tree has been used for this patch ? For instance, on current
imx-features branch of Sascha's tree, there's a pata_imx clock defined
here (see [1]). Should I try to apply it on top of some other branch ?

Arnaud

[1] http://git.pengutronix.de/?p=imx/linux-2.6.git;a=commit;h=03b20b07be130e44faf29f787c66ce5cce5afb2a

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
  2011-08-31  3:50 [PATCH V7 0/5] imx53 ahci driver v7 Richard Zhu
@ 2011-08-31  3:50   ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-31  3:50 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: jgarzik, kernel, linux-ide, avorontsov, eric, eric.miao, Richard Zhu

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
---
 arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
 arch/arm/mach-mx5/devices-imx53.h               |    4 +
 arch/arm/plat-mxc/Makefile                      |    1 +
 arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
 arch/arm/plat-mxc/devices/Kconfig               |    4 +
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
 arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
 9 files changed, 242 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

diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
index 7f20308..e1fadaf 100644
--- a/arch/arm/mach-mx5/clock-mx51-mx53.c
+++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
@@ -1397,6 +1397,22 @@ 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,
+};
+
+static struct clk ahci_phy_clk = {
+	.parent = &usb_phy1_clk,
+};
+
+static struct clk ahci_dma_clk = {
+	.parent = &ahb_clk,
+};
+
 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);
@@ -1503,6 +1519,9 @@ static struct clk_lookup mx53_lookups[] = {
 	_REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
 	_REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
 	_REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk)
 };
 
 static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/devices-imx53.h b/arch/arm/mach-mx5/devices-imx53.h
index c27fe8b..bcb3af1 100644
--- a/arch/arm/mach-mx5/devices-imx53.h
+++ b/arch/arm/mach-mx5/devices-imx53.h
@@ -40,3 +40,7 @@ extern const struct imx_imx_ssi_data imx53_imx_ssi_data[];
 extern const struct imx_imx_keypad_data imx53_imx_keypad_data;
 #define imx53_add_imx_keypad(pdata)	\
 	imx_add_imx_keypad(&imx53_imx_keypad_data, pdata)
+
+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, pdata)
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index d53c35f..cc8e65a 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -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_AHCI)	+= ahci_sata.o
 ifdef CONFIG_SND_IMX_SOC
 obj-y += ssi-fiq.o
 obj-y += ssi-fiq-ksym.o
diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
new file mode 100644
index 0000000..4f54816
--- /dev/null
+++ b/arch/arm/plat-mxc/ahci_sata.c
@@ -0,0 +1,104 @@
+/*
+ * 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 <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/device.h>
+#include <mach/ahci_sata.h>
+
+static struct clk *sata_clk, *sata_ref_clk;
+
+/* AHCI module Initialization, if return 0, initialization is successful. */
+int sata_init(struct device *dev, void __iomem *addr)
+{
+	u32 tmpdata;
+	int ret = 0;
+	struct clk *clk;
+
+	sata_clk = clk_get(dev, "ahci");
+	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");
+		goto put_sata_clk;
+	}
+
+	/* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
+	sata_ref_clk = clk_get(dev, "ahci_phy");
+	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");
+		goto put_sata_ref_clk;
+	}
+
+	/* Get the AHB clock rate, and configure the TIMER1MS reg later */
+	clk = clk_get(dev, "ahci_dma");
+	if (IS_ERR(clk)) {
+		dev_err(dev, "no dma clock.\n");
+		ret = PTR_ERR(clk);
+		goto release_sata_ref_clk;
+	}
+	tmpdata = clk_get_rate(clk) / 1000;
+	clk_put(clk);
+
+	writel(tmpdata, addr + HOST_TIMER1MS);
+
+	tmpdata = readl(addr + HOST_CAP);
+	if (!(tmpdata & HOST_CAP_SSS)) {
+		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);
+
+	return 0;
+
+release_sata_ref_clk:
+	clk_disable(sata_ref_clk);
+put_sata_ref_clk:
+	clk_put(sata_ref_clk);
+release_sata_clk:
+	clk_disable(sata_clk);
+put_sata_clk:
+	clk_put(sata_clk);
+
+	return ret;
+}
+
+void sata_exit(struct device *dev)
+{
+	clk_disable(sata_ref_clk);
+	clk_put(sata_ref_clk);
+
+	clk_disable(sata_clk);
+	clk_put(sata_clk);
+
+}
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index bd294ad..f63887b 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 
 config IMX_HAVE_PLATFORM_SPI_IMX
 	bool
+
+config IMX_HAVE_PLATFORM_AHCI
+	bool
+	default y if ARCH_MX53
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index b41bf97..e858ad9 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.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_AHCI) +=  platform-ahci-imx.o
diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
new file mode 100644
index 0000000..9e1b460
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
@@ -0,0 +1,66 @@
+/*
+ * 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 <linux/dma-mapping.h>
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+#include <mach/ahci_sata.h>
+
+#define imx_ahci_imx_data_entry_single(soc, _devid)		\
+	{								\
+		.devid = _devid,					\
+		.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_imx_data_entry_single(MX53, "imx53-ahci");
+#endif
+
+static struct ahci_platform_data default_sata_pdata = {
+	.init = sata_init,
+	.exit = sata_exit,
+};
+
+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,
+		}, {
+			.start = data->irq,
+			.end = data->irq,
+			.flags = IORESOURCE_IRQ,
+		},
+	};
+
+	if (pdata == NULL)
+		pdata = &default_sata_pdata;
+
+	return imx_add_platform_device_dmamask(data->devid, 0,
+			res, ARRAY_SIZE(res),
+			pdata, sizeof(*pdata),  DMA_BIT_MASK(32));
+}
diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
new file mode 100644
index 0000000..ba297e1
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#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 */
+};
+
+extern int sata_init(struct device *dev, void __iomem *addr);
+extern void sata_exit(struct device *dev);
+#endif /* __PLAT_MXC_AHCI_SATA_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 524538a..f04e063 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
 struct platform_device *imx_add_imx_dma(void);
 struct platform_device *imx_add_imx_sdma(char *name,
 	resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
+
+#include <linux/ahci_platform.h>
+struct imx_ahci_imx_data {
+	const char *devid;
+	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);
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms
@ 2011-08-31  3:50   ` Richard Zhu
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Zhu @ 2011-08-31  3:50 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Richard Zhu <richard.zhu@linaro.org>
Tested-By: Hector Oron Martinez <hector.oron@gmail.com>
---
 arch/arm/mach-mx5/clock-mx51-mx53.c             |   19 ++++
 arch/arm/mach-mx5/devices-imx53.h               |    4 +
 arch/arm/plat-mxc/Makefile                      |    1 +
 arch/arm/plat-mxc/ahci_sata.c                   |  104 +++++++++++++++++++++++
 arch/arm/plat-mxc/devices/Kconfig               |    4 +
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-ahci-imx.c   |   66 ++++++++++++++
 arch/arm/plat-mxc/include/mach/ahci_sata.h      |   33 +++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   10 ++
 9 files changed, 242 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

diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
index 7f20308..e1fadaf 100644
--- a/arch/arm/mach-mx5/clock-mx51-mx53.c
+++ b/arch/arm/mach-mx5/clock-mx51-mx53.c
@@ -1397,6 +1397,22 @@ 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,
+};
+
+static struct clk ahci_phy_clk = {
+	.parent = &usb_phy1_clk,
+};
+
+static struct clk ahci_dma_clk = {
+	.parent = &ahb_clk,
+};
+
 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);
@@ -1503,6 +1519,9 @@ static struct clk_lookup mx53_lookups[] = {
 	_REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
 	_REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
 	_REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk)
+	_REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk)
 };
 
 static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/devices-imx53.h b/arch/arm/mach-mx5/devices-imx53.h
index c27fe8b..bcb3af1 100644
--- a/arch/arm/mach-mx5/devices-imx53.h
+++ b/arch/arm/mach-mx5/devices-imx53.h
@@ -40,3 +40,7 @@ extern const struct imx_imx_ssi_data imx53_imx_ssi_data[];
 extern const struct imx_imx_keypad_data imx53_imx_keypad_data;
 #define imx53_add_imx_keypad(pdata)	\
 	imx_add_imx_keypad(&imx53_imx_keypad_data, pdata)
+
+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, pdata)
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index d53c35f..cc8e65a 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -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_AHCI)	+= ahci_sata.o
 ifdef CONFIG_SND_IMX_SOC
 obj-y += ssi-fiq.o
 obj-y += ssi-fiq-ksym.o
diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
new file mode 100644
index 0000000..4f54816
--- /dev/null
+++ b/arch/arm/plat-mxc/ahci_sata.c
@@ -0,0 +1,104 @@
+/*
+ * 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 <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/device.h>
+#include <mach/ahci_sata.h>
+
+static struct clk *sata_clk, *sata_ref_clk;
+
+/* AHCI module Initialization, if return 0, initialization is successful. */
+int sata_init(struct device *dev, void __iomem *addr)
+{
+	u32 tmpdata;
+	int ret = 0;
+	struct clk *clk;
+
+	sata_clk = clk_get(dev, "ahci");
+	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");
+		goto put_sata_clk;
+	}
+
+	/* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
+	sata_ref_clk = clk_get(dev, "ahci_phy");
+	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");
+		goto put_sata_ref_clk;
+	}
+
+	/* Get the AHB clock rate, and configure the TIMER1MS reg later */
+	clk = clk_get(dev, "ahci_dma");
+	if (IS_ERR(clk)) {
+		dev_err(dev, "no dma clock.\n");
+		ret = PTR_ERR(clk);
+		goto release_sata_ref_clk;
+	}
+	tmpdata = clk_get_rate(clk) / 1000;
+	clk_put(clk);
+
+	writel(tmpdata, addr + HOST_TIMER1MS);
+
+	tmpdata = readl(addr + HOST_CAP);
+	if (!(tmpdata & HOST_CAP_SSS)) {
+		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);
+
+	return 0;
+
+release_sata_ref_clk:
+	clk_disable(sata_ref_clk);
+put_sata_ref_clk:
+	clk_put(sata_ref_clk);
+release_sata_clk:
+	clk_disable(sata_clk);
+put_sata_clk:
+	clk_put(sata_clk);
+
+	return ret;
+}
+
+void sata_exit(struct device *dev)
+{
+	clk_disable(sata_ref_clk);
+	clk_put(sata_ref_clk);
+
+	clk_disable(sata_clk);
+	clk_put(sata_clk);
+
+}
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index bd294ad..f63887b 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 
 config IMX_HAVE_PLATFORM_SPI_IMX
 	bool
+
+config IMX_HAVE_PLATFORM_AHCI
+	bool
+	default y if ARCH_MX53
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index b41bf97..e858ad9 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.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_AHCI) +=  platform-ahci-imx.o
diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
new file mode 100644
index 0000000..9e1b460
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
@@ -0,0 +1,66 @@
+/*
+ * 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 <linux/dma-mapping.h>
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+#include <mach/ahci_sata.h>
+
+#define imx_ahci_imx_data_entry_single(soc, _devid)		\
+	{								\
+		.devid = _devid,					\
+		.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_imx_data_entry_single(MX53, "imx53-ahci");
+#endif
+
+static struct ahci_platform_data default_sata_pdata = {
+	.init = sata_init,
+	.exit = sata_exit,
+};
+
+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,
+		}, {
+			.start = data->irq,
+			.end = data->irq,
+			.flags = IORESOURCE_IRQ,
+		},
+	};
+
+	if (pdata == NULL)
+		pdata = &default_sata_pdata;
+
+	return imx_add_platform_device_dmamask(data->devid, 0,
+			res, ARRAY_SIZE(res),
+			pdata, sizeof(*pdata),  DMA_BIT_MASK(32));
+}
diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
new file mode 100644
index 0000000..ba297e1
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#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 */
+};
+
+extern int sata_init(struct device *dev, void __iomem *addr);
+extern void sata_exit(struct device *dev);
+#endif /* __PLAT_MXC_AHCI_SATA_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 524538a..f04e063 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -301,3 +301,13 @@ struct platform_device *__init imx_add_spi_imx(
 struct platform_device *imx_add_imx_dma(void);
 struct platform_device *imx_add_imx_sdma(char *name,
 	resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
+
+#include <linux/ahci_platform.h>
+struct imx_ahci_imx_data {
+	const char *devid;
+	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);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2011-09-23  8:58 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-30  9:56 [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms Richard Zhu
2011-08-30  9:56 ` Richard Zhu
2011-08-30  9:56 ` [PATCH V7 2/5] ahci_plt Add the board_ids and pi refer to different features Richard Zhu
2011-08-30  9:56   ` Richard Zhu
2011-08-30  9:56 ` [PATCH V7 3/5] MX53 Enable the AHCI SATA on MX53 ARD board Richard Zhu
2011-08-30  9:56   ` Richard Zhu
2011-08-30  9:56 ` [PATCH V7 4/5] MX53 Enable the AHCI SATA on MX53 LOCO board Richard Zhu
2011-08-30  9:56   ` Richard Zhu
2011-08-30  9:56 ` [PATCH V7 5/5] MX53 Enable the AHCI SATA on MX53 SMD board Richard Zhu
2011-08-30  9:56   ` Richard Zhu
2011-08-30 10:37 ` [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms Wolfram Sang
2011-08-30 10:37   ` Wolfram Sang
2011-08-30 10:43 ` Hector Oron
2011-08-30 10:43   ` Hector Oron
2011-08-31  2:08   ` Richard Zhu
2011-08-31  2:08     ` Richard Zhu
2011-08-31 12:57     ` Hector Oron
2011-08-31 12:57       ` Hector Oron
2011-09-01  3:09       ` Richard Zhu
2011-09-01  3:09         ` Richard Zhu
2011-09-05 18:06         ` Eric Miao
2011-09-05 18:06           ` Eric Miao
2011-09-06  8:46         ` Hector Oron
2011-09-06  8:46           ` Hector Oron
2011-09-06 13:25           ` Eric Miao
2011-09-06 13:25             ` Eric Miao
2011-09-22  9:30             ` Hector Oron
2011-09-22  9:30               ` Hector Oron
2011-09-22 12:19               ` Eric Miao
2011-09-22 12:19                 ` Eric Miao
2011-09-23  8:58                 ` Hector Oron
2011-09-23  8:58                   ` Hector Oron
2011-09-05 19:25       ` Arnaud Patard
2011-09-05 19:25         ` Arnaud Patard (Rtp)
2011-08-31  3:50 [PATCH V7 0/5] imx53 ahci driver v7 Richard Zhu
2011-08-31  3:50 ` [PATCH V7 1/5] AHCI Add the AHCI SATA feature on the MX53 platforms Richard Zhu
2011-08-31  3:50   ` Richard Zhu
2011-08-31 10:03   ` Arnaud Patard
2011-08-31 10:03     ` Arnaud Patard (Rtp)
2011-08-31 11:04     ` Eric Miao
2011-08-31 11:04       ` Eric Miao
2011-09-20 20:30   ` Sascha Hauer
2011-09-20 20:30     ` Sascha Hauer
2011-09-21  5:04     ` Richard Zhu
2011-09-21  5:04       ` Richard Zhu
2011-09-21  7:02       ` Sascha Hauer
2011-09-21  7:02         ` Sascha Hauer
2011-09-21  7:32         ` Shawn Guo
2011-09-21  7:32           ` Shawn Guo
2011-09-21  7:05       ` Richard Zhu
2011-09-21  7:05         ` Richard Zhu
2011-09-22 18:12         ` Jeff Garzik
2011-09-22 18:12           ` Jeff Garzik
2011-09-22 18:31         ` Anton Vorontsov
2011-09-22 18:31           ` Anton Vorontsov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.