Add SDHCI driver for Tegra
Subsystems (5)
v3 cover Add SDHCI driver for Tegra
Third time is a charm?
Mostly just minor fixups this time, and addition of 8-bit support.
Changes since v1:
* Rewrote for sdhci-pltfm
* Dropped/moved some quirks
Changes since v2:
* Whitespace fixes
* Changed order of test in get_ro
* 8-bit support
* Setup gpio directions for inputs
PATCH 1/2 sdhci: add quirk for max len ADMA descriptors
Some controllers misparse segment length 0 as being 0, not 65536. Add a quirk to deal with it.
--- drivers/mmc/host/sdhci.c | 10 +++++++--- include/linux/mmc/sdhci.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +7 -3
@@ -1928,10 +1928,14 @@ int sdhci_add_host(struct sdhci_host *host)* of bytes. When doing hardware scatter/gather, each entry cannot * be larger than 64 KiB though. */ -if (host->flags &SDHCI_USE_ADMA ) - mmc->max_seg_size =65536 ; -else +if (host->flags &SDHCI_USE_ADMA ) { +if (host->quirks &SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC ) + mmc->max_seg_size =65535 ; +else + mmc->max_seg_size =65536 ; + }else { mmc->max_seg_size = mmc->max_req_size; + }/* * Maximum block size. This varies from controller to controller and
include/linux/mmc/sdhci.h +2 -0
@@ -83,6 +83,8 @@ struct sdhci_host {#define SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 (1<<28)/* Controller doesn't have HISPD bit field in HI-SPEED SD card */ #define SDHCI_QUIRK_NO_HISPD_BIT (1<<29) +/* Controller treats ADMA descriptors with length 0000h incorrectly */ +#define SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC (1<<30)int irq;/* Device IRQ */ void __iomem *ioaddr;/* Mapped address */
Signature · 1 line
1.7.3.GIT
Re: [PATCH 1/2] sdhci: add quirk for max len ADMA descriptors
Quoted 4 lines · Olof Johansson
Some controllers misparse segment length 0 as being 0, not 65536. Add a quirk to deal with it.
Signed-off-by Olof Johansson <[email protected]>
I tend to NACK it (but I am not the maintainer). I'd prefer to see a draft of your idea of a sdhci_add_host_fixup()-function :)
Regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [PATCH 1/2] sdhci: add quirk for max len ADMA descriptors
Quoted 8 lines · Wolfram Sang
Quoted 4 lines · Olof Johansson
Some controllers misparse segment length 0 as being 0, not 65536. Add a quirk to deal with it.
Signed-off-by Olof Johansson <[email protected]>I tend to NACK it (but I am not the maintainer). I'd prefer to see a draft of your idea of a sdhci_add_host_fixup()-function :)
See, I tend to get annoyed when I get asked to clean up others' messes because something I do is all of the sudden held to a higher standard than they have been.
So, I see one of three options:
* This go in, and I clean up some of the other drivers separately, _as promised_
* I do a sdhci_host_fixup() function, and only clean up my driver and the rest will be cleaned up... never, probably
* I just remove this quirk, repost my driver without it, carry the quirk out of tree and get on with other things that I actually care about
So, don't overdo it. I already promised I would help clean up this subsystem. Ok?
Thanks,
-Olof
Re: [PATCH 1/2] sdhci: add quirk for max len ADMA descriptors
Hi Olof,
happy new 2011, first of all.
Quoted 6 lines · Olof Johansson
Quoted 2 lines
I tend to NACK it (but I am not the maintainer). I'd prefer to see a draft of your idea of a sdhci_add_host_fixup()-function :)
See, I tend to get annoyed when I get asked to clean up others' messes because something I do is all of the sudden held to a higher standard than they have been.
If I wasn't stubborn, the bits would have run out in October already, and you'd be in a worse situation now ;) That put aside, I anticipated that Chris is going to pick up your patches nonetheless (which causes no hard feelings here), that's why I wrote "I am not the maintainer".
BTW I'd say cleaning up mess from the past is not that uncommon in kernel-development (think BKL), and raising standards is a good thing as well, no?
I see your point, though, that if you introduce a fixup()-function now, nobody will convert an existing driver to it. It would be nice to have the cleanup in one go, but until someone is driving/funding this bigger step, we have to fiddle with incremental improvements which need a bit more negotiation, it seems.
Kind regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 2/2 mmc: add sdhci-tegra driver for Tegra SoCs
In reply to Olof JohanssonSDHCI driver for Tegra. This driver plugs in as a new variant of sdhci-pltfm, using the platform data structure passed in to specify the GPIOs to use for card detect, write protect and card power enablement.
Original driver (of which only the header file is left):
The rest, which has been rewritten by now:
---
SDHCI driver for Tegra. Pretty straight forward, a few pieces of functionality left to fill in but nothing that stops it from going upstream. Board enablement submitted separately.
Changes since v1:
* Rewrote for sdhci-pltfm
Changes since v2:
* Whitespace fixes
* Changed order of test in get_ro
* 8-bit support
* Set gpio directions
arch/arm/mach-tegra/include/mach/sdhci.h | 28 ++++ drivers/mmc/host/Kconfig | 10 ++ drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sdhci-pltfm.c | 3 + drivers/mmc/host/sdhci-pltfm.h | 1 + drivers/mmc/host/sdhci-tegra.c | 251 ++++++++++++++++++++++++++++++ 6 files changed, 294 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-tegra/include/mach/sdhci.h create mode 100644 drivers/mmc/host/sdhci-tegra.c
arch/arm/mach-tegra/include/mach/sdhci.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* include/asm-arm/arch-tegra/include/mach/sdhci.h +* +* Copyright (C) 2009 Palm, Inc. +* Author: Yvonne Yip <[email protected]> +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +* +*/ +#ifndef __ASM_ARM_ARCH_TEGRA_SDHCI_H +#define __ASM_ARM_ARCH_TEGRA_SDHCI_H + +#include <linux/mmc/host.h> + +struct tegra_sdhci_platform_data { +int cd_gpio; +int wp_gpio; +int power_gpio; +}; + +#endif
drivers/mmc/host/Kconfig +10 -0
@@ -140,6 +140,16 @@ config MMC_SDHCI_ESDHC_IMX If unsure, say N. +config MMC_SDHCI_TEGRA + tristate "SDHCI platform support for the Tegra SD/MMC Controller" + depends on MMC_SDHCI_PLTFM && ARCH_TEGRA + select MMC_SDHCI_IO_ACCESSORS + help + This selects the Tegra SD/MMC controller. If you have a Tegra + platform with SD or MMC devices, say Y or M here. + + If unsure, say N. + config MMC_SDHCI_S3C tristate "SDHCI support on Samsung S3C SoC" depends on MMC_SDHCI && PLAT_SAMSUNG
drivers/mmc/host/Makefile +1 -0
@@ -39,6 +39,7 @@ obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-platform.o sdhci-platform-y := sdhci-pltfm.o sdhci-platform-$(CONFIG_MMC_SDHCI_CNS3XXX) += sdhci-cns3xxx.o sdhci-platform-$(CONFIG_MMC_SDHCI_ESDHC_IMX) += sdhci-esdhc-imx.o +sdhci-platform-$(CONFIG_MMC_SDHCI_TEGRA) += sdhci-tegra.o obj-$(CONFIG_MMC_SDHCI_OF) += sdhci-of.o sdhci-of-y := sdhci-of-core.o
drivers/mmc/host/sdhci-pltfm.c +3 -0
@@ -170,6 +170,9 @@ static const struct platform_device_id sdhci_pltfm_ids[] = { #ifdef CONFIG_MMC_SDHCI_ESDHC_IMX { "sdhci-esdhc-imx", (kernel_ulong_t)&sdhci_esdhc_imx_pdata }, #endif +#ifdef CONFIG_MMC_SDHCI_TEGRA + { "sdhci-tegra", (kernel_ulong_t)&sdhci_tegra_pdata }, +#endif { }, }; MODULE_DEVICE_TABLE(platform, sdhci_pltfm_ids);
drivers/mmc/host/sdhci-pltfm.h +1 -0
@@ -22,5 +22,6 @@ struct sdhci_pltfm_host {extern struct sdhci_pltfm_data sdhci_cns3xxx_pdata;extern struct sdhci_pltfm_data sdhci_esdhc_imx_pdata; +extern struct sdhci_pltfm_data sdhci_tegra_pdata;#endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */
drivers/mmc/host/sdhci-tegra.c new file +251 -0
251 lines not on this page · raw message
Signature · 1 line
1.7.3.GIT
Re: [PATCH 2/2] mmc: add sdhci-tegra driver for Tegra SoCs
Quoted 4 lines
Changes since v2:
* Whitespace fixes
* Changed order of test inget_ro
What benefit has the reordering? (And just to make sure: You still return -1 meaning "read-only". I assume this is intentional)
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [PATCH 2/2] mmc: add sdhci-tegra driver for Tegra SoCs
Quoted 7 lines · Wolfram Sang
Quoted 4 lines
Changes since v2:
* Whitespace fixes
* Changed order of test inget_roWhat benefit has the reordering? (And just to make sure: You still return -1 meaning "read-only". I assume this is intentional)\
Uh, thanks for the vague feedback last time. I thought that's what your concern with it was.
But yeah, defaulting to RW makes more sense. v4 coming once I know if you want me to rip out the new quirk or not.
-Olof
Re: [PATCH 2/2] mmc: add sdhci-tegra driver for Tegra SoCs
Hi Olof,
Quoted 2 lines · Olof Johansson
But yeah, defaulting to RW makes more sense. v4 coming once I know if you want me to rip out the new quirk or not.
I'll take a v4 with the remaining quirk for now, and we'd be extremely interested in seeing sdhci_ops->fixup work and quirk removal from you.
For what it's worth, Wolfram's not singling you out -- recently we've been consistently rejecting patches that add new SDHCI quirks and asking for rework. (See Takashi's JMicron 388 patch, for example.)
Thanks!
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [PATCH 2/2] mmc: add sdhci-tegra driver for Tegra SoCs
In reply to Wolfram SangQuoted 7 lines · Wolfram Sang
Quoted 4 lines
Changes since v2:
* Whitespace fixes
* Changed order of test inget_roWhat benefit has the reordering? (And just to make sure: You still return -1 meaning "read-only". I assume this is intentional)
Looking at drivers/mmc/core/sd.c:mmc_sd_setup_card(), returning <0 means no RO detection, and will print a warning to that effect. If no other RO-related quirks are included (i.e. such as SDHCI_QUIRK_INVERTED_WRITE_PROTECT), the value will be passed up through sdhci_get_ro and thus handled appropriately.
So on second look the code as it is seems correct to me.
Still, I have a 8-bit fix to incorporate, so I'll repost a v4 anyway.
-Olof
Re: [PATCH 2/2] mmc: add sdhci-tegra driver for Tegra SoCs
Quoted 9 lines · Olof Johansson
Quoted 7 lines · Wolfram Sang
Quoted 4 lines
Changes since v2:
* Whitespace fixes
* Changed order of test inget_roWhat benefit has the reordering? (And just to make sure: You still return -1 meaning "read-only". I assume this is intentional)
Quoted 7 lines
Looking at drivers/mmc/core/sd.c:mmc_sd_setup_card(), returning <0 means no RO detection, and will print a warning to that effect. If no other RO-related quirks are included (i.e. such as
SDHCI_QUIRK_INVERTED_WRITE_PROTECT), the value will be passed up throughsdhci_get_roand thus handled appropriately.So on second look the code as it is seems correct to me.
ACK. I misread the code before :( No wonder my comment seemed vague to you, sorry for that. I agree that the code is correct and the reordering helps readability. The only nitpick I'd have now is to return -ESOMETHING (-EINVAL?) instead of -1 to make the fault more obvious.
Kind regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |