]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00139241-1 mx6 sata: refine the imx ahci sata driver
authorRichard Zhu <r65037@freescale.com>
Tue, 5 Jul 2011 08:29:47 +0000 (16:29 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:32:56 +0000 (08:32 +0200)
refine the imx ahci sata driver, when enable mx6q sata

Signed-off-by: Richard Zhu <r65037@freescale.com>
arch/arm/plat-mxc/Makefile
arch/arm/plat-mxc/ahci_sata.c [new file with mode: 0644]
arch/arm/plat-mxc/devices/Kconfig
arch/arm/plat-mxc/devices/Makefile
arch/arm/plat-mxc/devices/platform-ahci-imx.c
arch/arm/plat-mxc/include/mach/ahci_sata.h
arch/arm/plat-mxc/include/mach/devices-common.h

index 8b864bba27743adddd9634fd278683a90b60765c..458397cf779fa6c5705eb2396ed5b70fdd237a42 100755 (executable)
@@ -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 (file)
index 0000000..9dd607e
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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/kernel.h>
+#include <mach/ahci_sata.h>
+
+/* AHCI module Initialization, if return 0, initialization is successful. */
+int sata_init(void __iomem *addr, unsigned long timer1ms)
+{
+       u32 tmpdata;
+
+       /* Reset HBA */
+       writel(HOST_RESET, addr + HOST_CTL);
+
+       tmpdata = readl(addr + HOST_VERSIONR);
+       tmpdata = 0;
+       while (readl(addr + HOST_VERSIONR) == 0) {
+               tmpdata++;
+               if (tmpdata > 100000) {
+                       printk(KERN_ERR "Can't recover from RESET HBA!\n");
+                       break;
+               }
+       }
+
+       tmpdata = readl(addr + HOST_CAP);
+       if (!(tmpdata & HOST_CAP_SSS)) {
+               tmpdata |= HOST_CAP_SSS;
+               writel(tmpdata, addr + HOST_CAP);
+       }
+       tmpdata = readl(addr + HOST_CAP);
+
+       if (!(readl(addr + HOST_PORTS_IMPL) & 0x1))
+               writel((readl(addr + HOST_PORTS_IMPL) | 0x1),
+                       addr + HOST_PORTS_IMPL);
+
+       writel(timer1ms, addr + HOST_TIMER1MS);
+
+       return 0;
+}
index b6eda42e8e753a84ff036a476f8808e2cfe3b04e..554adb8a8e616f2c502d64e830e0667059eee10e 100755 (executable)
@@ -99,7 +99,7 @@ config IMX_HAVE_PLATFORM_IMX_VPU
 config IMX_HAVE_PLATFORM_IMX_DVFS
        bool
 
-config IMX_HAVE_PLATFORM_SATA_AHCI
+config IMX_HAVE_PLATFORM_AHCI
        bool
 
 config IMX_HAVE_PLATFORM_IMX_IIM
index c4203cfd6853859c5e7ee7a249f2a45437762b4e..992b71525eb81daddcde0a53f37989f1e9fe91e4 100755 (executable)
@@ -31,7 +31,7 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_IPUV3) +=  platform-imx_ipuv3.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_TVE) += platform-imx_tve.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_VPU) +=  platform-imx_vpu.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_DVFS) +=  platform-imx_dvfs.o
-obj-$(CONFIG_IMX_HAVE_PLATFORM_SATA_AHCI) +=  platform-ahci-imx.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_AHCI) +=  platform-ahci-imx.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_IIM)        += platform-imx-iim.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_GPU) +=  platform-mxc_gpu.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_OCOTP) += platform-imx-ocotp.o
index 9f730f1f0df49a5f14b6856c614d4eb99d66685b..30bfeaaac3d62aa5b1935cbf99cb08d9c056ecdf 100755 (executable)
        }
 
 #ifdef CONFIG_SOC_IMX53
-const struct imx_ahci_imx_data imx53_ahci_imx_data __initconst =
+const struct imx_ahci_data imx53_ahci_data __initconst =
        imx_ahci_data_entry_single(MX53);
 #endif
 
-struct platform_device *__init imx_add_ahci_imx(
-               const struct imx_ahci_imx_data *data,
+#ifdef CONFIG_SOC_IMX6Q
+const struct imx_ahci_data imx6q_ahci_data __initconst =
+       imx_ahci_data_entry_single(MX6Q);
+#endif
+
+struct platform_device *__init imx_add_ahci(
+               const struct imx_ahci_data *data,
                const struct ahci_platform_data *pdata)
 {
        struct resource res[] = {
index 25df23ee6a743f38d87a2f2ad5a11ec761f4e320..21189954426b799675b88008afb29cd212c86640 100755 (executable)
 enum {
        HOST_CAP = 0x00,
        HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */
+       HOST_CTL                = 0x04, /* global host control */
+       HOST_RESET              = (1 << 0),  /* reset controller; self-clear */
        HOST_PORTS_IMPL = 0x0c,
        HOST_TIMER1MS = 0xe0, /* Timer 1-ms */
+       HOST_VERSIONR = 0xfc, /* host version register*/
+
        /* Offest used to control the MPLL input clk */
        PHY_CR_CLOCK_FREQ_OVRD = 0x12,
        /* Port0 SATA Status */
@@ -48,4 +52,5 @@ enum {
        SATA_PHY_CR_CLOCK_MPLL_TST = 0x0017,
 };
 
+extern int sata_init(void __iomem *addr, unsigned long timer1ms);
 #endif /* __PLAT_MXC_AHCI_SATA_H__ */
index 01466e51468094428f7d3635c0600ad2a153b9ff..f9412992a2beba52a075786f6f23cb0c5abadfdd 100755 (executable)
@@ -354,13 +354,13 @@ struct platform_device *__init imx_add_tve(
                const struct fsl_mxc_tve_platform_data *pdata);
 
 #include <linux/ahci_platform.h>
-struct imx_ahci_imx_data {
+struct imx_ahci_data {
        int id;
        resource_size_t iobase;
        resource_size_t irq;
 };
-struct platform_device *__init imx_add_ahci_imx(
-               const struct imx_ahci_imx_data *data,
+struct platform_device *__init imx_add_ahci(
+               const struct imx_ahci_data *data,
                const struct ahci_platform_data *pdata);
 
 struct imx_iim_data {