Amol Jadi | cd43ea0 | 2011-02-15 20:56:04 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in |
| 11 | * the documentation and/or other materials provided with the |
| 12 | * distribution. |
| 13 | * * Neither the name of Google, Inc. nor the names of its contributors |
| 14 | * may be used to endorse or promote products derived from this |
| 15 | * software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 21 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 24 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 25 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 27 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 28 | * SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | #include <debug.h> |
| 32 | #include <reg.h> |
| 33 | #include <platform/iomap.h> |
Amol Jadi | db1edb3 | 2011-07-18 14:24:46 -0700 | [diff] [blame] | 34 | #include <qgic.h> |
Amol Jadi | c52c8a3 | 2011-07-12 11:27:04 -0700 | [diff] [blame] | 35 | #include <uart_dm.h> |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 36 | #include <dev/fbcon.h> |
Amol Jadi | da05574 | 2011-06-14 16:15:12 -0700 | [diff] [blame] | 37 | #include <mmu.h> |
| 38 | #include <arch/arm/mmu.h> |
Amol Jadi | cd43ea0 | 2011-02-15 20:56:04 -0800 | [diff] [blame] | 39 | |
Amol Jadi | cd43ea0 | 2011-02-15 20:56:04 -0800 | [diff] [blame] | 40 | extern void platform_init_timer(void); |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 41 | extern void mipi_panel_reset(void); |
| 42 | extern void mipi_dsi_panel_power_on(void); |
| 43 | extern void mdp_clock_init(void); |
| 44 | extern void mmss_clock_init(void); |
| 45 | extern struct fbcon_config *mipi_init(void); |
| 46 | extern void mipi_dsi_shutdown(void); |
Amol Jadi | cd43ea0 | 2011-02-15 20:56:04 -0800 | [diff] [blame] | 47 | |
Amol Jadi | da05574 | 2011-06-14 16:15:12 -0700 | [diff] [blame] | 48 | #define MB (1024*1024) |
| 49 | |
| 50 | #define MSM_IOMAP_SIZE ((MSM_IOMAP_END - MSM_IOMAP_BASE)/MB) |
| 51 | |
| 52 | /* LK memory - cacheable, write through */ |
| 53 | #define LK_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \ |
| 54 | MMU_MEMORY_AP_READ_WRITE) |
| 55 | |
| 56 | /* Kernel region - cacheable, write through */ |
| 57 | #define KERNEL_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \ |
| 58 | MMU_MEMORY_AP_READ_WRITE) |
| 59 | |
| 60 | /* Scratch region - cacheable, write through */ |
| 61 | #define SCRATCH_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \ |
| 62 | MMU_MEMORY_AP_READ_WRITE) |
| 63 | |
| 64 | /* Peripherals - non-shared device */ |
| 65 | #define IOMAP_MEMORY (MMU_MEMORY_TYPE_DEVICE_NON_SHARED | \ |
| 66 | MMU_MEMORY_AP_READ_WRITE) |
| 67 | |
| 68 | |
| 69 | mmu_section_t mmu_section_table[] = { |
| 70 | /* Physical addr, Virtual addr, Size (in MB), Flags */ |
| 71 | {MEMBASE, MEMBASE, (MEMSIZE/MB), LK_MEMORY}, |
| 72 | {BASE_ADDR, BASE_ADDR, 44, KERNEL_MEMORY}, |
| 73 | {SCRATCH_ADDR, SCRATCH_ADDR, 128, SCRATCH_MEMORY}, |
| 74 | {MSM_IOMAP_BASE, MSM_IOMAP_BASE, MSM_IOMAP_SIZE, IOMAP_MEMORY}, |
| 75 | }; |
| 76 | |
Amol Jadi | cd43ea0 | 2011-02-15 20:56:04 -0800 | [diff] [blame] | 77 | void platform_early_init(void) |
| 78 | { |
Amol Jadi | c52c8a3 | 2011-07-12 11:27:04 -0700 | [diff] [blame] | 79 | uart_init(target_uart_gsbi()); |
Amol Jadi | db1edb3 | 2011-07-18 14:24:46 -0700 | [diff] [blame] | 80 | qgic_init(); |
Amol Jadi | cd43ea0 | 2011-02-15 20:56:04 -0800 | [diff] [blame] | 81 | platform_init_timer(); |
| 82 | } |
| 83 | |
| 84 | void platform_init(void) |
| 85 | { |
| 86 | dprintf(INFO, "platform_init()\n"); |
| 87 | } |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 88 | |
| 89 | void display_init(void){ |
| 90 | struct fbcon_config *fb_cfg; |
| 91 | |
Kinson Chik | c1ad946 | 2011-07-20 17:40:06 -0700 | [diff] [blame^] | 92 | panel_backlight_on(); |
| 93 | |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 94 | mipi_dsi_panel_power_on(); |
| 95 | mipi_panel_reset(); |
| 96 | |
| 97 | mdp_clock_init(); |
| 98 | mmss_clock_init(); |
| 99 | |
| 100 | fb_cfg = mipi_init(); |
| 101 | fbcon_setup(fb_cfg); |
| 102 | } |
| 103 | |
| 104 | void display_shutdown(void) |
| 105 | { |
| 106 | mipi_dsi_shutdown(); |
| 107 | } |
Amol Jadi | 4421e65 | 2011-06-16 15:00:48 -0700 | [diff] [blame] | 108 | |
| 109 | void platform_uninit(void) |
| 110 | { |
| 111 | platform_uninit_timer(); |
| 112 | #if DISPLAY_SPLASH_SCREEN |
| 113 | display_shutdown(); |
| 114 | #endif |
| 115 | } |
| 116 | |
Amol Jadi | da05574 | 2011-06-14 16:15:12 -0700 | [diff] [blame] | 117 | /* Setup memory for this platform */ |
| 118 | void platform_init_mmu_mappings(void) |
| 119 | { |
| 120 | uint32_t i; |
| 121 | uint32_t sections; |
| 122 | uint32_t table_size = ARRAY_SIZE(mmu_section_table); |
| 123 | |
| 124 | for (i = 0; i < table_size; i++) |
| 125 | { |
| 126 | sections = mmu_section_table[i].num_of_sections; |
| 127 | |
| 128 | while (sections--) |
| 129 | { |
| 130 | arm_mmu_map_section(mmu_section_table[i].paddress + sections*MB, |
| 131 | mmu_section_table[i].vaddress + sections*MB, |
| 132 | mmu_section_table[i].flags); |
| 133 | } |
| 134 | } |
| 135 | } |