SPI at Bootloader on HiKey


#1

Hello everyone,

me and my colleague are trying to enable SPI during the bootloader phases on the HiKey board (LeMaker, 2GB edition). We tried to find some information on the installed SPI controller (ARM Primecell PL022), but unfortunately we weren’t able to create a working setup.

During our investigation we came across a topic in the U-Boot bootloader mailing list which was talking about our exact problem, but lacking some final implemenation. We tried to pick it up from there but are struggeling to finalize the setup, since we cannot figure out how to configure the ports properly and which clock we have to use (see http://lists.denx.de/pipermail/u-boot/2016-September/267135.html for our latest, yet incomplete, patch - see here http://lists.denx.de/pipermail/u-boot/2016-September/266146.html for the inital message).

Anyone who can point us in the right direction? Any help is greatly appreciated!


#2

You need to take the module out of reset first.
Refer to https://github.com/96boards-hikey/edk2/blob/hikey/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InitPeripherals.c

Clock info is here:
https://github.com/96boards-hikey/arm-trusted-firmware/blob/hikey/plat/hikey/include/hi6220_regs_peri.h#L62
https://github.com/96boards-hikey/arm-trusted-firmware/blob/hikey/plat/hikey/include/hi6220_regs_peri.h#L250

Other related pin control info:



The rest should just follow the arm pl022 spec.

Good luck and let us know how it works for you!


#3

Hey,

thanks a lot for your answer and sorry for my late answer, I was ill and couldn’t come back to you earlier.
We are trying to put everything together right now. Do you, by any chance, know of the existence of a kind of “bare metal” SPI driver implementation we could re-use, while only changing the necessary board specific properties?

Thanks again for your help.


#4

You’re welcome. Hope you’re feeling better. Sorry but I don’t know of any bare metal implementation you can reuse. What’s wrong with the u-boot one you were going to use?


#5

Hey again, thanks for asking, feeling much better now. :slight_smile:

There may be nothing wrong with that, it’s just that we aren’t that familiar with driver implementation and aren’t sure whether the driver implementation we found would work in our scenario. Therefore we had the idea to reusing a bare metal implementation that is working for sure and modify it to match the board specifics.


#6

You can reference the linux one (http://lxr.free-electrons.com/source/drivers/spi/spi-pl022.c). It’s a lot more complicated, but you can ignore the interrupt/dma related functions for now if you’re just starting out and just look at the init/readwrite/transfer functions to begin with.

Another reference implementation I found is for ecos [1][2], but not sure why it’s not in the official ecos repo [3]. This is probably easier to digest than the one above.

[1] http://ecos-discuss.ecos.sourceware.narkive.com/gpaGhMCS/where-is-cygpkg-devs-spi-arm-lpc2xxx
[2] www.zynaptic.com/ecos/devel/pl022_spi_devel_19_12_08.tgz
[3] http://sourceware.org/viewvc/ecos/

The final reference I can suggest is https://github.com/OP-TEE/optee_os/blob/master/core/drivers/pl022_spi.c.

HTH


#7

Thanks a lot for all the information. :slight_smile:
I’ll have a look at the links and keep you updated about our progress.