15 #include <linux/types.h>
18 #include <linux/wait.h>
24 #include <linux/export.h>
30 #include <asm/switch_to.h>
34 #define PMCCR1_NEXT_STATE 0x0C
35 #define PMCCR1_NEXT_STATE_SHIFT 2
36 #define PMCCR1_CURR_STATE 0x03
37 #define IMMR_SYSCR_OFFSET 0x100
38 #define IMMR_RCW_OFFSET 0x900
39 #define RCW_PCI_HOST 0x80000000
51 #define PMCER_GPIO 0x100
52 #define PMCER_PCI 0x080
53 #define PMCER_USB 0x040
54 #define PMCER_ETSEC1 0x020
55 #define PMCER_ETSEC2 0x010
56 #define PMCER_TIMER 0x008
57 #define PMCER_INT1 0x004
58 #define PMCER_INT2 0x002
59 #define PMCER_PMCI 0x001
60 #define PMCER_ALL 0x1FF
64 #define PMCCR1_USE_STATE 0x80000000
65 #define PMCCR1_PME_EN 0x00000080
66 #define PMCCR1_ASSERT_PME 0x00000040
67 #define PMCCR1_POWER_OFF 0x00000020
105 static int has_deep_sleep, deep_sleeping;
111 static int is_pci_agent, wake_from_pci;
113 static int pci_pm_state;
118 return deep_sleeping;
122 static int mpc83xx_change_state(
void)
132 if (curr_state != pci_pm_state) {
133 reg_cfg1 &= ~PMCCR1_CURR_STATE;
134 reg_cfg1 |= pci_pm_state;
150 if (mpc83xx_change_state())
161 static void mpc83xx_suspend_restore_regs(
void)
168 static void mpc83xx_suspend_save_regs(
void)
184 if (pci_pm_state != (deep_sleeping ? 3 : 2))
204 mpc83xx_suspend_save_regs();
220 mpc83xx_suspend_restore_regs();
236 static void mpc83xx_suspend_end(
void)
264 static int agent_thread_fn(
void *
data)
270 if (signal_pending(
current) || pci_pm_state < 2)
291 static void mpc83xx_set_agent(
void)
299 static int mpc83xx_is_pci_agent(
void)
317 .valid = mpc83xx_suspend_valid,
318 .begin = mpc83xx_suspend_begin,
319 .enter = mpc83xx_suspend_enter,
320 .end = mpc83xx_suspend_end,
345 is_pci_agent = mpc83xx_is_pci_agent();
346 if (is_pci_agent < 0)
384 sizeof(*syscr_regs));
413 static struct pmc_type pmc_types[] = {
424 .compatible =
"fsl,mpc8313-pmc",
425 .data = &pmc_types[0],
428 .compatible =
"fsl,mpc8349-pmc",
429 .data = &pmc_types[1],
436 .name =
"mpc83xx-pmc",
438 .of_match_table = pmc_match,
444 static int pmc_init(
void)