From owner-svn-src-projects@FreeBSD.ORG Fri May 24 04:00:48 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0B10E911; Fri, 24 May 2013 04:00:48 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E1CB978A; Fri, 24 May 2013 04:00:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4O40lQ4028438; Fri, 24 May 2013 04:00:47 GMT (envelope-from jhibbits@svn.freebsd.org) Received: (from jhibbits@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4O40lm3028435; Fri, 24 May 2013 04:00:47 GMT (envelope-from jhibbits@svn.freebsd.org) Message-Id: <201305240400.r4O40lm3028435@svn.freebsd.org> From: Justin Hibbits Date: Fri, 24 May 2013 04:00:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r250958 - projects/pmac_pmu/sys/powerpc/powermac X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 May 2013 04:00:48 -0000 Author: jhibbits Date: Fri May 24 04:00:47 2013 New Revision: 250958 URL: http://svnweb.freebsd.org/changeset/base/250958 Log: Complete the suspend/resume for macio. Modified: projects/pmac_pmu/sys/powerpc/powermac/macio.c projects/pmac_pmu/sys/powerpc/powermac/maciovar.h Modified: projects/pmac_pmu/sys/powerpc/powermac/macio.c ============================================================================== --- projects/pmac_pmu/sys/powerpc/powermac/macio.c Fri May 24 03:59:14 2013 (r250957) +++ projects/pmac_pmu/sys/powerpc/powermac/macio.c Fri May 24 04:00:47 2013 (r250958) @@ -72,6 +72,7 @@ struct macio_softc { int sc_rev; int sc_devid; uint32_t saved_fcrs[6]; + uint32_t saved_mbcr; }; static MALLOC_DEFINE(M_MACIO, "macio", "macio device information"); @@ -138,7 +139,7 @@ static driver_t macio_pci_driver = { devclass_t macio_devclass; -DRIVER_MODULE(macio, pci, macio_pci_driver, macio_devclass, 0, 0); +EARLY_DRIVER_MODULE(macio, pci, macio_pci_driver, macio_devclass, 0, 0, BUS_PASS_BUS); /* * PCI ID search table @@ -629,27 +630,40 @@ static int macio_suspend(device_t dev) if (error) return (error); + if (bus_current_pass != BUS_PASS_BUS) { + return (EAGAIN); + } + powerpc_sync(); + sc->saved_fcrs[0] = bus_read_4(sc->sc_memr, KEYLARGO_FCR0); sc->saved_fcrs[1] = bus_read_4(sc->sc_memr, KEYLARGO_FCR1); sc->saved_fcrs[2] = bus_read_4(sc->sc_memr, KEYLARGO_FCR2); sc->saved_fcrs[3] = bus_read_4(sc->sc_memr, KEYLARGO_FCR3); + sc->saved_fcrs[4] = bus_read_4(sc->sc_memr, KEYLARGO_FCR4); + sc->saved_fcrs[5] = bus_read_4(sc->sc_memr, KEYLARGO_FCR5); - temp = bus_read_4(sc->sc_memr, KEYLARGO_FCR0); + temp = sc->saved_fcrs[0]; temp |= FCR0_USB_REF_SUSPEND; + bus_write_4(sc->sc_memr, KEYLARGO_FCR0, temp); + eieio(); powerpc_sync(); + DELAY(1000); + temp &= ~(FCR0_SCCA_ENABLE | FCR0_SCCB_ENABLE | FCR0_SCC_CELL_ENABLE | FCR0_IRDA_ENABLE | FCR0_IRDA_CLK32_ENABLE | FCR0_IRDA_CLK19_ENABLE); bus_write_4(sc->sc_memr, KEYLARGO_FCR0, temp); - DELAY(1000); + eieio(); powerpc_sync(); if (sc->sc_devid == 0x22) { temp = bus_read_4(sc->sc_memr, KEYLARGO_MEDIABAY); + sc->saved_mbcr = temp; temp |= KEYLARGO_MB0_DEV_ENABLE; bus_write_4(sc->sc_memr, KEYLARGO_MEDIABAY, temp); + eieio(); powerpc_sync(); } - temp = bus_read_4(sc->sc_memr, KEYLARGO_FCR1); + temp = sc->saved_fcrs[1]; temp &= ~(FCR1_AUDIO_SEL_22MCLK | FCR1_AUDIO_CLK_ENABLE | FCR1_AUDIO_CLKOUT_ENABLE | FCR1_AUDIO_CELL_ENABLE | FCR1_I2S0_CELL_ENABLE | FCR1_I2S0_CLK_ENABLE | @@ -661,25 +675,25 @@ static int macio_suspend(device_t dev) FCR1_UIDE_ENABLE ); bus_write_4(sc->sc_memr, KEYLARGO_FCR1, temp); + eieio(); powerpc_sync(); - temp = bus_read_4(sc->sc_memr, KEYLARGO_FCR2); + temp = sc->saved_fcrs[2]; temp &= ~FCR2_IOBUS_ENABLE; bus_write_4(sc->sc_memr, KEYLARGO_FCR2, temp); + eieio(); powerpc_sync(); - temp = bus_read_4(sc->sc_memr, KEYLARGO_FCR3); + temp = sc->saved_fcrs[3]; temp |= (FCR3_SHUTDOWN_PLL_KW6 | FCR3_SHUTDOWN_PLL_KW4 | FCR3_SHUTDOWN_PLL_KW35 | FCR3_SHUTDOWN_PLL_KW12); temp &= ~(FCR3_CLK_66_ENABLE | FCR3_CLK_49_ENABLE | FCR3_CLK_45_ENABLE | FCR3_CLK_31_ENABLE | FCR3_TMR_CLK18_ENABLE | FCR3_I2S1_CLK18_ENABLE | - FCR3_I2S0_CLK18_ENABLE | FCR3_VA_CLK16_ENABLE); + FCR3_I2S0_CLK18_ENABLE | FCR3_VIA_CLK16_ENABLE); if (sc->sc_rev >= 2) temp |= (FCR3_SHUTDOWN_PLL_2X | FCR3_SHUTDOWN_PLL_TOTAL); bus_write_4(sc->sc_memr, KEYLARGO_FCR3, temp); - /* Delay for a millisecond to let things settle. */ - temp = bus_read_4(sc->sc_memr, KEYLARGO_FCR0); - DELAY(1000); - + eieio(); powerpc_sync(); + powerpc_sync(); return (0); } @@ -687,26 +701,20 @@ static int macio_resume(device_t dev) { struct macio_softc *sc = device_get_softc(dev); - bus_write_4(sc->sc_memr, KEYLARGO_FCR0, sc->saved_fcrs[0]); - bus_read_4(sc->sc_memr, KEYLARGO_FCR0); - DELAY(10); - bus_write_4(sc->sc_memr, KEYLARGO_FCR1, sc->saved_fcrs[1]); - bus_read_4(sc->sc_memr, KEYLARGO_FCR1); - DELAY(10); - bus_write_4(sc->sc_memr, KEYLARGO_FCR2, sc->saved_fcrs[2]); - bus_read_4(sc->sc_memr, KEYLARGO_FCR2); - DELAY(10); - bus_write_4(sc->sc_memr, KEYLARGO_FCR3, sc->saved_fcrs[3]); - bus_read_4(sc->sc_memr, KEYLARGO_FCR3); - DELAY(10); - bus_write_4(sc->sc_memr, KEYLARGO_FCR4, sc->saved_fcrs[4]); - bus_read_4(sc->sc_memr, KEYLARGO_FCR4); - DELAY(10); - bus_write_4(sc->sc_memr, KEYLARGO_FCR5, sc->saved_fcrs[5]); - bus_read_4(sc->sc_memr, KEYLARGO_FCR5); - DELAY(10); + if (bus_current_pass == BUS_PASS_BUS) { + if (sc->sc_devid == 0x22) + bus_write_4(sc->sc_memr, KEYLARGO_MEDIABAY, sc->saved_mbcr); + + bus_write_4(sc->sc_memr, KEYLARGO_FCR0, sc->saved_fcrs[0]); + bus_write_4(sc->sc_memr, KEYLARGO_FCR1, sc->saved_fcrs[1]); + bus_write_4(sc->sc_memr, KEYLARGO_FCR2, sc->saved_fcrs[2]); + bus_write_4(sc->sc_memr, KEYLARGO_FCR3, sc->saved_fcrs[3]); + bus_write_4(sc->sc_memr, KEYLARGO_FCR4, sc->saved_fcrs[4]); + bus_write_4(sc->sc_memr, KEYLARGO_FCR5, sc->saved_fcrs[5]); + } - bus_generic_resume(dev); + /* Let things settle. */ + DELAY(1000); - return (0); + return (bus_generic_resume(dev)); } Modified: projects/pmac_pmu/sys/powerpc/powermac/maciovar.h ============================================================================== --- projects/pmac_pmu/sys/powerpc/powermac/maciovar.h Fri May 24 03:59:14 2013 (r250957) +++ projects/pmac_pmu/sys/powerpc/powermac/maciovar.h Fri May 24 04:00:47 2013 (r250958) @@ -61,12 +61,6 @@ #define KEYLARGO_MB1_DEV_RESET 0x02000000 #define KEYLARGO_MB1_ENABLE 0x01000000 -#define KEYLARGO_GPIO_BASE 0x6a -#define KEYLARGO_GPIO_LEVELS_0 0x50 -#define KEYLARGO_GPIO_LEVELS_1 0x54 - -#define KEYLARGO_EXTINT_GPIO_REG_BASE 0x58 - #define FCR0_CHOOSE_SCCB 0x00000001 #define FCR0_CHOOSE_SCCA 0x00000002 #define FCR0_SLOW_SCC_PCLK 0x00000004 @@ -112,7 +106,7 @@ #define FCR3_TMR_CLK18_ENABLE 0x00001000 #define FCR3_I2S1_CLK18_ENABLE 0x00002000 #define FCR3_I2S0_CLK18_ENABLE 0x00004000 -#define FCR3_VA_CLK16_ENABLE 0x00008000 +#define FCR3_VIA_CLK16_ENABLE 0x00008000 /* * Format of a macio reg property entry.