blob: af7249b237246d3f01a57a21262e2b9d7a058122 [file] [log] [blame]
Avaneesh Kumar Dwivedi7b506d22017-03-17 16:41:13 +05301/* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
Kyle Yane45fa022016-08-29 11:40:26 -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#ifndef __MSM_PERIPHERAL_LOADER_H
13#define __MSM_PERIPHERAL_LOADER_H
14
15struct device;
16struct module;
17struct pil_priv;
18
19/**
20 * struct pil_desc - PIL descriptor
21 * @name: string used for pil_get()
22 * @fw_name: firmware name
23 * @dev: parent device
24 * @ops: callback functions
25 * @owner: module the descriptor belongs to
26 * @proxy_timeout: delay in ms until proxy vote is removed
27 * @flags: bitfield for image flags
28 * @priv: DON'T USE - internal only
29 * @attrs: DMA attributes to be used during dma allocation.
30 * @proxy_unvote_irq: IRQ to trigger a proxy unvote. proxy_timeout
31 * is ignored if this is set.
32 * @map_fw_mem: Custom function used to map physical address space to virtual.
33 * This defaults to ioremap if not specified.
34 * @unmap_fw_mem: Custom function used to undo mapping by map_fw_mem.
35 * This defaults to iounmap if not specified.
36 * @shutdown_fail: Set if PIL op for shutting down subsystem fails.
37 * @modem_ssr: true if modem is restarting, false if booting for first time.
Avaneesh Kumar Dwivedi7b506d22017-03-17 16:41:13 +053038 * @clear_fw_region: Clear fw region on failure in loading.
Kyle Yane45fa022016-08-29 11:40:26 -070039 * @subsys_vmid: memprot id for the subsystem.
40 */
41struct pil_desc {
42 const char *name;
43 const char *fw_name;
44 struct device *dev;
45 const struct pil_reset_ops *ops;
46 struct module *owner;
47 unsigned long proxy_timeout;
48 unsigned long flags;
49#define PIL_SKIP_ENTRY_CHECK BIT(0)
50 struct pil_priv *priv;
51 unsigned long attrs;
52 unsigned int proxy_unvote_irq;
53 void * (*map_fw_mem)(phys_addr_t phys, size_t size, void *data);
54 void (*unmap_fw_mem)(void *virt, size_t size, void *data);
55 void *map_data;
56 bool shutdown_fail;
57 bool modem_ssr;
Avaneesh Kumar Dwivedi7b506d22017-03-17 16:41:13 +053058 bool clear_fw_region;
Kyle Yane45fa022016-08-29 11:40:26 -070059 u32 subsys_vmid;
60};
61
62/**
63 * struct pil_image_info - info in IMEM about image and where it is loaded
64 * @name: name of image (may or may not be NULL terminated)
65 * @start: indicates physical address where image starts (little endian)
66 * @size: size of image (little endian)
67 */
68struct pil_image_info {
69 char name[8];
70 __le64 start;
71 __le32 size;
72} __attribute__((__packed__));
73
74/**
75 * struct pil_reset_ops - PIL operations
76 * @init_image: prepare an image for authentication
77 * @mem_setup: prepare the image memory region
78 * @verify_blob: authenticate a program segment, called once for each loadable
79 * program segment (optional)
80 * @proxy_vote: make proxy votes before auth_and_reset (optional)
81 * @auth_and_reset: boot the processor
82 * @proxy_unvote: remove any proxy votes (optional)
83 * @deinit_image: restore actions performed in init_image if necessary
84 * @shutdown: shutdown the processor
85 */
86struct pil_reset_ops {
87 int (*init_image)(struct pil_desc *pil, const u8 *metadata,
88 size_t size);
89 int (*mem_setup)(struct pil_desc *pil, phys_addr_t addr, size_t size);
90 int (*verify_blob)(struct pil_desc *pil, phys_addr_t phy_addr,
91 size_t size);
92 int (*proxy_vote)(struct pil_desc *pil);
93 int (*auth_and_reset)(struct pil_desc *pil);
94 void (*proxy_unvote)(struct pil_desc *pil);
95 int (*deinit_image)(struct pil_desc *pil);
96 int (*shutdown)(struct pil_desc *pil);
97};
98
99#ifdef CONFIG_MSM_PIL
100extern int pil_desc_init(struct pil_desc *desc);
101extern int pil_boot(struct pil_desc *desc);
102extern void pil_shutdown(struct pil_desc *desc);
103extern void pil_free_memory(struct pil_desc *desc);
104extern void pil_desc_release(struct pil_desc *desc);
105extern phys_addr_t pil_get_entry_addr(struct pil_desc *desc);
106extern int pil_do_ramdump(struct pil_desc *desc, void *ramdump_dev);
107extern int pil_assign_mem_to_subsys(struct pil_desc *desc, phys_addr_t addr,
108 size_t size);
109extern int pil_assign_mem_to_linux(struct pil_desc *desc, phys_addr_t addr,
110 size_t size);
111extern int pil_assign_mem_to_subsys_and_linux(struct pil_desc *desc,
112 phys_addr_t addr, size_t size);
113extern int pil_reclaim_mem(struct pil_desc *desc, phys_addr_t addr, size_t size,
114 int VMid);
115extern bool is_timeout_disabled(void);
116#else
117static inline int pil_desc_init(struct pil_desc *desc) { return 0; }
118static inline int pil_boot(struct pil_desc *desc) { return 0; }
119static inline void pil_shutdown(struct pil_desc *desc) { }
120static inline void pil_free_memory(struct pil_desc *desc) { }
121static inline void pil_desc_release(struct pil_desc *desc) { }
122static inline phys_addr_t pil_get_entry_addr(struct pil_desc *desc)
123{
124 return 0;
125}
126static inline int pil_do_ramdump(struct pil_desc *desc, void *ramdump_dev)
127{
128 return 0;
129}
130static inline int pil_assign_mem_to_subsys(struct pil_desc *desc,
131 phys_addr_t addr, size_t size)
132{
133 return 0;
134}
135static inline int pil_assign_mem_to_linux(struct pil_desc *desc,
136 phys_addr_t addr, size_t size)
137{
138 return 0;
139}
140static inline int pil_assign_mem_to_subsys_and_linux(struct pil_desc *desc,
141 phys_addr_t addr, size_t size)
142{
143 return 0;
144}
145static inline int pil_reclaim_mem(struct pil_desc *desc, phys_addr_t addr,
146 size_t size, int VMid)
147{
148 return 0;
149}
150extern bool is_timeout_disabled(void) { return false; }
151#endif
152
153#endif