当前位置: 首页>>代码示例>>C++>>正文


C++ spi_flash_probe函数代码示例

本文整理汇总了C++中spi_flash_probe函数的典型用法代码示例。如果您正苦于以下问题:C++ spi_flash_probe函数的具体用法?C++ spi_flash_probe怎么用?C++ spi_flash_probe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了spi_flash_probe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的spi_flash_probe函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。