Lines Matching full:i2c

5  *  Platform driver for the PCA9564 I2C controller.
17 #include <linux/i2c.h>
20 #include <linux/i2c-algo-pca.h>
21 #include <linux/platform_data/i2c-pca-platform.h>
42 struct i2c_pca_pf_data *i2c = pd; in i2c_pca_pf_readbyte8() local
43 return ioread8(i2c->reg_base + reg); in i2c_pca_pf_readbyte8()
48 struct i2c_pca_pf_data *i2c = pd; in i2c_pca_pf_readbyte16() local
49 return ioread8(i2c->reg_base + reg * 2); in i2c_pca_pf_readbyte16()
54 struct i2c_pca_pf_data *i2c = pd; in i2c_pca_pf_readbyte32() local
55 return ioread8(i2c->reg_base + reg * 4); in i2c_pca_pf_readbyte32()
60 struct i2c_pca_pf_data *i2c = pd; in i2c_pca_pf_writebyte8() local
61 iowrite8(val, i2c->reg_base + reg); in i2c_pca_pf_writebyte8()
66 struct i2c_pca_pf_data *i2c = pd; in i2c_pca_pf_writebyte16() local
67 iowrite8(val, i2c->reg_base + reg * 2); in i2c_pca_pf_writebyte16()
72 struct i2c_pca_pf_data *i2c = pd; in i2c_pca_pf_writebyte32() local
73 iowrite8(val, i2c->reg_base + reg * 4); in i2c_pca_pf_writebyte32()
79 struct i2c_pca_pf_data *i2c = pd; in i2c_pca_pf_waitforcompletion() local
83 if (i2c->irq) { in i2c_pca_pf_waitforcompletion()
84 ret = wait_event_timeout(i2c->wait, in i2c_pca_pf_waitforcompletion()
85 i2c->algo_data.read_byte(i2c, I2C_PCA_CON) in i2c_pca_pf_waitforcompletion()
86 & I2C_PCA_CON_SI, i2c->adap.timeout); in i2c_pca_pf_waitforcompletion()
89 timeout = jiffies + i2c->adap.timeout; in i2c_pca_pf_waitforcompletion()
92 if (i2c->algo_data.read_byte(i2c, I2C_PCA_CON) in i2c_pca_pf_waitforcompletion()
104 struct i2c_pca_pf_data *i2c = pd; in i2c_pca_pf_dummyreset() local
106 dev_warn(&i2c->adap.dev, "No reset-pin found. Chip may get stuck!\n"); in i2c_pca_pf_dummyreset()
111 struct i2c_pca_pf_data *i2c = pd; in i2c_pca_pf_resetchip() local
113 gpiod_set_value(i2c->gpio, 1); in i2c_pca_pf_resetchip()
115 gpiod_set_value(i2c->gpio, 0); in i2c_pca_pf_resetchip()
120 struct i2c_pca_pf_data *i2c = dev_id; in i2c_pca_pf_handler() local
122 if ((i2c->algo_data.read_byte(i2c, I2C_PCA_CON) & I2C_PCA_CON_SI) == 0) in i2c_pca_pf_handler()
125 wake_up(&i2c->wait); in i2c_pca_pf_handler()
133 struct i2c_pca_pf_data *i2c; in i2c_pca_pf_probe() local
146 i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); in i2c_pca_pf_probe()
147 if (!i2c) in i2c_pca_pf_probe()
150 i2c->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in i2c_pca_pf_probe()
151 if (IS_ERR(i2c->reg_base)) in i2c_pca_pf_probe()
152 return PTR_ERR(i2c->reg_base); in i2c_pca_pf_probe()
155 init_waitqueue_head(&i2c->wait); in i2c_pca_pf_probe()
157 i2c->irq = irq; in i2c_pca_pf_probe()
159 i2c->adap.nr = pdev->id; in i2c_pca_pf_probe()
160 i2c->adap.owner = THIS_MODULE; in i2c_pca_pf_probe()
161 snprintf(i2c->adap.name, sizeof(i2c->adap.name), in i2c_pca_pf_probe()
164 i2c->adap.algo_data = &i2c->algo_data; in i2c_pca_pf_probe()
165 i2c->adap.dev.parent = &pdev->dev; in i2c_pca_pf_probe()
166 i2c->adap.dev.of_node = np; in i2c_pca_pf_probe()
168 i2c->gpio = devm_gpiod_get_optional(&pdev->dev, "reset", GPIOD_OUT_LOW); in i2c_pca_pf_probe()
169 if (IS_ERR(i2c->gpio)) in i2c_pca_pf_probe()
170 return PTR_ERR(i2c->gpio); in i2c_pca_pf_probe()
172 i2c->adap.timeout = HZ; in i2c_pca_pf_probe()
174 &i2c->algo_data.i2c_clock); in i2c_pca_pf_probe()
176 i2c->algo_data.i2c_clock = 59000; in i2c_pca_pf_probe()
179 i2c->adap.timeout = platform_data->timeout; in i2c_pca_pf_probe()
180 i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed; in i2c_pca_pf_probe()
183 i2c->algo_data.data = i2c; in i2c_pca_pf_probe()
184 i2c->algo_data.wait_for_completion = i2c_pca_pf_waitforcompletion; in i2c_pca_pf_probe()
185 if (i2c->gpio) in i2c_pca_pf_probe()
186 i2c->algo_data.reset_chip = i2c_pca_pf_resetchip; in i2c_pca_pf_probe()
188 i2c->algo_data.reset_chip = i2c_pca_pf_dummyreset; in i2c_pca_pf_probe()
192 i2c->algo_data.write_byte = i2c_pca_pf_writebyte32; in i2c_pca_pf_probe()
193 i2c->algo_data.read_byte = i2c_pca_pf_readbyte32; in i2c_pca_pf_probe()
196 i2c->algo_data.write_byte = i2c_pca_pf_writebyte16; in i2c_pca_pf_probe()
197 i2c->algo_data.read_byte = i2c_pca_pf_readbyte16; in i2c_pca_pf_probe()
201 i2c->algo_data.write_byte = i2c_pca_pf_writebyte8; in i2c_pca_pf_probe()
202 i2c->algo_data.read_byte = i2c_pca_pf_readbyte8; in i2c_pca_pf_probe()
208 IRQF_TRIGGER_FALLING, pdev->name, i2c); in i2c_pca_pf_probe()
213 ret = i2c_pca_add_numbered_bus(&i2c->adap); in i2c_pca_pf_probe()
217 platform_set_drvdata(pdev, i2c); in i2c_pca_pf_probe()
226 struct i2c_pca_pf_data *i2c = platform_get_drvdata(pdev); in i2c_pca_pf_remove() local
228 i2c_del_adapter(&i2c->adap); in i2c_pca_pf_remove()
246 .name = "i2c-pca-platform",
254 MODULE_DESCRIPTION("I2C-PCA9564/PCA9665 platform driver");