Lines Matching defs:ccsr_i2c
22 struct ls_i2c *ccsr_i2c = (void *)nxp_i2c_addr;
26 i2c_out(&ccsr_i2c->cr, I2C_CR_DIS);
27 i2c_out(&ccsr_i2c->fd, I2C_FD_CONSERV);
28 i2c_out(&ccsr_i2c->sr, I2C_SR_RST);
29 i2c_out(&ccsr_i2c->cr, I2C_CR_EN);
32 static int wait_for_state(struct ls_i2c *ccsr_i2c,
40 sr = i2c_in(&ccsr_i2c->sr);
42 i2c_out(&ccsr_i2c->sr, sr);
60 static int tx_byte(struct ls_i2c *ccsr_i2c, unsigned char c)
64 i2c_out(&ccsr_i2c->sr, I2C_SR_IF);
65 i2c_out(&ccsr_i2c->dr, c);
66 ret = wait_for_state(ccsr_i2c, I2C_SR_IF, I2C_SR_IF);
79 static int gen_stop(struct ls_i2c *ccsr_i2c)
84 cr = i2c_in(&ccsr_i2c->cr);
86 i2c_out(&ccsr_i2c->cr, cr);
87 ret = wait_for_state(ccsr_i2c, I2C_SR_IDLE, I2C_SR_BB);
94 static int i2c_write_addr(struct ls_i2c *ccsr_i2c, unsigned char chip,
105 if (i2c_in(&ccsr_i2c->ad) == (chip << 1)) {
109 i2c_out(&ccsr_i2c->sr, I2C_SR_IF);
110 ret = wait_for_state(ccsr_i2c, I2C_SR_IDLE, I2C_SR_BB);
115 cr = i2c_in(&ccsr_i2c->cr);
117 i2c_out(&ccsr_i2c->cr, cr);
118 ret = wait_for_state(ccsr_i2c, I2C_SR_BB, I2C_SR_BB);
125 i2c_out(&ccsr_i2c->cr, cr);
126 ret = tx_byte(ccsr_i2c, chip << 1);
128 gen_stop(ccsr_i2c);
134 ret = tx_byte(ccsr_i2c, (addr >> (alen << 3)) & 0xff);
136 gen_stop(ccsr_i2c);
144 static int read_data(struct ls_i2c *ccsr_i2c, unsigned char chip,
151 cr = i2c_in(&ccsr_i2c->cr);
156 i2c_out(&ccsr_i2c->cr, cr);
157 i2c_out(&ccsr_i2c->sr, I2C_SR_IF);
158 i2c_in(&ccsr_i2c->dr); /* dummy read */
160 ret = wait_for_state(ccsr_i2c, I2C_SR_IF, I2C_SR_IF);
162 gen_stop(ccsr_i2c);
166 gen_stop(ccsr_i2c);
171 cr = i2c_in(&ccsr_i2c->cr);
173 i2c_out(&ccsr_i2c->cr, cr);
175 i2c_out(&ccsr_i2c->sr, I2C_SR_IF);
176 buf[i] = i2c_in(&ccsr_i2c->dr);
182 static int write_data(struct ls_i2c *ccsr_i2c, unsigned char chip,
189 ret = tx_byte(ccsr_i2c, buf[i]);
194 ret = gen_stop(ccsr_i2c);
205 struct ls_i2c *ccsr_i2c = (void *)g_nxp_i2c_addr;
207 ret = i2c_write_addr(ccsr_i2c, chip, addr, alen);
209 gen_stop(ccsr_i2c);
213 cr = i2c_in(&ccsr_i2c->cr);
215 i2c_out(&ccsr_i2c->cr, cr);
217 ret = tx_byte(ccsr_i2c, (chip << 1) | 1);
219 gen_stop(ccsr_i2c);
223 return read_data(ccsr_i2c, chip, buf, len);
230 struct ls_i2c *ccsr_i2c = (void *)g_nxp_i2c_addr;
232 ret = i2c_write_addr(ccsr_i2c, chip, addr, alen);
237 return write_data(ccsr_i2c, chip, buf, len);
243 struct ls_i2c *ccsr_i2c = (void *)g_nxp_i2c_addr;
245 ret = i2c_write_addr(ccsr_i2c, chip, 0, 0);
251 ret = gen_stop(ccsr_i2c);