qemu/tests/libqos/sdhci.h
<<
>>
Prefs
   1/*
   2 * libqos driver framework
   3 *
   4 * Copyright (c) 2018 Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
   5 *
   6 * This library is free software; you can redistribute it and/or
   7 * modify it under the terms of the GNU Lesser General Public
   8 * License version 2 as published by the Free Software Foundation.
   9 *
  10 * This library is distributed in the hope that it will be useful,
  11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13 * Lesser General Public License for more details.
  14 *
  15 * You should have received a copy of the GNU Lesser General Public
  16 * License along with this library; if not, see <http://www.gnu.org/licenses/>
  17 */
  18
  19#ifndef QGRAPH_QSDHCI_H
  20#define QGRAPH_QSDHCI_H
  21
  22#include "libqos/qgraph.h"
  23#include "pci.h"
  24
  25typedef struct QSDHCI QSDHCI;
  26typedef struct QSDHCI_MemoryMapped QSDHCI_MemoryMapped;
  27typedef struct QSDHCI_PCI  QSDHCI_PCI;
  28typedef struct QSDHCIProperties QSDHCIProperties;
  29
  30/* Properties common to all QSDHCI devices */
  31struct QSDHCIProperties {
  32    uint8_t version;
  33    uint8_t baseclock;
  34    struct {
  35        bool sdma;
  36        uint64_t reg;
  37    } capab;
  38};
  39
  40struct QSDHCI {
  41    uint16_t (*readw)(QSDHCI *s, uint32_t reg);
  42    uint64_t (*readq)(QSDHCI *s, uint32_t reg);
  43    void (*writeq)(QSDHCI *s, uint32_t reg, uint64_t val);
  44    QSDHCIProperties props;
  45};
  46
  47/* Memory Mapped implementation of QSDHCI */
  48struct QSDHCI_MemoryMapped {
  49    QOSGraphObject obj;
  50    QTestState *qts;
  51    QSDHCI sdhci;
  52    uint64_t addr;
  53};
  54
  55/* PCI implementation of QSDHCI */
  56struct QSDHCI_PCI {
  57    QOSGraphObject obj;
  58    QPCIDevice dev;
  59    QSDHCI sdhci;
  60    QPCIBar mem_bar;
  61};
  62
  63/**
  64 * qos_init_sdhci_mm(): external constructor used by all drivers/machines
  65 * that "contain" a #QSDHCI_MemoryMapped driver
  66 */
  67void qos_init_sdhci_mm(QSDHCI_MemoryMapped *sdhci, QTestState *qts,
  68                       uint32_t addr, QSDHCIProperties *common);
  69
  70#endif
  71