From: Hong-Xing.Zhu@freescale.com (Richard Zhu)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO
Date: Mon, 14 Mar 2011 17:55:44 +0800 [thread overview]
Message-ID: <1300096544-1946-2-git-send-email-Hong-Xing.Zhu@freescale.com> (raw)
In-Reply-To: <1300096544-1946-1-git-send-email-Hong-Xing.Zhu@freescale.com>
Signed-off-by: Richard Zhu <Hong-Xing.Zhu@freescale.com>
---
arch/arm/mach-mx5/board-mx53_loco.c | 120 +++++++++++++++++++++++++++++++++++
1 files changed, 120 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c
index 0a18f8d..9a7bbea 100644
--- a/arch/arm/mach-mx5/board-mx53_loco.c
+++ b/arch/arm/mach-mx5/board-mx53_loco.c
@@ -23,11 +23,13 @@
#include <linux/fec.h>
#include <linux/delay.h>
#include <linux/gpio.h>
+#include <linux/ahci_platform.h>
#include <mach/common.h>
#include <mach/hardware.h>
#include <mach/imx-uart.h>
#include <mach/iomux-mx53.h>
+#include <mach/ahci_sata.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -203,6 +205,123 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = {
.bitrate = 100000,
};
+/* HW Initialization, if return 0, initialization is successful. */
+static int sata_init(struct device *dev, void __iomem *addr)
+{
+ void __iomem *mmio;
+ struct clk *clk;
+ int ret = 0;
+ u32 tmpdata;
+
+ clk = clk_get(dev, "imx_sata_clk");
+ ret = IS_ERR(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't get clock.\n");
+ return ret;
+ }
+ ret = clk_enable(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't enable clock.\n");
+ clk_put(clk);
+ return ret;
+ }
+
+ /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */
+ clk = clk_get(dev, "usb_phy1");
+ ret = IS_ERR(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
+ goto no_input_clk;
+ }
+ ret = clk_enable(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI Can't enable USB PHY1 clock.\n");
+ clk_put(clk);
+ goto no_input_clk;
+ }
+
+ /* Get the AHB clock rate, and configure the TIMER1MS reg later */
+ clk = clk_get(NULL, "ahb_clk");
+ ret = IS_ERR(clk);
+ if (ret) {
+ printk(KERN_ERR "IMX AHCI can't get AHB clock.\n");
+ goto no_clk;
+ }
+
+ mmio = ioremap(MX53_SATA_BASE_ADDR, SZ_2K);
+ if (mmio == NULL) {
+ printk(KERN_ERR "Failed to map SATA REGS\n");
+ goto no_clk;
+ }
+
+ tmpdata = readl(mmio + HOST_CAP);
+ if (!(tmpdata & HOST_CAP_SSS)) {
+ tmpdata |= HOST_CAP_SSS;
+ writel(tmpdata, mmio + HOST_CAP);
+ }
+
+ if (!(readl(mmio + HOST_PORTS_IMPL) & 0x1))
+ writel((readl(mmio + HOST_PORTS_IMPL) | 0x1),
+ mmio + HOST_PORTS_IMPL);
+
+ tmpdata = clk_get_rate(clk) / 1000;
+ writel(tmpdata, mmio + HOST_TIMER1MS);
+
+ iounmap(mmio);
+
+ return ret;
+
+no_clk:
+ clk = clk_get(dev, "usb_phy1");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+
+no_input_clk:
+ clk = clk_get(dev, "imx_sata_clk");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get clock.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+
+ return ret;
+}
+
+static void sata_exit(struct device *dev)
+{
+ struct clk *clk;
+
+ clk = clk_get(dev, "usb_phy1");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get USB PHY1 CLK.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+
+ clk = clk_get(dev, "imx_sata_clk");
+ if (IS_ERR(clk)) {
+ clk = NULL;
+ printk(KERN_ERR "IMX AHCI can't get clock.\n");
+ } else {
+ clk_disable(clk);
+ clk_put(clk);
+ }
+}
+
+static struct ahci_platform_data sata_data = {
+ .init = sata_init,
+ .exit = sata_exit,
+};
+
static void __init mx53_loco_board_init(void)
{
mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,
@@ -215,6 +334,7 @@ static void __init mx53_loco_board_init(void)
imx53_add_imx_i2c(1, &mx53_loco_i2c_data);
imx53_add_sdhci_esdhc_imx(0, NULL);
imx53_add_sdhci_esdhc_imx(2, NULL);
+ imx53_add_ahci_imx(0, &sata_data);
}
static void __init mx53_loco_timer_init(void)
--
1.7.1
next prev parent reply other threads:[~2011-03-14 9:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-14 9:55 [RFC PATCH 1/2] AHCI Add the AHCI SATA feature on MX53 platforms Richard Zhu
2011-03-14 9:55 ` Richard Zhu [this message]
2011-03-14 14:50 ` [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO Jeff Garzik
2011-03-15 9:02 ` Sascha Hauer
2011-03-16 9:49 ` Zhu Richard-R65037
2011-03-15 9:32 ` Sascha Hauer
2011-03-16 9:56 ` Zhu Richard-R65037
2011-03-14 14:50 ` [RFC PATCH 1/2] AHCI Add the AHCI SATA feature on MX53 platforms Jeff Garzik
2011-03-15 9:22 ` Sascha Hauer
2011-03-16 9:49 ` Zhu Richard-R65037
-- strict thread matches above, loose matches on Subject: below --
2011-03-10 8:59 Richard Zhu
2011-03-10 8:59 ` [RFC PATCH 2/2] MX53 Enable the AHCI SATA on MX53 LOCO Richard Zhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1300096544-1946-2-git-send-email-Hong-Xing.Zhu@freescale.com \
--to=hong-xing.zhu@freescale.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).