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