Pushkar Joshi | 7ffaa99 | 2013-02-05 10:23:40 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Hanumant Singh | 4bcc4e5 | 2012-07-19 11:31:59 -0700 | [diff] [blame] | 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 | #include <asm/cacheflush.h> |
| 13 | #include <linux/slab.h> |
| 14 | #include <linux/io.h> |
| 15 | #include <linux/init.h> |
Hanumant Singh | 4bcc4e5 | 2012-07-19 11:31:59 -0700 | [diff] [blame] | 16 | #include <linux/export.h> |
| 17 | #include <mach/msm_iomap.h> |
| 18 | #include <mach/msm_memory_dump.h> |
| 19 | |
| 20 | |
| 21 | /*TODO: Needs to be set to correct value */ |
Hanumant Singh | ae35862 | 2012-08-22 21:14:16 -0700 | [diff] [blame] | 22 | #define DUMP_TABLE_OFFSET 0x14 |
Hanumant Singh | 4bcc4e5 | 2012-07-19 11:31:59 -0700 | [diff] [blame] | 23 | #define MSM_DUMP_TABLE_VERSION MK_TABLE(1, 0) |
| 24 | |
| 25 | static struct msm_memory_dump mem_dump_data; |
| 26 | |
Hanumant Singh | 4bcc4e5 | 2012-07-19 11:31:59 -0700 | [diff] [blame] | 27 | int msm_dump_table_register(struct msm_client_dump *client_entry) |
| 28 | { |
| 29 | struct msm_client_dump *entry; |
| 30 | struct msm_dump_table *table = mem_dump_data.dump_table_ptr; |
| 31 | |
| 32 | if (!table || table->num_entries >= MAX_NUM_CLIENTS) |
| 33 | return -EINVAL; |
| 34 | entry = &table->client_entries[table->num_entries]; |
| 35 | entry->id = client_entry->id; |
| 36 | entry->start_addr = client_entry->start_addr; |
| 37 | entry->end_addr = client_entry->end_addr; |
| 38 | table->num_entries++; |
| 39 | /* flush cache */ |
| 40 | dmac_flush_range(table, table + sizeof(struct msm_dump_table)); |
| 41 | return 0; |
| 42 | } |
| 43 | EXPORT_SYMBOL(msm_dump_table_register); |
| 44 | |
| 45 | static int __init init_memory_dump(void) |
| 46 | { |
| 47 | struct msm_dump_table *table; |
| 48 | |
| 49 | mem_dump_data.dump_table_ptr = kzalloc(sizeof(struct msm_dump_table), |
| 50 | GFP_KERNEL); |
| 51 | if (!mem_dump_data.dump_table_ptr) { |
| 52 | printk(KERN_ERR "unable to allocate memory for dump table\n"); |
| 53 | return -ENOMEM; |
| 54 | } |
| 55 | table = mem_dump_data.dump_table_ptr; |
| 56 | table->version = MSM_DUMP_TABLE_VERSION; |
| 57 | mem_dump_data.dump_table_phys = virt_to_phys(table); |
Hanumant Singh | ae35862 | 2012-08-22 21:14:16 -0700 | [diff] [blame] | 58 | writel_relaxed(mem_dump_data.dump_table_phys, |
| 59 | MSM_IMEM_BASE + DUMP_TABLE_OFFSET); |
Hanumant Singh | 4bcc4e5 | 2012-07-19 11:31:59 -0700 | [diff] [blame] | 60 | printk(KERN_INFO "MSM Memory Dump table set up\n"); |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | early_initcall(init_memory_dump); |
| 65 | |