/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2011 Bayard G. Bell. All rights reserved.
*/
#include <sys/ddi_impldefs.h>
#include <sys/psm_types.h>
/*
* ACPI Power Management Driver
*
* acpippm deals with those bits of ppm functionality that
* must be mediated by ACPI
*
* The routines in this driver is referenced by Platform
* Power Management driver of X86 workstation systems.
* acpippm driver is loaded because it is listed as a platform driver
* It is initially configured as a pseudo driver.
*/
extern void pc_tod_set_rtc_offsets(ACPI_TABLE_FADT *);
extern int acpica_use_safe_delay;
/*
* Configuration Function prototypes and data structures
*/
/*
* Configuration data structures
*/
appm_open, /* open */
appm_close, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
appm_ioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* chpoll */
ddi_prop_op, /* prop_op */
NULL, /* stream */
CB_REV, /* rev */
nodev, /* aread */
nodev, /* awrite */
};
DEVO_REV, /* devo_rev */
0, /* refcnt */
appm_getinfo, /* getinfo */
nulldev, /* identify */
nulldev, /* probe */
appm_attach, /* attach */
appm_detach, /* detach */
nodev, /* reset */
&appm_cbops, /* cb_ops */
NULL, /* bus_ops */
NULL, /* power */
ddi_quiesce_not_needed, /* quiesce */
};
extern struct mod_ops mod_driverops;
"ACPI ppm driver",
&appm_ops,
};
&modldrv,
};
/*
* Driver state structure
*/
typedef struct {
} appm_unit;
/*
* Driver global variables
*
* appm_lock synchronize the access of lyr handle to each appm
* minor device, therefore write to tomatillo device is
* sequentialized. Lyr protocol requires pairing up lyr open
* and close, so only a single reference is allowed per minor node.
*/
static void *appm_statep;
/*
* S3 stuff:
*/
extern int acpi_enter_sleepstate(s3a_t *);
extern int acpi_exit_sleepstate(s3a_t *);
int
_init(void)
{
int error;
sizeof (appm_unit), 0)) != DDI_SUCCESS) {
return (error);
}
return (error);
}
return (error);
}
int
_fini(void)
{
int error;
}
return (error);
}
int
{
}
/*
* Driver attach(9e) entry point
*/
static int
{
int instance;
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
if (rv != DDI_SUCCESS) {
return (rv);
}
rv = DDI_FAILURE;
goto doerrs;
}
/*
* Export "ddi-kernel-ioctl" property - prepared to support
* kernel ioctls (driver layering).
* XXX is this still needed?
* XXXX (RSF) Not that I am aware of.
*/
DDI_KERNEL_IOCTL, NULL, 0);
if (rv != DDI_PROP_SUCCESS)
goto doerrs;
/*
* XXX here we would do whatever we need to to determine if the
* XXX platform supports ACPI, and fail the attach if not.
* XXX If it does, we do whatever setup is needed to get access to
* XXX ACPI register space.
*/
/*
* create minor node for kernel_ioctl calls
*/
if (rv != DDI_SUCCESS)
goto doerrs;
/* Get the FADT */
return (rv);
/* Init the RTC offsets */
return (rv);
return (rv);
}
/*
* Driver getinfo(9e) entry routine
*/
/* ARGSUSED */
static int
{
int instance;
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
case DDI_INFO_DEVT2INSTANCE:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/*
* detach(9e)
*/
/* ARGSUSED */
static int
{
switch (cmd) {
case DDI_DETACH:
return (DDI_FAILURE);
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/* ARGSUSED */
static int
{
/* not intended to allow sysadmin level root process to open it */
return (EPERM);
if ((unitp = ddi_get_soft_state(
return (DDI_FAILURE);
}
return (EBUSY);
}
return (DDI_SUCCESS);
}
/* ARGSUSED */
static int
{
if ((unitp =
return (DDI_FAILURE);
return (DDI_SUCCESS);
}
/*
* must match ppm.conf
*/
/* ARGSUSED3 */
static int
{
int ret;
return (EPERM);
}
return (EIO);
}
if (!acpi_initted) {
if (acpica_init() == 0) {
} else {
}
return (EINVAL);
}
}
switch (cmd) {
case APPMIOC_ENTER_S3:
/*
* suspend to RAM (ie S3)
*/
break;
case APPMIOC_EXIT_S3:
/*
* return from S3
*/
break;
default:
return (ENOTTY);
}
/*
* upon failure return EINVAL
*/
if (ret != 0) {
}
return (EINVAL);
}
return (0);
}