Dhoat Harpal | 4ff370d | 2016-11-14 16:41:04 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2013,2017 The Linux Foundation. All rights reserved. |
Chris Lew | b4791c3 | 2016-08-01 11:58:55 -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 | |
| 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 | #include <soc/qcom/ramdump.h> |
| 18 | |
| 19 | |
| 20 | #define SMD_HEAP_SIZE 512 |
Dhoat Harpal | 4ff370d | 2016-11-14 16:41:04 +0530 | [diff] [blame] | 21 | extern uint32_t smem_max_items; |
Chris Lew | b4791c3 | 2016-08-01 11:58:55 -0700 | [diff] [blame] | 22 | |
| 23 | struct smem_heap_info { |
| 24 | unsigned int initialized; |
| 25 | unsigned int free_offset; |
| 26 | unsigned int heap_remaining; |
| 27 | unsigned int reserved; |
| 28 | }; |
| 29 | |
| 30 | struct smem_heap_entry { |
| 31 | unsigned int allocated; |
| 32 | unsigned int offset; |
| 33 | unsigned int size; |
| 34 | unsigned int reserved; /* [1:0] reserved, [31:2] aux smem base addr */ |
| 35 | }; |
| 36 | #define BASE_ADDR_MASK 0xfffffffc |
| 37 | |
| 38 | struct smem_proc_comm { |
| 39 | unsigned int command; |
| 40 | unsigned int status; |
| 41 | unsigned int data1; |
| 42 | unsigned int data2; |
| 43 | }; |
| 44 | |
| 45 | struct smem_shared { |
| 46 | struct smem_proc_comm proc_comm[4]; |
| 47 | unsigned int version[32]; |
| 48 | struct smem_heap_info heap_info; |
| 49 | struct smem_heap_entry heap_toc[SMD_HEAP_SIZE]; |
| 50 | }; |
| 51 | |
| 52 | struct smem_area { |
| 53 | phys_addr_t phys_addr; |
| 54 | resource_size_t size; |
| 55 | void __iomem *virt_addr; |
| 56 | }; |
| 57 | |
| 58 | /* used for unit testing spinlocks */ |
| 59 | remote_spinlock_t *smem_get_remote_spinlock(void); |
| 60 | |
| 61 | bool smem_initialized_check(void); |
| 62 | |
| 63 | /** |
| 64 | * smem_module_init_notifier_register() - Register a smem module |
| 65 | * init notifier block |
| 66 | * @nb: Notifier block to be registered |
| 67 | * |
| 68 | * In order to mark the dependency on SMEM Driver module initialization |
| 69 | * register a notifier using this API. Once the smem module_init is |
| 70 | * done, notification will be passed to the registered module. |
| 71 | */ |
| 72 | int smem_module_init_notifier_register(struct notifier_block *nb); |
| 73 | |
| 74 | /** |
| 75 | * smem_module_init_notifier_register() - Unregister a smem module |
| 76 | * init notifier block |
| 77 | * @nb: Notifier block to be unregistered |
| 78 | */ |
| 79 | int smem_module_init_notifier_unregister(struct notifier_block *nb); |
| 80 | |
| 81 | /** |
| 82 | * smem_get_free_space() - Get the available allocation free space for a |
| 83 | * partition |
| 84 | * |
| 85 | * @to_proc: remote SMEM host. Determines the applicable partition |
| 86 | * @returns: size in bytes available to allocate |
| 87 | * |
| 88 | * Helper function for SMD so that SMD only scans the channel allocation |
| 89 | * table for a partition when it is reasonably certain that a channel has |
| 90 | * actually been created, because scanning can be expensive. Creating a channel |
| 91 | * will consume some of the free space in a partition, so SMD can compare the |
| 92 | * last free space size against the current free space size to determine if |
| 93 | * a channel may have been created. SMD can't do this directly, because the |
| 94 | * necessary partition internals are restricted to just SMEM. |
| 95 | */ |
| 96 | unsigned int smem_get_free_space(unsigned int to_proc); |
| 97 | |
| 98 | /** |
| 99 | * smem_get_version() - Get the smem user version number |
| 100 | * |
| 101 | * @idx: SMEM user idx in SMEM_VERSION_INFO table. |
| 102 | * @returns: smem version number if success otherwise zero. |
| 103 | */ |
| 104 | unsigned int smem_get_version(unsigned int idx); |
| 105 | #endif /* _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_ */ |