Index: devel/rpi-spigen/Makefile =================================================================== --- devel/rpi-spigen/Makefile +++ devel/rpi-spigen/Makefile @@ -0,0 +1,39 @@ +# Created by: Bob Frazier +# $FreeBSD$ + +PORTNAME= rpi-spigen +PORTVERSION= 1.0 +PORTREVISION= 0 +CATEGORIES= devel + +MAINTAINER= bobf@mrp3.com +COMMENT= SPI device 'spigen' overlay for Raspberry Pi + +LICENSE= BSD2CLAUSE + +ONLY_FOR_ARCHS= armv6 armv7 + +.include + +.if ${OPSYS} != FreeBSD || ${OSVERSION} < 1101514 +IGNORE= requires a newer FreeBSD 11 (or later) kernel+world +.endif + +do-fetch: + @${ECHO_CMD} this project does not fetch + +do-extract: + @${MKDIR} ${WRKSRC} + @${CP} files/spigen.dts ${WRKSRC} + +checksum: fetch + @${ECHO_CMD} this project does not need a checksum + +do-build: + @cd ${WRKSRC} ; dtc -I dts -O dtb -o spigen.dtbo spigen.dts + +do-install: + @${MKDIR} ${STAGEDIR}/boot/dtb/overlays + ${INSTALL} ${WRKSRC}/spigen.dtbo ${STAGEDIR}/boot/dtb/overlays + +.include Index: devel/rpi-spigen/files/spigen.dts =================================================================== --- devel/rpi-spigen/files/spigen.dts +++ devel/rpi-spigen/files/spigen.dts @@ -0,0 +1,30 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "brcm,bcm2836", "broadcom,bcm2708-vc"; + + fragment@0 { + target-path = "/axi/spi0"; + __overlay__ { + status = "okay"; + + spigen2: spigen2 { + compatible = "freebsd,spigen"; + reg = <2>; // to invert clock polarity, 'or' with 0x80000000 + status = "okay"; + }; + spigen1: spigen1 { + compatible = "freebsd,spigen"; + reg = <1>; + status = "okay"; + }; + spigen0: spigen0 { + compatible = "freebsd,spigen"; + reg = <0>; + status = "okay"; + }; + }; + }; +}; + Index: devel/rpi-spigen/pkg-descr =================================================================== --- devel/rpi-spigen/pkg-descr +++ devel/rpi-spigen/pkg-descr @@ -0,0 +1,16 @@ +rpi-spigen: A simple overlay for Raspberry Pi that enables spigen + +This port installs an 'overlay' for the hardware definitions that are loaded +during the boot process, to create 3 spigen devices, spigen0 through spigen2, +for a Raspberry Pi model 1B or model 2. Each device is assigned a +corresponding 'cs' (enable pin) value. So access to an SPI device using 'E0' +would involve using 'spigen0'. + +Programs can then use the appropriate spigen device (via ioctl) to control +external hardware that is connected to the SPI pins on the 26-pin connector. + +NOTE: On the Raspberry Pi model 1, the 'E2' pin is not available on the 26 +pin connector, but can be accessed on the circuit board with the use of +additional wiring. On the Raspberry Pi model 2 (and later), the extended +40 pin connector provides access to the 'E2' pin. + Index: devel/rpi-spigen/pkg-message =================================================================== --- devel/rpi-spigen/pkg-message +++ devel/rpi-spigen/pkg-message @@ -0,0 +1,25 @@ + +rpi-spigen: A simple overlay for Raspberry Pi that enables spigen + +IMPORTANT: to actually load the overlay during the boot process, you will +need to add the following lines to the '/boot/loader.conf' : + + spigen_load="YES" + fdt_overlays="spigen.dtbo" + +If you already have overlays listed in 'fdt_overlays', just add the one for +'spigen.dtbo' to the end of that list, separated by white space. + +You will then need to reboot your Raspberry Pi for this to take effect. + +You can check that it is working by listing all of the spigen devices: + + ls /dev/spigen* + +There should be 3 of them, spigen0 through spigen2. If you check the +sysctl variables, you'll see which 'cs' pins are assigned: + + sysctl dev.spigen | grep "%location" + +('cs=0' corresponds to E0, 'cs=1' to E1, 'cs=2' to E2) +