|  | @@ -216,3 +216,111 @@ static int calc_tacc(unsigned int cyc, int nwait_en,
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  static int s3c2410_calc_bank(struct s3c_cpufreq_config *cfg,
 | 
	
		
			
				|  |  |  			     struct s3c2410_iobank_timing *bt)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	unsigned long hclk = cfg->freq.hclk_tns;
 | 
	
		
			
				|  |  | +	unsigned long res;
 | 
	
		
			
				|  |  | +	int ret;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	res  = bt->bankcon;
 | 
	
		
			
				|  |  | +	res &= (S3C2410_BANKCON_SDRAM | S3C2410_BANKCON_PMC16);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/* tacp: 2,3,4,5 */
 | 
	
		
			
				|  |  | +	/* tcah: 0,1,2,4 */
 | 
	
		
			
				|  |  | +	/* tcoh: 0,1,2,4 */
 | 
	
		
			
				|  |  | +	/* tacc: 1,2,3,4,6,7,10,14 (>4 for nwait) */
 | 
	
		
			
				|  |  | +	/* tcos: 0,1,2,4 */
 | 
	
		
			
				|  |  | +	/* tacs: 0,1,2,4 */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	ret  = calc_0124(bt->tacs, hclk, &res, S3C2410_BANKCON_Tacs_SHIFT);
 | 
	
		
			
				|  |  | +	ret |= calc_0124(bt->tcos, hclk, &res, S3C2410_BANKCON_Tcos_SHIFT);
 | 
	
		
			
				|  |  | +	ret |= calc_0124(bt->tcah, hclk, &res, S3C2410_BANKCON_Tcah_SHIFT);
 | 
	
		
			
				|  |  | +	ret |= calc_0124(bt->tcoh, hclk, &res, S3C2410_BANKCON_Tcoh_SHIFT);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (ret)
 | 
	
		
			
				|  |  | +		return -EINVAL;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	ret |= calc_tacp(bt->tacp, hclk, &res);
 | 
	
		
			
				|  |  | +	ret |= calc_tacc(bt->tacc, bt->nwait_en, hclk, &res);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (ret)
 | 
	
		
			
				|  |  | +		return -EINVAL;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	bt->bankcon = res;
 | 
	
		
			
				|  |  | +	return 0;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static unsigned int tacc_tab[] = {
 | 
	
		
			
				|  |  | +	[0]	= 1,
 | 
	
		
			
				|  |  | +	[1]	= 2,
 | 
	
		
			
				|  |  | +	[2]	= 3,
 | 
	
		
			
				|  |  | +	[3]	= 4,
 | 
	
		
			
				|  |  | +	[4]	= 6,
 | 
	
		
			
				|  |  | +	[5]	= 9,
 | 
	
		
			
				|  |  | +	[6]	= 10,
 | 
	
		
			
				|  |  | +	[7]	= 14,
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * get_tacc - turn tACC value into cycle time
 | 
	
		
			
				|  |  | + * @hclk_tns: The cycle time for HCLK, in 10ths of nanoseconds.
 | 
	
		
			
				|  |  | + * @val: The bank timing register value, shifed down.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +static unsigned int get_tacc(unsigned long hclk_tns,
 | 
	
		
			
				|  |  | +			     unsigned long val)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	val &= 7;
 | 
	
		
			
				|  |  | +	return hclk_tns * tacc_tab[val];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * get_0124 - turn 0/1/2/4 divider into cycle time
 | 
	
		
			
				|  |  | + * @hclk_tns: The cycle time for HCLK, in 10ths of nanoseconds.
 | 
	
		
			
				|  |  | + * @val: The bank timing register value, shifed down.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +static unsigned int get_0124(unsigned long hclk_tns,
 | 
	
		
			
				|  |  | +			     unsigned long val)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	val &= 3;
 | 
	
		
			
				|  |  | +	return hclk_tns * ((val == 3) ? 4 : val);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * s3c2410_iotiming_getbank - turn BANKCON into cycle time information
 | 
	
		
			
				|  |  | + * @cfg: The frequency configuration
 | 
	
		
			
				|  |  | + * @bt: The bank timing to fill in (uses cached BANKCON)
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Given the BANKCON setting in @bt and the current frequency settings
 | 
	
		
			
				|  |  | + * in @cfg, update the cycle timing information.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +void s3c2410_iotiming_getbank(struct s3c_cpufreq_config *cfg,
 | 
	
		
			
				|  |  | +			      struct s3c2410_iobank_timing *bt)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	unsigned long bankcon = bt->bankcon;
 | 
	
		
			
				|  |  | +	unsigned long hclk = cfg->freq.hclk_tns;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	bt->tcah = get_0124(hclk, bankcon >> S3C2410_BANKCON_Tcah_SHIFT);
 | 
	
		
			
				|  |  | +	bt->tcoh = get_0124(hclk, bankcon >> S3C2410_BANKCON_Tcoh_SHIFT);
 | 
	
		
			
				|  |  | +	bt->tcos = get_0124(hclk, bankcon >> S3C2410_BANKCON_Tcos_SHIFT);
 | 
	
		
			
				|  |  | +	bt->tacs = get_0124(hclk, bankcon >> S3C2410_BANKCON_Tacs_SHIFT);
 | 
	
		
			
				|  |  | +	bt->tacc = get_tacc(hclk, bankcon >> S3C2410_BANKCON_Tacc_SHIFT);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * s3c2410_iotiming_debugfs - debugfs show io bank timing information
 | 
	
		
			
				|  |  | + * @seq: The seq_file to write output to using seq_printf().
 | 
	
		
			
				|  |  | + * @cfg: The current configuration.
 | 
	
		
			
				|  |  | + * @iob: The IO bank information to decode.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +void s3c2410_iotiming_debugfs(struct seq_file *seq,
 | 
	
		
			
				|  |  | +			      struct s3c_cpufreq_config *cfg,
 | 
	
		
			
				|  |  | +			      union s3c_iobank *iob)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	struct s3c2410_iobank_timing *bt = iob->io_2410;
 | 
	
		
			
				|  |  | +	unsigned long bankcon = bt->bankcon;
 | 
	
		
			
				|  |  | +	unsigned long hclk = cfg->freq.hclk_tns;
 | 
	
		
			
				|  |  | +	unsigned int tacs;
 | 
	
		
			
				|  |  | +	unsigned int tcos;
 | 
	
		
			
				|  |  | +	unsigned int tacc;
 | 
	
		
			
				|  |  | +	unsigned int tcoh;
 | 
	
		
			
				|  |  | +	unsigned int tcah;
 | 
	
		
			
				|  |  | +
 |