odroid-c4:application_note:software:spi_ss_irq

'ODROID-N2' on this page refers to the ODROID-N2 series (N2, N2+, N2L).

How to add more SPI slave devices with SS and IRQ

This wiki describes how to use more SS(Chip-select) and IRQ pins for more SPI slave devices.

If you want to add slave devices you should consider which pins to use as SS(Chip-select) or IRQ pins. You can choose any GPIO on external 40pin except you're using. You should check the available pins and then edit the device tree blob file.

First of all, you can check whether GPIO is in use or not with “cat /sys/kernel/debug/gpio” command.

root@odroid:~# cat /sys/kernel/debug/gpio 
GPIOs 0-138:
 gpio-3   (amlsd               ) out lo
 gpio-5   (DWC_OTG             ) in  lo
 gpio-13  (blue:heartbeat      ) out hi
 gpio-49  (amlsd               ) in  hi
root@odroid:~#

You can find the number of gpio-<nr> this Expansion Connector in a column named “GPIO & Export No”.

And then, modify the num_chipselect and cs_gpios properties.
https://github.com/hardkernel/linux/blob/odroidn2-4.9.y/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts#L451-L454

You can find the number of gpio-<nr> this Expansion Connector in a column named “GPIO & Export No”.

And then, modify the num_chipselect and cs_gpios properties.
https://github.com/hardkernel/linux/blob/odroidc4-4.9.y/arch/arm64/boot/dts/amlogic/meson64_odroidc4.dts#L451-L454

You can find the number of gpio-<nr> this Expansion Connector in a column named “GPIO”.

And then, modify the num_chipselect and cs_gpios properties.
https://github.com/hardkernel/linux/blob/odroidc2-v3.16.y/arch/arm64/boot/dts/meson64_odroidc2.dts#L819-L821

You can find the number of gpio-<nr> this Expansion Connector in a column named “GPIO”.

And then, modify the num_chipselect and cs_gpios properties.
https://github.com/hardkernel/linux/blob/odroidc-3.10.y/arch/arm/boot/dts/meson8b_odroidc.dts#L584-L585

Some of SPI slave devices require interrupts like touch LCD, CAN or etc. You can choose GPIO on external 40pin as interrupt pin except you're using.

But the important fact is that you can only use 8 interrupts on ODROID-N2.
Refer to the ODROID-N2 datasheet Page 226.

If you use the edge trigger as both(falling and rising) it is consumed two GPIO IRQs. So you can only four GPIO IRQs if you set all the GPIO as both edges.

If you want to test GPIO IRQs with CLI, please refer to this link.
IRQ test on terminal

You can check whether IRQ is in use or not with “cat /proc/interrupts”.

you can see the example dts that the ads7846 use GPIO as pendown interrupt.
https://github.com/hardkernel/linux/blob/odroidn2-4.9.y/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts#L476

Some of SPI slave devices require interrupts like touch LCD, CAN or etc. You can choose GPIO on external 40pin as interrupt pin except you're using.

But the important fact is that you can only use 8 interrupts on ODROID-C4.
Refer to the ODROID-C4 datasheet Page 197.

If you use the edge trigger as both(falling and rising) it is consumed two GPIO IRQs. So you can only four GPIO IRQs if you set all the GPIO as both edges.

If you want to test GPIO IRQs with CLI, please refer to this link.
IRQ test on terminal

You can check whether IRQ is in use or not with “cat /proc/interrupts”.

you can see the example dts that the ads7846 use GPIO as pendown interrupt.
https://github.com/hardkernel/linux/blob/odroidc4-4.9.y/arch/arm64/boot/dts/amlogic/meson64_odroidc4.dts#L476

Some of SPI slave devices require interrupts like touch LCD, CAN or etc. You can choose GPIO on external 40pin as interrupt pin except you're using.

But the important fact is that you can only use 6 interrupts on ODROID-C2. There are a total of 8 GPIO-IRQs but it is using the four IRQ to notice the SD_EMMC IN/OUT on ODROID-C2.
Refer to the ODROID-C2 datasheet Page 86.

If you try to use the edge trigger as both(falling and rising) it is consumed three GPIO IRQs. So you can only three GPIO IRQs if you set all the GPIO as both edges.

If you want to test GPIO IRQs with CLI, please refer to this link.
IRQ test on terminal

You can check whether IRQ is in use or not with “cat /proc/interrupts”.
The GPIO IRQ numbers are assigned 96 ~ 103.

The picture shows you that it is using two IRQs, 99 and 101.

You can see the C1 dts example that the ads7846 use GPIO as pendown interrupt.
https://github.com/hardkernel/linux/blob/odroidc-3.10.y/arch/arm/boot/dts/meson8b_odroidc.dts#L636

Some of SPI slave devices require interrupts like touch LCD, CAN or etc. You can choose GPIO on external 40pin as interrupt pin except you're using.

But the important fact is that you can only use 8 interrupts on ODROID-C1.
Refer to the ODROID-C1 datasheet Page 45.

If you use the edge trigger as both(falling and rising) it is consumed two GPIO IRQs. So you can only four GPIO IRQs if you set all the GPIO as both edges.

If you want to test GPIO IRQs with CLI, please refer to this link.
IRQ test on terminal

You can check whether IRQ is in use or not with “cat /proc/interrupts”.
According to the ODROID-C1 datasheet page 52, the GPIO IRQ numbers are assigned 96 ~ 103.

The picture below is when I assigned the IRQ with ads7846 modules.

you can see the example dts that the ads7846 use GPIO as pendown interrupt.
https://github.com/hardkernel/linux/blob/odroidc-3.10.y/arch/arm/boot/dts/meson8b_odroidc.dts#L636

If don't have a build system, you can use the dtc(device-tree-compiler) on terminal.

Install device-tree-compiler on your ODROID-N2

sudo apt update
sudo apt install device-tree-compiler

Backup your dtb file

If you have a problem while modifying the dtb file and cannot boot, overwrite the it with this backup file.

sudo cp /media/boot/meson64_odroidn2.dtb /media/boot/meson64_odroidn2.dtb.old

Disassemble from dtb to dts

sudo dtc -I dtb -O dts /media/boot/meson64_odroidn2.dtb > /media/boot/meson64_odroidn2_my.dts

Edit the dts

In the spi node, modify to the settings you want, adding slave devices, adding SS/IRQ pins and etc.

Compile from dts to dtb

sudo dtc -I dts -O dtb /media/boot/meson64_odroidn2_my.dts > /media/boot/meson64_odroidn2.dtb
sync
sudo reboot

If you have a problem while modifying the dtb file and cannot boot, overwrite with the file you backed up.

ODROID-C4

If don't have a build system, you can use the dtc(device-tree-compiler) on terminal.

Install device-tree-compiler on your ODROID-C4

sudo apt update
sudo apt install device-tree-compiler

Backup your dtb file

If you have a problem while modifying the dtb file and cannot boot, overwrite the it with this backup file.

sudo cp /media/boot/meson64_odroidc4.dtb /media/boot/meson64_odroidc4.dtb.old

Disassemble from dtb to dts

sudo dtc -I dtb -O dts /media/boot/meson64_odroidc4.dtb > /media/boot/meson64_odroidc4_my.dts

Edit the dts

In the spi node, modify to the settings you want, adding slave devices, adding SS/IRQ pins and etc.

Compile from dts to dtb

sudo dtc -I dts -O dtb /media/boot/meson64_odroidc4_my.dts > /media/boot/meson64_odroidc4.dtb
sync
sudo reboot

If you have a problem while modifying the dtb file and cannot boot, overwrite with the file you backed up.

ODROID-C2

If don't have a build system, you can use the dtc(device-tree-compiler) on terminal.

Install device-tree-compiler on your ODROID-C2

sudo apt update
sudo apt install device-tree-compiler

Backup your dtb file

If you have a problem while modifying the dtb file and cannot boot, overwrite the it with this backup file.

sudo cp /media/boot/meson64_odroidc2.dtb /media/boot/meson64_odroidc2.dtb.old

Disassemble from dtb to dts

sudo dtc -I dtb -O dts /media/boot/meson64_odroidc2.dtb > /media/boot/meson64_odroidc2_my.dts

Edit the dts

In the spi node, modify to the settings you want, adding slave devices, adding SS/IRQ pins and etc.

Compile from dts to dtb

sudo dtc -I dts -O dtb /media/boot/meson64_odroidc2_my.dts > /media/boot/meson64_odroidc2.dtb
sync
sudo reboot

If you have a problem while modifying the dtb file and cannot boot, overwrite with the file you backed up.

ODROID-C1/C1+

If don't have a build system, you can use the dtc(device-tree-compiler) on terminal.

Install device-tree-compiler on your ODROID-C1

sudo apt update
sudo apt install device-tree-compiler

Backup your dtb file

If you have a problem while modifying the dtb file and cannot boot, overwrite the it with this backup file.

sudo cp /media/boot/meson8b_odroidc.dtb /media/boot/meson8b_odroidc.dtb.old

Disassemble from dtb to dts

sudo dtc -I dtb -O dts /media/boot/meson8b_odroidc.dtb > /media/boot/meson8b_odroidc_my.dts

Edit the dts

In the spi node, modify to the settings you want, adding slave devices, adding SS/IRQ pins and etc.

Compile from dts to dtb

sudo dtc -I dts -O dtb /media/boot/meson8b_odroidc_my.dts > /media/boot/meson8b_odroidc.dtb
sync
sudo reboot

If you have a problem while modifying the dtb file and cannot boot, overwrite with the file you backed up.

2020/03/17 14:16 · luke.go
  • odroid-c4/application_note/software/spi_ss_irq.txt
  • Last modified: 2020/04/23 16:11
  • by luke.go