uboot/drivers/mmc/pic32_sdhci.c
<<
>>
Prefs
   1/*
   2 * Support of SDHCI for Microchip PIC32 SoC.
   3 *
   4 * Copyright (C) 2015 Microchip Technology Inc.
   5 * Andrei Pistirica <andrei.pistirica@microchip.com>
   6 *
   7 * SPDX-License-Identifier:     GPL-2.0+
   8 */
   9
  10#include <dm.h>
  11#include <common.h>
  12#include <sdhci.h>
  13#include <linux/errno.h>
  14#include <mach/pic32.h>
  15
  16DECLARE_GLOBAL_DATA_PTR;
  17
  18static int pic32_sdhci_probe(struct udevice *dev)
  19{
  20        struct sdhci_host *host = dev_get_priv(dev);
  21        const void *fdt = gd->fdt_blob;
  22        u32 f_min_max[2];
  23        fdt_addr_t addr;
  24        fdt_size_t size;
  25        int ret;
  26
  27        addr = fdtdec_get_addr_size(fdt, dev->of_offset, "reg", &size);
  28        if (addr == FDT_ADDR_T_NONE)
  29                return -EINVAL;
  30
  31        host->ioaddr    = ioremap(addr, size);
  32        host->name      = dev->name;
  33        host->quirks    = SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_NO_CD;
  34        host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
  35                                        "bus-width", 4);
  36
  37        ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
  38                                   "clock-freq-min-max", f_min_max, 2);
  39        if (ret) {
  40                printf("sdhci: clock-freq-min-max not found\n");
  41                return ret;
  42        }
  43
  44        ret = add_sdhci(host, f_min_max[1], f_min_max[0]);
  45        if (ret)
  46                return ret;
  47        host->mmc->dev = dev;
  48
  49        return 0;
  50}
  51
  52static const struct udevice_id pic32_sdhci_ids[] = {
  53        { .compatible = "microchip,pic32mzda-sdhci" },
  54        { }
  55};
  56
  57U_BOOT_DRIVER(pic32_sdhci_drv) = {
  58        .name                   = "pic32_sdhci",
  59        .id                     = UCLASS_MMC,
  60        .of_match               = pic32_sdhci_ids,
  61        .probe                  = pic32_sdhci_probe,
  62        .priv_auto_alloc_size   = sizeof(struct sdhci_host),
  63};
  64