1 /*
2 * Copyright (c) 2016 Eric Holland
3 *
4 * Use of this source code is governed by a MIT-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/MIT
7 */
8 #include <lk/err.h>
9 #include <lk/debug.h>
10 #include <arch/arm/cm.h>
11 #include <dev/uart.h>
12 #include <platform.h>
13 #include <platform/init.h>
14 #include <platform/clock.h>
15 #include <nrfx.h>
16 #include <mdk/system_nrf52.h>
17 #include <nrfx_clock.h>
18
platform_early_init(void)19 void platform_early_init(void) {
20
21 SystemInit();
22 // Initialize the clock control peripheral
23 nrf52_clock_init();
24
25 arm_cm_systick_init(32768);
26 }
27
platform_init(void)28 void platform_init(void) {
29
30 dprintf(SPEW, "Nordic nrf52xxx platform for lk...\n");
31
32 char *variant = (char *)&NRF_FICR->FICR_INFO.VARIANT;
33 dprintf(SPEW, "Part Number - %x-%c%c%c%c\n", NRF_FICR->FICR_INFO.PART,
34 variant[3], variant[2], variant[1], variant[0]);
35 dprintf(SPEW, "\tRam: %dk\n", NRF_FICR->FICR_INFO.RAM);
36 dprintf(SPEW, "\tFlash: %d pages of %d bytes each (%dk bytes total)\n", \
37 NRF_FICR->CODESIZE, NRF_FICR->CODEPAGESIZE, \
38 (NRF_FICR->CODESIZE * NRF_FICR->CODEPAGESIZE)>>10);
39 dprintf(SPEW, "\tRadio MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", \
40 (NRF_FICR->DEVICEADDR[1] >> 8) & 0xFF, \
41 (NRF_FICR->DEVICEADDR[1]) & 0xFF, \
42 (NRF_FICR->DEVICEADDR[0] >> 24) & 0xFF, \
43 (NRF_FICR->DEVICEADDR[0] >> 16) & 0xFF, \
44 (NRF_FICR->DEVICEADDR[0] >> 8) & 0xFF, \
45 (NRF_FICR->DEVICEADDR[0] >> 0) & 0xFF);
46 }
47