1 /* 2 * Copyright (c) 2013 Corey Tabaka 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8 #pragma once 9 10 #include <lk/compiler.h> 11 #include <dev/driver.h> 12 13 /* i2c interface */ 14 struct i2c_ops { 15 struct driver_ops std; 16 17 status_t (*write)(struct device *dev, uint8_t addr, const void *buf, size_t len); 18 status_t (*read)(struct device *dev, uint8_t addr, void *buf, size_t len); 19 20 status_t (*write_reg)(struct device *dev, uint8_t addr, uint8_t reg, uint8_t value); 21 status_t (*read_reg)(struct device *dev, uint8_t addr, uint8_t reg, void *value); 22 }; 23 24 __BEGIN_CDECLS 25 26 status_t class_i2c_write(struct device *dev, uint8_t addr, const void *buf, size_t len); 27 status_t class_i2c_read(struct device *dev, uint8_t addr, void *buf, size_t len); 28 status_t class_i2c_write_reg(struct device *dev, uint8_t addr, uint8_t reg, uint8_t value); 29 status_t class_i2c_read_reg(struct device *dev, uint8_t addr, uint8_t reg, void *value); 30 31 __END_CDECLS 32 33