pmu.c (209639) | pmu.c (212054) |
---|---|
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> | 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: head/sys/powerpc/powermac/pmu.c 209639 2010-07-02 02:17:39Z marcel $"); | 30__FBSDID("$FreeBSD: head/sys/powerpc/powermac/pmu.c 212054 2010-08-31 15:27:46Z nwhitehorn $"); |
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> | 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/reboot.h> |
|
39#include <sys/sysctl.h> 40 41#include <dev/ofw/ofw_bus.h> 42#include <dev/ofw/openfirm.h> 43#include <dev/led/led.h> 44 45#include <machine/bus.h> 46#include <machine/intr_machdep.h> --- 29 unchanged lines hidden (view full) --- 76 * ADB Interface 77 */ 78 79static u_int pmu_adb_send(device_t dev, u_char command_byte, int len, 80 u_char *data, u_char poll); 81static u_int pmu_adb_autopoll(device_t dev, uint16_t mask); 82static u_int pmu_poll(device_t dev); 83 | 40#include <sys/sysctl.h> 41 42#include <dev/ofw/ofw_bus.h> 43#include <dev/ofw/openfirm.h> 44#include <dev/led/led.h> 45 46#include <machine/bus.h> 47#include <machine/intr_machdep.h> --- 29 unchanged lines hidden (view full) --- 77 * ADB Interface 78 */ 79 80static u_int pmu_adb_send(device_t dev, u_char command_byte, int len, 81 u_char *data, u_char poll); 82static u_int pmu_adb_autopoll(device_t dev, uint16_t mask); 83static u_int pmu_poll(device_t dev); 84 |
85/* 86 * Power interface 87 */ 88 89static void pmu_shutdown(void *xsc, int howto); |
|
84static void pmu_set_sleepled(void *xsc, int onoff); 85static int pmu_server_mode(SYSCTL_HANDLER_ARGS); 86static int pmu_acline_state(SYSCTL_HANDLER_ARGS); 87static int pmu_query_battery(struct pmu_softc *sc, int batt, 88 struct pmu_battstate *info); 89static int pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS); 90 91/* --- 377 unchanged lines hidden (view full) --- 469 sc->sc_leddev = led_create(pmu_set_sleepled, sc, "sleepled"); 470 471 /* 472 * Register RTC 473 */ 474 475 clock_register(dev, 1000); 476 | 90static void pmu_set_sleepled(void *xsc, int onoff); 91static int pmu_server_mode(SYSCTL_HANDLER_ARGS); 92static int pmu_acline_state(SYSCTL_HANDLER_ARGS); 93static int pmu_query_battery(struct pmu_softc *sc, int batt, 94 struct pmu_battstate *info); 95static int pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS); 96 97/* --- 377 unchanged lines hidden (view full) --- 475 sc->sc_leddev = led_create(pmu_set_sleepled, sc, "sleepled"); 476 477 /* 478 * Register RTC 479 */ 480 481 clock_register(dev, 1000); 482 |
483 /* 484 * Register power control handler 485 */ 486 EVENTHANDLER_REGISTER(shutdown_final, pmu_shutdown, sc, 487 SHUTDOWN_PRI_LAST); 488 |
|
477 return (bus_generic_attach(dev)); 478} 479 480static int 481pmu_detach(device_t dev) 482{ 483 struct pmu_softc *sc; 484 --- 261 unchanged lines hidden (view full) --- 746 pmu_send(sc, PMU_ADB_POLL_OFF, 0, NULL, 16, resp); 747 748 mtx_unlock(&sc->sc_mutex); 749 750 return 0; 751} 752 753static void | 489 return (bus_generic_attach(dev)); 490} 491 492static int 493pmu_detach(device_t dev) 494{ 495 struct pmu_softc *sc; 496 --- 261 unchanged lines hidden (view full) --- 758 pmu_send(sc, PMU_ADB_POLL_OFF, 0, NULL, 16, resp); 759 760 mtx_unlock(&sc->sc_mutex); 761 762 return 0; 763} 764 765static void |
766pmu_shutdown(void *xsc, int howto) 767{ 768 struct pmu_softc *sc = xsc; 769 uint8_t cmd[] = {'M', 'A', 'T', 'T'}; 770 771 if (howto & RB_HALT) 772 pmu_send(sc, PMU_POWER_OFF, 4, cmd, 0, NULL); 773 else 774 pmu_send(sc, PMU_RESET_CPU, 0, NULL, 0, NULL); 775 776 for (;;); 777} 778 779static void |
|
754pmu_set_sleepled(void *xsc, int onoff) 755{ 756 struct pmu_softc *sc = xsc; 757 uint8_t cmd[] = {4, 0, 0}; 758 759 cmd[2] = onoff; 760 761 mtx_lock(&sc->sc_mutex); --- 223 unchanged lines hidden --- | 780pmu_set_sleepled(void *xsc, int onoff) 781{ 782 struct pmu_softc *sc = xsc; 783 uint8_t cmd[] = {4, 0, 0}; 784 785 cmd[2] = onoff; 786 787 mtx_lock(&sc->sc_mutex); --- 223 unchanged lines hidden --- |