xref: /illumos-gate/usr/src/uts/sun4v/ontario/os/ontario.c (revision fa9e4066)
1b7f45089Sdf /*
2b7f45089Sdf  * CDDL HEADER START
3b7f45089Sdf  *
4b7f45089Sdf  * The contents of this file are subject to the terms of the
5b7f45089Sdf  * Common Development and Distribution License, Version 1.0 only
6b7f45089Sdf  * (the "License").  You may not use this file except in compliance
7b7f45089Sdf  * with the License.
8b7f45089Sdf  *
9b7f45089Sdf  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10b7f45089Sdf  * or http://www.opensolaris.org/os/licensing.
11b7f45089Sdf  * See the License for the specific language governing permissions
12b7f45089Sdf  * and limitations under the License.
13b7f45089Sdf  *
14b7f45089Sdf  * When distributing Covered Code, include this CDDL HEADER in each
15b7f45089Sdf  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16b7f45089Sdf  * If applicable, add the following below this CDDL HEADER, with the
17b7f45089Sdf  * fields enclosed by brackets "[]" replaced with your own identifying
18b7f45089Sdf  * information: Portions Copyright [yyyy] [name of copyright owner]
19b7f45089Sdf  *
20b7f45089Sdf  * CDDL HEADER END
21b7f45089Sdf  */
22b7f45089Sdf 
23b7f45089Sdf /*
24b7f45089Sdf  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25b7f45089Sdf  * Use is subject to license terms.
26b7f45089Sdf  */
27b7f45089Sdf 
28b7f45089Sdf #pragma ident	"%Z%%M%	%I%	%E% SMI"
29b7f45089Sdf 
30b7f45089Sdf #include <sys/param.h>
31b7f45089Sdf #include <sys/systm.h>
32b7f45089Sdf #include <sys/sysmacros.h>
33b7f45089Sdf #include <sys/sunddi.h>
34b7f45089Sdf #include <sys/esunddi.h>
35b7f45089Sdf #include <sys/sunndi.h>
36b7f45089Sdf 
37b7f45089Sdf #include <sys/platform_module.h>
38b7f45089Sdf #include <sys/errno.h>
39b7f45089Sdf #include <sys/utsname.h>
40b7f45089Sdf #include <sys/modctl.h>
41b7f45089Sdf #include <sys/systeminfo.h>
42b7f45089Sdf #include <sys/promif.h>
43b7f45089Sdf #include <sys/bootconf.h>
44b7f45089Sdf 
45b7f45089Sdf /*
46b7f45089Sdf  * Definitions for accessing the pci config space of the isa node
47b7f45089Sdf  * of Southbridge.
48b7f45089Sdf  */
496acc6190Sdf #define	ONTARIO_ISA_PATHNAME	"/pci@7c0/pci@0/pci@1/pci@0/isa@2"
506acc6190Sdf #define	ONTARIO_IDE_PATHNAME	"/pci@7c0/pci@0/pci@1/pci@0/ide@8"
51b7f45089Sdf 
52b7f45089Sdf /*
53b7f45089Sdf  * Handle for isa pci space
54b7f45089Sdf  */
55b7f45089Sdf static ddi_acc_handle_t isa_handle;
56b7f45089Sdf 
57b7f45089Sdf /*
58b7f45089Sdf  * Platform power management drivers list - empty by default
59b7f45089Sdf  */
60b7f45089Sdf char *platform_module_list[] = {
61b7f45089Sdf 	(char *)0
62b7f45089Sdf };
63b7f45089Sdf 
64b7f45089Sdf 
65b7f45089Sdf /*ARGSUSED*/
66b7f45089Sdf void
plat_tod_fault(enum tod_fault_type tod_bad)67b7f45089Sdf plat_tod_fault(enum tod_fault_type tod_bad)
68b7f45089Sdf {
69b7f45089Sdf }
70b7f45089Sdf 
71b7f45089Sdf void
load_platform_drivers(void)72b7f45089Sdf load_platform_drivers(void)
73b7f45089Sdf {
74b7f45089Sdf 	dev_info_t 		*dip;		/* dip of the isa driver */
75*fa9e4066Sahrens 	pnode_t 		nodeid;
76b7f45089Sdf 
77b7f45089Sdf 	/*
78b7f45089Sdf 	 * Install ISA driver. This is required for the southbridge IDE
79b7f45089Sdf 	 * workaround - to reset the IDE channel during IDE bus reset.
80b7f45089Sdf 	 * Panic the system in case ISA driver could not be loaded or
81b7f45089Sdf 	 * any problem in accessing its pci config space. Since the register
82b7f45089Sdf 	 * to reset the channel for IDE is in ISA config space!.
83b7f45089Sdf 	 */
84b7f45089Sdf 
85b7f45089Sdf 	nodeid = prom_finddevice(ONTARIO_IDE_PATHNAME);
86b7f45089Sdf 	if (nodeid == OBP_BADNODE) {
87b7f45089Sdf 		return;
88b7f45089Sdf 	}
89b7f45089Sdf 	dip = e_ddi_hold_devi_by_path(ONTARIO_ISA_PATHNAME, 0);
90b7f45089Sdf 	if (dip == NULL) {
91b7f45089Sdf 		cmn_err(CE_PANIC, "Could not install the isa driver\n");
92b7f45089Sdf 		return;
93b7f45089Sdf 	}
94b7f45089Sdf 
95b7f45089Sdf 	if (pci_config_setup(dip, &isa_handle) != DDI_SUCCESS) {
96b7f45089Sdf 		cmn_err(CE_PANIC, "Could not get the config space of isa\n");
97b7f45089Sdf 		return;
98b7f45089Sdf 	}
99b7f45089Sdf }
100b7f45089Sdf 
101b7f45089Sdf /*
102b7f45089Sdf  * This routine provides a workaround for a bug in the SB chip which
103b7f45089Sdf  * can cause data corruption. Will be invoked from the IDE HBA driver for
104b7f45089Sdf  * Acer SouthBridge at the time of IDE bus reset.
105b7f45089Sdf  */
106b7f45089Sdf /*ARGSUSED*/
107b7f45089Sdf int
plat_ide_chipreset(dev_info_t * dip,int chno)108b7f45089Sdf plat_ide_chipreset(dev_info_t *dip, int chno)
109b7f45089Sdf {
110b7f45089Sdf 	uint8_t	val;
111b7f45089Sdf 	int	ret = DDI_SUCCESS;
112b7f45089Sdf 
113b7f45089Sdf 	if (isa_handle == NULL) {
114b7f45089Sdf 		return (DDI_FAILURE);
115b7f45089Sdf 	}
116b7f45089Sdf 
117b7f45089Sdf 	val = pci_config_get8(isa_handle, 0x58);
118b7f45089Sdf 	/*
119b7f45089Sdf 	 * The dip passed as the argument is not used here.
120b7f45089Sdf 	 * This will be needed for platforms which have multiple on-board SB,
121b7f45089Sdf 	 * The dip passed will be used to match the corresponding ISA node.
122b7f45089Sdf 	 */
123b7f45089Sdf 	switch (chno) {
124b7f45089Sdf 	case 0:
125b7f45089Sdf 		/*
126b7f45089Sdf 		 * First disable the primary channel then re-enable it.
127b7f45089Sdf 		 * As per ALI no wait should be required in between have
128b7f45089Sdf 		 * given 1ms delay in between to be on safer side.
129b7f45089Sdf 		 * bit 2 of register 0x58 when 0 disable the channel 0.
130b7f45089Sdf 		 * bit 2 of register 0x58 when 1 enables the channel 0.
131b7f45089Sdf 		 */
132b7f45089Sdf 		pci_config_put8(isa_handle, 0x58, val & 0xFB);
133b7f45089Sdf 		drv_usecwait(1000);
134b7f45089Sdf 		pci_config_put8(isa_handle, 0x58, val);
135b7f45089Sdf 		break;
136b7f45089Sdf 	case 1:
137b7f45089Sdf 		/*
138b7f45089Sdf 		 * bit 3 of register 0x58 when 0 disable the channel 1.
139b7f45089Sdf 		 * bit 3 of register 0x58 when 1 enables the channel 1.
140b7f45089Sdf 		 */
141b7f45089Sdf 		pci_config_put8(isa_handle, 0x58, val & 0xF7);
142b7f45089Sdf 		drv_usecwait(1000);
143b7f45089Sdf 		pci_config_put8(isa_handle, 0x58, val);
144b7f45089Sdf 		break;
145b7f45089Sdf 	default:
146b7f45089Sdf 		/*
147b7f45089Sdf 		 * Unknown channel number passed. Return failure.
148b7f45089Sdf 		 */
149b7f45089Sdf 		ret = DDI_FAILURE;
150b7f45089Sdf 	}
151b7f45089Sdf 
152b7f45089Sdf 	return (ret);
153b7f45089Sdf }
154