1 /* 2 * Copyright 2022, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "ocores_i2c.h" 8 9 10 device_manager_info* gDeviceManager; 11 i2c_for_controller_interface* gI2c; 12 13 14 i2c_sim_interface gOcoresI2cDriver = { 15 .info = { 16 .info = { 17 .name = OCORES_I2C_DRIVER_MODULE_NAME, 18 }, __anon36af51890102() 19 .supports_device = [](device_node* parent) { 20 return OcoresI2c::SupportsDevice(parent); 21 }, __anon36af51890202() 22 .register_device = [](device_node* parent) { 23 return OcoresI2c::RegisterDevice(parent); 24 }, __anon36af51890302() 25 .init_driver = [](device_node* node, void** driverCookie) { 26 return OcoresI2c::InitDriver(node, *(OcoresI2c**)driverCookie); 27 }, __anon36af51890402() 28 .uninit_driver = [](void* driverCookie) { 29 return static_cast<OcoresI2c*>(driverCookie)->UninitDriver(); 30 }, 31 }, __anon36af51890502() 32 .set_i2c_bus = [](i2c_bus_cookie cookie, i2c_bus bus) { 33 static_cast<OcoresI2c*>(cookie)->SetI2cBus(bus); 34 }, 35 .exec_command = [](i2c_bus_cookie cookie, i2c_op op, 36 i2c_addr slaveAddress, const void *cmdBuffer, size_t cmdLength, __anon36af51890602() 37 void* dataBuffer, size_t dataLength) { 38 return static_cast<OcoresI2c*>(cookie)->ExecCommand(op, slaveAddress, 39 (const uint8*)cmdBuffer, cmdLength, (uint8*)dataBuffer, dataLength); 40 }, __anon36af51890702() 41 .acquire_bus = [](i2c_bus_cookie cookie) { 42 return static_cast<OcoresI2c*>(cookie)->AcquireBus(); 43 }, __anon36af51890802() 44 .release_bus = [](i2c_bus_cookie cookie) { 45 static_cast<OcoresI2c*>(cookie)->ReleaseBus(); 46 }, 47 }; 48 49 50 _EXPORT module_dependency module_dependencies[] = { 51 { B_DEVICE_MANAGER_MODULE_NAME, (module_info**)&gDeviceManager }, 52 { I2C_FOR_CONTROLLER_MODULE_NAME, (module_info**)&gI2c }, 53 {} 54 }; 55 56 _EXPORT module_info *modules[] = { 57 (module_info *)&gOcoresI2cDriver, 58 NULL 59 }; 60