1 /*
2  * Copyright (C) 2017 STMicroelectronics
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _VARIANT_ARGONKEY_H_
18 #define _VARIANT_ARGONKEY_H_
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #define PLATFORM_HW_TYPE            0x4172   // 'Ar' -> argonkey
25 
26 #define VARIANT_VER                 0x00000000
27 
28 //we have LSE in argonkey
29 #define RTC_CLK                     RTC_CLK_LSE
30 #define RTC_PREDIV_A                0UL
31 #define RTC_PREDIV_S                32767UL
32 
33 //spi bus for comms
34 #define PLATFORM_HOST_INTF_SPI_BUS  0
35 
36 #define SH_INT_WAKEUP               GPIO_PA(0)
37 #define SH_EXTI_WAKEUP_IRQ          EXTI0_IRQn
38 #define AP_INT_WAKEUP               GPIO_PA(1)
39 /*
40  * Allocating a GPIO for non-wakeup host interrupt is optional in CHRE.
41  * ArgonKey implements this feature and enables it here. If you want to use
42  * the GPIO_PA(3) for other purposes, you should comment the line below and
43  * the corresponding line in the host's devicetree.
44  */
45 #define AP_INT_NONWAKEUP            GPIO_PA(3)
46 
47 #define DEBUG_UART_UNITNO           1
48 #define DEBUG_UART_GPIO_TX          GPIO_PA(9)
49 #define DEBUG_UART_GPIO_RX          GPIO_PA(10)
50 
51 #define DEBUG_LOG_EVT               0x3B474F4C
52 
53 #define BL_FLASH_TABLE                                                  \
54 {                                                                       \
55     { (uint8_t *)(&BL),                      0x04000, BL_FLASH_BL     },\
56     { (uint8_t *)(__eedata_start),           0x04000, BL_FLASH_EEDATA },\
57     { (uint8_t *)(__eedata_start + 0x04000), 0x04000, BL_FLASH_EEDATA },\
58     { (uint8_t *)(__code_start),             0x04000, BL_FLASH_KERNEL },\
59     { (uint8_t *)(__code_start + 0x04000),   0x10000, BL_FLASH_KERNEL },\
60     { (uint8_t *)(__code_start + 0x14000),   0x20000, BL_FLASH_KERNEL },\
61     { (uint8_t *)(__shared_start),           0x20000, BL_FLASH_SHARED },\
62     { (uint8_t *)(__shared_start + 0x20000), 0x20000, BL_FLASH_SHARED },\
63     { (uint8_t *)(__shared_start + 0x40000), 0x20000, BL_FLASH_SHARED },\
64     { (uint8_t *)(__shared_start + 0x60000), 0x20000, BL_FLASH_SHARED },\
65     { (uint8_t *)(__shared_start + 0x80000), 0x20000, BL_FLASH_SHARED },\
66     { (uint8_t *)(__shared_start + 0xA0000), 0x20000, BL_FLASH_SHARED },\
67 }
68 
69 /* ------------------------------------------------------------------------ */
70 /* sensor accel+gyro lsm6dsl (compatible lsm6dsm) on spi */
71 
72 // #define LSM6DSM_DBG_ENABLED                 1
73 
74 #define LSM6DSM_SPI_SLAVE_BUS_ID               1
75 #define LSM6DSM_SPI_SLAVE_FREQUENCY_HZ         8000000
76 #define LSM6DSM_SPI_SLAVE_CS_GPIO              GPIO_PB(12)
77 
78 #define LSM6DSM_INT_IRQ                        EXTI1_IRQn
79 #define LSM6DSM_INT1_GPIO                      GPIO_PB(1)
80 
81 /* i2c slave sensor mag lis2mdl (lsm303agr compatible) */
82 #define LSM6DSM_I2C_MASTER_LSM303AGR           1
83 
84 #define LSM6DSM_ACCEL_GYRO_ROT_MATRIX          -1, 0, 0, 0, -1, 0, 0, 0, 1
85 #define LSM6DSM_MAGN_ROT_MATRIX                -1, 0, 0, 0, 1, 0, 0, 0, 1
86 
87 #define LSM6DSM_ACCEL_CALIB_ENABLED            1
88 #define LSM6DSM_GYRO_CALIB_ENABLED             1
89 #define LSM6DSM_MAGN_CALIB_ENABLED             1
90 #define LSM6DSM_OVERTEMP_CALIB_ENABLED         1
91 
92 /* ------------------------------------------------------------------------ */
93 /* sensor baro+temp lps22hb on i2c */
94 /* unused PIN GPIO_PA(15), INT EXTI15_10_IRQn */
95 
96 // #define LPS22HB_DBG_ENABLED                 1
97 
98 #define LPS22HB_I2C_BUS_ID                     1
99 #define LPS22HB_I2C_SPEED                      400000
100 #define LPS22HB_I2C_ADDR                       0x5D
101 
102 /* ------------------------------------------------------------------------ */
103 /* sensor humidity hts221 on i2c */
104 /* unused PIN GPIO_PA(2), INT EXTI2_IRQn is used as button */
105 
106 // #define HTS221_DBG_ENABLED                  1
107 
108 #define HTS221_I2C_BUS_ID                      1
109 #define HTS221_I2C_SPEED                       400000
110 #define HTS221_I2C_ADDR                        0x5F
111 
112 /* ------------------------------------------------------------------------ */
113 /* sensor als isl29034 on i2c */
114 
115 #define ISL29034_I2C_BUS_ID                    1
116 #define ISL29034_I2C_SPEED                     400000
117 #define ISL29034_I2C_ADDR                      0x44
118 
119 /* ------------------------------------------------------------------------ */
120 /* sensor proximity vl53l0x on i2c */
121 
122 // FIXME
123 // I2C_BUS_ID 1
124 // I2C_SPEED  400000
125 // I2C_ADDR   0x29
126 // PIN        GPIO_PB(3)
127 // IRQ        EXTI3_IRQn
128 
129 /* ------------------------------------------------------------------------ */
130 /* sensor hall mrms501a on gpio */
131 
132 #define HALL_PIN                               GPIO_PB(5)
133 #define HALL_IRQ                               EXTI9_5_IRQn
134 
135 /* ------------------------------------------------------------------------ */
136 /* microphone on i2s */
137 
138 // FIXME
139 // I2S_BUS_ID 4
140 
141 /* ------------------------------------------------------------------------ */
142 /* led controller lp3943 on i2c */
143 
144 #define LP3943_I2C_BUS_ID                      2
145 #define LP3943_I2C_SPEED                       200000
146 #define LP3943_I2C_ADDR                        0x60
147 
148 /* ------------------------------------------------------------------------ */
149 /* button on gpio */
150 
151 // FIXME
152 // PIN GPIO_PA(2)
153 // INT EXTI2_IRQn
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif
160