blob: 3fa842fbd55f0b0eddc8b2d268ce7f77db981b40 [file] [log] [blame]
Jeff Hugo5ba15fe2013-05-06 14:24:24 -06001/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
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
13#ifndef _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_
14#define _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_
15
16#include <linux/remote_spinlock.h>
17
18#include <mach/ramdump.h>
19
Jeff Hugo5ba15fe2013-05-06 14:24:24 -060020#define SMD_HEAP_SIZE 512
21
22struct smem_heap_info {
23 unsigned initialized;
24 unsigned free_offset;
25 unsigned heap_remaining;
26 unsigned reserved;
27};
28
29struct smem_heap_entry {
30 unsigned allocated;
31 unsigned offset;
32 unsigned size;
33 unsigned reserved; /* bits 1:0 reserved, bits 31:2 aux smem base addr */
34};
35#define BASE_ADDR_MASK 0xfffffffc
36
37struct smem_proc_comm {
38 unsigned command;
39 unsigned status;
40 unsigned data1;
41 unsigned data2;
42};
43
44struct smem_shared {
45 struct smem_proc_comm proc_comm[4];
46 unsigned version[32];
47 struct smem_heap_info heap_info;
48 struct smem_heap_entry heap_toc[SMD_HEAP_SIZE];
49};
50
51struct smem_area {
52 phys_addr_t phys_addr;
53 resource_size_t size;
54 void __iomem *virt_addr;
55};
56
Jeff Hugo5ba15fe2013-05-06 14:24:24 -060057/* used for unit testing spinlocks */
58remote_spinlock_t *smem_get_remote_spinlock(void);
Jeff Hugob9fb9402013-05-15 09:58:54 -060059
Jeff Hugo429dc2c2013-05-28 15:06:07 -060060bool smem_initialized_check(void);
Jeff Hugo7cc06b12013-06-17 16:13:18 -060061
62/**
63 * smem_module_init_notifier_register() - Register a smem module
64 * init notifier block
65 * @nb: Notifier block to be registered
66 *
67 * In order to mark the dependency on SMEM Driver module initialization
68 * register a notifier using this API. Once the smem module_init is
69 * done, notification will be passed to the registered module.
70 */
71int smem_module_init_notifier_register(struct notifier_block *nb);
72
73/**
74 * smem_module_init_notifier_register() - Unregister a smem module
75 * init notifier block
76 * @nb: Notifier block to be unregistered
77 */
78int smem_module_init_notifier_unregister(struct notifier_block *nb);
Jeff Hugo830785d2013-08-27 13:20:10 -060079
80/**
81 * smem_get_free_space() - Get the available allocation free space for a
82 * partition
83 *
84 * @to_proc: remote SMEM host. Determines the applicable partition
85 * @returns: size in bytes available to allocate
86 *
87 * Helper function for SMD so that SMD only scans the channel allocation
88 * table for a partition when it is reasonably certain that a channel has
89 * actually been created, because scanning can be expensive. Creating a channel
90 * will consume some of the free space in a partition, so SMD can compare the
91 * last free space size against the current free space size to determine if
92 * a channel may have been created. SMD can't do this directly, because the
93 * necessary partition internals are restricted to just SMEM.
94 */
95unsigned smem_get_free_space(unsigned to_proc);
Jeff Hugo5ba15fe2013-05-06 14:24:24 -060096#endif /* _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_ */