bcm63xx: Fix caldata partition mtd patch

Allow bcm63xxpart to receive a caldata offset if calibration data is contained in flash.

Tested-by: Álvaro Fernández Rojas <noltari@gmail.com>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>

SVN-Revision: 35010
This commit is contained in:
Jonas Gorski 2013-01-04 14:47:50 +00:00
parent 10fc07daac
commit 0e58173fa5

View file

@ -1,18 +1,18 @@
From 8ab86c5dc38ad4de1442e50e0adbc354d9184d71 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jonas.gorski@gmail.com>
Date: Tue, 1 May 2012 14:38:41 +0200
Subject: [PATCH 68/79] MTD: bcm63xxpart: allow passing a caldata offset
Allow bcm63xxpart to receive a caldata offset if calibration data is Allow bcm63xxpart to receive a caldata offset if calibration data is
contained in flash. contained in flash.
--- ---
drivers/mtd/bcm63xxpart.c | 47 ++++++++++++++++++++++++++++++++++++++-- drivers/mtd/bcm63xxpart.c | 51 ++++++++++++++++++++++++++++++++++++---
include/linux/mtd/partitions.h | 2 ++ include/linux/mtd/partitions.h | 2 +
2 files changed, 47 insertions(+), 2 deletions(-) 2 files changed, 49 insertions(+), 4 deletions(-)
--- a/drivers/mtd/bcm63xxpart.c --- a/drivers/mtd/bcm63xxpart.c
+++ b/drivers/mtd/bcm63xxpart.c +++ b/drivers/mtd/bcm63xxpart.c
@@ -80,6 +80,8 @@ static int bcm63xx_parse_cfe_partitions( @@ -76,10 +76,12 @@ static int bcm63xx_parse_cfe_partitions(
struct mtd_partition *parts;
int ret;
size_t retlen;
- unsigned int rootfsaddr, kerneladdr, spareaddr;
+ unsigned int rootfsaddr, kerneladdr, spareaddr, nvramaddr;
unsigned int rootfslen, kernellen, sparelen, totallen; unsigned int rootfslen, kernellen, sparelen, totallen;
unsigned int cfelen, nvramlen; unsigned int cfelen, nvramlen;
unsigned int cfe_erasesize; unsigned int cfe_erasesize;
@ -21,10 +21,12 @@ contained in flash.
int i; int i;
u32 computed_crc; u32 computed_crc;
bool rootfs_first = false; bool rootfs_first = false;
@@ -94,6 +96,23 @@ static int bcm63xx_parse_cfe_partitions( @@ -93,6 +95,24 @@ static int bcm63xx_parse_cfe_partitions(
cfelen = cfe_erasesize;
nvramlen = bcm63xx_nvram_get_psi_size() * 1024; nvramlen = bcm63xx_nvram_get_psi_size() * 1024;
nvramlen = roundup(nvramlen, cfe_erasesize); nvramlen = roundup(nvramlen, cfe_erasesize);
+ nvramaddr = master->size - nvramlen;
+
+ if (data) { + if (data) {
+ if (data->caldata[0]) { + if (data->caldata[0]) {
+ caldatalen1 = cfe_erasesize; + caldatalen1 = cfe_erasesize;
@ -41,20 +43,19 @@ contained in flash.
+ caldatalen2 = 0; + caldatalen2 = 0;
+ } + }
+ } + }
+
/* Allocate memory for buffer */ /* Allocate memory for buffer */
buf = vmalloc(sizeof(struct bcm_tag)); buf = vmalloc(sizeof(struct bcm_tag));
if (!buf) @@ -144,7 +164,7 @@ static int bcm63xx_parse_cfe_partitions(
@@ -144,7 +163,7 @@ static int bcm63xx_parse_cfe_partitions(
rootfsaddr = 0; rootfsaddr = 0;
spareaddr = cfelen; spareaddr = cfelen;
} }
- sparelen = master->size - spareaddr - nvramlen; - sparelen = master->size - spareaddr - nvramlen;
+ sparelen = master->size - spareaddr - nvramlen - caldatalen1 - caldatalen2; + sparelen = min_not_zero(nvramaddr, caldataaddr1) - spareaddr;
/* Determine number of partitions */ /* Determine number of partitions */
if (rootfslen > 0) if (rootfslen > 0)
@@ -153,6 +172,12 @@ static int bcm63xx_parse_cfe_partitions( @@ -153,6 +173,12 @@ static int bcm63xx_parse_cfe_partitions(
if (kernellen > 0) if (kernellen > 0)
nrparts++; nrparts++;
@ -67,7 +68,7 @@ contained in flash.
/* Ask kernel for more memory */ /* Ask kernel for more memory */
parts = kzalloc(sizeof(*parts) * nrparts + 10 * nrparts, GFP_KERNEL); parts = kzalloc(sizeof(*parts) * nrparts + 10 * nrparts, GFP_KERNEL);
if (!parts) { if (!parts) {
@@ -190,6 +215,23 @@ static int bcm63xx_parse_cfe_partitions( @@ -190,15 +216,32 @@ static int bcm63xx_parse_cfe_partitions(
curpart++; curpart++;
} }
@ -89,15 +90,16 @@ contained in flash.
+ } + }
+ +
parts[curpart].name = "nvram"; parts[curpart].name = "nvram";
parts[curpart].offset = master->size - nvramlen; - parts[curpart].offset = master->size - nvramlen;
+ parts[curpart].offset = nvramaddr;
parts[curpart].size = nvramlen; parts[curpart].size = nvramlen;
@@ -198,7 +240,8 @@ static int bcm63xx_parse_cfe_partitions( curpart++;
/* Global partition "linux" to make easy firmware upgrade */ /* Global partition "linux" to make easy firmware upgrade */
parts[curpart].name = "linux"; parts[curpart].name = "linux";
parts[curpart].offset = cfelen; parts[curpart].offset = cfelen;
- parts[curpart].size = master->size - cfelen - nvramlen; - parts[curpart].size = master->size - cfelen - nvramlen;
+ parts[curpart].size = master->size - cfelen - nvramlen + parts[curpart].size = min_not_zero(nvramaddr, caldataaddr1) - cfelen;
+ - caldatalen1 - caldatalen2;
for (i = 0; i < nrparts; i++) for (i = 0; i < nrparts; i++)
pr_info("Partition %d is %s offset %llx and length %llx\n", i, pr_info("Partition %d is %s offset %llx and length %llx\n", i,