Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | /* * SPDX-License-Identifier: Apache-2.0 * * Basic initialization for the CC2650 System on Chip. */ #include <toolchain/gcc.h> #include <init.h> #include <sys_io.h> #include "soc.h" #define CCFG_SIZE 88 /* The bootloader of the SoC (in ROM) reads configuration * data (CCFG) at a fixed address (last page of flash). * The most notable information being whether to run the * code stored in flash or not. * * We put configuration data in a specific section so that * the linker script can map it accordingly. */ const u32_t __ti_ccfg_section ti_ccfg[CCFG_SIZE / sizeof(u32_t)] = { 0x00008001, /* EXT_LF_CLK: default values */ 0xFF13FFFF, /* MODE_CONF_1: default values */ 0x0058FFFF, /* SIZE_AND_DIS_FLAGS: 88 bytes long, no external osc. */ 0xFFFFFFFF, /* MODE_CONF: default values */ 0xFFFFFFFF, /* VOLT_LOAD_0: default values */ 0xFFFFFFFF, /* VOLT_LOAD_1: default values */ 0xFFFFFFFF, /* RTC_OFFSET: default values */ 0xFFFFFFFF, /* FREQ_OFFSET: default values */ 0xFFFFFFFF, /* IEEE_MAC_0: use MAC address from FCFG */ 0xFFFFFFFF, /* IEEE_MAC_1: use MAC address from FCFG */ 0xFFFFFFFF, /* IEEE_BLE_0: use BLE address from FCFG */ 0xFFFFFFFF, /* IEEE_BLE_1: use BLE address from FCFG */ /* BL_CONFIG: disable backdoor and bootloader, * default pin, default active level (high) */ CC2650_CCFG_BACKDOOR_DISABLED | (0xFF << CC2650_CCFG_BL_CONFIG_BL_PIN_NUMBER_POS) | (0x1 << CC2650_CCFG_BL_CONFIG_BL_LEVEL_POS) | 0x00FE0000 | /* reserved */ CC2650_CCFG_BOOTLOADER_DISABLED, 0xFFFFFFFF, /* ERASE_CONF: default values (banks + chip erase) */ /* CCFG_TI_OPTIONS: disable TI failure analysis */ CC2650_CCFG_TI_FA_DISABLED | 0xFFFFFF00, /* reserved */ 0xFFC5C5C5, /* CCFG_TAP_DAP_0: default values */ 0xFFC5C5C5, /* CCFG_TAP_DAP_1: default values */ /* IMAGE_VALID_CONF: authorize program on flash to run */ CC2650_CCFG_IMAGE_IS_VALID, /* Make all flash chip programmable + erasable * (which is default) */ 0xFFFFFFFF, /* CCFG_PROT_31_0 */ 0xFFFFFFFF, /* CCFG_PROT_61_32 */ 0xFFFFFFFF, /* CCFG_PROT_95_64 */ 0xFFFFFFFF /* CCFG_PROT_127_96 */ }; /* PRCM Registers */ static const u32_t clkloadctl = REG_ADDR(TI_CC2650_PRCM_40082000_BASE_ADDRESS, CC2650_PRCM_CLKLOADCTL); static const u32_t gpioclkgr = REG_ADDR(TI_CC2650_PRCM_40082000_BASE_ADDRESS, CC2650_PRCM_GPIOCLKGR); static const u32_t pdctl0 = REG_ADDR(TI_CC2650_PRCM_40082000_BASE_ADDRESS, CC2650_PRCM_PDCTL0); static const u32_t pdstat0 = REG_ADDR(TI_CC2650_PRCM_40082000_BASE_ADDRESS, CC2650_PRCM_PDSTAT0); #ifdef CONFIG_SERIAL static const u32_t uartclkgr = REG_ADDR(TI_CC2650_PRCM_40082000_BASE_ADDRESS, CC2650_PRCM_UARTCLKGR); #endif /* Setup power and clock for needed hardware modules. */ static void setup_modules_prcm(void) { #if defined(CONFIG_GPIO_CC2650) || \ defined(CONFIG_SERIAL) /* Setup power */ #if defined(CONFIG_GPIO_CC2650) sys_set_bit(pdctl0, CC2650_PRCM_PDCTL0_PERIPH_ON_POS); #endif #ifdef CONFIG_SERIAL sys_set_bit(pdctl0, CC2650_PRCM_PDCTL0_SERIAL_ON_POS); #endif /* Setup clocking */ #ifdef CONFIG_GPIO_CC2650 sys_set_bit(gpioclkgr, CC2650_PRCM_GPIOCLKGR_CLK_EN_POS); #endif #ifdef CONFIG_SERIAL sys_set_bit(uartclkgr, CC2650_PRCM_UARTCLKGR_CLK_EN_POS); #endif /* Reload clocking configuration for device */ sys_set_bit(clkloadctl, CC2650_PRCM_CLKLOADCTL_LOAD_POS); /* Wait for power to be completely on, to avoid bus faults * when accessing modules' registers. */ #if defined(CONFIG_GPIO_CC2650) while (!(sys_read32(pdstat0) & BIT(CC2650_PRCM_PDSTAT0_PERIPH_ON_POS))) { continue; } #endif #if defined(CONFIG_SERIAL) while (!(sys_read32(pdstat0) & BIT(CC2650_PRCM_PDSTAT0_SERIAL_ON_POS))) { continue; } #endif #endif } static int ti_cc2650(struct device *dev) { ARG_UNUSED(dev); NMI_INIT(); setup_modules_prcm(); return 0; } SYS_INIT(ti_cc2650, PRE_KERNEL_1, 0); int bit_is_set(u32_t reg, u8_t bit) { return sys_read32(reg) & BIT(bit); } |