int i2c_shared_master_write_reg(REFERENCE_PARAM(struct r_i2c, i2cPorts), int device, int reg_addr, const unsigned char data[], int nbytes) { int retval; swlock_acquire(&i2c_swlock); retval = i2c_master_write_reg(device, reg_addr, data, nbytes, i2cPorts); swlock_release(&i2c_swlock); return retval; }
/*sysfs interface : i2c_master_read_reg, i2c_master_write_reg anx7730 addr id:: DP_rx(0x50:0, 0x8c:1) HDMI_tx(0x72:5, 0x7a:6, 0x70:7) ex:read ) 05df = read:0 id:5 reg:0xdf ex:write) 15df5f = write:1 id:5 reg:0xdf val:0x5f */ static ssize_t anx7730_write_reg_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int ret = 0; char op, i; char r[3]; char v[3]; unchar tmp; int id, reg, val = 0 ; if (sp_tx_system_state != STATE_PLAY_BACK) { pr_err("%s: error!, Not STATE_PLAY_BACK\n", LOG_TAG); return -EINVAL; } if (sp_tx_rx_type != RX_HDMI) { pr_err("%s: error!, rx is not anx7730\n", LOG_TAG); return -EINVAL; } if (count != 7 && count != 5) { pr_err("%s: cnt:%d, invalid input!\n", LOG_TAG, count-1); pr_err("%s: ex) 05df -> op:0(read) id:5 reg:0xdf \n", LOG_TAG); pr_err("%s: ex) 15df5f -> op:1(wirte) id:5 reg:0xdf val:0x5f\n", LOG_TAG); return -EINVAL; } ret = snprintf(&op, 2, buf); ret = snprintf(&i, 2, buf+1); ret = snprintf(r, 3, buf+2); id = simple_strtoul(&i, NULL, 10); reg = simple_strtoul(r, NULL, 16); if ((id != 0 && id != 1 && id != 5 && id != 6 && id != 7)) { pr_err("%s: invalid addr id! (id:0,1,5,6,7)\n", LOG_TAG); return -EINVAL; } switch (op) { case 0x30: /* "0" -> read */ i2c_master_read_reg(id, reg, &tmp); pr_info("%s: anx7730 read(%d,0x%x)= 0x%x \n", LOG_TAG, id, reg, tmp); break; case 0x31: /* "1" -> write */ ret = snprintf(v, 3, buf+4); val = simple_strtoul(v, NULL, 16); i2c_master_write_reg(id, reg, val); i2c_master_read_reg(id, reg, &tmp); pr_info("%s: anx7730 write(%d,0x%x,0x%x)\n", LOG_TAG, id, reg, tmp); break; default: pr_err("%s: invalid operation code! (0:read, 1:write)\n", LOG_TAG); return -EINVAL; } return count; }
static int dp_reset_pd_function(const char *val, struct kernel_param *kp) { int ret=0; int old_val = dp_pd_value; struct anx7808_platform_data *pdata = anx7808_client->dev.platform_data; if (ret) return ret; if (dp_pd_value > 0xf) { dp_pd_value = old_val; return -EINVAL; } ret = param_set_int(val, kp); if(dp_pd_value==0){ /* gpio_set_value(pdata->gpio_usb_select, 0); msleep(20); gpio_set_value(pdata->gpio_usb_select, 1); msleep(500); gpio_set_value(pdata->gpio_usb_select, 0); msleep(20); gpio_set_value(pdata->gpio_usb_select, 1); msleep(500); */ unchar ch, cl; uint n; sp_read_reg(RX_P0, HDMI_RX_HTOTAL_LOW, &cl); sp_read_reg(RX_P0, HDMI_RX_HTOTAL_HIGH, &ch); n = ch; n = (n << 8) + cl; printk("ANX7808 RX cur_h_res = 0x%x\n", n); sp_read_reg(RX_P0, HDMI_RX_VTOTAL_LOW, &cl); sp_read_reg(RX_P0, HDMI_RX_VTOTAL_HIGH, &ch); n = ch; n = (n << 8) + cl; printk("ANX7808 RX cur_v_res = 0x%x\n", n); sp_read_reg(RX_P0, HDMI_RX_VID_PCLK_CNTR_REG, &cl); printk("ANX7808 RX cur_pix_clk = 0x%x\n", cl); sp_read_reg(RX_P0, HDMI_RX_HDMI_STATUS_REG, &cl); printk("ANX7808 RX dvi_status = 0x%x\n", ((cl & HDMI_MODE) == HDMI_MODE)); }else if (dp_pd_value==1) { gpio_set_value(pdata->gpio_usb_select, 0); msleep(20); gpio_set_value(pdata->gpio_usb_select, 1); msleep(20); gpio_set_value(pdata->gpio_usb_select, 0); msleep(20); gpio_set_value(pdata->gpio_usb_select, 1); msleep(20); gpio_set_value(pdata->gpio_usb_select, 0); msleep(20); gpio_set_value(pdata->gpio_usb_select, 1); msleep(20); gpio_set_value(pdata->gpio_usb_select, 0); msleep(20); gpio_set_value(pdata->gpio_usb_select, 1); } else if (dp_pd_value==2) { sp_tx_hardware_power_set(1); } else if (dp_pd_value==3) { sp_tx_hardware_power_set(0); } else if (dp_pd_value==4) { sp_tx_hardware_poweron(anx7808_client); } else if (dp_pd_value==5) { sp_tx_hardware_powerdown(anx7808_client); } else if (dp_pd_value==6) { unchar c1=0; /* unchar addr_tmp = 0x50; switch(addr_tmp) { case 0x50: c= 0; break; case 0x8c: c= 1; break; case 0x70: c= 7; break; case 0x72: c = 5; break; case 0x7a: c = 6; break; default : break; } */ i2c_master_read_reg(0, 0x0B, &c1); printk("[myDP] 7730reg 0x50, 0x0B=%x\n", (uint)c1); msleep(1); i2c_master_read_reg(5, 0xE3, &c1); printk("[myDP] 7730reg 0x72, 0xE3=%x\n", (uint)c1); msleep(1); i2c_master_read_reg(0, 0x06, &c1); printk("[myDP] 7730reg 0x50, 0x06=%x\n", (uint)c1); msleep(1); i2c_master_read_reg(5, 0x06, &c1); printk("[myDP] 7730reg 0x72, 0x06=%x\n", (uint)c1); i2c_master_read_reg(0, 0x05, &c1); printk("[myDP] 7730reg 0x50, 0x05=%x\n", (uint)c1); } else if (dp_pd_value==7) { unchar c=0; printk("[myDP] write 7730reg 0, 0x06 bit5\n"); i2c_master_read_reg(0,0x06, &c); c = c | 0x20; i2c_master_write_reg(0,0x06, c); } else if (dp_pd_value==8) { unchar c=0; printk("[myDP] write 7730reg 0, 0x06 bit3\n"); i2c_master_read_reg(0,0x06, &c); c = c | 0x08; i2c_master_write_reg(0,0x06, c); } else if (dp_pd_value==9) { unchar c=0; printk("[myDP] write 7730reg 0, 0x06 bit2\n"); i2c_master_read_reg(0,0x06, &c); c = c | 0x04; i2c_master_write_reg(0,0x06, c); } else if (dp_pd_value==10) { unchar c=0; printk("[myDP] write 7730reg 0, 0x06 bit0\n"); i2c_master_read_reg(0,0x06, &c); c = c | 0x01; i2c_master_write_reg(0,0x06, c); } else if (dp_pd_value==11) { unchar c=0; printk("[myDP] write 7730reg 5, 0x06 bit5\n"); i2c_master_read_reg(5,0x06, &c); c = c | 0x20; i2c_master_write_reg(5,0x06, c); } else if (dp_pd_value==12) { myDP_TV_mode = 1; } else if (dp_pd_value==13) { myDP_TV_mode = 0; } else if (dp_pd_value==14) { // printk("[myDP shell] switch to myDP\n"); // gpio_set_value(pdata->gpio_usb_select, 1); myDP_DP_Dongle = 1; } else if (dp_pd_value==15) { // printk("[myDP shell] switch to USB\n"); // gpio_set_value(pdata->gpio_usb_select, 0); myDP_DP_Dongle = 0; } return 0; }
static int read_swing_function(const char *val, struct kernel_param *kp) { int ret=0; unchar c=0; int old_val = read_swing_value; //struct anx7808_platform_data *pdata = anx7808_client->dev.platform_data; if (ret) return ret; if (read_swing_value > 0xf) { read_swing_value = old_val; return -EINVAL; } ret = param_set_int(val, kp); if (read_swing_value==1) { myDP_force_pad_mode = 1; } else if (read_swing_value==2) // test tx phy { myDP_force_pad_mode = 0; } else if (read_swing_value==3) { g_pre_emphis_value = 2; printk("7808 6db\n"); } else if (read_swing_value==4) { g_pre_emphis_value = 3; printk("7808 9db\n"); } else if (read_swing_value==5) { g_dump_7730_reg = 1; } else if (read_swing_value==6) { g_dump_7730_reg = 0; } else if (read_swing_value==7) { unchar c=0; printk("[myDP] HW reset === 7730reg 0x72, 0x06 bit0\n"); i2c_master_read_reg(5,0x06, &c); c = c | 0x01; i2c_master_write_reg(5,0x06, c); } else if (read_swing_value==8) { unchar c=0; int i; printk("******* ANX7730 reg 0x50 DUMP ============\n"); for (i=0; i <=0xff; i++) { i2c_master_read_reg(0, i , &c); if (i%0xf) printk("0x%x = (%x), ", i, c); else printk("0x%x = (%x)\n", i, c); } printk("******* ANX7730 reg 0x72 DUMP ============\n"); for (i=0; i <=0xff; i++) { i2c_master_read_reg(5, i , &c); if (i%0xf) printk("0x%x = (%x), ", i, c); else printk("0x%x = (%x)\n", i, c); } } else if (read_swing_value==9) { g_force_swing_value = 1; } else if (read_swing_value==10) { g_force_swing_value = 0; } else if (read_swing_value==11) { g_swing_value = 0; printk("7808 swing = 200mv\n"); } else if (read_swing_value==12) { g_swing_value = 1; printk("7808 swing = 400mv\n"); } else if (read_swing_value==13) { g_swing_value = 2; printk("7808 swing = 600mv\n"); } else if (read_swing_value==14) { g_swing_value = 3; printk("7808 swing = 800mv\n"); } else if (read_swing_value==15) { sp_read_reg(TX_P0, 0xa3, &c); printk("=== TX_P0 0xa3: %x ===\n",c); } return 0; }
static void slimport_playback_proc(void) { unchar c1 = 0; unchar c=0; unchar c2=0; if (g_dump_7808_reg) { //0x7E, 8B dump_7808_reg_info(); // dump_7808_reg_pclk(); sp_tx_show_infomation(); } if (g_dump_7730_reg) { sp_tx_link_err_check_1(); sp_read_reg(TX_P2, SP_TX_TOTAL_PIXEL_STA_L, &c); sp_read_reg(TX_P2, SP_TX_TOTAL_PIXEL_STA_H, &c1); if(c1!=0x7||c!=0xd0) printk("ANX7808 TX cur_h_res = 0x%x,0x%x\n", c,c1); sp_read_reg(TX_P2, SP_TX_TOTAL_LINE_STA_L, &c); sp_read_reg(TX_P2, SP_TX_TOTAL_LINE_STA_H, &c1); if(c1!=0x4||c!=0xd3) printk("ANX7808 TX cur_v_res = 0x%x\n,0x%x\n", c,c1); if ( (sp_tx_asus_pad) && (!myDP_DP_Dongle) ) { //======================================== // disable 7730 OCM i2c_master_write_reg(7,0xf0, 0); i2c_master_read_reg(7,0xf0, &c); if(c != 0 ) i2c_master_write_reg(7,0xf0, 0); //======================================== i2c_master_read_reg(0, 0xcb, &c1); i2c_master_read_reg(1, 0xd1, &c); //i2c_master_read_reg(0, 0x31, &c2); i2c_master_write_reg(0, 0xcb, c1); i2c_master_write_reg(1, 0xd1, c); if ((c1 & 0x08) || (c & 0x80)) { printk("[myDP] # 7730 video FIFO error , 0xcb= (%x), RX ISR6 = (%x)\n", c1, c); } // printk("========== ANX7730 reg 0x50 DUMP ============\n"); /* for (i=0x20; i <=0x30; i++) { i2c_master_read_reg(0, i , &c); if (i%0xf) printk("0x%x = (%x), ", i, c); else printk("0x%x = (%x)\n", i, c); } */ i2c_master_read_reg(0, 0x24 , &c1); i2c_master_read_reg(0, 0x25 , &c2); if ((c1 != 0x7) || (c2 != 0xd0)) { printk("Fail 7730 0x50 H total = (%x, %x)", c1, c2); } // printk("========== ANX7730 reg 0x72 DUMP ============\n"); /* for (i=0x24; i <=0x34; i++) { i2c_master_read_reg(5, i , &c); if (i%0xf) printk("0x%x = (%x), ", i, c); else printk("0x%x = (%x)\n", i, c); } */ i2c_master_read_reg(5, 0x2b , &c1); i2c_master_read_reg(5, 0x2c , &c2); if ((c1 != 0xd0) || (c2 != 0x7)) { printk("Fail 7730 0x72 H total = (%x, %x)", c1, c2); } // //======================================== // re-enable 7730 OCM i2c_master_write_reg(7,0xf0, 0xe6); i2c_master_write_reg(7,0xf0, 0xe6); //======================================== } } }