blob: 8923398db66f01eef7777faaa08f2d324674e4ed [file] [log] [blame]
Steven Miao24a70cf2013-09-12 16:36:16 +08001/*
2 * arch/blackfin/mach-common/scb-init.c - reprogram system cross bar priority
3 *
4 * Copyright 2012 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
Steven Miao24a70cf2013-09-12 16:36:16 +08009#include <linux/errno.h>
10#include <linux/kernel.h>
11#include <asm/scb.h>
12
13__attribute__((l1_text))
14inline void scb_mi_write(unsigned long scb_mi_arbw, unsigned int slots,
15 unsigned char *scb_mi_prio)
16{
17 unsigned int i;
18
19 for (i = 0; i < slots; ++i)
20 bfin_write32(scb_mi_arbw, (i << SCB_SLOT_OFFSET) | scb_mi_prio[i]);
21}
22
23__attribute__((l1_text))
24inline void scb_mi_read(unsigned long scb_mi_arbw, unsigned int slots,
25 unsigned char *scb_mi_prio)
26{
27 unsigned int i;
28
29 for (i = 0; i < slots; ++i) {
30 bfin_write32(scb_mi_arbw, (0xFF << SCB_SLOT_OFFSET) | i);
31 scb_mi_prio[i] = bfin_read32(scb_mi_arbw);
32 }
33}
34
35__attribute__((l1_text))
36void init_scb(void)
37{
38 unsigned int i, j;
39 unsigned char scb_tmp_prio[32];
40
41 pr_info("Init System Crossbar\n");
42 for (i = 0; scb_data[i].scb_mi_arbr > 0; ++i) {
43
44 scb_mi_write(scb_data[i].scb_mi_arbw, scb_data[i].scb_mi_slots, scb_data[i].scb_mi_prio);
45
46 pr_debug("scb priority at 0x%lx:\n", scb_data[i].scb_mi_arbr);
47 scb_mi_read(scb_data[i].scb_mi_arbw, scb_data[i].scb_mi_slots, scb_tmp_prio);
48 for (j = 0; j < scb_data[i].scb_mi_slots; ++j)
49 pr_debug("slot %d = %d\n", j, scb_tmp_prio[j]);
50 }
51
52}