diff options
Diffstat (limited to 'arch/x86/platform/olpc/olpc-xo1-sci.c')
| -rw-r--r-- | arch/x86/platform/olpc/olpc-xo1-sci.c | 43 | 
1 files changed, 36 insertions, 7 deletions
diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c b/arch/x86/platform/olpc/olpc-xo1-sci.c index 1d4c783d732..04b8c73659c 100644 --- a/arch/x86/platform/olpc/olpc-xo1-sci.c +++ b/arch/x86/platform/olpc/olpc-xo1-sci.c @@ -18,6 +18,7 @@  #include <linux/interrupt.h>  #include <linux/platform_device.h>  #include <linux/pm.h> +#include <linux/pm_wakeup.h>  #include <linux/mfd/core.h>  #include <linux/power_supply.h>  #include <linux/suspend.h> @@ -83,8 +84,12 @@ static void send_ebook_state(void)  		return;  	} +	if (!!test_bit(SW_TABLET_MODE, ebook_switch_idev->sw) == state) +		return; /* Nothing new to report. */ +  	input_report_switch(ebook_switch_idev, SW_TABLET_MODE, state);  	input_sync(ebook_switch_idev); +	pm_wakeup_event(&ebook_switch_idev->dev, 0);  }  static void flip_lid_inverter(void) @@ -123,8 +128,12 @@ static void detect_lid_state(void)  /* Report current lid switch state through input layer */  static void send_lid_state(void)  { +	if (!!test_bit(SW_LID, lid_switch_idev->sw) == !lid_open) +		return; /* Nothing new to report. */ +  	input_report_switch(lid_switch_idev, SW_LID, !lid_open);  	input_sync(lid_switch_idev); +	pm_wakeup_event(&lid_switch_idev->dev, 0);  }  static ssize_t lid_wake_mode_show(struct device *dev, @@ -213,11 +222,30 @@ static irqreturn_t xo1_sci_intr(int irq, void *dev_id)  	dev_dbg(&pdev->dev, "sts %x gpe %x\n", sts, gpe); -	if (sts & CS5536_PWRBTN_FLAG && !(sts & CS5536_WAK_FLAG)) { -		input_report_key(power_button_idev, KEY_POWER, 1); -		input_sync(power_button_idev); -		input_report_key(power_button_idev, KEY_POWER, 0); -		input_sync(power_button_idev); +	if (sts & CS5536_PWRBTN_FLAG) { +		if (!(sts & CS5536_WAK_FLAG)) { +			/* Only report power button input when it was pressed +			 * during regular operation (as opposed to when it +			 * was used to wake the system). */ +			input_report_key(power_button_idev, KEY_POWER, 1); +			input_sync(power_button_idev); +			input_report_key(power_button_idev, KEY_POWER, 0); +			input_sync(power_button_idev); +		} +		/* Report the wakeup event in all cases. */ +		pm_wakeup_event(&power_button_idev->dev, 0); +	} + +	if ((sts & (CS5536_RTC_FLAG | CS5536_WAK_FLAG)) == +			(CS5536_RTC_FLAG | CS5536_WAK_FLAG)) { +		/* When the system is woken by the RTC alarm, report the +		 * event on the rtc device. */ +		struct device *rtc = bus_find_device_by_name( +			&platform_bus_type, NULL, "rtc_cmos"); +		if (rtc) { +			pm_wakeup_event(rtc, 0); +			put_device(rtc); +		}  	}  	if (gpe & CS5536_GPIOM7_PME_FLAG) { /* EC GPIO */ @@ -310,9 +338,10 @@ static int __devinit setup_sci_interrupt(struct platform_device *pdev)  		outb(lo, CS5536_PIC_INT_SEL2);  	} -	/* Enable SCI from power button, and clear pending interrupts */ +	/* Enable interesting SCI events, and clear pending interrupts */  	sts = inl(acpi_base + CS5536_PM1_STS); -	outl((CS5536_PM_PWRBTN << 16) | 0xffff, acpi_base + CS5536_PM1_STS); +	outl(((CS5536_PM_PWRBTN | CS5536_PM_RTC) << 16) | 0xffff, +	     acpi_base + CS5536_PM1_STS);  	r = request_irq(sci_irq, xo1_sci_intr, 0, DRV_NAME, pdev);  	if (r)  |