/*
* 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>
/*
* The pmugpio driver supports ALOM GPIO bits for resetSC and
* watchdog heartbeat on all relevant platforms. Historically,
* pmugpio is a leaf off the Chalupa pmubus. In addition to
* this support the pmugpio driver has been modified to support
* Minneapolis/Boston Controller (MBC) FPGA GPIO and Seattle CPLD
* GPIO.
*/
typedef enum {
/*
* FWARC 2005/686: gpio device compatible property
*/
/*
* CPLD GPIO Register defines.
*/
/*
* MBC FPGA CSR defines.
*/
/*
* Time periods, in nanoseconds
*/
typedef struct pmugpio_state {
static void *pmugpio_statep;
void **result);
nulldev, /* open */
nulldev, /* close */
nulldev, /* strategy */
nulldev, /* print */
nulldev, /* dump */
nulldev, /* read */
nulldev, /* write */
nulldev, /* ioctl */
nulldev, /* devmap */
nulldev, /* mmap */
nulldev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
NULL, /* streamtab */
};
DEVO_REV, /* Devo_rev */
0, /* Refcnt */
pmugpio_info, /* Info */
nulldev, /* Identify */
nulldev, /* Probe */
pmugpio_attach, /* Attach */
pmugpio_detach, /* Detach */
nodev, /* Reset */
&pmugpio_cb_ops, /* Driver operations */
0, /* Bus operations */
NULL, /* Power */
ddi_quiesce_not_supported, /* devo_quiesce */
};
&mod_driverops, /* This one is a driver */
"Pmugpio Driver", /* Name of the module. */
&pmugpio_ops, /* Driver ops */
};
};
int
_init(void)
{
int error;
/* Initialize the soft state structures */
sizeof (pmugpio_state_t), 1)) != 0) {
return (error);
}
/* Install the loadable module */
}
return (error);
}
int
{
}
int
_fini(void)
{
int error;
if (error == 0) {
/* Release per module resources */
}
return (error);
}
static int
{
int instance;
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
/* Get the instance and create soft state */
return (DDI_FAILURE);
}
if (pmugpio_ptr == NULL) {
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
/* Display information in the banner */
/* Save the dip */
pmugpio_dip = dip;
return (DDI_SUCCESS);
}
/* ARGSUSED */
static int
{
/* Pointer to soft state */
switch (cmd) {
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/* ARGSUSED */
static int
{
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
*result = (void *)pmugpio_dip;
error = DDI_SUCCESS;
break;
case DDI_INFO_DEVT2INSTANCE:
error = DDI_SUCCESS;
break;
default:
error = DDI_FAILURE;
}
return (error);
}
void
pmugpio_watchdog_pat(void)
{
int instance;
return;
}
if (pmugpio_ptr == NULL) {
return;
}
/*
* The RMC can read interrupts either high to low OR low to high. As
* a result all that needs to happen is that when we hit the time to
* send an signal we simply need to change the state.
*/
/*
* fetch current reg value and invert it
*/
switch (pmugpio_ptr->access_type) {
case PMUGPIO_CPLD:
value = (CPLD_WATCHDOG ^
break;
case PMUGPIO_MBC:
break;
case PMUGPIO_OTHER:
break;
default:
}
}
}
void
pmugpio_reset(void)
{
int instance;
return;
}
if (pmugpio_ptr == NULL) {
return;
}
/*
* For Chalupa, turn all bits on then off again - pmubus nexus
* will ensure that only unmasked bit is affected.
* For CPLD and MBC, turn just reset bit on, then off.
*/
switch (pmugpio_ptr->access_type) {
case PMUGPIO_CPLD:
break;
case PMUGPIO_MBC:
(value | MBC_PPC_RESET));
(value & ~MBC_PPC_RESET));
break;
case PMUGPIO_OTHER:
pmugpio_ptr->pmugpio_reset_reg, ~0);
pmugpio_ptr->pmugpio_reset_reg, 0);
break;
default:
}
}
static int
{
char *pmugpio_type;
/* The host controller will be little endian */
/*
* Determine access type per FWARC 2005/686.
* For Boston and Seattle, the OBP gpio device contains a property
* named "gpio-device-type".
*
* Boston: gpio-device-type = SUNW,mbc
* Seattle: gpio-device-type = SUNW,cpld
*
* If this property does not exist, we are a legacy Chalupa.
*/
else {
return (DDI_FAILURE);
}
}
else
switch (pmugpio_ptr->access_type) {
case PMUGPIO_CPLD:
case PMUGPIO_MBC:
if (ddi_regs_map_setup(dip, 0,
return (DDI_FAILURE);
/* MBC and CPLD have reset and watchdog bits in same reg. */
break;
case PMUGPIO_OTHER:
return (DDI_FAILURE);
}
if (ddi_regs_map_setup(dip, 0,
return (DDI_FAILURE);
}
break;
default:
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}