Monthly Archives: September 2019

VoCore2: develop SPI driver

I start this SPI driver blog because it is pretty useful and it can be a tutorial for kernel develop.

Currently the SPI driver is from mt7621/mt7620, it works well. I think maybe there is someway to improve it? I have done similar to i2c driver, and for myself it is much better than the original one.

Let’s check openwrt spi-mt7621.c first…

static inline int mt7621_spi_wait_till_ready(struct spi_device *spi)
	struct mt7621_spi *rs = spidev_to_mt7621_spi(spi);
	int i;

	for (i = 0; i < RALINK_SPI_WAIT_MAX_LOOP; i++) {
		u32 status;

		status = mt7621_spi_read(rs, MT7621_SPI_TRANS);
		if ((status & SPITRANS_BUSY) == 0) {
			return 0;

	return -ETIMEDOUT;

From this code, means we are using busy wait for every bit. This will consume a lot of CPU time and increase VoCore2 current. Busy wait is never a good idea, but easy to develop.

Check datasheet again, 0x10000b28 bit 9 is Interrupt Enable. That means we might have a way avoid busy wait, even more, we might have a way to use DMA for mass data transfer.

Tomorrow I will try to make some test. I can directly write to SPI register in user space by mmap.

To be continue...

We stop ship to EU by DHL

Recently a French purchase a VoCore2 Ultimate from, but he reject pay VAT when the package reach its customs(29EUR VAT and approx. 15EUR handle cost for DHL) , so we require DHL destroy the package, but DHL return the package without notify us and request us pay for 130USD returning postage(shipping postage is around 20USD), so we have to stop corporate with DHL.

PS: returning happens before, but DHL will notify us and ask to destroy first.

For further order, we will ship by EMS. It is one or two days slower than DHL but much better at clearance, at least if a client do not pay his VAT, it is free to return.

I do not want to blame anyone. It is absolutely not fair if you buy a 45USD item but pay 50USD VAT + handle fee. So I think the best way is to stop using DHL ship to EU countries.

Be careful use DHL, especially for the package returning. Maybe this is only happens when ship from China to Europe…