From c0b34f5c4bd037cd93709b30ee1a670723e77084 Mon Sep 17 00:00:00 2001 From: Michael Brandt Date: Tue, 10 Nov 2009 16:39:53 +0100 Subject: PACK2 changes merged PACK2 changes: mmc and i2c frequency, put the second core into wfe, default bootcmd. --- board/st/u8500/Makefile | 2 +- board/st/u8500/core2.S | 56 ++++++++++++++++++++++++++++++++++++++++++++++ board/st/u8500/mmc_utils.c | 2 +- board/st/u8500/u8500.c | 33 ++++++++++++++++----------- 4 files changed, 78 insertions(+), 15 deletions(-) create mode 100755 board/st/u8500/core2.S (limited to 'board') diff --git a/board/st/u8500/Makefile b/board/st/u8500/Makefile index 78eece7fe..632a49161 100755 --- a/board/st/u8500/Makefile +++ b/board/st/u8500/Makefile @@ -27,7 +27,7 @@ CFLAGS += -D__RELEASE -D__STN_8500 LIB = $(obj)lib$(BOARD).a COBJS := u8500.o flash.o gpio.o i2c.o mmc.o mmc_utils.o init_mmc.o emmc.o -SOBJS := +SOBJS := core2.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/board/st/u8500/core2.S b/board/st/u8500/core2.S new file mode 100755 index 000000000..7152e3077 --- /dev/null +++ b/board/st/u8500/core2.S @@ -0,0 +1,56 @@ +/* + * secondary_wfe() + * Copyright (c) 2009 ST Ericsson + * Author: Srinidhi Kasagar + * + * puts the secondary core in wfe. This is required for the locked + * version of ST Ericsson SMP platform to attach the debugger at this stage. + * This is a GCC generated code. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +.global secondary_startup +secondary_startup: + dsb @ WFI may enter a low-power mode + wfi + mov pc, lr + +.global secondary_wfe +secondary_wfe: +.L8: wfe + ldr r0, .L9 + ldr r1, .L9+4 + ldr r3, [r0, #4080] + str r3, [r1, #0] + ldr r3, .L9+8 + ldr r2, [r1, #0] + cmp r2, r3 + bne .L8 + ldr r3, [r0, #4084] + str r3, [r1, #4] + blx r3 + b .L8 +.L10: + .align 2 +.L9: + .word -2146103296 + .word .LANCHOR0 + .word -1577128703 + .size secondary_wfe, .-secondary_wfe + .global handler + .global magic_num + .bss + .align 2 +.LANCHOR0 = . + 0 + .type magic_num, %object + .size magic_num, 4 +magic_num: + .space 4 + .type handler, %object + .size handler, 4 +handler: + .space 4 + .ident "GCC: (GNU) 4.2.3" + .section .note.GNU-stack,"",%progbits diff --git a/board/st/u8500/mmc_utils.c b/board/st/u8500/mmc_utils.c index b7d4e7085..3c31d9333 100755 --- a/board/st/u8500/mmc_utils.c +++ b/board/st/u8500/mmc_utils.c @@ -224,7 +224,7 @@ t_mmc_error mmc_initCard () clockcontrol.pwrsave= MMC_DISABLE; clockcontrol.bypass = MMC_DISABLE; clockcontrol.widebus= MMC_DISABLE; - error = mmc_setclockfrequency (0x0A); // 12MHz + error = mmc_setclockfrequency(0x00); /* 26 MHz */ if (error != MMC_OK) { goto end; diff --git a/board/st/u8500/u8500.c b/board/st/u8500/u8500.c index 0cca76cf3..4bb94e2b9 100755 --- a/board/st/u8500/u8500.c +++ b/board/st/u8500/u8500.c @@ -27,20 +27,26 @@ #include #include "common.h" +#define NOMADIK_PER4_BASE (0x80150000) +#define NOMADIK_BACKUPRAM0_BASE (NOMADIK_PER4_BASE + 0x00000) +#define NOMADIK_BACKUPRAM1_BASE (NOMADIK_PER4_BASE + 0x01000) -void init_regs(void); -#if 0 -void *memcopy(void *dest, const void *src, size_t count) +extern void (*handler)(); +extern unsigned volatile long magic_num; +extern void secondary_wfe(); + +void wake_up_other_cores() { - u16 *tmp = (u16 *) dest, *s = (u16 *) src; + handler = secondary_wfe; + *((volatile unsigned int *)(NOMADIK_BACKUPRAM0_BASE+0x1FF4))= handler; + *((volatile unsigned int *)(NOMADIK_BACKUPRAM0_BASE+0x1FF0))= 0xA1FEED01; + asm("SEV"); + return; +} - count = count / 2; - while (count--) - *tmp++ = *s++; +void init_regs(void); - return dest; -} -#endif +DECLARE_GLOBAL_DATA_PTR; #if defined(CONFIG_SHOW_BOOT_PROGRESS) void show_boot_progress(int progress) { @@ -60,7 +66,6 @@ static inline void delay(unsigned long loops) int board_init(void) { - DECLARE_GLOBAL_DATA_PTR; gd->bd->bi_arch_number = 0x1A4; gd->bd->bi_boot_params = 0x00000100; //enable the timers in PRCMU reg @@ -86,12 +91,13 @@ Description: ******************************/ int dram_init(void) { - DECLARE_GLOBAL_DATA_PTR; gd->bd->bi_dram[0].start = PHYS_SDRAM_1; gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE_1; +#ifdef CONFIG_U8500_V1 gd->bd->bi_dram[1].start = PHYS_SDRAM_2; gd->bd->bi_dram[1].size = PHYS_SDRAM_SIZE_2; - +#endif + wake_up_other_cores(); return 0; } @@ -103,6 +109,7 @@ unsigned int addr_vall_arr[] = { 0x8000F008, 0x00007FFF, // Clocks for I2C TODO Enable reqd only 0x8000E120, 0x003C0000, // GPIO for I2C/SD 0x8000E124, 0x00000000, // GPIO for I2C/SD +0x80157020, 0x00000130, // I2C 48MHz clock 0x8012F000, 0x00007FFF, // Clocks for SD TODO Enable reqd only 0x8012F008, 0x00007FFF, // Clocks for SD TODO Enable reqd only 0xA03DF000, 0x0000000D, // Clock for MTU Timers -- cgit v1.2.3 From 509b586bdead191b624099537525b96b6822e06e Mon Sep 17 00:00:00 2001 From: Michael Brandt Date: Mon, 23 Nov 2009 10:26:01 +0100 Subject: support eMMC and MMC as block devices mmc init 0 will now initialise eMMC and mmc init 1 initialises MMC. They can now be used in subsequent fatload or ext2load commands. The numbering was choosing according to the Linux device numbering /dev/mmcblk0 (eMMC) and /dev/mmcblk1 (MMC). --- board/st/u8500/init_mmc.c | 199 ++++++++++++++++++---------------------------- 1 file changed, 79 insertions(+), 120 deletions(-) (limited to 'board') diff --git a/board/st/u8500/init_mmc.c b/board/st/u8500/init_mmc.c index 02d9f32f7..7d6656024 100755 --- a/board/st/u8500/init_mmc.c +++ b/board/st/u8500/init_mmc.c @@ -34,52 +34,65 @@ #endif #define LOOP(x) {int i;for(i=0;i<1000;i++);} -#ifdef CONFIG_CMD_FAT -static block_dev_desc_t mmc_dev; -u32 CSD[4]; -char MMC_CmdBuffer[1024] ; -extern long do_fat_read (const char *filename, void *buffer, unsigned long maxsize,int dols); +#define MMC_CARD_NUM 1 +#define EMMC_CARD_NUM 4 +enum { + DEV_EMMC = 0, + DEV_MMC +}; + +static block_dev_desc_t mmc_dev; +static block_dev_desc_t emmc_dev; +static u32 CSD[4]; block_dev_desc_t * mmc_get_dev(int dev) { - return (block_dev_desc_t *)(&mmc_dev); + if (dev == DEV_EMMC) + return (block_dev_desc_t *)(&emmc_dev); + else if (dev == DEV_MMC) + return (block_dev_desc_t *)(&mmc_dev); + + printf("mmc_get_dev: unknown dev %d\n", dev); + return 0; } -unsigned long mmc_block_read(int dev, unsigned long blknr,lbaint_t blkcnt, - void *dest) +static unsigned long emmc_block_read(int dev, unsigned long blknr, + lbaint_t blkcnt, void *dest) { - unsigned long i; - unsigned long src= blknr; - unsigned long rc = 0; + unsigned long rc; - for(i = 0; i < blkcnt; i++) - { - /* card#, read offset, buffer, blocksize, transfer mode */ - mmc_readblock(1, (u32) (512 * src), (u32 *)dest, 512, - MMCPOLLING); - rc++; - src++; - dest += 512; + rc = mmc_readblocks(EMMC_CARD_NUM, (u32) (512 * blknr), (u32 *)dest, + 512, blkcnt); + if (rc != 0) { + printf("mmc_block_read: readblocks failed %ld\n", rc); + rc = 0; + } else { + rc = blkcnt; } - return rc; } -t_mmc_error mmc_fat_read_file (char *filename, u32 address, u32 FileSize) +unsigned long mmc_block_read(int dev, unsigned long blknr, + lbaint_t blkcnt, void *dest) { - u8 *mem_address = (u8 *) address; - t_mmc_error mmc_error = MMC_OK; + unsigned long i; + unsigned long src= blknr; + unsigned long rc = 0; - if((do_fat_read(filename,mem_address,FileSize,0)) < 0) + for(i = 0; i < blkcnt; i++) { - printf("error in reading %s file\n",filename); - mmc_error = MMC_INVALID_PARAMETER; + /* card#, read offset, buffer, blksize, transfer mode */ + mmc_readblock(MMC_CARD_NUM, (u32) (512 * src), + (u32 *)dest, 512, MMCPOLLING); + rc++; + src++; + dest += 512; } - return mmc_error; + return rc; } -int mmc_hw_init (void) +int mmc_hw_init(void) { t_mmc_error response; @@ -116,71 +129,6 @@ int mmc_hw_init (void) return 1; } -/* - * init_mmc_fat - initialise MMC HW and register as FAT device - */ -int init_mmc_fat(void) -{ - unsigned int size; - unsigned int sizemult; - unsigned long num_sects; - unsigned long sect_size; /* in bytes */ - unsigned long mmc_size; - - if(mmc_hw_init()) - { - goto end; - } - /*read block len*/ - sect_size = 1<<((CSD[2] << 12 )>>28); - /*c_size */ - size = ((CSD[2] & 0x3ff)<<2) + (CSD[1]>>30) ; - /*size of multiplier */ - sizemult = (CSD[1] << 14 )>>29; - - num_sects = (size+1)*(1<<(sizemult+2)); - /* memory capcity of the Inserted Card */ - mmc_size = (num_sects * sect_size)/(1024 * 1024); - printf("Memory Card size = %d MiB \n", mmc_size); - printf("sector size is %d, num_sects %d\n", sect_size, num_sects); - - mmc_dev.if_type = IF_TYPE_MMC; - mmc_dev.part_type = PART_TYPE_DOS; - mmc_dev.dev = 0; - mmc_dev.lun = 0; - mmc_dev.type = 0; - mmc_dev.blksz = 512; - mmc_dev.lba = num_sects; /* XXX: assumes 512 blksize */ - sprintf((char*)mmc_dev.vendor, "Unknown vendor"); - sprintf((char*)mmc_dev.product, "Unknown product"); - sprintf((char*)mmc_dev.revision, "N/A"); - mmc_dev.removable = 0; - mmc_dev.block_read = mmc_block_read; - - /* do fat registration with the SD/MMC device*/ - if (fat_register_device(&mmc_dev, 1) != 0) { - printf("could not register as FAT device\n"); - goto end; - } -#if 0 - printf(" Size \t FileName \n"); - do_fat_read("/", NULL, 0, 1); - /* do fat read for the commands to be executed*/ - if (do_fat_read("command.txt", &MMC_CmdBuffer[0], sizeof(MMC_CmdBuffer), 0) - == -1) { - printf(" No command.txt found in the Card\n"); - return (0); - } - setenv("bootcmd", MMC_CmdBuffer); -#endif - return(0); -end: - gpio_altfuncdisable(GPIO_ALT_SD_CARD0, "MMC"); - mmc_disable(); - return 1; -} -#endif /* CONFIG_CMD_FAT */ - #define I2C_SCL_FREQ 100000 /* I2C bus clock frequency.*/ #define I2C_INPUT_FREQ 48000000 /* Input clock frequency.*/ #define I2C0_SLAVE_ADDRESS (0x84 >>1) /*GPIO expander slave address*/ @@ -192,7 +140,7 @@ end: #define SLAVE_SETUP_TIME 14 /* Slave data setup time */ -void config_extended_gpio(void) +static void config_extended_gpio(void) { t_i2c_error error_status; t_i2c_device_config i2c_device_config; @@ -280,26 +228,43 @@ void config_extended_gpio(void) } -/* ======================================================================== - Achraf - Name: init_mmc_card - Description: init VIC, GPIO and MMC - - ======================================================================== */ -int mmc_legacy_init(int dev) +/* + * mmc_legacy_init - called from commandline mmc init + * + * Initialise hardware and setup block device structure for fat and ext2 + * commands. + */ +int mmc_legacy_init(int dev) { - /*config extended GPIO pins for Level shifter and SDMMC_ENABLE */ - config_extended_gpio(); - - init_mmc(); - -#ifndef CONFIG_CMD_FAT - if (display_file_list("*") == MMC_CMD_RSP_TIMEOUT) - { - printf("MMC card not available on board\n"); - } -#endif - return 0; + + if (dev == DEV_EMMC) { + printf("EMMC init\n"); + /* XXX: emmc_init() does write the MBR (called pib)! */ + emmc_init(EMMC_CARD_NUM); + emmc_dev.if_type = IF_TYPE_MMC; + emmc_dev.part_type = PART_TYPE_DOS; + emmc_dev.dev = dev; + emmc_dev.lun = 0; + emmc_dev.type = 0; + emmc_dev.blksz = 512; + emmc_dev.lba = 0x80000; /* XXX: use real size, here 256 MB */ + sprintf((char*)emmc_dev.vendor, "Unknown vendor"); + sprintf((char*)emmc_dev.product, "Unknown product"); + sprintf((char*)emmc_dev.revision, "N/A"); + emmc_dev.removable = 0; + emmc_dev.block_read = emmc_block_read; + return 0; + } else if (dev == DEV_MMC) { + printf("MMC init\n"); + /* config extended GPIO pins for Level shifter and + * SDMMC_ENABLE */ + config_extended_gpio(); + init_mmc(); + return 0; + } + + printf("mmc_legacy_init: unsupported device# %d\n", dev); + return -1; } /* ======================================================================== @@ -325,13 +290,6 @@ static int init_mmc(void) gpio_base_address -> gpio_dats |= 0x1FFC0000; gpio_base_address -> gpio_pdis &= ~0x1FFC0000; -#ifdef CONFIG_CMD_FAT -#if 0 - if(init_mmc_fat()) - { - printf(" MMC Card not found \n"); - } -#endif if (mmc_hw_init() != 0) { printf("mmc_init: hw init failed\n"); } @@ -347,6 +305,7 @@ static int init_mmc(void) sprintf((char*)mmc_dev.revision, "N/A"); mmc_dev.removable = 0; mmc_dev.block_read = mmc_block_read; +#ifdef CONFIG_CMD_FAT if (fat_register_device(&mmc_dev, 1) != 0) { printf("mmc_init: could not register as FAT device\n"); } -- cgit v1.2.3