From patchwork Thu Mar 17 07:11:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhu X-Patchwork-Id: 649 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:44:21 -0000 Delivered-To: patches@linaro.org Received: by 10.151.46.5 with SMTP id y5cs31749ybj; Thu, 17 Mar 2011 00:11:21 -0700 (PDT) Received: by 10.52.173.79 with SMTP id bi15mr623612vdc.297.1300345881045; Thu, 17 Mar 2011 00:11:21 -0700 (PDT) Received: from ch1outboundpool.messaging.microsoft.com (ch1outboundpool.messaging.microsoft.com [216.32.181.185]) by mx.google.com with ESMTPS id k4si1700771vdu.98.2011.03.17.00.11.20 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 Mar 2011 00:11:21 -0700 (PDT) Received-SPF: neutral (google.com: 216.32.181.185 is neither permitted nor denied by best guess record for domain of R65037@freescale.com) client-ip=216.32.181.185; Authentication-Results: mx.google.com; spf=neutral (google.com: 216.32.181.185 is neither permitted nor denied by best guess record for domain of R65037@freescale.com) smtp.mail=R65037@freescale.com Received: from mail152-ch1-R.bigfish.com (216.32.181.172) by CH1EHSOBE018.bigfish.com (10.43.70.68) with Microsoft SMTP Server id 14.1.225.8; Thu, 17 Mar 2011 07:11:19 +0000 Received: from mail152-ch1 (localhost.localdomain [127.0.0.1]) by mail152-ch1-R.bigfish.com (Postfix) with ESMTP id B2F184380E6; Thu, 17 Mar 2011 07:11:19 +0000 (UTC) X-SpamScore: -3 X-BigFish: VS-3(zzbb2cKzz1202hzz8275bhz2dh2a8h668h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail152-ch1 (localhost.localdomain [127.0.0.1]) by mail152-ch1 (MessageSwitch) id 1300345879427812_2279; Thu, 17 Mar 2011 07:11:19 +0000 (UTC) Received: from CH1EHSMHS011.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.243]) by mail152-ch1.bigfish.com (Postfix) with ESMTP id 652D0D0004F; Thu, 17 Mar 2011 07:11:19 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS011.bigfish.com (10.43.70.11) with Microsoft SMTP Server (TLS) id 14.1.225.8; Thu, 17 Mar 2011 07:11:12 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.270.2; Thu, 17 Mar 2011 02:11:11 -0500 Received: from x-VirtualBox.ap.freescale.net (x-VirtualBox.ap.freescale.net [10.192.242.62]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id p2H7B1dK008815; Thu, 17 Mar 2011 02:11:08 -0500 (CDT) From: Richard Zhu To: CC: , , , , , , Richard Zhu Subject: [PATCH V1 3/3] MX53 Enable the AHCI SATA on MX53 LOCO Date: Thu, 17 Mar 2011 15:11:00 +0800 Message-ID: <1300345860-16574-3-git-send-email-Hong-Xing.Zhu@freescale.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1300345860-16574-1-git-send-email-Hong-Xing.Zhu@freescale.com> References: <1300345860-16574-1-git-send-email-Hong-Xing.Zhu@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com Signed-off-by: Richard Zhu --- arch/arm/mach-mx5/board-mx53_loco.c | 78 +++++++++++++++++++++++++++++++++++ 1 files changed, 78 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..4c00033 100644 --- a/arch/arm/mach-mx5/board-mx53_loco.c +++ b/arch/arm/mach-mx5/board-mx53_loco.c @@ -23,11 +23,13 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -203,6 +205,81 @@ 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) +{ + int ret = 0; + u32 tmpdata; + struct clk *clk; + struct ahci_platform_data *pdata = dev->platform_data; + + pdata->sata_clk = clk_get(dev, NULL); + if (IS_ERR(pdata->sata_clk)) { + dev_err(dev, "IMX AHCI can't get sata clock.\n"); + return PTR_ERR(pdata->sata_clk); + } + ret = clk_enable(pdata->sata_clk); + if (ret) { + dev_err(dev, "IMX AHCI can't enable sata clock.\n"); + clk_put(pdata->sata_clk); + return ret; + } + + /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */ + if (internal_clk_initialization(dev)) + goto release_sata_clk; + + /* Get the AHB clock rate, and configure the TIMER1MS reg later */ + clk = clk_get(NULL, "ahb"); + if (IS_ERR(clk)) { + dev_err(dev, "IMX AHCI can't get AHB clock.\n"); + ret = PTR_ERR(clk); + goto release_sata_ref_clk; + } + + 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); + + tmpdata = clk_get_rate(clk) / 1000; + clk_put(clk); + writel(tmpdata, addr + HOST_TIMER1MS); + + clk = NULL; + return ret; + +release_sata_ref_clk: + internal_clk_release(dev); + +release_sata_clk: + clk_disable(pdata->sata_clk); + clk_put(pdata->sata_clk); + + clk = NULL; + return ret; +} + +static void sata_exit(struct device *dev) +{ + struct ahci_platform_data *pdata = dev->platform_data; + + internal_clk_release(dev); + + clk_disable(pdata->sata_clk); + clk_put(pdata->sata_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 +292,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)