13 #include <linux/i2c.h>
16 #include <linux/export.h>
21 static int mb862xx_i2c_wait_event(
struct i2c_adapter *adap)
23 struct mb862xxfb_par *par = adap->
algo_data;
38 struct mb862xxfb_par *par = adap->
algo_data;
43 if (!mb862xx_i2c_wait_event(adap))
51 struct mb862xxfb_par *par = adap->
algo_data;
55 if (!mb862xx_i2c_wait_event(adap))
60 static int mb862xx_i2c_read_byte(
struct i2c_adapter *adap,
u8 *byte,
int last)
62 struct mb862xxfb_par *par = adap->
algo_data;
65 if (!mb862xx_i2c_wait_event(adap))
71 static void mb862xx_i2c_stop(
struct i2c_adapter *adap)
73 struct mb862xxfb_par *par = adap->
algo_data;
83 int last = m->
len - 1;
85 for (i = 0; i < m->
len; i++) {
86 if (!mb862xx_i2c_read_byte(adap, &m->
buf[i], i == last)) {
98 for (i = 0; i < m->
len; i++) {
99 if (!mb862xx_i2c_write_byte(adap, m->
buf[i])) {
110 struct mb862xxfb_par *par = adap->
algo_data;
115 dev_dbg(par->dev,
"%s: %d msgs\n", __func__, num);
117 for (i = 0; i < num; i++) {
120 dev_dbg(par->dev,
"%s: null msgs\n", __func__);
127 err = mb862xx_i2c_do_address(adap, addr);
131 err = mb862xx_i2c_read(adap, m);
133 err = mb862xx_i2c_write(adap, m);
137 mb862xx_i2c_stop(adap);
148 .master_xfer = mb862xx_xfer,
149 .functionality = mb862xx_func,
153 .name =
"MB862xx I2C adapter",
154 .algo = &mb862xx_algo,
163 par->adap = &mb862xx_i2c_adapter;
167 dev_err(par->dev,
"failed to add %s\n",
168 mb862xx_i2c_adapter.
name);