Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008, Google Inc. |
| 3 | * All rights reserved. |
| 4 | * |
Channagoud Kadabi | 3acfb74 | 2011-11-15 18:19:32 +0530 | [diff] [blame^] | 5 | * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved. |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in |
| 14 | * the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google, Inc. nor the names of its contributors |
| 17 | * may be used to endorse or promote products derived from this |
| 18 | * software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 27 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 28 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 30 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 31 | * SUCH DAMAGE. |
| 32 | */ |
| 33 | |
Amol Jadi | aeda4e6 | 2011-07-19 18:07:29 -0700 | [diff] [blame] | 34 | #include <reg.h> |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 35 | #include <debug.h> |
| 36 | #include <kernel/thread.h> |
| 37 | #include <platform/debug.h> |
Amol Jadi | aeda4e6 | 2011-07-19 18:07:29 -0700 | [diff] [blame] | 38 | #include <platform/iomap.h> |
Channagoud Kadabi | 3acfb74 | 2011-11-15 18:19:32 +0530 | [diff] [blame^] | 39 | #include <platform/irqs.h> |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 40 | #include <mddi.h> |
| 41 | #include <dev/fbcon.h> |
Channagoud Kadabi | 2199269 | 2011-08-12 14:59:38 +0530 | [diff] [blame] | 42 | #include <dev/gpio.h> |
Aparna Mallavarapu | 45869c3 | 2011-08-05 13:22:35 +0530 | [diff] [blame] | 43 | #include <smem.h> |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 44 | |
| 45 | static struct fbcon_config *fb_config; |
| 46 | |
Amol Jadi | aeda4e6 | 2011-07-19 18:07:29 -0700 | [diff] [blame] | 47 | static uint32_t ticks_per_sec = 0; |
| 48 | |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 49 | void platform_init_interrupts(void); |
| 50 | void platform_init_timer(); |
| 51 | |
| 52 | void uart3_clock_init(void); |
| 53 | void uart_init(void); |
| 54 | |
| 55 | void acpu_clock_init(void); |
| 56 | |
| 57 | void mddi_clock_init(unsigned num, unsigned rate); |
| 58 | |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 59 | extern void mipi_dsi_shutdown(void); |
| 60 | |
Aparna Mallavarapu | 45869c3 | 2011-08-05 13:22:35 +0530 | [diff] [blame] | 61 | unsigned board_msm_id(void); |
| 62 | |
Channagoud Kadabi | 3acfb74 | 2011-11-15 18:19:32 +0530 | [diff] [blame^] | 63 | static int target_uses_qgic; |
| 64 | int debug_timer = 0, gpt_timer = 0, usb_hs_int = 0; |
| 65 | |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 66 | void platform_early_init(void) |
| 67 | { |
Shashank Mittal | 2fad67f | 2011-04-08 19:45:10 -0700 | [diff] [blame] | 68 | #if WITH_DEBUG_UART |
| 69 | uart1_clock_init(); |
| 70 | uart_init(); |
| 71 | #endif |
Channagoud Kadabi | 81ba110 | 2011-10-01 16:37:59 +0530 | [diff] [blame] | 72 | if(machine_is_8x25()) { |
| 73 | qgic_init(); |
| 74 | target_uses_qgic = 1; |
Channagoud Kadabi | 3acfb74 | 2011-11-15 18:19:32 +0530 | [diff] [blame^] | 75 | debug_timer = (GIC_PPI_START + 2); |
| 76 | gpt_timer = (GIC_PPI_START + 3); |
| 77 | usb_hs_int = INT_USB_HS_GIC; |
Channagoud Kadabi | 81ba110 | 2011-10-01 16:37:59 +0530 | [diff] [blame] | 78 | } else { |
| 79 | platform_init_interrupts(); |
Channagoud Kadabi | 3acfb74 | 2011-11-15 18:19:32 +0530 | [diff] [blame^] | 80 | debug_timer = 8; |
| 81 | gpt_timer = 7; |
| 82 | usb_hs_int = INT_USB_HS_VIC; |
Channagoud Kadabi | 81ba110 | 2011-10-01 16:37:59 +0530 | [diff] [blame] | 83 | } |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 84 | platform_init_timer(); |
| 85 | } |
| 86 | |
| 87 | void platform_init(void) |
| 88 | { |
| 89 | dprintf(INFO, "platform_init()\n"); |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 90 | acpu_clock_init(); |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | void display_init(void) |
| 94 | { |
| 95 | #if DISPLAY_TYPE_MDDI |
| 96 | fb_config = mddi_init(); |
| 97 | ASSERT(fb_config); |
| 98 | fbcon_setup(fb_config); |
| 99 | #endif |
| 100 | #if DISPLAY_TYPE_LCDC |
| 101 | fb_config = lcdc_init(); |
| 102 | ASSERT(fb_config); |
| 103 | fbcon_setup(fb_config); |
| 104 | #endif |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 105 | #if DISPLAY_TYPE_MIPI |
Channagoud Kadabi | 2199269 | 2011-08-12 14:59:38 +0530 | [diff] [blame] | 106 | dprintf(SPEW, "display_init()\n"); |
| 107 | panel_dsi_init(); |
| 108 | fb_config = mipi_init(); |
| 109 | ASSERT(fb_config); |
| 110 | fbcon_setup(fb_config); |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 111 | #endif |
| 112 | } |
| 113 | |
| 114 | void display_shutdown(void) |
| 115 | { |
| 116 | #if DISPLAY_TYPE_MIPI |
Channagoud Kadabi | 3acfb74 | 2011-11-15 18:19:32 +0530 | [diff] [blame^] | 117 | if (machine_is_evb()) |
Channagoud Kadabi | d53664b | 2011-12-28 16:39:15 +0530 | [diff] [blame] | 118 | return; |
Channagoud Kadabi | 2199269 | 2011-08-12 14:59:38 +0530 | [diff] [blame] | 119 | dprintf(SPEW, "display_shutdown()\n"); |
| 120 | mipi_dsi_shutdown(); |
| 121 | /* Power down DSI bridge chip */ |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 122 | gpio_set(128, 0x1); |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 123 | #endif |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 124 | } |
Amol Jadi | 4421e65 | 2011-06-16 15:00:48 -0700 | [diff] [blame] | 125 | |
| 126 | void platform_uninit(void) |
| 127 | { |
Amol Jadi | 4421e65 | 2011-06-16 15:00:48 -0700 | [diff] [blame] | 128 | #if DISPLAY_SPLASH_SCREEN |
| 129 | display_shutdown(); |
| 130 | #endif |
Amol Jadi | d7cfc03 | 2012-01-09 16:56:08 -0800 | [diff] [blame] | 131 | |
| 132 | platform_uninit_timer(); |
Amol Jadi | 4421e65 | 2011-06-16 15:00:48 -0700 | [diff] [blame] | 133 | } |
Amol Jadi | aeda4e6 | 2011-07-19 18:07:29 -0700 | [diff] [blame] | 134 | |
| 135 | /* Initialize DGT timer */ |
| 136 | void platform_init_timer(void) |
| 137 | { |
| 138 | /* disable timer */ |
| 139 | writel(0, DGT_ENABLE); |
| 140 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 141 | ticks_per_sec = 19200000; /* Uses TCXO (19.2 MHz) */ |
Amol Jadi | aeda4e6 | 2011-07-19 18:07:29 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | /* Returns timer ticks per sec */ |
| 145 | uint32_t platform_tick_rate(void) |
| 146 | { |
| 147 | return ticks_per_sec; |
| 148 | } |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 149 | |
Aparna Mallavarapu | 45869c3 | 2011-08-05 13:22:35 +0530 | [diff] [blame] | 150 | bool machine_is_7x25a(void) |
| 151 | { |
| 152 | if ((board_msm_id() == MSM7225A) || (board_msm_id() == MSM7625A)) |
| 153 | return 1; |
| 154 | else |
| 155 | return 0; |
| 156 | } |
Channagoud Kadabi | 2199269 | 2011-08-12 14:59:38 +0530 | [diff] [blame] | 157 | |
| 158 | /* Toggle RESET pin of the DSI Client before sending |
| 159 | * panel init commands |
| 160 | */ |
| 161 | void panel_dsi_init(void) |
| 162 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 163 | gpio_set(128, 0x1); |
Aparna Mallavarapu | 34144df | 2011-08-20 21:16:03 +0530 | [diff] [blame] | 164 | mdelay(5); |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 165 | gpio_set(128, 0x0); |
| 166 | gpio_set(129, 0x1); |
Channagoud Kadabi | 2199269 | 2011-08-12 14:59:38 +0530 | [diff] [blame] | 167 | gpio_config(129, GPIO_OUTPUT); |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 168 | gpio_set(129, 0x0); |
| 169 | gpio_set(129, 0x1); |
Channagoud Kadabi | 2199269 | 2011-08-12 14:59:38 +0530 | [diff] [blame] | 170 | mdelay(10); |
| 171 | } |
Channagoud Kadabi | 81ba110 | 2011-10-01 16:37:59 +0530 | [diff] [blame] | 172 | |
| 173 | int target_supports_qgic() |
| 174 | { |
| 175 | return target_uses_qgic; |
| 176 | } |