add support for target 3c24xx (more known as Openmoko GTA02 "Freerunner") and merge...
[openwrt.git] / target / linux / s3c24xx / patches / 0130-From-cc08b5986dfd8d971ee46ce7045fb7863f99a92a-Mon-Se.patch
1 From 348e7db53a04b7d98e0f63f372b86882a995d3c8 Mon Sep 17 00:00:00 2001
2 From: Matt Hsu <matt_hsu@openmoko.org>
3 Date: Fri, 25 Jul 2008 23:06:07 +0100
4 Subject: [PATCH] From cc08b5986dfd8d971ee46ce7045fb7863f99a92a Mon Sep 17 00:00:00 2001
5  Subject: [PATCH] - add suspend/resume function of s3c24xx_hcd driver
6
7 Signed-off-by: Matt Hsu <matt_hsu@openmoko.org>
8 ---
9  drivers/sdio/hcd/s3c24xx/s3c24xx_hcd.c |   65 ++++++++++++++++++++++++++++++++
10  drivers/sdio/hcd/s3c24xx/s3c24xx_hcd.h |   14 +++++++
11  2 files changed, 79 insertions(+), 0 deletions(-)
12
13 diff --git a/drivers/sdio/hcd/s3c24xx/s3c24xx_hcd.c b/drivers/sdio/hcd/s3c24xx/s3c24xx_hcd.c
14 index af0066d..fdc69a0 100644
15 --- a/drivers/sdio/hcd/s3c24xx/s3c24xx_hcd.c
16 +++ b/drivers/sdio/hcd/s3c24xx/s3c24xx_hcd.c
17 @@ -1365,11 +1365,76 @@ static int s3c24xx_hcd_remove(struct platform_device * pdev) {
18         return 0;
19  }
20  
21 +#ifdef CONFIG_PM 
22 +
23 +static int s3c24xx_hcd_suspend(struct platform_device * pdev)
24 +{
25 +       struct s3c24xx_hcd_context * context = &hcd_context;    
26 +       unsigned long flags;
27 +
28 +       spin_lock_irqsave(&context->lock, flags);
29 +
30 +       context->suspend_regs.con       = readl(context->base + S3C2410_SDICON);
31 +       context->suspend_regs.pre       = readl(context->base + S3C2410_SDIPRE);
32 +       context->suspend_regs.cmdarg    = readl(context->base + S3C2410_SDICMDARG);
33 +       context->suspend_regs.cmdcon    = readl(context->base + S3C2410_SDICMDCON);
34 +       context->suspend_regs.cmdsta    = readl(context->base + S3C2410_SDICMDSTAT);
35 +       context->suspend_regs.r0        = readl(context->base + S3C2410_SDIRSP0);
36 +       context->suspend_regs.r1        = readl(context->base + S3C2410_SDIRSP1);
37 +       context->suspend_regs.r2        = readl(context->base + S3C2410_SDIRSP2);
38 +       context->suspend_regs.r3        = readl(context->base + S3C2410_SDIRSP3);
39 +       context->suspend_regs.timer     = readl(context->base + S3C2410_SDITIMER);
40 +       context->suspend_regs.bsize     = readl(context->base + S3C2410_SDIBSIZE);
41 +       context->suspend_regs.datcon    = readl(context->base + S3C2410_SDIDCON);
42 +       context->suspend_regs.datcnt    = readl(context->base + S3C2410_SDIDCNT);
43 +       context->suspend_regs.datsta    = readl(context->base + S3C2410_SDIDSTA);
44 +       context->suspend_regs.fsta      = readl(context->base + S3C2410_SDIFSTA);
45 +       context->suspend_regs.imask   = readl(context->base + S3C2440_SDIIMSK);
46 +       
47 +       spin_unlock_irqrestore(&context->lock, flags);
48 +       return 0;
49 +}
50 +
51 +static int s3c24xx_hcd_resume(struct platform_device * pdev)
52 +{      
53 +       struct s3c24xx_hcd_context * context = &hcd_context;
54 +       unsigned long flags;
55 +
56 +       spin_lock_irqsave(&context->lock, flags);
57 +       
58 +       writel(context->suspend_regs.con, context->base + S3C2410_SDICON);
59 +       writel(context->suspend_regs.pre, context->base + S3C2410_SDIPRE);
60 +       writel(context->suspend_regs.cmdarg, context->base + S3C2410_SDICMDARG);
61 +       writel(context->suspend_regs.cmdcon, context->base + S3C2410_SDICMDCON);
62 +       writel(context->suspend_regs.cmdsta, context->base + S3C2410_SDICMDSTAT);
63 +       writel(context->suspend_regs.r0, context->base + S3C2410_SDIRSP0);
64 +       writel(context->suspend_regs.r1, context->base + S3C2410_SDIRSP1);
65 +       writel(context->suspend_regs.r2, context->base + S3C2410_SDIRSP2);
66 +       writel(context->suspend_regs.r3, context->base + S3C2410_SDIRSP3);
67 +       writel(context->suspend_regs.timer, context->base + S3C2410_SDITIMER);
68 +       writel(context->suspend_regs.bsize, context->base + S3C2410_SDIBSIZE);
69 +       writel(context->suspend_regs.datcon, context->base + S3C2410_SDIDCON);
70 +       writel(context->suspend_regs.datcnt, context->base + S3C2410_SDIDCNT);
71 +       writel(context->suspend_regs.datsta, context->base + S3C2410_SDIDSTA);
72 +       writel(context->suspend_regs.fsta, context->base + S3C2410_SDIFSTA);
73 +       writel(context->suspend_regs.imask, context->base + S3C2440_SDIIMSK);
74 +
75 +       spin_unlock_irqrestore(&context->lock, flags);
76 +       return 0;
77 +}
78 +
79 +#else
80 +#define s3c24xx_hcd_suspend = NULL
81 +#define s3c24xx_hcd_resume  = NULL
82 +#endif
83 +
84  static struct platform_driver s3c24xx_hcd_sdio =
85  {
86         .driver.name    = "s3c24xx-sdio",
87         .probe          = s3c24xx_hcd_probe,
88         .remove         = s3c24xx_hcd_remove,
89 +       .suspend    = s3c24xx_hcd_suspend,
90 +       .resume         = s3c24xx_hcd_resume,
91  };
92  
93  #ifdef CONFIG_DEBUG_FS
94 diff --git a/drivers/sdio/hcd/s3c24xx/s3c24xx_hcd.h b/drivers/sdio/hcd/s3c24xx/s3c24xx_hcd.h
95 index eb262fc..47fdd33 100644
96 --- a/drivers/sdio/hcd/s3c24xx/s3c24xx_hcd.h
97 +++ b/drivers/sdio/hcd/s3c24xx/s3c24xx_hcd.h
98 @@ -57,6 +57,20 @@ struct s3c24xx_hcd_context {
99  
100         struct work_struct        io_work;
101         struct work_struct        irq_work;
102 +
103 +#ifdef CONFIG_PM
104 +       struct {
105 +               UINT32          con;
106 +               UINT32          pre;
107 +               UINT32          cmdarg, cmdcon, cmdsta;
108 +               UINT32          r0, r1, r2, r3;
109 +               UINT32          timer;
110 +               UINT32          bsize;
111 +               UINT32          datcon, datcnt, datsta;
112 +               UINT32          fsta;
113 +               UINT32          imask;  
114 +       } suspend_regs;
115 +#endif
116  };
117  
118  SDIO_STATUS s3c24xx_hcd_config(PSDHCD hcd, PSDCONFIG config);
119 -- 
120 1.5.6.3
121