Lines Matching refs:rmi_i2c
62 static int rmi_set_page(struct rmi_i2c_xport *rmi_i2c, u8 page) in rmi_set_page() argument
64 struct i2c_client *client = rmi_i2c->client; in rmi_set_page()
75 rmi_i2c->page = page; in rmi_set_page()
82 struct rmi_i2c_xport *rmi_i2c = in rmi_i2c_write_block() local
84 struct i2c_client *client = rmi_i2c->client; in rmi_i2c_write_block()
88 mutex_lock(&rmi_i2c->page_mutex); in rmi_i2c_write_block()
90 if (!rmi_i2c->tx_buf || rmi_i2c->tx_buf_size < tx_size) { in rmi_i2c_write_block()
91 if (rmi_i2c->tx_buf) in rmi_i2c_write_block()
92 devm_kfree(&client->dev, rmi_i2c->tx_buf); in rmi_i2c_write_block()
93 rmi_i2c->tx_buf_size = tx_size + BUFFER_SIZE_INCREMENT; in rmi_i2c_write_block()
94 rmi_i2c->tx_buf = devm_kzalloc(&client->dev, in rmi_i2c_write_block()
95 rmi_i2c->tx_buf_size, in rmi_i2c_write_block()
97 if (!rmi_i2c->tx_buf) { in rmi_i2c_write_block()
98 rmi_i2c->tx_buf_size = 0; in rmi_i2c_write_block()
104 rmi_i2c->tx_buf[0] = addr & 0xff; in rmi_i2c_write_block()
105 memcpy(rmi_i2c->tx_buf + 1, buf, len); in rmi_i2c_write_block()
107 if (RMI_I2C_PAGE(addr) != rmi_i2c->page) { in rmi_i2c_write_block()
108 retval = rmi_set_page(rmi_i2c, RMI_I2C_PAGE(addr)); in rmi_i2c_write_block()
113 retval = i2c_master_send(client, rmi_i2c->tx_buf, tx_size); in rmi_i2c_write_block()
124 mutex_unlock(&rmi_i2c->page_mutex); in rmi_i2c_write_block()
131 struct rmi_i2c_xport *rmi_i2c = in rmi_i2c_read_block() local
133 struct i2c_client *client = rmi_i2c->client; in rmi_i2c_read_block()
150 mutex_lock(&rmi_i2c->page_mutex); in rmi_i2c_read_block()
152 if (RMI_I2C_PAGE(addr) != rmi_i2c->page) { in rmi_i2c_read_block()
153 retval = rmi_set_page(rmi_i2c, RMI_I2C_PAGE(addr)); in rmi_i2c_read_block()
169 mutex_unlock(&rmi_i2c->page_mutex); in rmi_i2c_read_block()
188 struct rmi_i2c_xport *rmi_i2c = data; in rmi_i2c_regulator_bulk_disable() local
190 regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies), in rmi_i2c_regulator_bulk_disable()
191 rmi_i2c->supplies); in rmi_i2c_regulator_bulk_disable()
196 struct rmi_i2c_xport *rmi_i2c = data; in rmi_i2c_unregister_transport() local
198 rmi_unregister_transport_device(&rmi_i2c->xport); in rmi_i2c_unregister_transport()
206 struct rmi_i2c_xport *rmi_i2c; in rmi_i2c_probe() local
209 rmi_i2c = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_xport), in rmi_i2c_probe()
211 if (!rmi_i2c) in rmi_i2c_probe()
214 pdata = &rmi_i2c->xport.pdata; in rmi_i2c_probe()
230 rmi_i2c->supplies[0].supply = "vdd"; in rmi_i2c_probe()
231 rmi_i2c->supplies[1].supply = "vio"; in rmi_i2c_probe()
233 ARRAY_SIZE(rmi_i2c->supplies), in rmi_i2c_probe()
234 rmi_i2c->supplies); in rmi_i2c_probe()
238 error = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), in rmi_i2c_probe()
239 rmi_i2c->supplies); in rmi_i2c_probe()
245 rmi_i2c); in rmi_i2c_probe()
250 &rmi_i2c->startup_delay); in rmi_i2c_probe()
252 msleep(rmi_i2c->startup_delay); in rmi_i2c_probe()
254 rmi_i2c->client = client; in rmi_i2c_probe()
255 mutex_init(&rmi_i2c->page_mutex); in rmi_i2c_probe()
257 rmi_i2c->xport.dev = &client->dev; in rmi_i2c_probe()
258 rmi_i2c->xport.proto_name = "i2c"; in rmi_i2c_probe()
259 rmi_i2c->xport.ops = &rmi_i2c_ops; in rmi_i2c_probe()
261 i2c_set_clientdata(client, rmi_i2c); in rmi_i2c_probe()
267 error = rmi_set_page(rmi_i2c, 0); in rmi_i2c_probe()
275 error = rmi_register_transport_device(&rmi_i2c->xport); in rmi_i2c_probe()
283 rmi_i2c); in rmi_i2c_probe()
293 struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client); in rmi_i2c_suspend() local
296 ret = rmi_driver_suspend(rmi_i2c->xport.rmi_dev, true); in rmi_i2c_suspend()
300 regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies), in rmi_i2c_suspend()
301 rmi_i2c->supplies); in rmi_i2c_suspend()
309 struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client); in rmi_i2c_resume() local
312 ret = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), in rmi_i2c_resume()
313 rmi_i2c->supplies); in rmi_i2c_resume()
317 msleep(rmi_i2c->startup_delay); in rmi_i2c_resume()
319 ret = rmi_driver_resume(rmi_i2c->xport.rmi_dev, true); in rmi_i2c_resume()
329 struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client); in rmi_i2c_runtime_suspend() local
332 ret = rmi_driver_suspend(rmi_i2c->xport.rmi_dev, false); in rmi_i2c_runtime_suspend()
336 regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies), in rmi_i2c_runtime_suspend()
337 rmi_i2c->supplies); in rmi_i2c_runtime_suspend()
345 struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client); in rmi_i2c_runtime_resume() local
348 ret = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), in rmi_i2c_runtime_resume()
349 rmi_i2c->supplies); in rmi_i2c_runtime_resume()
353 msleep(rmi_i2c->startup_delay); in rmi_i2c_runtime_resume()
355 ret = rmi_driver_resume(rmi_i2c->xport.rmi_dev, false); in rmi_i2c_runtime_resume()