From owner-svn-src-stable-10@FreeBSD.ORG Sat Apr 12 19:57:16 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 52A0435F; Sat, 12 Apr 2014 19:57:16 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 3DCC4190A; Sat, 12 Apr 2014 19:57:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3CJvGmI013627; Sat, 12 Apr 2014 19:57:16 GMT (envelope-from andreast@svn.freebsd.org) Received: (from andreast@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3CJvFnc013622; Sat, 12 Apr 2014 19:57:15 GMT (envelope-from andreast@svn.freebsd.org) Message-Id: <201404121957.s3CJvFnc013622@svn.freebsd.org> From: Andreas Tobler Date: Sat, 12 Apr 2014 19:57:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r264375 - in stable/10/sys: modules/sound/driver/ai2s powerpc/include powerpc/powermac X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Apr 2014 19:57:16 -0000 Author: andreast Date: Sat Apr 12 19:57:15 2014 New Revision: 264375 URL: http://svnweb.freebsd.org/changeset/base/264375 Log: MFC r260607, r260610, r260934: r260607: The onyx codec works also as module, so add it. r260610: Described in the man page but not implemented. Here it comes, atomic_swap_32/64. The latter only for powerpc64. r260934: Fix the resource information for the i2s-a node on certain G5 PowerMacs. This is the first step needed to get the snapper codec working on those machines. The second step is to enable the corresponding I2S device and its clock. Tested on machines where the snapper codec was already working, a G4 PowerBook and a PowerMac9,1 with a Shasta based macio. The PowerMac7,2/7,3 with a K2 based macio can now also play sound. Modified: stable/10/sys/modules/sound/driver/ai2s/Makefile stable/10/sys/powerpc/include/atomic.h stable/10/sys/powerpc/powermac/macio.c stable/10/sys/powerpc/powermac/maciovar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/modules/sound/driver/ai2s/Makefile ============================================================================== --- stable/10/sys/modules/sound/driver/ai2s/Makefile Sat Apr 12 18:01:25 2014 (r264374) +++ stable/10/sys/modules/sound/driver/ai2s/Makefile Sat Apr 12 19:57:15 2014 (r264375) @@ -5,6 +5,6 @@ KMOD= snd_ai2s SRCS= device_if.h bus_if.h ofw_bus_if.h SRCS+= channel_if.h feeder_if.h mixer_if.h -SRCS+= snapper.c tumbler.c aoa.c i2s.c +SRCS+= onyx.c snapper.c tumbler.c aoa.c i2s.c .include Modified: stable/10/sys/powerpc/include/atomic.h ============================================================================== --- stable/10/sys/powerpc/include/atomic.h Sat Apr 12 18:01:25 2014 (r264374) +++ stable/10/sys/powerpc/include/atomic.h Sat Apr 12 19:57:15 2014 (r264375) @@ -684,10 +684,47 @@ atomic_fetchadd_long(volatile u_long *p, return (value); } +static __inline u_int +atomic_swap_32(volatile u_int *p, u_int v) +{ + u_int prev; + + __asm __volatile( + "1: lwarx %0,0,%2\n" + " stwcx. %3,0,%2\n" + " bne- 1b\n" + : "=&r" (prev), "+m" (*(volatile u_int *)p) + : "r" (p), "r" (v) + : "cc", "memory"); + + return (prev); +} + +#ifdef __powerpc64__ +static __inline u_long +atomic_swap_64(volatile u_long *p, u_long v) +{ + u_long prev; + + __asm __volatile( + "1: ldarx %0,0,%2\n" + " stdcx. %3,0,%2\n" + " bne- 1b\n" + : "=&r" (prev), "+m" (*(volatile u_long *)p) + : "r" (p), "r" (v) + : "cc", "memory"); + + return (prev); +} +#endif + #define atomic_fetchadd_32 atomic_fetchadd_int +#define atomic_swap_int atomic_swap_32 #ifdef __powerpc64__ #define atomic_fetchadd_64 atomic_fetchadd_long +#define atomic_swap_long atomic_swap_64 +#define atomic_swap_ptr atomic_swap_64 #endif #undef __ATOMIC_REL Modified: stable/10/sys/powerpc/powermac/macio.c ============================================================================== --- stable/10/sys/powerpc/powermac/macio.c Sat Apr 12 18:01:25 2014 (r264374) +++ stable/10/sys/powerpc/powermac/macio.c Sat Apr 12 19:57:15 2014 (r264375) @@ -236,13 +236,45 @@ macio_add_intr(phandle_t devnode, struct static void macio_add_reg(phandle_t devnode, struct macio_devinfo *dinfo) { - struct macio_reg *reg; - int i, nreg; + struct macio_reg *reg, *regp; + phandle_t child; + char buf[8]; + int i, layout_id = 0, nreg, res; nreg = OF_getprop_alloc(devnode, "reg", sizeof(*reg), (void **)®); if (nreg == -1) return; + /* + * Some G5's have broken properties in the i2s-a area. If so we try + * to fix it. Right now we know of two different cases, one for + * sound layout-id 36 and the other one for sound layout-id 76. + * What is missing is the base address for the memory addresses. + * We take them from the parent node (i2s) and use the size + * information from the child. + */ + + if (reg[0].mr_base == 0) { + child = OF_child(devnode); + while (child != 0) { + res = OF_getprop(child, "name", buf, sizeof(buf)); + if (res > 0 && strcmp(buf, "sound") == 0) + break; + child = OF_peer(child); + } + + res = OF_getprop(child, "layout-id", &layout_id, + sizeof(layout_id)); + + if (res > 0 && (layout_id == 36 || layout_id == 76)) { + res = OF_getprop_alloc(OF_parent(devnode), "reg", + sizeof(*regp), (void **)®p); + reg[0] = regp[0]; + reg[1].mr_base = regp[1].mr_base; + reg[2].mr_base = regp[1].mr_base + reg[1].mr_size; + } + } + for (i = 0; i < nreg; i++) { resource_list_add(&dinfo->mdi_resources, SYS_RES_MEMORY, i, reg[i].mr_base, reg[i].mr_base + reg[i].mr_size, @@ -284,6 +316,7 @@ macio_attach(device_t dev) phandle_t subchild; device_t cdev; u_int reg[3]; + char compat[32]; int error, quirks; sc = device_get_softc(dev); @@ -297,6 +330,9 @@ macio_attach(device_t dev) return (ENXIO); } + /* Used later to see if we have to enable the I2S part. */ + OF_getprop(root, "compatible", compat, sizeof(compat)); + sc->sc_base = reg[2]; sc->sc_size = MACIO_REG_SIZE; @@ -378,6 +414,21 @@ macio_attach(device_t dev) bus_write_4(sc->sc_memr, HEATHROW_FCR, fcr); } + + /* + * Make sure the I2S0 and the I2S0_CLK are enabled. + * On certain G5's they are not. + */ + if ((strcmp(ofw_bus_get_name(cdev), "i2s") == 0) && + (strcmp(compat, "K2-Keylargo") == 0)) { + + uint32_t fcr1; + + fcr1 = bus_read_4(sc->sc_memr, KEYLARGO_FCR1); + fcr1 |= FCR1_I2S0_CLK_ENABLE | FCR1_I2S0_ENABLE; + bus_write_4(sc->sc_memr, KEYLARGO_FCR1, fcr1); + } + } return (bus_generic_attach(dev)); Modified: stable/10/sys/powerpc/powermac/maciovar.h ============================================================================== --- stable/10/sys/powerpc/powermac/maciovar.h Sat Apr 12 18:01:25 2014 (r264374) +++ stable/10/sys/powerpc/powermac/maciovar.h Sat Apr 12 19:57:15 2014 (r264375) @@ -48,6 +48,9 @@ #define FCR_ENET_ENABLE 0x60000000 #define FCR_ENET_RESET 0x80000000 +#define FCR1_I2S0_CLK_ENABLE 0x00001000 +#define FCR1_I2S0_ENABLE 0x00002000 + /* Used only by macio_enable_wireless() for now. */ #define KEYLARGO_GPIO_BASE 0x6a #define KEYLARGO_EXTINT_GPIO_REG_BASE 0x58