Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Mar 2015 21:50:40 +0100
From:      Milan Obuch <freebsd-arm@dino.sk>
To:        Luiz Otavio O Souza <lists.br@gmail.com>
Cc:        freebsd-arm@freebsd.org
Subject:   Re: Raspberry Pi SPI device example?
Message-ID:  <20150303215040.13f8439f@zeta.dino.sk>
In-Reply-To: <CAB=2f8zgy8WdFVK9wdN8VXUSw5vpUCOhqPxv2cSHAxiiAw23KA@mail.gmail.com>
References:  <20150216093418.3d1be83b@zeta.dino.sk> <CAB=2f8xUGKWUPu1nk4PoD1ea4PO1BEy=fOZF8X2Y_hNEvTTPtg@mail.gmail.com> <20150219075342.7d2e7eec@zeta.dino.sk> <20150302124103.689135d3@zeta.dino.sk> <CAB=2f8zgy8WdFVK9wdN8VXUSw5vpUCOhqPxv2cSHAxiiAw23KA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.

--=_mailhost.netlabit.sk-77575-1425415841-0001-2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Mon, 2 Mar 2015 20:14:29 -0300
Luiz Otavio O Souza <lists.br@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

--=_mailhost.netlabit.sk-77575-1425415841-0001-2
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=tsc.c

/*-
 * 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);

--=_mailhost.netlabit.sk-77575-1425415841-0001-2--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150303215040.13f8439f>