From 12f40878081fd3bf24ab5bfde044ab4926265188 Mon Sep 17 00:00:00 2001 From: Naeun Yoo Date: Fri, 12 Jan 2018 21:44:41 +0900 Subject: [PATCH] [COMMON] drivers: i2c: Add I2C_CLIENT_SPEEDY Change-Id: I60608968106643c797b9a46828727cfadca5303b Signed-off-by: Naeun Yoo --- drivers/i2c/i2c-core-base.c | 4 ++++ drivers/i2c/i2c-core-of.c | 3 +++ include/linux/i2c.h | 2 ++ 3 files changed, 9 insertions(+) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 56e46581b84b..bebde9ceda35 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -546,6 +546,10 @@ int i2c_check_addr_validity(unsigned addr, unsigned short flags) /* 10-bit address, all values are valid */ if (addr > 0x3ff) return -EINVAL; + } else if (flags & I2C_CLIENT_SPEEDY) { + /* 12-bit address for SPEEDY, all values are valid */ + if (addr > 0xfff) + return -EINVAL; } else { /* 7-bit address, reject the general call address */ if (addr == 0x00 || addr > 0x7f) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index 8d474bb1dc15..a98bab070274 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -57,6 +57,9 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap, info.flags |= I2C_CLIENT_SLAVE; } + if (of_get_property(node, "i2c-speedy-address", NULL)) + info.flags |= I2C_CLIENT_SPEEDY; + if (i2c_check_addr_validity(addr, info.flags)) { dev_err(&adap->dev, "of_i2c: invalid addr=%x on %pOF\n", addr, node); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index d501d3956f13..16a1635f2f68 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -684,6 +684,8 @@ i2c_unlock_adapter(struct i2c_adapter *adapter) #define I2C_CLIENT_WAKE 0x80 /* for board_info; true iff can wake */ #define I2C_CLIENT_SCCB 0x9000 /* Use Omnivision SCCB protocol */ /* Must match I2C_M_STOP|IGNORE_NAK */ +#define I2C_CLIENT_SPEEDY 0x40 /* 12 bit of slave address for speedy */ + /* 4bit(device id) + 8bit(register offet) */ /* i2c adapter classes (bitmask) */ #define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */ -- 2.20.1