Home | History | Annotate | Line # | Download | only in fdt
      1  1.86   thorpej /* $NetBSD: fdtvar.h,v 1.86 2025/09/08 13:06:16 thorpej Exp $ */
      2   1.1  jmcneill 
      3   1.1  jmcneill /*-
      4   1.1  jmcneill  * Copyright (c) 2015 Jared D. McNeill <jmcneill (at) invisible.ca>
      5   1.1  jmcneill  * All rights reserved.
      6   1.1  jmcneill  *
      7   1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
      8   1.1  jmcneill  * modification, are permitted provided that the following conditions
      9   1.1  jmcneill  * are met:
     10   1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     11   1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     12   1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     14   1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     15   1.1  jmcneill  *
     16   1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17   1.1  jmcneill  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18   1.1  jmcneill  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19   1.1  jmcneill  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20   1.1  jmcneill  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21   1.1  jmcneill  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22   1.1  jmcneill  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23   1.1  jmcneill  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24   1.1  jmcneill  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25   1.1  jmcneill  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26   1.1  jmcneill  * SUCH DAMAGE.
     27   1.1  jmcneill  */
     28   1.1  jmcneill 
     29  1.62     skrll #ifndef _DEV_FDT_FDTVAR_H_
     30  1.62     skrll #define _DEV_FDT_FDTVAR_H_
     31   1.1  jmcneill 
     32   1.1  jmcneill #include <sys/types.h>
     33   1.1  jmcneill #include <sys/bus.h>
     34   1.1  jmcneill 
     35  1.11  jmcneill #include <dev/clock_subr.h>
     36  1.11  jmcneill 
     37   1.1  jmcneill #include <dev/ofw/openfirm.h>
     38   1.1  jmcneill 
     39  1.81   thorpej #include <dev/fdt/fdt_clock.h>
     40  1.81   thorpej #include <dev/fdt/fdt_dai.h>
     41  1.81   thorpej #include <dev/fdt/fdt_dma.h>
     42  1.81   thorpej #include <dev/fdt/fdt_gpio.h>
     43  1.81   thorpej #include <dev/fdt/fdt_i2c.h>
     44  1.81   thorpej #include <dev/fdt/fdt_intr.h>
     45  1.81   thorpej #include <dev/fdt/fdt_iommu.h>
     46  1.81   thorpej #include <dev/fdt/fdt_mbox.h>
     47  1.81   thorpej #include <dev/fdt/fdt_mmc_pwrseq.h>
     48  1.81   thorpej #include <dev/fdt/fdt_phy.h>
     49  1.81   thorpej #include <dev/fdt/fdt_pinctrl.h>
     50  1.81   thorpej #include <dev/fdt/fdt_power.h>
     51  1.81   thorpej #include <dev/fdt/fdt_powerdomain.h>
     52  1.81   thorpej #include <dev/fdt/fdt_pwm.h>
     53  1.81   thorpej #include <dev/fdt/fdt_regulator.h>
     54  1.81   thorpej #include <dev/fdt/fdt_reset.h>
     55  1.81   thorpej #include <dev/fdt/fdt_spi.h>
     56  1.81   thorpej #include <dev/fdt/fdt_syscon.h>
     57  1.81   thorpej 
     58   1.1  jmcneill struct fdt_attach_args {
     59   1.1  jmcneill 	const char *faa_name;
     60   1.1  jmcneill 	bus_space_tag_t faa_bst;
     61   1.1  jmcneill 	bus_dma_tag_t faa_dmat;
     62   1.1  jmcneill 	int faa_phandle;
     63  1.13  jmcneill 	int faa_quiet;
     64   1.1  jmcneill };
     65   1.1  jmcneill 
     66  1.52   hkenken struct fdt_phandle_data {
     67  1.52   hkenken 	int phandle;
     68  1.52   hkenken 	int count;
     69  1.52   hkenken 	const u_int *values;
     70  1.52   hkenken };
     71  1.52   hkenken 
     72  1.60  jmcneill struct fdt_dma_range {
     73  1.60  jmcneill 	paddr_t		dr_sysbase;
     74  1.60  jmcneill 	bus_addr_t	dr_busbase;
     75  1.60  jmcneill 	bus_size_t	dr_len;
     76  1.60  jmcneill };
     77  1.60  jmcneill 
     78  1.72  jmcneill #define	FDT_BUS_SPACE_FLAG_NONPOSTED_MMIO	__BIT(0)
     79  1.72  jmcneill 
     80  1.28     skrll void		fdtbus_set_decoderegprop(bool);
     81  1.28     skrll 
     82   1.2  jmcneill int		fdtbus_get_reg(int, u_int, bus_addr_t *, bus_size_t *);
     83  1.26  jmcneill int		fdtbus_get_reg_byname(int, const char *, bus_addr_t *,
     84  1.26  jmcneill 		    bus_size_t *);
     85  1.17  jmcneill int		fdtbus_get_reg64(int, u_int, uint64_t *, uint64_t *);
     86  1.60  jmcneill int		fdtbus_get_addr_cells(int);
     87  1.60  jmcneill int		fdtbus_get_size_cells(int);
     88  1.60  jmcneill uint64_t	fdtbus_get_cells(const uint8_t *, int);
     89   1.2  jmcneill int		fdtbus_get_phandle(int, const char *);
     90  1.52   hkenken int		fdtbus_get_phandle_with_data(int, const char *, const char *,
     91  1.52   hkenken 		    int, struct fdt_phandle_data *);
     92   1.3  jmcneill int		fdtbus_get_phandle_from_native(int);
     93  1.74     skrll 
     94  1.58   thorpej bool		fdtbus_init(const void *);
     95   1.2  jmcneill const void *	fdtbus_get_data(void);
     96  1.86   thorpej 
     97   1.2  jmcneill int		fdtbus_phandle2offset(int);
     98   1.2  jmcneill int		fdtbus_offset2phandle(int);
     99   1.8  jmcneill bool		fdtbus_get_path(int, char *, size_t);
    100   1.1  jmcneill 
    101  1.15  jmcneill bool		fdtbus_status_okay(int);
    102  1.15  jmcneill 
    103  1.23  jmcneill const void *	fdtbus_get_prop(int, const char *, int *);
    104  1.22  jmcneill const char *	fdtbus_get_string(int, const char *);
    105  1.24  jmcneill const char *	fdtbus_get_string_index(int, const char *, u_int);
    106  1.49  jakllsch int		fdtbus_get_index(int, const char *, const char *, u_int *);
    107  1.22  jmcneill 
    108  1.79     skrll void		fdtbus_cpus_md_attach(device_t, device_t, void *);
    109  1.79     skrll 
    110  1.36  jmcneill void		fdt_add_bus(device_t, int, struct fdt_attach_args *);
    111  1.41  jmcneill void		fdt_add_bus_match(device_t, int, struct fdt_attach_args *,
    112  1.74     skrll 		    bool (*)(void *, int), void *);
    113  1.43  jmcneill void		fdt_add_child(device_t, int, struct fdt_attach_args *, u_int);
    114  1.36  jmcneill 
    115  1.29    bouyer void		fdt_remove_byhandle(int);
    116  1.29    bouyer void		fdt_remove_bycompat(const char *[]);
    117  1.45  jmcneill int		fdt_find_with_property(const char *, int *);
    118  1.69   thorpej 
    119  1.16  jmcneill int		fdtbus_print(void *, const char *);
    120  1.16  jmcneill 
    121  1.60  jmcneill bus_dma_tag_t	fdtbus_dma_tag_create(int, const struct fdt_dma_range *,
    122  1.60  jmcneill 		    u_int);
    123  1.72  jmcneill bus_space_tag_t	fdtbus_bus_tag_create(int, uint32_t);
    124  1.60  jmcneill 
    125  1.76     skrll 
    126  1.62     skrll #endif /* _DEV_FDT_FDTVAR_H_ */
    127