msm: pil: Consolidate proxy voting into core

Almost each pil driver needs to proxy vote for certain resources
that the secure code cannot handle. Instead of repeating the same
boiler plate code in each pil driver move the proxy voting and
callback scheduling to the core. A driver is expected to provide
a proxy_vote and proxy_unvote function if proxy voting is
required.

Call the proxy_vote before booting the processor and remove the
proxy vote after the alloted timeout. If the driver doesn't
provide a timeout remove the proxy immediately after the
processor is booted. Also flush any pending works during shutdown
so that proxy votes don't linger.

Change-Id: I13322b5bfb040fd76cdfc0228771d076addf6559
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/arch/arm/mach-msm/peripheral-loader.h b/arch/arm/mach-msm/peripheral-loader.h
index cc00446..e3b250b 100644
--- a/arch/arm/mach-msm/peripheral-loader.h
+++ b/arch/arm/mach-msm/peripheral-loader.h
@@ -15,19 +15,41 @@
 struct device;
 struct module;
 
+/**
+ * struct pil_desc - PIL descriptor
+ * @name: string used for pil_get()
+ * @depends_on: booted before this peripheral
+ * @dev: parent device
+ * @ops: callback functions
+ * @owner: module the descriptor belongs to
+ * @proxy_timeout: delay in ms until proxy vote is removed
+ */
 struct pil_desc {
 	const char *name;
 	const char *depends_on;
 	struct device *dev;
 	const struct pil_reset_ops *ops;
 	struct module *owner;
+	unsigned long proxy_timeout;
 };
 
+/**
+ * struct pil_reset_ops - PIL operations
+ * @init_image: prepare an image for authentication
+ * @verify_blob: authenticate a program segment, called once for each loadable
+ *		 program segment (optional)
+ * @proxy_vote: make proxy votes before auth_and_reset (optional)
+ * @auth_and_reset: boot the processor
+ * @proxy_unvote: remove any proxy votes (optional)
+ * @shutdown: shutdown the processor
+ */
 struct pil_reset_ops {
 	int (*init_image)(struct pil_desc *pil, const u8 *metadata,
 			  size_t size);
 	int (*verify_blob)(struct pil_desc *pil, u32 phy_addr, size_t size);
+	int (*proxy_vote)(struct pil_desc *pil);
 	int (*auth_and_reset)(struct pil_desc *pil);
+	void (*proxy_unvote)(struct pil_desc *pil);
 	int (*shutdown)(struct pil_desc *pil);
 };