zephyr/drivers/i2c/i2c_quark_se_ss.h
Daniel Leung dff5f6a038 i2c: make i2c_transfer() really generic
Make the i2c_transfer() to transact messages through the I2C bus.

It is useful for I2C storage devices, as now we can send one message
containing the destination byte/block address, then send the data
in another message. There is no need to construct one continuous
data buffer to send both address and data anymore.

The drivers and sample apps have been updated to utilize updated
API when appropriate. For i2c_dw, only master mode has been updated.
Slave mode will be updated once we can adequately test it.

Change-Id: I0a811d60567367817fcc8d15f5454e5c933722e2
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:25:15 -05:00

90 lines
2.4 KiB
C

/*
* Copyright (c) 2015 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file Header for I2C driver for Quark SE Sensor Subsystem
*/
#ifndef __DRIVERS_I2C_QUARK_SE_SS_H__
#define __DRIVERS_I2C_QUARK_SE_SS_H__
#include <i2c.h>
#include <stdbool.h>
/* dev->state values from IC_DATA_CMD Data transfer mode settings (bit 8) */
#define I2C_QSE_SS_STATE_READY (0)
#define I2C_QSE_SS_CMD_SEND (1 << 0)
#define I2C_QSE_SS_CMD_RECV (1 << 1)
#define I2C_QSE_SS_CMD_ERROR (1 << 2)
#define I2C_QSE_SS_BUSY (1 << 3)
/*
* DesignWare speed values don't directly translate from the Zephyr speed
* selections in include/i2c.h so here we do a little translation
*/
#define I2C_QSE_SS_SPEED_STANDARD 0x1
#define I2C_QSE_SS_SPEED_FAST 0x2
#define I2C_QSE_SS_SPEED_FAST_PLUS 0x2
/* IC_CON Low count and high count default values */
/* TODO verify all values for Quark SE SS */
#define I2C_STD_HCNT (CONFIG_I2C_CLOCK_SPEED * 4)
#define I2C_STD_LCNT (CONFIG_I2C_CLOCK_SPEED * 5)
#define I2C_FS_HCNT ((CONFIG_I2C_CLOCK_SPEED * 6) / 8)
#define I2C_FS_LCNT ((CONFIG_I2C_CLOCK_SPEED * 7) / 8)
typedef void (*i2c_qse_ss_cfg_func_t)(struct device *port);
struct i2c_qse_ss_rom_config {
uint32_t base_address;
i2c_qse_ss_cfg_func_t config_func;
/* IRQ for ERR (error) conditions */
uint32_t isr_err_vector;
uint32_t isr_err_mask;
/* IRQ for RX_AVAIL */
uint32_t isr_rx_vector;
uint32_t isr_rx_mask;
/* IRQ for TX_REQ */
uint32_t isr_tx_vector;
uint32_t isr_tx_mask;
/* IRQ for STOP_DET */
uint32_t isr_stop_vector;
uint32_t isr_stop_mask;
};
struct i2c_qse_ss_dev_config {
device_sync_call_t sync;
union dev_config app_config;
volatile uint8_t state; /* last direction of transfer */
uint8_t xfr_flags;
uint8_t *xfr_buf;
uint32_t xfr_len;
uint32_t request_bytes;
uint16_t hcnt;
uint16_t lcnt;
};
#endif /* __DRIVERS_I2C_QUARK_SE_SS_H__ */