Date: Sat, 7 Oct 2006 06:59:39 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 107398 for review Message-ID: <200610070659.k976xdi7067784@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=107398 Change 107398 by imp@imp_lighthouse on 2006/10/07 06:59:29 Get the MFG ID and print it. Affected files ... .. //depot/projects/arm/src/sys/dev/flash/at45d.c#4 edit Differences ... ==== //depot/projects/arm/src/sys/dev/flash/at45d.c#4 (text+ko) ==== @@ -37,6 +37,9 @@ #include <sys/module.h> #include <sys/mutex.h> +#include <dev/spibus/spi.h> +#include "spibus_if.h" + struct at45d_softc { struct intr_config_hook config_intrhook; @@ -247,6 +250,34 @@ } #endif +static int +at45d_get_mfg_info(device_t dev, uint8_t *resp) +{ + uint8_t txCmdBuf[8], rxCmdBuf[8], txBuf[8], rxBuf[8]; + struct spi_command cmd; + int err; + + memset(txCmdBuf, 0, sizeof(txCmdBuf)); + memset(txBuf, 0, sizeof(txBuf)); + memset(rxCmdBuf, 0, sizeof(rxCmdBuf)); + memset(rxBuf, 0, sizeof(rxBuf)); + + txCmdBuf[0] = MANUFACTURER_ID; + + cmd.tx_cmd = &txCmdBuf; + cmd.rx_cmd = &rxCmdBuf; + cmd.tx_cmd_sz = 1; + cmd.rx_cmd_sz = 1; + cmd.tx_data = &txBuf; + cmd.rx_data = &rxBuf; + cmd.tx_data_sz = 4; + cmd.rx_data_sz = 4; + err = SPIBUS_TRANSFER(device_get_parent(dev), dev, &cmd); + if (err) + return (err); + memcpy(resp, rxBuf, 4); + return (0); +} static int at45d_probe(device_t dev) @@ -282,7 +313,10 @@ at45d_delayed_attach(void *xsc) { struct at45d_softc *sc = xsc; + uint8_t buf[4]; + at45d_get_mfg_info(sc->dev, buf); + printf("Reply is %#x %#x %#x %#x\n", buf[0], buf[1], buf[2], buf[3]); config_intrhook_disestablish(&sc->config_intrhook); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610070659.k976xdi7067784>