cudavar.h revision 184299
1/*-
2 * Copyright (c) 2006 Michael Lorenz
3 * Copyright (c) 2008 Nathan Whitehorn
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of The NetBSD Foundation nor the names of its
15 *    contributors may be used to endorse or promote products derived
16 *    from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $FreeBSD: head/sys/powerpc/powermac/cudavar.h 184299 2008-10-26 19:37:38Z nwhitehorn $
31 *
32 */
33
34#ifndef	_POWERPC_CUDAVAR_H_
35#define	_POWERPC_CUDAVAR_H_
36
37#define CUDA_DEVSTR	"Apple CUDA I/O Controller"
38
39/* Cuda addresses */
40#define CUDA_ADB	0
41#define CUDA_PSEUDO	1
42#define CUDA_ERROR	2	/* error codes? */
43#define CUDA_TIMER	3
44#define CUDA_POWER	4
45#define CUDA_IIC	5	/* XXX ??? */
46#define CUDA_PMU	6
47#define CUDA_ADB_QUERY	7
48
49/* Cuda commands */
50#define CMD_AUTOPOLL	1
51#define CMD_READ_RTC	3
52#define CMD_WRITE_RTC	9
53#define CMD_POWEROFF	10
54#define CMD_RESET	17
55#define CMD_IIC		34
56
57/* Cuda state codes */
58#define CUDA_NOTREADY	0x1	/* has not been initialized yet */
59#define CUDA_IDLE	0x2	/* the bus is currently idle */
60#define CUDA_OUT	0x3	/* sending out a command */
61#define CUDA_IN		0x4	/* receiving data */
62#define CUDA_POLLING	0x5	/* polling - II only */
63
64struct cuda_softc {
65	device_t	sc_dev;
66	int		sc_memrid;
67	struct resource	*sc_memr;
68	int     	sc_irqrid;
69        struct resource *sc_irq;
70        void    	*sc_ih;
71
72	struct mtx	sc_mutex;
73
74	device_t	adb_bus;
75
76	int sc_node;
77	volatile int sc_state;
78	int sc_waiting;
79	int sc_polling;
80	int sc_sent;
81	int sc_out_length;
82	int sc_received;
83	int sc_iic_done;
84	int sc_error;
85	volatile int sc_autopoll;
86
87	int sc_i2c_read_len;
88
89	/* internal buffers */
90	uint8_t sc_in[256];
91	uint8_t sc_out[256];
92};
93
94#endif /* _POWERPC_CUDAVAR_H_ */
95