exynos_var.h revision 1.12.2.2 1 1.12.2.2 tls /* $NetBSD: exynos_var.h,v 1.12.2.2 2014/08/10 06:53:52 tls Exp $ */
2 1.12.2.2 tls /*-
3 1.12.2.2 tls * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
4 1.12.2.2 tls * All rights reserved.
5 1.12.2.2 tls *
6 1.12.2.2 tls * This code is derived from software contributed to The NetBSD Foundation
7 1.12.2.2 tls * by Matt Thomas of 3am Software Foundry.
8 1.12.2.2 tls *
9 1.12.2.2 tls * This code is derived from software contributed to The NetBSD Foundation
10 1.12.2.2 tls * by Reinoud Zandijk.
11 1.12.2.2 tls *
12 1.12.2.2 tls * Redistribution and use in source and binary forms, with or without
13 1.12.2.2 tls * modification, are permitted provided that the following conditions
14 1.12.2.2 tls * are met:
15 1.12.2.2 tls * 1. Redistributions of source code must retain the above copyright
16 1.12.2.2 tls * notice, this list of conditions and the following disclaimer.
17 1.12.2.2 tls * 2. Redistributions in binary form must reproduce the above copyright
18 1.12.2.2 tls * notice, this list of conditions and the following disclaimer in the
19 1.12.2.2 tls * documentation and/or other materials provided with the distribution.
20 1.12.2.2 tls *
21 1.12.2.2 tls * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 1.12.2.2 tls * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 1.12.2.2 tls * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 1.12.2.2 tls * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 1.12.2.2 tls * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 1.12.2.2 tls * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 1.12.2.2 tls * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 1.12.2.2 tls * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 1.12.2.2 tls * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 1.12.2.2 tls * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 1.12.2.2 tls * POSSIBILITY OF SUCH DAMAGE.
32 1.12.2.2 tls */
33 1.12.2.2 tls
34 1.12.2.2 tls #ifndef _ARM_SAMSUNG_EXYNOS_VAR_H_
35 1.12.2.2 tls #define _ARM_SAMSUNG_EXYNOS_VAR_H_
36 1.12.2.2 tls
37 1.12.2.2 tls #include <sys/types.h>
38 1.12.2.2 tls #include <sys/bus.h>
39 1.12.2.2 tls #include <sys/gpio.h>
40 1.12.2.2 tls #include <dev/gpio/gpiovar.h>
41 1.12.2.2 tls #include <arm/samsung/exynos_reg.h>
42 1.12.2.2 tls
43 1.12.2.2 tls extern uint32_t exynos_soc_id;
44 1.12.2.2 tls extern uint32_t exynos_pop_id;
45 1.12.2.2 tls
46 1.12.2.2 tls #define EXYNOS_PRODUCT_FAMILY(soc) __SHIFTOUT((soc), __BITS(24,31))
47 1.12.2.2 tls #define EXYNOS4_PRODUCT_FAMILY 0xe4
48 1.12.2.2 tls #define EXYNOS5_PRODUCT_FAMILY 0xe5
49 1.12.2.2 tls #define EXYNOS_PRODUCT_ID(soc) __SHIFTOUT((soc), __BITS(12,31))
50 1.12.2.2 tls #define EXYNOS_PRODUCT_PACKAGE(soc) __SHIFTOUT((soc), __BITS(8,11))
51 1.12.2.2 tls #define EXYNOS_PRODUCT_REV(soc) __SHIFTOUT((soc), __BITS(4,7))
52 1.12.2.2 tls #define EXYNOS_PRODUCT_SUBREV(soc) __SHIFTOUT((soc), __BITS(0,3))
53 1.12.2.2 tls
54 1.12.2.2 tls
55 1.12.2.2 tls #define IS_EXYNOS4410_P() (EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe4410)
56 1.12.2.2 tls #define IS_EXYNOS4412_P() (EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe4412)
57 1.12.2.2 tls #define IS_EXYNOS4412_R0_P() \
58 1.12.2.2 tls ((EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe4412) && \
59 1.12.2.2 tls (EXYNOS_PRODUCT_REV(exynos_soc_id) == 0))
60 1.12.2.2 tls #define IS_EXYNOS4X12_P() ((EXYNOS_PRODUCT_ID(exynos_soc_id) & 0xff0ff) \
61 1.12.2.2 tls == 0xe4012)
62 1.12.2.2 tls
63 1.12.2.2 tls #define IS_EXYNOS4_P() (EXYNOS_PRODUCT_FAMILY(exynos_soc_id) == EXYNOS4_PRODUCT_FAMILY)
64 1.12.2.2 tls
65 1.12.2.2 tls #define IS_EXYNOS5410_P() (EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe5410)
66 1.12.2.2 tls #define IS_EXYNOS5440_P() (EXYNOS_PRODUCT_ID(exynos_soc_id) == 0xe5440)
67 1.12.2.2 tls
68 1.12.2.2 tls #define IS_EXYNOS5_P() (EXYNOS_PRODUCT_FAMILY(exynos_soc_id) == EXYNOS5_PRODUCT_FAMILY)
69 1.12.2.2 tls
70 1.12.2.2 tls struct exyo_locators {
71 1.12.2.2 tls const char *loc_name;
72 1.12.2.2 tls bus_size_t loc_offset;
73 1.12.2.2 tls bus_size_t loc_size;
74 1.12.2.2 tls int loc_port;
75 1.12.2.2 tls int loc_intr;
76 1.12.2.2 tls int loc_flags;
77 1.12.2.2 tls
78 1.12.2.2 tls /* for i2c: */
79 1.12.2.2 tls const char *loc_gpio_bus;
80 1.12.2.2 tls uint8_t loc_sda, loc_slc, loc_func;
81 1.12.2.2 tls };
82 1.12.2.2 tls
83 1.12.2.2 tls
84 1.12.2.2 tls struct exyo_attach_args {
85 1.12.2.2 tls struct exyo_locators exyo_loc;
86 1.12.2.2 tls bus_space_tag_t exyo_core_bst;
87 1.12.2.2 tls bus_space_tag_t exyo_core_a4x_bst;
88 1.12.2.2 tls bus_space_handle_t exyo_core_bsh;
89 1.12.2.2 tls bus_dma_tag_t exyo_dmat;
90 1.12.2.2 tls bus_dma_tag_t exyo_coherent_dmat;
91 1.12.2.2 tls };
92 1.12.2.2 tls
93 1.12.2.2 tls struct exynos_gpio_pinset {
94 1.12.2.2 tls char pinset_group[10];
95 1.12.2.2 tls uint8_t pinset_func;
96 1.12.2.2 tls uint8_t pinset_mask;
97 1.12.2.2 tls };
98 1.12.2.2 tls
99 1.12.2.2 tls struct exynos_gpio_pindata {
100 1.12.2.2 tls gpio_chipset_tag_t pd_gc;
101 1.12.2.2 tls int pd_pin;
102 1.12.2.2 tls };
103 1.12.2.2 tls
104 1.12.2.2 tls
105 1.12.2.2 tls #define EXYNOS_MAX_IIC_BUSSES 9
106 1.12.2.2 tls struct i2c_controller;
107 1.12.2.2 tls extern struct i2c_controller *exynos_i2cbus[EXYNOS_MAX_IIC_BUSSES];
108 1.12.2.2 tls
109 1.12.2.2 tls
110 1.12.2.2 tls extern struct bus_space exynos_bs_tag;
111 1.12.2.2 tls extern struct bus_space exynos_a4x_bs_tag;
112 1.12.2.2 tls extern struct arm32_bus_dma_tag exynos_bus_dma_tag;
113 1.12.2.2 tls extern struct arm32_bus_dma_tag exynos_coherent_bus_dma_tag;
114 1.12.2.2 tls
115 1.12.2.2 tls extern bus_space_handle_t exynos_core_bsh;
116 1.12.2.2 tls
117 1.12.2.2 tls extern void exynos_bootstrap(vaddr_t, vaddr_t);
118 1.12.2.2 tls extern void exynos_dma_bootstrap(psize_t memsize);
119 1.12.2.2 tls extern void exynos_gpio_bootstrap(void);
120 1.12.2.2 tls
121 1.12.2.2 tls extern void exynos_device_register(device_t self, void *aux);
122 1.12.2.2 tls extern void exynos_device_register_post_config(device_t self, void *aux);
123 1.12.2.2 tls extern void exyo_device_register(device_t self, void *aux);
124 1.12.2.2 tls extern void exyo_device_register_post_config(device_t self, void *aux);
125 1.12.2.2 tls extern void exynos_wdt_reset(void);
126 1.12.2.2 tls
127 1.12.2.2 tls extern bool exynos_gpio_pinset_available(const struct exynos_gpio_pinset *);
128 1.12.2.2 tls extern void exynos_gpio_pinset_acquire(const struct exynos_gpio_pinset *);
129 1.12.2.2 tls extern void exynos_gpio_pinset_release(const struct exynos_gpio_pinset *);
130 1.12.2.2 tls extern void exynos_gpio_pinset_to_pindata(const struct exynos_gpio_pinset *,
131 1.12.2.2 tls int pinnr, struct exynos_gpio_pindata *);
132 1.12.2.2 tls extern bool exynos_gpio_pin_reserve(const char *, struct exynos_gpio_pindata *);
133 1.12.2.2 tls
134 1.12.2.2 tls static inline void
135 1.12.2.2 tls exynos_gpio_pindata_write(const struct exynos_gpio_pindata *pd, int value)
136 1.12.2.2 tls {
137 1.12.2.2 tls gpiobus_pin_write(pd->pd_gc, pd->pd_pin, value);
138 1.12.2.2 tls }
139 1.12.2.2 tls
140 1.12.2.2 tls static inline int
141 1.12.2.2 tls exynos_gpio_pindata_read(const struct exynos_gpio_pindata *pd)
142 1.12.2.2 tls {
143 1.12.2.2 tls return gpiobus_pin_read(pd->pd_gc, pd->pd_pin);
144 1.12.2.2 tls }
145 1.12.2.2 tls
146 1.12.2.2 tls static inline void
147 1.12.2.2 tls exynos_gpio_pindata_ctl(const struct exynos_gpio_pindata *pd, int flags)
148 1.12.2.2 tls {
149 1.12.2.2 tls gpiobus_pin_ctl(pd->pd_gc, pd->pd_pin, flags);
150 1.12.2.2 tls }
151 1.12.2.2 tls
152 1.12.2.2 tls
153 1.12.2.2 tls #ifdef ARM_TRUSTZONE_FIRMWARE
154 1.12.2.2 tls /* trustzone calls */
155 1.12.2.2 tls extern int exynos_do_idle(void);
156 1.12.2.2 tls extern int exynos_set_cpu_boot_addr(int cpu, vaddr_t boot_addr);
157 1.12.2.2 tls extern int exynos_cpu_boot(int cpu);
158 1.12.2.2 tls extern int exynos_l2cc_init(void);
159 1.12.2.2 tls #endif
160 1.12.2.2 tls
161 1.12.2.2 tls #endif /* _ARM_SAMSUNG_EXYNOS_VAR_H_ */
162