Home | History | Annotate | Line # | Download | only in samsung
exynos_var.h revision 1.28.4.1
      1  1.28.4.1   thorpej /*	$NetBSD: exynos_var.h,v 1.28.4.1 2021/04/03 22:28:18 thorpej Exp $	*/
      2      1.15     skrll 
      3       1.1      matt /*-
      4       1.1      matt  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
      5       1.1      matt  * All rights reserved.
      6       1.1      matt  *
      7       1.1      matt  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1      matt  * by Matt Thomas of 3am Software Foundry.
      9       1.1      matt  *
     10       1.1      matt  * This code is derived from software contributed to The NetBSD Foundation
     11       1.1      matt  * by Reinoud Zandijk.
     12       1.1      matt  *
     13       1.1      matt  * Redistribution and use in source and binary forms, with or without
     14       1.1      matt  * modification, are permitted provided that the following conditions
     15       1.1      matt  * are met:
     16       1.1      matt  * 1. Redistributions of source code must retain the above copyright
     17       1.1      matt  *    notice, this list of conditions and the following disclaimer.
     18       1.1      matt  * 2. Redistributions in binary form must reproduce the above copyright
     19       1.1      matt  *    notice, this list of conditions and the following disclaimer in the
     20       1.1      matt  *    documentation and/or other materials provided with the distribution.
     21       1.1      matt  *
     22       1.1      matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     23       1.1      matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     24       1.1      matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     25       1.1      matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     26       1.1      matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27       1.1      matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28       1.1      matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29       1.1      matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30       1.1      matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31       1.1      matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     32       1.1      matt  * POSSIBILITY OF SUCH DAMAGE.
     33       1.1      matt  */
     34       1.1      matt 
     35       1.1      matt #ifndef _ARM_SAMSUNG_EXYNOS_VAR_H_
     36       1.1      matt #define _ARM_SAMSUNG_EXYNOS_VAR_H_
     37       1.1      matt 
     38       1.1      matt #include <sys/types.h>
     39       1.1      matt #include <sys/bus.h>
     40       1.1      matt #include <sys/gpio.h>
     41       1.5   reinoud #include <dev/gpio/gpiovar.h>
     42       1.1      matt #include <arm/samsung/exynos_reg.h>
     43       1.1      matt 
     44       1.1      matt extern uint32_t exynos_soc_id;
     45       1.1      matt extern uint32_t exynos_pop_id;
     46       1.1      matt 
     47       1.1      matt #define EXYNOS_PRODUCT_FAMILY(soc)	__SHIFTOUT((soc), __BITS(24,31))
     48       1.1      matt #define  EXYNOS4_PRODUCT_FAMILY		0xe4
     49       1.1      matt #define  EXYNOS5_PRODUCT_FAMILY		0xe5
     50       1.1      matt #define EXYNOS_PRODUCT_ID(soc)		__SHIFTOUT((soc), __BITS(12,31))
     51       1.1      matt #define EXYNOS_PRODUCT_PACKAGE(soc)	__SHIFTOUT((soc), __BITS(8,11))
     52       1.1      matt #define EXYNOS_PRODUCT_REV(soc)		__SHIFTOUT((soc), __BITS(4,7))
     53       1.1      matt #define EXYNOS_PRODUCT_SUBREV(soc)	__SHIFTOUT((soc), __BITS(0,3))
     54       1.1      matt 
     55       1.1      matt 
     56       1.1      matt #define IS_EXYNOS4410_P()	(EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe4410)
     57       1.1      matt #define IS_EXYNOS4412_P()	(EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe4412)
     58       1.1      matt #define IS_EXYNOS4412_R0_P() \
     59       1.1      matt 			((EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe4412) && \
     60       1.1      matt 			 (EXYNOS_PRODUCT_REV(exynos_soc_id) == 0))
     61      1.11   reinoud #define IS_EXYNOS4X12_P()	((EXYNOS_PRODUCT_ID(exynos_soc_id) & 0xff0ff) \
     62      1.11   reinoud 			== 0xe4012)
     63       1.2   reinoud 
     64       1.2   reinoud #define IS_EXYNOS4_P()	(EXYNOS_PRODUCT_FAMILY(exynos_soc_id) == EXYNOS4_PRODUCT_FAMILY)
     65       1.1      matt 
     66       1.1      matt #define IS_EXYNOS5410_P()	(EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe5410)
     67      1.14   reinoud #define IS_EXYNOS5422_P()	(EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe5422)
     68       1.1      matt #define IS_EXYNOS5440_P()	(EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe5440)
     69       1.1      matt 
     70       1.1      matt #define IS_EXYNOS5_P()	(EXYNOS_PRODUCT_FAMILY(exynos_soc_id) == EXYNOS5_PRODUCT_FAMILY)
     71       1.1      matt 
     72      1.16   reinoud 
     73       1.1      matt struct exyo_locators {
     74       1.1      matt 	const char *loc_name;
     75       1.1      matt 	bus_size_t loc_offset;
     76       1.1      matt 	bus_size_t loc_size;
     77       1.1      matt 	int loc_port;
     78       1.1      matt 	int loc_intr;
     79       1.1      matt 	int loc_flags;
     80       1.9   reinoud 
     81       1.9   reinoud 	/* for i2c: */
     82       1.9   reinoud 	const char *loc_gpio_bus;
     83       1.9   reinoud 	uint8_t loc_sda, loc_slc, loc_func;
     84       1.1      matt };
     85       1.1      matt 
     86      1.10   reinoud 
     87       1.1      matt struct exyo_attach_args {
     88       1.1      matt 	struct exyo_locators exyo_loc;
     89       1.1      matt 	bus_space_tag_t exyo_core_bst;
     90       1.1      matt 	bus_space_tag_t exyo_core_a4x_bst;
     91       1.1      matt 	bus_space_handle_t exyo_core_bsh;
     92       1.1      matt 	bus_dma_tag_t exyo_dmat;
     93       1.1      matt 	bus_dma_tag_t exyo_coherent_dmat;
     94       1.1      matt };
     95       1.1      matt 
     96      1.28     skrll struct exynos_pinctrl_banks {
     97      1.28     skrll 	struct exynos_gpio_bank *epb_banks;
     98      1.28     skrll 	size_t			epb_nbanks;
     99      1.28     skrll };
    100      1.28     skrll 
    101       1.5   reinoud struct exynos_gpio_pinset {
    102      1.19     marty 	char pinset_bank[10];
    103       1.5   reinoud 	uint8_t pinset_func;
    104       1.9   reinoud 	uint8_t pinset_mask;
    105       1.5   reinoud };
    106       1.5   reinoud 
    107       1.5   reinoud struct exynos_gpio_pindata {
    108       1.5   reinoud 	gpio_chipset_tag_t pd_gc;
    109       1.5   reinoud 	int pd_pin;
    110       1.5   reinoud };
    111       1.5   reinoud 
    112      1.23     marty struct exynos_gpio_pin_cfg {
    113      1.23     marty 	uint32_t cfg;
    114      1.24  jmcneill 	int cfg_valid;
    115      1.23     marty 	uint32_t pud;
    116      1.24  jmcneill 	int pud_valid;
    117      1.23     marty 	uint32_t drv;
    118      1.24  jmcneill 	int drv_valid;
    119      1.23     marty 	uint32_t conpwd;
    120      1.24  jmcneill 	int conpwd_valid;
    121      1.23     marty 	uint32_t pudpwd;
    122      1.24  jmcneill 	int pudpwd_valid;
    123      1.23     marty };
    124      1.23     marty 
    125      1.23     marty struct exynos_gpio_softc {
    126      1.23     marty 	device_t		sc_dev;
    127      1.23     marty 	bus_space_tag_t		sc_bst;
    128      1.23     marty 	bus_space_handle_t	sc_bsh;
    129      1.23     marty 	struct exynos_gpio_bank *sc_bank;
    130      1.23     marty 	int			sc_phandle;
    131      1.23     marty };
    132       1.1      matt 
    133       1.9   reinoud #define EXYNOS_MAX_IIC_BUSSES 9
    134       1.9   reinoud struct i2c_controller;
    135       1.9   reinoud extern struct i2c_controller *exynos_i2cbus[EXYNOS_MAX_IIC_BUSSES];
    136       1.9   reinoud 
    137       1.9   reinoud 
    138       1.1      matt extern struct bus_space exynos_bs_tag;
    139       1.1      matt extern struct bus_space exynos_a4x_bs_tag;
    140       1.4   reinoud extern struct arm32_bus_dma_tag exynos_bus_dma_tag;
    141       1.4   reinoud extern struct arm32_bus_dma_tag exynos_coherent_bus_dma_tag;
    142       1.4   reinoud 
    143      1.20     marty extern struct bus_space armv7_generic_bs_tag;
    144      1.20     marty extern struct bus_space armv7_generic_a4x_bs_tag;
    145       1.1      matt extern bus_space_handle_t exynos_core_bsh;
    146      1.16   reinoud extern bus_space_handle_t exynos_wdt_bsh;
    147      1.16   reinoud extern bus_space_handle_t exynos_pmu_bsh;
    148      1.16   reinoud extern bus_space_handle_t exynos_cmu_bsh;
    149      1.17   reinoud extern bus_space_handle_t exynos_sysreg_bsh;
    150       1.1      matt 
    151      1.27     skrll extern void exynos_bootstrap(int);
    152       1.5   reinoud extern void exynos_dma_bootstrap(psize_t memsize);
    153      1.22     marty 
    154      1.21     marty struct exynos_pinctrl_softc;
    155      1.23     marty struct exynos_gpio_softc;
    156      1.22     marty struct fdt_attach_args;
    157      1.23     marty 
    158      1.23     marty extern struct exynos_gpio_softc * exynos_gpio_bank_config(struct exynos_pinctrl_softc *,
    159      1.22     marty 				    const struct fdt_attach_args *, int);
    160      1.18   reinoud extern void exynos_wdt_reset(void);
    161      1.18   reinoud 
    162      1.18   reinoud extern void exynos_init_clkout_for_usb(void);	// board specific
    163       1.5   reinoud 
    164      1.13   reinoud extern void exynos_clocks_bootstrap(void);
    165      1.13   reinoud extern void exynos_sysctl_cpufreq_init(void);
    166      1.13   reinoud extern uint64_t exynos_get_cpufreq(void);
    167      1.13   reinoud 
    168       1.3   reinoud extern void exynos_device_register(device_t self, void *aux);
    169       1.8   reinoud extern void exynos_device_register_post_config(device_t self, void *aux);
    170      1.18   reinoud extern void exynos_usb_phy_init(bus_space_handle_t usb2phy_bsh);
    171      1.18   reinoud extern void exynos_usb_soc_powerup(void);
    172      1.18   reinoud 
    173       1.3   reinoud extern void exyo_device_register(device_t self, void *aux);
    174       1.8   reinoud extern void exyo_device_register_post_config(device_t self, void *aux);
    175       1.5   reinoud 
    176      1.28     skrll extern struct exynos_pinctrl_banks exynos5410_pinctrl_banks;
    177      1.28     skrll extern struct exynos_pinctrl_banks exynos5420_pinctrl_banks;
    178      1.28     skrll 
    179  1.28.4.1   thorpej extern struct exynos_gpio_bank *exynos_gpio_bank_lookup(const struct exynos_pinctrl_banks *, const char *name);
    180       1.5   reinoud extern bool exynos_gpio_pinset_available(const struct exynos_gpio_pinset *);
    181       1.5   reinoud extern void exynos_gpio_pinset_acquire(const struct exynos_gpio_pinset *);
    182       1.5   reinoud extern void exynos_gpio_pinset_release(const struct exynos_gpio_pinset *);
    183       1.9   reinoud extern void exynos_gpio_pinset_to_pindata(const struct exynos_gpio_pinset *,
    184       1.9   reinoud 	int pinnr, struct exynos_gpio_pindata *);
    185       1.5   reinoud extern bool exynos_gpio_pin_reserve(const char *, struct exynos_gpio_pindata *);
    186      1.23     marty extern void exynos_gpio_pin_ctl_write(const struct exynos_gpio_bank *,
    187      1.24  jmcneill 				      const struct exynos_gpio_pin_cfg *,
    188      1.24  jmcneill 				      int);
    189       1.5   reinoud static inline void
    190       1.5   reinoud exynos_gpio_pindata_write(const struct exynos_gpio_pindata *pd, int value)
    191       1.5   reinoud {
    192       1.5   reinoud         gpiobus_pin_write(pd->pd_gc, pd->pd_pin, value);
    193       1.5   reinoud }
    194       1.5   reinoud 
    195       1.5   reinoud static inline int
    196       1.5   reinoud exynos_gpio_pindata_read(const struct exynos_gpio_pindata *pd)
    197       1.5   reinoud {
    198       1.5   reinoud         return gpiobus_pin_read(pd->pd_gc, pd->pd_pin);
    199       1.5   reinoud }
    200       1.4   reinoud 
    201       1.7   reinoud static inline void
    202       1.6   reinoud exynos_gpio_pindata_ctl(const struct exynos_gpio_pindata *pd, int flags)
    203       1.6   reinoud {
    204       1.6   reinoud         gpiobus_pin_ctl(pd->pd_gc, pd->pd_pin, flags);
    205       1.6   reinoud }
    206       1.6   reinoud 
    207       1.3   reinoud 
    208       1.3   reinoud #ifdef ARM_TRUSTZONE_FIRMWARE
    209       1.3   reinoud /* trustzone calls */
    210       1.3   reinoud extern int exynos_do_idle(void);
    211       1.3   reinoud extern int exynos_set_cpu_boot_addr(int cpu, vaddr_t boot_addr);
    212       1.3   reinoud extern int exynos_cpu_boot(int cpu);
    213      1.18   reinoud #ifdef EXYNOS4
    214      1.18   reinoud extern int exynos4_l2cc_init(void);
    215      1.18   reinoud #endif
    216       1.3   reinoud #endif
    217       1.1      matt 
    218       1.1      matt #endif	/* _ARM_SAMSUNG_EXYNOS_VAR_H_ */
    219