meson_pinctrl.h revision 1.3.4.2 1 1.3.4.2 christos /* $NetBSD: meson_pinctrl.h,v 1.3.4.2 2019/06/10 22:05:51 christos Exp $ */
2 1.3.4.2 christos
3 1.3.4.2 christos /*-
4 1.3.4.2 christos * Copyright (c) 2019 Jared McNeill <jmcneill (at) invisible.ca>
5 1.3.4.2 christos * All rights reserved.
6 1.3.4.2 christos *
7 1.3.4.2 christos * Redistribution and use in source and binary forms, with or without
8 1.3.4.2 christos * modification, are permitted provided that the following conditions
9 1.3.4.2 christos * are met:
10 1.3.4.2 christos * 1. Redistributions of source code must retain the above copyright
11 1.3.4.2 christos * notice, this list of conditions and the following disclaimer.
12 1.3.4.2 christos * 2. Redistributions in binary form must reproduce the above copyright
13 1.3.4.2 christos * notice, this list of conditions and the following disclaimer in the
14 1.3.4.2 christos * documentation and/or other materials provided with the distribution.
15 1.3.4.2 christos *
16 1.3.4.2 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.3.4.2 christos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.3.4.2 christos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.3.4.2 christos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.3.4.2 christos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.3.4.2 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.3.4.2 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.3.4.2 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.3.4.2 christos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.3.4.2 christos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.3.4.2 christos * SUCH DAMAGE.
27 1.3.4.2 christos */
28 1.3.4.2 christos
29 1.3.4.2 christos #ifndef _MESON_PINCTRL_H
30 1.3.4.2 christos #define _MESON_PINCTRL_H
31 1.3.4.2 christos
32 1.3.4.2 christos #include "opt_soc.h"
33 1.3.4.2 christos
34 1.3.4.2 christos #include <sys/bus.h>
35 1.3.4.2 christos
36 1.3.4.2 christos #define MESON_PINCTRL_MAXBANK 8
37 1.3.4.2 christos
38 1.3.4.2 christos enum meson_pinctrl_regtype {
39 1.3.4.2 christos MESON_PINCTRL_REGTYPE_PULL,
40 1.3.4.2 christos MESON_PINCTRL_REGTYPE_PULL_ENABLE,
41 1.3.4.2 christos MESON_PINCTRL_REGTYPE_GPIO,
42 1.3.4.2 christos };
43 1.3.4.2 christos
44 1.3.4.2 christos struct meson_pinctrl_gpioreg {
45 1.3.4.2 christos enum meson_pinctrl_regtype type;
46 1.3.4.2 christos bus_size_t reg;
47 1.3.4.2 christos uint32_t mask;
48 1.3.4.2 christos };
49 1.3.4.2 christos
50 1.3.4.2 christos struct meson_pinctrl_gpio {
51 1.3.4.2 christos u_int id;
52 1.3.4.2 christos const char *name;
53 1.3.4.2 christos struct meson_pinctrl_gpioreg oen;
54 1.3.4.2 christos struct meson_pinctrl_gpioreg out;
55 1.3.4.2 christos struct meson_pinctrl_gpioreg in;
56 1.3.4.2 christos struct meson_pinctrl_gpioreg pupden;
57 1.3.4.2 christos struct meson_pinctrl_gpioreg pupd;
58 1.3.4.2 christos };
59 1.3.4.2 christos
60 1.3.4.2 christos struct meson_pinctrl_group {
61 1.3.4.2 christos const char *name;
62 1.3.4.2 christos bus_size_t reg;
63 1.3.4.2 christos u_int bit;
64 1.3.4.2 christos u_int bank[MESON_PINCTRL_MAXBANK];
65 1.3.4.2 christos u_int nbank;
66 1.3.4.2 christos };
67 1.3.4.2 christos
68 1.3.4.2 christos struct meson_pinctrl_config {
69 1.3.4.2 christos const char *name;
70 1.3.4.2 christos const struct meson_pinctrl_group *groups;
71 1.3.4.2 christos u_int ngroups;
72 1.3.4.2 christos const struct meson_pinctrl_gpio *gpios;
73 1.3.4.2 christos u_int ngpios;
74 1.3.4.2 christos };
75 1.3.4.2 christos
76 1.3.4.2 christos #ifdef SOC_MESON8B
77 1.3.4.2 christos extern const struct meson_pinctrl_config meson8b_aobus_pinctrl_config;
78 1.3.4.2 christos extern const struct meson_pinctrl_config meson8b_cbus_pinctrl_config;
79 1.3.4.2 christos #endif
80 1.3.4.2 christos
81 1.3.4.2 christos #ifdef SOC_MESONGXBB
82 1.3.4.2 christos extern const struct meson_pinctrl_config mesongxbb_aobus_pinctrl_config;
83 1.3.4.2 christos extern const struct meson_pinctrl_config mesongxbb_periphs_pinctrl_config;
84 1.3.4.2 christos #endif
85 1.3.4.2 christos
86 1.3.4.2 christos #ifdef SOC_MESONGXL
87 1.3.4.2 christos extern const struct meson_pinctrl_config mesongxl_aobus_pinctrl_config;
88 1.3.4.2 christos extern const struct meson_pinctrl_config mesongxl_periphs_pinctrl_config;
89 1.3.4.2 christos #endif
90 1.3.4.2 christos
91 1.3.4.2 christos #endif /* !_MESON_PINCTRL_H */
92