Home | History | Annotate | Line # | Download | only in fdt
fdtvar.h revision 1.7.2.1
      1  1.7.2.1  pgoyette /* $NetBSD: fdtvar.h,v 1.7.2.1 2017/04/26 02:53:11 pgoyette 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.1  jmcneill #ifndef _DEV_FDT_FDTVAR_H
     30      1.1  jmcneill #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.1  jmcneill #include <dev/i2c/i2cvar.h>
     36      1.3  jmcneill #include <dev/clk/clk.h>
     37      1.1  jmcneill 
     38  1.7.2.1  pgoyette #include <dev/clock_subr.h>
     39  1.7.2.1  pgoyette 
     40      1.1  jmcneill #include <dev/ofw/openfirm.h>
     41      1.1  jmcneill 
     42      1.1  jmcneill struct fdt_attach_args {
     43      1.1  jmcneill 	const char *faa_name;
     44      1.1  jmcneill 	bus_space_tag_t faa_bst;
     45      1.1  jmcneill 	bus_space_tag_t faa_a4x_bst;
     46      1.1  jmcneill 	bus_dma_tag_t faa_dmat;
     47      1.1  jmcneill 	int faa_phandle;
     48      1.1  jmcneill };
     49      1.1  jmcneill 
     50      1.1  jmcneill /* flags for fdtbus_intr_establish */
     51      1.1  jmcneill #define FDT_INTR_MPSAFE	__BIT(0)
     52      1.1  jmcneill 
     53      1.1  jmcneill struct fdtbus_interrupt_controller_func {
     54      1.7     marty 	void *	(*establish)(device_t, u_int *, int, int,
     55      1.1  jmcneill 			     int (*)(void *), void *);
     56      1.1  jmcneill 	void	(*disestablish)(device_t, void *);
     57      1.7     marty 	bool	(*intrstr)(device_t, u_int *, char *, size_t);
     58      1.1  jmcneill };
     59      1.1  jmcneill 
     60      1.1  jmcneill struct fdtbus_i2c_controller_func {
     61      1.1  jmcneill 	i2c_tag_t (*get_tag)(device_t);
     62      1.1  jmcneill };
     63      1.1  jmcneill 
     64      1.1  jmcneill struct fdtbus_gpio_controller;
     65      1.1  jmcneill 
     66      1.1  jmcneill struct fdtbus_gpio_pin {
     67      1.1  jmcneill 	struct fdtbus_gpio_controller *gp_gc;
     68      1.1  jmcneill 	void *gp_priv;
     69      1.1  jmcneill };
     70      1.1  jmcneill 
     71      1.1  jmcneill struct fdtbus_gpio_controller_func {
     72      1.1  jmcneill 	void *	(*acquire)(device_t, const void *, size_t, int);
     73      1.1  jmcneill 	void	(*release)(device_t, void *);
     74      1.4  jmcneill 	int	(*read)(device_t, void *, bool);
     75      1.4  jmcneill 	void	(*write)(device_t, void *, int, bool);
     76      1.1  jmcneill };
     77      1.1  jmcneill 
     78      1.5     marty struct fdtbus_pinctrl_controller;
     79      1.5     marty 
     80      1.5     marty struct fdtbus_pinctrl_pin {
     81      1.5     marty 	struct fdtbus_pinctrl_controller *pp_pc;
     82      1.5     marty 	void *pp_priv;
     83      1.5     marty };
     84      1.5     marty 
     85      1.5     marty struct fdtbus_pinctrl_controller_func {
     86      1.6     marty 	int (*set_config)(void *);
     87      1.5     marty };
     88      1.5     marty 
     89      1.1  jmcneill struct fdtbus_regulator_controller;
     90      1.1  jmcneill 
     91      1.1  jmcneill struct fdtbus_regulator {
     92      1.1  jmcneill 	struct fdtbus_regulator_controller *reg_rc;
     93      1.1  jmcneill };
     94      1.1  jmcneill 
     95      1.1  jmcneill struct fdtbus_regulator_controller_func {
     96      1.1  jmcneill 	int	(*acquire)(device_t);
     97      1.1  jmcneill 	void	(*release)(device_t);
     98      1.1  jmcneill 	int	(*enable)(device_t, bool);
     99  1.7.2.1  pgoyette 	int	(*set_voltage)(device_t, u_int, u_int);
    100  1.7.2.1  pgoyette 	int	(*get_voltage)(device_t, u_int *);
    101      1.1  jmcneill };
    102      1.1  jmcneill 
    103      1.3  jmcneill struct fdtbus_clock_controller_func {
    104      1.3  jmcneill 	struct clk *	(*decode)(device_t, const void *, size_t);
    105      1.3  jmcneill };
    106      1.3  jmcneill 
    107      1.3  jmcneill struct fdtbus_reset_controller;
    108      1.3  jmcneill 
    109      1.3  jmcneill struct fdtbus_reset {
    110      1.3  jmcneill 	struct fdtbus_reset_controller *rst_rc;
    111      1.3  jmcneill 	void *rst_priv;
    112      1.3  jmcneill };
    113      1.3  jmcneill 
    114      1.3  jmcneill struct fdtbus_reset_controller_func {
    115      1.3  jmcneill 	void *	(*acquire)(device_t, const void *, size_t);
    116      1.3  jmcneill 	void	(*release)(device_t, void *);
    117      1.3  jmcneill 	int	(*reset_assert)(device_t, void *);
    118      1.3  jmcneill 	int	(*reset_deassert)(device_t, void *);
    119      1.3  jmcneill };
    120      1.3  jmcneill 
    121      1.2  jmcneill int		fdtbus_register_interrupt_controller(device_t, int,
    122      1.2  jmcneill 		    const struct fdtbus_interrupt_controller_func *);
    123      1.2  jmcneill int		fdtbus_register_i2c_controller(device_t, int,
    124      1.2  jmcneill 		    const struct fdtbus_i2c_controller_func *);
    125      1.2  jmcneill int		fdtbus_register_gpio_controller(device_t, int,
    126      1.2  jmcneill 		    const struct fdtbus_gpio_controller_func *);
    127      1.6     marty int		fdtbus_register_pinctrl_config(void *, int,
    128      1.5     marty 		    const struct fdtbus_pinctrl_controller_func *);
    129      1.2  jmcneill int		fdtbus_register_regulator_controller(device_t, int,
    130      1.2  jmcneill 		    const struct fdtbus_regulator_controller_func *);
    131      1.3  jmcneill int		fdtbus_register_clock_controller(device_t, int,
    132      1.3  jmcneill 		    const struct fdtbus_clock_controller_func *);
    133      1.3  jmcneill int		fdtbus_register_reset_controller(device_t, int,
    134      1.3  jmcneill 		    const struct fdtbus_reset_controller_func *);
    135      1.1  jmcneill 
    136      1.2  jmcneill int		fdtbus_get_reg(int, u_int, bus_addr_t *, bus_size_t *);
    137      1.2  jmcneill int		fdtbus_get_phandle(int, const char *);
    138      1.3  jmcneill int		fdtbus_get_phandle_from_native(int);
    139      1.2  jmcneill i2c_tag_t	fdtbus_get_i2c_tag(int);
    140      1.2  jmcneill void *		fdtbus_intr_establish(int, u_int, int, int,
    141      1.2  jmcneill 		    int (*func)(void *), void *arg);
    142      1.2  jmcneill void		fdtbus_intr_disestablish(int, void *);
    143      1.2  jmcneill bool		fdtbus_intr_str(int, u_int, char *, size_t);
    144      1.1  jmcneill struct fdtbus_gpio_pin *fdtbus_gpio_acquire(int, const char *, int);
    145      1.2  jmcneill void		fdtbus_gpio_release(struct fdtbus_gpio_pin *);
    146      1.2  jmcneill int		fdtbus_gpio_read(struct fdtbus_gpio_pin *);
    147      1.2  jmcneill void		fdtbus_gpio_write(struct fdtbus_gpio_pin *, int);
    148      1.4  jmcneill int		fdtbus_gpio_read_raw(struct fdtbus_gpio_pin *);
    149      1.4  jmcneill void		fdtbus_gpio_write_raw(struct fdtbus_gpio_pin *, int);
    150      1.6     marty int		fdtbus_pinctrl_set_config_index(int, u_int);
    151      1.6     marty int		fdtbus_pinctrl_set_config(int, const char *);
    152      1.1  jmcneill struct fdtbus_regulator *fdtbus_regulator_acquire(int, const char *);
    153      1.2  jmcneill void		fdtbus_regulator_release(struct fdtbus_regulator *);
    154      1.2  jmcneill int		fdtbus_regulator_enable(struct fdtbus_regulator *);
    155      1.2  jmcneill int		fdtbus_regulator_disable(struct fdtbus_regulator *);
    156  1.7.2.1  pgoyette int		fdtbus_regulator_set_voltage(struct fdtbus_regulator *,
    157  1.7.2.1  pgoyette 		    u_int, u_int);
    158  1.7.2.1  pgoyette int		fdtbus_regulator_get_voltage(struct fdtbus_regulator *,
    159  1.7.2.1  pgoyette 		    u_int *);
    160      1.2  jmcneill 
    161      1.3  jmcneill struct clk *	fdtbus_clock_get(int, const char *);
    162      1.3  jmcneill struct clk *	fdtbus_clock_get_index(int, u_int);
    163      1.3  jmcneill 
    164      1.3  jmcneill struct fdtbus_reset *fdtbus_reset_get(int, const char *);
    165      1.3  jmcneill struct fdtbus_reset *fdtbus_reset_get_index(int, u_int);
    166      1.3  jmcneill void		fdtbus_reset_put(struct fdtbus_reset *);
    167      1.3  jmcneill int		fdtbus_reset_assert(struct fdtbus_reset *);
    168      1.3  jmcneill int		fdtbus_reset_deassert(struct fdtbus_reset *);
    169      1.3  jmcneill 
    170  1.7.2.1  pgoyette int		fdtbus_todr_attach(device_t, int, todr_chip_handle_t);
    171  1.7.2.1  pgoyette 
    172      1.2  jmcneill bool		fdtbus_set_data(const void *);
    173      1.2  jmcneill const void *	fdtbus_get_data(void);
    174      1.2  jmcneill int		fdtbus_phandle2offset(int);
    175      1.2  jmcneill int		fdtbus_offset2phandle(int);
    176  1.7.2.1  pgoyette bool		fdtbus_get_path(int, char *, size_t);
    177  1.7.2.1  pgoyette 
    178  1.7.2.1  pgoyette const char *	fdtbus_get_stdout_path(void);
    179  1.7.2.1  pgoyette int		fdtbus_get_stdout_phandle(void);
    180  1.7.2.1  pgoyette int		fdtbus_get_stdout_speed(void);
    181      1.1  jmcneill 
    182      1.1  jmcneill #endif /* _DEV_FDT_FDTVAR_H */
    183