summaryrefslogtreecommitdiff
path: root/arch/arm/soc/nxp_kinetis/k6x/soc_config.c
blob: e97c7c9ed3536be72bc47454c49eb379eaf8d7c5 (plain)
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
/*
 * Copyright (c) 2015 Intel Corporation.
 * Copyright (c) 2016, Freescale Semiconductor, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * @file Board config file
 */

#include <device.h>
#include <init.h>

#include <kernel.h>

#include "soc.h"
#include <fsl_common.h>

#ifdef CONFIG_UART_K20
#include <uart.h>
#include <console/uart_console.h>
#include <serial/uart_k20_priv.h>
#endif /* CONFIG_UART_K20 */

/*
 * UART configuration
 */

#ifdef CONFIG_UART_K20

static int uart_k20_init(struct device *dev)
{
	uint32_t scgc4;

	ARG_UNUSED(dev);

	/* Although it is possible to modify the bits through
	 * *sim directly, the following code saves about 20 bytes
	 * of ROM space, compared to direct modification.
	 */
	scgc4 = SIM->SCGC4;

#ifdef CONFIG_UART_K20_PORT_0
	scgc4 |= SIM_SCGC4_UART0(1);
#endif

#ifdef CONFIG_UART_K20_PORT_1
	scgc4 |= SIM_SCGC4_UART1(1);
#endif

#ifdef CONFIG_UART_K20_PORT_2
	scgc4 |= SIM_SCGC4_UART2(1);
#endif

#ifdef CONFIG_UART_K20_PORT_3
	scgc4 |= SIM_SCGC4_UART3(1);
#endif

	SIM->SCGC4 = scgc4;

#ifdef CONFIG_UART_K20_PORT_4
	SIM->SCGC1 |= SIM_SCGC1_UART4(1);
#endif

	return 0;
}

DEVICE_INIT(_uart_k20_init, "", uart_k20_init,
				NULL, NULL,
				PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

#endif /* CONFIG_UART_K20 */