mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-08-20 00:48:52 +09:00
![Tom Rini](/assets/img/avatar_default.png)
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
118 lines
2.2 KiB
C
118 lines
2.2 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <asm/io.h>
|
|
#include "vct.h"
|
|
|
|
static u32 ebi_read(u32 addr)
|
|
{
|
|
addr &= ~0xFC000000;
|
|
|
|
reg_write(EBI_CPU_IO_ACCS(EBI_BASE), EXT_DEVICE_CHANNEL_2 | addr);
|
|
ebi_wait();
|
|
|
|
return reg_read(EBI_IO_ACCS_DATA(EBI_BASE));
|
|
}
|
|
|
|
static int ebi_write_u16(u32 addr, u32 data, int fetchIO)
|
|
{
|
|
u32 val = (data << 16);
|
|
|
|
addr &= ~0xFC000000;
|
|
|
|
ebi_wait();
|
|
|
|
reg_write(EBI_IO_ACCS_DATA(EBI_BASE), val);
|
|
reg_write(EBI_CPU_IO_ACCS(EBI_BASE),
|
|
EXT_DEVICE_CHANNEL_2 | EBI_CPU_WRITE | addr);
|
|
ebi_wait();
|
|
|
|
if (fetchIO) {
|
|
u32 counter = 0;
|
|
while (!(reg_read(EBI_SIG_LEVEL(EBI_BASE)) & EXT_CPU_IORDY_SL)) {
|
|
if (counter++ > 0xFFFFFF)
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static u16 ebi_read_u16(u32 addr)
|
|
{
|
|
return ((ebi_read(addr) >> 16) & 0xFFFF);
|
|
}
|
|
|
|
static u8 ebi_read_u8(u32 addr)
|
|
{
|
|
u32 val = ebi_read(addr) >> 16;
|
|
|
|
if (addr & 0x1)
|
|
return val & 0xff;
|
|
else
|
|
return (val >> 8) & 0xff;
|
|
}
|
|
|
|
/*
|
|
* EBI initialization for NOR FLASH access
|
|
*/
|
|
int ebi_init_nor_flash(void)
|
|
{
|
|
reg_write(EBI_DEV1_CONFIG1(EBI_BASE), 0x83000);
|
|
|
|
reg_write(EBI_DEV2_CONFIG1(EBI_BASE), 0x400002);
|
|
reg_write(EBI_DEV2_CONFIG2(EBI_BASE), 0x50);
|
|
|
|
reg_write(EBI_DEV2_TIM1_RD1(EBI_BASE), 0x409113);
|
|
reg_write(EBI_DEV2_TIM1_RD2(EBI_BASE), 0xFF01000);
|
|
reg_write(EBI_DEV2_TIM1_WR1(EBI_BASE), 0x04003113);
|
|
reg_write(EBI_DEV2_TIM1_WR2(EBI_BASE), 0x3FC12011);
|
|
reg_write(EBI_DEV2_TIM_EXT(EBI_BASE), 0xFFF00000);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Accessor functions replacing the "weak" functions in
|
|
* drivers/mtd/cfi_flash.c
|
|
*/
|
|
void flash_write8(u8 value, void *addr)
|
|
{
|
|
ebi_write_u16((u32)addr, value, 0);
|
|
}
|
|
|
|
void flash_write16(u16 value, void *addr)
|
|
{
|
|
ebi_write_u16((u32)addr, value, 0);
|
|
}
|
|
|
|
u8 flash_read8(void *addr)
|
|
{
|
|
return ebi_read_u8((u32)addr);
|
|
}
|
|
|
|
u16 flash_read16(void *addr)
|
|
{
|
|
return ebi_read_u16((u32)addr);
|
|
}
|
|
|
|
u32 flash_read32(void *addr)
|
|
{
|
|
return ((u32)ebi_read_u16((u32)addr) << 16) |
|
|
ebi_read_u16((u32)addr + 2);
|
|
}
|
|
|
|
void *board_flash_read_memcpy(void *dest, const void *src, size_t count)
|
|
{
|
|
u16 *tmp = (u16 *)dest, *s = (u16 *)src;
|
|
int i;
|
|
|
|
for (i = 0; i < count; i += 2)
|
|
*tmp++ = flash_read16(s++);
|
|
|
|
return dest;
|
|
}
|