Hey everybody.
I'm quite new to allwinner, my first experience was with the A13 (sun4i) from olimex.
I wrote a kernel driver for the sunxi kernel, which uses the spi and some GPIO.
It talks to an SPI RF chip and works just fine.
I want to port my kernel driver for the Orange Pi Zero, but have some issues.
My main question is: how do i access the fex file, how do i manipulate the gpio and spi ?
In the sun4i there are helper functions in the arch/arm/mach-sun4i/sys_config.c file.
#define PIN_DIR(handler,dir) gpio_set_one_pin_io_status(handler, dir, NULL)
#define PIN_SET(handler,val) gpio_write_one_pin_value(handler, val, NULL)
#define PIN_GET(handler) gpio_read_one_pin_value(handler, NULL)
I don't seem to get them in the sun8i sys_config.c file that is located in #include <mach/sys_config.h>
I normally get the gpio pins as such:
my_sx1272_data->pin_led = gpio_request_ex("sx1272_para", "pin_led");
And i manipulate the IO with these defines, that also use the functions from sys_config.
PIN_DIR(my_sx1272_data->pin_led, PIN_DIR_OUT);
PIN_SET(my_sx1272_data->pin_led, 0);
For the SPI i use this way of setup, i guess this will work, but i need to get rid of the sys_config implicit function compilation error first.
struct spi_board_info spi_device_info = {
.modalias = "DURALINK",
.max_speed_hz = 350*1000, //speed your device (slave) can handle
.bus_num = 2,
.chip_select = 0,
.mode = 0,
};
master = spi_busnum_to_master( spi_device_info.bus_num );
if( !master ){
printk(KERN_ERR "[LoRa] MASTER not found.\n");
return -ENODEV;
}
// create a new slave device, given the master and device info
spi_device = spi_new_device( master, &spi_device_info );
if( !spi_device ) {
printk(KERN_ERR "[LoRa] FAILED to create slave.\n");
return -ENODEV;
}
spi_device->bits_per_word = 8;
ret = spi_setup( spi_device );
if( ret ){
printk(KERN_ERR "[LoRa] FAILED to setup slave.\n");
spi_unregister_device( spi_device );
return -ENODEV;
}
Currently using Linux OPI-3.4.113 3.4.113-sun8i #50 SMP PREEMPT Mon Nov 14 08:41:55 CET 2016 armv7l GNU/Linux
So it's the Debian armbian image 3.4.113.
Thanks in advance.