125b6a6f1Skrish_iyer /* 225b6a6f1Skrish_iyer * Copyright 2018 Haiku, Inc. All rights reserved. 325b6a6f1Skrish_iyer * Distributed under the terms of the MIT License. 425b6a6f1Skrish_iyer * 525b6a6f1Skrish_iyer * Authors: 625b6a6f1Skrish_iyer * B Krishnan Iyer, krishnaniyer97@gmail.com 725b6a6f1Skrish_iyer */ 825b6a6f1Skrish_iyer #ifndef MMC_BUS_H 925b6a6f1Skrish_iyer #define MMC_BUS_H 1025b6a6f1Skrish_iyer 1125b6a6f1Skrish_iyer 1225b6a6f1Skrish_iyer #include <new> 1325b6a6f1Skrish_iyer #include <stdio.h> 1425b6a6f1Skrish_iyer #include <string.h> 1525b6a6f1Skrish_iyer 1625b6a6f1Skrish_iyer #include <lock.h> 1725b6a6f1Skrish_iyer #include <util/AutoLock.h> 18*ff76d2dfSAdrien Destugues #include "mmc.h" 1925b6a6f1Skrish_iyer 2025b6a6f1Skrish_iyer 2125b6a6f1Skrish_iyer #define MMCBUS_TRACE 2225b6a6f1Skrish_iyer #ifdef MMCBUS_TRACE 2325b6a6f1Skrish_iyer # define TRACE(x...) dprintf("\33[33mmmc_bus:\33[0m " x) 2425b6a6f1Skrish_iyer #else 2525b6a6f1Skrish_iyer # define TRACE(x...) 2625b6a6f1Skrish_iyer #endif 2725b6a6f1Skrish_iyer #define TRACE_ALWAYS(x...) dprintf("\33[33mmmc_bus:\33[0m " x) 2825b6a6f1Skrish_iyer #define ERROR(x...) dprintf("\33[33mmmc_bus:\33[0m " x) 2925b6a6f1Skrish_iyer #define CALLED() TRACE("CALLED %s\n", __PRETTY_FUNCTION__) 3025b6a6f1Skrish_iyer 3125b6a6f1Skrish_iyer extern device_manager_info *gDeviceManager; 3225b6a6f1Skrish_iyer 3325b6a6f1Skrish_iyer 3425b6a6f1Skrish_iyer class MMCBus; 3525b6a6f1Skrish_iyer 3625b6a6f1Skrish_iyer class MMCBus { 3725b6a6f1Skrish_iyer public: 3825b6a6f1Skrish_iyer 3925b6a6f1Skrish_iyer MMCBus(device_node *node); 4025b6a6f1Skrish_iyer ~MMCBus(); 4125b6a6f1Skrish_iyer status_t InitCheck(); 4225b6a6f1Skrish_iyer 4325b6a6f1Skrish_iyer private: 44*ff76d2dfSAdrien Destugues status_t ExecuteCommand(uint8_t command, 45*ff76d2dfSAdrien Destugues uint32_t argument, uint32_t* response); 46*ff76d2dfSAdrien Destugues static status_t WorkerThread(void*); 47*ff76d2dfSAdrien Destugues 48*ff76d2dfSAdrien Destugues private: 4925b6a6f1Skrish_iyer 5025b6a6f1Skrish_iyer device_node* fNode; 51*ff76d2dfSAdrien Destugues mmc_bus_interface* fController; 5225b6a6f1Skrish_iyer void* fCookie; 5325b6a6f1Skrish_iyer status_t fStatus; 54*ff76d2dfSAdrien Destugues thread_id fWorkerThread; 5525b6a6f1Skrish_iyer }; 5625b6a6f1Skrish_iyer 5725b6a6f1Skrish_iyer 5825b6a6f1Skrish_iyer #endif /*MMC_BUS_H*/ 59