void hs_slew_rate_cal(void){ unsigned char valid_reg; unsigned long data; unsigned long x; unsigned char value; unsigned long start_time, timeout; unsigned int timeout_flag = 0; //4 s1:enable usb ring oscillator. USBPHY_WRITE8(0x15,0x80); //4 s2:wait 1us. udelay(1); //4 s3:enable free run clock USBPHY_WRITE8 (0xf00-0x800+0x11,0x01); //4 s4:setting cyclecnt. USBPHY_WRITE8 (0xf00-0x800+0x01,0x04); //4 s5:enable frequency meter USBPHY_SET8 (0xf00-0x800+0x03,0x01); //4 s6:wait for frequency valid. start_time = jiffies; timeout = jiffies + 3 * HZ; while(!(USBPHY_READ8(0xf00-0x800+0x10)&0x1)){ if(time_after(jiffies, timeout)){ timeout_flag = 1; break; } } //4 s7: read result. if(timeout_flag){ printk("[USBPHY] Slew Rate Calibration: Timeout\n"); value = 0x4; } else{ data = USBPHY_READ32 (0xf00-0x800+0x0c); x = ((1024*FRA*PARA)/data); value = (unsigned char)(x/1000); if((x-value*1000)/100>=5) value += 1; printk("[USBPHY]slew calibration:FM_OUT =%lu,x=%lu,value=%d\n",data,x,value); } //4 s8: disable Frequency and run clock. USBPHY_CLR8 (0xf00-0x800+0x03,0x01);//disable frequency meter USBPHY_CLR8 (0xf00-0x800+0x11,0x01);//disable free run clock //4 s9: //USBPHY_WRITE8(0x15,value); USBPHY_WRITE8(0x15, (value<<4)); //4 s10:disable usb ring oscillator. USBPHY_CLR8(0x15,0x80); }
static void hs_slew_rate_cal(void) { unsigned long data; unsigned long x; unsigned char value; unsigned long start_time, timeout; unsigned int timeout_flag = 0; /* 4 s1:enable usb ring oscillator. */ USBPHY_SET8(0x15, 0x80); /* 4 s2:wait 1us. */ udelay(1); /* 4 s3:enable free run clock */ USBPHY_SET8(0xf00 - 0x800 + 0x11, 0x01); /* 4 s4:setting cyclecnt. */ USBPHY_SET8(0xf00 - 0x800 + 0x01, 0x04); /* 4 s5:enable frequency meter */ USBPHY_SET8(0xf00 - 0x800 + 0x03, 0x01); /* 4 s6:wait for frequency valid. */ start_time = jiffies; timeout = jiffies + 3 * HZ; while (!(USBPHY_READ8(0xf00 - 0x800 + 0x10) & 0x1)) { if (time_after(jiffies, timeout)) { timeout_flag = 1; break; } } /* 4 s7: read result. */ if (timeout_flag) { DBG(0, "[USBPHY] Slew Rate Calibration: Timeout\n"); value = 0x4; } else { data = USBPHY_READ32(0xf00 - 0x800 + 0x0c); x = ((1024 * FRA * PARA) / data); value = (unsigned char)(x / 1000); if ((x - value * 1000) / 100 >= 5) value += 1; DBG(0, "[USBPHY]slew calibration:FM_OUT =%lu,x=%lu,value=%d\n", data, x, value); } /* 4 s8: disable Frequency and run clock. */ USBPHY_CLR8(0xf00 - 0x800 + 0x03, 0x01); USBPHY_CLR8(0xf00 - 0x800 + 0x11, 0x01); /* 4 s9: */ #define MSK_RG_USB20_HSTX_SRCTRL 0x7 /* all clr first then set */ USBPHY_CLR8(0x15, MSK_RG_USB20_HSTX_SRCTRL << 4); USBPHY_SET8(0x15, (value & MSK_RG_USB20_HSTX_SRCTRL) << 4); /* 4 s10:disable usb ring oscillator. */ USBPHY_CLR8(0x15, 0x80); }
void hs_slew_rate_cal(void){ unsigned long start_time, timeout; unsigned long data = 0, cal; unsigned int timeout_flag = 0; USBPHY_SET8(0x1d, 0x40); USBPHY_SET8(0x66, 0x20); USBPHY_WRITE32(0x700, (1<<28) | (1<<24) | TIME_WINDOW); start_time = jiffies; timeout = jiffies + 3 * HZ; while(!(USBPHY_READ32(0x710)&0x1)) { if(time_after(jiffies, timeout)) { timeout_flag = 1; break; } } if(timeout_flag) { printk("[USB] Slew Rate Calibration: Timeout\n"); cal = 0x4; } else { printk("[USB] Slew Rate Calibration: Complete\n"); data = USBPHY_READ32(0x70c); cal = ((((2 * A * 48 * TIME_WINDOW) / FRA) / data) + 1) / 2; } printk("[USB] cal = %lu\n", cal); USBPHY_CLR8(0x15, 0x07); USBPHY_SET8(0x15, (cal & 0x7)); USBPHY_CLR8(0x703, 0x01); USBPHY_CLR8(0x1d, 0x40); return; }
void hs_slew_rate_cal(void){ unsigned long data; unsigned long x; unsigned char value; unsigned long start_time, timeout; unsigned int timeout_flag = 0; //s1: USBPHY_WRITE8(0x12,0x81); //s2: USBPHY_WRITE8 (0xf00-0x800+0x11,0x01); USBPHY_WRITE8 (0xf00-0x800+0x01,0x04); USBPHY_SET8 (0xf00-0x800+0x03,0x01); //s3: start_time = jiffies; timeout = jiffies + 3 * HZ; while(!(USBPHY_READ8(0xf00-0x800+0x10)&0x1)){ if(time_after(jiffies, timeout)){ timeout_flag = 1; break; } } //s4: if(timeout_flag){ printk("[USBPHY] Slew Rate Calibration: Timeout\n"); value = 0x4; } else{ data = USBPHY_READ32 (0xf00-0x800+0x0c); x = ((1024*FRA*PARA)/data); value = (unsigned char)(x/1000); if((x-value*1000)/100>=5) value += 1; //printk("[USBPHY]slew calibration:x=%d,value=%d\n",x,value); } //s5: USBPHY_CLR8 (0xf00-0x800+0x03,0x01);//disable frequency meter USBPHY_CLR8 (0xf00-0x800+0x11,0x01);//disable free run clock USBPHY_WRITE8(0x12,value); }