]> git.sur5r.net Git - u-boot/blob - arch/arm/mach-at91/matrix.c
arm: at91/spl: matrix: move matrix init to separate file
[u-boot] / arch / arm / mach-at91 / matrix.c
1 /*
2  * Copyright (C) 2015 Atmel Corporation
3  *                    Wenyou Yang <wenyou.yang@atmel.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <common.h>
9 #include <asm/io.h>
10 #include <asm/arch/sama5_matrix.h>
11
12 void matrix_init(void)
13 {
14         struct atmel_matrix *h64mx = (struct atmel_matrix *)ATMEL_BASE_MATRIX0;
15         struct atmel_matrix *h32mx = (struct atmel_matrix *)ATMEL_BASE_MATRIX1;
16         int i;
17
18         /* Disable the write protect */
19         writel(ATMEL_MATRIX_WPMR_WPKEY & ~ATMEL_MATRIX_WPMR_WPEN, &h64mx->wpmr);
20         writel(ATMEL_MATRIX_WPMR_WPKEY & ~ATMEL_MATRIX_WPMR_WPEN, &h32mx->wpmr);
21
22         /* DDR port 1 ~ poart 7, slave number is: 4 ~ 10 */
23         for (i = 4; i <= 10; i++) {
24                 writel(0x000f0f0f, &h64mx->ssr[i]);
25                 writel(0x0000ffff, &h64mx->sassr[i]);
26                 writel(0x0000000f, &h64mx->srtsr[i]);
27         }
28
29         /* CS3 */
30         writel(0x00c0c0c0, &h32mx->ssr[3]);
31         writel(0xff000000, &h32mx->sassr[3]);
32         writel(0xff000000, &h32mx->srtsr[3]);
33
34         /* NFC SRAM */
35         writel(0x00010101, &h32mx->ssr[4]);
36         writel(0x00000001, &h32mx->sassr[4]);
37         writel(0x00000001, &h32mx->srtsr[4]);
38
39         /* Configure Programmable Security peripherals on matrix 64 */
40         writel(readl(&h64mx->spselr[0]) | 0x00080000, &h64mx->spselr[0]);
41         writel(readl(&h64mx->spselr[1]) | 0x00180000, &h64mx->spselr[1]);
42         writel(readl(&h64mx->spselr[2]) | 0x00000008, &h64mx->spselr[2]);
43
44         /* Configure Programmable Security peripherals on matrix 32 */
45         writel(readl(&h32mx->spselr[0]) | 0xFFC00000, &h32mx->spselr[0]);
46         writel(readl(&h32mx->spselr[1]) | 0x60E3FFFF, &h32mx->spselr[1]);
47
48         /* Enable the write protect */
49         writel(ATMEL_MATRIX_WPMR_WPKEY | ATMEL_MATRIX_WPMR_WPEN, &h64mx->wpmr);
50         writel(ATMEL_MATRIX_WPMR_WPKEY | ATMEL_MATRIX_WPMR_WPEN, &h32mx->wpmr);
51 }