您尚未登录。

楼主 #1 2017-12-11 17:57:05

晕哥
管理员
注册时间: 2017-09-06
已发帖子: 9,348
积分: 9202

荔枝派全志Allwinner V3s的u-boot spl里面使用默认的spi速度,我试着修改spi 速度,看能否成功。

荔枝派全志Allwinner V3s的u-boot spl里面使用默认的spi速度,我试着修改spi 速度,看能否成功。
参考: 荔枝派Zero V3s开发板入坑教程

#include <asm/arch/spi.h>

#define SUNXI_SPI_MAX_RATE (108 * 1000 * 1000)
#define SUNXI_SPI_MIN_RATE (3 * 1000)
static int spi0_set_speed(uint speed)
{
	unsigned int div;
	uint32_t reg;

	printf("|||||||||| %s: speed=%u\n", __func__, speed);

	speed = min(speed, (unsigned int)SUNXI_SPI_MAX_RATE);
	speed = max((unsigned int)SUNXI_SPI_MIN_RATE, speed);

	div = SUNXI_SPI_MAX_RATE / (2 * speed);

	if (div <= (SUNXI_SPI_CLK_CTL_CDR2_MASK + 1)) {
		if (div > 0)
			div--;

		reg = SUNXI_SPI_CLK_CTL_CDR2(div) | SUNXI_SPI_CLK_CTL_DRS;
	} else {
		div = __ilog2(SUNXI_SPI_MAX_RATE) - __ilog2(speed);
		reg = SUNXI_SPI_CLK_CTL_CDR1(div);
	}

	writel(reg, SUN6I_SPI0_CCTL);

	printf("//////////// %s: speed=%u\n", __func__, speed);
	printf("//////////// %s: speed=%u\n", __func__, speed);
	printf("//////////// %s: speed=%u\n", __func__, speed);

	return 0;
}

调用

	spi0_enable_clock();
	spi0_set_speed(98000000);




离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn