aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm63xx/patches-3.3/427-MTD-m25p80-allow-passing-pp_data.patch
blob: 51836f56175b09c44cceb42baccfbf26989abb34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
From 087a67d5750a51f5b0851228b5b2518f3300f7d8 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jonas.gorski@gmail.com>
Date: Thu, 3 May 2012 12:17:54 +0200
Subject: [PATCH 65/79] MIPS: BCM63XX: store the flash type in global variable

---
 arch/mips/bcm63xx/dev-flash.c                      |   36 +++++++++++++-------
 .../include/asm/mach-bcm63xx/bcm63xx_dev_flash.h   |    2 ++
 2 files changed, 26 insertions(+), 12 deletions(-)

--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -24,6 +24,8 @@
 #include <bcm63xx_regs.h>
 #include <bcm63xx_io.h>
 
+int bcm63xx_attached_flash = -1;
+
 static struct mtd_partition mtd_partitions[] = {
 	{
 		.name		= "cfe",
@@ -81,20 +83,23 @@ static int __init bcm63xx_detect_flash_t
 		bcm63xx_spi_flash_info[0].max_speed_hz = 40000000;
 		val = bcm_misc_readl(MISC_STRAPBUS_6328_REG);
 		if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
-			return BCM63XX_FLASH_TYPE_SERIAL;
+			bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
 		else
-			return BCM63XX_FLASH_TYPE_NAND;
+			bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
+		break;
 	case BCM6338_CPU_ID:
 	case BCM6345_CPU_ID:
 	case BCM6348_CPU_ID:
 		/* no way to auto detect so assume parallel */
-		return BCM63XX_FLASH_TYPE_PARALLEL;
+		bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
+		break;
 	case BCM6358_CPU_ID:
 		val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
 		if (val & STRAPBUS_6358_BOOT_SEL_PARALLEL)
-			return BCM63XX_FLASH_TYPE_PARALLEL;
+			bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
 		else
-			return BCM63XX_FLASH_TYPE_SERIAL;
+			bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
+		break;
 	case BCM6368_CPU_ID:
 		val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
 		if (val & STRAPBUS_6368_SPI_CLK_FAST)
@@ -102,25 +107,32 @@ static int __init bcm63xx_detect_flash_t
 
 		switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
 		case STRAPBUS_6368_BOOT_SEL_NAND:
-			return BCM63XX_FLASH_TYPE_NAND;
+			bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
+			break;
 		case STRAPBUS_6368_BOOT_SEL_SERIAL:
-			return BCM63XX_FLASH_TYPE_SERIAL;
+			bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
+			break;
 		case STRAPBUS_6368_BOOT_SEL_PARALLEL:
-			return BCM63XX_FLASH_TYPE_PARALLEL;
+			bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
+			break;
+		default:
+			return -EINVAL;
 		}
 	default:
 		return -EINVAL;
 	}
+
+	return 0;
 }
 
 int __init bcm63xx_flash_register(void)
 {
-	int flash_type;
 	u32 val;
 
-	flash_type = bcm63xx_detect_flash_type();
 
-	switch (flash_type) {
+	bcm63xx_detect_flash_type();
+
+	switch (bcm63xx_attached_flash) {
 	case BCM63XX_FLASH_TYPE_PARALLEL:
 		/* read base address of boot chip select (0) */
 		val = bcm_mpi_readl(MPI_CSBASE_REG(0));
@@ -141,7 +153,7 @@ int __init bcm63xx_flash_register(void)
 		return -ENODEV;
 	default:
 		pr_err("flash detection failed for BCM%x: %d",
-		       bcm63xx_get_cpu_id(), flash_type);
+		       bcm63xx_get_cpu_id(), bcm63xx_attached_flash);
 		return -ENODEV;
 	}
 }
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
@@ -7,6 +7,8 @@ enum {
 	BCM63XX_FLASH_TYPE_NAND,
 };
 
+extern int bcm63xx_attached_flash;
+
 int __init bcm63xx_flash_register(void);
 
 #endif /* __BCM63XX_FLASH_H */