/*
* 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.
*/
#include <sys/ddi_impldefs.h>
/*
* JBus Power Management Driver
*
* jbusppm driver initiates the JBus clock speed change
* as part of the protocol to adjust the clock speed on
* all JBus resident devices.
*
* jbusppm driver is loaded because of the explicit dependency
* defined in PPM driver.
*/
/*
* Configuration Function prototypes and data structures
*/
/*
* Configuration data structures
*/
jbppm_open, /* open */
jbppm_close, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
jbppm_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 */
jbppm_getinfo, /* getinfo */
nulldev, /* identify */
nulldev, /* probe */
jbppm_attach, /* attach */
jbppm_detach, /* detach */
nodev, /* reset */
&jbppm_cbops, /* cb_ops */
NULL, /* bus_ops */
NULL, /* power */
ddi_quiesce_not_supported, /* devo_quiesce */
};
extern struct mod_ops mod_driverops;
"JBus ppm driver",
};
&modldrv,
};
/*
* Local functions
*/
static int jbppm_start_next(dev_info_t *, int);
/*
* Driver global variables
*
* jbppm_lock synchronize the access of lyr handle to each jbppm
* 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 *jbppm_statep;
/*
* bit masks to scale the IO bridge clock in sync with and only with
* scaling CPU clock.
*
* The array index indicates power level (from lowest to highest).
*/
};
int
_init(void)
{
int error;
sizeof (jbppm_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).
*/
DDI_KERNEL_IOCTL, NULL, 0);
if (rv != DDI_PROP_SUCCESS)
goto doerrs;
if (rv != DDI_SUCCESS)
goto doerrs;
if (rv != DDI_SUCCESS)
goto doerrs;
/*
* create minor node for kernel_ioctl calls
*/
if (rv != DDI_SUCCESS)
goto doerrs;
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);
}
/* ARGSUSED3 */
static int
{
return (EPERM);
if ((unitp =
return (EIO);
switch (cmd) {
case JBPPMIOC_ISMASTER:
return (0);
else
return (-1);
case JBPPMIOC_NEXT:
return (0);
case JBPPMIOC_GO:
return (EINVAL);
default:
return (ENOTTY);
}
}
/*
* jbppm_next_speed - program a new speed into IO bridge device prior to
* actual speed transition.
*/
static void
{
}
/*
* jbppm_start_next - Initiate JBus speed change on all JBus devices.
* chng_delay indicates after master deassert j_chng signal the number of
* jbus clock delay before all jbus device start to transit to the new
* speed.
* Trigger sequence:
* wait while j_chng[1:0] == 10
* write 00 to j_chng
* trigger by writing 10 to j_chng[1:0]
* wait while j_chng[1:0] == 10
* write 00 to j_chng[1:0]
* Note: this sequence is not the same as Enchilada spec described, chiefly
* because else where (e.g. flush E$ code) may have speed change code. If sw
* wait upon j_chng[1:0] == 11 in both places, we'll have problem. That spec
* requires wait on 11 to ensure that trigger has completed. An alternative
* way to ensure that is to check and wait upon 10. J_chng[1:0] stays as 10
* for only a short period of time that is under HW control, unlike 11 signals
* which has to be cleared by sw.
*/
/* ARGSUSED */
static int
{
/* wait while trigger is incomplete */
do {
/* clear(reset) */
/* trigger */
data64 &= ~J_CHNG_DELAY_MASK;
/* wait while trigger is incomplete */
do {
/* clear(reset) */
return (DDI_SUCCESS);
}