Amol Jadi | ca4f4c9 | 2011-01-13 20:19:34 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2009, Google Inc. |
| 3 | * All rights reserved. |
| 4 | * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * * Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * * Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in |
| 13 | * the documentation and/or other materials provided with the |
| 14 | * distribution. |
| 15 | * * Neither the name of Google, Inc. nor the names of its contributors |
| 16 | * may be used to endorse or promote products derived from this |
| 17 | * software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 22 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 23 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 26 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 27 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 30 | * SUCH DAMAGE. |
| 31 | */ |
| 32 | |
| 33 | #include <debug.h> |
| 34 | #include <lib/ptable.h> |
| 35 | #include <smem.h> |
| 36 | #include <platform/iomap.h> |
| 37 | #include <reg.h> |
| 38 | |
| 39 | #define LINUX_MACHTYPE_8960_SIM 3230 |
| 40 | #define LINUX_MACHTYPE_8960_RUMI3 3231 |
| 41 | |
Amol Jadi | cd43ea0 | 2011-02-15 20:56:04 -0800 | [diff] [blame^] | 42 | extern unsigned int mmc_boot_main(unsigned char slot, unsigned int base); |
| 43 | extern void mdelay(unsigned msecs); |
| 44 | extern void dmb(void); |
| 45 | |
Amol Jadi | ca4f4c9 | 2011-01-13 20:19:34 -0800 | [diff] [blame] | 46 | void target_init(void) |
| 47 | { |
| 48 | dprintf(INFO, "target_init()\n"); |
| 49 | |
| 50 | if(mmc_boot_main(MMC_SLOT, MSM_SDC1_BASE)) |
| 51 | { |
| 52 | dprintf(CRITICAL, "mmc init failed!"); |
| 53 | ASSERT(0); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | unsigned board_machtype(void) |
| 58 | { |
| 59 | /* TODO: Add a run time mechanism to detect if we are running on RUMI3. |
Amol Jadi | cd43ea0 | 2011-02-15 20:56:04 -0800 | [diff] [blame^] | 60 | * Until then, PLATFORM_MSM8960_RUMI3 can be defined as compile time |
Amol Jadi | ca4f4c9 | 2011-01-13 20:19:34 -0800 | [diff] [blame] | 61 | * option for RUMI3. |
| 62 | */ |
| 63 | |
Amol Jadi | cd43ea0 | 2011-02-15 20:56:04 -0800 | [diff] [blame^] | 64 | #if PLATFORM_MSM8960_RUMI3 |
Amol Jadi | ca4f4c9 | 2011-01-13 20:19:34 -0800 | [diff] [blame] | 65 | return LINUX_MACHTYPE_8960_RUMI3; |
| 66 | #else |
| 67 | return LINUX_MACHTYPE_8960_SIM; |
| 68 | #endif |
| 69 | } |
| 70 | |
| 71 | void reboot_device(unsigned reboot_reason) |
| 72 | { |
| 73 | /* Reset WDG0 counter */ |
| 74 | writel(1,MSM_WDT0_RST); |
| 75 | /* Disable WDG0 */ |
| 76 | writel(0,MSM_WDT0_EN); |
| 77 | /* Set WDG0 bark time */ |
| 78 | writel(0x31F3,MSM_WDT0_BT); |
| 79 | /* Enable WDG0 */ |
| 80 | writel(3,MSM_WDT0_EN); |
| 81 | dmb(); |
| 82 | /* Enable WDG output */ |
| 83 | writel(3,MSM_TCSR_BASE + TCSR_WDOG_CFG); |
| 84 | mdelay(10000); |
| 85 | dprintf (CRITICAL, "Rebooting failed\n"); |
| 86 | return; |
| 87 | } |
| 88 | |
| 89 | unsigned check_reboot_mode(void) |
| 90 | { |
| 91 | unsigned restart_reason = 0; |
Amol Jadi | cd43ea0 | 2011-02-15 20:56:04 -0800 | [diff] [blame^] | 92 | void *restart_reason_addr = (void*)0x401FFFFC; |
Amol Jadi | ca4f4c9 | 2011-01-13 20:19:34 -0800 | [diff] [blame] | 93 | |
| 94 | /* Read reboot reason and scrub it */ |
| 95 | restart_reason = readl(restart_reason_addr); |
| 96 | writel(0x00, restart_reason_addr); |
| 97 | |
| 98 | return restart_reason; |
| 99 | } |
| 100 | |
| 101 | void target_battery_charging_enable(unsigned enable, unsigned disconnect) |
| 102 | { |
| 103 | } |