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 | * |
| 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 20 | #define MSM_MPM_NR_MPM_IRQS 64 |
| 21 | |
| 22 | struct 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 Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 34 | extern struct msm_mpm_device_data msm8660_mpm_dev_data; |
| 35 | extern struct msm_mpm_device_data msm8960_mpm_dev_data; |
| 36 | extern struct msm_mpm_device_data msm9615_mpm_dev_data; |
| 37 | extern struct msm_mpm_device_data apq8064_mpm_dev_data; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 38 | |
Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 39 | void msm_mpm_irq_extn_init(struct msm_mpm_device_data *mpm_data); |
| 40 | |
Mahesh Sivasubramanian | 102e596 | 2012-06-20 13:12:11 -0600 | [diff] [blame] | 41 | #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 Jadavani | fe608a2 | 2012-04-13 10:45:53 +0530 | [diff] [blame] | 54 | int msm_mpm_enable_pin(unsigned int pin, unsigned int enable); |
Mahesh Sivasubramanian | 102e596 | 2012-06-20 13:12:11 -0600 | [diff] [blame] | 55 | |
| 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 Jadavani | fe608a2 | 2012-04-13 10:45:53 +0530 | [diff] [blame] | 68 | int msm_mpm_set_pin_wake(unsigned int pin, unsigned int on); |
Mahesh Sivasubramanian | 102e596 | 2012-06-20 13:12:11 -0600 | [diff] [blame] | 69 | /** |
| 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 Jadavani | fe608a2 | 2012-04-13 10:45:53 +0530 | [diff] [blame] | 81 | int msm_mpm_set_pin_type(unsigned int pin, unsigned int flow_type); |
Mahesh Sivasubramanian | 102e596 | 2012-06-20 13:12:11 -0600 | [diff] [blame] | 82 | /** |
| 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 94 | bool msm_mpm_irqs_detectable(bool from_idle); |
Mahesh Sivasubramanian | 102e596 | 2012-06-20 13:12:11 -0600 | [diff] [blame] | 95 | /** |
| 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 108 | bool msm_mpm_gpio_irqs_detectable(bool from_idle); |
Mahesh Sivasubramanian | 102e596 | 2012-06-20 13:12:11 -0600 | [diff] [blame] | 109 | /** |
| 110 | * msm_mpm_enter_sleep() -Called from PM code before entering low power mode |
| 111 | * |
Mahesh Sivasubramanian | 2efbc35 | 2012-07-18 14:15:44 -0600 | [diff] [blame] | 112 | * @sclk_count: wakeup time in sclk counts for programmed RPM wakeup |
Mahesh Sivasubramanian | 102e596 | 2012-06-20 13:12:11 -0600 | [diff] [blame] | 113 | * @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 Sivasubramanian | 2efbc35 | 2012-07-18 14:15:44 -0600 | [diff] [blame] | 119 | void msm_mpm_enter_sleep(uint32_t sclk_count, bool from_idle); |
Mahesh Sivasubramanian | 102e596 | 2012-06-20 13:12:11 -0600 | [diff] [blame] | 120 | /** |
| 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 129 | void msm_mpm_exit_sleep(bool from_idle); |
Mahesh Sivasubramanian | 102e596 | 2012-06-20 13:12:11 -0600 | [diff] [blame] | 130 | /** |
| 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 | */ |
| 143 | void __init of_mpm_init(struct device_node *node); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 144 | #else |
Subhash Jadavani | 350290f | 2012-04-12 10:57:56 +0530 | [diff] [blame] | 145 | static inline int msm_mpm_enable_irq(unsigned int irq, unsigned int enable) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 146 | { return -ENODEV; } |
Subhash Jadavani | 350290f | 2012-04-12 10:57:56 +0530 | [diff] [blame] | 147 | static inline int msm_mpm_set_irq_wake(unsigned int irq, unsigned int on) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 148 | { return -ENODEV; } |
Subhash Jadavani | 350290f | 2012-04-12 10:57:56 +0530 | [diff] [blame] | 149 | static inline int msm_mpm_set_irq_type(unsigned int irq, unsigned int flow_type) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 150 | { return -ENODEV; } |
Subhash Jadavani | fe608a2 | 2012-04-13 10:45:53 +0530 | [diff] [blame] | 151 | static inline int msm_mpm_enable_pin(unsigned int pin, unsigned int enable) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 152 | { return -ENODEV; } |
Subhash Jadavani | fe608a2 | 2012-04-13 10:45:53 +0530 | [diff] [blame] | 153 | static inline int msm_mpm_set_pin_wake(unsigned int pin, unsigned int on) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 154 | { return -ENODEV; } |
Subhash Jadavani | fe608a2 | 2012-04-13 10:45:53 +0530 | [diff] [blame] | 155 | static inline int msm_mpm_set_pin_type(unsigned int pin, |
Subhash Jadavani | 350290f | 2012-04-12 10:57:56 +0530 | [diff] [blame] | 156 | unsigned int flow_type) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 157 | { return -ENODEV; } |
Subhash Jadavani | 350290f | 2012-04-12 10:57:56 +0530 | [diff] [blame] | 158 | static inline bool msm_mpm_irqs_detectable(bool from_idle) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 159 | { return false; } |
Subhash Jadavani | 350290f | 2012-04-12 10:57:56 +0530 | [diff] [blame] | 160 | static inline bool msm_mpm_gpio_irqs_detectable(bool from_idle) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 161 | { return false; } |
Mahesh Sivasubramanian | 2efbc35 | 2012-07-18 14:15:44 -0600 | [diff] [blame] | 162 | static inline void msm_mpm_enter_sleep(uint32_t sclk_count, bool from_idle) {} |
Subhash Jadavani | 350290f | 2012-04-12 10:57:56 +0530 | [diff] [blame] | 163 | static inline void msm_mpm_exit_sleep(bool from_idle) {} |
Mahesh Sivasubramanian | 102e596 | 2012-06-20 13:12:11 -0600 | [diff] [blame] | 164 | static inline void __init of_mpm_init(struct device_node *node) {} |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 165 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 166 | #endif /* __ARCH_ARM_MACH_MSM_MPM_H */ |