Commit f7dac85d authored by Anas Nashif's avatar Anas Nashif
Browse files

drivers: i2c: move to new logger



Move to new logger subsystem.

Signed-off-by: default avatarAnas Nashif <anas.nashif@intel.com>
parent 3da71419
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
@@ -34,18 +34,10 @@ config I2C_INIT_PRIORITY
	help
	  I2C device driver initialization priority.

config SYS_LOG_I2C_LEVEL
	int "I2C log level"
	depends on SYS_LOG
	default 0
	help
	  Sets log level for I2C drivers.
	  Levels are:
	  - 0 OFF, do not write
	  - 1 ERROR, only write SYS_LOG_ERR
	  - 2 WARNING, write SYS_LOG_WRN in addition to previous level
	  - 3 INFO, write SYS_LOG_INF in addition to previous levels
	  - 4 DEBUG, write SYS_LOG_DBG in addition to previous levels

module = I2C
module-str = i2c
source "subsys/logging/Kconfig.template.log_config"

config I2C_0
	bool "Enable I2C Port 0"
+2 −6
Original line number Diff line number Diff line
@@ -13,11 +13,7 @@ extern "C" {

#include <i2c.h>
#include <dt-bindings/i2c/i2c.h>

#ifndef SYS_LOG_LEVEL
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_I2C_LEVEL
#endif
#include <logging/sys_log.h>
#include <logging/log.h>

static inline u32_t _i2c_map_dt_bitrate(u32_t bitrate)
{
@@ -34,7 +30,7 @@ static inline u32_t _i2c_map_dt_bitrate(u32_t bitrate)
		return I2C_SPEED_ULTRA << I2C_SPEED_SHIFT;
	}

	SYS_LOG_ERR("Invalid I2C bit rate value");
	LOG_ERR("Invalid I2C bit rate value");

	return 0;
}
+4 −3
Original line number Diff line number Diff line
@@ -35,8 +35,9 @@

#include <misc/util.h>

#define SYS_LOG_LEVEL CONFIG_SYS_LOG_I2C_LEVEL
#include <logging/sys_log.h>
#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(i2c_atmel_sam3)

#define TWI_IRQ_PDC \
	(TWI_SR_ENDRX | TWI_SR_ENDTX | TWI_SR_RXBUFF | TWI_SR_TXBUFE)
@@ -587,7 +588,7 @@ static int __deprecated i2c_sam3_init(struct device *dev)

	if (i2c_sam3_runtime_configure(dev, dev_data->dev_config)
	    != 0) {
		SYS_LOG_DBG("I2C: Cannot set default configuration 0x%x",
		LOG_DBG("I2C: Cannot set default configuration 0x%x",
		    dev_data->dev_config);
		return -EINVAL;
	}
+7 −2
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@
#include <errno.h>
#include <i2c.h>
#include <soc.h>
#include "i2c-priv.h"

/* Driverlib includes */
#include <inc/hw_memmap.h>
@@ -19,6 +18,12 @@
#include <driverlib/rom_map.h>
#include <driverlib/i2c.h>

#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(i2c_cc32xx)

#include "i2c-priv.h"

#define I2C_MASTER_CMD_BURST_RECEIVE_START_NACK	 I2C_MASTER_CMD_BURST_SEND_START
#define I2C_MASTER_CMD_BURST_RECEIVE_STOP \
	I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP
@@ -269,7 +274,7 @@ static void i2c_cc32xx_isr(void *arg)
	/* Clear interrupt source to avoid additional interrupts */
	MAP_I2CMasterIntClearEx(base, int_status);

	SYS_LOG_DBG("primed state: %d; err_status: 0x%x; int_status: 0x%x",
	LOG_DBG("primed state: %d; err_status: 0x%x; int_status: 0x%x",
		    data->state, err_status, int_status);

	/* Handle errors: */
+17 −17
Original line number Diff line number Diff line
@@ -32,12 +32,12 @@

#include "i2c_dw.h"
#include "i2c_dw_registers.h"
#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(i2c_dw);

#include "i2c-priv.h"

#define SYS_LOG_LEVEL CONFIG_SYS_LOG_I2C_LEVEL
#include <logging/sys_log.h>

static inline void _i2c_dw_data_ask(struct device *dev)
{
	struct i2c_dw_dev_config * const dw = dev->driver_data;
@@ -221,7 +221,7 @@ static void i2c_dw_isr(void *arg)
	 *   - Receive data is available (rx_avail)
	 */

	SYS_LOG_DBG("I2C: interrupt received");
	LOG_DBG("I2C: interrupt received");

	/* Check if we are configured as a master device */
	if (regs->ic_con.bits.master_mode) {
@@ -299,7 +299,7 @@ static int _i2c_dw_setup(struct device *dev, u16_t slave_address)
		 * Make sure to set both the master_mode and slave_disable_bit
		 * to both 0 or both 1
		 */
		SYS_LOG_DBG("I2C: host configured as Master Device");
		LOG_DBG("I2C: host configured as Master Device");
		ic_con.bits.master_mode = 1;
		ic_con.bits.slave_disable = 1;
	} else {
@@ -310,7 +310,7 @@ static int _i2c_dw_setup(struct device *dev, u16_t slave_address)

	/* Set addressing mode - (initialization = 7 bit) */
	if (I2C_ADDR_10_BITS & dw->app_config) {
		SYS_LOG_DBG("I2C: using 10-bit address");
		LOG_DBG("I2C: using 10-bit address");
		ic_con.bits.addr_master_10bit = 1;
		ic_con.bits.addr_slave_10bit = 1;
	}
@@ -318,7 +318,7 @@ static int _i2c_dw_setup(struct device *dev, u16_t slave_address)
	/* Setup the clock frequency and speed mode */
	switch (I2C_SPEED_GET(dw->app_config)) {
	case I2C_SPEED_STANDARD:
		SYS_LOG_DBG("I2C: speed set to STANDARD");
		LOG_DBG("I2C: speed set to STANDARD");
		regs->ic_ss_scl_lcnt = dw->lcnt;
		regs->ic_ss_scl_hcnt = dw->hcnt;
		ic_con.bits.speed = I2C_DW_SPEED_STANDARD;
@@ -327,7 +327,7 @@ static int _i2c_dw_setup(struct device *dev, u16_t slave_address)
	case I2C_SPEED_FAST:
		/* fall through */
	case I2C_SPEED_FAST_PLUS:
		SYS_LOG_DBG("I2C: speed set to FAST or FAST_PLUS");
		LOG_DBG("I2C: speed set to FAST or FAST_PLUS");
		regs->ic_fs_scl_lcnt = dw->lcnt;
		regs->ic_fs_scl_hcnt = dw->hcnt;
		ic_con.bits.speed = I2C_DW_SPEED_FAST;
@@ -338,19 +338,19 @@ static int _i2c_dw_setup(struct device *dev, u16_t slave_address)
			return -EINVAL;
		}

		SYS_LOG_DBG("I2C: speed set to HIGH");
		LOG_DBG("I2C: speed set to HIGH");
		regs->ic_hs_scl_lcnt = dw->lcnt;
		regs->ic_hs_scl_hcnt = dw->hcnt;
		ic_con.bits.speed = I2C_DW_SPEED_HIGH;

		break;
	default:
		SYS_LOG_DBG("I2C: invalid speed requested");
		LOG_DBG("I2C: invalid speed requested");
		return -EINVAL;
	}

	SYS_LOG_DBG("I2C: lcnt = %d", dw->lcnt);
	SYS_LOG_DBG("I2C: hcnt = %d", dw->hcnt);
	LOG_DBG("I2C: lcnt = %d", dw->lcnt);
	LOG_DBG("I2C: hcnt = %d", dw->hcnt);

	/* Set the IC_CON register */
	regs->ic_con = ic_con;
@@ -629,7 +629,7 @@ static inline int i2c_dw_pci_setup(struct device *dev)
	pci_bus_scan_init();

	if (!pci_bus_scan(&dw->pci_dev)) {
		SYS_LOG_DBG("Could not find device");
		LOG_DBG("Could not find device");
		return 0;
	}

@@ -664,7 +664,7 @@ static int i2c_dw_initialize(struct device *dev)
	/* verify that we have a valid DesignWare register first */
	if (regs->ic_comp_type != I2C_DW_MAGIC_KEY) {
		dev->driver_api = NULL;
		SYS_LOG_DBG("I2C: DesignWare magic key not found, check base "
		LOG_DBG("I2C: DesignWare magic key not found, check base "
			    "address. Stopping initialization");
		return -EIO;
	}
@@ -675,10 +675,10 @@ static int i2c_dw_initialize(struct device *dev)
	 * can move provide support for it
	 */
	if (regs->ic_con.bits.speed == I2C_DW_SPEED_HIGH) {
		SYS_LOG_DBG("I2C: high speed supported");
		LOG_DBG("I2C: high speed supported");
		dw->support_hs_mode = true;
	} else {
		SYS_LOG_DBG("I2C: high speed NOT supported");
		LOG_DBG("I2C: high speed NOT supported");
		dw->support_hs_mode = false;
	}

@@ -687,7 +687,7 @@ static int i2c_dw_initialize(struct device *dev)
	dw->app_config = I2C_MODE_MASTER | _i2c_map_dt_bitrate(rom->bitrate);

	if (i2c_dw_runtime_configure(dev, dw->app_config) != 0) {
		SYS_LOG_DBG("I2C: Cannot set default configuration");
		LOG_DBG("I2C: Cannot set default configuration");
		return -EIO;
	}

Loading