Skip to content

Commit

Permalink
i2c: gp2a_proximity: Disable CPU-boost when proximity sensor is open
Browse files Browse the repository at this point in the history
When proximity sensor is open, we are expecting the screen to be turning on and off rapidly. Disable CPU-boost when this happens so the CPU isn't boosted every time the screen turns on.

Signed-off-by: Sultanxda <sultanxda@gmail.com>
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
  • Loading branch information
kerneltoast authored and Cl3Kener committed Oct 17, 2014
1 parent a0c58ec commit 0ab5338
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/cpufreq/cpu_boost.c
Expand Up @@ -147,6 +147,14 @@ static void __cpuinit cpu_boost_main(struct work_struct *work)
msecs_to_jiffies(wait_ms));
}

void cpu_boost_shutdown(void){
enabled = 0;
}

void cpu_boost_startup(void){
enabled = 1;
}

static ssize_t cpu_boost_enabled_status_read(struct device *dev,
struct device_attribute *attr, char *buf)
{
Expand All @@ -158,8 +166,8 @@ static ssize_t cpu_boost_enabled_status_write(struct device *dev,
{
unsigned int data;
if(sscanf(buf, "%u\n", &data) == 1) {
if (data == 1) enabled = 1;
else if (data == 0) enabled = 0;
if (data == 1) cpu_boost_startup();
else if (data == 0) cpu_boost_shutdown();
}
return size;
}
Expand Down
5 changes: 5 additions & 0 deletions drivers/i2c/chips/gp2a_proximity.c
Expand Up @@ -17,6 +17,7 @@
* MA 02110-1301, USA.
*/

#include <linux/cpu_boost.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/i2c.h>
Expand Down Expand Up @@ -225,6 +226,8 @@ proximity_enable_store(struct device *dev, struct device_attribute *attr, const
#endif

if (data->enabled && !value) { /* Proximity power off */
cpu_boost_startup();

disable_irq(data->gp2a_irq);

proximity_onoff(0);
Expand All @@ -235,6 +238,8 @@ proximity_enable_store(struct device *dev, struct device_attribute *attr, const
data->power_off();
}
if (!data->enabled && value) { /* proximity power on */
cpu_boost_shutdown();

if(data->power_on)
data->power_on();
if(data->gp2a_led_on)
Expand Down
5 changes: 5 additions & 0 deletions include/linux/cpu_boost.h
Expand Up @@ -37,7 +37,12 @@ void cpu_boost(unsigned int freq_mhz);
*/
void cpu_unboost(void);

void cpu_boost_shutdown(void);
void cpu_boost_startup(void);

#else
static inline void cpu_boost_shutdown(void);
static inline void cpu_boost_startup(void);
static inline void cpu_boost_timeout(unsigned int freq_mhz, unsigned int duration_ms) { }
static inline void cpu_boost(unsigned int freq_mhz) { }
static inline void cpu_unboost(void) { }
Expand Down

0 comments on commit 0ab5338

Please sign in to comment.