summaryrefslogtreecommitdiff
path: root/cleopatre
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre')
-rw-r--r--cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-devices.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-devices.c b/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-devices.c
index d628e42cba..66c5de7be3 100644
--- a/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-devices.c
+++ b/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-devices.c
@@ -36,6 +36,7 @@
#include "../drivers/net/arm/synop3504.h"
#include "spc300-devices.h"
+#include "spc300.h"
/**
* UART Devices Structures
@@ -480,6 +481,83 @@ void spc300_add_device_ethernet(void)
#endif
}
+/**
+ * Fill a MTD partitions table.
+ * \param nvram_offset offset of the nvram starting at the base of the flash
+ * (it is usually given as a boot param)
+ * \param nvram the nvram itself (for the linux images information)
+ * \param mtd_partition the generated partition table - you need to
+ * allocate it
+ * \param nb_part number of partition in mtd_partition (allocated)
+ * \return negative value if error, otherwise number of partition filled in
+ * the partition table (mtd_partition)
+ */
+static int spc300_gen_mtd_partition_table(uint32_t nvram_offset,
+ spidcom_nvram_t *nvram,
+ struct mtd_partition *mtd_partition,
+ uint nb_part)
+{
+ uint pos = 0;
+ int ret;
+ const uint linux_image_str_size = 10;
+ const uint nvram_size = 0x00010000;
+ struct mtd_partition base_partition[] =
+ {
+ {
+ .name = "u-boot",
+ .size = nvram_offset,
+ .offset = 0,
+ .mask_flags = 0,
+ }, {
+ .name = "nvram",
+ .size = nvram_size,
+ .offset = MTDPART_OFS_APPEND,
+ .mask_flags = 0,
+ }, {
+ .name = "user-fs",
+ .size = nvram->img_0_offset - nvram_offset - nvram_size,
+ .offset = MTDPART_OFS_APPEND,
+ .mask_flags = 0,
+ },
+ };
+ uint base_partition_size = ARRAY_SIZE(base_partition);
+
+ //Check parameters (except nvram which has already been used - if it is
+ //NULL, it will make an oops).
+ BUG_ON(nvram_offset == NVRAM_OFFSET_INVALID);
+ BUG_ON(!mtd_partition);
+ //u-boot + nvram + user-fs + nb_images linux.
+ BUG_ON(nb_part < (base_partition_size + nvram->nb_images));
+
+ //Copy base partitions.
+ for (pos = 0; pos < base_partition_size; pos++)
+ {
+ mtd_partition[pos] = base_partition[pos];
+ }
+
+ //Copy Linux image partitions.
+ for (pos = 0; pos < nvram->nb_images; pos++)
+ {
+ //Build image name.
+ mtd_partition[base_partition_size + pos].name
+ = kcalloc(linux_image_str_size, 1, 0);
+ BUG_ON(!mtd_partition[base_partition_size + pos].name);
+ ret = snprintf(mtd_partition[base_partition_size + pos].name,
+ linux_image_str_size, "image %d", pos);
+ BUG_ON(ret < 0);
+
+ mtd_partition[base_partition_size + pos].size =
+ nvram->img_max_size;
+ mtd_partition[base_partition_size + pos].offset =
+ MTDPART_OFS_APPEND;
+ mtd_partition[base_partition_size + pos].mask_flags = 0;
+ }
+ //Last image should expand on the whole remaining space.
+ mtd_partition[base_partition_size + pos - 1].size = MTDPART_SIZ_FULL;
+
+ return base_partition_size + nvram->nb_images;
+}
+
void __init spc300_add_device_spidevs(struct spc300_flash_spi_dev *flash, struct spc300_afe_spi_dev *afe)
{
unsigned int pos = 0;