Port-arm archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Raspberry Pi ACT LED
> Has anybody made any progress in having this ACT led to work and
> indicate SD card activity?
Yes! I made a PoC on my Raspberrys and gave Jared´s code a quick test.
I have the following models:
-Pi 1 Model B: The ACT LED is connected to Pin 16 and lights up when
the Pin is set to 0 (!).
-Pi 2: The ACT LED ist wired to Pin 47 (Pin 15 on gpio1 in NetBSD) and
flahes when that Pin is set to 1.
I have hard-coded these values into the emmc driver for my Pi 2.
static void
bcm2835gpio_pin_write(u_int pin, u_int val)
{
const bus_space_tag_t iot = &bcm2835_bs_tag;
const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(BCM2835_GPIO_BASE);
bus_size_t reg;
if (val) {
reg = BCM2835_GPIO_GPSET(pin /
BCM2835_GPIO_GPSET_PINS_PER_REGISTER);
} else {
reg = BCM2835_GPIO_GPCLR(pin /
BCM2835_GPIO_GPCLR_PINS_PER_REGISTER);
}
bus_space_write_4(iot, ioh, reg, 1 << (pin %
BCM2835_GPIO_GPSET_PINS_PER_REGISTER));
}
(....)
mutex_enter(&sc->sc_lock);
KASSERT(sc->sc_state == EMMC_DMA_STATE_IDLE);
sc->sc_state = EMMC_DMA_STATE_BUSY;
bcm_dmac_set_conblk_addr(sc->sc_dmac,
sc->sc_dmamap->dm_segs[0].ds_addr);
bcm_dmac_transfer(sc->sc_dmac);
bcm2835gpio_pin_write(47, 1);
while (sc->sc_state == EMMC_DMA_STATE_BUSY) {
error = cv_timedwait(&sc->sc_cv, &sc->sc_lock, hz * 10);
if (error == EWOULDBLOCK) {
device_printf(sc->sc.sc_dev, "transfer timeout!\n");
bcm_dmac_halt(sc->sc_dmac);
sc->sc_state = EMMC_DMA_STATE_IDLE;
error = ETIMEDOUT;
break;
}
}
bcm2835gpio_pin_write(47, 0);
mutex_exit(&sc->sc_lock);
This works perfectly. I also tried to pass the bcmemmc_softc to the
bcm2835gpio_pin_write function in order to receive the bus space
handle and tag, which made the device unbootable (I´m not familiar
with that API so I may not oversee it properly at this point.)
However I´m not sure if this approach is best. It might be better to
call the GPIO driver insted of duplicating its routines. There is also
no lock which orders accesses to the according register between the
emmc and GPIO driver - which might be an issue, too. Is there a way
to call the GPIO driver instance from the emmc driver?
I can implement the MD part later which is to inform the emmc driver
if/how to control the LED.
Home |
Main Index |
Thread Index |
Old Index