blob: 34f8f59cf80c3dc83a133f56bbbf1999bd2323ed [file] [log] [blame]
Pushkar Joshi7ffaa992013-02-05 10:23:40 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Hanumant Singh4bcc4e52012-07-19 11:31:59 -07002 *
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 Singh4bcc4e52012-07-19 11:31:59 -070016#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 Singhae358622012-08-22 21:14:16 -070022#define DUMP_TABLE_OFFSET 0x14
Hanumant Singh4bcc4e52012-07-19 11:31:59 -070023#define MSM_DUMP_TABLE_VERSION MK_TABLE(1, 0)
24
25static struct msm_memory_dump mem_dump_data;
26
Hanumant Singh4bcc4e52012-07-19 11:31:59 -070027int 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}
43EXPORT_SYMBOL(msm_dump_table_register);
44
45static 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 Singhae358622012-08-22 21:14:16 -070058 writel_relaxed(mem_dump_data.dump_table_phys,
59 MSM_IMEM_BASE + DUMP_TABLE_OFFSET);
Hanumant Singh4bcc4e52012-07-19 11:31:59 -070060 printk(KERN_INFO "MSM Memory Dump table set up\n");
61 return 0;
62}
63
64early_initcall(init_memory_dump);
65