17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*986fd29aSsetje * Common Development and Distribution License (the "License").
6*986fd29aSsetje * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
22*986fd29aSsetje * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate #include <sys/param.h>
297c478bd9Sstevel@tonic-gate #include <sys/systm.h>
307c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
317c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
327c478bd9Sstevel@tonic-gate #include <sys/esunddi.h>
337c478bd9Sstevel@tonic-gate #include <sys/platform_module.h>
347c478bd9Sstevel@tonic-gate #include <sys/errno.h>
357c478bd9Sstevel@tonic-gate #include <sys/lgrp.h>
367c478bd9Sstevel@tonic-gate #include <sys/memnode.h>
377c478bd9Sstevel@tonic-gate #include <sys/promif.h>
387c478bd9Sstevel@tonic-gate
3984612482Sminht #define EBUS_NAME "ebus"
4084612482Sminht #define RTC_NAME "rtc"
417c478bd9Sstevel@tonic-gate #define SHARED_MI2CV_PATH "/i2c@1f,520000"
427c478bd9Sstevel@tonic-gate static dev_info_t *shared_mi2cv_dip;
437c478bd9Sstevel@tonic-gate static kmutex_t chicago_mi2cv_mutex;
447c478bd9Sstevel@tonic-gate
4584612482Sminht /*
4684612482Sminht * External variables
4784612482Sminht */
4884612482Sminht extern volatile uint8_t *v_rtc_addr_reg;
4984612482Sminht
507c478bd9Sstevel@tonic-gate int (*p2get_mem_unum)(int, uint64_t, char *, int, int *);
5184612482Sminht static void get_ebus_rtc_vaddr(void);
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate void
startup_platform(void)547c478bd9Sstevel@tonic-gate startup_platform(void)
557c478bd9Sstevel@tonic-gate {
567c478bd9Sstevel@tonic-gate mutex_init(&chicago_mi2cv_mutex, NULL, NULL, NULL);
577c478bd9Sstevel@tonic-gate }
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gate int
set_platform_tsb_spares()607c478bd9Sstevel@tonic-gate set_platform_tsb_spares()
617c478bd9Sstevel@tonic-gate {
627c478bd9Sstevel@tonic-gate return (0);
637c478bd9Sstevel@tonic-gate }
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gate void
set_platform_defaults(void)667c478bd9Sstevel@tonic-gate set_platform_defaults(void)
677c478bd9Sstevel@tonic-gate {
687c478bd9Sstevel@tonic-gate extern char *tod_module_name;
6984612482Sminht
7084612482Sminht /*
7184612482Sminht * We need to set tod_module_name explicitly because there is a
7284612482Sminht * well known South bridge RTC node on chicago and tod_module_name
7384612482Sminht * gets set to that.
7484612482Sminht */
7584612482Sminht tod_module_name = "todbq4802";
7684612482Sminht
7784612482Sminht /* Work-around for Chicago platform */
7884612482Sminht get_ebus_rtc_vaddr();
7984612482Sminht
807c478bd9Sstevel@tonic-gate }
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate * Definitions for accessing the pci config space of the isa node
847c478bd9Sstevel@tonic-gate * of Southbridge.
857c478bd9Sstevel@tonic-gate */
867c478bd9Sstevel@tonic-gate static ddi_acc_handle_t isa_handle = NULL; /* handle for isa pci space */
877c478bd9Sstevel@tonic-gate
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate void
load_platform_drivers(void)907c478bd9Sstevel@tonic-gate load_platform_drivers(void)
917c478bd9Sstevel@tonic-gate {
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate * Install power driver which handles the power button.
947c478bd9Sstevel@tonic-gate */
957c478bd9Sstevel@tonic-gate if (i_ddi_attach_hw_nodes("power") != DDI_SUCCESS)
967c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "Failed to install \"power\" driver.");
977c478bd9Sstevel@tonic-gate (void) ddi_hold_driver(ddi_name_to_major("power"));
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate /*
1007c478bd9Sstevel@tonic-gate * It is OK to return error because 'us' driver is not available
1017c478bd9Sstevel@tonic-gate * in all clusters (e.g. missing in Core cluster).
1027c478bd9Sstevel@tonic-gate */
1037c478bd9Sstevel@tonic-gate (void) i_ddi_attach_hw_nodes("us");
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate if (i_ddi_attach_hw_nodes("grbeep") != DDI_SUCCESS)
1067c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "Failed to install \"beep\" driver.");
1077c478bd9Sstevel@tonic-gate
1087c478bd9Sstevel@tonic-gate
1097c478bd9Sstevel@tonic-gate /*
1107c478bd9Sstevel@tonic-gate * mc-us3i must stay loaded for plat_get_mem_unum()
1117c478bd9Sstevel@tonic-gate */
1127c478bd9Sstevel@tonic-gate if (i_ddi_attach_hw_nodes("mc-us3i") != DDI_SUCCESS)
1137c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "mc-us3i driver failed to install");
1147c478bd9Sstevel@tonic-gate (void) ddi_hold_driver(ddi_name_to_major("mc-us3i"));
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gate /*
1177c478bd9Sstevel@tonic-gate * Figure out which mi2cv dip is shared with OBP for the nvram
1187c478bd9Sstevel@tonic-gate * device, so the lock can be acquired.
1197c478bd9Sstevel@tonic-gate */
1207c478bd9Sstevel@tonic-gate shared_mi2cv_dip = e_ddi_hold_devi_by_path(SHARED_MI2CV_PATH, 0);
1217c478bd9Sstevel@tonic-gate }
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1247c478bd9Sstevel@tonic-gate int
plat_cpu_poweron(struct cpu * cp)1257c478bd9Sstevel@tonic-gate plat_cpu_poweron(struct cpu *cp)
1267c478bd9Sstevel@tonic-gate {
1277c478bd9Sstevel@tonic-gate return (ENOTSUP); /* not supported on this platform */
1287c478bd9Sstevel@tonic-gate }
1297c478bd9Sstevel@tonic-gate
1307c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1317c478bd9Sstevel@tonic-gate int
plat_cpu_poweroff(struct cpu * cp)1327c478bd9Sstevel@tonic-gate plat_cpu_poweroff(struct cpu *cp)
1337c478bd9Sstevel@tonic-gate {
1347c478bd9Sstevel@tonic-gate return (ENOTSUP); /* not supported on this platform */
1357c478bd9Sstevel@tonic-gate }
1367c478bd9Sstevel@tonic-gate
1377c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1387c478bd9Sstevel@tonic-gate void
plat_freelist_process(int mnode)1397c478bd9Sstevel@tonic-gate plat_freelist_process(int mnode)
1407c478bd9Sstevel@tonic-gate {
1417c478bd9Sstevel@tonic-gate }
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate char *platform_module_list[] = {
1447c478bd9Sstevel@tonic-gate "mi2cv",
1457c478bd9Sstevel@tonic-gate "jbusppm",
1467c478bd9Sstevel@tonic-gate "pca9556",
1477c478bd9Sstevel@tonic-gate "ppm",
1487c478bd9Sstevel@tonic-gate (char *)0
1497c478bd9Sstevel@tonic-gate };
1507c478bd9Sstevel@tonic-gate
1517c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1527c478bd9Sstevel@tonic-gate void
plat_tod_fault(enum tod_fault_type tod_bad)1537c478bd9Sstevel@tonic-gate plat_tod_fault(enum tod_fault_type tod_bad)
1547c478bd9Sstevel@tonic-gate {
1557c478bd9Sstevel@tonic-gate }
1567c478bd9Sstevel@tonic-gate
1577c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1587c478bd9Sstevel@tonic-gate int
plat_get_mem_unum(int synd_code,uint64_t flt_addr,int flt_bus_id,int flt_in_memory,ushort_t flt_status,char * buf,int buflen,int * lenp)1597c478bd9Sstevel@tonic-gate plat_get_mem_unum(int synd_code, uint64_t flt_addr, int flt_bus_id,
1607c478bd9Sstevel@tonic-gate int flt_in_memory, ushort_t flt_status, char *buf, int buflen, int *lenp)
1617c478bd9Sstevel@tonic-gate {
1627c478bd9Sstevel@tonic-gate if (flt_in_memory && (p2get_mem_unum != NULL))
1637c478bd9Sstevel@tonic-gate return (p2get_mem_unum(synd_code, P2ALIGN(flt_addr, 8),
1647c478bd9Sstevel@tonic-gate buf, buflen, lenp));
1657c478bd9Sstevel@tonic-gate else
1667c478bd9Sstevel@tonic-gate return (ENOTSUP);
1677c478bd9Sstevel@tonic-gate }
1687c478bd9Sstevel@tonic-gate
1697c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1707c478bd9Sstevel@tonic-gate int
plat_get_cpu_unum(int cpuid,char * buf,int buflen,int * lenp)1717c478bd9Sstevel@tonic-gate plat_get_cpu_unum(int cpuid, char *buf, int buflen, int *lenp)
1727c478bd9Sstevel@tonic-gate {
1737c478bd9Sstevel@tonic-gate if (snprintf(buf, buflen, "MB") >= buflen) {
1747c478bd9Sstevel@tonic-gate return (ENOSPC);
1757c478bd9Sstevel@tonic-gate } else {
1767c478bd9Sstevel@tonic-gate *lenp = strlen(buf);
1777c478bd9Sstevel@tonic-gate return (0);
1787c478bd9Sstevel@tonic-gate }
1797c478bd9Sstevel@tonic-gate }
1807c478bd9Sstevel@tonic-gate
1817c478bd9Sstevel@tonic-gate /*
1827c478bd9Sstevel@tonic-gate * Fiesta support for lgroups.
1837c478bd9Sstevel@tonic-gate *
1847c478bd9Sstevel@tonic-gate * On fiesta platform, an lgroup platform handle == CPU id
1857c478bd9Sstevel@tonic-gate */
1867c478bd9Sstevel@tonic-gate
1877c478bd9Sstevel@tonic-gate /*
1887c478bd9Sstevel@tonic-gate * Macro for extracting the CPU number from the CPU id
1897c478bd9Sstevel@tonic-gate */
1907c478bd9Sstevel@tonic-gate #define CPUID_TO_LGRP(id) ((id) & 0x7)
1917c478bd9Sstevel@tonic-gate #define CHICAGO_MC_SHIFT 36
1927c478bd9Sstevel@tonic-gate
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate * Return the platform handle for the lgroup containing the given CPU
1957c478bd9Sstevel@tonic-gate */
1967c478bd9Sstevel@tonic-gate void *
plat_lgrp_cpu_to_hand(processorid_t id)1977c478bd9Sstevel@tonic-gate plat_lgrp_cpu_to_hand(processorid_t id)
1987c478bd9Sstevel@tonic-gate {
199b4ea5066Sminht return ((void *)(uintptr_t)CPUID_TO_LGRP(id));
2007c478bd9Sstevel@tonic-gate }
2017c478bd9Sstevel@tonic-gate
2027c478bd9Sstevel@tonic-gate /*
2037c478bd9Sstevel@tonic-gate * Platform specific lgroup initialization
2047c478bd9Sstevel@tonic-gate */
2057c478bd9Sstevel@tonic-gate void
plat_lgrp_init(void)2067c478bd9Sstevel@tonic-gate plat_lgrp_init(void)
2077c478bd9Sstevel@tonic-gate {
208fa9e4066Sahrens pnode_t curnode;
209f72d0064Sess char tmp_name[sizeof (OBP_CPU)];
2107c478bd9Sstevel@tonic-gate int portid;
2117c478bd9Sstevel@tonic-gate int cpucnt = 0;
2127c478bd9Sstevel@tonic-gate int max_portid = -1;
2137c478bd9Sstevel@tonic-gate extern uint32_t lgrp_expand_proc_thresh;
2147c478bd9Sstevel@tonic-gate extern uint32_t lgrp_expand_proc_diff;
2157c478bd9Sstevel@tonic-gate extern pgcnt_t lgrp_mem_free_thresh;
2167c478bd9Sstevel@tonic-gate extern uint32_t lgrp_loadavg_tolerance;
2177c478bd9Sstevel@tonic-gate extern uint32_t lgrp_loadavg_max_effect;
2187c478bd9Sstevel@tonic-gate extern uint32_t lgrp_load_thresh;
2197c478bd9Sstevel@tonic-gate extern lgrp_mem_policy_t lgrp_mem_policy_root;
2207c478bd9Sstevel@tonic-gate
2217c478bd9Sstevel@tonic-gate /*
2227c478bd9Sstevel@tonic-gate * Count the number of CPUs installed to determine if
2237c478bd9Sstevel@tonic-gate * NUMA optimization should be enabled or not.
2247c478bd9Sstevel@tonic-gate *
2257c478bd9Sstevel@tonic-gate * All CPU nodes reside in the root node and have a
2267c478bd9Sstevel@tonic-gate * device type "cpu".
2277c478bd9Sstevel@tonic-gate */
2287c478bd9Sstevel@tonic-gate curnode = prom_rootnode();
2297c478bd9Sstevel@tonic-gate for (curnode = prom_childnode(curnode); curnode;
2307c478bd9Sstevel@tonic-gate curnode = prom_nextnode(curnode)) {
231f72d0064Sess bzero(tmp_name, sizeof (tmp_name));
232f72d0064Sess if (prom_bounded_getprop(curnode, OBP_DEVICETYPE, tmp_name,
233f72d0064Sess sizeof (tmp_name)) == -1 || strcmp(tmp_name, OBP_CPU) != 0)
2347c478bd9Sstevel@tonic-gate continue;
2357c478bd9Sstevel@tonic-gate
2367c478bd9Sstevel@tonic-gate cpucnt++;
2377c478bd9Sstevel@tonic-gate if (prom_getprop(curnode, "portid", (caddr_t)&portid) !=
2387c478bd9Sstevel@tonic-gate -1 && portid > max_portid)
2397c478bd9Sstevel@tonic-gate max_portid = portid;
2407c478bd9Sstevel@tonic-gate }
2417c478bd9Sstevel@tonic-gate if (cpucnt <= 1)
2427c478bd9Sstevel@tonic-gate max_mem_nodes = 1;
2437c478bd9Sstevel@tonic-gate else if (max_portid >= 0 && max_portid < MAX_MEM_NODES)
2447c478bd9Sstevel@tonic-gate max_mem_nodes = max_portid + 1;
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gate /*
2477c478bd9Sstevel@tonic-gate * Set tuneables for fiesta architecture
2487c478bd9Sstevel@tonic-gate *
2497c478bd9Sstevel@tonic-gate * lgrp_expand_proc_thresh is the minimum load on the lgroups
2507c478bd9Sstevel@tonic-gate * this process is currently running on before considering
2517c478bd9Sstevel@tonic-gate * expanding threads to another lgroup.
2527c478bd9Sstevel@tonic-gate *
2537c478bd9Sstevel@tonic-gate * lgrp_expand_proc_diff determines how much less the remote lgroup
2547c478bd9Sstevel@tonic-gate * must be loaded before expanding to it.
2557c478bd9Sstevel@tonic-gate *
2567c478bd9Sstevel@tonic-gate * Optimize for memory bandwidth by spreading multi-threaded
2577c478bd9Sstevel@tonic-gate * program to different lgroups.
2587c478bd9Sstevel@tonic-gate */
2597c478bd9Sstevel@tonic-gate lgrp_expand_proc_thresh = lgrp_loadavg_max_effect - 1;
2607c478bd9Sstevel@tonic-gate lgrp_expand_proc_diff = lgrp_loadavg_max_effect / 2;
2617c478bd9Sstevel@tonic-gate lgrp_loadavg_tolerance = lgrp_loadavg_max_effect / 2;
2627c478bd9Sstevel@tonic-gate lgrp_mem_free_thresh = 1; /* home lgrp must have some memory */
2637c478bd9Sstevel@tonic-gate lgrp_expand_proc_thresh = lgrp_loadavg_max_effect - 1;
2647c478bd9Sstevel@tonic-gate lgrp_mem_policy_root = LGRP_MEM_POLICY_NEXT;
2657c478bd9Sstevel@tonic-gate lgrp_load_thresh = 0;
2667c478bd9Sstevel@tonic-gate
2677c478bd9Sstevel@tonic-gate mem_node_pfn_shift = CHICAGO_MC_SHIFT - MMU_PAGESHIFT;
2687c478bd9Sstevel@tonic-gate }
2697c478bd9Sstevel@tonic-gate
2707c478bd9Sstevel@tonic-gate /*
2717c478bd9Sstevel@tonic-gate * Return latency between "from" and "to" lgroups
2727c478bd9Sstevel@tonic-gate *
2737c478bd9Sstevel@tonic-gate * This latency number can only be used for relative comparison
2747c478bd9Sstevel@tonic-gate * between lgroups on the running system, cannot be used across platforms,
2757c478bd9Sstevel@tonic-gate * and may not reflect the actual latency. It is platform and implementation
2767c478bd9Sstevel@tonic-gate * specific, so platform gets to decide its value. It would be nice if the
2777c478bd9Sstevel@tonic-gate * number was at least proportional to make comparisons more meaningful though.
2787c478bd9Sstevel@tonic-gate * NOTE: The numbers below are supposed to be load latencies for uncached
2797c478bd9Sstevel@tonic-gate * memory divided by 10.
2807c478bd9Sstevel@tonic-gate */
2817c478bd9Sstevel@tonic-gate int
plat_lgrp_latency(lgrp_handle_t from,lgrp_handle_t to)2827c478bd9Sstevel@tonic-gate plat_lgrp_latency(lgrp_handle_t from, lgrp_handle_t to)
2837c478bd9Sstevel@tonic-gate {
2847c478bd9Sstevel@tonic-gate /*
2857c478bd9Sstevel@tonic-gate * Return remote latency when there are more than two lgroups
2867c478bd9Sstevel@tonic-gate * (root and child) and getting latency between two different
2877c478bd9Sstevel@tonic-gate * lgroups or root is involved
2887c478bd9Sstevel@tonic-gate */
2897c478bd9Sstevel@tonic-gate if (lgrp_optimizations() && (from != to ||
2907c478bd9Sstevel@tonic-gate from == LGRP_DEFAULT_HANDLE || to == LGRP_DEFAULT_HANDLE))
2917c478bd9Sstevel@tonic-gate return (17);
2927c478bd9Sstevel@tonic-gate else
2937c478bd9Sstevel@tonic-gate return (12);
2947c478bd9Sstevel@tonic-gate }
2957c478bd9Sstevel@tonic-gate
2967c478bd9Sstevel@tonic-gate int
plat_pfn_to_mem_node(pfn_t pfn)2977c478bd9Sstevel@tonic-gate plat_pfn_to_mem_node(pfn_t pfn)
2987c478bd9Sstevel@tonic-gate {
2997c478bd9Sstevel@tonic-gate ASSERT(max_mem_nodes > 1);
3007c478bd9Sstevel@tonic-gate return (pfn >> mem_node_pfn_shift);
3017c478bd9Sstevel@tonic-gate }
3027c478bd9Sstevel@tonic-gate
3037c478bd9Sstevel@tonic-gate /*
3047c478bd9Sstevel@tonic-gate * Assign memnode to lgroups
3057c478bd9Sstevel@tonic-gate */
3067c478bd9Sstevel@tonic-gate void
plat_fill_mc(pnode_t nodeid)307fa9e4066Sahrens plat_fill_mc(pnode_t nodeid)
3087c478bd9Sstevel@tonic-gate {
3097c478bd9Sstevel@tonic-gate int portid;
3107c478bd9Sstevel@tonic-gate
3117c478bd9Sstevel@tonic-gate /*
3127c478bd9Sstevel@tonic-gate * Chicago memory controller portid == global CPU id
3137c478bd9Sstevel@tonic-gate */
3147c478bd9Sstevel@tonic-gate if ((prom_getprop(nodeid, "portid", (caddr_t)&portid) == -1) ||
3157c478bd9Sstevel@tonic-gate (portid < 0))
3167c478bd9Sstevel@tonic-gate return;
3177c478bd9Sstevel@tonic-gate
3187c478bd9Sstevel@tonic-gate if (portid < max_mem_nodes)
3197c478bd9Sstevel@tonic-gate plat_assign_lgrphand_to_mem_node((lgrp_handle_t)portid, portid);
3207c478bd9Sstevel@tonic-gate }
3217c478bd9Sstevel@tonic-gate
3227c478bd9Sstevel@tonic-gate /*
3237c478bd9Sstevel@tonic-gate * Common locking enter code
3247c478bd9Sstevel@tonic-gate */
3257c478bd9Sstevel@tonic-gate void
plat_setprop_enter(void)3267c478bd9Sstevel@tonic-gate plat_setprop_enter(void)
3277c478bd9Sstevel@tonic-gate {
3287c478bd9Sstevel@tonic-gate mutex_enter(&chicago_mi2cv_mutex);
3297c478bd9Sstevel@tonic-gate }
3307c478bd9Sstevel@tonic-gate
3317c478bd9Sstevel@tonic-gate /*
3327c478bd9Sstevel@tonic-gate * Common locking exit code
3337c478bd9Sstevel@tonic-gate */
3347c478bd9Sstevel@tonic-gate void
plat_setprop_exit(void)3357c478bd9Sstevel@tonic-gate plat_setprop_exit(void)
3367c478bd9Sstevel@tonic-gate {
3377c478bd9Sstevel@tonic-gate mutex_exit(&chicago_mi2cv_mutex);
3387c478bd9Sstevel@tonic-gate }
3397c478bd9Sstevel@tonic-gate
3407c478bd9Sstevel@tonic-gate /*
3417c478bd9Sstevel@tonic-gate * Called by mi2cv driver
3427c478bd9Sstevel@tonic-gate */
3437c478bd9Sstevel@tonic-gate void
plat_shared_i2c_enter(dev_info_t * i2cnexus_dip)3447c478bd9Sstevel@tonic-gate plat_shared_i2c_enter(dev_info_t *i2cnexus_dip)
3457c478bd9Sstevel@tonic-gate {
3467c478bd9Sstevel@tonic-gate if (i2cnexus_dip == shared_mi2cv_dip) {
3477c478bd9Sstevel@tonic-gate plat_setprop_enter();
3487c478bd9Sstevel@tonic-gate }
3497c478bd9Sstevel@tonic-gate }
3507c478bd9Sstevel@tonic-gate
3517c478bd9Sstevel@tonic-gate /*
3527c478bd9Sstevel@tonic-gate * Called by mi2cv driver
3537c478bd9Sstevel@tonic-gate */
3547c478bd9Sstevel@tonic-gate void
plat_shared_i2c_exit(dev_info_t * i2cnexus_dip)3557c478bd9Sstevel@tonic-gate plat_shared_i2c_exit(dev_info_t *i2cnexus_dip)
3567c478bd9Sstevel@tonic-gate {
3577c478bd9Sstevel@tonic-gate if (i2cnexus_dip == shared_mi2cv_dip) {
3587c478bd9Sstevel@tonic-gate plat_setprop_exit();
3597c478bd9Sstevel@tonic-gate }
3607c478bd9Sstevel@tonic-gate }
36184612482Sminht
36284612482Sminht /*
36384612482Sminht * Work-around for the Chicago platform.
36484612482Sminht * There are two RTCs in the Chicago platform, one on the Southbridge
36584612482Sminht * and one on the EBUS.
36684612482Sminht * In the current Solaris implementation, have_rtc in sun4u/os/fillsysinfo.c
36784612482Sminht * returns address of the first rtc it sees. In this case, it's the SB RTC.
36884612482Sminht *
36984612482Sminht * get_ebus_rtc_vaddr() looks for the EBUS RTC and setup the right address.
37084612482Sminht * If there is no EBUS RTC node or the RTC node does not have the valid
37184612482Sminht * address property, get_ebus_rtc_vaddr() will fail.
37284612482Sminht */
37384612482Sminht static void
get_ebus_rtc_vaddr()37484612482Sminht get_ebus_rtc_vaddr()
37584612482Sminht {
376fa9e4066Sahrens pnode_t node;
37784612482Sminht int size;
37884612482Sminht uint32_t eaddr;
37984612482Sminht
38084612482Sminht /* Find ebus RTC node */
38184612482Sminht if ((node = prom_findnode_byname(prom_rootnode(),
38284612482Sminht EBUS_NAME)) == OBP_NONODE)
38384612482Sminht cmn_err(CE_PANIC, "ebus node not present\n");
38484612482Sminht if ((node = prom_findnode_byname(node, RTC_NAME)) == OBP_NONODE)
38584612482Sminht cmn_err(CE_PANIC, "ebus RTC node not found\n");
38684612482Sminht
38784612482Sminht /* Make sure the ebus RTC address property is valid */
38884612482Sminht if ((size = prom_getproplen(node, "address")) == -1)
38984612482Sminht cmn_err(CE_PANIC, "ebus RTC addr prop. length not found\n");
39084612482Sminht if (size != sizeof (eaddr))
39184612482Sminht cmn_err(CE_PANIC, "ebus RTC addr length not OK."
392b4ea5066Sminht " expected = %lu found =%d\n", sizeof (eaddr), size);
39384612482Sminht if (prom_getprop(node, "address", (caddr_t)&eaddr) == -1)
39484612482Sminht cmn_err(CE_PANIC, "ebus RTC addr propery not found\n");
395b4ea5066Sminht v_rtc_addr_reg = (volatile unsigned char *)(uintptr_t)eaddr;
39684612482Sminht
39784612482Sminht /*
39884612482Sminht * Does this rtc have watchdog support?
39984612482Sminht */
40084612482Sminht if (prom_getproplen(node, "watchdog-enable") != -1)
40184612482Sminht watchdog_available = 1;
40284612482Sminht }
403