mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 13:41:31 +00:00
x86: Convert MMC to driver model
Convert the pci_mmc driver over to driver model and migrate all x86 boards that use it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: remove DM_MMC from edison_defconfig] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
52a1c2c68b
commit
b7c6baef28
8 changed files with 60 additions and 80 deletions
|
@ -98,6 +98,7 @@ config X86
|
||||||
imply DM_ETH
|
imply DM_ETH
|
||||||
imply DM_GPIO
|
imply DM_GPIO
|
||||||
imply DM_KEYBOARD
|
imply DM_KEYBOARD
|
||||||
|
imply DM_MMC
|
||||||
imply DM_RTC
|
imply DM_RTC
|
||||||
imply DM_SERIAL
|
imply DM_SERIAL
|
||||||
imply DM_SPI
|
imply DM_SPI
|
||||||
|
|
|
@ -11,18 +11,6 @@
|
||||||
#include <asm/mrccache.h>
|
#include <asm/mrccache.h>
|
||||||
#include <asm/post.h>
|
#include <asm/post.h>
|
||||||
|
|
||||||
static struct pci_device_id mmc_supported[] = {
|
|
||||||
{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT_SDIO },
|
|
||||||
{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT_SD },
|
|
||||||
{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT_EMMC2 },
|
|
||||||
{},
|
|
||||||
};
|
|
||||||
|
|
||||||
int cpu_mmc_init(bd_t *bis)
|
|
||||||
{
|
|
||||||
return pci_mmc_init("ValleyView SDHCI", mmc_supported);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef CONFIG_EFI_APP
|
#ifndef CONFIG_EFI_APP
|
||||||
int arch_cpu_init(void)
|
int arch_cpu_init(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,11 +16,6 @@
|
||||||
#include <asm/arch/msg_port.h>
|
#include <asm/arch/msg_port.h>
|
||||||
#include <asm/arch/quark.h>
|
#include <asm/arch/quark.h>
|
||||||
|
|
||||||
static struct pci_device_id mmc_supported[] = {
|
|
||||||
{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_SDIO },
|
|
||||||
{},
|
|
||||||
};
|
|
||||||
|
|
||||||
static void quark_setup_mtrr(void)
|
static void quark_setup_mtrr(void)
|
||||||
{
|
{
|
||||||
u32 base, mask;
|
u32 base, mask;
|
||||||
|
@ -328,11 +323,6 @@ int arch_early_init_r(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cpu_mmc_init(bd_t *bis)
|
|
||||||
{
|
|
||||||
return pci_mmc_init("Quark SDHCI", mmc_supported);
|
|
||||||
}
|
|
||||||
|
|
||||||
int arch_misc_init(void)
|
int arch_misc_init(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ENABLE_MRC_CACHE
|
#ifdef CONFIG_ENABLE_MRC_CACHE
|
||||||
|
|
|
@ -5,4 +5,4 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
obj-y += fsp_configs.o irq.o
|
obj-y += fsp_configs.o irq.o
|
||||||
obj-y += tnc.o topcliff.o
|
obj-y += tnc.o
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-2.0+
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <common.h>
|
|
||||||
#include <mmc.h>
|
|
||||||
#include <pci_ids.h>
|
|
||||||
|
|
||||||
static struct pci_device_id mmc_supported[] = {
|
|
||||||
{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_SDIO_0 },
|
|
||||||
{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_SDIO_1 },
|
|
||||||
{},
|
|
||||||
};
|
|
||||||
|
|
||||||
int cpu_mmc_init(bd_t *bis)
|
|
||||||
{
|
|
||||||
return pci_mmc_init("Topcliff SDHCI", mmc_supported);
|
|
||||||
}
|
|
|
@ -27,7 +27,6 @@ CONFIG_OF_EMBED=y
|
||||||
CONFIG_CPU=y
|
CONFIG_CPU=y
|
||||||
CONFIG_DFU_MMC=y
|
CONFIG_DFU_MMC=y
|
||||||
CONFIG_DFU_RAM=y
|
CONFIG_DFU_RAM=y
|
||||||
CONFIG_DM_MMC=y
|
|
||||||
CONFIG_DM_PCI_COMPAT=y
|
CONFIG_DM_PCI_COMPAT=y
|
||||||
CONFIG_USB_DWC3_GADGET=y
|
CONFIG_USB_DWC3_GADGET=y
|
||||||
CONFIG_USB_GADGET=y
|
CONFIG_USB_GADGET=y
|
||||||
|
|
|
@ -6,37 +6,71 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <dm.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <mapmem.h>
|
||||||
#include <sdhci.h>
|
#include <sdhci.h>
|
||||||
#include <asm/pci.h>
|
#include <asm/pci.h>
|
||||||
|
|
||||||
int pci_mmc_init(const char *name, struct pci_device_id *mmc_supported)
|
struct pci_mmc_plat {
|
||||||
|
struct mmc_config cfg;
|
||||||
|
struct mmc mmc;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pci_mmc_priv {
|
||||||
|
struct sdhci_host host;
|
||||||
|
void *base;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int pci_mmc_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct sdhci_host *mmc_host;
|
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
|
||||||
u32 iobase;
|
struct pci_mmc_plat *plat = dev_get_platdata(dev);
|
||||||
|
struct pci_mmc_priv *priv = dev_get_priv(dev);
|
||||||
|
struct sdhci_host *host = &priv->host;
|
||||||
|
u32 ioaddr;
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; ; i++) {
|
dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &ioaddr);
|
||||||
struct udevice *dev;
|
host->ioaddr = map_sysmem(ioaddr, 0);
|
||||||
|
host->name = dev->name;
|
||||||
ret = pci_find_device_id(mmc_supported, i, &dev);
|
ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
mmc_host = malloc(sizeof(struct sdhci_host));
|
host->mmc = &plat->mmc;
|
||||||
if (!mmc_host)
|
host->mmc->priv = &priv->host;
|
||||||
return -ENOMEM;
|
host->mmc->dev = dev;
|
||||||
|
upriv->mmc = host->mmc;
|
||||||
|
|
||||||
mmc_host->name = name;
|
return sdhci_probe(dev);
|
||||||
dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
|
|
||||||
mmc_host->ioaddr = (void *)(ulong)iobase;
|
|
||||||
mmc_host->quirks = 0;
|
|
||||||
mmc_host->max_clk = 0;
|
|
||||||
ret = add_sdhci(mmc_host, 0, 0);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
static int pci_mmc_bind(struct udevice *dev)
|
||||||
|
{
|
||||||
|
struct pci_mmc_plat *plat = dev_get_platdata(dev);
|
||||||
|
|
||||||
|
return sdhci_bind(dev, &plat->mmc, &plat->cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
U_BOOT_DRIVER(pci_mmc) = {
|
||||||
|
.name = "pci_mmc",
|
||||||
|
.id = UCLASS_MMC,
|
||||||
|
.bind = pci_mmc_bind,
|
||||||
|
.probe = pci_mmc_probe,
|
||||||
|
.ops = &sdhci_ops,
|
||||||
|
.priv_auto_alloc_size = sizeof(struct pci_mmc_priv),
|
||||||
|
.platdata_auto_alloc_size = sizeof(struct pci_mmc_plat),
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct pci_device_id mmc_supported[] = {
|
||||||
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT_SDIO) },
|
||||||
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT_SD) },
|
||||||
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT_EMMC2) },
|
||||||
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_SDIO) },
|
||||||
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_SDIO_0) },
|
||||||
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_SDIO_1) },
|
||||||
|
{},
|
||||||
|
};
|
||||||
|
|
||||||
|
U_BOOT_PCI_DEVICE(pci_mmc, mmc_supported);
|
||||||
|
|
|
@ -585,18 +585,6 @@ int cpu_mmc_init(bd_t *bis);
|
||||||
int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
|
int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
|
||||||
int mmc_get_env_dev(void);
|
int mmc_get_env_dev(void);
|
||||||
|
|
||||||
struct pci_device_id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pci_mmc_init() - set up PCI MMC devices
|
|
||||||
*
|
|
||||||
* This finds all the matching PCI IDs and sets them up as MMC devices.
|
|
||||||
*
|
|
||||||
* @name: Name to use for devices
|
|
||||||
* @mmc_supported: PCI IDs to search for, terminated by {0, 0}
|
|
||||||
*/
|
|
||||||
int pci_mmc_init(const char *name, struct pci_device_id *mmc_supported);
|
|
||||||
|
|
||||||
/* Set block count limit because of 16 bit register limit on some hardware*/
|
/* Set block count limit because of 16 bit register limit on some hardware*/
|
||||||
#ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT
|
#ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT
|
||||||
#define CONFIG_SYS_MMC_MAX_BLK_COUNT 65535
|
#define CONFIG_SYS_MMC_MAX_BLK_COUNT 65535
|
||||||
|
|
Loading…
Add table
Reference in a new issue