blob: b92c0396276e36f11b5559d4557fbbb7b37e715f [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2010-2012, The Linux Foundation. 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 *
12 */
13
14#ifndef __ARCH_ARM_MACH_MSM_MPM_H
15#define __ARCH_ARM_MACH_MSM_MPM_H
16
17#include <linux/types.h>
18#include <linux/list.h>
19
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#define MSM_MPM_NR_MPM_IRQS 64
21
22struct msm_mpm_device_data {
23 uint16_t *irqs_m2a;
24 unsigned int irqs_m2a_size;
25 uint16_t *bypassed_apps_irqs;
26 unsigned int bypassed_apps_irqs_size;
27 void __iomem *mpm_request_reg_base;
28 void __iomem *mpm_status_reg_base;
29 void __iomem *mpm_apps_ipc_reg;
30 unsigned int mpm_apps_ipc_val;
31 unsigned int mpm_ipc_irq;
32};
33
Praveen Chidambaram78499012011-11-01 17:15:17 -060034extern struct msm_mpm_device_data msm8660_mpm_dev_data;
35extern struct msm_mpm_device_data msm8960_mpm_dev_data;
36extern struct msm_mpm_device_data msm9615_mpm_dev_data;
37extern struct msm_mpm_device_data apq8064_mpm_dev_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070038
Praveen Chidambaram78499012011-11-01 17:15:17 -060039void msm_mpm_irq_extn_init(struct msm_mpm_device_data *mpm_data);
40
Mahesh Sivasubramanian102e5962012-06-20 13:12:11 -060041#if defined(CONFIG_MSM_MPM) || defined(CONFIG_MSM_MPM_OF)
42/**
43 * msm_mpm_enable_pin() - Enable/Disable a MPM pin for idle wakeups.
44 *
45 * @pin: MPM pin to set
46 * @enable: enable/disable the pin
47 *
48 * returns 0 on success or errorno
49 *
50 * Drivers can call the function to configure MPM pins for wakeup from idle low
51 * power modes. The API provides a direct access to the configuring MPM pins
52 * that are not connected to a IRQ/GPIO
53 */
Subhash Jadavanife608a22012-04-13 10:45:53 +053054int msm_mpm_enable_pin(unsigned int pin, unsigned int enable);
Mahesh Sivasubramanian102e5962012-06-20 13:12:11 -060055
56/**
57 * msm_mpm_set_pin_wake() - Enable/Disable a MPM pin during suspend
58 *
59 * @pin: MPM pin to set
60 * @enable: enable/disable the pin as wakeup
61 *
62 * returns 0 on success or errorno
63 *
64 * Drivers can call the function to configure MPM pins for wakeup from suspend
65 * low power modes. The API provides a direct access to the configuring MPM pins
66 * that are not connected to a IRQ/GPIO
67 */
Subhash Jadavanife608a22012-04-13 10:45:53 +053068int msm_mpm_set_pin_wake(unsigned int pin, unsigned int on);
Mahesh Sivasubramanian102e5962012-06-20 13:12:11 -060069/**
70 * msm_mpm_set_pin_type() - Set the flowtype of a MPM pin.
71 *
72 * @pin: MPM pin to configure
73 * @flow_type: flowtype of the MPM pin.
74 *
75 * returns 0 on success or errorno
76 *
77 * Drivers can call the function to configure the flowtype of the MPM pins
78 * The API provides a direct access to the configuring MPM pins that are not
79 * connected to a IRQ/GPIO
80 */
Subhash Jadavanife608a22012-04-13 10:45:53 +053081int msm_mpm_set_pin_type(unsigned int pin, unsigned int flow_type);
Mahesh Sivasubramanian102e5962012-06-20 13:12:11 -060082/**
83 * msm_mpm_irqs_detectable() - Check if active irqs can be monitored by MPM
84 *
85 * @from_idle: indicates if the sytem is entering low power mode as a part of
86 * suspend/idle task.
87 *
88 * returns true if all active interrupts can be monitored by the MPM
89 *
90 * Low power management code calls into this API to check if all active
91 * interrupts can be monitored by MPM and choose a level such that all active
92 * interrupts can wake the system up from low power mode.
93 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094bool msm_mpm_irqs_detectable(bool from_idle);
Mahesh Sivasubramanian102e5962012-06-20 13:12:11 -060095/**
96 * msm_mpm_gpio_detectable() - Check if active gpio irqs can be monitored by
97 * MPM
98 *
99 * @from_idle: indicates if the sytem is entering low power mode as a part of
100 * suspend/idle task.
101 *
102 * returns true if all active GPIO interrupts can be monitored by the MPM
103 *
104 * Low power management code calls into this API to check if all active
105 * GPIO interrupts can be monitored by MPM and choose a level such that all
106 * active interrupts can wake the system up from low power mode.
107 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700108bool msm_mpm_gpio_irqs_detectable(bool from_idle);
Mahesh Sivasubramanian102e5962012-06-20 13:12:11 -0600109/**
110 * msm_mpm_enter_sleep() -Called from PM code before entering low power mode
111 *
Mahesh Sivasubramanian2efbc352012-07-18 14:15:44 -0600112 * @sclk_count: wakeup time in sclk counts for programmed RPM wakeup
Mahesh Sivasubramanian102e5962012-06-20 13:12:11 -0600113 * @from_idle: indicates if the sytem is entering low power mode as a part of
114 * suspend/idle task.
115 *
116 * Low power management code calls into this API to configure the MPM to
117 * monitor the active irqs before going to sleep.
118 */
Mahesh Sivasubramanian2efbc352012-07-18 14:15:44 -0600119void msm_mpm_enter_sleep(uint32_t sclk_count, bool from_idle);
Mahesh Sivasubramanian102e5962012-06-20 13:12:11 -0600120/**
121 * msm_mpm_exit_sleep() -Called from PM code after resuming from low power mode
122 *
123 * @from_idle: indicates if the sytem is entering low power mode as a part of
124 * suspend/idle task.
125 *
126 * Low power management code calls into this API to query the MPM for the
127 * wakeup source and retriggering the appropriate interrupt.
128 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700129void msm_mpm_exit_sleep(bool from_idle);
Mahesh Sivasubramanian102e5962012-06-20 13:12:11 -0600130/**
131 * of_mpm_init() - Device tree initialization function
132 *
133 * @node: MPM device tree node.
134 *
135 * The initialization function is called from the machine irq function after
136 * GPIO/GIC device initialization routines are called. MPM driver keeps track
137 * of all enabled/wakeup interrupts in the system to be able to configure MPM
138 * when entering a system wide low power mode. The MPM is a alway-on low power
139 * hardware block that monitors 64 wakeup interrupts when the system is in a
140 * low power mode. The initialization function constructs the MPM mapping
141 * between the IRQs and the MPM pin based on data in the device tree.
142 */
143void __init of_mpm_init(struct device_node *node);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700144#else
Subhash Jadavani350290f2012-04-12 10:57:56 +0530145static inline int msm_mpm_enable_irq(unsigned int irq, unsigned int enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700146{ return -ENODEV; }
Subhash Jadavani350290f2012-04-12 10:57:56 +0530147static inline int msm_mpm_set_irq_wake(unsigned int irq, unsigned int on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700148{ return -ENODEV; }
Subhash Jadavani350290f2012-04-12 10:57:56 +0530149static inline int msm_mpm_set_irq_type(unsigned int irq, unsigned int flow_type)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150{ return -ENODEV; }
Subhash Jadavanife608a22012-04-13 10:45:53 +0530151static inline int msm_mpm_enable_pin(unsigned int pin, unsigned int enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700152{ return -ENODEV; }
Subhash Jadavanife608a22012-04-13 10:45:53 +0530153static inline int msm_mpm_set_pin_wake(unsigned int pin, unsigned int on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700154{ return -ENODEV; }
Subhash Jadavanife608a22012-04-13 10:45:53 +0530155static inline int msm_mpm_set_pin_type(unsigned int pin,
Subhash Jadavani350290f2012-04-12 10:57:56 +0530156 unsigned int flow_type)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700157{ return -ENODEV; }
Subhash Jadavani350290f2012-04-12 10:57:56 +0530158static inline bool msm_mpm_irqs_detectable(bool from_idle)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700159{ return false; }
Subhash Jadavani350290f2012-04-12 10:57:56 +0530160static inline bool msm_mpm_gpio_irqs_detectable(bool from_idle)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700161{ return false; }
Mahesh Sivasubramanian2efbc352012-07-18 14:15:44 -0600162static inline void msm_mpm_enter_sleep(uint32_t sclk_count, bool from_idle) {}
Subhash Jadavani350290f2012-04-12 10:57:56 +0530163static inline void msm_mpm_exit_sleep(bool from_idle) {}
Mahesh Sivasubramanian102e5962012-06-20 13:12:11 -0600164static inline void __init of_mpm_init(struct device_node *node) {}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700165#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700166#endif /* __ARCH_ARM_MACH_MSM_MPM_H */