1255365Sdes/*	$NetBSD: stivar.h,v 1.11 2020/12/23 08:34:35 tsutsui Exp $	*/
2255365Sdes
3255365Sdes/*	$OpenBSD: stivar.h,v 1.24 2009/02/06 22:51:04 miod Exp $	*/
4255365Sdes
5255365Sdes/*
6255365Sdes * Copyright (c) 2000-2003 Michael Shalayeff
7255365Sdes * All rights reserved.
8255365Sdes *
9255365Sdes * Redistribution and use in source and binary forms, with or without
10255365Sdes * modification, are permitted provided that the following conditions
11255365Sdes * are met:
12255365Sdes * 1. Redistributions of source code must retain the above copyright
13255365Sdes *    notice, this list of conditions and the following disclaimer.
14255365Sdes * 2. Redistributions in binary form must reproduce the above copyright
15255365Sdes *    notice, this list of conditions and the following disclaimer in the
16255365Sdes *    documentation and/or other materials provided with the distribution.
17255365Sdes *
18255365Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19255365Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20255365Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21255365Sdes * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22255365Sdes * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23255365Sdes * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24255365Sdes * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25255365Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26255365Sdes * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27255365Sdes * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28255365Sdes * THE POSSIBILITY OF SUCH DAMAGE.
29255365Sdes */
30255365Sdes
31255365Sdes#ifndef _IC_STIVAR_H_
32255365Sdes#define _IC_STIVAR_H_
33255365Sdes
34255365Sdesstruct sti_softc;
35255365Sdes
36255365Sdes/*
37255365Sdes * STI ROM information - one per device
38255365Sdes */
39255365Sdesstruct sti_rom {
40255365Sdes	struct sti_softc	*rom_softc;	/* backpointer to device */
41255365Sdes	int			 rom_devtype;
42255365Sdes
43255365Sdes	bus_space_tag_t		 iot, memt;	/* XXX iot unused */
44255365Sdes	bus_space_handle_t	 romh;
45255365Sdes	bus_space_handle_t	 regh[STI_REGION_MAX];
46255365Sdes	bus_addr_t		*bases;
47255365Sdes
48255365Sdes	struct sti_dd		 rom_dd;	/* in word format */
49255365Sdes	vaddr_t			 rom_code;
50255365Sdes
51255365Sdes	/*
52255365Sdes	 * ROM-provided function pointers
53255365Sdes	 */
54255365Sdes	sti_init_t		 init;
55255365Sdes	sti_mgmt_t		 mgmt;
56255365Sdes	sti_unpmv_t		 unpmv;
57255365Sdes	sti_blkmv_t		 blkmv;
58	sti_test_t		 test;
59	sti_exhdl_t		 exhdl;
60	sti_inqconf_t		 inqconf;
61	sti_scment_t		 scment;
62	sti_dmac_t		 dmac;
63	sti_flowc_t		 flowc;
64	sti_utiming_t		 utiming;
65	sti_pmgr_t		 pmgr;
66	sti_util_t		 util;
67};
68
69/*
70 * STI screen information - one per head
71 */
72struct sti_screen {
73	struct sti_rom		*scr_rom;
74
75#ifdef notyet
76	u_int			 scr_flags;
77#endif
78
79	int			 scr_bpp;
80
81	struct sti_font		 scr_curfont;
82	struct sti_cfg		 scr_cfg;
83	struct sti_ecfg		 scr_ecfg;
84	char			 name[STI_DEVNAME_LEN];
85
86	void			*scr_romfont;	/* ROM font copy in memory... */
87	u_int			 scr_fontmaxcol;/* ...or in off-screen area */
88	u_int			 scr_fontbase;
89
90	uint8_t			 scr_rcmap[STI_NCMAP],
91				 scr_gcmap[STI_NCMAP],
92				 scr_bcmap[STI_NCMAP];
93
94	uint16_t		 fbheight, fbwidth;
95	uint16_t		 oheight, owidth;	/* offscreen size */
96	bus_addr_t		 fbaddr;
97	bus_size_t		 fblen;
98
99	/* wsdisplay information */
100	int			 scr_nscreens;
101	u_int			 scr_wsmode;
102	struct	wsscreen_descr	 scr_wsd;
103	const struct wsscreen_descr	*scr_scrlist[1];
104	struct	wsscreen_list	 scr_screenlist;
105
106	/*
107	 * Board-specific function data and pointers
108	 */
109	void			(*setupfb)(struct sti_screen *);
110	int			(*putcmap)(struct sti_screen *, u_int, u_int);
111
112	uint32_t		reg10_value;
113	uint32_t		reg12_value;
114	bus_addr_t		cmap_finish_register;
115};
116
117/*
118 * STI device state
119 */
120struct sti_softc {
121	device_t sc_dev;
122#if notyet
123	void *sc_ih;
124#endif
125
126	u_int			sc_flags;
127#define	STI_CONSOLE	0x0001	/* first head is console... */
128#define	STI_ATTACHED	0x0002	/* ... and wsdisplay_cnattach() has been done */
129#define	STI_ROM_ENABLED	0x0004	/* PCI ROM is enabled */
130
131	bus_addr_t		bases[STI_REGION_MAX];
132	struct sti_rom		*sc_rom;
133	struct sti_screen	*sc_scr;
134
135	/* optional, required for PCI */
136	void			(*sc_enable_rom)(struct sti_softc *);
137	void			(*sc_disable_rom)(struct sti_softc *);
138};
139
140int	sti_attach_common(struct sti_softc *, bus_space_tag_t, bus_space_tag_t,
141	    bus_space_handle_t, u_int);
142int	sti_cnattach(struct sti_rom *, struct sti_screen *, bus_space_tag_t,
143	    bus_addr_t *, u_int);
144void	sti_describe(struct sti_softc *);
145void	sti_end_attach(struct sti_softc *);
146u_int	sti_rom_size(bus_space_tag_t, bus_space_handle_t);
147
148int	sti_init(struct sti_screen *, int);
149#define	STI_TEXTMODE	0x01
150#define	STI_CLEARSCR	0x02
151#define	STI_FBMODE	0x04
152int	sti_ioctl(void *, void *, u_long, void *, int, struct lwp *);
153paddr_t	sti_mmap(void *, void *, off_t, int);
154int	sti_alloc_screen(void *, const struct wsscreen_descr *,
155	    void **, int *, int *, long *);
156void	sti_free_screen(void *, void *);
157int	sti_show_screen(void *, void *, int, void (*cb)(void *, int, int),
158	    void *);
159int	sti_load_font(void *, void *, struct wsdisplay_font *);
160
161int	sti_cnattach(struct sti_rom *, struct sti_screen *, bus_space_tag_t,
162	    bus_addr_t *, u_int);
163
164#endif /* _IC_STIVAR_H_ */
165