From owner-freebsd-arch@FreeBSD.ORG Sun Sep 2 14:47:18 2012 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DEF8E106566B for ; Sun, 2 Sep 2012 14:47:17 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from mail-ie0-f182.google.com (mail-ie0-f182.google.com [209.85.223.182]) by mx1.freebsd.org (Postfix) with ESMTP id 9DEA18FC1A for ; Sun, 2 Sep 2012 14:47:17 +0000 (UTC) Received: by iebc12 with SMTP id c12so3564970ieb.13 for ; Sun, 02 Sep 2012 07:47:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=+JTmYZHQ0QK9DQ65sX02rU6l/WvGRMKln1xITpW3tU0=; b=pUU1OMEZc9EmS4scwJG/YU7lQ94TkZXe0ObpQiaNUSpYyMwSrhAY+JEPEMuWzgJJv8 T0wERbYwDvecykG4HlSMLT135+q3DIAfX7kED0Aa+U7Okm5SOs/QfUCTZI5C7eJg3Wxx 8AeqBuAYav4ZBlUA73qHOgCewKUIrT83rPZrrcd2agkrPPxX7a/ddpqPDiO0P1o1LVTS nL9P7XjH4avNne9J18d9SNgIsXWZ0oq6J7Rb7yz2tDhKQg48ynuZpuHLGN0y8JKR53DH p2JH8+8dQZSyzp9jHa0xFT3fnKmOUcmkGbIbEk8W14GUN9IsjkMiA0vGPg2w6zXdptvt Vzag== Received: by 10.50.77.131 with SMTP id s3mr8243006igw.20.1346597236800; Sun, 02 Sep 2012 07:47:16 -0700 (PDT) Received: from 63.imp.bsdimp.com (50-78-194-198-static.hfc.comcastbusiness.net. [50.78.194.198]) by mx.google.com with ESMTPS id wn5sm6391745igc.7.2012.09.02.07.47.15 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 02 Sep 2012 07:47:15 -0700 (PDT) Sender: Warner Losh Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: Date: Sun, 2 Sep 2012 08:47:14 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Luiz Otavio O Souza X-Mailer: Apple Mail (2.1084) X-Gm-Message-State: ALoCoQk3gTRq0FwKrb4MAaHnhwm8IgybkkcKnVHuCder6SrXLFlAZWp7eScAL1RIf6NAcdQyle+i Cc: freebsd-arch@freebsd.org Subject: Re: spibus access serialization X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Sep 2012 14:47:18 -0000 On Sep 2, 2012, at 6:37 AM, Luiz Otavio O Souza wrote: > Hi, >=20 > I've some embedded systems with spi devices that share the same spibus = and because of that i'm working to get some kind of access serialization = on spibus and also protection to devices which need a series of spi = transfers to achieve some goal. >=20 > The SPI usage (with all the patches applied) goes like this: >=20 > /* Wait until the spibus is free. When free, acquire the bus and = select the device */ > SPIBUS_ACQUIRE_BUS(spibus, device); Does it do this with a sleep? > /* Program the CPLD to read data from NAND */ > SPIBUS_TRANSFER(spibus, device, &cmd); >=20 > /* Read 'n' bytes from CPLD */ > SPIBUS_TRANSFER(spibus, device, &cmd); >=20 > /* Release the spibus and deselect the device */ > SPIBUS_RELEASE_BUS(spibus, device); >=20 > While today everything is done inside SPIBUS_TRANSFER(). >=20 > The patch spibus-01.diff adds the bus methods and the default methods. >=20 > The spibus-02-devices.diff adds the needed glue to all spi devices = (dev/flash/at45d.c, dev/flash/mx25l.c, arm/lpc/ssd1289.c, = mips/atheros/pcf2123_rtc.c). As the default methods are just nops, there = are no functional changes. >=20 > On spibus-03-controllers.diff we finally add the serialization methods = to spi controllers (mips/atheros/ar71xx_spi.c and arm/lpc/lpc_spi.c) and = change the device CS to happen on bus acquire and release and not on = start and end of each transfer. >=20 > The spi controller on arm/at91/at91_spi.c wasn't changed because looks = like it will be need to move the device CS control from the controller = and use it as a GPIO pin. I need to read more of at91 code before i can = suggest some change there. Until there it will work just as now (no = serialization and selecting/deselecting the device within each = transfer). The at91_spi controller controls which CS line is asserted. So long as = you don't change the bits in the registers, it will stay asserted. I = think it can fit with this scheme. I'll have to take a closer look. = All my AT91 devices have only one chip on the spi bus. > Comments ? I like the idea.... I'll review the code in more detail to see if I see = any gotchas in it. Not sure why we need so many different flash modules, but that's a = different issue. > Thanks, > Luiz >=20 >=20 >=20 > = ______= _________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to = "freebsd-arch-unsubscribe@freebsd.org"