From owner-freebsd-arch@FreeBSD.ORG Thu Jun 19 13:35:05 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AF9E55D4 for ; Thu, 19 Jun 2014 13:35:05 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 874C6211C for ; Thu, 19 Jun 2014 13:35:05 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 68DC7B9A1; Thu, 19 Jun 2014 09:35:04 -0400 (EDT) From: John Baldwin To: freebsd-arch@freebsd.org Subject: Re: How to properly handle several fonctions provided by the Winbond SuperIO chip? Date: Thu, 19 Jun 2014 09:19:04 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; KDE/4.5.5; amd64; ; ) References: <1118241087.138096.1403180509132.JavaMail.zimbra@arkoon-netasq.com> In-Reply-To: <1118241087.138096.1403180509132.JavaMail.zimbra@arkoon-netasq.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201406190919.04443.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 19 Jun 2014 09:35:04 -0400 (EDT) Cc: Emeric POUPON X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jun 2014 13:35:05 -0000 On Thursday, June 19, 2014 8:21:49 am Emeric POUPON wrote: > Hello, > > I have a design question about how to configure/control a Winbond Super IO device. > > Currently, only the Watchdog feature is properly handled in FreeBSD (see dev/wbwd), but I would like to control the GPIO that are managed by this SuperIO device. > > Making a complete separate isa driver seems not to be a good idea : > - duplicated probe/attach routines. > - concurrency accesses on the registers. Indeed this device provides an "extended mode" in order to be configured, and it also provides a "logical device" selection in order to access specific features (one logical device for the watchdog, another one for a GPIO port, etc.). > > As far as I understand, they solved the problem on Linux by : > - using separate drivers > - using a memory locked mechanism when entering/exiting the extended mode. > > However, on FreeBSD I would split the whole thing in three drivers: > - wbsio (sio stands for SuperIO), the main driver: > - identify/attach/probe routines on the isa bus. > - provide primitives to enter/exit the extended mode, and hangle an internal mutex to give exclusive access on this mode. > - provide primitives to select the logical device and read/write the internal registers > - attach child devices "wbwd" and "gpio". > - wbwd, > - child of wbsio > - register the watchdog event callback > - use wbsio primitives to get the work done > - wbgpio, > - child of wbsio > - implement gpio methods > - add child devices "gpioc" and "gpiobus" > - use wbsio primitives to get the work done > > What do you think? Is that the good way to proceed? This sounds correct to treat the raw device as a bus and the logical devices it provides as children. -- John Baldwin