diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/mmc/sh_mmcif.h | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/include/linux/mmc/sh_mmcif.h b/include/linux/mmc/sh_mmcif.h index 5c99da1078aa..44fc5348fd5d 100644 --- a/include/linux/mmc/sh_mmcif.h +++ b/include/linux/mmc/sh_mmcif.h | |||
@@ -14,8 +14,9 @@ | |||
14 | #ifndef __SH_MMCIF_H__ | 14 | #ifndef __SH_MMCIF_H__ |
15 | #define __SH_MMCIF_H__ | 15 | #define __SH_MMCIF_H__ |
16 | 16 | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/sh_dma.h> | ||
19 | 20 | ||
20 | /* | 21 | /* |
21 | * MMCIF : CE_CLK_CTRL [19:16] | 22 | * MMCIF : CE_CLK_CTRL [19:16] |
@@ -31,13 +32,19 @@ | |||
31 | * 1111 : Peripheral clock (sup_pclk set '1') | 32 | * 1111 : Peripheral clock (sup_pclk set '1') |
32 | */ | 33 | */ |
33 | 34 | ||
35 | struct sh_mmcif_dma { | ||
36 | struct sh_dmae_slave chan_priv_tx; | ||
37 | struct sh_dmae_slave chan_priv_rx; | ||
38 | }; | ||
39 | |||
34 | struct sh_mmcif_plat_data { | 40 | struct sh_mmcif_plat_data { |
35 | void (*set_pwr)(struct platform_device *pdev, int state); | 41 | void (*set_pwr)(struct platform_device *pdev, int state); |
36 | void (*down_pwr)(struct platform_device *pdev); | 42 | void (*down_pwr)(struct platform_device *pdev); |
37 | int (*get_cd)(struct platform_device *pdef); | 43 | int (*get_cd)(struct platform_device *pdef); |
38 | u8 sup_pclk; /* 1 :SH7757, 0: SH7724/SH7372 */ | 44 | struct sh_mmcif_dma *dma; |
39 | unsigned long caps; | 45 | u8 sup_pclk; /* 1 :SH7757, 0: SH7724/SH7372 */ |
40 | u32 ocr; | 46 | unsigned long caps; |
47 | u32 ocr; | ||
41 | }; | 48 | }; |
42 | 49 | ||
43 | #define MMCIF_CE_CMD_SET 0x00000000 | 50 | #define MMCIF_CE_CMD_SET 0x00000000 |
@@ -59,6 +66,32 @@ struct sh_mmcif_plat_data { | |||
59 | #define MMCIF_CE_HOST_STS2 0x0000004C | 66 | #define MMCIF_CE_HOST_STS2 0x0000004C |
60 | #define MMCIF_CE_VERSION 0x0000007C | 67 | #define MMCIF_CE_VERSION 0x0000007C |
61 | 68 | ||
69 | /* CE_BUF_ACC */ | ||
70 | #define BUF_ACC_DMAWEN (1 << 25) | ||
71 | #define BUF_ACC_DMAREN (1 << 24) | ||
72 | #define BUF_ACC_BUSW_32 (0 << 17) | ||
73 | #define BUF_ACC_BUSW_16 (1 << 17) | ||
74 | #define BUF_ACC_ATYP (1 << 16) | ||
75 | |||
76 | /* CE_CLK_CTRL */ | ||
77 | #define CLK_ENABLE (1 << 24) /* 1: output mmc clock */ | ||
78 | #define CLK_CLEAR ((1 << 19) | (1 << 18) | (1 << 17) | (1 << 16)) | ||
79 | #define CLK_SUP_PCLK ((1 << 19) | (1 << 18) | (1 << 17) | (1 << 16)) | ||
80 | #define CLKDIV_4 (1<<16) /* mmc clock frequency. | ||
81 | * n: bus clock/(2^(n+1)) */ | ||
82 | #define CLKDIV_256 (7<<16) /* mmc clock frequency. (see above) */ | ||
83 | #define SRSPTO_256 ((1 << 13) | (0 << 12)) /* resp timeout */ | ||
84 | #define SRBSYTO_29 ((1 << 11) | (1 << 10) | \ | ||
85 | (1 << 9) | (1 << 8)) /* resp busy timeout */ | ||
86 | #define SRWDTO_29 ((1 << 7) | (1 << 6) | \ | ||
87 | (1 << 5) | (1 << 4)) /* read/write timeout */ | ||
88 | #define SCCSTO_29 ((1 << 3) | (1 << 2) | \ | ||
89 | (1 << 1) | (1 << 0)) /* ccs timeout */ | ||
90 | |||
91 | /* CE_VERSION */ | ||
92 | #define SOFT_RST_ON (1 << 31) | ||
93 | #define SOFT_RST_OFF 0 | ||
94 | |||
62 | static inline u32 sh_mmcif_readl(void __iomem *addr, int reg) | 95 | static inline u32 sh_mmcif_readl(void __iomem *addr, int reg) |
63 | { | 96 | { |
64 | return readl(addr + reg); | 97 | return readl(addr + reg); |
@@ -145,21 +178,20 @@ static inline int sh_mmcif_boot_do_read(void __iomem *base, | |||
145 | 178 | ||
146 | static inline void sh_mmcif_boot_init(void __iomem *base) | 179 | static inline void sh_mmcif_boot_init(void __iomem *base) |
147 | { | 180 | { |
148 | unsigned long tmp; | ||
149 | |||
150 | /* reset */ | 181 | /* reset */ |
151 | tmp = sh_mmcif_readl(base, MMCIF_CE_VERSION); | 182 | sh_mmcif_writel(base, MMCIF_CE_VERSION, SOFT_RST_ON); |
152 | sh_mmcif_writel(base, MMCIF_CE_VERSION, tmp | 0x80000000); | 183 | sh_mmcif_writel(base, MMCIF_CE_VERSION, SOFT_RST_OFF); |
153 | sh_mmcif_writel(base, MMCIF_CE_VERSION, tmp & ~0x80000000); | ||
154 | 184 | ||
155 | /* byte swap */ | 185 | /* byte swap */ |
156 | sh_mmcif_writel(base, MMCIF_CE_BUF_ACC, 0x00010000); | 186 | sh_mmcif_writel(base, MMCIF_CE_BUF_ACC, BUF_ACC_ATYP); |
157 | 187 | ||
158 | /* Set block size in MMCIF hardware */ | 188 | /* Set block size in MMCIF hardware */ |
159 | sh_mmcif_writel(base, MMCIF_CE_BLOCK_SET, SH_MMCIF_BBS); | 189 | sh_mmcif_writel(base, MMCIF_CE_BLOCK_SET, SH_MMCIF_BBS); |
160 | 190 | ||
161 | /* Enable the clock, set it to Bus clock/256 (about 325Khz)*/ | 191 | /* Enable the clock, set it to Bus clock/256 (about 325Khz). */ |
162 | sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL, 0x01072fff); | 192 | sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL, |
193 | CLK_ENABLE | CLKDIV_256 | SRSPTO_256 | | ||
194 | SRBSYTO_29 | SRWDTO_29 | SCCSTO_29); | ||
163 | 195 | ||
164 | /* CMD0 */ | 196 | /* CMD0 */ |
165 | sh_mmcif_boot_cmd(base, 0x00000040, 0); | 197 | sh_mmcif_boot_cmd(base, 0x00000040, 0); |
@@ -184,7 +216,9 @@ static inline void sh_mmcif_boot_slurp(void __iomem *base, | |||
184 | unsigned long tmp; | 216 | unsigned long tmp; |
185 | 217 | ||
186 | /* In data transfer mode: Set clock to Bus clock/4 (about 20Mhz) */ | 218 | /* In data transfer mode: Set clock to Bus clock/4 (about 20Mhz) */ |
187 | sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL, 0x01012fff); | 219 | sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL, |
220 | CLK_ENABLE | CLKDIV_4 | SRSPTO_256 | | ||
221 | SRBSYTO_29 | SRWDTO_29 | SCCSTO_29); | ||
188 | 222 | ||
189 | /* CMD9 - Get CSD */ | 223 | /* CMD9 - Get CSD */ |
190 | sh_mmcif_boot_cmd(base, 0x09806000, 0x00010000); | 224 | sh_mmcif_boot_cmd(base, 0x09806000, 0x00010000); |