drivers: mmc: add driver for Microchip PIC32 SDHCI controller.
PATCH v2 8/13 drivers: mmc: add driver for Microchip PIC32 SDHCI controller.
PIC32 architecture has in-built SDHCI controller. This driver implements platform specific glue to use common SDHCI functionality.
---
Changes in v2:
- drop SDHCI shared bus configuration (for shared interrupt-and-clock pins)
drivers/mmc/Kconfig | 6 +++++ drivers/mmc/Makefile | 2 +- drivers/mmc/pic32_sdhci.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/sdhci.c | 12 +++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 drivers/mmc/pic32_sdhci.c
drivers/mmc/Kconfig +6 -0
@@ -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
drivers/mmc/Makefile +1 -1
@@ -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
drivers/mmc/pic32_sdhci.c new file +63 -0
63 lines not on this page · raw message
drivers/mmc/sdhci.c +12 -0
@@ -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 +sdhci_writeb (host, ctrl,SDHCI_HOST_CONTROL ); }
Signature · 1 line
1.8.3.1
PATCH v2 8/13 drivers: mmc: add driver for Microchip PIC32 SDHCI controller.
2016-01-04 15:01 GMT+01:00 Purna Chandra Mandal <[email protected]>:
Quoted 88 lines
PIC32 architecture has in-built SDHCI controller. This driver implements platform specific glue to use common SDHCI functionality.
Signed-off-by Andrei Pistirica <[email protected]>Signed-off-by Sandeep Sheriker Mallikarjun <[email protected]>Signed-off-by Purna Chandra Mandal <[email protected]>---
Changes in v2:
- drop SDHCI shared bus configuration (for shared interrupt-and-clock pins)drivers/mmc/Kconfig | 6 +++++ drivers/mmc/Makefile | 2 +- drivers/mmc/pic32_sdhci.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/sdhci.c | 12 +++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 drivers/mmc/pic32_sdhci.cdrivers/mmc/Kconfig +6
-0@@ -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. + endmenudrivers/mmc/Makefile +1
-1@@ -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.odrivers/mmc/pic32_sdhci.c new file +38
-0@@ -0,0 +1,63 @@ +/* +* Support of SDHCI for Microchip PIC32 SoC. +* +* Copyright (C) 2015 Microchip Technology Inc. +* Andrei Pistirica <[email protected]> +* +* 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); +u32 f_min_max[2 ]; +int ret; + + 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 int pic32_sdhci_ofdata_to_platdata (struct udevice *dev) +{ +struct sdhci_host *host =dev_get_priv (dev); +fdt_addr_t addr; +
drivers/mmc/pic32_sdhci.c line 48
Quoted 10 lines
drivers/mmc/pic32_sdhci.c new file +10
-0+ addr =dev_get_addr (dev); +if (addr ==FDT_ADDR_T_NONE ) +return -EINVAL ; + + host->name = (char *)dev->name; + host->ioaddr =pic32_ioremap (addr); + host->quirks =SDHCI_QUIRK_NO_HISPD_BIT ; + host->bus_width =fdtdec_get_int (gd->fdt_blob, dev->of_offset, +"bus-width" ,4 ); +return 0 ;
all that code could be moved to pic32_sdhci_probe()
Quoted 42 lines
drivers/mmc/pic32_sdhci.c new file +15
-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, + .ofdata_to_platdata = pic32_sdhci_ofdata_to_platdata, + .priv_auto_alloc_size =sizeof (struct sdhci_host ), +};drivers/mmc/sdhci.c +12
-1@@ -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 +sdhci_writeb (host, ctrl,SDHCI_HOST_CONTROL ); } --1.8.3.1
Signature · 1 line
- Daniel
PATCH v2 8/13 drivers: mmc: add driver for Microchip PIC32 SDHCI controller.
Quoted 92 lines · Daniel Schwierzeck
2016-01-04 15:01 GMT+01:00 Purna Chandra Mandal <[email protected]>:
Quoted 91 lines
PIC32 architecture has in-built SDHCI controller. This driver implements platform specific glue to use common SDHCI functionality.
Signed-off-by Andrei Pistirica <[email protected]>Signed-off-by Sandeep Sheriker Mallikarjun <[email protected]>Signed-off-by Purna Chandra Mandal <[email protected]>---
Changes in v2:
- drop SDHCI shared bus configuration (for shared interrupt-and-clock pins)drivers/mmc/Kconfig | 6 +++++ drivers/mmc/Makefile | 2 +- drivers/mmc/pic32_sdhci.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/sdhci.c | 12 +++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 drivers/mmc/pic32_sdhci.cdrivers/mmc/Kconfig +6
-0@@ -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. + endmenudrivers/mmc/Makefile +1
-1@@ -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.odrivers/mmc/pic32_sdhci.c new file +41
-0@@ -0,0 +1,63 @@ +/* +* Support of SDHCI for Microchip PIC32 SoC. +* +* Copyright (C) 2015 Microchip Technology Inc. +* Andrei Pistirica <[email protected]> +* +* 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); +u32 f_min_max[2 ]; +int ret; + + 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 int pic32_sdhci_ofdata_to_platdata (struct udevice *dev) +{ +struct sdhci_host *host =dev_get_priv (dev); +fdt_addr_t addr; + + addr =dev_get_addr (dev); +if (addr ==FDT_ADDR_T_NONE ) +return -EINVAL ;
Quoted 8 lines
drivers/mmc/pic32_sdhci.c line 48
Quoted 7 lines
drivers/mmc/pic32_sdhci.c new file +7
-0+ + host->name = (char *)dev->name; + host->ioaddr =pic32_ioremap (addr); + host->quirks =SDHCI_QUIRK_NO_HISPD_BIT ; + host->bus_width =fdtdec_get_int (gd->fdt_blob, dev->of_offset, +"bus-width" ,4 ); +return 0 ;all that code could be moved to
pic32_sdhci_probe()
ack.
Quoted 42 lines
Quoted 42 lines
drivers/mmc/pic32_sdhci.c new file +15
-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, + .ofdata_to_platdata = pic32_sdhci_ofdata_to_platdata, + .priv_auto_alloc_size =sizeof (struct sdhci_host ), +};drivers/mmc/sdhci.c +12
-1@@ -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 +sdhci_writeb (host, ctrl,SDHCI_HOST_CONTROL ); } --1.8.3.1