Skip to content

Commit

Permalink
mmc: add TS7800 FPGA based MMC controller driver
Browse files Browse the repository at this point in the history
add standard mmc/host controller driver for TS-7800v1
  • Loading branch information
Firas Ashkar committed Sep 21, 2022
1 parent 442412b commit d87a5ac
Show file tree
Hide file tree
Showing 5 changed files with 2,376 additions and 1 deletion.
1 change: 1 addition & 0 deletions arch/arm/mach-orion5x/ts78xx-fpga.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct fpga_devices {
/* embeddedTS */
struct fpga_device ts_rtc;
struct fpga_device ts_nand;
struct fpga_device ts_sdmmc;
struct fpga_device ts_rng;
};

Expand Down
56 changes: 56 additions & 0 deletions arch/arm/mach-orion5x/ts78xx-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,48 @@ static void ts78xx_ts_nand_unload(void)
platform_device_del(&ts78xx_ts_nand_device);
}

/*****************************************************************************
* SD/MMC Host controller
****************************************************************************/
#define TS_SDMMC_CTRL (TS78XX_FPGA_REGS_PHYS_BASE + 0x100)
#define TS_SDMMC_SDBUSY 0x41

static struct resource ts78xx_ts_sdmmc_resources[] = {
DEFINE_RES_MEM_NAMED(TS_SDMMC_CTRL, 0x100, "ts_sdmmc_ctrl"),
DEFINE_RES_IRQ_NAMED(TS_SDMMC_SDBUSY, "ts_sdmmc_sdbusy"),
};

static struct platform_device ts78xx_ts_sdmmc_device = {
.name = "ts7800v1_sdmmc",
.id = -1,
.resource = ts78xx_ts_sdmmc_resources,
.num_resources = ARRAY_SIZE(ts78xx_ts_sdmmc_resources),
};

static int ts78xx_ts_sdmmc_load(void)
{
int rc;

if (ts78xx_fpga.supports.ts_sdmmc.init == 0) {
rc = platform_device_register(&ts78xx_ts_sdmmc_device);
if (!rc)
ts78xx_fpga.supports.ts_sdmmc.init = 1;
} else {
rc = platform_device_add(&ts78xx_ts_sdmmc_device);
}

if (rc)
pr_info("SD/MMC host controller could not be registered: %d\n",
rc);

return rc;
}

static void ts78xx_ts_sdmmc_unload(void)
{
platform_device_del(&ts78xx_ts_sdmmc_device);
}

/*****************************************************************************
* HW RNG
****************************************************************************/
Expand Down Expand Up @@ -332,6 +374,7 @@ static void ts78xx_fpga_devices_zero_init(void)
{
ts78xx_fpga.supports.ts_rtc.init = 0;
ts78xx_fpga.supports.ts_nand.init = 0;
ts78xx_fpga.supports.ts_sdmmc.init = 0;
ts78xx_fpga.supports.ts_rng.init = 0;
}

Expand All @@ -348,8 +391,10 @@ static void ts78xx_fpga_supports(void)
case TS7800_REV_7:
case TS7800_REV_8:
case TS7800_REV_9:
case TS7800_REV_11:
ts78xx_fpga.supports.ts_rtc.present = 1;
ts78xx_fpga.supports.ts_nand.present = 1;
ts78xx_fpga.supports.ts_sdmmc.present = 1;
ts78xx_fpga.supports.ts_rng.present = 1;
break;
default:
Expand All @@ -360,11 +405,13 @@ static void ts78xx_fpga_supports(void)
ts78xx_fpga.id & 0xff);
ts78xx_fpga.supports.ts_rtc.present = 1;
ts78xx_fpga.supports.ts_nand.present = 1;
ts78xx_fpga.supports.ts_sdmmc.present = 1;
ts78xx_fpga.supports.ts_rng.present = 1;
break;
default:
ts78xx_fpga.supports.ts_rtc.present = 0;
ts78xx_fpga.supports.ts_nand.present = 0;
ts78xx_fpga.supports.ts_sdmmc.present = 0;
ts78xx_fpga.supports.ts_rng.present = 0;
}
}
Expand All @@ -386,6 +433,12 @@ static int ts78xx_fpga_load_devices(void)
ts78xx_fpga.supports.ts_nand.present = 0;
ret |= tmp;
}
if (ts78xx_fpga.supports.ts_sdmmc.present == 1) {
tmp = ts78xx_ts_sdmmc_load();
if (tmp)
ts78xx_fpga.supports.ts_sdmmc.present = 0;
ret |= tmp;
}
if (ts78xx_fpga.supports.ts_rng.present == 1) {
tmp = ts78xx_ts_rng_load();
if (tmp)
Expand All @@ -403,6 +456,8 @@ static int ts78xx_fpga_unload_devices(void)
ts78xx_ts_rtc_unload();
if (ts78xx_fpga.supports.ts_nand.present == 1)
ts78xx_ts_nand_unload();
if (ts78xx_fpga.supports.ts_sdmmc.present == 1)
ts78xx_ts_sdmmc_unload();
if (ts78xx_fpga.supports.ts_rng.present == 1)
ts78xx_ts_rng_unload();

Expand Down Expand Up @@ -575,3 +630,4 @@ MACHINE_START(TS78XX, "embeddedTS TS-78xx SBC")
.init_time = orion5x_timer_init,
.restart = orion5x_restart,
MACHINE_END

4 changes: 4 additions & 0 deletions drivers/mmc/host/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1106,5 +1106,9 @@ config MMC_OWL
This selects support for the SD/MMC Host Controller on
Actions Semi Owl SoCs.

config TS7800V1_SDMMC
tristate "TS-7800v1 FPGA based SD/MMC Host Controller support"
depends on MACH_TS78XX

config MMC_SDHCI_EXTERNAL_DMA
bool
3 changes: 2 additions & 1 deletion drivers/mmc/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ obj-$(CONFIG_MMC_USDHI6ROL0) += usdhi6rol0.o
obj-$(CONFIG_MMC_TOSHIBA_PCI) += toshsd.o
obj-$(CONFIG_MMC_BCM2835) += bcm2835.o
obj-$(CONFIG_MMC_OWL) += owl-mmc.o
obj-$(CONFIG_TS7800V1_SDMMC) += ts7800v1_sdmmc.o

obj-$(CONFIG_MMC_REALTEK_PCI) += rtsx_pci_sdmmc.o
obj-$(CONFIG_MMC_REALTEK_USB) += rtsx_usb_sdmmc.o
Expand Down Expand Up @@ -117,4 +118,4 @@ sdhci-xenon-driver-y += sdhci-xenon.o sdhci-xenon-phy.o
#
# SD Card driver for TS-78XX (Armada38x)
#
obj-$(CONFIG_TS_SDCARD) += tssdcard.o
obj-$(CONFIG_TS_SDCARD) += tssdcard.o
Loading

0 comments on commit d87a5ac

Please sign in to comment.