Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * (C) Copyright 2000 |
| 5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 6 | * |
| 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 23 | * MA 02111-1307 USA |
| 24 | */ |
| 25 | |
| 26 | #include <common.h> |
| 27 | #include <asm/fsl_law.h> |
| 28 | #include <asm/io.h> |
| 29 | |
| 30 | #define LAWAR_EN 0x80000000 |
Becky Bruce | 2a15f75 | 2008-01-23 16:31:05 -0600 | [diff] [blame] | 31 | #define FSL_HW_NUM_LAWS 10 /* number of LAWs in the hw implementation */ |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 32 | |
| 33 | void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id) |
| 34 | { |
| 35 | volatile u32 *base = (volatile u32 *)(CFG_IMMR + 0xc08); |
| 36 | volatile u32 *lawbar = base + 8 * idx; |
| 37 | volatile u32 *lawar = base + 8 * idx + 2; |
| 38 | |
| 39 | out_be32(lawbar, addr >> 12); |
| 40 | out_be32(lawar, LAWAR_EN | ((u32)id << 20) | (u32)sz); |
| 41 | |
| 42 | return ; |
| 43 | } |
| 44 | |
| 45 | void disable_law(u8 idx) |
| 46 | { |
| 47 | volatile u32 *base = (volatile u32 *)(CFG_IMMR + 0xc08); |
| 48 | volatile u32 *lawbar = base + 8 * idx; |
| 49 | volatile u32 *lawar = base + 8 * idx + 2; |
| 50 | |
| 51 | out_be32(lawar, 0); |
| 52 | out_be32(lawbar, 0); |
| 53 | |
| 54 | return; |
| 55 | } |
| 56 | |
Becky Bruce | 2a15f75 | 2008-01-23 16:31:05 -0600 | [diff] [blame] | 57 | void print_laws(void) |
| 58 | { |
| 59 | volatile u32 *base = (volatile u32 *)(CFG_IMMR + 0xc08); |
| 60 | volatile u32 *lawbar = base; |
| 61 | volatile u32 *lawar = base + 2; |
| 62 | int i; |
| 63 | |
| 64 | printf("\nLocal Access Window Configuration\n"); |
| 65 | for(i = 0; i < FSL_HW_NUM_LAWS; i++) { |
| 66 | printf("\tLAWBAR%d : 0x%08x, LAWAR%d : 0x%08x\n", |
| 67 | i, in_be32(lawbar), i, in_be32(lawar)); |
| 68 | lawbar += 8; |
| 69 | lawar += 8; |
| 70 | } |
| 71 | |
| 72 | return; |
| 73 | } |
| 74 | |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 75 | void init_laws(void) |
| 76 | { |
| 77 | int i; |
| 78 | u8 law_idx = 0; |
| 79 | |
| 80 | for (i = 0; i < num_law_entries; i++) { |
| 81 | if (law_table[i].index != -1) |
| 82 | law_idx = law_table[i].index; |
| 83 | |
| 84 | set_law(law_idx++, law_table[i].addr, |
| 85 | law_table[i].size, law_table[i].trgt_id); |
| 86 | } |
| 87 | |
| 88 | return ; |
| 89 | } |