26 #define SW_I2C_ADDR 0x1a
27 #define SW_I2C_EN 0x02
28 #define SW_SCL_OUT 0x04
29 #define SW_SDA_OUT 0x08
30 #define SW_SDA_IN 0x04
32 #define SW_I2C_BUSY_ADDR 0x2f
33 #define SW_I2C_BUSY 0x02
47 for (i = 0; i < 8; i++) {
113 for (i = 0; i < 8; i++) {
247 ret = mxl111sf_i2c_start(state);
251 ret = mxl111sf_i2c_bitbang_sendbyte(state,
252 (msg->
addr << 1) | 0x01);
254 mxl111sf_i2c_stop(state);
258 for (i = 0; i < msg->
len; i++) {
259 ret = mxl111sf_i2c_bitbang_recvbyte(state,
262 mxl111sf_i2c_stop(state);
266 if (i < msg->
len - 1)
267 mxl111sf_i2c_ack(state);
270 mxl111sf_i2c_nack(state);
272 ret = mxl111sf_i2c_stop(state);
278 ret = mxl111sf_i2c_start(state);
282 ret = mxl111sf_i2c_bitbang_sendbyte(state,
283 (msg->
addr << 1) & 0xfe);
285 mxl111sf_i2c_stop(state);
289 for (i = 0; i < msg->
len; i++) {
290 ret = mxl111sf_i2c_bitbang_sendbyte(state,
293 mxl111sf_i2c_stop(state);
299 mxl111sf_i2c_stop(state);
307 #define USB_WRITE_I2C_CMD 0x99
308 #define USB_READ_I2C_CMD 0xdd
309 #define USB_END_I2C_CMD 0xfe
311 #define USB_WRITE_I2C_CMD_LEN 26
312 #define USB_READ_I2C_CMD_LEN 24
314 #define I2C_MUX_REG 0x30
315 #define I2C_CONTROL_REG 0x00
316 #define I2C_SLAVE_ADDR_REG 0x08
317 #define I2C_DATA_REG 0x0c
318 #define I2C_INT_STATUS_REG 0x10
324 &wdata[1], 25,
NULL, 0);
334 &wdata[1], 25, rdata, 24);
356 mxl111sf_i2c_get_data(state, 0, buf, buf);
383 mxl111sf_i2c_get_data(state, 0, buf, buf);
385 if (0x08 == (buf[1] & 0x08))
388 if ((buf[5] & 0x02) == 0x02)
389 mxl_i2c(
"(buf[5] & 0x02) == 0x02");
403 mxl_i2c(
"read %d bytes", count);
405 while ((fifo_status == 0) && (i++ < 5))
406 fifo_status = mxl111sf_i2c_check_fifo(state);
408 i2c_w_data[0] = 0xDD;
409 i2c_w_data[1] = 0x00;
411 for (i = 2; i < 26; i++)
412 i2c_w_data[i] = 0xFE;
414 for (i = 0; i <
count; i++) {
415 i2c_w_data[2+(i*3)] = 0x0C;
416 i2c_w_data[3+(i*3)] = 0x00;
417 i2c_w_data[4+(i*3)] = 0x00;
420 mxl111sf_i2c_get_data(state, 0, i2c_w_data, i2c_r_data);
423 if (mxl111sf_i2c_check_status(state) == 1) {
426 for (i = 0; i <
count; i++) {
427 rbuf[
i] = i2c_r_data[(i*3)+1];
430 i2c_r_data[(i*3)+2]);
453 mxl_i2c(
"addr: 0x%02x, read buff len: %d, write buff len: %d",
457 for (index = 0; index < 26; index++)
488 ret = mxl111sf_i2c_send_data(state, 0, buf);
501 buf[6] = (msg->
addr);
504 ret = mxl111sf_i2c_send_data(state, 0, buf);
507 if (mxl111sf_i2c_check_status(state) == 1) {
508 mxl_i2c(
"NACK writing slave address %02x",
521 block_len = (msg->
len / 8);
522 left_over_len = (msg->
len % 8);
525 mxl_i2c(
"block_len %d, left_over_len %d",
526 block_len, left_over_len);
528 for (index = 0; index < block_len; index++) {
529 for (i = 0; i < 8; i++) {
532 buf[3+(i*3)] = msg->
buf[(index*8)+
i];
536 ret = mxl111sf_i2c_send_data(state, 0, buf);
539 if (mxl111sf_i2c_check_status(state) == 1) {
540 mxl_i2c(
"NACK writing slave address %02x",
554 for (k = 0; k < 26; k++)
560 for (i = 0; i < left_over_len; i++) {
562 buf[3+(i*3)] = msg->
buf[(index*8)+
i];
563 mxl_i2c(
"index = %d %d data %d",
564 index, i, msg->
buf[(index*8)+i]);
567 ret = mxl111sf_i2c_send_data(state, 0, buf);
570 if (mxl111sf_i2c_check_status(state) == 1) {
571 mxl_i2c(
"NACK writing slave address %02x",
603 buf[6] = (msg->
len & 0xFF);
611 ret = mxl111sf_i2c_send_data(state, 0, buf);
614 if (mxl111sf_i2c_check_status(state) == 1) {
615 mxl_i2c(
"NACK reading slave address %02x",
629 block_len = ((msg->
len) / 8);
630 left_over_len = ((msg->
len) % 8);
633 mxl_i2c(
"block_len %d, left_over_len %d",
634 block_len, left_over_len);
640 for (index = 0; index < block_len; index++) {
642 for (i = 0; i < 8; i++) {
648 ret = mxl111sf_i2c_get_data(state, 0, buf, i2c_r_data);
651 if (mxl111sf_i2c_check_status(state) == 1) {
652 mxl_i2c(
"NACK reading slave address %02x",
664 for (i = 0; i < 8; i++) {
665 rd_status[
i] = i2c_r_data[(i*3)+2];
667 if (rd_status[i] == 0x04) {
671 msg->
buf[(index*8)+i] =
675 mxl111sf_i2c_readagain(
678 if (ret_status == 1) {
683 msg->
buf[(index*8)+(k+i+1)] =
685 mxl_i2c(
"read data: %02x\t %02x",
686 msg->
buf[(index*8)+(k+i)],
688 mxl_i2c(
"read data: %02x\t %02x",
689 msg->
buf[(index*8)+(k+i+1)],
699 msg->
buf[(index*8)+i] =
703 msg->
buf[(index*8)+i] =
713 for (k = 0; k < 26; k++)
719 for (i = 0; i < left_over_len; i++) {
724 ret = mxl111sf_i2c_get_data(state, 0, buf,
728 if (mxl111sf_i2c_check_status(state) == 1) {
729 mxl_i2c(
"NACK reading slave address %02x",
740 for (i = 0; i < left_over_len; i++) {
741 msg->
buf[(block_len*8)+i] =
743 mxl_i2c(
"read data: %02x\t %02x",
745 i2c_r_data[(i*3)+2]);
760 ret = mxl111sf_i2c_send_data(state, 0, buf);
775 mxl111sf_i2c_send_data(state, 0, buf);
789 mxl111sf_i2c_send_data(state, 0, buf);
807 mxl111sf_i2c_send_data(state, 0, buf);
825 for (i = 0; i < num; i++) {
827 mxl111sf_i2c_hw_xfer_msg(state, &msg[i]) :
828 mxl111sf_i2c_sw_xfer_msg(state, &msg[i]);
831 "transaction %d of %d, %sing %d bytes "
832 "to/from 0x%02x", ret, i+1, num,