I am trying to put the CAN interface on a riscv computer, and it is taking some time. What I thought is to put a rpi working, and replicate the work on the other system. Here is the configuration that is being followed:
Overlay
part of soc ..
spi@7e204000 {
compatible = "brcm,bcm2835-spi";
clocks = <0x08 0x14>;
status = "okay";
#address-cells = <0x01>;
interrupts = <0x02 0x16>;
cs-gpios = <0x07 0x08 0x01 0x07 0x07 0x01>;
#size-cells = <0x00>;
dma-names = "tx\0rx";
phandle = <0x22>;
reg = <0x7e204000 0x200>;
pinctrl-0 = <0x0e 0x0f>;
dmas = <0x0b 0x06 0x0b 0x07>;
pinctrl-names = "default";
spidev@1 {
compatible = "spidev";
#address-cells = <0x01>;
#size-cells = <0x00>;
phandle = <0x6b>;
reg = <0x01>;
spi-max-frequency = <0x7735940>;
};
mcp2515@0 {
compatible = "microchip,mcp2515";
clocks = <0x8e>;
interrupt-parent = <0x07>; // THIS IS GPIO
interrupts = <0x19 0x08>; // The first is 25 dec, that is the interrupt associated with the spi0.0. The second I think is something related to interrupts
phandle = <0x8f>;
reg = <0x00>;
pinctrl-0 = <0x8d>;
spi-max-frequency = <0x989680>;
pinctrl-names = "default";
};
spidev@0 {
compatible = "spidev";
status = "disabled";
#address-cells = <0x01>;
#size-cells = <0x00>;
phandle = <0x6a>;
reg = <0x00>;
spi-max-frequency = <0x7735940>;
};
};
part of /
can0_osc {
compatible = "fixed-clock";
#clock-cells = <0x00>;
phandle = <0x8e>;
clock-frequency = <0x7a1200>;
};
part of gpio
gpio@7e200000 {
compatible = "brcm,bcm2835-gpio";
gpio-line-names = "A lot of text";
gpio-controller;
gpio-ranges = <0x07 0x00 0x00 0x36>;
#interrupt-cells = <0x02>;
interrupts = <0x02 0x11 0x02 0x12>;
phandle = <0x07>;
reg = <0x7e200000 0xb4>;
#gpio-cells = <0x02>;
pinctrl-names = "default";
interrupt-controller;
SOME USELESS CODE HERE
can0_pins {
brcm,pins = <0x19>;
phandle = <0x8d>;
brcm,function = <0x00>;
};
Pinmux
pin 25 (gpio25): spi0.0 (GPIO UNCLAIMED) function gpio_in group gpio25
Interrupts
160: 252 pinctrl-bcm2835 25 Level spi0.0
Overlay
/*
* Device tree overlay for mcp251x/can0 on spi0.0
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
/* disable spi-dev for spi0.0 */
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
spidev@0{
status = "disabled";
};
};
};
/* the interrupt pin of the can-controller */
fragment@1 {
target = <&gpio>;
__overlay__ {
can0_pins: can0_pins {
brcm,pins = <25>;
brcm,function = <0>; /* input */
};
};
};
/* the clock/oscillator of the can-controller */
fragment@2 {
target-path = "/clocks";
__overlay__ {
/* external oscillator of mcp2515 on SPI0.0 */
can0_osc: can0_osc {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <16000000>;
};
};
};
/* the spi config of the can-controller itself binding everything together */
fragment@3 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
can0: mcp2515@0 {
reg = <0>;
compatible = "microchip,mcp2515";
pinctrl-names = "default";
pinctrl-0 = <&can0_pins>;
spi-max-frequency = <10000000>;
interrupt-parent = <&gpio>;
interrupts = <25 0x2>;
clocks = <&can0_osc>;
};
};
};
__overrides__ {
oscillator = <&can0_osc>,"clock-frequency:0";
spimaxfrequency = <&can0>,"spi-max-frequency:0";
interrupt = <&can0_pins>,"brcm,pins:0",<&can0>,"interrupts:0";
};
};