From owner-p4-projects@FreeBSD.ORG Sat Oct 7 06:59:40 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 73E5E16A415; Sat, 7 Oct 2006 06:59:40 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 36F5F16A403 for ; Sat, 7 Oct 2006 06:59:40 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 032ED43D4C for ; Sat, 7 Oct 2006 06:59:40 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k976xd7W067787 for ; Sat, 7 Oct 2006 06:59:39 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k976xdi7067784 for perforce@freebsd.org; Sat, 7 Oct 2006 06:59:39 GMT (envelope-from imp@freebsd.org) Date: Sat, 7 Oct 2006 06:59:39 GMT Message-Id: <200610070659.k976xdi7067784@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 107398 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Oct 2006 06:59:40 -0000 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 #include +#include +#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); }