changeset 523:9a478d33b3ca

fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 09 Jun 2019 21:51:27 +0000
parents 26bb2c069427
children e9385c835824
files loadtools/flashid.c loadtools/fldevs.c
diffstat 2 files changed, 68 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/flashid.c	Thu Jun 06 06:56:32 2019 +0000
+++ b/loadtools/flashid.c	Sun Jun 09 21:51:27 2019 +0000
@@ -17,6 +17,7 @@
 extern struct flash_device flashdev_PL129J;
 extern struct flash_device flashdev_PL129N;
 extern struct flash_device flashdev_K5A32xx_T;
+extern struct flash_device flashdev_K5L33xx_A;
 
 extern int flash_global_config;
 extern struct flash_bank_info flash_bank_info[2];
@@ -114,6 +115,24 @@
 	return(-1);
 }
 
+static
+samsung_extended_id(bi)
+	struct flash_bank_info *bi;
+{
+	uint16_t ext1, ext2;
+
+	printf("Samsung extended ID device, reading extended ID\n");
+	if (do_r16(bi->base_addr + 0x1C, &ext1) < 0)
+		return(-1);
+	if (do_r16(bi->base_addr + 0x1E, &ext2) < 0)
+		return(-1);
+	printf("Extended ID: %04X %04X\n", ext1, ext2);
+	if (ext1 == 0x2503 && ext2 == 0x2501)
+		return try_device(bi, &flashdev_K5L33xx_A);
+	fprintf(stderr, "Error: unknown device ID\n");
+	return(-1);
+}
+
 static struct idmap {
 	uint16_t	manuf_id;
 	uint16_t	dev_id;
@@ -135,6 +154,7 @@
 	{0x0089, 0x88CD, try_device, &flashdev_28F640C3B},
 	/* Samsung flash */
 	{0x00EC, 0x22A0, try_device, &flashdev_K5A32xx_T},
+	{0x00EC, 0x257E, samsung_extended_id, 0},
 	/* table search terminator */
 	{0,      0,      0,          0}
 };
--- a/loadtools/fldevs.c	Thu Jun 06 06:56:32 2019 +0000
+++ b/loadtools/fldevs.c	Sun Jun 09 21:51:27 2019 +0000
@@ -31,6 +31,13 @@
 	.total_sectors	= 71,
 };
 
+static struct flash_geom geom_4M_bothends = {
+	.total_size	= 0x400000,
+	.nregions	= 3,
+	.regions	= {0x2000, 8, 0x10000, 62, 0x2000, 8},
+	.total_sectors	= 78,
+};
+
 static struct flash_geom geom_8M_topboot = {
 	.total_size	= 0x800000,
 	.nregions	= 2,
@@ -300,3 +307,44 @@
 	.bank_geom		= {&geom_4M_topboot, 0},
 	.cmdset			= &flash_cmdset_amd,
 };
+
+/* a different 4 MiB Samsung flash chip used in Huawei GTM900 */
+
+static struct cfi_check samsung_4M_bothends_cfi[] = {
+	{0x10, 'Q'},
+	{0x11, 'R'},
+	{0x12, 'Y'},
+	{0x13, 0x02},
+	{0x14, 0x00},
+	{0x15, 0x40},
+	{0x16, 0x00},
+	{0x27, 0x16},
+	{0x2C, 0x03},
+	{0x2D, 0x07},
+	{0x2E, 0x00},
+	{0x2F, 0x20},
+	{0x30, 0x00},
+	{0x31, 0x3D},
+	{0x32, 0x00},
+	{0x33, 0x00},
+	{0x34, 0x01},
+	{0x35, 0x07},
+	{0x36, 0x00},
+	{0x37, 0x20},
+	{0x38, 0x00},
+	{0x40, 'P'},
+	{0x41, 'R'},
+	{0x42, 'I'},
+	{0x43, '0'},
+	{0x44, '0'},
+	{0x4F, 0x04},
+	{-1,   0}
+};
+
+struct flash_device flashdev_K5L33xx_A = {
+	.name			= "Samsung K5L33xx_A",
+	.cfi_table		= samsung_4M_bothends_cfi,
+	.required_global_config	= FLASH_GLOBAL_CFG_SINGLE_4M,
+	.bank_geom		= {&geom_4M_bothends, 0},
+	.cmdset			= &flash_cmdset_amd,
+};