imx53 ahci driver v7
Subsystems (5)
v7 cover imx53 ahci driver v7
*** BLURB HERE ***
This is the seventh iteration of the imx53 ahci patch. Changes between v5 and v7 are described in the following description.
ChangeLog v5->v6:
- Move the most ahci initialization codes from the board related files to the common ahci_sata file.
- Add the imx53 ahci's own ata_port_info definition in ahci_platform driver, since the 'ahci_pmp_retry_srst_ops' is required when imx53 ahci is present.
ChangeLog v6->v7:
- Define the default imx53 ahci platform data, reduce the modificatons on the board related files.
- Handle the sata_pwr_en pin obviously on smd board.
Richard Zhu (5):
AHCI Add the AHCI SATA feature on the MX53 platforms ahci_plt Add the board_ids and pi refer to different features MX53 Enable the AHCI SATA on MX53 ARD board
MX53 Enable the AHCI SATA on MX53 LOCO board
MX53 Enable the AHCI SATA on MX53 SMD board
arch/arm/mach-mx5/board-mx53_ard.c | 1 + arch/arm/mach-mx5/board-mx53_loco.c | 1 + arch/arm/mach-mx5/board-mx53_smd.c | 32 +++++++ 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 ++ drivers/ata/ahci_platform.c | 44 ++++++++-- 13 files changed, 314 insertions(+), 6 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
PATCH v7 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms
--- 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
arch/arm/mach-mx5/clock-mx51-mx53.c +19 -0
@@ -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 )
arch/arm/mach-mx5/devices-imx53.h +4 -0
@@ -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)
arch/arm/plat-mxc/Makefile +1 -0
@@ -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
arch/arm/plat-mxc/ahci_sata.c new file +104 -0
104 lines not on this page · raw message
arch/arm/plat-mxc/devices/Kconfig +4 -0
@@ -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
arch/arm/plat-mxc/devices/Makefile +1 -0
@@ -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
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +66 -0
66 lines not on this page · raw message
arch/arm/plat-mxc/include/mach/ahci_sata.h new file +33 -0
@@ -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__ */
arch/arm/plat-mxc/include/mach/devices-common.h +10 -0
@@ -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);
Signature · 1 line
1.7.1
PATCH v7 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms
Richard Zhu <[email protected]> writes:
Hi,
arch/arm/mach-mx5/clock-mx51-mx53.c static struct clk_lookup mx53_lookups[] = { · line 1527
Quoted 10 lines
arch/arm/mach-mx5/clock-mx51-mx53.c +3
-0@@ -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
PATCH v7 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms
Hi Arnaud,
You can just use Linus tree v3.1-rc4 as the base for this.
Sent from my iPhone
Quoted 27 lines · Arnaud Patard (Rtp)
Richard Zhu <[email protected]> writes:
Hi,arch/arm/mach-mx5/clock-mx51-mx53.c static struct clk_lookup mx53_lookups[] = { · line 1527
Quoted 10 lines
arch/arm/mach-mx5/clock-mx51-mx53.c +3
-0@@ -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_imxclock 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
Sascha Hauer
maintainerPATCH v7 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms
In reply to Richard ZhuQuoted 48 lines · Richard Zhu
Signed-off-by Richard Zhu <[email protected]>Tested-by Hector Oron Martinez <[email protected]>--- 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.harch/arm/mach-mx5/clock-mx51-mx53.c +0
-0@@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = { .secondary = &esdhc4_ipg_clk, };arch/arm/plat-mxc/ahci_sata.c new file +17
-0@@ -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.,
arch/arm/plat-mxc/ahci_sata.c line 27
Quoted 10 lines
arch/arm/plat-mxc/ahci_sata.c new file +10
-0+* 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.
arch/arm/plat-mxc/ahci_sata.c line 30
Quoted 3 lines
arch/arm/plat-mxc/ahci_sata.c new file +3
-0+ +/* 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.
Quoted 7 lines
arch/arm/plat-mxc/ahci_sata.c new file +7
-0+{ +u32 tmpdata; +int ret =0 ; +struct clk *clk; + + sata_clk =clk_get (dev,"ahci" ); +if (IS_ERR (sata_clk)) {
arch/arm/plat-mxc/ahci_sata.c line 47
Quoted 10 lines
arch/arm/plat-mxc/ahci_sata.c new file +10
-0+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?
Quoted 212 lines
arch/arm/plat-mxc/ahci_sata.c new file +57
-0+ 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); + +}arch/arm/plat-mxc/devices/Kconfig +4
-0@@ -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_MX53arch/arm/plat-mxc/devices/Makefile +1
-0@@ -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.oarch/arm/plat-mxc/devices/platform-ahci-imx.c new file +66
-0@@ -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 )); +}arch/arm/plat-mxc/include/mach/ahci_sata.h new file +33
-0@@ -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__ */ arch/arm/plat-mxc/include/mach/devices-common.h +10
-0@@ -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);Signature · 1 line
1.7.1
Signature · 4 lines
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 |
PATCH v7 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms
Hi Sascha:
Thanks for your comments.
Best Regard
Richard Zhu
Quoted 53 lines · Sascha Hauer
Quoted 52 lines · Richard Zhu
Signed-off-by Richard Zhu <[email protected]>Tested-by Hector Oron Martinez <[email protected]>---
?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 100644arch/arm/plat-mxc/devices/platform-ahci-imx.c?create mode 100644arch/arm/plat-mxc/include/mach/ahci_sata.harch/arm/mach-mx5/clock-mx51-mx53.c +0
-0@@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = { ? ? ? .secondary = &esdhc4_ipg_clk, ?};arch/arm/plat-mxc/ahci_sata.c new file +21
-0@@ -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>
Quoted 8 lines
arch/arm/plat-mxc/ahci_sata.c line 27
Quoted 6 lines
arch/arm/plat-mxc/ahci_sata.c new file +6
-0+#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.
Quoted 10 lines
arch/arm/plat-mxc/ahci_sata.c line 30
Quoted 4 lines
arch/arm/plat-mxc/ahci_sata.c new file +3
-0+ +/* 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.
Quoted 11 lines
Quoted 11 lines
arch/arm/plat-mxc/ahci_sata.c new file +11
-0+{ + ? ? 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);
Quoted 8 lines
arch/arm/plat-mxc/ahci_sata.c line 47
Quoted 6 lines
arch/arm/plat-mxc/ahci_sata.c new file +6
-0+ ? ? 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.
Quoted 220 lines
Quoted 209 lines
arch/arm/plat-mxc/ahci_sata.c new file +57
-0+ ? ? 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); + +}arch/arm/plat-mxc/devices/Kconfig +0
-0@@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX?config
IMX_HAVE_PLATFORM_SPI_IMX
? ? ? boolarch/arm/plat-mxc/devices/Kconfig +4
-0+ +config IMX_HAVE_PLATFORM_AHCI + ? ? bool + ? ? default y if ARCH_MX53arch/arm/plat-mxc/devices/Makefile +0
-0@@ -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
arch/arm/plat-mxc/devices/Makefile +1
-0+obj-$(CONFIG_IMX_HAVE_PLATFORM_AHCI) += ?platform-ahci-imx.oarch/arm/plat-mxc/devices/platform-ahci-imx.c new file +66
-0@@ -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)); +}arch/arm/plat-mxc/include/mach/ahci_sata.h new file +33
-0@@ -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__ */ arch/arm/plat-mxc/include/mach/devices-common.h +10
-1@@ -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); --Quoted 4 lines
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 |
Sascha Hauer
maintainerPATCH v7 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms
Quoted 88 lines · Richard Zhu
Hi Sascha:
Thanks for your comments.Best Regard
Richard ZhuQuoted 53 lines · Sascha Hauer
Quoted 52 lines · Richard Zhu
Signed-off-by Richard Zhu <[email protected]>Tested-by Hector Oron Martinez <[email protected]>---
?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 100644arch/arm/plat-mxc/devices/platform-ahci-imx.c?create mode 100644arch/arm/plat-mxc/include/mach/ahci_sata.harch/arm/mach-mx5/clock-mx51-mx53.c +0
-0@@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = { ? ? ? .secondary = &esdhc4_ipg_clk, ?};arch/arm/plat-mxc/ahci_sata.c new file +21
-0@@ -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> Quoted 8 lines
arch/arm/plat-mxc/ahci_sata.c line 27
Quoted 6 lines
arch/arm/plat-mxc/ahci_sata.c new file +6
-0+#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 intoahci_platform_datastruct. Then the clks can
be transferred by the platform data.
The current is preferred, refer to the second choice.Quoted 10 lines
arch/arm/plat-mxc/ahci_sata.c line 30
Quoted 4 lines
arch/arm/plat-mxc/ahci_sata.c new file +3
-0+ +/* 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).
Quoted 6 lines
Refer to you comments, do you means that the ->init and ->exit should be done in
ahci_platform.cdriver?
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.
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +34
-0@@ -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
Quoted 8 lines
Quoted 8 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c line 42
Quoted 8 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +8
-0+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, ...
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +11
-0+ +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, + ? ? ? ? ? ? }, {
Quoted 8 lines
Quoted 8 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c line 61
Quoted 8 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +8
-0+ ? ? ? ? ? ? ? ? ? ? .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);
}Signature · 4 lines
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 |
PATCH v7 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms
Quoted 96 lines · Sascha Hauer
Quoted 88 lines · Richard Zhu
Hi Sascha:
Thanks for your comments.Best Regard
Richard ZhuQuoted 53 lines · Sascha Hauer
Quoted 52 lines · Richard Zhu
Signed-off-by Richard Zhu <[email protected]>Tested-by Hector Oron Martinez <[email protected]>---
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.ccreate mode 100644arch/arm/plat-mxc/devices/platform-ahci-imx.ccreate mode 100644arch/arm/plat-mxc/include/mach/ahci_sata.harch/arm/mach-mx5/clock-mx51-mx53.c +0
-0@@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = { .secondary = &esdhc4_ipg_clk, };arch/arm/plat-mxc/ahci_sata.c new file +21
-0@@ -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> Quoted 8 lines
arch/arm/plat-mxc/ahci_sata.c line 27
Quoted 6 lines
arch/arm/plat-mxc/ahci_sata.c new file +6
-0+#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 intoahci_platform_datastruct. Then the clks can
be transferred by the platform data.
The current is preferred, refer to the second choice.Quoted 10 lines
arch/arm/plat-mxc/ahci_sata.c line 30
Quoted 4 lines
arch/arm/plat-mxc/ahci_sata.c new file +3
-0+ +/* 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).
Quoted 6 lines
Refer to you comments, do you means that the ->init and ->exit should be done in
ahci_platform.cdriver?
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.
Quoted 5 lines
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
Quoted 96 lines
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +34
-0@@ -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 Quoted 8 lines
Quoted 8 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c line 42
Quoted 8 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +8
-0+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, ...
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +11
-0+ +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, + }, {Quoted 8 lines
Quoted 8 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c line 61
Quoted 8 lines
arch/arm/plat-mxc/devices/platform-ahci-imx.c new file +8
-0+ .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*__initimx53_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); }Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v7 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms
In reply to Richard ZhuHi 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
Quoted 338 lines · Richard Zhu
Hi Sascha:
Thanks for your comments.Best Regard
Richard ZhuQuoted 53 lines · Sascha Hauer
Quoted 52 lines · Richard Zhu
Signed-off-by Richard Zhu <[email protected]>Tested-by Hector Oron Martinez <[email protected]>---
?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 100644arch/arm/plat-mxc/devices/platform-ahci-imx.c?create mode 100644arch/arm/plat-mxc/include/mach/ahci_sata.harch/arm/mach-mx5/clock-mx51-mx53.c +0
-0@@ -1397,6 +1397,22 @@ static struct clk esdhc4_mx53_clk = { ? ? ? .secondary = &esdhc4_ipg_clk, ?};arch/arm/plat-mxc/ahci_sata.c new file +21
-0@@ -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> Quoted 8 lines
arch/arm/plat-mxc/ahci_sata.c line 27
Quoted 6 lines
arch/arm/plat-mxc/ahci_sata.c new file +6
-0+#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 intoahci_platform_datastruct. Then the clks can
be transferred by the platform data.
The current is preferred, refer to the second choice.Quoted 10 lines
arch/arm/plat-mxc/ahci_sata.c line 30
Quoted 4 lines
arch/arm/plat-mxc/ahci_sata.c new file +3
-0+ +/* 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.cdriver?
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.Quoted 11 lines
Quoted 11 lines
arch/arm/plat-mxc/ahci_sata.c new file +11
-0+{ + ? ? 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);Quoted 8 lines
arch/arm/plat-mxc/ahci_sata.c line 47
Quoted 6 lines
arch/arm/plat-mxc/ahci_sata.c new file +6
-0+ ? ? 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.Quoted 220 lines
Quoted 209 lines
arch/arm/plat-mxc/ahci_sata.c new file +57
-0+ ? ? 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); + +}arch/arm/plat-mxc/devices/Kconfig +0
-0@@ -76,3 +76,7 @@ config IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX?config
IMX_HAVE_PLATFORM_SPI_IMX
? ? ? boolarch/arm/plat-mxc/devices/Kconfig +4
-0+ +config IMX_HAVE_PLATFORM_AHCI + ? ? bool + ? ? default y if ARCH_MX53arch/arm/plat-mxc/devices/Makefile +0
-0@@ -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
arch/arm/plat-mxc/devices/Makefile +1
-0+obj-$(CONFIG_IMX_HAVE_PLATFORM_AHCI) += ?platform-ahci-imx.oarch/arm/plat-mxc/devices/platform-ahci-imx.c new file +66
-0@@ -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)); +}arch/arm/plat-mxc/include/mach/ahci_sata.h new file +33
-0@@ -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__ */ arch/arm/plat-mxc/include/mach/devices-common.h +10
-1@@ -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); --Quoted 4 lines
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 |
PATCH v7 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms
Quoted 6 lines · Richard Zhu
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
PATCH v7 1/5 AHCI Add the AHCI SATA feature on the MX53 platforms
In reply to Richard ZhuHi Richard,
Quoted 3 lines · Richard Zhu
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'.
Quoted 2 lines
* separate the ahci to ahci common codes, ahci-pci driver and ahci-platform driver.
Done. Long time ago, actually.
Quoted 2 lines
* 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,
Signature · 2 lines
Anton Vorontsov Email: cbouatmailru at gmail.com
PATCH v7 2/5 ahci_plt Add the board_ids and pi refer to different features
In reply to Richard ZhuOn 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.
--- drivers/ata/ahci_platform.c | 44 +++++++++++++++++++++++++++++++++++++----- 1 files changed, 38 insertions(+), 6 deletions(-)
drivers/ata/ahci_platform.c +38 -6
@@ -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 )
Signature · 1 line
1.7.1
PATCH v7 2/5 ahci_plt Add the board_ids and pi refer to different features
Quoted 28 lines · 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 <[email protected]>Acked-by Eric Miao <[email protected]>---
?drivers/ata/ahci_platform.c | ? 44 +++++++++++++++++++++++++++++++++++++----- ?1 files changed, 38 insertions(+), 6 deletions(-)drivers/ata/ahci_platform.c +0
-0@@ -23,6 +23,41 @@?#include <
linux/ahci_platform.h>
?#include "ahci.h"drivers/ata/ahci_platform.c +8
-0+enum ahci_type { + ? ? ? AHCI, ? ? ? ? ? /* standard platform ahci */ + ? ? ? IMX53_AHCI, ? ? /* ahci on i.mx53 */ +}; + +static struct platform_device_id ahci_devtype[] = { + ? ? ? { + ? ? ? ? ? ? ? .name = "ahci",
drivers/ata/ahci_platform.c
Quoted 10 lines
drivers/ata/ahci_platform.c +10
-0+ ? ? ? ? ? ? ? .driver_data = AHCI, + ? ? ? }, { + ? ? ? ? ? ? ? .name = "imx53-ahci", + ? ? ? ? ? ? ? .driver_data = IMX53_AHCI, + ? ? ? }, { + ? ? ? ? ? ? ? /* sentinel */ + ? ? ? } +}; +MODULE_DEVICE_TABLE (platform, ahci_devtype); +
I still prefer this way as this is most flexible. We'll see how we can better organize this along with newly added ahci controllers.
Jeff,
Can you take this patch through? Or if you are good with this, we can also push this one along with the other patches to go through sascha's imx tree.
Quoted 53 lines
drivers/ata/ahci_platform.c +17
-0+ +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_templateahci_platform_sht= { ? ? ? ?AHCI_SHT("ahci_platform"),
?};drivers/ata/ahci_platform.c +3
-7@@ -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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v7 3/5 MX53 Enable the AHCI SATA on MX53 ARD board
In reply to Richard Zhu--- arch/arm/mach-mx5/board-mx53_ard.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-mx5/board-mx53_ard.c +1 -0
@@ -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 )
Signature · 1 line
1.7.1
PATCH v7 4/5 MX53 Enable the AHCI SATA on MX53 LOCO board
In reply to Richard Zhu--- arch/arm/mach-mx5/board-mx53_loco.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-mx5/board-mx53_loco.c +1 -0
@@ -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 )
Signature · 1 line
1.7.1
PATCH v7 5/5 MX53 Enable the AHCI SATA on MX53 SMD board
In reply to Richard Zhu--- arch/arm/mach-mx5/board-mx53_smd.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-)
arch/arm/mach-mx5/board-mx53_smd.c +32 -0
@@ -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 )
Signature · 1 line
1.7.1
v7 cover imx53 ahci driver v7
In reply to Richard ZhuRichard Zhu <[email protected]> writes:
Hi,
Quoted 12 lines
*** BLURB HERE ***
This is the seventh iteration of the imx53 ahci patch. Changes between v5 and v7 are described in the following description.ChangeLog
v5->v6:
- Move the most ahci initialization codes from the board related files to the commonahci_satafile.- Add the imx53 ahci's own
ata_port_infodefinition inahci_platformdriver, since the 'ahci_pmp_retry_srst_ops' is required when imx53 ahci is present.
Quoted 6 lines
ChangeLog
v6->v7:
- Define the default imx53 ahci platform data, reduce the modificatons on the board related files.- Handle the
sata_pwr_enpin obviously on smd board.
Sorry to disturb you with silly questions, but a v7 has already been sent yesterday [1]. Is this patchset the same as yesterday or did you modify some parts ?
Thanks,
Arnaud
[1]
http://lists.infradead.org/pipermail/linux-arm-kernel/2011-August/063195.html
v7 cover imx53 ahci driver v7
Hi Arnaud:
These serial patches are same to the v7 patch sent yesterday. Just add the cover-letter description, and the acked, tested info in the commit msg.
Best Regards
Richard Zhu
Quoted 32 lines · Arnaud Patard
Richard Zhu <[email protected]> writes:
Hi,
Quoted 12 lines
*** BLURB HERE ***
This is the seventh iteration of the imx53 ahci patch. Changes between v5 and v7 are described in the following description.ChangeLog
v5->v6:
?- Move the most ahci initialization codes from the board related files ?to the commonahci_satafile.?- Add the imx53 ahci's own
ata_port_infodefinition inahci_platform?driver, since the 'ahci_pmp_retry_srst_ops' is required when imx53 ?ahci is present.Quoted 6 lines
ChangeLog
v6->v7:
?- Define the default imx53 ahci platform data, reduce the modificatons ?on the board related files.?- Handle the
sata_pwr_enpin obviously on smd board.Sorry to disturb you with silly questions, but a v7 has already been sent yesterday [1]. Is this patchset the same as yesterday or did you modify some parts ?
Thanks,
Arnaud[1]
http://lists.infradead.org/pipermail/linux-arm-kernel/2011-August/063195.html