1*8afae5d5Sryo /* $NetBSD: meson_pinctrl.h,v 1.4 2021/01/01 07:21:58 ryo Exp $ */ 2912cfa14Sjmcneill 3912cfa14Sjmcneill /*- 4912cfa14Sjmcneill * Copyright (c) 2019 Jared McNeill <jmcneill@invisible.ca> 5912cfa14Sjmcneill * All rights reserved. 6912cfa14Sjmcneill * 7912cfa14Sjmcneill * Redistribution and use in source and binary forms, with or without 8912cfa14Sjmcneill * modification, are permitted provided that the following conditions 9912cfa14Sjmcneill * are met: 10912cfa14Sjmcneill * 1. Redistributions of source code must retain the above copyright 11912cfa14Sjmcneill * notice, this list of conditions and the following disclaimer. 12912cfa14Sjmcneill * 2. Redistributions in binary form must reproduce the above copyright 13912cfa14Sjmcneill * notice, this list of conditions and the following disclaimer in the 14912cfa14Sjmcneill * documentation and/or other materials provided with the distribution. 15912cfa14Sjmcneill * 16912cfa14Sjmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17912cfa14Sjmcneill * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18912cfa14Sjmcneill * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19912cfa14Sjmcneill * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20912cfa14Sjmcneill * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21912cfa14Sjmcneill * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22912cfa14Sjmcneill * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23912cfa14Sjmcneill * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24912cfa14Sjmcneill * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25912cfa14Sjmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26912cfa14Sjmcneill * SUCH DAMAGE. 27912cfa14Sjmcneill */ 28912cfa14Sjmcneill 29912cfa14Sjmcneill #ifndef _MESON_PINCTRL_H 30912cfa14Sjmcneill #define _MESON_PINCTRL_H 31912cfa14Sjmcneill 32912cfa14Sjmcneill #include "opt_soc.h" 33912cfa14Sjmcneill 34912cfa14Sjmcneill #include <sys/bus.h> 35912cfa14Sjmcneill 36912cfa14Sjmcneill #define MESON_PINCTRL_MAXBANK 8 37912cfa14Sjmcneill 38912cfa14Sjmcneill enum meson_pinctrl_regtype { 39912cfa14Sjmcneill MESON_PINCTRL_REGTYPE_PULL, 40912cfa14Sjmcneill MESON_PINCTRL_REGTYPE_PULL_ENABLE, 41912cfa14Sjmcneill MESON_PINCTRL_REGTYPE_GPIO, 42912cfa14Sjmcneill }; 43912cfa14Sjmcneill 44912cfa14Sjmcneill struct meson_pinctrl_gpioreg { 45912cfa14Sjmcneill enum meson_pinctrl_regtype type; 46912cfa14Sjmcneill bus_size_t reg; 47912cfa14Sjmcneill uint32_t mask; 48912cfa14Sjmcneill }; 49912cfa14Sjmcneill 50912cfa14Sjmcneill struct meson_pinctrl_gpio { 51912cfa14Sjmcneill u_int id; 52912cfa14Sjmcneill const char *name; 53912cfa14Sjmcneill struct meson_pinctrl_gpioreg oen; 54912cfa14Sjmcneill struct meson_pinctrl_gpioreg out; 55912cfa14Sjmcneill struct meson_pinctrl_gpioreg in; 56912cfa14Sjmcneill struct meson_pinctrl_gpioreg pupden; 57912cfa14Sjmcneill struct meson_pinctrl_gpioreg pupd; 58912cfa14Sjmcneill }; 59912cfa14Sjmcneill 60912cfa14Sjmcneill struct meson_pinctrl_group { 61912cfa14Sjmcneill const char *name; 62912cfa14Sjmcneill bus_size_t reg; 63912cfa14Sjmcneill u_int bit; 64912cfa14Sjmcneill u_int bank[MESON_PINCTRL_MAXBANK]; 65912cfa14Sjmcneill u_int nbank; 66*8afae5d5Sryo 67*8afae5d5Sryo /* when (mask != 0), func/mask are used instead of 'u_int bit' */ 68*8afae5d5Sryo uint32_t func; 69*8afae5d5Sryo uint32_t mask; 70*8afae5d5Sryo 71912cfa14Sjmcneill }; 72912cfa14Sjmcneill 73912cfa14Sjmcneill struct meson_pinctrl_config { 74912cfa14Sjmcneill const char *name; 75912cfa14Sjmcneill const struct meson_pinctrl_group *groups; 76912cfa14Sjmcneill u_int ngroups; 77912cfa14Sjmcneill const struct meson_pinctrl_gpio *gpios; 78912cfa14Sjmcneill u_int ngpios; 79912cfa14Sjmcneill }; 80912cfa14Sjmcneill 81912cfa14Sjmcneill #ifdef SOC_MESON8B 82912cfa14Sjmcneill extern const struct meson_pinctrl_config meson8b_aobus_pinctrl_config; 83912cfa14Sjmcneill extern const struct meson_pinctrl_config meson8b_cbus_pinctrl_config; 84912cfa14Sjmcneill #endif 85912cfa14Sjmcneill 867e38c880Sjmcneill #ifdef SOC_MESONGXBB 877e38c880Sjmcneill extern const struct meson_pinctrl_config mesongxbb_aobus_pinctrl_config; 887e38c880Sjmcneill extern const struct meson_pinctrl_config mesongxbb_periphs_pinctrl_config; 897e38c880Sjmcneill #endif 907e38c880Sjmcneill 91229af777Sjmcneill #ifdef SOC_MESONGXL 92229af777Sjmcneill extern const struct meson_pinctrl_config mesongxl_aobus_pinctrl_config; 93229af777Sjmcneill extern const struct meson_pinctrl_config mesongxl_periphs_pinctrl_config; 94229af777Sjmcneill #endif 95229af777Sjmcneill 96*8afae5d5Sryo #ifdef SOC_MESONG12 97*8afae5d5Sryo extern const struct meson_pinctrl_config mesong12a_aobus_pinctrl_config; 98*8afae5d5Sryo extern const struct meson_pinctrl_config mesong12a_periphs_pinctrl_config; 99*8afae5d5Sryo #endif 100*8afae5d5Sryo 101912cfa14Sjmcneill #endif /* !_MESON_PINCTRL_H */ 102