2 * Copyright (C) 2015 Atmel Corporation
3 * Wenyou Yang <wenyou.yang@atmel.com>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/sama5_matrix.h>
12 void matrix_init(void)
14 struct atmel_matrix *h64mx = (struct atmel_matrix *)ATMEL_BASE_MATRIX0;
15 struct atmel_matrix *h32mx = (struct atmel_matrix *)ATMEL_BASE_MATRIX1;
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);
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]);
30 writel(0x00c0c0c0, &h32mx->ssr[3]);
31 writel(0xff000000, &h32mx->sassr[3]);
32 writel(0xff000000, &h32mx->srtsr[3]);
35 writel(0x00010101, &h32mx->ssr[4]);
36 writel(0x00000001, &h32mx->sassr[4]);
37 writel(0x00000001, &h32mx->srtsr[4]);
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]);
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]);
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);