5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include <sys/types.h>
28 #include <sys/modctl.h>
29 #include <sys/debug.h>
30 #include <sys/promif.h>
31 #include <sys/pci.h>
32 #include <sys/errno.h>
33 #include <sys/open.h>
34 #include <sys/uio.h>
35 #include <sys/cred.h>
36 #include <sys/cpu.h>
37 #include "ata_common.h"
38 #include "ata_disk.h"
39 #include "atapi.h"
40 #include "ata_blacklist.h"
41 #include "sil3xxx.h"
42
43 /*
44 * Solaris Entry Points.
3482 if (proprc == DDI_PROP_SUCCESS) {
3483 cp = bufp;
3484 rc = stoi(&cp);
3485 ddi_prop_free(bufp);
3486 } else {
3487 /*
3488 * see if property is encoded as an int instead of string.
3489 */
3490 rc = ddi_prop_get_int(match_dev, dip, flags, name, defvalue);
3491 }
3492
3493 return (rc);
3494 }
3495
3496 /*
3497 * Initialize the power management components
3498 */
3499 static void
3500 ata_init_pm(dev_info_t *dip)
3501 {
3502 char pmc_name[16];
3503 char *pmc[] = {
3504 NULL,
3505 "0=Sleep (PCI D3 State)",
3506 "3=PowerOn (PCI D0 State)",
3507 NULL
3508 };
3509 int instance;
3510 ata_ctl_t *ata_ctlp;
3511
3512
3513 instance = ddi_get_instance(dip);
3514 ata_ctlp = ddi_get_soft_state(ata_state, instance);
3515 ata_ctlp->ac_pm_support = 0;
3516
3517 /* check PCI capabilities */
3518 if (!ata_is_pci(dip))
3519 return;
3520
3521 (void) sprintf(pmc_name, "NAME=ata%d", instance);
3522 pmc[0] = pmc_name;
3523
3524 #ifdef ATA_USE_AUTOPM
3525 if (ddi_prop_update_string_array(DDI_DEV_T_NONE, dip,
3526 "pm-components", pmc, 3) != DDI_PROP_SUCCESS) {
3527 return;
3528 }
3529 #endif
3530
3531 ata_ctlp->ac_pm_support = 1;
3532 ata_ctlp->ac_pm_level = PM_LEVEL_D0;
3533
3534 ATA_BUSY_COMPONENT(dip, 0);
3535 if (ATA_RAISE_POWER(dip, 0, PM_LEVEL_D0) != DDI_SUCCESS) {
3536 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "pm-components");
3537 }
3538 ATA_IDLE_COMPONENT(dip, 0);
3539 }
3540
3541 /*
3542 * resume the hard drive
3543 */
3544 static void
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright 2017 RackTop Systems.
27 */
28
29 #include <sys/types.h>
30 #include <sys/modctl.h>
31 #include <sys/debug.h>
32 #include <sys/promif.h>
33 #include <sys/pci.h>
34 #include <sys/errno.h>
35 #include <sys/open.h>
36 #include <sys/uio.h>
37 #include <sys/cred.h>
38 #include <sys/cpu.h>
39 #include "ata_common.h"
40 #include "ata_disk.h"
41 #include "atapi.h"
42 #include "ata_blacklist.h"
43 #include "sil3xxx.h"
44
45 /*
46 * Solaris Entry Points.
3484 if (proprc == DDI_PROP_SUCCESS) {
3485 cp = bufp;
3486 rc = stoi(&cp);
3487 ddi_prop_free(bufp);
3488 } else {
3489 /*
3490 * see if property is encoded as an int instead of string.
3491 */
3492 rc = ddi_prop_get_int(match_dev, dip, flags, name, defvalue);
3493 }
3494
3495 return (rc);
3496 }
3497
3498 /*
3499 * Initialize the power management components
3500 */
3501 static void
3502 ata_init_pm(dev_info_t *dip)
3503 {
3504 int instance;
3505 ata_ctl_t *ata_ctlp;
3506 #ifdef ATA_USE_AUTOPM
3507 char pmc_name[16];
3508 char *pmc[] = {
3509 NULL,
3510 "0=Sleep (PCI D3 State)",
3511 "3=PowerOn (PCI D0 State)",
3512 NULL
3513 };
3514 #endif
3515
3516
3517 instance = ddi_get_instance(dip);
3518 ata_ctlp = ddi_get_soft_state(ata_state, instance);
3519 ata_ctlp->ac_pm_support = 0;
3520
3521 /* check PCI capabilities */
3522 if (!ata_is_pci(dip))
3523 return;
3524
3525 #ifdef ATA_USE_AUTOPM
3526 (void) sprintf(pmc_name, "NAME=ata%d", instance);
3527 pmc[0] = pmc_name;
3528
3529 if (ddi_prop_update_string_array(DDI_DEV_T_NONE, dip,
3530 "pm-components", pmc, 3) != DDI_PROP_SUCCESS) {
3531 return;
3532 }
3533 #endif
3534
3535 ata_ctlp->ac_pm_support = 1;
3536 ata_ctlp->ac_pm_level = PM_LEVEL_D0;
3537
3538 ATA_BUSY_COMPONENT(dip, 0);
3539 if (ATA_RAISE_POWER(dip, 0, PM_LEVEL_D0) != DDI_SUCCESS) {
3540 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "pm-components");
3541 }
3542 ATA_IDLE_COMPONENT(dip, 0);
3543 }
3544
3545 /*
3546 * resume the hard drive
3547 */
3548 static void
|