Raspberry Pi SPI device example?
Milan Obuch
freebsd-arm at dino.sk
Tue Mar 3 20:50:51 UTC 2015
On Mon, 2 Mar 2015 20:14:29 -0300
Luiz Otavio O Souza <lists.br at gmail.com> wrote:
[ snip ]
> Edit the DTS source file (bcm2835.dtsi and/or rpi.dts in
> sys/boot/fdt/dts/arm/) and then the DTB will be built as part of the
> next kernel build (you can also build it manually in
> sys/modules/dtb/rpi).
>
> Here is a patch I'm using to attach a mx25l compatible flash on my RPi
> (old patch...):
>
> http://loos.com.br/mx25l-fdt-intr.diff
>
> And the DTS changes:
>
> Index: sys/boot/fdt/dts/rpi.dts
> ===================================================================
> --- sys/boot/fdt/dts/rpi.dts (revision 253747)
> +++ sys/boot/fdt/dts/rpi.dts (working copy)
> @@ -281,6 +281,14 @@
> broadcom,function = "ALT3";
> };
> };
> +
> + spi0 {
> + flash0 {
> + compatible = "flash,mx25l";
> + spi-chipselect = <0>;
> + };
> + };
> +
> usb {
> hub {
> compatible = "usb,hub", "usb,device";
>
>
> HTH,
> Luiz
Hi,
no success yet. I wrote simple skeleton containing only basic
functions, attached, but nothing shows any call to them. In my dts, I
put
spi0 {
tsc0 {
compatible = "st,stmpe_tc";
spi-chipselect = <0>;
};
};
I tried some variations, too, but no change. There are just two lines
in dmesg mentioning spi:
spi0: <BCM2708/2835 SPI controller> mem 0x204000-0x20401f irq 62 on simplebus0
spibus0: <OFW SPI bus> on spi0
I think I am just missing something simple and obvious, but I can't see
it. Anybody knows what is missing here?
Regards,
Milan
-------------- next part --------------
/*-
* Copyright (c) 2015
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPREC OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNEC FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINEC INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* STMPE610 - touch screen controller/port expander
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/malloc.h>
#include <sys/rman.h>
#include <sys/timeet.h>
#include <sys/timetc.h>
#include <sys/watchdog.h>
#include <sys/gpio.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/intr.h>
#include <dev/spibus/spi.h>
#include <dev/spibus/spibusvar.h>
#include "spibus_if.h"
#include "gpio_if.h"
struct tsc_softc {
device_t dev;
device_t dev_gpio;
};
struct tsc_softc *tsc_sc;
static int
tsc_probe(device_t dev)
{
device_set_desc(dev, "Touchscreen Controller");
device_printf(dev, "probe\n");
return (BUS_PROBE_DEFAULT);
}
static int
tsc_attach(device_t dev)
{
struct tsc_softc *sc;
sc = device_get_softc(dev);
sc->dev = dev;
tsc_sc = sc;
device_printf(dev, "attach\n");
return (0);
}
static int
tsc_detach(device_t dev)
{
struct tsc_softc *sc;
sc = device_get_softc(dev);
return (0);
}
static device_method_t tsc_methods[] = {
DEVMETHOD(device_probe, tsc_probe),
DEVMETHOD(device_attach, tsc_attach),
DEVMETHOD(device_detach, tsc_detach),
DEVMETHOD_END
};
static driver_t tsc_driver = {
"tsc",
tsc_methods,
sizeof(struct tsc_softc),
};
static devclass_t tsc_devclass;
DRIVER_MODULE(tsc, spibus, tsc_driver, tsc_devclass, 0, 0);
More information about the freebsd-arm
mailing list