summaryrefslogtreecommitdiff
path: root/board/st/u8500/emmc.c
diff options
context:
space:
mode:
authorMichael Brandt <michael.brandt@stericsson.com>2010-02-19 10:15:10 +0100
committerJonas ABERG <jonas.aberg@stericsson.com>2010-05-19 09:52:26 +0200
commitf4f7f7d70bc982d6689f09bf97e62caec223629f (patch)
tree35e858603bc26edc2ae6c9774486367acaa4a6f9 /board/st/u8500/emmc.c
parent1e4db0172510318ddc94ef7fcc071fdd435c2e47 (diff)
HREF V1 updates
This patch is part of WP254081 which depends on WP252006. * Fixed I2C, use real timeouts instead of counter * Undefined CONFIG_BOOTTIME, since it as to be changed to new timer.c * Merged V1 patches from Bangalore The patches were merged manually, because of the differences of the U-Boot baseline (Bangalore U-Boot 1.3.1, Lund 2009.11). The original patches were created by Rabin Vincent <rabin.vincent@stericsson.com>. and were applied originally to Branches: blr_lsp, remotes/origin/blr_lsp Follows: qpppaaa_20100210_094651 0001-u8500-gpio-add-I2C0-altfun.patch 0002-u8500-use-correct-v1-macros.patch 0003-emmc-clean-up-paritioning.patch 0004-u8500-remove-incorrect-ram-settings.patch 0005-u8500-gpio-remove-unnecessary-ifdefs.patch 0006-u8500-add-ED-v1-detection-and-handle-eMMC-diff.patch 0008-u8500-mmc-don-t-disable-altfuns.patch 0009-u8500-gpio-remove-unused-defined.patch 0010-u8500-mmc-add-barrier-for-while-loop.patch 0011-u8500-mmc-handle-non-block-addressed-cards.patch 0012-u8500-mmc-remove-unused-gpio-settings-on-v1.patch 0013-u8500-emmc-build-fix.patch 0014-u8500-handle-v1-gpios-and-clocks.patch 0015-mmc-build-fix-for-block-addressing.patch 0016-u8500-add-clocks-and-hardware-files.patch 0017-u8500-enable-PRCUM-timers-reg-for-ED.patch 0018-u8500-handle-MTU-for-v1-ED.patch 0019-u8500-emmc-remove-unnecessary-GPIO-settings.patch 0020-u8500-remove-dead-code.patch 0021-u8500-add-working-MTU-timer.patch 0022-pl011-empty-rx-fifo-if-necessary.patch 0023-u8500-gpio-fix-cont-handling-in-altfunc.patch 0024-u8500-reduce-bootdelay-to-1-and-enable-zero-check.patch 0025-u8500-disable-forcing-of-verify-but-set-n-by-default.patch 0029-u8500-fix-some-gpio-settings.patch 0030-emmc-make-v1-paritioning-differences-explicit.patch Signed-off-by: Michael Brandt <Michael.Brandt@stericsson.com> Change-Id: I1106702e393c34f630e71f071e06c3952b0d3a1a Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/182 Reviewed-by: Michael BRANDT <michael.brandt@stericsson.com> Tested-by: Jonas ABERG <jonas.aberg@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'board/st/u8500/emmc.c')
-rw-r--r--board/st/u8500/emmc.c192
1 files changed, 88 insertions, 104 deletions
diff --git a/board/st/u8500/emmc.c b/board/st/u8500/emmc.c
index eec9a1a8b..bfb33c803 100644
--- a/board/st/u8500/emmc.c
+++ b/board/st/u8500/emmc.c
@@ -39,11 +39,13 @@ int emmc_init(u8 card_num)
t_mmc_error mmc_error;
t_mmc_error response;
gpio_error gpioerror;
+ t_logical_address mmcbase;
int error;
-#ifndef CONFIG_U8500_V1
+ mmcbase = u8500_is_earlydrop() ? CFG_EMMC_BASE_ED : CFG_EMMC_BASE_V1;
+
/* Initialize the base address of eMMC */
- mmc_error = mmc_init(card_num, CFG_EMMC_BASE);
+ mmc_error = mmc_init(card_num, mmcbase);
if (MMC_OK != mmc_error)
{
@@ -51,36 +53,37 @@ int emmc_init(u8 card_num)
goto end;
}
- /* Initialize the gpio alternate function for eMMC */
- struct gpio_register *p_gpio_register = (void *) IO_ADDRESS(CFG_GPIO_6_BASE);
- p_gpio_register -> gpio_dats |= 0x0000FFE0;
- p_gpio_register -> gpio_pdis &= ~0x0000FFE0;
-
- //enable the alternate function of EMMC
- gpioerror = gpio_altfuncenable(GPIO_ALT_EMMC, "EMMC");
- if(gpioerror != GPIO_OK)
- {
- printf("emmc_init() gpio_altfuncenable %d failed\n", gpioerror);
- goto end;
- }
+ /*
+ * FIXME The following code is not required on v1. Check if it is really
+ * needed on ED or can be dropped.
+ */
+ if (u8500_is_earlydrop()) {
+#ifndef CONFIG_U8500_V1
+ /* Initialize the gpio alternate function for eMMC */
+ struct gpio_register *p_gpio_register = (void *) IO_ADDRESS(CFG_GPIO_6_BASE);
+ p_gpio_register -> gpio_dats |= 0x0000FFE0;
+ p_gpio_register -> gpio_pdis &= ~0x0000FFE0;
+
+ //enable the alternate function of EMMC
+ gpioerror = gpio_altfuncenable(GPIO_ALT_EMMC, "EMMC");
+ if(gpioerror != GPIO_OK)
+ {
+ printf("emmc_init() gpio_altfuncenable %d failed\n", gpioerror);
+ goto end;
+ }
#else
-/* Initialize the base address of PoP eMMC */
- mmc_error = mmc_init(card_num, CFG_POP_EMMC_BASE);
-
- if (MMC_OK != mmc_error)
- {
- printf("emmc_init() %d \n", mmc_error);
- goto end;
- }
- //enable the alternate function of PoP EMMC
- gpioerror = gpio_altfuncenable(GPIO_ALT_POP_EMMC, "EMMC");
- if (gpioerror != GPIO_OK) {
- printf("emmc_init() gpio_altfuncenable %d failed \n",
- gpioerror);
- goto end;
- }
+ //enable the alternate function of PoP EMMC
+ // gpioerror = gpio_altfuncenable(GPIO_ALT_POP_EMMC, "EMMC");
+ gpioerror = gpio_altfuncenable(GPIO_ALT_EMMC, "EMMC");
+ if (gpioerror != GPIO_OK) {
+ printf("emmc_init() gpio_altfuncenable %d failed \n",
+ gpioerror);
+ goto end;
+ }
#endif
+ }
+
//Power-on the controller
response = mmc_poweron(card_num);
if (response != MMC_OK)
@@ -105,91 +108,71 @@ int emmc_init(u8 card_num)
return 0;
end:
-#ifndef CONFIG_U8500_V1
- gpio_altfuncdisable(GPIO_ALT_EMMC, "EMMC");
-#else
- gpio_altfuncdisable(GPIO_ALT_POP_EMMC, "EMMC");
-#endif
mmc_poweroff(card_num);
return 1;
}
+struct partition {
+ unsigned char boot_ind; /* 0x80 - active */
+ unsigned char head; /* starting head */
+ unsigned char sector; /* starting sector */
+ unsigned char cyl; /* starting cylinder */
+ unsigned char sys_ind; /* What partition type */
+ unsigned char end_head; /* end head */
+ unsigned char end_sector; /* end sector */
+ unsigned char end_cyl; /* end cylinder */
+ u32 start_sect; /* starting sector counting from 0 */
+ u32 nr_sects; /* nr of sectors in partition */
+} __attribute__((packed));
+
+#define PART(type, start, num) \
+ { \
+ .boot_ind = 0x00, \
+ .head = 0x03, \
+ .sector = 0xD0, \
+ .cyl = 0xff, \
+ .sys_ind = type, \
+ .end_head = 0x03, \
+ .end_sector = 0xd0, \
+ .end_cyl = 0xff, \
+ .start_sect = start, \
+ .nr_sects = num, \
+ }
+
+static struct partition partitions_ed[] = {
+ [0] = PART(0x83, 0x000A0000, 0x00004000), /* Kernel */
+ [1] = PART(0x83, 0x000A4000, 0x00080000), /* Root file system */
+ [2] = PART(0x83, 0x00124000, 0x0022c000),
+ [3] = PART(0x0c, 0x00350000, 0x00b9a000),
+};
+
+static struct partition partitions_v1[] = {
+ [0] = PART(0x83, 0x000A0000, 0x00004000), /* Kernel */
+ [1] = PART(0x83, 0x000A4000, 0x00080000), /* Root file system */
+ [2] = PART(0x83, 0x00124000, 0x00000800), /* Modem parameters */
+ [3] = {0},
+};
+
+#undef PART
+
int emmc_write_pib(void)
{
int i;
t_mmc_error mmc_error;
u32 block_offset = PIB_EMMC_ADDR;
- u8 emmc_last_sector[512];
u8 card_num = 4;
+ u8 mbr[512];
- for (i = 0; i < 0x1BF; i++) {
- emmc_last_sector[i] = 0;
- }
- emmc_last_sector[0x1BF] = 0x03;
- emmc_last_sector[0x1C0] = 0xD0;
- emmc_last_sector[0x1C1] = 0xFF;
- emmc_last_sector[0x1C2] = 0x83;
- emmc_last_sector[0x1C3] = 0x03;
- emmc_last_sector[0x1C4] = 0xD0;
- emmc_last_sector[0x1C5] = 0xFF;
- emmc_last_sector[0x1C6] = 0x00;
- emmc_last_sector[0x1C7] = 0x00;
- emmc_last_sector[0x1C8] = 0x0A;
- emmc_last_sector[0x1C9] = 0x00;
- emmc_last_sector[0x1CA] = 0x00;
- emmc_last_sector[0x1CB] = 0x40;
- emmc_last_sector[0x1CC] = 0x00;
- emmc_last_sector[0x1CD] = 0x00;
- emmc_last_sector[0x1CE] = 0x00;
- emmc_last_sector[0x1CF] = 0x03;
- emmc_last_sector[0x1D0] = 0xD0;
- emmc_last_sector[0x1D1] = 0xFF;
- emmc_last_sector[0x1D2] = 0x83;
- emmc_last_sector[0x1D3] = 0x03;
- emmc_last_sector[0x1D4] = 0xD0;
- emmc_last_sector[0x1D5] = 0xFF;
- emmc_last_sector[0x1D6] = 0x00;
- emmc_last_sector[0x1D7] = 0x40;
- emmc_last_sector[0x1D8] = 0x0A;
- emmc_last_sector[0x1D9] = 0x00;
- emmc_last_sector[0x1DA] = 0x00;
- emmc_last_sector[0x1DB] = 0x00;
- emmc_last_sector[0x1DC] = 0x08;
- emmc_last_sector[0x1DD] = 0x00;
- emmc_last_sector[0x1DE] = 0x00;
- emmc_last_sector[0x1DF] = 0x03;
- emmc_last_sector[0x1E0] = 0xD0;
- emmc_last_sector[0x1E1] = 0xFF;
- emmc_last_sector[0x1E2] = 0x83;
- emmc_last_sector[0x1E3] = 0x03;
- emmc_last_sector[0x1E4] = 0xD0;
- emmc_last_sector[0x1E5] = 0xFF;
- emmc_last_sector[0x1E6] = 0x00;
- emmc_last_sector[0x1E7] = 0x40;
- emmc_last_sector[0x1E8] = 0x12;
- emmc_last_sector[0x1E9] = 0x00;
- emmc_last_sector[0x1EA] = 0x00;
- emmc_last_sector[0x1EB] = 0xC0;
- emmc_last_sector[0x1EC] = 0x22;
- emmc_last_sector[0x1ED] = 0x00;
- emmc_last_sector[0x1EE] = 0x00;
- emmc_last_sector[0x1EF] = 0x03;
- emmc_last_sector[0x1F0] = 0xD0;
- emmc_last_sector[0x1F1] = 0xFF;
- emmc_last_sector[0x1F2] = 0x0C;
- emmc_last_sector[0x1F3] = 0x03;
- emmc_last_sector[0x1F4] = 0xD0;
- emmc_last_sector[0x1F5] = 0xFF;
- emmc_last_sector[0x1F6] = 0x00;
- emmc_last_sector[0x1F7] = 0x00;
- emmc_last_sector[0x1F8] = 0x35;
- emmc_last_sector[0x1F9] = 0x00;
- emmc_last_sector[0x1FA] = 0x00;
- emmc_last_sector[0x1FB] = 0xA0;
- emmc_last_sector[0x1FC] = 0xB9;
- emmc_last_sector[0x1FD] = 0x00;
- emmc_last_sector[0x1FE] = 0x55;
- emmc_last_sector[0x1FF] = 0xAA;
+ memset(mbr, 0, 0x1be);
+
+ if (u8500_is_earlydrop())
+ memcpy(mbr + 0x1be, partitions_ed, sizeof(partitions_ed));
+ else
+ memcpy(mbr + 0x1be, partitions_v1, sizeof(partitions_v1));
+
+ /* magic */
+ mbr[0x1fe] = 0x55;
+ mbr[0x1ff] = 0xAA;
/* HACK required for HREF board as erase block size = 512KB */
/*
@@ -199,8 +182,9 @@ int emmc_write_pib(void)
return 1;
}
*/
+
mmc_error =
- mmc_writeblocks(card_num, block_offset, (u32 *) emmc_last_sector,
+ mmc_writeblocks(card_num, block_offset, (u32 *) mbr,
512, 1);
if (mmc_error != MMC_OK) {
printf(" eMMC PIB write failed \n");