blob: 31bb7545b5343eadb8700f95f83f0092b9fccec8 [file] [log] [blame]
Kumar Gala418ec852009-03-19 02:32:23 -05001/*
2 * Copyright 2008-2009 Freescale Semiconductor, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * Version 2 as published by the Free Software Foundation.
7 */
8
Kumar Gala83d40df2008-01-16 01:13:58 -06009#ifndef _FSL_LAW_H_
10#define _FSL_LAW_H_
11
12#include <asm/io.h>
13
Kumar Gala418ec852009-03-19 02:32:23 -050014#define LAW_EN 0x80000000
15
Kumar Gala83d40df2008-01-16 01:13:58 -060016#define SET_LAW_ENTRY(idx, a, sz, trgt) \
17 { .index = idx, .addr = a, .size = sz, .trgt_id = trgt }
18
Kumar Galaf0600542008-06-11 00:44:10 -050019#define SET_LAW(a, sz, trgt) \
20 { .index = -1, .addr = a, .size = sz, .trgt_id = trgt }
21
Kumar Gala83d40df2008-01-16 01:13:58 -060022enum law_size {
23 LAW_SIZE_4K = 0xb,
24 LAW_SIZE_8K,
25 LAW_SIZE_16K,
26 LAW_SIZE_32K,
27 LAW_SIZE_64K,
28 LAW_SIZE_128K,
29 LAW_SIZE_256K,
30 LAW_SIZE_512K,
31 LAW_SIZE_1M,
32 LAW_SIZE_2M,
33 LAW_SIZE_4M,
34 LAW_SIZE_8M,
35 LAW_SIZE_16M,
36 LAW_SIZE_32M,
37 LAW_SIZE_64M,
38 LAW_SIZE_128M,
39 LAW_SIZE_256M,
40 LAW_SIZE_512M,
41 LAW_SIZE_1G,
42 LAW_SIZE_2G,
43 LAW_SIZE_4G,
44 LAW_SIZE_8G,
45 LAW_SIZE_16G,
46 LAW_SIZE_32G,
47};
48
Kumar Gala418ec852009-03-19 02:32:23 -050049#ifdef CONFIG_FSL_CORENET
50enum law_trgt_if {
51 LAW_TRGT_IF_PCIE_1 = 0x00,
52 LAW_TRGT_IF_PCIE_2 = 0x01,
53 LAW_TRGT_IF_PCIE_3 = 0x02,
54 LAW_TRGT_IF_RIO_1 = 0x08,
55 LAW_TRGT_IF_RIO_2 = 0x09,
56
57 LAW_TRGT_IF_DDR_1 = 0x10,
58 LAW_TRGT_IF_DDR_2 = 0x11, /* 2nd controller */
59 LAW_TRGT_IF_DDR_INTRLV = 0x14,
60
61 LAW_TRGT_IF_BMAN = 0x18,
62 LAW_TRGT_IF_DCSR = 0x1d,
63 LAW_TRGT_IF_LBC = 0x1f,
64 LAW_TRGT_IF_QMAN = 0x3c,
65};
66#define LAW_TRGT_IF_DDR LAW_TRGT_IF_DDR_1
67#else
Kumar Gala83d40df2008-01-16 01:13:58 -060068enum law_trgt_if {
69 LAW_TRGT_IF_PCI = 0x00,
70 LAW_TRGT_IF_PCI_2 = 0x01,
71#ifndef CONFIG_MPC8641
72 LAW_TRGT_IF_PCIE_1 = 0x02,
73#endif
Srikanth Srinivasan8d949af2009-01-21 17:17:33 -060074#if !defined(CONFIG_MPC8572) && !defined(CONFIG_P2020)
Kumar Gala83d40df2008-01-16 01:13:58 -060075 LAW_TRGT_IF_PCIE_3 = 0x03,
76#endif
77 LAW_TRGT_IF_LBC = 0x04,
78 LAW_TRGT_IF_CCSR = 0x08,
79 LAW_TRGT_IF_DDR_INTRLV = 0x0b,
80 LAW_TRGT_IF_RIO = 0x0c,
81 LAW_TRGT_IF_DDR = 0x0f,
82 LAW_TRGT_IF_DDR_2 = 0x16, /* 2nd controller */
83};
84#define LAW_TRGT_IF_DDR_1 LAW_TRGT_IF_DDR
85#define LAW_TRGT_IF_PCI_1 LAW_TRGT_IF_PCI
86#define LAW_TRGT_IF_PCIX LAW_TRGT_IF_PCI
87#define LAW_TRGT_IF_PCIE_2 LAW_TRGT_IF_PCI_2
88
89#ifdef CONFIG_MPC8641
90#define LAW_TRGT_IF_PCIE_1 LAW_TRGT_IF_PCI
91#endif
92
Srikanth Srinivasan8d949af2009-01-21 17:17:33 -060093#if defined(CONFIG_MPC8572) || defined(CONFIG_P2020)
Kumar Gala83d40df2008-01-16 01:13:58 -060094#define LAW_TRGT_IF_PCIE_3 LAW_TRGT_IF_PCI
95#endif
Kumar Gala418ec852009-03-19 02:32:23 -050096#endif /* CONFIG_FSL_CORENET */
Kumar Gala83d40df2008-01-16 01:13:58 -060097
98struct law_entry {
99 int index;
100 phys_addr_t addr;
101 enum law_size size;
102 enum law_trgt_if trgt_id;
103};
104
105extern void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
Kumar Galaf0600542008-06-11 00:44:10 -0500106extern int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
Kumar Galaba04f702008-06-10 16:16:02 -0500107extern int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
Kumar Galaf784e322008-08-26 15:01:28 -0500108extern int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id);
Kumar Gala418ec852009-03-19 02:32:23 -0500109extern struct law_entry find_law(phys_addr_t addr);
Kumar Gala83d40df2008-01-16 01:13:58 -0600110extern void disable_law(u8 idx);
111extern void init_laws(void);
Becky Bruceddcebcb2008-01-23 16:31:05 -0600112extern void print_laws(void);
Kumar Gala83d40df2008-01-16 01:13:58 -0600113
114/* define in board code */
115extern struct law_entry law_table[];
116extern int num_law_entries;
117#endif