fdba73939a96e1569255dab5262fca600ecab4a2
[fw/openocd] / src / flash / nor / cc26xx.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4  *   Copyright (C) 2017 by Texas Instruments, Inc.                         *
5  ***************************************************************************/
6
7 #ifndef OPENOCD_FLASH_NOR_CC26XX_H
8 #define OPENOCD_FLASH_NOR_CC26XX_H
9
10 /* Addresses of FCFG1 registers to access ICEPick Device ID and User ID */
11 #define FCFG1_ICEPICK_ID 0x50001318
12 #define FCFG1_USER_ID    0x50001294
13
14 /* ICEPick device ID mask and values */
15 #define ICEPICK_ID_MASK          0x0fffffff
16 #define ICEPICK_REV_MASK         0xf0000000
17 #define CC26X0_ICEPICK_ID        0x0b99a02f
18 #define CC26X1_ICEPICK_ID        0x0b9bd02f
19 #define CC13X0_ICEPICK_ID        0x0b9be02f
20 #define CC13X2_CC26X2_ICEPICK_ID 0x0bb4102f
21
22 /* User ID mask for Agama CC13x2 vs CC26x2 */
23 #define USER_ID_CC13_MASK 0x00800000
24
25 /* Common CC26xx/CC13xx flash and memory parameters */
26 #define CC26XX_FLASH_BASE_ADDR   0x00000000
27 #define CC26XX_FLASH_SIZE_INFO   0x4003002c
28 #define CC26XX_SRAM_SIZE_INFO    0x40082250
29 #define CC26XX_ALGO_BASE_ADDRESS 0x20000000
30
31 /* Chameleon CC26x0/CC13x0 specific parameters */
32 #define CC26X0_MAX_SECTORS   32
33 #define CC26X0_SECTOR_LENGTH 0x1000
34 #define CC26X0_ALGO_BUFFER_0 0x20001c00
35 #define CC26X0_ALGO_BUFFER_1 0x20002c00
36 #define CC26X0_ALGO_PARAMS_0 0x20001bd8
37 #define CC26X0_ALGO_PARAMS_1 0x20001bec
38 #define CC26X0_WORKING_SIZE  (CC26X0_ALGO_BUFFER_1 + CC26X0_SECTOR_LENGTH - \
39                                                          CC26XX_ALGO_BASE_ADDRESS)
40
41 /* Agama CC26x2/CC13x2 specific parameters */
42 #define CC26X2_MAX_SECTORS   128
43 #define CC26X2_SECTOR_LENGTH 0x2000
44 #define CC26X2_ALGO_BUFFER_0 0x20002000
45 #define CC26X2_ALGO_BUFFER_1 0x20004000
46 #define CC26X2_ALGO_PARAMS_0 0x20001fd8
47 #define CC26X2_ALGO_PARAMS_1 0x20001fec
48 #define CC26X2_WORKING_SIZE  (CC26X2_ALGO_BUFFER_1 + CC26X2_SECTOR_LENGTH - \
49                                                          CC26XX_ALGO_BASE_ADDRESS)
50
51 /* CC26xx flash helper algorithm buffer flags */
52 #define CC26XX_BUFFER_EMPTY 0x00000000
53 #define CC26XX_BUFFER_FULL  0xffffffff
54
55 /* CC26XX flash helper algorithm commands */
56 #define CC26XX_CMD_NO_ACTION                     0
57 #define CC26XX_CMD_ERASE_ALL                     1
58 #define CC26XX_CMD_PROGRAM                       2
59 #define CC26XX_CMD_ERASE_AND_PROGRAM             3
60 #define CC26XX_CMD_ERASE_AND_PROGRAM_WITH_RETAIN 4
61 #define CC26XX_CMD_ERASE_SECTORS                 5
62
63 /* CC26xx and CC13xx device types */
64 #define CC26XX_NO_TYPE 0 /* Device type not determined yet */
65 #define CC26X0_TYPE    1 /* CC26x0 Chameleon device */
66 #define CC26X1_TYPE    2 /* CC26x1 Chameleon device */
67 #define CC26X2_TYPE    3 /* CC26x2 Agama device */
68 #define CC13X0_TYPE    4 /* CC13x0 Chameleon device */
69 #define CC13X2_TYPE    5 /* CC13x2 Agama device */
70
71 /* Flash helper algorithm parameter block struct */
72 #define CC26XX_STATUS_OFFSET 0x0c
73 struct cc26xx_algo_params {
74         uint8_t address[4];
75         uint8_t length[4];
76         uint8_t command[4];
77         uint8_t status[4];
78 };
79
80 /* Flash helper algorithm for CC26x0 Chameleon targets */
81 const uint8_t cc26x0_algo[] = {
82 #include "../../../contrib/loaders/flash/cc26xx/cc26x0_algo.inc"
83 };
84
85 /* Flash helper algorithm for CC26x2 Agama targets */
86 const uint8_t cc26x2_algo[] = {
87 #include "../../../contrib/loaders/flash/cc26xx/cc26x2_algo.inc"
88 };
89
90 #endif /* OPENOCD_FLASH_NOR_CC26XX_H */