blob: 1c2faf7d01e715a039b044e5842d7f59d6055df2 [file] [log] [blame]
Stephen Boyd6d67d252011-09-27 11:50:05 -07001/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -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 */
Stephen Boyde4174b22011-09-20 00:19:43 -070012#ifndef __MSM_PERIPHERAL_LOADER_H
13#define __MSM_PERIPHERAL_LOADER_H
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070014
Stephen Boyd3f4da322011-08-30 01:03:23 -070015struct device;
Stephen Boyd6d67d252011-09-27 11:50:05 -070016struct module;
Stephen Boyd163f1c32012-06-29 13:20:20 -070017struct pil_priv;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018
Stephen Boyd36974ec2012-03-22 01:30:59 -070019/**
20 * struct pil_desc - PIL descriptor
21 * @name: string used for pil_get()
Stephen Boyd36974ec2012-03-22 01:30:59 -070022 * @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 Boyd3030c252012-08-08 17:24:05 -070026 * @flags: bitfield for image flags
Stephen Boyd163f1c32012-06-29 13:20:20 -070027 * @priv: DON'T USE - internal only
Stephen Boyd36974ec2012-03-22 01:30:59 -070028 */
Stephen Boyd3f4da322011-08-30 01:03:23 -070029struct pil_desc {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070030 const char *name;
Stephen Boyd3f4da322011-08-30 01:03:23 -070031 struct device *dev;
32 const struct pil_reset_ops *ops;
Stephen Boyd6d67d252011-09-27 11:50:05 -070033 struct module *owner;
Stephen Boyd36974ec2012-03-22 01:30:59 -070034 unsigned long proxy_timeout;
Stephen Boyd3030c252012-08-08 17:24:05 -070035 unsigned long flags;
36#define PIL_SKIP_ENTRY_CHECK BIT(0)
Stephen Boyd163f1c32012-06-29 13:20:20 -070037 struct pil_priv *priv;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070038};
39
Stephen Boyd36974ec2012-03-22 01:30:59 -070040/**
41 * struct pil_reset_ops - PIL operations
42 * @init_image: prepare an image for authentication
Stephen Boyd379e7332012-08-08 18:04:21 -070043 * @mem_setup: prepare the image memory region
Stephen Boyd36974ec2012-03-22 01:30:59 -070044 * @verify_blob: authenticate a program segment, called once for each loadable
45 * program segment (optional)
46 * @proxy_vote: make proxy votes before auth_and_reset (optional)
47 * @auth_and_reset: boot the processor
48 * @proxy_unvote: remove any proxy votes (optional)
49 * @shutdown: shutdown the processor
50 */
Stephen Boyd5bd999a2011-08-02 18:50:57 -070051struct pil_reset_ops {
Stephen Boyd3f4da322011-08-30 01:03:23 -070052 int (*init_image)(struct pil_desc *pil, const u8 *metadata,
Stephen Boyd5bd999a2011-08-02 18:50:57 -070053 size_t size);
Stephen Boyd379e7332012-08-08 18:04:21 -070054 int (*mem_setup)(struct pil_desc *pil, phys_addr_t addr, size_t size);
Stephen Boyd3f4da322011-08-30 01:03:23 -070055 int (*verify_blob)(struct pil_desc *pil, u32 phy_addr, size_t size);
Stephen Boyd36974ec2012-03-22 01:30:59 -070056 int (*proxy_vote)(struct pil_desc *pil);
Stephen Boyd3f4da322011-08-30 01:03:23 -070057 int (*auth_and_reset)(struct pil_desc *pil);
Stephen Boyd36974ec2012-03-22 01:30:59 -070058 void (*proxy_unvote)(struct pil_desc *pil);
Stephen Boyd3f4da322011-08-30 01:03:23 -070059 int (*shutdown)(struct pil_desc *pil);
Stephen Boyd5bd999a2011-08-02 18:50:57 -070060};
61
Stephen Boyd866f9a22012-07-10 18:56:53 -070062#ifdef CONFIG_MSM_PIL
Stephen Boyd163f1c32012-06-29 13:20:20 -070063extern int pil_desc_init(struct pil_desc *desc);
64extern int pil_boot(struct pil_desc *desc);
65extern void pil_shutdown(struct pil_desc *desc);
66extern void pil_desc_release(struct pil_desc *desc);
Stephen Boyd3030c252012-08-08 17:24:05 -070067extern phys_addr_t pil_get_entry_addr(struct pil_desc *desc);
Stephen Boyd866f9a22012-07-10 18:56:53 -070068#else
Stephen Boyd163f1c32012-06-29 13:20:20 -070069static inline int pil_desc_init(struct pil_desc *desc) { return 0; }
70static inline int pil_boot(struct pil_desc *desc) { return 0; }
71static inline void pil_shutdown(struct pil_desc *desc) { }
72static inline void pil_desc_release(struct pil_desc *desc) { }
Stephen Boyd3030c252012-08-08 17:24:05 -070073static inline phys_addr_t pil_get_entry_addr(struct pil_desc *desc)
74{
75 return 0;
76}
Stephen Boyd866f9a22012-07-10 18:56:53 -070077#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078
79#endif