1295626Sandrew/*-
2295626Sandrew * Copyright (C) 2008 MARVELL INTERNATIONAL LTD.
3295626Sandrew * All rights reserved.
4295626Sandrew *
5295626Sandrew * Developed by Semihalf.
6295626Sandrew *
7295626Sandrew * Redistribution and use in source and binary forms, with or without
8295626Sandrew * modification, are permitted provided that the following conditions
9295626Sandrew * are met:
10295626Sandrew * 1. Redistributions of source code must retain the above copyright
11295626Sandrew *    notice, this list of conditions and the following disclaimer.
12295626Sandrew * 2. Redistributions in binary form must reproduce the above copyright
13295626Sandrew *    notice, this list of conditions and the following disclaimer in the
14295626Sandrew *    documentation and/or other materials provided with the distribution.
15295626Sandrew * 3. Neither the name of MARVELL nor the names of contributors
16295626Sandrew *    may be used to endorse or promote products derived from this software
17295626Sandrew *    without specific prior written permission.
18295626Sandrew *
19295626Sandrew * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20295626Sandrew * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21295626Sandrew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22295626Sandrew * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
23295626Sandrew * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24295626Sandrew * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25295626Sandrew * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26295626Sandrew * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27295626Sandrew * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28295626Sandrew * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29295626Sandrew * SUCH DAMAGE.
30295626Sandrew *
31295626Sandrew * $FreeBSD$
32295626Sandrew */
33295626Sandrew
34295626Sandrew#ifndef _TWSI_H_
35295626Sandrew#define	_TWSI_H_
36295626Sandrew
37295626Sandrewstruct twsi_baud_rate {
38295626Sandrew	uint32_t	raw;
39295626Sandrew	int		param;
40295626Sandrew	int		m;
41295626Sandrew	int		n;
42295626Sandrew};
43295626Sandrew
44295626Sandrewstruct twsi_softc {
45295626Sandrew	device_t	dev;
46295626Sandrew	struct resource	*res[1];	/* SYS_RES_MEMORY */
47295626Sandrew	struct mtx	mutex;
48295626Sandrew	device_t	iicbus;
49295626Sandrew
50295626Sandrew	bus_size_t	reg_data;
51295626Sandrew	bus_size_t	reg_slave_addr;
52295626Sandrew	bus_size_t	reg_slave_ext_addr;
53295626Sandrew	bus_size_t	reg_control;
54295626Sandrew	bus_size_t	reg_status;
55295626Sandrew	bus_size_t	reg_baud_rate;
56295626Sandrew	bus_size_t	reg_soft_reset;
57295626Sandrew	struct twsi_baud_rate  baud_rate[IIC_FASTEST + 1];
58295626Sandrew};
59295626Sandrew
60295626SandrewDECLARE_CLASS(twsi_driver);
61295626Sandrew
62295626Sandrew#define	TWSI_BAUD_RATE_PARAM(M,N)	((((M) << 3) | ((N) & 0x7)) & 0x7f)
63295626Sandrew
64295626Sandrewint twsi_attach(device_t);
65295626Sandrewint twsi_detach(device_t);
66295626Sandrew
67295626Sandrew#endif /* _TWSI_H_ */
68