From owner-svn-src-head@freebsd.org Thu May 26 06:35:13 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 69733B4A1CF; Thu, 26 May 2016 06:35:13 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 16C3B16C9; Thu, 26 May 2016 06:35:13 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4Q6ZCvA097981; Thu, 26 May 2016 06:35:12 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4Q6ZC3U097979; Thu, 26 May 2016 06:35:12 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201605260635.u4Q6ZC3U097979@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Thu, 26 May 2016 06:35:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300710 - head/sys/dev/spibus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2016 06:35:13 -0000 Author: adrian Date: Thu May 26 06:35:11 2016 New Revision: 300710 URL: https://svnweb.freebsd.org/changeset/base/300710 Log: [spibus] add initial placeholders for transfer mode and frequency. This doesn't yet implement it in the controllers or the transfer calls, but it's a start. Obtained from: loos (frequency), ray/zrouter (transfer mode) Modified: head/sys/dev/spibus/spibus.c head/sys/dev/spibus/spibusvar.h Modified: head/sys/dev/spibus/spibus.c ============================================================================== --- head/sys/dev/spibus/spibus.c Thu May 26 03:55:27 2016 (r300709) +++ head/sys/dev/spibus/spibus.c Thu May 26 06:35:11 2016 (r300710) @@ -105,6 +105,7 @@ spibus_print_child(device_t dev, device_ retval += bus_print_child_header(dev, child); retval += printf(" at cs %d", devi->cs); + retval += printf(" mode %d", devi->mode); retval += bus_print_child_footer(dev, child); return (retval); @@ -117,6 +118,7 @@ spibus_probe_nomatch(device_t bus, devic device_printf(bus, ""); printf(" at cs %d\n", devi->cs); + printf(" mode %d", devi->mode); return; } @@ -149,6 +151,11 @@ spibus_read_ivar(device_t bus, device_t case SPIBUS_IVAR_CS: *(uint32_t *)result = devi->cs; break; + case SPIBUS_IVAR_MODE: + *(uint32_t *)result = devi->mode; + break; + case SPIBUS_IVAR_CLOCK: + *(uint32_t *)result = devi->clock; } return (0); } @@ -179,7 +186,9 @@ spibus_hinted_child(device_t bus, const child = BUS_ADD_CHILD(bus, 0, dname, dunit); devi = SPIBUS_IVAR(child); + devi->mode = SPIBUS_MODE_NONE; resource_int_value(dname, dunit, "cs", &devi->cs); + resource_int_value(dname, dunit, "mode", &devi->mode); } static int Modified: head/sys/dev/spibus/spibusvar.h ============================================================================== --- head/sys/dev/spibus/spibusvar.h Thu May 26 03:55:27 2016 (r300709) +++ head/sys/dev/spibus/spibusvar.h Thu May 26 06:35:11 2016 (r300710) @@ -34,13 +34,22 @@ struct spibus_softc device_t dev; }; +#define SPIBUS_MODE_NONE 0 +#define SPIBUS_MODE_CPHA 1 +#define SPIBUS_MODE_CPOL 2 +#define SPIBUS_MODE_CPOL_CPHA 3 + struct spibus_ivar { uint32_t cs; + uint32_t mode; + uint32_t clock; }; enum { - SPIBUS_IVAR_CS /* chip select that we're on */ + SPIBUS_IVAR_CS, /* chip select that we're on */ + SPIBUS_IVAR_MODE, /* SPI mode (0-3) */ + SPIBUS_IVAR_CLOCK, /* maximum clock freq for device */ }; #define SPIBUS_ACCESSOR(A, B, T) \ @@ -52,6 +61,8 @@ spibus_get_ ## A(device_t dev, T *t) } SPIBUS_ACCESSOR(cs, CS, uint32_t) +SPIBUS_ACCESSOR(mode, MODE, uint32_t) +SPIBUS_ACCESSOR(clock, CLOCK, uint32_t) extern driver_t spibus_driver; extern devclass_t spibus_devclass;