xref: /openbsd/sys/dev/ic/stivar.h (revision e5dd7070)
1 /*	$OpenBSD: stivar.h,v 1.25 2015/04/05 23:25:57 miod Exp $	*/
2 
3 /*
4  * Copyright (c) 2000-2003 Michael Shalayeff
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26  * THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _IC_STIVAR_H_
30 #define _IC_STIVAR_H_
31 
32 struct sti_softc;
33 struct sti_screen;
34 
35 /*
36  * STI ROM information - one per device
37  */
38 struct sti_rom {
39 	struct sti_softc	*rom_softc;	/* backpointer to device */
40 	int			 rom_devtype;
41 
42 	bus_space_tag_t		 iot, memt;	/* XXX iot unused */
43 	bus_space_handle_t	 romh;
44 	bus_space_handle_t	 regh[STI_REGION_MAX];
45 	bus_addr_t		*bases;
46 
47 	struct sti_dd		 rom_dd;	/* in word format */
48 	vaddr_t			 rom_code;
49 
50 	/*
51 	 * ROM-provided function pointers
52 	 */
53 	sti_init_t		 init;
54 	sti_mgmt_t		 mgmt;
55 	sti_unpmv_t		 unpmv;
56 	sti_blkmv_t		 blkmv;
57 	sti_test_t		 test;
58 	sti_exhdl_t		 exhdl;
59 	sti_inqconf_t		 inqconf;
60 	sti_scment_t		 scment;
61 	sti_dmac_t		 dmac;
62 	sti_flowc_t		 flowc;
63 	sti_utiming_t		 utiming;
64 	sti_pmgr_t		 pmgr;
65 	sti_util_t		 util;
66 };
67 
68 /*
69  * STI screen information - one per head
70  */
71 struct sti_screen {
72 	struct sti_rom		*scr_rom;
73 
74 #ifdef notyet
75 	u_int			 scr_flags;
76 #endif
77 
78 	int			 scr_bpp;
79 
80 	struct sti_font		 scr_curfont;
81 	struct sti_cfg		 scr_cfg;
82 	struct sti_ecfg		 scr_ecfg;
83 	u_int8_t		 name[STI_DEVNAME_LEN];
84 
85 	void			*scr_romfont;	/* ROM font copy in memory... */
86 	u_int			 scr_fontmaxcol;/* ...or in off-screen area */
87 	u_int			 scr_fontbase;
88 
89 	u_int8_t		 scr_rcmap[STI_NCMAP],
90 				 scr_gcmap[STI_NCMAP],
91 				 scr_bcmap[STI_NCMAP];
92 
93 	u_int16_t		 fbheight, fbwidth;
94 	u_int16_t		 oheight, owidth;	/* offscreen size */
95 	bus_addr_t		 fbaddr;
96 	bus_size_t		 fblen;
97 
98 	/* wsdisplay information */
99 	int			 scr_nscreens;
100 	u_int			 scr_wsmode;
101 	struct	wsscreen_descr	 scr_wsd;
102 	struct	wsscreen_descr	*scr_scrlist[1];
103 	struct	wsscreen_list	 scr_screenlist;
104 
105 	/*
106 	 * Board-specific function data and pointers
107 	 */
108 	void			(*setupfb)(struct sti_screen *);
109 	int			(*putcmap)(struct sti_screen *, u_int, u_int);
110 
111 	uint32_t		reg10_value;
112 	uint32_t		reg12_value;
113 	bus_addr_t		cmap_finish_register;
114 };
115 
116 /*
117  * STI device state
118  */
119 struct sti_softc {
120 	struct device		 sc_dev;
121 #ifdef notyet
122 	void			*sc_ih;
123 #endif
124 
125 	u_int			 sc_flags;
126 #define	STI_CONSOLE	0x0001	/* first head is console... */
127 #define	STI_ATTACHED	0x0002	/* ... and wsdisplay_cnattach() has been done */
128 #define	STI_ROM_ENABLED	0x0004	/* PCI ROM is enabled */
129 
130 	bus_addr_t		 bases[STI_REGION_MAX];
131 	struct sti_rom		*sc_rom;
132 	struct sti_screen	*sc_scr;
133 
134 	/* optional, required for PCI */
135 	void			(*sc_enable_rom)(struct sti_softc *);
136 	void			(*sc_disable_rom)(struct sti_softc *);
137 };
138 
139 int	sti_attach_common(struct sti_softc *, bus_space_tag_t, bus_space_tag_t,
140 	    bus_space_handle_t, u_int);
141 int	sti_cnattach(struct sti_rom *, struct sti_screen *, bus_space_tag_t,
142 	    bus_addr_t *, u_int);
143 void	sti_describe(struct sti_softc *);
144 void	sti_end_attach(void *);
145 u_int	sti_rom_size(bus_space_tag_t, bus_space_handle_t);
146 
147 #endif /* _IC_STIVAR_H_ */
148