Refactor AFE code and make SPI work

Signed-off-by: Maxim Osipov <maxim.osipov@gmail.com>