File: /usr/src/linux/include/asm-ia64/sn/ksys/elsc.h

1     /* $Id$
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 Silicon Graphics, Inc.
8      * Copyright (C) 2000 by Colin Ngam
9      */
10     #ifndef _ASM_SN_KSYS_ELSC_H
11     #define _ASM_SN_KSYS_ELSC_H
12     
13     #include <linux/config.h>
14     
15     #if defined(CONFIG_IA64_SGI_SN1) || defined(CONFIG_IA64_GENERIC)
16     #include <asm/sn/ksys/l1.h>
17     #endif
18     
19     // #include <asm/sn/ksys/i2c.h>
20     
21     #define ELSC_I2C_ADDR		0x08
22     #define ELSC_I2C_HUB0		0x09
23     #define ELSC_I2C_HUB1		0x0a
24     #define ELSC_I2C_HUB2		0x0b
25     #define ELSC_I2C_HUB3		0x0c
26     
27     #define ELSC_PACKET_MAX		96
28     #define ELSC_ACP_MAX		86		/* 84+cr+lf */
29     #define ELSC_LINE_MAX		(ELSC_ACP_MAX - 2)
30     
31     /*
32      * ELSC character queue type for I/O
33      */
34     
35     #define ELSC_QSIZE	128		/* Power of 2 is more efficient */
36     
37     typedef sc_cq_t elsc_cq_t;
38     
39     /*
40      * ELSC structure passed around as handle
41      */
42     
43     typedef l1sc_t elsc_t;
44     
45     void	elsc_init(elsc_t *e, nasid_t nasid);
46     
47     int	elsc_process(elsc_t *e);
48     int	elsc_msg_check(elsc_t *e, char *msg, int msg_max);
49     int	elsc_msg_callback(elsc_t *e,
50     			  void (*callback)(void *callback_data, char *msg),
51     			  void *callback_data);
52     #ifdef LATER
53     char   *elsc_errmsg(int code);
54     
55     int	elsc_nvram_write(elsc_t *e, int addr, char *buf, int len);
56     int	elsc_nvram_read(elsc_t *e, int addr, char *buf, int len);
57     int	elsc_nvram_magic(elsc_t *e);
58     #endif
59     
60     int	elsc_command(elsc_t *e, int only_if_message);
61     int	elsc_parse(elsc_t *e, char *p1, char *p2, char *p3);
62     int	elsc_ust_write(elsc_t *e, uchar_t c);
63     int 	elsc_ust_read(elsc_t *e, char *c);
64     
65     
66     
67     /*
68      * System controller commands
69      */
70     
71     int	elsc_version(elsc_t *e, char *result);
72     #ifdef LATER
73     int	elsc_debug_set(elsc_t *e, u_char byte1, u_char byte2);
74     int	elsc_debug_get(elsc_t *e, u_char *byte1, u_char *byte2);
75     #endif
76     int	elsc_module_set(elsc_t *e, int module);
77     int	elsc_module_get(elsc_t *e);
78     int	elsc_partition_set(elsc_t *e, int partition);
79     int	elsc_partition_get(elsc_t *e);
80     int	elsc_domain_set(elsc_t *e, int domain);
81     int	elsc_domain_get(elsc_t *e);
82     int	elsc_cluster_set(elsc_t *e, int cluster);
83     int	elsc_cluster_get(elsc_t *e);
84     int	elsc_cell_set(elsc_t *e, int cell);
85     int	elsc_cell_get(elsc_t *e);
86     int	elsc_bist_set(elsc_t *e, char bist_status);
87     char	elsc_bist_get(elsc_t *e);
88     int	elsc_lock(elsc_t *e,
89     		  int retry_interval_usec,
90     		  int timeout_usec, u_char lock_val);
91     int	elsc_unlock(elsc_t *e);
92     int	elsc_display_char(elsc_t *e, int led, int chr);
93     int	elsc_display_digit(elsc_t *e, int led, int num, int l_case);
94     #ifdef LATER
95     int	elsc_display_mesg(elsc_t *e, char *chr);	/* 8-char input */
96     int	elsc_password_set(elsc_t *e, char *password);	/* 4-char input */
97     int	elsc_password_get(elsc_t *e, char *password);	/* 4-char output */
98     int	elsc_rpwr_query(elsc_t *e, int is_master);
99     int	elsc_power_query(elsc_t *e);
100     int	elsc_power_down(elsc_t *e, int sec);
101     int	elsc_power_cycle(elsc_t *e);
102     int	elsc_system_reset(elsc_t *e);
103     int	elsc_dip_switches(elsc_t *e);
104     int	elsc_nic_get(elsc_t *e, uint64_t *nic, int verbose);
105     #endif
106     
107     int	_elsc_hbt(elsc_t *e, int ival, int rdly);
108     
109     #define	elsc_hbt_enable(e, ival, rdly)	_elsc_hbt(e, ival, rdly)
110     #define	elsc_hbt_disable(e)		_elsc_hbt(e, 0, 0)
111     #define	elsc_hbt_send(e)		_elsc_hbt(e, 0, 1)
112     
113     /*
114      * Routines for using the ELSC as a UART.  There's a version of each
115      * routine that takes a pointer to an elsc_t, and another version that
116      * gets the pointer by calling a user-supplied global routine "get_elsc".
117      * The latter version is useful when the elsc is employed for stdio.
118      */
119     
120     #define ELSCUART_FLASH		0x3c			/* LED pattern */
121     
122     elsc_t	       *get_elsc(void);
123     
124     int	elscuart_probe(void);
125     void	elscuart_init(void *);
126     int	elscuart_poll(void);
127     int	elscuart_readc(void);
128     int	elscuart_getc(void);
129     int	elscuart_putc(int);
130     int	elscuart_puts(char *);
131     char   *elscuart_gets(char *, int);
132     int	elscuart_flush(void);
133     
134     
135     
136     /*
137      * Error codes
138      *
139      *   The possible ELSC error codes are a superset of the I2C error codes,
140      *   so ELSC error codes begin at -100.
141      */
142     
143     #define ELSC_ERROR_NONE			0
144     
145     #define ELSC_ERROR_CMD_SEND	       -100	/* Error sending command    */
146     #define ELSC_ERROR_CMD_CHECKSUM	       -101	/* Command checksum bad     */
147     #define ELSC_ERROR_CMD_UNKNOWN	       -102	/* Unknown command          */
148     #define ELSC_ERROR_CMD_ARGS	       -103	/* Invalid argument(s)      */
149     #define ELSC_ERROR_CMD_PERM	       -104	/* Permission denied	    */
150     #define ELSC_ERROR_CMD_STATE	       -105	/* not allowed in this state*/
151     
152     #define ELSC_ERROR_RESP_TIMEOUT	       -110	/* ELSC response timeout    */
153     #define ELSC_ERROR_RESP_CHECKSUM       -111	/* Response checksum bad    */
154     #define ELSC_ERROR_RESP_FORMAT	       -112	/* Response format error    */
155     #define ELSC_ERROR_RESP_DIR	       -113	/* Response direction error */
156     
157     #define ELSC_ERROR_MSG_LOST	       -120	/* Queue full; msg. lost    */
158     #define ELSC_ERROR_LOCK_TIMEOUT	       -121	/* ELSC response timeout    */
159     #define ELSC_ERROR_DATA_SEND	       -122	/* Error sending data       */
160     #define ELSC_ERROR_NIC		       -123	/* NIC processing error     */
161     #define ELSC_ERROR_NVMAGIC	       -124	/* Bad magic no. in NVRAM   */
162     #define ELSC_ERROR_MODULE	       -125	/* Moduleid processing err  */
163     
164     #endif /* _ASM_SN_KSYS_ELSC_H */
165