本文整理汇总了C++中spi_flash_probe函数的典型用法代码示例。如果您正苦于以下问题:C++ spi_flash_probe函数的具体用法?C++ spi_flash_probe怎么用?C++ spi_flash_probe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spi_flash_probe函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setup_flash_device
static int setup_flash_device(void)
{
#ifdef CONFIG_DM_SPI_FLASH
struct udevice *new;
int ret;
/* speed and mode will be read from DT */
ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
0, 0, &new);
if (ret) {
set_default_env("!spi_flash_probe_bus_cs() failed");
return ret;
}
env_flash = dev_get_uclass_priv(new);
#else
if (!env_flash) {
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
if (!env_flash) {
set_default_env("!spi_flash_probe() failed");
return -EIO;
}
}
#endif
return 0;
}
开发者ID:koenkooi,项目名称:u-boot,代码行数:29,代码来源:sf.c
示例2: init_pcie_bridge_from_spi
static int init_pcie_bridge_from_spi(void *buf, size_t size)
{
struct spi_flash *spi;
int ret;
unsigned long pcie_addr;
spi = spi_flash_probe(0, 0, 1000000, SPI_MODE_3);
if (!spi) {
printf("%s: spi_flash probe error.\n", __func__);
return 1;
}
if (is_sh7757_b0())
pcie_addr = SH7757LCR_PCIEBRG_ADDR_B0;
else
pcie_addr = SH7757LCR_PCIEBRG_ADDR;
ret = spi_flash_read(spi, pcie_addr, size, buf);
if (ret) {
printf("%s: spi_flash read error.\n", __func__);
spi_flash_free(spi);
return 1;
}
spi_flash_free(spi);
return 0;
}
开发者ID:OpenNoah,项目名称:u-boot,代码行数:27,代码来源:sh7757lcr.c
示例3: spl_spi_load_image
/*
* The main entry for SPI booting. It's necessary that SDRAM is already
* configured and available since this code loads the main U-Boot image
* from SPI into SDRAM and starts it from there.
*/
void spl_spi_load_image(void)
{
struct spi_flash *flash;
struct image_header *header;
/*
* Load U-Boot image from SPI flash into RAM
*/
flash = spi_flash_probe(CONFIG_SPL_SPI_BUS, CONFIG_SPL_SPI_CS,
CONFIG_SF_DEFAULT_SPEED, SPI_MODE_3);
if (!flash) {
puts("SPI probe failed.\n");
hang();
}
/* use CONFIG_SYS_TEXT_BASE as temporary storage area */
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
/* Load u-boot, mkimage header is 64 bytes. */
spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40,
(void *) header);
spl_parse_image_header(header);
spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
spl_image.size, (void *)spl_image.load_addr);
}
开发者ID:AeroGirl,项目名称:u-boot-kern3.2,代码行数:31,代码来源:spi_spl_load.c
示例4: board_identify
static void board_identify(void)
{
struct spi_flash *sf;
sf = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS,
CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE);
boot_mode_sf = (sf != NULL);
}
开发者ID:OpenNoah,项目名称:u-boot,代码行数:7,代码来源:ma5d4evk.c
示例5: env_relocate_spec
void env_relocate_spec(void)
{
int ret;
char *buf = NULL;
buf = (char *)memalign(ARCH_DMA_MINALIGN, CONFIG_ENV_SIZE);
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
if (!env_flash) {
set_default_env("!spi_flash_probe() failed");
if (buf)
free(buf);
return;
}
ret = spi_flash_read(env_flash,
CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, buf);
if (ret) {
set_default_env("!spi_flash_read() failed");
goto out;
}
ret = env_import(buf, 1);
if (ret)
gd->env_valid = 1;
out:
spi_flash_free(env_flash);
if (buf)
free(buf);
env_flash = NULL;
}
开发者ID:0xFelix,项目名称:u-boot-edminiv2,代码行数:31,代码来源:env_sf.c
示例6: spi_SaveS3info
void spi_SaveS3info(u32 pos, u32 size, u8 *buf, u32 len)
{
struct spi_flash *flash;
spi_init();
flash = spi_flash_probe(0, 0);
if (!flash) {
printk(BIOS_DEBUG, "Could not find SPI device\n");
/* Dont make flow stop. */
return;
}
flash->spi->rw = SPI_WRITE_FLAG;
spi_claim_bus(flash->spi);
flash->erase(flash, pos, size);
flash->write(flash, pos, sizeof(len), &len);
u32 nvram_pos;
for (nvram_pos = 0; nvram_pos < len - CONFIG_AMD_SB_SPI_TX_LEN; nvram_pos += CONFIG_AMD_SB_SPI_TX_LEN) {
flash->write(flash, nvram_pos + pos + 4, CONFIG_AMD_SB_SPI_TX_LEN, (u8 *)(buf + nvram_pos));
}
flash->write(flash, nvram_pos + pos + 4, len % CONFIG_AMD_SB_SPI_TX_LEN, (u8 *)(buf + nvram_pos));
flash->spi->rw = SPI_WRITE_FLAG;
spi_release_bus(flash->spi);
return;
}
开发者ID:alterapraxisptyltd,项目名称:coreboot,代码行数:29,代码来源:spi.c
示例7: do_write_mac
int do_write_mac(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
int i, ret;
char mac_string[256];
struct spi_flash *spi;
unsigned char *buf;
if (argc != 5) {
buf = malloc(256);
if (!buf) {
printf("%s: malloc error.\n", __func__);
return 1;
}
get_sh_eth_mac_raw(buf, 256);
/* print current MAC address */
for (i = 0; i < 4; i++) {
get_sh_eth_mac(i, mac_string, buf);
if (i < 2)
printf(" ETHERC ch%d = %s\n", i, mac_string);
else
printf("GETHERC ch%d = %s\n", i-2, mac_string);
}
free(buf);
return 0;
}
/* new setting */
memset(mac_string, 0xff, sizeof(mac_string));
sprintf(mac_string, "%s\t%s\t%s\t%s",
argv[1], argv[2], argv[3], argv[4]);
/* write MAC data to SPI rom */
spi = spi_flash_probe(0, 0, 1000000, SPI_MODE_3);
if (!spi) {
printf("%s: spi_flash probe error.\n", __func__);
return 1;
}
ret = spi_flash_erase(spi, SH7757LCR_ETHERNET_MAC_BASE_SPI,
SH7757LCR_SPI_SECTOR_SIZE);
if (ret) {
printf("%s: spi_flash erase error.\n", __func__);
return 1;
}
ret = spi_flash_write(spi, SH7757LCR_ETHERNET_MAC_BASE_SPI,
sizeof(mac_string), mac_string);
if (ret) {
printf("%s: spi_flash write error.\n", __func__);
spi_flash_free(spi);
return 1;
}
spi_flash_free(spi);
puts("The writing of the MAC address to SPI ROM was completed.\n");
return 0;
}
开发者ID:OpenNoah,项目名称:u-boot,代码行数:60,代码来源:sh7757lcr.c
示例8: sf_env_relocate_spec
static int sf_env_relocate_spec(unsigned int offset)
{
int ret;
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
if (!env_flash)
goto err_probe;
ret = spi_flash_read(env_flash, offset, CONFIG_ENV_SIZE, env_ptr);
if (ret)
goto err_read;
if (crc32(0, env_ptr->data, ENV_SIZE) != env_ptr->crc)
goto err_crc;
gd->env_valid = 1;
return 0;
err_read:
spi_flash_free(env_flash);
env_flash = NULL;
err_probe:
err_crc:
return 1;
}
开发者ID:armfun,项目名称:boot-hix5hd2,代码行数:27,代码来源:env_sf.c
示例9: env_relocate_spec
void env_relocate_spec(void)
{
char buf[CONFIG_ENV_SIZE];
int ret;
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
if (!env_flash) {
set_default_env("!spi_flash_probe() failed");
return;
}
ret = spi_flash_read(env_flash,
CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, buf);
if (ret) {
set_default_env("!spi_flash_read() failed");
goto out;
}
ret = env_import(buf, 1);
if (ret)
gd->env_valid = 1;
out:
spi_flash_free(env_flash);
env_flash = NULL;
}
开发者ID:0s4l,项目名称:u-boot-xlnx,代码行数:26,代码来源:env_sf.c
示例10: get_mac_addr
static int get_mac_addr(u8 *addr)
{
int ret;
struct spi_flash *flash;
flash = spi_flash_probe(CFG_MAC_ADDR_SPI_BUS, CFG_MAC_ADDR_SPI_CS,
CFG_MAC_ADDR_SPI_MAX_HZ, CFG_MAC_ADDR_SPI_MODE);
if (!flash) {
printf(" Error - unable to probe SPI flash.\n");
goto err_probe;
}
ret = spi_flash_read(flash, CFG_MAC_ADDR_OFFSET, 6, addr);
if (ret) {
printf("Error - unable to read MAC address from SPI flash.\n");
goto err_read;
}
err_read:
/* cannot call free currently since the free function calls free() for
* spi_flash structure though it is not directly allocated through
* malloc()
*/
/* spi_flash_free(flash); */
err_probe:
return ret;
}
开发者ID:Klaus-schwarzkopf,项目名称:u-boot,代码行数:27,代码来源:da850evm.c
示例11: spi_env_relocate_spec
void spi_env_relocate_spec(void)
{
int ret;
env_t env_buf;
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
if (!env_flash)
goto err_probe;
ret = spi_flash_read(env_flash, CONFIG_ENV_IN_SPI_OFFSET, CONFIG_ENV_SIZE, &env_buf);
if (ret)
goto err_read;
env_import(&env_buf, 1);
gd->env_valid = 1;
return;
err_read:
spi_flash_free(env_flash);
env_flash = NULL;
err_probe:
//err_crc:
set_default_env("!bad CRC");
}
开发者ID:matt0526,项目名称:matt_uboot,代码行数:26,代码来源:env_sf.c
示例12: initr_spiflash
static int initr_spiflash(void)
{
spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
CONFIG_SF_DEFAULT_CS,
CONFIG_SF_DEFAULT_SPEED,
CONFIG_SF_DEFAULT_MODE);
return 0;
}
开发者ID:barawn,项目名称:u-boot-uub,代码行数:8,代码来源:board_r.c
示例13: main
int main(int argc, char **argv) {
int ret;
unsigned int cs = 0, max_hz = 0, spi_mode = 0; /* Dummy for now */
if (getuid() != 0) {
fprintf(stderr, "Error: Not started with 'root'\n");
return -1;
}
if (bcm2835_init() != 1) {
fprintf(stderr, "bcm2835_init() failed\n");
return -2;
}
ret = spi_flash_probe(cs, max_hz, spi_mode);
printf("spi_flash_probe=%d\n", ret);
if (ret == 0) {
printf("Detected %s with sector size %d total %d bytes\n", spi_flash_get_name(), spi_flash_get_sector_size(), spi_flash_get_size());
}
#if 0
int i;
uint8_t buffer[16];
ret = spi_flash_cmd_erase(0, 4096);
printf("spi_flash_cmd_erase=%d\n", ret);
ret = spi_flash_cmd_read_fast(0, sizeof(buffer), buffer);
printf("spi_flash_cmd_read_fast=%d\n", ret);
for (i = 0; i < sizeof(buffer); i++) {
printf("%.2x[%c]", buffer[i], isprint(buffer[i]) ? buffer[i] : '.');
}
printf("\n");
ret = spi_flash_cmd_write_multi(0, 6, (const void *)"Arjan");
printf("spi_flash_cmd_write_multi=%d\n", ret);
ret = spi_flash_cmd_read_fast(0, sizeof(buffer), buffer);
printf("spi_flash_cmd_read_fast=%d\n", ret);
for (i = 0; i < sizeof(buffer); i++) {
printf("%.2x[%c]", buffer[i], isprint(buffer[i]) ? buffer[i] : '.');
}
#endif
printf("\nDone!\n");
return 0;
}
开发者ID:vanvught,项目名称:rpidmx512,代码行数:58,代码来源:detect.c
示例14: init_flash
inline int init_flash(void)
{
flash_device = spi_flash_probe(0, 0, 0, 0);
if (!flash_device)
return -1;
return 0;
}
开发者ID:pcengines,项目名称:sortbootorder,代码行数:9,代码来源:flash_access.c
示例15: spi_flash_init
unsigned long spi_flash_init(void)
{
flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS, CONFIG_ENV_SPI_MAX_HZ, SPI_MODE_3);
if (!flash) {
printf("Failed to initialize SPI flash at %u:%u\n", CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS);
return 1;
}
return 0;
}
开发者ID:12thmantec,项目名称:u-boot-novena-spl,代码行数:9,代码来源:mv_flash.c
示例16: spi_boot
/*
* The main entry for SPI booting. It's necessary that SDRAM is already
* configured and available since this code loads the main U-Boot image
* from SPI into SDRAM and starts it from there.
*/
void spi_boot(void)
{
void (*uboot)(void) __noreturn;
u32 offset, code_len, copy_len = 0;
#ifndef CONFIG_FSL_CORENET
unsigned char *buf = NULL;
#endif
struct spi_flash *flash;
flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
if (flash == NULL) {
puts("\nspi_flash_probe failed");
hang();
}
#ifdef CONFIG_FSL_CORENET
offset = CONFIG_SYS_SPI_FLASH_U_BOOT_OFFS;
code_len = CONFIG_SYS_SPI_FLASH_U_BOOT_SIZE;
#else
/*
* Load U-Boot image from SPI flash into RAM
*/
buf = malloc(flash->page_size);
if (buf == NULL) {
puts("\nmalloc failed");
hang();
}
memset(buf, 0, flash->page_size);
spi_flash_read(flash, CONFIG_CFG_DATA_SECTOR,
flash->page_size, (void *)buf);
offset = *(u32 *)(buf + ESPI_BOOT_IMAGE_ADDR);
/* Skip spl code */
offset += CONFIG_SYS_SPI_FLASH_U_BOOT_OFFS;
/* Get the code size from offset 0x48 */
code_len = *(u32 *)(buf + ESPI_BOOT_IMAGE_SIZE);
/* Skip spl code */
code_len = code_len - CONFIG_SPL_MAX_SIZE;
#endif
/* copy code to DDR */
printf("Loading second stage boot loader ");
while (copy_len <= code_len) {
spi_flash_read(flash, offset + copy_len, 0x2000,
(void *)(CONFIG_SYS_SPI_FLASH_U_BOOT_DST
+ copy_len));
copy_len = copy_len + 0x2000;
putc('.');
}
/*
* Jump to U-Boot image
*/
flush_cache(CONFIG_SYS_SPI_FLASH_U_BOOT_DST, code_len);
uboot = (void *)CONFIG_SYS_SPI_FLASH_U_BOOT_START;
(*uboot)();
}
开发者ID:0xFelix,项目名称:u-boot-edminiv2,代码行数:62,代码来源:fsl_espi_spl.c
示例17: OemAgesaSaveS3Info
u32 OemAgesaSaveS3Info(S3_DATA_TYPE S3DataType, u32 DataSize, void *Data)
{
u32 pos;
struct spi_flash *flash;
u8 *new_data;
u32 bytes_to_process;
u32 nvram_pos;
if (S3DataType == S3DataTypeNonVolatile)
pos = S3_DATA_NONVOLATILE_POS;
else
pos = S3_DATA_VOLATILE_POS;
spi_init();
flash = spi_flash_probe(0, 0, 0, 0);
if (!flash) {
printk(BIOS_DEBUG, "%s: Could not find SPI device\n", __func__);
/* Don't make flow stop. */
return AGESA_SUCCESS;
}
flash->spi->rw = SPI_WRITE_FLAG;
spi_claim_bus(flash->spi);
// initialize the incoming data array
new_data = (u8 *)malloc(DataSize + (u32)sizeof(DataSize));
memcpy(new_data, &DataSize, (u32)sizeof(DataSize)); // the size gets written first
memcpy(new_data + (u32)sizeof(DataSize), Data, DataSize);
DataSize += (u32)sizeof(DataSize); // add in the size of the data
for ( ; DataSize > 0; DataSize -= bytes_to_process) {
bytes_to_process = ( DataSize >= flash->sector_size) ? flash->sector_size : DataSize;
if (memcmp((u8 *)pos, (u8 *)new_data, bytes_to_process)) {
printk(BIOS_DEBUG, "%s: Data mismatch - write the data\n", __func__);
flash->erase(flash, pos, flash->sector_size);
for (nvram_pos = 0; \
nvram_pos < bytes_to_process - (bytes_to_process % CONFIG_AMD_SB_SPI_TX_LEN); \
nvram_pos += CONFIG_AMD_SB_SPI_TX_LEN) {
flash->write(flash, pos + nvram_pos, CONFIG_AMD_SB_SPI_TX_LEN, \
(u8 *)(new_data + nvram_pos));
}
flash->write(flash, pos + nvram_pos, bytes_to_process % CONFIG_AMD_SB_SPI_TX_LEN, \
(u8 *)(new_data + nvram_pos));
}
else
printk(BIOS_DEBUG, "%s: existing nvram data matched\n", __func__);
new_data += bytes_to_process;
pos += bytes_to_process;
}
free(new_data);
flash->spi->rw = SPI_WRITE_FLAG;
spi_release_bus(flash->spi);
return AGESA_SUCCESS;
}
开发者ID:byteworks-ch,项目名称:pcengines-apu-bios,代码行数:56,代码来源:s3_resume.c
示例18: set_arc_product
static int set_arc_product(int argc, char *const argv[])
{
int err = 0;
char *mystrerr = "ERROR: Failed to save factory info in spi location";
if (argc != 5)
return -1;
/* Check serial number */
if (strlen(argv[1]) != MAX_SERIAL_SIZE)
return -1;
/* Check HWaddrs */
if (ishwaddr(argv[2]) || ishwaddr(argv[3]) || ishwaddr(argv[4]))
return -1;
strcpy(smac[3], argv[1]);
strcpy(smac[2], argv[2]);
strcpy(smac[1], argv[3]);
strcpy(smac[0], argv[4]);
flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
/*
* Save factory defaults
*/
if (spi_flash_write(flash, FIRM_ADDR1, sizeof(smac), smac)) {
printf("%s: %s [1]\n", __func__, mystrerr);
err++;
}
if (spi_flash_write(flash, FIRM_ADDR2, sizeof(smac), smac)) {
printf("%s: %s [2]\n", __func__, mystrerr);
err++;
}
if (spi_flash_write(flash, FIRM_ADDR3, sizeof(smac), smac)) {
printf("%s: %s [3]\n", __func__, mystrerr);
err++;
}
if (spi_flash_write(flash, FIRM_ADDR4, sizeof(smac), smac)) {
printf("%s: %s [4]\n", __func__, mystrerr);
err++;
}
if (err == 4) {
printf("%s: %s [ALL]\n", __func__, mystrerr);
return -2;
}
return 0;
}
开发者ID:OpenNoah,项目名称:u-boot,代码行数:54,代码来源:cmd_arc.c
示例19: boot_device_init
void boot_device_init(void)
{
int bus = CONFIG_BOOT_MEDIA_SPI_BUS;
int cs = 0;
if (spi_flash_info != NULL)
return;
spi_flash_info = spi_flash_probe(bus, cs);
mmap_helper_device_init(&mdev, _cbfs_cache, _cbfs_cache_size);
}
开发者ID:asuradaimao,项目名称:coreboot,代码行数:12,代码来源:cbfs_spi.c
示例20: spi_flash_probe
spiflash_logic_t *spiflash_logic_open(unsigned long long address,
unsigned long long length)
{
struct mtd_info_ex *mtd_info_ex;
spiflash_logic_t *spiflash_logic;
struct spi_flash *spiflash;
spiflash = spi_flash_probe(0,0,0,0);
if (spiflash == NULL) {
printf("no devices available\n");
return NULL;
}
mtd_info_ex = get_spiflash_info();
if (mtd_info_ex == NULL) {
printf("get spi flash info failed\n");
return NULL;
}
/* Reject open, which are not block aligned */
if ((address & (mtd_info_ex->erasesize - 1))
|| (length & (mtd_info_ex->erasesize - 1))) {
printf("Attempt to open non block aligned, "
"spi flash blocksize: 0x%08x, address: 0x%08llx,"
" length: 0x%08llx\n",
mtd_info_ex->erasesize, address, length);
return NULL;
}
if ((address > spiflash->size)
|| (length > spiflash->size)
|| ((address + length) > spiflash->size)) {
printf("Attempt to open outside the flash area, "
"spi flash chipsize: 0x%08x, address: 0x%08llx,"
" length: 0x%08llx\n",
spiflash->size, address, length);
return NULL;
}
spiflash_logic = malloc(sizeof(spiflash_logic_t));
if (!spiflash_logic) {
printf("no many memory.\n");
return NULL;
}
spiflash_logic->spiflash = spiflash;
spiflash_logic->address = address;
spiflash_logic->length = length;
spiflash_logic->erasesize = mtd_info_ex->erasesize;
return spiflash_logic;
}
开发者ID:armfun,项目名称:boot-hix5hd2,代码行数:52,代码来源:spiflash_logif.c
注:本文中的spi_flash_probe函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论