aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ssb/driver_chipcommon_sflash.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ssb/driver_chipcommon_sflash.c')
-rw-r--r--drivers/ssb/driver_chipcommon_sflash.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/drivers/ssb/driver_chipcommon_sflash.c b/drivers/ssb/driver_chipcommon_sflash.c
index 720665ca2bb1..e84cf04f4416 100644
--- a/drivers/ssb/driver_chipcommon_sflash.c
+++ b/drivers/ssb/driver_chipcommon_sflash.c
@@ -9,6 +9,19 @@
9 9
10#include "ssb_private.h" 10#include "ssb_private.h"
11 11
12static struct resource ssb_sflash_resource = {
13 .name = "ssb_sflash",
14 .start = SSB_FLASH2,
15 .end = 0,
16 .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
17};
18
19struct platform_device ssb_sflash_dev = {
20 .name = "ssb_sflash",
21 .resource = &ssb_sflash_resource,
22 .num_resources = 1,
23};
24
12struct ssb_sflash_tbl_e { 25struct ssb_sflash_tbl_e {
13 char *name; 26 char *name;
14 u32 id; 27 u32 id;
@@ -16,7 +29,7 @@ struct ssb_sflash_tbl_e {
16 u16 numblocks; 29 u16 numblocks;
17}; 30};
18 31
19static struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = { 32static const struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
20 { "M25P20", 0x11, 0x10000, 4, }, 33 { "M25P20", 0x11, 0x10000, 4, },
21 { "M25P40", 0x12, 0x10000, 8, }, 34 { "M25P40", 0x12, 0x10000, 8, },
22 35
@@ -27,7 +40,7 @@ static struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
27 { 0 }, 40 { 0 },
28}; 41};
29 42
30static struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = { 43static const struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
31 { "SST25WF512", 1, 0x1000, 16, }, 44 { "SST25WF512", 1, 0x1000, 16, },
32 { "SST25VF512", 0x48, 0x1000, 16, }, 45 { "SST25VF512", 0x48, 0x1000, 16, },
33 { "SST25WF010", 2, 0x1000, 32, }, 46 { "SST25WF010", 2, 0x1000, 32, },
@@ -45,7 +58,7 @@ static struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
45 { 0 }, 58 { 0 },
46}; 59};
47 60
48static struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = { 61static const struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = {
49 { "AT45DB011", 0xc, 256, 512, }, 62 { "AT45DB011", 0xc, 256, 512, },
50 { "AT45DB021", 0x14, 256, 1024, }, 63 { "AT45DB021", 0x14, 256, 1024, },
51 { "AT45DB041", 0x1c, 256, 2048, }, 64 { "AT45DB041", 0x1c, 256, 2048, },
@@ -73,7 +86,8 @@ static void ssb_sflash_cmd(struct ssb_chipcommon *cc, u32 opcode)
73/* Initialize serial flash access */ 86/* Initialize serial flash access */
74int ssb_sflash_init(struct ssb_chipcommon *cc) 87int ssb_sflash_init(struct ssb_chipcommon *cc)
75{ 88{
76 struct ssb_sflash_tbl_e *e; 89 struct ssb_sflash *sflash = &cc->dev->bus->mipscore.sflash;
90 const struct ssb_sflash_tbl_e *e;
77 u32 id, id2; 91 u32 id, id2;
78 92
79 switch (cc->capabilities & SSB_CHIPCO_CAP_FLASHT) { 93 switch (cc->capabilities & SSB_CHIPCO_CAP_FLASHT) {
@@ -131,9 +145,21 @@ int ssb_sflash_init(struct ssb_chipcommon *cc)
131 return -ENOTSUPP; 145 return -ENOTSUPP;
132 } 146 }
133 147
148 sflash->window = SSB_FLASH2;
149 sflash->blocksize = e->blocksize;
150 sflash->numblocks = e->numblocks;
151 sflash->size = sflash->blocksize * sflash->numblocks;
152 sflash->present = true;
153
134 pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n", 154 pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n",
135 e->name, e->blocksize, e->numblocks); 155 e->name, e->blocksize, e->numblocks);
136 156
157 /* Prepare platform device, but don't register it yet. It's too early,
158 * malloc (required by device_private_init) is not available yet. */
159 ssb_sflash_dev.resource[0].end = ssb_sflash_dev.resource[0].start +
160 sflash->size;
161 ssb_sflash_dev.dev.platform_data = sflash;
162
137 pr_err("Serial flash support is not implemented yet!\n"); 163 pr_err("Serial flash support is not implemented yet!\n");
138 164
139 return -ENOTSUPP; 165 return -ENOTSUPP;