1/* $NetBSD: coramvar.h,v 1.3 2011/08/06 19:21:27 jmcneill Exp $ */
2
3/*
4 * Copyright (c) 2008, 2011 Jonathan A. Kollasch
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 COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _DEV_PCI_CORAMVAR_H
30#define _DEV_PCI_CORAMVAR_H
31
32#include <sys/bus.h>
33#include <sys/mutex.h>
34#include <dev/pci/pcivar.h>
35#include <dev/pci/pcireg.h>
36#include <dev/i2c/i2cvar.h>
37
38#define KERNADDR(p)	((void *)((p)->addr))
39#define DMAADDR(p)	((p)->map->dm_segs[0].ds_addr)
40
41struct coram_board {
42	uint16_t vendor;
43	uint16_t product;
44	const char *name;
45};
46
47struct coram_sram_ch {
48	uint32_t	csc_cmds;
49	uint32_t	csc_iq;
50	uint32_t	csc_iqsz;
51	uint32_t	csc_cdt;
52	uint32_t	csc_cdtsz;
53	uint32_t	csc_fifo;
54	uint32_t	csc_fifosz;
55	uint32_t	csc_risc;
56	uint32_t	csc_riscsz;
57	uint32_t	csc_ptr1;
58	uint32_t	csc_ptr2;
59	uint32_t	csc_cnt1;
60	uint32_t	csc_cnt2;
61};
62
63struct coram_dma {
64	bus_dmamap_t		map;
65	void *			addr;
66	bus_dma_segment_t	segs[1];
67	int			nsegs;
68	size_t			size;
69	struct coram_dma *	next;
70};
71
72struct coram_softc {
73	device_t		sc_dev;
74	device_t		sc_dtvdev;
75
76	bus_space_tag_t		sc_memt;
77	bus_space_handle_t	sc_memh;
78	bus_size_t		sc_mems;
79	bus_dma_tag_t		sc_dmat;
80
81	pci_chipset_tag_t	sc_pc;
82	void *			sc_ih;
83
84	struct coram_iic_softc {
85		struct coram_softc *	cic_sc;
86		bus_space_handle_t	cic_regh;
87		struct i2c_controller	cic_i2c;
88		kmutex_t		cic_busmutex;
89		device_t		cic_i2cdev;
90	} sc_iic[3];
91
92	struct coram_sram_ch	sc_vidc_sch;
93
94	struct coram_dma *	sc_dma;
95	struct coram_dma *	sc_tsbuf;
96
97	uint32_t *		sc_riscbuf;
98	uint32_t		sc_riscbufsz;
99
100	void			*sc_tuner;
101	void			*sc_demod;
102
103	void			(*sc_dtvsubmitcb)(void *,
104				    const struct dtv_payload *);
105	void			*sc_dtvsubmitarg;
106
107	const struct coram_board *sc_board;
108};
109
110#endif /* !_DEV_PCI_CORAMVAR_H */
111