Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 1 | /* |
Dipen Dudhat | 00c4294 | 2011-01-20 16:29:35 +0530 | [diff] [blame] | 2 | * Copyright 2008-2011 Freescale Semiconductor, Inc. |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 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 Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 9 | #ifndef _FSL_LAW_H_ |
| 10 | #define _FSL_LAW_H_ |
| 11 | |
| 12 | #include <asm/io.h> |
| 13 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 14 | #define LAW_EN 0x80000000 |
| 15 | |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 16 | #define SET_LAW_ENTRY(idx, a, sz, trgt) \ |
| 17 | { .index = idx, .addr = a, .size = sz, .trgt_id = trgt } |
| 18 | |
Kumar Gala | 75639e0 | 2008-06-11 00:44:10 -0500 | [diff] [blame] | 19 | #define SET_LAW(a, sz, trgt) \ |
| 20 | { .index = -1, .addr = a, .size = sz, .trgt_id = trgt } |
| 21 | |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 22 | enum 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 Yang | 019b293 | 2009-12-09 14:26:08 +0800 | [diff] [blame] | 49 | #define law_size_bits(sz) (__ilog2_u64(sz) - 1) |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 50 | #define lawar_size(x) (1ULL << ((x & 0x3f) + 1)) |
Li Yang | 019b293 | 2009-12-09 14:26:08 +0800 | [diff] [blame] | 51 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 52 | #ifdef CONFIG_FSL_CORENET |
| 53 | enum 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 Gala | 74e78b6 | 2010-04-28 04:02:21 -0500 | [diff] [blame] | 57 | LAW_TRGT_IF_PCIE_4 = 0x03, |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 58 | 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 */ |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 63 | LAW_TRGT_IF_DDR_3 = 0x12, |
| 64 | LAW_TRGT_IF_DDR_4 = 0x13, |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 65 | LAW_TRGT_IF_DDR_INTRLV = 0x14, |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 66 | LAW_TRGT_IF_DDR_INTLV_34 = 0x15, |
| 67 | LAW_TRGT_IF_DDR_INTLV_123 = 0x17, |
| 68 | LAW_TRGT_IF_DDR_INTLV_1234 = 0x16, |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 69 | LAW_TRGT_IF_BMAN = 0x18, |
| 70 | LAW_TRGT_IF_DCSR = 0x1d, |
| 71 | LAW_TRGT_IF_LBC = 0x1f, |
| 72 | LAW_TRGT_IF_QMAN = 0x3c, |
| 73 | }; |
| 74 | #define LAW_TRGT_IF_DDR LAW_TRGT_IF_DDR_1 |
Prabhakar Kushwaha | 4fc2aac | 2012-08-15 06:24:15 +0000 | [diff] [blame] | 75 | #define LAW_TRGT_IF_IFC LAW_TRGT_IF_LBC |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 76 | #else |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 77 | enum law_trgt_if { |
| 78 | LAW_TRGT_IF_PCI = 0x00, |
| 79 | LAW_TRGT_IF_PCI_2 = 0x01, |
| 80 | #ifndef CONFIG_MPC8641 |
| 81 | LAW_TRGT_IF_PCIE_1 = 0x02, |
| 82 | #endif |
Srikanth Srinivasan | a864f32 | 2009-01-21 17:17:33 -0600 | [diff] [blame] | 83 | #if !defined(CONFIG_MPC8572) && !defined(CONFIG_P2020) |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 84 | LAW_TRGT_IF_PCIE_3 = 0x03, |
| 85 | #endif |
| 86 | LAW_TRGT_IF_LBC = 0x04, |
| 87 | LAW_TRGT_IF_CCSR = 0x08, |
| 88 | LAW_TRGT_IF_DDR_INTRLV = 0x0b, |
| 89 | LAW_TRGT_IF_RIO = 0x0c, |
Li Yang | 019b293 | 2009-12-09 14:26:08 +0800 | [diff] [blame] | 90 | LAW_TRGT_IF_RIO_2 = 0x0d, |
Roy Zang | 1de20b0 | 2011-02-03 22:14:19 -0600 | [diff] [blame] | 91 | LAW_TRGT_IF_DPAA_SWP_SRAM = 0x0e, |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 92 | LAW_TRGT_IF_DDR = 0x0f, |
| 93 | LAW_TRGT_IF_DDR_2 = 0x16, /* 2nd controller */ |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 94 | /* place holder for 3-way and 4-way interleaving */ |
| 95 | LAW_TRGT_IF_DDR_3, |
| 96 | LAW_TRGT_IF_DDR_4, |
| 97 | LAW_TRGT_IF_DDR_INTLV_34, |
| 98 | LAW_TRGT_IF_DDR_INTLV_123, |
| 99 | LAW_TRGT_IF_DDR_INTLV_1234, |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 100 | }; |
| 101 | #define LAW_TRGT_IF_DDR_1 LAW_TRGT_IF_DDR |
| 102 | #define LAW_TRGT_IF_PCI_1 LAW_TRGT_IF_PCI |
| 103 | #define LAW_TRGT_IF_PCIX LAW_TRGT_IF_PCI |
| 104 | #define LAW_TRGT_IF_PCIE_2 LAW_TRGT_IF_PCI_2 |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 105 | #define LAW_TRGT_IF_RIO_1 LAW_TRGT_IF_RIO |
Dipen Dudhat | 00c4294 | 2011-01-20 16:29:35 +0530 | [diff] [blame] | 106 | #define LAW_TRGT_IF_IFC LAW_TRGT_IF_LBC |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 107 | |
| 108 | #ifdef CONFIG_MPC8641 |
| 109 | #define LAW_TRGT_IF_PCIE_1 LAW_TRGT_IF_PCI |
| 110 | #endif |
| 111 | |
Srikanth Srinivasan | a864f32 | 2009-01-21 17:17:33 -0600 | [diff] [blame] | 112 | #if defined(CONFIG_MPC8572) || defined(CONFIG_P2020) |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 113 | #define LAW_TRGT_IF_PCIE_3 LAW_TRGT_IF_PCI |
| 114 | #endif |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 115 | #endif /* CONFIG_FSL_CORENET */ |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 116 | |
| 117 | struct law_entry { |
| 118 | int index; |
| 119 | phys_addr_t addr; |
| 120 | enum law_size size; |
| 121 | enum law_trgt_if trgt_id; |
| 122 | }; |
| 123 | |
| 124 | extern void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id); |
Kumar Gala | 75639e0 | 2008-06-11 00:44:10 -0500 | [diff] [blame] | 125 | extern int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id); |
Kumar Gala | a9abb00 | 2008-06-10 16:16:02 -0500 | [diff] [blame] | 126 | extern int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id); |
Kumar Gala | 61ed053 | 2008-08-26 15:01:28 -0500 | [diff] [blame] | 127 | extern int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id); |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 128 | extern struct law_entry find_law(phys_addr_t addr); |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 129 | extern void disable_law(u8 idx); |
| 130 | extern void init_laws(void); |
Becky Bruce | 2a15f75 | 2008-01-23 16:31:05 -0600 | [diff] [blame] | 131 | extern void print_laws(void); |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 132 | |
| 133 | /* define in board code */ |
| 134 | extern struct law_entry law_table[]; |
| 135 | extern int num_law_entries; |
| 136 | #endif |