Common AHCI and SDHCI drivers
Subsystems (3)
cover Common AHCI and SDHCI drivers
From: Rob Herring <[email protected]>
This patch series enables common SDHCI and AHCI drivers for other platforms to use.
The AHCI driver is modified to support non-PCI versions of the controller.
The Samsung s5p mmc driver appears to be the cleanest implementation of an SDHCI controller based on reviewing various Linux SDHCI drivers. The FSL ESDHCI controller is also, but has quite a few quirks. IIRC, the omap HSMMC block is also based on SDHCI.
Rob
Rob Herring (5):
mmc: copy s5p to sdhci
mmc: sdhci: rework Samsung specfic code
mmc: sdhci: exit cmd on error status
scsi/ahci: ata id little endian fix
scsi/ahci: add support for non-PCI controllers
arch/arm/include/asm/arch-s5pc1xx/mmc.h | 72 ---- arch/arm/include/asm/arch-s5pc2xx/mmc.h | 72 ---- board/samsung/goni/goni.c | 4 +- board/samsung/universal_c210/universal.c | 6 +- common/cmd_scsi.c | 6 +- drivers/block/ahci.c | 64 ++++- drivers/mmc/Makefile | 3 +- drivers/mmc/s5p_mmc.c | 478 --------------------------- drivers/mmc/sdhci.c | 527 ++++++++++++++++++++++++++++++ include/sdhci.h | 18 + 10 files changed, 613 insertions(+), 637 deletions(-) delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/mmc.h delete mode 100644 arch/arm/include/asm/arch-s5pc2xx/mmc.h delete mode 100644 drivers/mmc/s5p_mmc.c create mode 100644 drivers/mmc/sdhci.c create mode 100644 include/sdhci.h
Signature · 1 line
1.7.4.1
PATCH 1/5 mmc: copy s5p to sdhci
From: Rob Herring <[email protected]>
The s5p mmc controller is a standard SDHCI controller with a few extra registers. So rename it to reflect that and so other platforms can use it.
--- drivers/mmc/Makefile | 3 +- drivers/mmc/s5p_mmc.c | 478 ------------------------------------------------- drivers/mmc/sdhci.c | 478 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 480 insertions(+), 479 deletions(-) delete mode 100644 drivers/mmc/s5p_mmc.c create mode 100644 drivers/mmc/sdhci.c
drivers/mmc/Makefile +2 -1
@@ -37,7 +37,8 @@ COBJS-$(CONFIG_MXC_MMC) += mxcmmc.o COBJS-$(CONFIG_OMAP3_MMC) += omap3_mmc.o COBJS-$(CONFIG_OMAP_HSMMC) += omap_hsmmc.o COBJS-$(CONFIG_PXA_MMC) += pxa_mmc.o -COBJS-$(CONFIG_S5P_MMC) += s5p_mmc.o +COBJS-$(CONFIG_S5P_MMC) += sdhci.o +COBJS-$(CONFIG_SDHCI) += sdhci.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/mmc/s5p_mmc.c deleted +0 -478
478 lines not on this page · raw message
drivers/mmc/sdhci.c new file +478 -0
478 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 2/5 mmc: sdhci: rework Samsung specfic code
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Move the register definitions into the sdhci.c file. Set the base address from the board init code.
The Samsung SDHCI controller has extra registers. Make them conditional on CONFIG_MMC_S5P.
--- arch/arm/include/asm/arch-s5pc1xx/mmc.h | 72 --------------------------- arch/arm/include/asm/arch-s5pc2xx/mmc.h | 72 --------------------------- board/samsung/goni/goni.c | 4 +- board/samsung/universal_c210/universal.c | 6 +- drivers/mmc/sdhci.c | 79 +++++++++++++++++++++++------ include/sdhci.h | 18 +++++++ 6 files changed, 85 insertions(+), 166 deletions(-) delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/mmc.h delete mode 100644 arch/arm/include/asm/arch-s5pc2xx/mmc.h create mode 100644 include/sdhci.h
arch/arm/include/asm/arch-s5pc1xx/mmc.h deleted +0 -72
@@ -1,72 +0,0 @@ -/* -* (C) Copyright 2009 SAMSUNG Electronics -* Minkyu Kang <[email protected]> -* -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -*/ - -#ifndef __ASM_ARCH_MMC_H_ -#define __ASM_ARCH_MMC_H_ - -#ifndef __ASSEMBLY__ -struct s5p_mmc { -unsigned int sysad; -unsigned short blksize; -unsigned short blkcnt; -unsigned int argument; -unsigned short trnmod; -unsigned short cmdreg; -unsigned int rspreg0; -unsigned int rspreg1; -unsigned int rspreg2; -unsigned int rspreg3; -unsigned int bdata; -unsigned int prnsts; -unsigned char hostctl; -unsigned char pwrcon; -unsigned char blkgap; -unsigned char wakcon; -unsigned short clkcon; -unsigned char timeoutcon; -unsigned char swrst; -unsigned int norintsts;/* errintsts */ -unsigned int norintstsen;/* errintstsen */ -unsigned int norintsigen;/* errintsigen */ -unsigned short acmd12errsts; -unsigned char res1[2 ]; -unsigned int capareg; -unsigned char res2[4 ]; -unsigned int maxcurr; -unsigned char res3[0x34 ]; -unsigned int control2; -unsigned int control3; -unsigned char res4[4 ]; -unsigned int control4; -unsigned char res5[0x6e ]; -unsigned short hcver; -unsigned char res6[0xFFF00 ]; -}; - -struct mmc_host { -struct s5p_mmc *reg; -unsigned int version;/* SDHCI spec. version */ -unsigned int clock;/* Current clock (MHz) */ -}; - -int s5p_mmc_init (int dev_index,int bus_width); - -#endif /* __ASSEMBLY__ */ -#endif
arch/arm/include/asm/arch-s5pc2xx/mmc.h deleted +0 -72
72 lines not on this page · raw message
board/samsung/goni/goni.c +2 -2
@@ -23,8 +23,8 @@*/ #include <common.h> +#include <sdhci.h> #include <asm/arch/gpio.h> -#include <asm/arch/mmc.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -93,6 +93,6 @@ int board_mmc_init(bd_t *bis) gpio_set_drv(&s5pc110_gpio->g0, i, GPIO_DRV_4X); } -return s5p_mmc_init (0 ,4 ); +return sdhci_mmc_init ((void *)samsung_get_base_mmc (),4 ); }#endif
board/samsung/universal_c210/universal.c +3 -3
@@ -23,10 +23,10 @@*/ #include <common.h> +#include <sdhci.h> #include <asm/io.h> #include <asm/arch/adc.h> #include <asm/arch/gpio.h> -#include <asm/arch/mmc.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -217,7 +217,7 @@ int board_mmc_init(bd_t *bis)* mmc0 : eMMC (8-bit buswidth) * mmc2 : SD card (4-bit buswidth) */ - err =s5p_mmc_init (0 ,8 ); + err =sdhci_mmc_init ((void *)samsung_get_base_mmc (),8 );/* * Check the T-flash detect pin
@@ -241,7 +241,7 @@ int board_mmc_init(bd_t *bis)/* GPK2[0:6] drv 4x */ gpio_set_drv (&gpio2->k2, i,GPIO_DRV_4X ); } - err =s5p_mmc_init (2 ,4 ); + err =sdhci_mmc_init ((void *)(samsung_get_base_mmc () +0x20000 ),4 ); }return err;
drivers/mmc/sdhci.c +62 -17
134 lines not on this page · raw message
include/sdhci.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Copyright 2011 Calxeda, Inc. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +*/ + +int sdhci_mmc_init (void *base,int bus_width); +
Signature · 1 line
1.7.4.1
PATCH 2/5 mmc: sdhci: rework Samsung specfic code
Dear Rob Herring,
Quoted 9 lines · In message <[email protected]> you wrote:
From: Rob Herring <[email protected]>
Move the register definitions into the
sdhci.cfile. Set the base address from the board init code.The Samsung SDHCI controller has extra registers. Make them conditional on
CONFIG_MMC_S5P.Signed-off-by Rob Herring <[email protected]>
Please run your patches through checkpatch before submittint. This should have shown you this:
...
board/samsung/universal_c210/universal.c int board_mmc_init(bd_t *bis) · line 244
Quoted 2 lines
board/samsung/universal_c210/universal.c +1
-1- err =s5p_mmc_init (2 ,4 ); + err =sdhci_mmc_init ((void *)(samsung_get_base_mmc () +0x20000 ),4 );
Line too long.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "I'm growing older, but not up." - Jimmy Buffett
PATCH 3/5 mmc: sdhci: exit cmd on error status
In reply to Rob HerringFrom: Rob Herring <[email protected]>
If the controller has an error condition, then stop polling for command complete and exit mmc_send_cmd.
--- drivers/mmc/sdhci.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/mmc/sdhci.c +4 -0
@@ -204,6 +204,10 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,writel (mask, &host->reg->norintsts);break ; } +if (mask & (1 <<15 )) { +writel (mask, &host->reg->norintsts); +return -1 ; + } }if (i == retry) {
Signature · 1 line
1.7.4.1
PATCH 4/5 scsi/ahci: ata id little endian fix
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The ata id string always needs swapping, not just on BE machines.
--- drivers/block/ahci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/block/ahci.c +1 -1
@@ -468,7 +468,7 @@ static char *ata_id_strcpy(u16 *target, u16 *src, int len) {int i;for (i =0 ; i < len /2 ; i++) - target[i] =le16_to_cpu (src[i]); + target[i] =swab16 (src[i]);return (char *)target; }
Signature · 1 line
1.7.4.1
PATCH 5/5 scsi/ahci: add support for non-PCI controllers
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Add support for AHCI controllers that are not PCI based.
--- common/cmd_scsi.c | 6 +++- drivers/block/ahci.c | 62 +++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 60 insertions(+), 8 deletions(-)
common/cmd_scsi.c +4 -2
@@ -47,7 +47,8 @@#define SCSI_DEV_ID 0x5288#else -#error no scsi device defined +#define SCSI_VEND_ID 0 +#define SCSI_DEV_ID 0#endif
@@ -174,7 +175,7 @@ removable: scsi_curr_dev =-1 ; } - +#ifdef CONFIG_PCI void scsi_init (void ) {int busdevfunc;
@@ -192,6 +193,7 @@ void scsi_init(void)scsi_low_level_init (busdevfunc); scsi_scan(1); } +#endif block_dev_desc_t *scsi_get_dev (int dev) {
drivers/block/ahci.c +56 -6
127 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 5/5 scsi/ahci: add support for non-PCI controllers
Dear Rob Herring,
Quoted 3 lines · In message <[email protected]> you wrote:
From: Rob Herring <[email protected]>
Add support for AHCI controllers that are not PCI based.
...
drivers/block/ahci.c void scsi_low_level_init(int busdevfunc) · line 698
Quoted 1 line
drivers/block/ahci.c +1
-0+memset ((void *)ataid,0 ,sizeof (hd_driveid_t *) *AHCI_MAX_PORTS );
This triggers a checkpatch error.
Why don;t you simply write:
memset((void *)ataid, 0, sizeof(ataid)):
?
Quoted 1 line
+
err_out:
labels should not be indented
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de For every complex problem, there is a solution that is simple, neat, and wrong. - Mark Twain
cover Common AHCI and SDHCI drivers
In reply to Rob HerringDear Rob Herring,
Quoted 11 lines · In message <[email protected]> you wrote:
From: Rob Herring <[email protected]>
This patch series enables common SDHCI and AHCI drivers for other platforms to use.
The AHCI driver is modified to support non-PCI versions of the controller.
The Samsung s5p mmc driver appears to be the cleanest implementation of an SDHCI controller based on reviewing various Linux SDHCI drivers. The FSL ESDHCI controller is also, but has quite a few quirks. IIRC, the omap HSMMC block is also based on SDHCI.
Which board(s) is(are) using this driver?
We don't want to add dead code, so we usually don;t add any drivers that have no actual users.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de One essential to success is that you desire be an all-obsessing one, your thoughts and aims be co-ordinated, and your energy be concentra- ted and applied without letup.
cover Common AHCI and SDHCI drivers
Quoted 15 lines · Wolfgang Denk
Dear Rob Herring,
Quoted 11 lines · In message<[email protected]> you wrote:
From: Rob Herring<[email protected]>
This patch series enables common SDHCI and AHCI drivers for other platforms to use.
The AHCI driver is modified to support non-PCI versions of the controller.
The Samsung s5p mmc driver appears to be the cleanest implementation of an SDHCI controller based on reviewing various Linux SDHCI drivers. The FSL ESDHCI controller is also, but has quite a few quirks. IIRC, the omap HSMMC block is also based on SDHCI.
Quoted 5 lines
Which board(s) is(are) using this driver?
We don't want to add dead code, so we usually don;t add any drivers that have no actual users.
For SDHCI, the Samsung boards will still use the code. It's really a clean-up to reflect that it should be generic code as is the Linux version. It will get used by more boards soon.
For AHCI, I'm not ready to submit the new platform. FSL MX53 can use this code as well, but I don't have h/w to test that.
Rob