From patchwork Mon Apr 11 08:05:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhu X-Patchwork-Id: 943 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:47:38 -0000 Delivered-To: patches@linaro.org Received: by 10.68.59.138 with SMTP id z10cs28912pbq; Mon, 11 Apr 2011 01:06:21 -0700 (PDT) Received: by 10.216.243.143 with SMTP id k15mr224860wer.98.1302509180355; Mon, 11 Apr 2011 01:06:20 -0700 (PDT) Received: from AM1EHSOBE002.bigfish.com (am1ehsobe002.messaging.microsoft.com [213.199.154.205]) by mx.google.com with ESMTPS id h28si10299506wes.100.2011.04.11.01.06.19 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Apr 2011 01:06:20 -0700 (PDT) Received-SPF: neutral (google.com: 213.199.154.205 is neither permitted nor denied by best guess record for domain of R65037@freescale.com) client-ip=213.199.154.205; Authentication-Results: mx.google.com; spf=neutral (google.com: 213.199.154.205 is neither permitted nor denied by best guess record for domain of R65037@freescale.com) smtp.mail=R65037@freescale.com Received: from mail50-am1-R.bigfish.com (10.3.201.245) by AM1EHSOBE002.bigfish.com (10.3.204.22) with Microsoft SMTP Server id 14.1.225.8; Mon, 11 Apr 2011 08:06:19 +0000 Received: from mail50-am1 (localhost.localdomain [127.0.0.1]) by mail50-am1-R.bigfish.com (Postfix) with ESMTP id 22F0519580DD; Mon, 11 Apr 2011 08:06:19 +0000 (UTC) X-SpamScore: -3 X-BigFish: VS-3(zzbb2cKzz1202hzz8275bhz2dh2a8h668h839h61h) 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 mail50-am1 (localhost.localdomain [127.0.0.1]) by mail50-am1 (MessageSwitch) id 1302509178759250_22722; Mon, 11 Apr 2011 08:06:18 +0000 (UTC) Received: from AM1EHSMHS015.bigfish.com (unknown [10.3.201.241]) by mail50-am1.bigfish.com (Postfix) with ESMTP id ABAD71A9804C; Mon, 11 Apr 2011 08:06:18 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS015.bigfish.com (10.3.207.153) with Microsoft SMTP Server (TLS) id 14.1.225.8; Mon, 11 Apr 2011 08:06:18 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.270.2; Mon, 11 Apr 2011 03:06:03 -0500 Received: from x-VirtualBox.ap.freescale.net (x-VirtualBox.ap.freescale.net [10.192.242.110]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p3B85u4G016838; Mon, 11 Apr 2011 03:06:01 -0500 (CDT) From: Richard Zhu To: CC: , , , , , , Richard Zhu Subject: [PATCH V3 2/2] MX53 Enable the AHCI SATA on MX53 LOCO Date: Mon, 11 Apr 2011 16:05:53 +0800 Message-ID: <1302509153-30326-2-git-send-email-Hong-Xing.Zhu@freescale.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1302509153-30326-1-git-send-email-Hong-Xing.Zhu@freescale.com> References: <1302509153-30326-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 | 76 +++++++++++++++++++++++++++++++++++ 1 files changed, 76 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..489830a 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 @@ -38,6 +40,8 @@ #define LOCO_FEC_PHY_RST IMX_GPIO_NR(7, 6) +static struct clk *sata_clk, *sata_ref_clk; + static iomux_v3_cfg_t mx53_loco_pads[] = { /* FEC */ MX53_PAD_FEC_MDC__FEC_MDC, @@ -203,6 +207,77 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = { .bitrate = 100000, }; +/* HW Initialization, if return 0, initialization is successful. */ +static int mx53_loco_sata_init(struct device *dev, void __iomem *addr) +{ + int ret = 0; + struct clk *clk; + + sata_clk = clk_get(dev, NULL); + if (IS_ERR(sata_clk)) { + dev_err(dev, "no sata clock.\n"); + return PTR_ERR(sata_clk); + } + ret = clk_enable(sata_clk); + if (ret) { + dev_err(dev, "can't enable sata clock.\n"); + clk_put(sata_clk); + return ret; + } + + /* FSL IMX AHCI SATA uses the internal usb phy1 clk on loco */ + sata_ref_clk = clk_get(NULL, "usb_phy1"); + if (IS_ERR(sata_ref_clk)) { + dev_err(dev, "no sata ref clock.\n"); + ret = PTR_ERR(sata_ref_clk); + goto release_sata_clk; + } + ret = clk_enable(sata_ref_clk); + if (ret) { + dev_err(dev, "can't enable sata ref clock.\n"); + clk_put(sata_ref_clk); + goto release_sata_clk; + } + + /* Get the AHB clock rate, and configure the TIMER1MS reg later */ + clk = clk_get(NULL, "ahb"); + if (IS_ERR(clk)) { + dev_err(dev, "no ahb clock.\n"); + ret = PTR_ERR(clk); + goto release_sata_ref_clk; + } + + sata_init(addr, clk); + + clk = NULL; + return ret; + +release_sata_ref_clk: + clk_disable(sata_ref_clk); + clk_put(sata_ref_clk); + +release_sata_clk: + clk_disable(sata_clk); + clk_put(sata_clk); + + clk = NULL; + return ret; +} + +static void sata_exit(struct device *dev) +{ + clk_disable(sata_ref_clk); + clk_put(sata_ref_clk); + + clk_disable(sata_clk); + clk_put(sata_clk); +} + +static struct ahci_platform_data sata_data = { + .init = mx53_loco_sata_init, + .exit = sata_exit, +}; + static void __init mx53_loco_board_init(void) { mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads, @@ -215,6 +290,7 @@ static void __init mx53_loco_board_init(void) imx53_add_imx_i2c(1, &mx53_loco_i2c_data); imx53_add_sdhci_esdhc_imx(0, NULL); imx53_add_sdhci_esdhc_imx(2, NULL); + imx53_add_ahci_imx(0, &sata_data); } static void __init mx53_loco_timer_init(void)