Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -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 | */ |
Stephen Boyd | e4174b2 | 2011-09-20 00:19:43 -0700 | [diff] [blame] | 12 | #ifndef __MSM_PERIPHERAL_LOADER_H |
| 13 | #define __MSM_PERIPHERAL_LOADER_H |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 14 | |
Stephen Boyd | 3f4da32 | 2011-08-30 01:03:23 -0700 | [diff] [blame] | 15 | struct device; |
Stephen Boyd | 6d67d25 | 2011-09-27 11:50:05 -0700 | [diff] [blame] | 16 | struct module; |
Stephen Boyd | 163f1c3 | 2012-06-29 13:20:20 -0700 | [diff] [blame] | 17 | struct pil_priv; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 18 | |
Stephen Boyd | 36974ec | 2012-03-22 01:30:59 -0700 | [diff] [blame] | 19 | /** |
| 20 | * struct pil_desc - PIL descriptor |
| 21 | * @name: string used for pil_get() |
Stephen Boyd | 36974ec | 2012-03-22 01:30:59 -0700 | [diff] [blame] | 22 | * @dev: parent device |
| 23 | * @ops: callback functions |
| 24 | * @owner: module the descriptor belongs to |
| 25 | * @proxy_timeout: delay in ms until proxy vote is removed |
Stephen Boyd | 3030c25 | 2012-08-08 17:24:05 -0700 | [diff] [blame] | 26 | * @flags: bitfield for image flags |
Stephen Boyd | 163f1c3 | 2012-06-29 13:20:20 -0700 | [diff] [blame] | 27 | * @priv: DON'T USE - internal only |
Seemanta Dutta | d21a797 | 2013-03-05 12:16:17 -0800 | [diff] [blame] | 28 | * @proxy_unvote_irq: IRQ to trigger a proxy unvote. proxy_timeout |
| 29 | * is ignored if this is set. |
Stephen Boyd | 36974ec | 2012-03-22 01:30:59 -0700 | [diff] [blame] | 30 | */ |
Stephen Boyd | 3f4da32 | 2011-08-30 01:03:23 -0700 | [diff] [blame] | 31 | struct pil_desc { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 32 | const char *name; |
Stephen Boyd | 3f4da32 | 2011-08-30 01:03:23 -0700 | [diff] [blame] | 33 | struct device *dev; |
| 34 | const struct pil_reset_ops *ops; |
Stephen Boyd | 6d67d25 | 2011-09-27 11:50:05 -0700 | [diff] [blame] | 35 | struct module *owner; |
Stephen Boyd | 36974ec | 2012-03-22 01:30:59 -0700 | [diff] [blame] | 36 | unsigned long proxy_timeout; |
Stephen Boyd | 3030c25 | 2012-08-08 17:24:05 -0700 | [diff] [blame] | 37 | unsigned long flags; |
| 38 | #define PIL_SKIP_ENTRY_CHECK BIT(0) |
Stephen Boyd | 163f1c3 | 2012-06-29 13:20:20 -0700 | [diff] [blame] | 39 | struct pil_priv *priv; |
Seemanta Dutta | d21a797 | 2013-03-05 12:16:17 -0800 | [diff] [blame] | 40 | unsigned int proxy_unvote_irq; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
Stephen Boyd | 36974ec | 2012-03-22 01:30:59 -0700 | [diff] [blame] | 43 | /** |
| 44 | * struct pil_reset_ops - PIL operations |
| 45 | * @init_image: prepare an image for authentication |
Stephen Boyd | 379e733 | 2012-08-08 18:04:21 -0700 | [diff] [blame] | 46 | * @mem_setup: prepare the image memory region |
Stephen Boyd | 36974ec | 2012-03-22 01:30:59 -0700 | [diff] [blame] | 47 | * @verify_blob: authenticate a program segment, called once for each loadable |
| 48 | * program segment (optional) |
| 49 | * @proxy_vote: make proxy votes before auth_and_reset (optional) |
| 50 | * @auth_and_reset: boot the processor |
| 51 | * @proxy_unvote: remove any proxy votes (optional) |
| 52 | * @shutdown: shutdown the processor |
| 53 | */ |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 54 | struct pil_reset_ops { |
Stephen Boyd | 3f4da32 | 2011-08-30 01:03:23 -0700 | [diff] [blame] | 55 | int (*init_image)(struct pil_desc *pil, const u8 *metadata, |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 56 | size_t size); |
Stephen Boyd | 379e733 | 2012-08-08 18:04:21 -0700 | [diff] [blame] | 57 | int (*mem_setup)(struct pil_desc *pil, phys_addr_t addr, size_t size); |
Tianyi Gou | 74a9399 | 2013-04-10 19:58:21 -0700 | [diff] [blame^] | 58 | int (*verify_blob)(struct pil_desc *pil, phys_addr_t phy_addr, |
| 59 | size_t size); |
Stephen Boyd | 36974ec | 2012-03-22 01:30:59 -0700 | [diff] [blame] | 60 | int (*proxy_vote)(struct pil_desc *pil); |
Stephen Boyd | 3f4da32 | 2011-08-30 01:03:23 -0700 | [diff] [blame] | 61 | int (*auth_and_reset)(struct pil_desc *pil); |
Stephen Boyd | 36974ec | 2012-03-22 01:30:59 -0700 | [diff] [blame] | 62 | void (*proxy_unvote)(struct pil_desc *pil); |
Stephen Boyd | 3f4da32 | 2011-08-30 01:03:23 -0700 | [diff] [blame] | 63 | int (*shutdown)(struct pil_desc *pil); |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
Stephen Boyd | 866f9a2 | 2012-07-10 18:56:53 -0700 | [diff] [blame] | 66 | #ifdef CONFIG_MSM_PIL |
Stephen Boyd | 163f1c3 | 2012-06-29 13:20:20 -0700 | [diff] [blame] | 67 | extern int pil_desc_init(struct pil_desc *desc); |
| 68 | extern int pil_boot(struct pil_desc *desc); |
| 69 | extern void pil_shutdown(struct pil_desc *desc); |
| 70 | extern void pil_desc_release(struct pil_desc *desc); |
Stephen Boyd | 3030c25 | 2012-08-08 17:24:05 -0700 | [diff] [blame] | 71 | extern phys_addr_t pil_get_entry_addr(struct pil_desc *desc); |
Stephen Boyd | 1066777 | 2012-11-28 16:45:35 -0800 | [diff] [blame] | 72 | extern int pil_do_ramdump(struct pil_desc *desc, void *ramdump_dev); |
Stephen Boyd | 866f9a2 | 2012-07-10 18:56:53 -0700 | [diff] [blame] | 73 | #else |
Stephen Boyd | 163f1c3 | 2012-06-29 13:20:20 -0700 | [diff] [blame] | 74 | static inline int pil_desc_init(struct pil_desc *desc) { return 0; } |
| 75 | static inline int pil_boot(struct pil_desc *desc) { return 0; } |
| 76 | static inline void pil_shutdown(struct pil_desc *desc) { } |
| 77 | static inline void pil_desc_release(struct pil_desc *desc) { } |
Stephen Boyd | 3030c25 | 2012-08-08 17:24:05 -0700 | [diff] [blame] | 78 | static inline phys_addr_t pil_get_entry_addr(struct pil_desc *desc) |
| 79 | { |
| 80 | return 0; |
| 81 | } |
Stephen Boyd | 1066777 | 2012-11-28 16:45:35 -0800 | [diff] [blame] | 82 | static inline int pil_do_ramdump(struct pil_desc *desc, void *ramdump_dev) |
| 83 | { |
| 84 | return 0; |
| 85 | } |
Stephen Boyd | 866f9a2 | 2012-07-10 18:56:53 -0700 | [diff] [blame] | 86 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 87 | |
| 88 | #endif |