include/device: Split i2c.h into three
Split `i2c.h` into three pieces to ease reuse of the generic defi- nitions. No code is changed. * `i2c.h` - keeps the generic definitions * `i2c_simple.h` - holds the current, limited to one controller driver per board, devicetree independent I2C interface * `i2c_bus.h` - will become the devicetree compatible interface for native I2C (e.g. non-SMBus) controllers Change-Id: I382d45c70f9314588663e1284f264f877469c74d Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/20845 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
457fba6be5
commit
0f2dd1eff9
|
@ -18,7 +18,6 @@
|
|||
#include <arch/acpi_device.h>
|
||||
#include <arch/acpigen.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/path.h>
|
||||
#if IS_ENABLED(CONFIG_GENERIC_GPIO_LIB)
|
||||
#include <gpio.h>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <arch/io.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
|
||||
#define TWI_BASE(n) (A1X_TWI0_BASE + 0x400 * (n))
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
*/
|
||||
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_bus.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if ENV_RAMSTAGE
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <assert.h>
|
||||
#include <timer.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
|
||||
/*
|
||||
* The implementation is based on Wikipedia.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <bcd.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <rtc.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <arch/acpi_device.h>
|
||||
#include <arch/acpigen.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/device.h>
|
||||
#include <device/path.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#define __I2C_GENERIC_CHIP_H__
|
||||
|
||||
#include <arch/acpi_device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
|
||||
struct drivers_i2c_generic_config {
|
||||
const char *hid; /* ACPI _HID (required) */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <arch/acpi_device.h>
|
||||
#include <arch/acpigen.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/device.h>
|
||||
#include <device/path.h>
|
||||
#include <gpio.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <arch/acpi_device.h>
|
||||
#include <arch/acpigen.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/device.h>
|
||||
#include <device/path.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <arch/acpi_device.h>
|
||||
#include <arch/acpigen.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/device.h>
|
||||
#include <device/path.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/smbus.h>
|
||||
#include <device/device.h>
|
||||
#include <version.h>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <arch/acpi_device.h>
|
||||
#include <arch/acpigen.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/device.h>
|
||||
#include <device/path.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <arch/acpi_device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
|
||||
struct drivers_i2c_tpm_config {
|
||||
const char *hid; /* ACPI _HID (required) */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <types.h>
|
||||
#include <delay.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <endian.h>
|
||||
#include <timer.h>
|
||||
#include <tpm.h>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <assert.h>
|
||||
#include <commonlib/endian.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <endian.h>
|
||||
#include <lib.h>
|
||||
#include <tpm.h>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <commonlib/endian.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <endian.h>
|
||||
#include <lib.h>
|
||||
#include <tpm.h>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <types.h>
|
||||
#include <delay.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <endian.h>
|
||||
#include <timer.h>
|
||||
#include <tpm.h>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "drivers/i2c/ww_ring/ww_ring_programs.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <arch/acpi_device.h>
|
||||
#include <arch/acpigen.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/device.h>
|
||||
#include <device/path.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <console/console.h>
|
||||
#include <arch/io.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
|
||||
#include "max77686.h"
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <edid.h>
|
||||
#include <console/console.h>
|
||||
#include <timer.h>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <delay.h>
|
||||
#include <types.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include "tps65090.h"
|
||||
|
||||
/* TPS65090 register addresses */
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <bcd.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <rtc.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <console/console.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
|
||||
/* Hide these definitions from the rest of the source, so keep them here */
|
||||
enum registers {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define _DEVICE_I2C_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* struct i2c_msg - an I2C transaction segment beginning with START
|
||||
|
@ -67,162 +66,4 @@ enum i2c_address_mode {
|
|||
I2C_MODE_10_BIT
|
||||
};
|
||||
|
||||
|
||||
int platform_i2c_transfer(unsigned int bus, struct i2c_msg *segments,
|
||||
int count);
|
||||
|
||||
#define SOFTWARE_I2C_MAX_BUS 10 /* increase as necessary */
|
||||
|
||||
struct software_i2c_ops {
|
||||
void (*set_sda)(unsigned int bus, int high);
|
||||
void (*set_scl)(unsigned int bus, int high);
|
||||
int (*get_sda)(unsigned int bus);
|
||||
int (*get_scl)(unsigned int bus);
|
||||
};
|
||||
|
||||
extern struct software_i2c_ops *software_i2c[];
|
||||
|
||||
int software_i2c_transfer(unsigned int bus, struct i2c_msg *segments,
|
||||
int count);
|
||||
void software_i2c_wedge_ack(unsigned int bus, u8 slave);
|
||||
void software_i2c_wedge_read(unsigned int bus, u8 slave, u8 reg, int bit_count);
|
||||
void software_i2c_wedge_write(unsigned int bus, u8 slave, u8 reg,
|
||||
int bit_count);
|
||||
|
||||
int i2c_read_field(unsigned int bus, uint8_t slave, uint8_t reg, uint8_t *data,
|
||||
uint8_t mask, uint8_t shift);
|
||||
int i2c_write_field(unsigned int bus, uint8_t slave, uint8_t reg, uint8_t data,
|
||||
uint8_t mask, uint8_t shift);
|
||||
|
||||
/*
|
||||
* software_i2c is supposed to be a debug feature. It's usually not compiled in,
|
||||
* but when it is it can be dynamically enabled at runtime for certain busses.
|
||||
* Need this ugly stub to arbitrate since I2C device drivers hardcode
|
||||
* 'i2c_transfer()' as their entry point.
|
||||
*/
|
||||
static inline int i2c_transfer(unsigned int bus, struct i2c_msg *segments,
|
||||
int count)
|
||||
{
|
||||
if (CONFIG_SOFTWARE_I2C)
|
||||
if (bus < SOFTWARE_I2C_MAX_BUS && software_i2c[bus])
|
||||
return software_i2c_transfer(bus, segments, count);
|
||||
|
||||
return platform_i2c_transfer(bus, segments, count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a raw chunk of data in one segment and one frame.
|
||||
*
|
||||
* [start][slave addr][r][data][stop]
|
||||
*/
|
||||
static inline int i2c_read_raw(unsigned int bus, uint8_t slave, uint8_t *data,
|
||||
int len)
|
||||
{
|
||||
struct i2c_msg seg = {
|
||||
.flags = I2C_M_RD, .slave = slave, .buf = data, .len = len
|
||||
};
|
||||
|
||||
return i2c_transfer(bus, &seg, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a raw chunk of data in one segment and one frame.
|
||||
*
|
||||
* [start][slave addr][w][data][stop]
|
||||
*/
|
||||
static inline int i2c_write_raw(unsigned int bus, uint8_t slave, uint8_t *data,
|
||||
int len)
|
||||
{
|
||||
struct i2c_msg seg = {
|
||||
.flags = 0, .slave = slave, .buf = data, .len = len
|
||||
};
|
||||
|
||||
return i2c_transfer(bus, &seg, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read multi-bytes with two segments in one frame
|
||||
*
|
||||
* [start][slave addr][w][register addr][start][slave addr][r][data...][stop]
|
||||
*/
|
||||
static inline int i2c_read_bytes(unsigned int bus, uint8_t slave, uint8_t reg,
|
||||
uint8_t *data, int len)
|
||||
{
|
||||
struct i2c_msg seg[2];
|
||||
|
||||
seg[0].flags = 0;
|
||||
seg[0].slave = slave;
|
||||
seg[0].buf = ®
|
||||
seg[0].len = 1;
|
||||
seg[1].flags = I2C_M_RD;
|
||||
seg[1].slave = slave;
|
||||
seg[1].buf = data;
|
||||
seg[1].len = len;
|
||||
|
||||
return i2c_transfer(bus, seg, ARRAY_SIZE(seg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a byte with two segments in one frame
|
||||
*
|
||||
* [start][slave addr][w][register addr][start][slave addr][r][data][stop]
|
||||
*/
|
||||
static inline int i2c_readb(unsigned int bus, uint8_t slave, uint8_t reg,
|
||||
uint8_t *data)
|
||||
{
|
||||
struct i2c_msg seg[2];
|
||||
|
||||
seg[0].flags = 0;
|
||||
seg[0].slave = slave;
|
||||
seg[0].buf = ®
|
||||
seg[0].len = 1;
|
||||
seg[1].flags = I2C_M_RD;
|
||||
seg[1].slave = slave;
|
||||
seg[1].buf = data;
|
||||
seg[1].len = 1;
|
||||
|
||||
return i2c_transfer(bus, seg, ARRAY_SIZE(seg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a byte with one segment in one frame.
|
||||
*
|
||||
* [start][slave addr][w][register addr][data][stop]
|
||||
*/
|
||||
static inline int i2c_writeb(unsigned int bus, uint8_t slave, uint8_t reg,
|
||||
uint8_t data)
|
||||
{
|
||||
struct i2c_msg seg;
|
||||
uint8_t buf[] = {reg, data};
|
||||
|
||||
seg.flags = 0;
|
||||
seg.slave = slave;
|
||||
seg.buf = buf;
|
||||
seg.len = ARRAY_SIZE(buf);
|
||||
|
||||
return i2c_transfer(bus, &seg, 1);
|
||||
}
|
||||
|
||||
/* I2C bus operation for ramstage drivers */
|
||||
struct device;
|
||||
struct i2c_bus_operations {
|
||||
/*
|
||||
* This is an SOC specific method that can be provided to translate the
|
||||
* 'struct device' for an I2C controller into a unique I2C bus number.
|
||||
* Returns -1 if the bus number for this device cannot be determined.
|
||||
*/
|
||||
int (*dev_to_bus)(struct device *dev);
|
||||
};
|
||||
|
||||
/* Return I2C bus number for provided device, -1 if not found */
|
||||
int i2c_dev_find_bus(struct device *dev);
|
||||
|
||||
/* Variants of I2C helper functions that take a device instead of bus number */
|
||||
int i2c_dev_transfer(struct device *dev, struct i2c_msg *segments, int count);
|
||||
int i2c_dev_readb(struct device *dev, uint8_t reg, uint8_t *data);
|
||||
int i2c_dev_writeb(struct device *dev, uint8_t reg, uint8_t data);
|
||||
int i2c_dev_read_bytes(struct device *dev, uint8_t reg, uint8_t *data, int len);
|
||||
int i2c_dev_read_raw(struct device *dev, uint8_t *data, int len);
|
||||
int i2c_dev_write_raw(struct device *dev, uint8_t *data, int len);
|
||||
|
||||
#endif /* _DEVICE_I2C_H_ */
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* This file is part of the coreboot project.
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _DEVICE_I2C_BUS_H_
|
||||
#define _DEVICE_I2C_BUS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/device.h>
|
||||
|
||||
/* I2C bus operation for ramstage drivers */
|
||||
struct i2c_bus_operations {
|
||||
/*
|
||||
* This is an SOC specific method that can be provided to translate the
|
||||
* 'struct device' for an I2C controller into a unique I2C bus number.
|
||||
* Returns -1 if the bus number for this device cannot be determined.
|
||||
*/
|
||||
int (*dev_to_bus)(struct device *dev);
|
||||
};
|
||||
|
||||
/* Return I2C bus number for provided device, -1 if not found */
|
||||
int i2c_dev_find_bus(struct device *dev);
|
||||
|
||||
/* Variants of I2C helper functions that take a device instead of bus number */
|
||||
int i2c_dev_transfer(struct device *dev, struct i2c_msg *segments, int count);
|
||||
int i2c_dev_readb(struct device *dev, uint8_t reg, uint8_t *data);
|
||||
int i2c_dev_writeb(struct device *dev, uint8_t reg, uint8_t data);
|
||||
int i2c_dev_read_bytes(struct device *dev, uint8_t reg, uint8_t *data, int len);
|
||||
int i2c_dev_read_raw(struct device *dev, uint8_t *data, int len);
|
||||
int i2c_dev_write_raw(struct device *dev, uint8_t *data, int len);
|
||||
|
||||
#endif /* _DEVICE_I2C_BUS_H_ */
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* This file is part of the coreboot project.
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _DEVICE_I2C_SIMPLE_H_
|
||||
#define _DEVICE_I2C_SIMPLE_H_
|
||||
|
||||
#include <commonlib/helpers.h>
|
||||
#include <device/i2c.h>
|
||||
|
||||
int platform_i2c_transfer(unsigned int bus, struct i2c_msg *segments,
|
||||
int count);
|
||||
|
||||
#define SOFTWARE_I2C_MAX_BUS 10 /* increase as necessary */
|
||||
|
||||
struct software_i2c_ops {
|
||||
void (*set_sda)(unsigned int bus, int high);
|
||||
void (*set_scl)(unsigned int bus, int high);
|
||||
int (*get_sda)(unsigned int bus);
|
||||
int (*get_scl)(unsigned int bus);
|
||||
};
|
||||
|
||||
extern struct software_i2c_ops *software_i2c[];
|
||||
|
||||
int software_i2c_transfer(unsigned int bus, struct i2c_msg *segments,
|
||||
int count);
|
||||
void software_i2c_wedge_ack(unsigned int bus, u8 slave);
|
||||
void software_i2c_wedge_read(unsigned int bus, u8 slave, u8 reg, int bit_count);
|
||||
void software_i2c_wedge_write(unsigned int bus, u8 slave, u8 reg,
|
||||
int bit_count);
|
||||
|
||||
int i2c_read_field(unsigned int bus, uint8_t slave, uint8_t reg, uint8_t *data,
|
||||
uint8_t mask, uint8_t shift);
|
||||
int i2c_write_field(unsigned int bus, uint8_t slave, uint8_t reg, uint8_t data,
|
||||
uint8_t mask, uint8_t shift);
|
||||
|
||||
/*
|
||||
* software_i2c is supposed to be a debug feature. It's usually not compiled in,
|
||||
* but when it is it can be dynamically enabled at runtime for certain busses.
|
||||
* Need this ugly stub to arbitrate since I2C device drivers hardcode
|
||||
* 'i2c_transfer()' as their entry point.
|
||||
*/
|
||||
static inline int i2c_transfer(unsigned int bus, struct i2c_msg *segments,
|
||||
int count)
|
||||
{
|
||||
if (CONFIG_SOFTWARE_I2C)
|
||||
if (bus < SOFTWARE_I2C_MAX_BUS && software_i2c[bus])
|
||||
return software_i2c_transfer(bus, segments, count);
|
||||
|
||||
return platform_i2c_transfer(bus, segments, count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a raw chunk of data in one segment and one frame.
|
||||
*
|
||||
* [start][slave addr][r][data][stop]
|
||||
*/
|
||||
static inline int i2c_read_raw(unsigned int bus, uint8_t slave, uint8_t *data,
|
||||
int len)
|
||||
{
|
||||
struct i2c_msg seg = {
|
||||
.flags = I2C_M_RD, .slave = slave, .buf = data, .len = len
|
||||
};
|
||||
|
||||
return i2c_transfer(bus, &seg, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a raw chunk of data in one segment and one frame.
|
||||
*
|
||||
* [start][slave addr][w][data][stop]
|
||||
*/
|
||||
static inline int i2c_write_raw(unsigned int bus, uint8_t slave, uint8_t *data,
|
||||
int len)
|
||||
{
|
||||
struct i2c_msg seg = {
|
||||
.flags = 0, .slave = slave, .buf = data, .len = len
|
||||
};
|
||||
|
||||
return i2c_transfer(bus, &seg, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read multi-bytes with two segments in one frame
|
||||
*
|
||||
* [start][slave addr][w][register addr][start][slave addr][r][data...][stop]
|
||||
*/
|
||||
static inline int i2c_read_bytes(unsigned int bus, uint8_t slave, uint8_t reg,
|
||||
uint8_t *data, int len)
|
||||
{
|
||||
struct i2c_msg seg[2];
|
||||
|
||||
seg[0].flags = 0;
|
||||
seg[0].slave = slave;
|
||||
seg[0].buf = ®
|
||||
seg[0].len = 1;
|
||||
seg[1].flags = I2C_M_RD;
|
||||
seg[1].slave = slave;
|
||||
seg[1].buf = data;
|
||||
seg[1].len = len;
|
||||
|
||||
return i2c_transfer(bus, seg, ARRAY_SIZE(seg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a byte with two segments in one frame
|
||||
*
|
||||
* [start][slave addr][w][register addr][start][slave addr][r][data][stop]
|
||||
*/
|
||||
static inline int i2c_readb(unsigned int bus, uint8_t slave, uint8_t reg,
|
||||
uint8_t *data)
|
||||
{
|
||||
struct i2c_msg seg[2];
|
||||
|
||||
seg[0].flags = 0;
|
||||
seg[0].slave = slave;
|
||||
seg[0].buf = ®
|
||||
seg[0].len = 1;
|
||||
seg[1].flags = I2C_M_RD;
|
||||
seg[1].slave = slave;
|
||||
seg[1].buf = data;
|
||||
seg[1].len = 1;
|
||||
|
||||
return i2c_transfer(bus, seg, ARRAY_SIZE(seg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a byte with one segment in one frame.
|
||||
*
|
||||
* [start][slave addr][w][register addr][data][stop]
|
||||
*/
|
||||
static inline int i2c_writeb(unsigned int bus, uint8_t slave, uint8_t reg,
|
||||
uint8_t data)
|
||||
{
|
||||
struct i2c_msg seg;
|
||||
uint8_t buf[] = {reg, data};
|
||||
|
||||
seg.flags = 0;
|
||||
seg.slave = slave;
|
||||
seg.buf = buf;
|
||||
seg.len = ARRAY_SIZE(buf);
|
||||
|
||||
return i2c_transfer(bus, &seg, 1);
|
||||
}
|
||||
|
||||
#endif /* _DEVICE_I2C_SIMPLE_H_ */
|
|
@ -19,7 +19,7 @@
|
|||
#include <cbmem.h>
|
||||
#include <delay.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <drivers/ti/tps65090/tps65090.h>
|
||||
#include <edid.h>
|
||||
#include <soc/clk.h>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <cbmem.h>
|
||||
#include <console/console.h>
|
||||
#include <program_loading.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <drivers/maxim/max77686/max77686.h>
|
||||
#include <soc/clk.h>
|
||||
#include <soc/cpu.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <bootblock_common.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <soc/clk_rst.h>
|
||||
#include <soc/clock.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <boardid.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <ec/google/chromeec/ec.h>
|
||||
#include <gpio.h>
|
||||
#include <soc/bl31_plat_params.h>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <bootblock_common.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <gpio.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <soc/clk_rst.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <boardid.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <reset.h>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <bootblock_common.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <gpio.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <soc/clk_rst.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <boardid.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <reset.h>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <bootblock_common.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <gpio.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <soc/clk_rst.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <boardid.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <reset.h>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <drivers/parade/ps8625/ps8625.h>
|
||||
#include <ec/google/chromeec/ec.h>
|
||||
#include <edid.h>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <cbmem.h>
|
||||
#include <commonlib/region.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <drivers/maxim/max77802/max77802.h>
|
||||
#include <program_loading.h>
|
||||
#include <soc/clk.h>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <bootblock_common.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <soc/clk_rst.h>
|
||||
#include <soc/clock.h>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <boot/coreboot_tables.h>
|
||||
#include <delay.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <soc/clk_rst.h>
|
||||
#include <soc/clock.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <boardid.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <delay.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/clock.h>
|
||||
#include <soc/funitcfg.h>
|
||||
#include <soc/nvidia/tegra/i2c.h>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <edid.h>
|
||||
#include <elog.h>
|
||||
#include <gpio.h>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <edid.h>
|
||||
#include <elog.h>
|
||||
#include <gpio.h>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <edid.h>
|
||||
#include <elog.h>
|
||||
#include <gpio.h>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <assert.h>
|
||||
#include <arch/io.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/pci_devs.h>
|
||||
#include <soc/reg_access.h>
|
||||
#include "reg_access.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <bootmode.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <lib.h>
|
||||
#include <soc/i2c.h>
|
||||
#include <soc/reg_access.h>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <bootstate.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/ramstage.h>
|
||||
#include <variant/gpio.h>
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <console/console.h>
|
||||
#include <lib.h>
|
||||
#include <hwilib.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include "ptn3460.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <assert.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/i2c.h>
|
||||
|
||||
struct cygnus_i2c_regs {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <soc/gpio.h>
|
||||
#include <intelblocks/lpc_lib.h>
|
||||
#include <intelblocks/lpss_i2c.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/pm.h>
|
||||
#include <soc/usb.h>
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
#include <arch/acpigen.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_bus.h>
|
||||
#include <device/pci.h>
|
||||
#include <device/pci_def.h>
|
||||
#include <device/pci_ids.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <console/console.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/pci.h>
|
||||
#include <device/pci_def.h>
|
||||
#include <intelblocks/lpss.h>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <console/console.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/pci.h>
|
||||
#include <device/pci_def.h>
|
||||
#include <device/pci_ids.h>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#ifndef SOC_INTEL_COMMON_BLOCK_LPSS_I2C_H
|
||||
#define SOC_INTEL_COMMON_BLOCK_LPSS_I2C_H
|
||||
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/pci.h>
|
||||
#include <device/pci_ids.h>
|
||||
#include <soc/i2c.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <device/pci.h>
|
||||
#include <device/pci_ids.h>
|
||||
#include <soc/i2c.h>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define _SOC_CHIP_H_
|
||||
|
||||
#include <arch/acpi_device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <intelblocks/gspi.h>
|
||||
#include <intelblocks/lpss_i2c.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/da9212.h>
|
||||
|
||||
enum {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <string.h>
|
||||
#include <symbols.h>
|
||||
#include <timer.h>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/mt6311.h>
|
||||
|
||||
enum {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <soc/addressmap.h>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <gpio.h>
|
||||
#include <soc/pinmux.h>
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <edid.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <soc/nvidia/tegra/i2c.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <arch/io.h>
|
||||
#include <console/console.h>
|
||||
#include <device/device.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <edid.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <assert.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <soc/blsp.h>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <assert.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <soc/gsbi.h>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <cbfs.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <soc/grf.h>
|
||||
#include <soc/soc.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <bcd.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <rtc.h>
|
||||
#include <soc/rk808.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <arch/io.h>
|
||||
#include <console/console.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <gpio.h>
|
||||
#include <soc/grf.h>
|
||||
#include <soc/i2c.h>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <assert.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/clk.h>
|
||||
#include <soc/i2c.h>
|
||||
#include <soc/periph.h>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <assert.h>
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <device/i2c.h>
|
||||
#include <device/i2c_simple.h>
|
||||
#include <soc/clk.h>
|
||||
#include <soc/i2c.h>
|
||||
#include <soc/periph.h>
|
||||
|
|
Loading…
Reference in New Issue