Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | /* Architecture-specific VCM functions */ |
| 15 | |
| 16 | /* Device attributes */ |
| 17 | |
| 18 | /* |
| 19 | * Sharing attributes. Pick only one. |
| 20 | */ |
| 21 | #define VCM_DEV_ATTR_NON_SH (0x00) |
| 22 | #define VCM_DEV_ATTR_SH (0x04) |
| 23 | |
| 24 | /* |
| 25 | * Caching attributes. Pick only one. |
| 26 | */ |
| 27 | #define VCM_DEV_ATTR_NONCACHED (0x00) |
| 28 | #define VCM_DEV_ATTR_CACHED_WB_WA (0x01) |
| 29 | #define VCM_DEV_ATTR_CACHED_WB_NWA (0x02) |
| 30 | #define VCM_DEV_ATTR_CACHED_WT (0x03) |
| 31 | |
| 32 | /* |
| 33 | * A "good" default set of attributes: shareable and non-cacheable. |
| 34 | */ |
| 35 | #define VCM_DEV_DEFAULT_ATTR (VCM_DEV_ATTR_SH | VCM_DEV_ATTR_NONCACHED) |
| 36 | |
| 37 | /** |
| 38 | * set_arm7_pte_attr() - Set ARMv7 page table attributes |
| 39 | * pt_base Virtual address of the first-level page table |
| 40 | * @va Virtual address whose attributes are to be set |
| 41 | * @len Page size used to map the given virtual address |
| 42 | * @attr Attributes to set for this mapping. |
| 43 | * |
| 44 | * Modify a mapping attribute. The base address of the page table must |
| 45 | * be a virtual address containing a valid ARMv7 page table. The |
| 46 | * virtual address must refer to an existing mapping and must be |
| 47 | * aligned to the length with which it was mapped. The mapping length |
| 48 | * must similarly be the same as was specified when the mapping was |
| 49 | * made (one of 4KB, 64KB, 1MB, or 16MB). The attribute must be one of |
| 50 | * the shareability attributes above ORed with one of the cacheability |
| 51 | * attributes. Any previous attributes are completely replaced by the |
| 52 | * most recent call to this function. This function only sets the |
| 53 | * cacheability and shareability attributes. This is accomplished by |
| 54 | * modifying the TEX class and the S bit in the PTE. It is an error to |
| 55 | * call this function without having called vcm_setup_tex_classes at |
| 56 | * least once. |
| 57 | * |
| 58 | * The return value is zero on success and non-zero on failure. |
| 59 | */ |
| 60 | int set_arm7_pte_attr(unsigned long pt_base, unsigned long va, |
| 61 | unsigned long len, unsigned int attr); |
| 62 | |
| 63 | |
| 64 | /** |
| 65 | * cpu_set_attr() - Set page table attributes on the CPU's page tables |
| 66 | * @va Virtual address whose attributes are to be set |
| 67 | * @len Page size used to map the given virtual address |
| 68 | * @attr Attributes to set for this mapping. |
| 69 | * |
| 70 | * Modify a mapping attribute within the ARM page tables. The va must |
| 71 | * refer to an existing mapping and must be aligned to the length with |
| 72 | * which it was mapped. The mapping length must similarly be the same |
| 73 | * as was specified when the mapping was made (one of 4KB, 64KB, 1MB, |
| 74 | * or 16MB). The attribute must be one of the shareability attributes |
| 75 | * above ORed with one of the cacheability attributes. Any previous |
| 76 | * attributes are completely replaced by the most recent call to this |
| 77 | * function. This function only sets the cacheability and shareability |
| 78 | * attributes. This is accomplished by modifying the TEX class and the |
| 79 | * S bit in the PTE. It is an error to call this function without |
| 80 | * having called vcm_setup_tex_classes at least once. It is an error |
| 81 | * to call this function on any system using a memory configuration |
| 82 | * that is anything OTHER than ARMv7 with TEX remap enabled. Only the |
| 83 | * HW page tables are modified; the Linux page tables are left |
| 84 | * untouched. |
| 85 | * |
| 86 | * The return value is zero on success and non-zero on failure. |
| 87 | */ |
| 88 | int cpu_set_attr(unsigned long va, unsigned long len, unsigned int attr); |
| 89 | |
| 90 | |
| 91 | /** |
| 92 | * vcm_setup_tex_classes() - Prepare TEX class table for use |
| 93 | * |
| 94 | * Initialize the attribute mapping table by examining the TEX classes |
| 95 | * used by the CPU and finding the classes that match the device |
| 96 | * attributes (VCM_DEV_xx) defined above. This function is only |
| 97 | * relevant if TEX remap is enabled. The results will be unpredictable |
| 98 | * and irrelevant if TEX remap is not in use. It is an error to call |
| 99 | * this function in any system using a memory configuration of |
| 100 | * anything OTHER than ARMv7 with TEX remap enabled. |
| 101 | * |
| 102 | * The return value is zero on success or non-zero on failure. In the |
| 103 | * present version, a failure will result in a panic. |
| 104 | */ |
| 105 | int vcm_setup_tex_classes(void); |