[COMMON] drivers: i2c: Add I2C_CLIENT_SPEEDY
authorNaeun Yoo <ne.yoo@samsung.com>
Fri, 12 Jan 2018 12:44:41 +0000 (21:44 +0900)
committerJaehyoung Choi <jkkkkk.choi@samsung.com>
Fri, 11 May 2018 07:39:30 +0000 (16:39 +0900)
Change-Id: I60608968106643c797b9a46828727cfadca5303b
Signed-off-by: Naeun Yoo <ne.yoo@samsung.com>
drivers/i2c/i2c-core-base.c
drivers/i2c/i2c-core-of.c
include/linux/i2c.h

index 56e46581b84bdb03eeb07ddaa8d83cec1aa76341..bebde9ceda351a8a6561767967450e5583110323 100644 (file)
@@ -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)
index 8d474bb1dc15755ddc0a5768ae7c518d5d374fec..a98bab070274344e8bee995947784e8da4ddef59 100644 (file)
@@ -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);
index d501d3956f13f041864dc25f0d7e8724ea2b5210..16a1635f2f6827ce813fce24b0a107c5c6ff73f9 100644 (file)
@@ -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, ... */