blackfin: bf60x: add wakeup source select
authorSteven Miao <realmz6@gmail.com>
Thu, 17 May 2012 09:29:54 +0000 (17:29 +0800)
committerBob Liu <lliubbo@gmail.com>
Mon, 21 May 2012 06:54:50 +0000 (14:54 +0800)
Support select the wakeup source for power management on bf60x.

Signed-off-by: Steven Miao <realmz6@gmail.com>
Signed-off-by: Bob Liu <lliubbo@gmail.com>
arch/blackfin/Kconfig
arch/blackfin/configs/BF609-EZKIT_defconfig
arch/blackfin/include/asm/dpmc.h
arch/blackfin/mach-bf609/pm.c
arch/blackfin/mach-common/ints-priority.c
arch/blackfin/mach-common/pm.c

index 4e48e72291a9cd2fa79bd6acbc938a727b2c85d3..383e7ecda923bb6b552b85301eeb240822df7fea 100644 (file)
@@ -1256,7 +1256,7 @@ config ARCH_SUSPEND_POSSIBLE
 
 choice
        prompt "Standby Power Saving Mode"
-       depends on PM
+       depends on PM && !BF60x
        default PM_BFIN_SLEEP_DEEPER
 config  PM_BFIN_SLEEP_DEEPER
        bool "Sleep Deeper"
@@ -1311,6 +1311,118 @@ config PM_BFIN_WAKE_GP
          On ADSP-BF549 this option enables the the same functionality on the
          /MRXON pin also PH7.
 
+config PM_BFIN_WAKE_PA15
+       bool "Allow Wake-Up from PA15"
+       depends on PM && BF60x
+       default n
+       help
+         Enable PA15 Wake-Up
+
+config PM_BFIN_WAKE_PA15_POL
+       int "Wake-up priority"
+       depends on PM_BFIN_WAKE_PA15
+       default 0
+       help
+         Wake-Up priority 0(low) 1(high)
+
+config PM_BFIN_WAKE_PB15
+       bool "Allow Wake-Up from PB15"
+       depends on PM && BF60x
+       default n
+       help
+         Enable PB15 Wake-Up
+
+config PM_BFIN_WAKE_PB15_POL
+       int "Wake-up priority"
+       depends on PM_BFIN_WAKE_PB15
+       default 0
+       help
+         Wake-Up priority 0(low) 1(high)
+
+config PM_BFIN_WAKE_PC15
+       bool "Allow Wake-Up from PC15"
+       depends on PM && BF60x
+       default n
+       help
+         Enable PC15 Wake-Up
+
+config PM_BFIN_WAKE_PC15_POL
+       int "Wake-up priority"
+       depends on PM_BFIN_WAKE_PC15
+       default 0
+       help
+         Wake-Up priority 0(low) 1(high)
+
+config PM_BFIN_WAKE_PD06
+       bool "Allow Wake-Up from PD06(ETH0_PHYINT)"
+       depends on PM && BF60x
+       default n
+       help
+         Enable PD06(ETH0_PHYINT) Wake-up
+
+config PM_BFIN_WAKE_PD06_POL
+       int "Wake-up priority"
+       depends on PM_BFIN_WAKE_PD06
+       default 0
+       help
+         Wake-Up priority 0(low) 1(high)
+
+config PM_BFIN_WAKE_PE12
+       bool "Allow Wake-Up from PE12(ETH1_PHYINT, PUSH BUTTON)"
+       depends on PM && BF60x
+       default n
+       help
+         Enable PE12(ETH1_PHYINT, PUSH BUTTON) Wake-up
+
+config PM_BFIN_WAKE_PE12_POL
+       int "Wake-up priority"
+       depends on PM_BFIN_WAKE_PE12
+       default 0
+       help
+         Wake-Up priority 0(low) 1(high)
+
+config PM_BFIN_WAKE_PG04
+       bool "Allow Wake-Up from PG04(CAN0_RX)"
+       depends on PM && BF60x
+       default n
+       help
+         Enable PG04(CAN0_RX) Wake-up
+
+config PM_BFIN_WAKE_PG04_POL
+       int "Wake-up priority"
+       depends on PM_BFIN_WAKE_PG04
+       default 0
+       help
+         Wake-Up priority 0(low) 1(high)
+
+config PM_BFIN_WAKE_PG13
+       bool "Allow Wake-Up from PG13"
+       depends on PM && BF60x
+       default n
+       help
+         Enable PG13 Wake-Up
+
+config PM_BFIN_WAKE_PG13_POL
+       int "Wake-up priority"
+       depends on PM_BFIN_WAKE_PG13
+       default 0
+       help
+         Wake-Up priority 0(low) 1(high)
+
+config PM_BFIN_WAKE_USB
+       bool "Allow Wake-Up from (USB)"
+       depends on PM && BF60x
+       default n
+       help
+         Enable (USB) Wake-up
+
+config PM_BFIN_WAKE_USB_POL
+       int "Wake-up priority"
+       depends on PM_BFIN_WAKE_USB
+       default 0
+       help
+         Wake-Up priority 0(low) 1(high)
+
 endmenu
 
 menu "CPU Frequency scaling"
index 0864f7aaa57299ee561e60b7b9c8895b9b174bdf..be9526bee4fbd9b5b2e7ec26036f08620ff0624d 100644 (file)
@@ -33,7 +33,8 @@ CONFIG_CPLB_SWITCH_TAB_L1=y
 CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BINFMT_FLAT=y
 CONFIG_BINFMT_ZFLAT=y
-# CONFIG_SUSPEND is not set
+CONFIG_PM_BFIN_WAKE_PE12=y
+CONFIG_PM_BFIN_WAKE_PE12_POL=1
 CONFIG_CPU_FREQ=y
 CONFIG_CPU_FREQ_GOV_POWERSAVE=y
 CONFIG_CPU_FREQ_GOV_ONDEMAND=y
@@ -119,7 +120,7 @@ CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61=m
 CONFIG_SND_SOC_ALL_CODECS=m
 CONFIG_USB=y
 CONFIG_USB_MUSB_HDRC=y
-CONFIG_USB_MUSB_BLACKFIN=y
+CONFIG_USB_MUSB_BLACKFIN=m
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MUSB_HDRC=y
index b47399cda6ed897b1dbfe490b674df4c7529ec71..528f4768578185e52584de63ac0eb28ceaca4215 100644 (file)
 #define VLEV_130               0x00F0  /* VLEV = 1.30 V (-5% - +10% Accuracy) */
 #endif
 
+#ifdef CONFIG_BF60x
+#define PA15WE                 0x00000001 /* Allow Wake-Up from PA15 */
+#define PB15WE                 0x00000002 /* Allow Wake-Up from PB15 */
+#define PC15WE                 0x00000004 /* Allow Wake-Up from PC15 */
+#define PD06WE                 0x00000008 /* Allow Wake-Up from PD06(ETH0_PHYINT) */
+#define PE12WE                 0x00000010 /* Allow Wake-Up from PE12(ETH1_PHYINT, PUSH BUTTON) */
+#define PG04WE                 0x00000020 /* Allow Wake-Up from PG04(CAN0_RX) */
+#define PG13WE                 0x00000040 /* Allow Wake-Up from PG13 */
+#define USBWE                  0x00000080 /* Allow Wake-Up from (USB) */
+#else
 #define WAKE                   0x0100  /* Enable RTC/Reset Wakeup From Hibernate */
 #define CANWE                  0x0200  /* Enable CAN Wakeup From Hibernate */
 #define PHYWE                  0x0400  /* Enable PHY Wakeup From Hibernate */
 #else
 #define USBWE                  0x0800  /* Enable USB Wakeup From Hibernate */
 #endif
-
+#endif
 
 #ifndef __ASSEMBLY__
 
index bbc5a79b5e2257df57c4be3cb080e4b29479e065..79cdf41096c296667d67dfc8ea690e3344d8025c 100644 (file)
@@ -212,6 +212,65 @@ void bfin_hibernate(unsigned long mask)
 void bf609_cpu_pm_enter(suspend_state_t state)
 {
        int error;
+       unsigned long wakeup = 0;
+       unsigned long wakeup_pol = 0;
+
+#ifdef CONFIG_PM_BFIN_WAKE_PA15
+       wakeup |= PA15WE;
+# if CONFIG_PM_BFIN_WAKE_PA15_POL
+       wakeup_pol |= PA15WE;
+# endif
+#endif
+
+#ifdef CONFIG_PM_BFIN_WAKE_PB15
+       wakeup |= PB15WE;
+# if CONFIG_PM_BFIN_WAKE_PA15_POL
+       wakeup_pol |= PB15WE;
+# endif
+#endif
+
+#ifdef CONFIG_PM_BFIN_WAKE_PC15
+       wakeup |= PC15WE;
+# if CONFIG_PM_BFIN_WAKE_PC15_POL
+       wakeup_pol |= PC15WE;
+# endif
+#endif
+
+#ifdef CONFIG_PM_BFIN_WAKE_PD06
+       wakeup |= PD06WE;
+# if CONFIG_PM_BFIN_WAKE_PD06_POL
+       wakeup_pol |= PD06WE;
+# endif
+#endif
+
+#ifdef CONFIG_PM_BFIN_WAKE_PE12
+       wakeup |= PE12WE;
+# if CONFIG_PM_BFIN_WAKE_PE12_POL
+       wakeup_pol |= PE12WE;
+# endif
+#endif
+
+#ifdef CONFIG_PM_BFIN_WAKE_PG04
+       wakeup |= PG04WE;
+# if CONFIG_PM_BFIN_WAKE_PG04_POL
+       wakeup_pol |= PG04WE;
+# endif
+#endif
+
+#ifdef CONFIG_PM_BFIN_WAKE_PG13
+       wakeup |= PG13WE;
+# if CONFIG_PM_BFIN_WAKE_PG13_POL
+       wakeup_pol |= PG13WE;
+# endif
+#endif
+
+#ifdef CONFIG_PM_BFIN_WAKE_USB
+       wakeup |= USBWE;
+# if CONFIG_PM_BFIN_WAKE_USB_POL
+       wakeup_pol |= USBWE;
+# endif
+#endif
+
        error = irq_set_irq_wake(255, 1);
        if(error < 0)
                printk(KERN_DEBUG "Unable to get irq wake\n");
@@ -220,9 +279,9 @@ void bf609_cpu_pm_enter(suspend_state_t state)
                printk(KERN_DEBUG "Unable to get irq wake\n");
 
        if (state == PM_SUSPEND_STANDBY)
-               bfin_deepsleep(0xffff);
+               bfin_deepsleep(wakeup);
        else {
-               bfin_hibernate(0xffff);
+               bfin_hibernate(wakeup);
        }
 }
 
@@ -263,26 +322,8 @@ static int __init bf609_init_pm(void)
 {
        int irq;
        int error;
-       error = gpio_request(GPIO_PG4, "gpiopg4");
-       if (error < 0) {
-               printk(KERN_DEBUG "failed to request GPIO %d, error %d\n",
-                               GPIO_PG4, error);
-       }
-
-       irq = gpio_to_irq(GPIO_PG4);
-       if (irq < 0) {
-               error = irq;
-               printk(KERN_DEBUG "Unable to get irq number for GPIO %d, error %d\n",
-                               GPIO_PG4, error);
-       }
-
-       printk(KERN_DEBUG "%s gpio %d irq %d\n", __func__, GPIO_PG4, irq);
-
-       error = request_irq(irq, test_isr, IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND, "gpiopg4", NULL);
-       if(error < 0)
-               printk(KERN_DEBUG "Unable to get irq\n");
 
-#if 1
+#if CONFIG_PM_BFIN_WAKE_PE12
        irq = gpio_to_irq(GPIO_PE12);
        if (irq < 0) {
                error = irq;
index 1146a6152ae6d8b7b87d45b0fec2b41293f8f507..2729cba715b0326c7411c3446248c8c0b5837668 100644 (file)
@@ -437,7 +437,7 @@ static void bfin_internal_unmask_irq_chip(struct irq_data *d)
 }
 #endif
 
-#ifdef CONFIG_PM
+#if defined(CONFIG_PM) && !defined(CONFIG_BF60x)
 int bfin_internal_set_wake(unsigned int irq, unsigned int state)
 {
        u32 bank, bit, wakeup = 0;
@@ -496,6 +496,7 @@ static int bfin_internal_set_wake_chip(struct irq_data *d, unsigned int state)
        return bfin_internal_set_wake(d->irq, state);
 }
 #else
+# define bfin_internal_set_wake(irq, state)
 # define bfin_internal_set_wake_chip NULL
 #endif
 
index c25c2f1c819c90cc1fbaa33b8af8131cd7dd4d96..610a3cdf39986fcf1515425b11dcd7785b717842 100644 (file)
@@ -153,9 +153,6 @@ int bfin_pm_suspend_mem_enter(void)
 
 #ifndef CONFIG_BF60x
        wakeup = bfin_read_VR_CTL() & ~FREQ;
-#else
-
-#endif
        wakeup |= SCKELOW;
 
 #ifdef CONFIG_PM_BFIN_WAKE_PH6
@@ -163,6 +160,7 @@ int bfin_pm_suspend_mem_enter(void)
 #endif
 #ifdef CONFIG_PM_BFIN_WAKE_GP
        wakeup |= GPWE;
+#endif
 #endif
 
        ret = blackfin_dma_suspend();