xref: /netbsd-src/sys/dev/ic/tms320av110var.h (revision e622eac459adf11c2e710d7a4de0f05510bbbe61)
1 /*	$NetBSD: tms320av110var.h,v 1.13 2019/05/08 13:40:18 isaki Exp $	*/
2 
3 /*-
4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Ignatios Souvatzis.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /*
33  * Machine independent definitions, declarations and data structures for
34  * access to the TMS320AV110 data sheet.
35  *
36  * Currently, only minimum support for audio output. For audio/video
37  * synchronization, more is needed.
38  */
39 
40 #ifndef _TMS320AV110_VAR_H_
41 #define _TMS320AV110_VAR_H_
42 
43 #include <sys/bus.h>
44 
45 /* softc */
46 
47 struct tav_softc {
48 	device_t	sc_dev;
49 	kmutex_t	sc_lock;
50 	kmutex_t	sc_intr_lock;
51 
52 	bus_space_tag_t sc_iot;
53 	bus_space_handle_t sc_ioh;
54 
55 	int		sc_active;
56 
57 	/* above audio callback function */
58 	void		(*sc_intr)(void *);
59 	void		*sc_intrarg;
60 	int		sc_bsize;
61 
62 	/* below audio interrupt acknowledge function. Ignored if NULL */
63 	void		(*sc_intack)(struct tav_softc *);
64 
65 	/* initialization from below */
66 
67 	uint8_t		sc_pcm_div;	/* passed in */
68 	uint8_t		sc_pcm_ord;	/* passed in */
69 	uint8_t		sc_pcm_18;	/* passed in */
70 	uint8_t		sc_dif;	/* passed in */
71 };
72 
73 /* prototypes */
74 
75 void tms320av110_attach_mi(struct tav_softc *);
76 int tms320av110_intr(void *);
77 
78 static void tav_write_short(bus_space_tag_t, bus_space_handle_t,
79     bus_size_t, uint16_t);
80 
81 /* access functions/macros: */
82 /* XXX shouldn't these be in the reg.h file? */
83 
84 #define tav_read_byte(ioh, iot, off) bus_space_read_1(ioh, iot, off)
85 
86 #define tav_read_short(ioh, iot, off)	(		\
87 	bus_space_read_1((ioh), (iot), (off))	|	\
88 	bus_space_read_1((ioh), (iot), (off)+1) << 8)
89 
90 #define tav_read_long(ioh, iot, off)	(		\
91 	bus_space_read_1((ioh), (iot), (off))	|	\
92 	bus_space_read_1((ioh), (iot), (off)+1) << 8 |	\
93 	bus_space_read_1((ioh), (iot), (off)+2) << 16 |	\
94 	bus_space_read_1((ioh), (iot), (off)+3))
95 
96 #define tav_read_time(ioh, iot, off)	(		\
97 	bus_space_read_1((ioh), (iot), (off))	|	\
98 	bus_space_read_1((ioh), (iot), (off)+1) << 8 |	\
99 	bus_space_read_1((ioh), (iot), (off)+2) << 16 |	\
100 	bus_space_read_1((ioh), (iot), (off)+3) << 24 |	\
101 	bus_space_read_1((ioh), (iot), (off)+4) << 32)
102 
103 #define tav_write_byte(ioh, iot, off, v) bus_space_write_1(ioh, iot, off, v)
104 
105 static __inline void
tav_write_short(bus_space_tag_t iot,bus_space_handle_t ioh,bus_size_t off,uint16_t val)106 tav_write_short(bus_space_tag_t iot, bus_space_handle_t ioh,
107     bus_size_t off, uint16_t val)
108 {
109 
110 	bus_space_write_1(iot, ioh, off+1, (val)>>8);
111 	bus_space_write_1(iot, ioh, off,  (uint8_t)val);
112 }
113 
114 #endif /* _TMS320AV110_VAR_H_ */
115