1/*- 2 * Copyright (c) 2006 Michael Lorenz 3 * Copyright 2008 by Nathan Whitehorn 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 13 unchanged lines hidden (view full) --- 22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: stable/10/sys/powerpc/powermac/pmu.c 262675 2014-03-02 02:35:46Z jhibbits $"); |
31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/module.h> 35#include <sys/bus.h> 36#include <sys/conf.h> 37#include <sys/kernel.h> 38#include <sys/clock.h> 39#include <sys/proc.h> 40#include <sys/reboot.h> 41#include <sys/sysctl.h> 42 43#include <dev/ofw/ofw_bus.h> 44#include <dev/ofw/openfirm.h> 45#include <dev/led/led.h> 46 47#include <machine/_inttypes.h> |
48#include <machine/bus.h> 49#include <machine/cpu.h> |
50#include <machine/hid.h> 51#include <machine/intr_machdep.h> 52#include <machine/md_var.h> 53#include <machine/pcb.h> 54#include <machine/pio.h> 55#include <machine/resource.h> |
56 57#include <vm/vm.h> 58#include <vm/pmap.h> 59 60#include <sys/rman.h> 61 62#include <dev/adb/adb.h> 63 --- 34 unchanged lines hidden (view full) --- 98 99static void pmu_shutdown(void *xsc, int howto); 100static void pmu_set_sleepled(void *xsc, int onoff); 101static int pmu_server_mode(SYSCTL_HANDLER_ARGS); 102static int pmu_acline_state(SYSCTL_HANDLER_ARGS); 103static int pmu_query_battery(struct pmu_softc *sc, int batt, 104 struct pmu_battstate *info); 105static int pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS); |
106 107/* 108 * List of battery-related sysctls we might ask for 109 */ 110 111enum { 112 PMU_BATSYSCTL_PRESENT = 1 << 8, 113 PMU_BATSYSCTL_CHARGING = 2 << 8, --- 908 unchanged lines hidden (view full) --- 1022 1023 mtx_lock(&sc->sc_mutex); 1024 pmu_send(sc, PMU_SET_RTC, sizeof(sec), (uint8_t *)&sec, 0, NULL); 1025 mtx_unlock(&sc->sc_mutex); 1026 1027 return (0); 1028} 1029 |
1030int 1031pmu_set_speed(int low_speed) 1032{ 1033 struct pmu_softc *sc; 1034 uint8_t sleepcmd[] = {'W', 'O', 'O', 'F', 0}; 1035 uint8_t resp[16]; 1036 1037 sc = device_get_softc(pmu); 1038 pmu_write_reg(sc, vIER, 0x10); 1039 spinlock_enter(); 1040 mtdec(0x7fffffff); 1041 mb(); 1042 mtdec(0x7fffffff); 1043 1044 sleepcmd[4] = low_speed; 1045 pmu_send(sc, PMU_CPU_SPEED, 5, sleepcmd, 16, resp); 1046 unin_chip_sleep(NULL, 1); |
1047 platform_sleep(); |
1048 unin_chip_wake(NULL); 1049 1050 mtdec(1); /* Force a decrementer exception */ 1051 spinlock_exit(); 1052 pmu_write_reg(sc, vIER, 0x90); 1053 1054 return (0); 1055} |