1235633Sdim/*-
2218885Sdim * SPDX-License-Identifier: BSD-2-Clause
3218885Sdim *
4218885Sdim * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com>
5218885Sdim * Copyright (c) 2024 Pierre-Luc Drouin <pldrouin@pldrouin.net>
6218885Sdim *
7218885Sdim * Redistribution and use in source and binary forms, with or without
8218885Sdim * modification, are permitted provided that the following conditions
9218885Sdim * are met:
10218885Sdim * 1. Redistributions of source code must retain the above copyright
11218885Sdim *    notice, this list of conditions and the following disclaimer.
12218885Sdim * 2. Redistributions in binary form must reproduce the above copyright
13218885Sdim *    notice, this list of conditions and the following disclaimer in the
14218885Sdim *    documentation and/or other materials provided with the distribution.
15252723Sdim *
16235633Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17218885Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18218885Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19245431Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20218885Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21218885Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22218885Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23218885Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24218885Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25252723Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26252723Sdim * SUCH DAMAGE.
27252723Sdim */
28218885Sdim
29218885Sdim/*
30218885Sdim * Vybrid Family Inter-Integrated Circuit (I2C)
31218885Sdim * Originally based on Chapter 48, Vybrid Reference Manual, Rev. 5, 07/2013
32218885Sdim * Currently based on Chapter 21, LX2160A Reference Manual, Rev. 1, 10/2021
33218885Sdim *
34218885Sdim * The current implementation is based on the original driver by Ruslan Bukin,
35218885Sdim * later modified by Dawid G��recki, and split into FDT and ACPI drivers by Val
36218885Sdim * Packett.
37218885Sdim */
38218885Sdim
39218885Sdim#ifndef __VF_I2C_H__
40218885Sdim#define __VF_I2C_H__
41218885Sdim
42218885Sdim#include "opt_acpi.h"
43218885Sdim#include "opt_platform.h"
44218885Sdim
45218885Sdim#ifdef FDT
46218885Sdim#include <dev/clk/clk.h>
47218885Sdim#endif
48218885Sdim
49218885Sdim#define VF_I2C_DEVSTR "Vybrid Family Inter-Integrated Circuit (I2C)"
50218885Sdim
51218885Sdim#define HW_MVF600       0x01
52218885Sdim#define HW_VF610        0x02
53218885Sdim
54218885Sdim#define MVF600_DIV_REG	0x14
55218885Sdim
56218885Sdim#define VF_I2C_DEFAULT_BUS_SPEED	100000
57218885Sdim
58218885Sdimstruct vf_i2c_softc {
59218885Sdim	struct resource         *res[2];
60218885Sdim	bus_space_tag_t         bst;
61218885Sdim	bus_space_handle_t      bsh;
62218885Sdim	uint32_t                freq;
63218885Sdim	device_t                dev;
64218885Sdim	device_t                iicbus;
65218885Sdim	struct mtx              mutex;
66218885Sdim	uintptr_t               hwtype;
67218885Sdim#ifdef FDT
68218885Sdim	clk_t                   clock;
69218885Sdim#endif
70218885Sdim};
71218885Sdim
72218885Sdimextern driver_t vf_i2c_driver;
73218885Sdim
74218885Sdimdevice_attach_t vf_i2c_attach_common;
75218885Sdim
76218885Sdim#endif /* !__VF_I2C_H__ */
77218885Sdim