From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 10/14] drivers: mmc: add driver for Microchip PIC32 SDHCI controller.
Date: Wed, 13 Jan 2016 16:15:53 +0100 [thread overview]
Message-ID: <1452698153.3931.38.camel@gmail.com> (raw)
In-Reply-To: <1452593909-16184-11-git-send-email-purna.mandal@microchip.com>
Am Dienstag, den 12.01.2016, 15:48 +0530 schrieb Purna Chandra Mandal:
> From: Andrei Pistirica <andrei.pistirica@microchip.com>
>
> This driver implements platform specific glue and fixups for
> PIC32 internal SDHCI controller.
>
> Signed-off-by: Andrei Pistirica <andrei.pistirica@microchip.com>
> Signed-off-by: Sandeep Sheriker Mallikarjun <
> sandeepsheriker.mallikarjun at microchip.com>
> Signed-off-by: Purna Chandra Mandal <purna.mandal@microchip.com>
>
Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
nits below
> ---
>
> Changes in v3:
> - remove ofdata_to_platdata, and replace platdata with priv
> - replace pic32_ioremap() with ioremap()
>
> Changes in v2:
> - drop sdhci shared bus configuration (for shared interrupt, clock
> pins)
>
> drivers/mmc/Kconfig | 6 +++++
> drivers/mmc/Makefile | 2 +-
> drivers/mmc/pic32_sdhci.c | 61
> +++++++++++++++++++++++++++++++++++++++++++++++
> drivers/mmc/sdhci.c | 12 ++++++++++
> 4 files changed, 80 insertions(+), 1 deletion(-)
> create mode 100644 drivers/mmc/pic32_sdhci.c
>
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index ceae7bc..0b6f54b 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -31,4 +31,10 @@ config SH_SDHI
> help
> Support for the on-chip SDHI host controller on
> SuperH/Renesas ARM SoCs platform
>
> +config PIC32_SDHCI
> + bool "Microchip PIC32 on-chip SDHCI support"
> + depends on DM_MMC && MACH_PIC32
> + help
> + Support for the on-chip SDHCI support on Microchip PIC32
> platforms.
> +
> endmenu
> diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
> index 5d35705..c9c3e3e 100644
> --- a/drivers/mmc/Makefile
> +++ b/drivers/mmc/Makefile
> @@ -48,4 +48,4 @@ obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
> else
> obj-$(CONFIG_GENERIC_MMC) += mmc_write.o
> endif
> -
> +obj-$(CONFIG_PIC32_SDHCI) += pic32_sdhci.o
> diff --git a/drivers/mmc/pic32_sdhci.c b/drivers/mmc/pic32_sdhci.c
> new file mode 100644
> index 0000000..f8a5a23
> --- /dev/null
> +++ b/drivers/mmc/pic32_sdhci.c
> @@ -0,0 +1,61 @@
> +/*
> + * Support of SDHCI for Microchip PIC32 SoC.
> + *
> + * Copyright (C) 2015 Microchip Technology Inc.
> + * Andrei Pistirica <andrei.pistirica@microchip.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +#include <dm.h>
> +#include <common.h>
> +#include <sdhci.h>
> +#include <asm/errno.h>
> +#include <mach/pic32.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +static int pic32_sdhci_probe(struct udevice *dev)
> +{
> + struct sdhci_host *host = dev_get_priv(dev);
> + const void *fdt = gd->fdt_blob;
> + u32 f_min_max[2];
> + fdt_addr_t addr;
> + fdt_size_t size;
> + int ret;
> +
> + addr = fdtdec_get_addr_size(fdt, dev->of_offset, "reg",
> &size);
> + if (addr == FDT_ADDR_T_NONE)
> + return -EINVAL;
> +
> + host->ioaddr = ioremap(addr, size);
> + if (!host->ioaddr)
> + return -EINVAL;
this check can be dropped. ioremap() always returns a mapped address
> +
> + host->name = (char *)dev->name;
> + host->quirks = SDHCI_QUIRK_NO_HISPD_BIT;
> + host->bus_width = fdtdec_get_int(gd->fdt_blob, dev
> ->of_offset,
> + "bus-width", 4);
> +
> + ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
> + "clock-freq-min-max", f_min_max,
> 2);
> + if (ret) {
> + printf("sdhci: clock-freq-min-max not found\n");
> + return ret;
> + }
> +
> + return add_sdhci(host, f_min_max[1], f_min_max[0]);
> +}
> +
> +static const struct udevice_id pic32_sdhci_ids[] = {
> + { .compatible = "microchip,pic32mzda-sdhci" },
> + { }
> +};
> +
> +U_BOOT_DRIVER(pic32_sdhci_drv) = {
> + .name = "pic32_sdhci",
> + .id = UCLASS_MMC,
> + .of_match = pic32_sdhci_ids,
> + .probe = pic32_sdhci_probe,
> + .priv_auto_alloc_size = sizeof(struct sdhci_host),
> +};
> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
> index 02d71b9..f32fe67 100644
> --- a/drivers/mmc/sdhci.c
> +++ b/drivers/mmc/sdhci.c
> @@ -424,6 +424,18 @@ static void sdhci_set_ios(struct mmc *mmc)
> if (host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)
> ctrl &= ~SDHCI_CTRL_HISPD;
>
> +#if defined(CONFIG_PIC32_SDHCI)
> + /*
> + * In PIC32MZ[DA] due to h/w bug SDHCI fails detecting card
> when JTAG
> + * is not connected.
> + * To work-around this problem:
> + * - set Card_Detect_Signal_Selection bit in
> SDHCI_Host_Control register
> + * - clear Card_Detect_Test_Level bit in SDHCI_Host_Control
> register
> + */
> + ctrl |= SDHCI_CTRL_CD_TEST;
> + ctrl &= ~SDHCI_CTRL_CD_TEST_INS;
> +#endif
I think this could (or should?) be implemented with a new quirks bit
> +
> sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
> }
>
--
- Daniel
next prev parent reply other threads:[~2016-01-13 15:15 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 10:18 [U-Boot] [PATCH v3 00/14] Initial Microchip PIC32MZ[DA] Support Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 01/14] MIPS: initialize board_init_f() argument to zero Purna Chandra Mandal
2016-01-12 12:29 ` Daniel Schwierzeck
2016-01-14 5:29 ` Purna Chandra Mandal
2016-01-21 14:06 ` Daniel Schwierzeck
2016-01-12 10:18 ` [U-Boot] [PATCH v3 02/14] MIPS: initial infrastructure for Microchip PIC32 architecture Purna Chandra Mandal
2016-01-12 12:55 ` Daniel Schwierzeck
2016-01-13 14:56 ` Tom Rini
2016-01-12 10:18 ` [U-Boot] [PATCH v3 03/14] drivers: clk: Add clock driver for Microchip PIC32 Microcontroller Purna Chandra Mandal
2016-01-13 13:38 ` Daniel Schwierzeck
2016-01-14 5:34 ` Purna Chandra Mandal
2016-01-13 14:55 ` Tom Rini
2016-01-14 6:04 ` Purna Chandra Mandal
2016-01-14 12:30 ` Tom Rini
2016-01-12 10:18 ` [U-Boot] [PATCH v3 04/14] drivers: pinctrl: Add pinctrl driver for Microchip PIC32 Purna Chandra Mandal
2016-01-13 13:42 ` Daniel Schwierzeck
2016-01-13 14:55 ` Tom Rini
2016-01-13 20:10 ` Simon Glass
2016-01-12 10:18 ` [U-Boot] [PATCH v3 05/14] drivers: gpio: add driver for Microchip PIC32 GPIO controller Purna Chandra Mandal
2016-01-13 13:46 ` Daniel Schwierzeck
2016-01-13 14:08 ` Daniel Schwierzeck
2016-01-14 5:41 ` Purna Chandra Mandal
2016-01-13 14:55 ` Tom Rini
2016-01-13 20:10 ` Simon Glass
2016-01-14 10:15 ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 06/14] drivers: serial: add driver for Microchip PIC32 UART controller Purna Chandra Mandal
2016-01-13 13:49 ` Daniel Schwierzeck
2016-01-13 14:03 ` Daniel Schwierzeck
2016-01-14 5:42 ` Purna Chandra Mandal
2016-01-13 14:55 ` Tom Rini
2016-01-13 20:09 ` Simon Glass
2016-01-14 6:14 ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 07/14] drivers: ddr: Add DDR2 SDRAM controller driver for Microchip PIC32 Purna Chandra Mandal
2016-01-13 13:53 ` Daniel Schwierzeck
2016-01-13 14:55 ` Tom Rini
2016-01-13 20:09 ` Simon Glass
2016-01-12 10:18 ` [U-Boot] [PATCH v3 08/14] MIPS: Add support for Microchip PIC32MZ[DA] SoC family Purna Chandra Mandal
2016-01-13 14:49 ` Daniel Schwierzeck
2016-01-14 5:54 ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 09/14] board: Add Microchip PIC32MZ[DA]-Starter-Kit board Purna Chandra Mandal
2016-01-13 14:56 ` Tom Rini
2016-01-14 6:40 ` Purna Chandra Mandal
2016-01-13 15:03 ` Daniel Schwierzeck
2016-01-14 8:40 ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 10/14] drivers: mmc: add driver for Microchip PIC32 SDHCI controller Purna Chandra Mandal
2016-01-13 14:56 ` Tom Rini
2016-01-13 15:15 ` Daniel Schwierzeck [this message]
2016-01-14 9:18 ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 11/14] board: add SDHCI support for PIC32MZDASK board Purna Chandra Mandal
2016-01-13 14:56 ` Tom Rini
2016-01-14 8:31 ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 12/14] drivers: net: phy: add SMSC LAN8740 Phy support Purna Chandra Mandal
2016-01-13 14:56 ` Tom Rini
2016-01-13 15:19 ` Daniel Schwierzeck
2016-01-12 10:18 ` [U-Boot] [PATCH v3 13/14] drivers: net: Add ethernet driver for Microchip PIC32 Purna Chandra Mandal
2016-01-13 14:56 ` Tom Rini
2016-01-14 10:29 ` Purna Chandra Mandal
2016-01-13 15:37 ` Daniel Schwierzeck
2016-01-14 10:05 ` Purna Chandra Mandal
2016-01-14 14:01 ` Daniel Schwierzeck
2016-01-12 10:18 ` [U-Boot] [PATCH v3 14/14] board: Enable ethernet, tftpboot support to pic32mzdask board Purna Chandra Mandal
2016-01-13 14:56 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452698153.3931.38.camel@gmail.com \
--to=daniel.schwierzeck@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox