荔枝派全志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);
离线