[meta-raspberrypi] CAN: Add Pican2 support

Submitted by Fabien Lahoudere on Nov. 16, 2018, 3:18 p.m. | Patch ID: 156351

Details

Message ID 1542381485-27805-1-git-send-email-fabien.lahoudere@collabora.com
State New
Headers show

Commit Message

Fabien Lahoudere Nov. 16, 2018, 3:18 p.m.
In order to make Pican 2 work, we :
- add mcp2515.dto to the overlay list
- add a variable to enable it in local.conf
- create a udev rule to mount interface

http://skpang.co.uk/catalog/pican2-canbus-board-for-raspberry-pi-23-p-1475.html

Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
---
 docs/extra-build-config.md                 | 9 +++++++++
 recipes-bsp/bootfiles/rpi-config_git.bb    | 6 ++++++
 recipes-core/udev/udev-rules-rpi.bb        | 6 +++++-
 recipes-core/udev/udev-rules-rpi/can.rules | 1 +
 4 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 recipes-core/udev/udev-rules-rpi/can.rules

Patch hide | download patch | download mbox

diff --git a/docs/extra-build-config.md b/docs/extra-build-config.md
index 732c102..4376462 100644
--- a/docs/extra-build-config.md
+++ b/docs/extra-build-config.md
@@ -246,6 +246,15 @@  When using device tree kernels, set this variable to enable the 802.15.4 hat:
 
 See: <https://openlabs.co/OSHW/Raspberry-Pi-802.15.4-radio>
 
+## Enable CAN with Pican2
+
+In order to use Pican2 CAN module, set the following variables:
+
+	ENABLE_SPI_BUS = "1"
+	ENABLE_CAN = "1"
+
+See: <http://skpang.co.uk/catalog/pican2-canbus-board-for-raspberry-pi-23-p-1475.html>
+
 ## Manual additions to config.txt
 
 The `RPI_EXTRA_CONFIG` variable can be used to manually add additional lines to
diff --git a/recipes-bsp/bootfiles/rpi-config_git.bb b/recipes-bsp/bootfiles/rpi-config_git.bb
index d92b8e4..d0d1fba 100644
--- a/recipes-bsp/bootfiles/rpi-config_git.bb
+++ b/recipes-bsp/bootfiles/rpi-config_git.bb
@@ -183,6 +183,12 @@  do_deploy() {
         echo "dtoverlay=at86rf233,speed=3000000" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
     fi
 
+    # ENABLE CAN
+    if [ "${ENABLE_CAN}" = "1" ]; then
+        echo "# Enable CAN" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
+        echo "dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
+    fi
+
     # Append extra config if the user has provided any
     echo "${RPI_EXTRA_CONFIG}" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
 }
diff --git a/recipes-core/udev/udev-rules-rpi.bb b/recipes-core/udev/udev-rules-rpi.bb
index edef0db..42cfcdd 100644
--- a/recipes-core/udev/udev-rules-rpi.bb
+++ b/recipes-core/udev/udev-rules-rpi.bb
@@ -2,7 +2,10 @@  DESCRIPTION = "udev rules for Raspberry Pi Boards"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
-SRC_URI = " file://99-com.rules"
+SRC_URI = " \
+	file://99-com.rules \
+	file://can.rules \
+	"
 
 S = "${WORKDIR}"
 
@@ -11,4 +14,5 @@  INHIBIT_DEFAULT_DEPS = "1"
 do_install () {
     install -d ${D}${sysconfdir}/udev/rules.d
     install -m 0644 ${WORKDIR}/99-com.rules ${D}${sysconfdir}/udev/rules.d/
+    install -m 0644 ${WORKDIR}/can.rules ${D}${sysconfdir}/udev/rules.d/
 }
diff --git a/recipes-core/udev/udev-rules-rpi/can.rules b/recipes-core/udev/udev-rules-rpi/can.rules
new file mode 100644
index 0000000..a47d57d
--- /dev/null
+++ b/recipes-core/udev/udev-rules-rpi/can.rules
@@ -0,0 +1 @@ 
+SUBSYSTEM=="net", DEVPATH=="/devices/platform/soc/3f204000.spi/spi_master/spi0/spi0.0/net/can0", RUN+="/sbin/ip link set can0 up type can bitrate 500000"

Comments

Andrei Gherzan Nov. 19, 2018, 4:27 p.m.
Hi Fabien,

On Fri, Nov 16, 2018 at 5:29 PM Fabien Lahoudere <
fabien.lahoudere@collabora.com> wrote:

> In order to make Pican 2 work, we :
> - add mcp2515.dto to the overlay list
> - add a variable to enable it in local.conf
> - create a udev rule to mount interface
>

>
> http://skpang.co.uk/catalog/pican2-canbus-board-for-raspberry-pi-23-p-1475.html
>
> Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
>

Could you please submit this PR in github? Check the readme for more
information.
--
Andrei Gherzan