[PATCH] S3C2412 TACLS rate calculation fix

Ben Dooks ben at fluff.org.uk
Tue Feb 13 06:12:04 EST 2007


The TALCs value on the S3C2412 value does not have
an +1 adjustment unlike the S3C2410 and S3C2440.

The TALCs value on the S3C2440 is only 2 bits instead
of three, so change it to a maximum of 4.

Re-work of an patch by Matt Reimer <mreimer at vpop.net>

Signed-off-by: Ben Dooks <ben-linux at fluff.org>

diff -urpN -X ../dontdiff linux-2.6.20-rmk-12feb2007/drivers/mtd/nand/s3c2410.c linux-2.6.20-rmk-12feb2007-bjd1/drivers/mtd/nand/s3c2410.c
--- linux-2.6.20-rmk-12feb2007/drivers/mtd/nand/s3c2410.c	2007-02-04 18:44:54.000000000 +0000
+++ linux-2.6.20-rmk-12feb2007-bjd1/drivers/mtd/nand/s3c2410.c	2007-02-13 10:53:54.000000000 +0000
@@ -183,15 +183,17 @@ static int s3c2410_nand_inithw(struct s3
 {
 	struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
 	unsigned long clkrate = clk_get_rate(info->clk);
-	int tacls_max = (info->cpu_type == TYPE_S3C2412) ? 8 : 4;
+	int tacls_max = (info->cpu_type == TYPE_S3C2440) ? 3 : 7;
+	int tacls_adj = (info->cpu_type == TYPE_S3C2412) ? 0 : -1;
 	int tacls, twrph0, twrph1;
 	unsigned long cfg = 0;
 
 	/* calculate the timing information for the controller */
 
 	clkrate /= 1000;	/* turn clock into kHz for ease of use */
+	tacls_max -= tacls_adj;
 
-	if (plat != NULL) {
+	if (plat != NULL) {	
 		tacls = s3c_nand_calc_rate(plat->tacls, clkrate, tacls_max);
 		twrph0 = s3c_nand_calc_rate(plat->twrph0, clkrate, 8);
 		twrph1 = s3c_nand_calc_rate(plat->twrph1, clkrate, 8);
@@ -207,20 +209,23 @@ static int s3c2410_nand_inithw(struct s3
 		return -EINVAL;
 	}
 
-	dev_info(info->device, "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n",
-	       tacls, to_ns(tacls, clkrate), twrph0, to_ns(twrph0, clkrate), twrph1, to_ns(twrph1, clkrate));
+	dev_info(info->device,
+		 "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n",
+		 tacls, to_ns(tacls, clkrate),
+		 twrph0, to_ns(twrph0, clkrate),
+		 twrph1, to_ns(twrph1, clkrate));
 
  	switch (info->cpu_type) {
  	case TYPE_S3C2410:
 		cfg = S3C2410_NFCONF_EN;
-		cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
+		cfg |= S3C2410_NFCONF_TACLS(tacls + tacls_adj);
 		cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
 		cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
 		break;
 
  	case TYPE_S3C2440:
  	case TYPE_S3C2412:
-		cfg = S3C2440_NFCONF_TACLS(tacls - 1);
+		cfg = S3C2440_NFCONF_TACLS(tacls + tacls_adj);
 		cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1);
 		cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1);
 




More information about the linux-mtd mailing list