1/* $Id: elsc.h,v 1.1.1.1 2008/10/15 03:29:03 james26_jang Exp $
2 *
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License.  See the file "COPYING" in the main directory of this archive
5 * for more details.
6 *
7 * Copyright (C) 1992-1997, 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 */
9#ifndef _ASM_SN_KSYS_ELSC_H
10#define _ASM_SN_KSYS_ELSC_H
11
12#include <asm/sn/ksys/l1.h>
13
14#define ELSC_ACP_MAX		86		/* 84+cr+lf */
15#define ELSC_LINE_MAX		(ELSC_ACP_MAX - 2)
16
17typedef sc_cq_t elsc_cq_t;
18
19/*
20 * ELSC structure passed around as handle
21 */
22
23typedef l1sc_t elsc_t;
24
25void	elsc_init(elsc_t *e, nasid_t nasid);
26
27int	elsc_process(elsc_t *e);
28int	elsc_msg_check(elsc_t *e, char *msg, int msg_max);
29int	elsc_msg_callback(elsc_t *e,
30			  void (*callback)(void *callback_data, char *msg),
31			  void *callback_data);
32char   *elsc_errmsg(int code);
33
34int	elsc_nvram_write(elsc_t *e, int addr, char *buf, int len);
35int	elsc_nvram_read(elsc_t *e, int addr, char *buf, int len);
36int	elsc_nvram_magic(elsc_t *e);
37int	elsc_command(elsc_t *e, int only_if_message);
38int	elsc_parse(elsc_t *e, char *p1, char *p2, char *p3);
39int	elsc_ust_write(elsc_t *e, uchar_t c);
40int 	elsc_ust_read(elsc_t *e, char *c);
41
42
43
44/*
45 * System controller commands
46 */
47
48int	elsc_version(elsc_t *e, char *result);
49int	elsc_debug_set(elsc_t *e, u_char byte1, u_char byte2);
50int	elsc_debug_get(elsc_t *e, u_char *byte1, u_char *byte2);
51int	elsc_module_set(elsc_t *e, int module);
52int	elsc_module_get(elsc_t *e);
53int	elsc_partition_set(elsc_t *e, int partition);
54int	elsc_partition_get(elsc_t *e);
55int	elsc_domain_set(elsc_t *e, int domain);
56int	elsc_domain_get(elsc_t *e);
57int	elsc_cluster_set(elsc_t *e, int cluster);
58int	elsc_cluster_get(elsc_t *e);
59int	elsc_cell_set(elsc_t *e, int cell);
60int	elsc_cell_get(elsc_t *e);
61int	elsc_bist_set(elsc_t *e, char bist_status);
62char	elsc_bist_get(elsc_t *e);
63int	elsc_lock(elsc_t *e, int retry_interval_usec, int timeout_usec, u_char lock_val);
64int	elsc_unlock(elsc_t *e);
65int	elsc_display_char(elsc_t *e, int led, int chr);
66int	elsc_display_digit(elsc_t *e, int led, int num, int l_case);
67int	elsc_display_mesg(elsc_t *e, char *chr);	/* 8-char input */
68int	elsc_password_set(elsc_t *e, char *password);	/* 4-char input */
69int	elsc_password_get(elsc_t *e, char *password);	/* 4-char output */
70int	elsc_rpwr_query(elsc_t *e, int is_master);
71int	elsc_power_query(elsc_t *e);
72int	elsc_power_down(elsc_t *e, int sec);
73int	elsc_power_cycle(elsc_t *e);
74int	elsc_system_reset(elsc_t *e);
75int	elsc_dip_switches(elsc_t *e);
76int	elsc_nic_get(elsc_t *e, uint64_t *nic, int verbose);
77
78int	_elsc_hbt(elsc_t *e, int ival, int rdly);
79
80#define	elsc_hbt_enable(e, ival, rdly)	_elsc_hbt(e, ival, rdly)
81#define	elsc_hbt_disable(e)		_elsc_hbt(e, 0, 0)
82#define	elsc_hbt_send(e)		_elsc_hbt(e, 0, 1)
83
84elsc_t	       *get_elsc(void);
85
86/*
87 * Error codes
88 *
89 *   The possible ELSC error codes are a superset of the I2C error codes,
90 *   so ELSC error codes begin at -100.
91 */
92
93#define ELSC_ERROR_NONE			0
94
95#define ELSC_ERROR_CMD_SEND	       (-100)	/* Error sending command    */
96#define ELSC_ERROR_CMD_CHECKSUM	       (-101)	/* Command checksum bad     */
97#define ELSC_ERROR_CMD_UNKNOWN	       (-102)	/* Unknown command          */
98#define ELSC_ERROR_CMD_ARGS	       (-103)	/* Invalid argument(s)      */
99#define ELSC_ERROR_CMD_PERM	       (-104)	/* Permission denied	    */
100#define ELSC_ERROR_CMD_STATE	       (-105)	/* not allowed in this state*/
101
102#define ELSC_ERROR_RESP_TIMEOUT	       (-110)	/* ELSC response timeout    */
103#define ELSC_ERROR_RESP_CHECKSUM       (-111)	/* Response checksum bad    */
104#define ELSC_ERROR_RESP_FORMAT	       (-112)	/* Response format error    */
105#define ELSC_ERROR_RESP_DIR	       (-113)	/* Response direction error */
106
107#define ELSC_ERROR_MSG_LOST	       (-120)	/* Queue full; msg. lost    */
108#define ELSC_ERROR_LOCK_TIMEOUT	       (-121)	/* ELSC response timeout    */
109#define ELSC_ERROR_DATA_SEND	       (-122)	/* Error sending data       */
110#define ELSC_ERROR_NIC		       (-123)	/* NIC processing error     */
111#define ELSC_ERROR_NVMAGIC	       (-124)	/* Bad magic no. in NVRAM   */
112#define ELSC_ERROR_MODULE	       (-125)	/* Moduleid processing err  */
113
114#endif /* _ASM_SN_KSYS_ELSC_H */
115