blob: 13caffd96e27eee4a595af054f4dde576ca4f4d5 [file] [log] [blame]
Kumar Gala65e6c322009-03-19 02:32:23 -05001/*
Dipen Dudhat00c42942011-01-20 16:29:35 +05302 * Copyright 2008-2011 Freescale Semiconductor, Inc.
Kumar Gala65e6c322009-03-19 02:32:23 -05003 *
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 Gala95fd2f62008-01-16 01:13:58 -06009#ifndef _FSL_LAW_H_
10#define _FSL_LAW_H_
11
12#include <asm/io.h>
13
Kumar Gala65e6c322009-03-19 02:32:23 -050014#define LAW_EN 0x80000000
15
Kumar Gala95fd2f62008-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 Gala75639e02008-06-11 00:44:10 -050019#define SET_LAW(a, sz, trgt) \
20 { .index = -1, .addr = a, .size = sz, .trgt_id = trgt }
21
Kumar Gala95fd2f62008-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
Li Yang019b2932009-12-09 14:26:08 +080049#define law_size_bits(sz) (__ilog2_u64(sz) - 1)
Becky Bruceeb891f02010-06-17 11:37:23 -050050#define lawar_size(x) (1ULL << ((x & 0x3f) + 1))
Li Yang019b2932009-12-09 14:26:08 +080051
Kumar Gala65e6c322009-03-19 02:32:23 -050052#ifdef CONFIG_FSL_CORENET
53enum law_trgt_if {
54 LAW_TRGT_IF_PCIE_1 = 0x00,
55 LAW_TRGT_IF_PCIE_2 = 0x01,
56 LAW_TRGT_IF_PCIE_3 = 0x02,
Kumar Gala74e78b62010-04-28 04:02:21 -050057 LAW_TRGT_IF_PCIE_4 = 0x03,
Kumar Gala65e6c322009-03-19 02:32:23 -050058 LAW_TRGT_IF_RIO_1 = 0x08,
59 LAW_TRGT_IF_RIO_2 = 0x09,
60
61 LAW_TRGT_IF_DDR_1 = 0x10,
62 LAW_TRGT_IF_DDR_2 = 0x11, /* 2nd controller */
63 LAW_TRGT_IF_DDR_INTRLV = 0x14,
64
65 LAW_TRGT_IF_BMAN = 0x18,
66 LAW_TRGT_IF_DCSR = 0x1d,
67 LAW_TRGT_IF_LBC = 0x1f,
68 LAW_TRGT_IF_QMAN = 0x3c,
69};
70#define LAW_TRGT_IF_DDR LAW_TRGT_IF_DDR_1
71#else
Kumar Gala95fd2f62008-01-16 01:13:58 -060072enum law_trgt_if {
73 LAW_TRGT_IF_PCI = 0x00,
74 LAW_TRGT_IF_PCI_2 = 0x01,
75#ifndef CONFIG_MPC8641
76 LAW_TRGT_IF_PCIE_1 = 0x02,
77#endif
Srikanth Srinivasana864f322009-01-21 17:17:33 -060078#if !defined(CONFIG_MPC8572) && !defined(CONFIG_P2020)
Kumar Gala95fd2f62008-01-16 01:13:58 -060079 LAW_TRGT_IF_PCIE_3 = 0x03,
80#endif
81 LAW_TRGT_IF_LBC = 0x04,
82 LAW_TRGT_IF_CCSR = 0x08,
83 LAW_TRGT_IF_DDR_INTRLV = 0x0b,
84 LAW_TRGT_IF_RIO = 0x0c,
Li Yang019b2932009-12-09 14:26:08 +080085 LAW_TRGT_IF_RIO_2 = 0x0d,
Roy Zang1de20b02011-02-03 22:14:19 -060086 LAW_TRGT_IF_DPAA_SWP_SRAM = 0x0e,
Kumar Gala95fd2f62008-01-16 01:13:58 -060087 LAW_TRGT_IF_DDR = 0x0f,
88 LAW_TRGT_IF_DDR_2 = 0x16, /* 2nd controller */
89};
90#define LAW_TRGT_IF_DDR_1 LAW_TRGT_IF_DDR
91#define LAW_TRGT_IF_PCI_1 LAW_TRGT_IF_PCI
92#define LAW_TRGT_IF_PCIX LAW_TRGT_IF_PCI
93#define LAW_TRGT_IF_PCIE_2 LAW_TRGT_IF_PCI_2
Kumar Gala8975d7a2010-12-30 12:09:53 -060094#define LAW_TRGT_IF_RIO_1 LAW_TRGT_IF_RIO
Dipen Dudhat00c42942011-01-20 16:29:35 +053095#define LAW_TRGT_IF_IFC LAW_TRGT_IF_LBC
Kumar Gala95fd2f62008-01-16 01:13:58 -060096
97#ifdef CONFIG_MPC8641
98#define LAW_TRGT_IF_PCIE_1 LAW_TRGT_IF_PCI
99#endif
100
Srikanth Srinivasana864f322009-01-21 17:17:33 -0600101#if defined(CONFIG_MPC8572) || defined(CONFIG_P2020)
Kumar Gala95fd2f62008-01-16 01:13:58 -0600102#define LAW_TRGT_IF_PCIE_3 LAW_TRGT_IF_PCI
103#endif
Kumar Gala65e6c322009-03-19 02:32:23 -0500104#endif /* CONFIG_FSL_CORENET */
Kumar Gala95fd2f62008-01-16 01:13:58 -0600105
106struct law_entry {
107 int index;
108 phys_addr_t addr;
109 enum law_size size;
110 enum law_trgt_if trgt_id;
111};
112
113extern void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
Kumar Gala75639e02008-06-11 00:44:10 -0500114extern int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
Kumar Galaa9abb002008-06-10 16:16:02 -0500115extern int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
Kumar Gala61ed0532008-08-26 15:01:28 -0500116extern int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id);
Kumar Gala65e6c322009-03-19 02:32:23 -0500117extern struct law_entry find_law(phys_addr_t addr);
Kumar Gala95fd2f62008-01-16 01:13:58 -0600118extern void disable_law(u8 idx);
119extern void init_laws(void);
Becky Bruce2a15f752008-01-23 16:31:05 -0600120extern void print_laws(void);
Kumar Gala95fd2f62008-01-16 01:13:58 -0600121
122/* define in board code */
123extern struct law_entry law_table[];
124extern int num_law_entries;
125#endif