diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-03-19 02:38:50 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-03-19 02:38:50 -0400 |
commit | 97eb3f24352ec6632c2127b35d8087d2a809a9b9 (patch) | |
tree | 722948059bbd325bbca232269490124231df80d4 /include/linux/mmc | |
parent | 439581ec07fa9cf3f519dd461a2cf41cfd3adcb4 (diff) | |
parent | def179c271ac9b5020deca798470521f14d11edd (diff) |
Merge branch 'next' into for-linus
Diffstat (limited to 'include/linux/mmc')
-rw-r--r-- | include/linux/mmc/dw_mmc.h | 217 | ||||
-rw-r--r-- | include/linux/mmc/host.h | 20 | ||||
-rw-r--r-- | include/linux/mmc/mmc.h | 2 | ||||
-rw-r--r-- | include/linux/mmc/sdhci.h | 6 | ||||
-rw-r--r-- | include/linux/mmc/sh_mmcif.h | 111 |
5 files changed, 313 insertions, 43 deletions
diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h new file mode 100644 index 000000000000..16b0261763ed --- /dev/null +++ b/include/linux/mmc/dw_mmc.h | |||
@@ -0,0 +1,217 @@ | |||
1 | /* | ||
2 | * Synopsys DesignWare Multimedia Card Interface driver | ||
3 | * (Based on NXP driver for lpc 31xx) | ||
4 | * | ||
5 | * Copyright (C) 2009 NXP Semiconductors | ||
6 | * Copyright (C) 2009, 2010 Imagination Technologies Ltd. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | */ | ||
13 | |||
14 | #ifndef _LINUX_MMC_DW_MMC_H_ | ||
15 | #define _LINUX_MMC_DW_MMC_H_ | ||
16 | |||
17 | #define MAX_MCI_SLOTS 2 | ||
18 | |||
19 | enum dw_mci_state { | ||
20 | STATE_IDLE = 0, | ||
21 | STATE_SENDING_CMD, | ||
22 | STATE_SENDING_DATA, | ||
23 | STATE_DATA_BUSY, | ||
24 | STATE_SENDING_STOP, | ||
25 | STATE_DATA_ERROR, | ||
26 | }; | ||
27 | |||
28 | enum { | ||
29 | EVENT_CMD_COMPLETE = 0, | ||
30 | EVENT_XFER_COMPLETE, | ||
31 | EVENT_DATA_COMPLETE, | ||
32 | EVENT_DATA_ERROR, | ||
33 | EVENT_XFER_ERROR | ||
34 | }; | ||
35 | |||
36 | struct mmc_data; | ||
37 | |||
38 | /** | ||
39 | * struct dw_mci - MMC controller state shared between all slots | ||
40 | * @lock: Spinlock protecting the queue and associated data. | ||
41 | * @regs: Pointer to MMIO registers. | ||
42 | * @sg: Scatterlist entry currently being processed by PIO code, if any. | ||
43 | * @pio_offset: Offset into the current scatterlist entry. | ||
44 | * @cur_slot: The slot which is currently using the controller. | ||
45 | * @mrq: The request currently being processed on @cur_slot, | ||
46 | * or NULL if the controller is idle. | ||
47 | * @cmd: The command currently being sent to the card, or NULL. | ||
48 | * @data: The data currently being transferred, or NULL if no data | ||
49 | * transfer is in progress. | ||
50 | * @use_dma: Whether DMA channel is initialized or not. | ||
51 | * @sg_dma: Bus address of DMA buffer. | ||
52 | * @sg_cpu: Virtual address of DMA buffer. | ||
53 | * @dma_ops: Pointer to platform-specific DMA callbacks. | ||
54 | * @cmd_status: Snapshot of SR taken upon completion of the current | ||
55 | * command. Only valid when EVENT_CMD_COMPLETE is pending. | ||
56 | * @data_status: Snapshot of SR taken upon completion of the current | ||
57 | * data transfer. Only valid when EVENT_DATA_COMPLETE or | ||
58 | * EVENT_DATA_ERROR is pending. | ||
59 | * @stop_cmdr: Value to be loaded into CMDR when the stop command is | ||
60 | * to be sent. | ||
61 | * @dir_status: Direction of current transfer. | ||
62 | * @tasklet: Tasklet running the request state machine. | ||
63 | * @card_tasklet: Tasklet handling card detect. | ||
64 | * @pending_events: Bitmask of events flagged by the interrupt handler | ||
65 | * to be processed by the tasklet. | ||
66 | * @completed_events: Bitmask of events which the state machine has | ||
67 | * processed. | ||
68 | * @state: Tasklet state. | ||
69 | * @queue: List of slots waiting for access to the controller. | ||
70 | * @bus_hz: The rate of @mck in Hz. This forms the basis for MMC bus | ||
71 | * rate and timeout calculations. | ||
72 | * @current_speed: Configured rate of the controller. | ||
73 | * @num_slots: Number of slots available. | ||
74 | * @pdev: Platform device associated with the MMC controller. | ||
75 | * @pdata: Platform data associated with the MMC controller. | ||
76 | * @slot: Slots sharing this MMC controller. | ||
77 | * @data_shift: log2 of FIFO item size. | ||
78 | * @push_data: Pointer to FIFO push function. | ||
79 | * @pull_data: Pointer to FIFO pull function. | ||
80 | * @quirks: Set of quirks that apply to specific versions of the IP. | ||
81 | * | ||
82 | * Locking | ||
83 | * ======= | ||
84 | * | ||
85 | * @lock is a softirq-safe spinlock protecting @queue as well as | ||
86 | * @cur_slot, @mrq and @state. These must always be updated | ||
87 | * at the same time while holding @lock. | ||
88 | * | ||
89 | * The @mrq field of struct dw_mci_slot is also protected by @lock, | ||
90 | * and must always be written at the same time as the slot is added to | ||
91 | * @queue. | ||
92 | * | ||
93 | * @pending_events and @completed_events are accessed using atomic bit | ||
94 | * operations, so they don't need any locking. | ||
95 | * | ||
96 | * None of the fields touched by the interrupt handler need any | ||
97 | * locking. However, ordering is important: Before EVENT_DATA_ERROR or | ||
98 | * EVENT_DATA_COMPLETE is set in @pending_events, all data-related | ||
99 | * interrupts must be disabled and @data_status updated with a | ||
100 | * snapshot of SR. Similarly, before EVENT_CMD_COMPLETE is set, the | ||
101 | * CMDRDY interupt must be disabled and @cmd_status updated with a | ||
102 | * snapshot of SR, and before EVENT_XFER_COMPLETE can be set, the | ||
103 | * bytes_xfered field of @data must be written. This is ensured by | ||
104 | * using barriers. | ||
105 | */ | ||
106 | struct dw_mci { | ||
107 | spinlock_t lock; | ||
108 | void __iomem *regs; | ||
109 | |||
110 | struct scatterlist *sg; | ||
111 | unsigned int pio_offset; | ||
112 | |||
113 | struct dw_mci_slot *cur_slot; | ||
114 | struct mmc_request *mrq; | ||
115 | struct mmc_command *cmd; | ||
116 | struct mmc_data *data; | ||
117 | |||
118 | /* DMA interface members*/ | ||
119 | int use_dma; | ||
120 | |||
121 | dma_addr_t sg_dma; | ||
122 | void *sg_cpu; | ||
123 | struct dw_mci_dma_ops *dma_ops; | ||
124 | #ifdef CONFIG_MMC_DW_IDMAC | ||
125 | unsigned int ring_size; | ||
126 | #else | ||
127 | struct dw_mci_dma_data *dma_data; | ||
128 | #endif | ||
129 | u32 cmd_status; | ||
130 | u32 data_status; | ||
131 | u32 stop_cmdr; | ||
132 | u32 dir_status; | ||
133 | struct tasklet_struct tasklet; | ||
134 | struct tasklet_struct card_tasklet; | ||
135 | unsigned long pending_events; | ||
136 | unsigned long completed_events; | ||
137 | enum dw_mci_state state; | ||
138 | struct list_head queue; | ||
139 | |||
140 | u32 bus_hz; | ||
141 | u32 current_speed; | ||
142 | u32 num_slots; | ||
143 | struct platform_device *pdev; | ||
144 | struct dw_mci_board *pdata; | ||
145 | struct dw_mci_slot *slot[MAX_MCI_SLOTS]; | ||
146 | |||
147 | /* FIFO push and pull */ | ||
148 | int data_shift; | ||
149 | void (*push_data)(struct dw_mci *host, void *buf, int cnt); | ||
150 | void (*pull_data)(struct dw_mci *host, void *buf, int cnt); | ||
151 | |||
152 | /* Workaround flags */ | ||
153 | u32 quirks; | ||
154 | }; | ||
155 | |||
156 | /* DMA ops for Internal/External DMAC interface */ | ||
157 | struct dw_mci_dma_ops { | ||
158 | /* DMA Ops */ | ||
159 | int (*init)(struct dw_mci *host); | ||
160 | void (*start)(struct dw_mci *host, unsigned int sg_len); | ||
161 | void (*complete)(struct dw_mci *host); | ||
162 | void (*stop)(struct dw_mci *host); | ||
163 | void (*cleanup)(struct dw_mci *host); | ||
164 | void (*exit)(struct dw_mci *host); | ||
165 | }; | ||
166 | |||
167 | /* IP Quirks/flags. */ | ||
168 | /* No special quirks or flags to cater for */ | ||
169 | #define DW_MCI_QUIRK_NONE 0 | ||
170 | /* DTO fix for command transmission with IDMAC configured */ | ||
171 | #define DW_MCI_QUIRK_IDMAC_DTO 1 | ||
172 | /* delay needed between retries on some 2.11a implementations */ | ||
173 | #define DW_MCI_QUIRK_RETRY_DELAY 2 | ||
174 | /* High Speed Capable - Supports HS cards (upto 50MHz) */ | ||
175 | #define DW_MCI_QUIRK_HIGHSPEED 4 | ||
176 | |||
177 | |||
178 | struct dma_pdata; | ||
179 | |||
180 | struct block_settings { | ||
181 | unsigned short max_segs; /* see blk_queue_max_segments */ | ||
182 | unsigned int max_blk_size; /* maximum size of one mmc block */ | ||
183 | unsigned int max_blk_count; /* maximum number of blocks in one req*/ | ||
184 | unsigned int max_req_size; /* maximum number of bytes in one req*/ | ||
185 | unsigned int max_seg_size; /* see blk_queue_max_segment_size */ | ||
186 | }; | ||
187 | |||
188 | /* Board platform data */ | ||
189 | struct dw_mci_board { | ||
190 | u32 num_slots; | ||
191 | |||
192 | u32 quirks; /* Workaround / Quirk flags */ | ||
193 | unsigned int bus_hz; /* Bus speed */ | ||
194 | |||
195 | /* delay in mS before detecting cards after interrupt */ | ||
196 | u32 detect_delay_ms; | ||
197 | |||
198 | int (*init)(u32 slot_id, irq_handler_t , void *); | ||
199 | int (*get_ro)(u32 slot_id); | ||
200 | int (*get_cd)(u32 slot_id); | ||
201 | int (*get_ocr)(u32 slot_id); | ||
202 | int (*get_bus_wd)(u32 slot_id); | ||
203 | /* | ||
204 | * Enable power to selected slot and set voltage to desired level. | ||
205 | * Voltage levels are specified using MMC_VDD_xxx defines defined | ||
206 | * in linux/mmc/host.h file. | ||
207 | */ | ||
208 | void (*setpower)(u32 slot_id, u32 volt); | ||
209 | void (*exit)(u32 slot_id); | ||
210 | void (*select_slot)(u32 slot_id); | ||
211 | |||
212 | struct dw_mci_dma_ops *dma_ops; | ||
213 | struct dma_pdata *data; | ||
214 | struct block_settings *blk_settings; | ||
215 | }; | ||
216 | |||
217 | #endif /* _LINUX_MMC_DW_MMC_H_ */ | ||
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 6d87f68ce4b6..bcb793ec7374 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h | |||
@@ -131,6 +131,9 @@ struct mmc_host { | |||
131 | unsigned int f_max; | 131 | unsigned int f_max; |
132 | unsigned int f_init; | 132 | unsigned int f_init; |
133 | u32 ocr_avail; | 133 | u32 ocr_avail; |
134 | u32 ocr_avail_sdio; /* SDIO-specific OCR */ | ||
135 | u32 ocr_avail_sd; /* SD-specific OCR */ | ||
136 | u32 ocr_avail_mmc; /* MMC-specific OCR */ | ||
134 | struct notifier_block pm_notify; | 137 | struct notifier_block pm_notify; |
135 | 138 | ||
136 | #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ | 139 | #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ |
@@ -168,9 +171,21 @@ struct mmc_host { | |||
168 | /* DDR mode at 1.8V */ | 171 | /* DDR mode at 1.8V */ |
169 | #define MMC_CAP_1_2V_DDR (1 << 12) /* can support */ | 172 | #define MMC_CAP_1_2V_DDR (1 << 12) /* can support */ |
170 | /* DDR mode at 1.2V */ | 173 | /* DDR mode at 1.2V */ |
174 | #define MMC_CAP_POWER_OFF_CARD (1 << 13) /* Can power off after boot */ | ||
175 | #define MMC_CAP_BUS_WIDTH_TEST (1 << 14) /* CMD14/CMD19 bus width ok */ | ||
171 | 176 | ||
172 | mmc_pm_flag_t pm_caps; /* supported pm features */ | 177 | mmc_pm_flag_t pm_caps; /* supported pm features */ |
173 | 178 | ||
179 | #ifdef CONFIG_MMC_CLKGATE | ||
180 | int clk_requests; /* internal reference counter */ | ||
181 | unsigned int clk_delay; /* number of MCI clk hold cycles */ | ||
182 | bool clk_gated; /* clock gated */ | ||
183 | struct work_struct clk_gate_work; /* delayed clock gate */ | ||
184 | unsigned int clk_old; /* old clock value cache */ | ||
185 | spinlock_t clk_lock; /* lock for clk fields */ | ||
186 | struct mutex clk_gate_mutex; /* mutex for clock gating */ | ||
187 | #endif | ||
188 | |||
174 | /* host specific block data */ | 189 | /* host specific block data */ |
175 | unsigned int max_seg_size; /* see blk_queue_max_segment_size */ | 190 | unsigned int max_seg_size; /* see blk_queue_max_segment_size */ |
176 | unsigned short max_segs; /* see blk_queue_max_segments */ | 191 | unsigned short max_segs; /* see blk_queue_max_segments */ |
@@ -306,5 +321,10 @@ static inline int mmc_card_is_removable(struct mmc_host *host) | |||
306 | return !(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable; | 321 | return !(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable; |
307 | } | 322 | } |
308 | 323 | ||
324 | static inline int mmc_card_is_powered_resumed(struct mmc_host *host) | ||
325 | { | ||
326 | return host->pm_flags & MMC_PM_KEEP_POWER; | ||
327 | } | ||
328 | |||
309 | #endif | 329 | #endif |
310 | 330 | ||
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 956fbd877692..612301f85d14 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h | |||
@@ -40,7 +40,9 @@ | |||
40 | #define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */ | 40 | #define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */ |
41 | #define MMC_STOP_TRANSMISSION 12 /* ac R1b */ | 41 | #define MMC_STOP_TRANSMISSION 12 /* ac R1b */ |
42 | #define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */ | 42 | #define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */ |
43 | #define MMC_BUS_TEST_R 14 /* adtc R1 */ | ||
43 | #define MMC_GO_INACTIVE_STATE 15 /* ac [31:16] RCA */ | 44 | #define MMC_GO_INACTIVE_STATE 15 /* ac [31:16] RCA */ |
45 | #define MMC_BUS_TEST_W 19 /* adtc R1 */ | ||
44 | #define MMC_SPI_READ_OCR 58 /* spi spi_R3 */ | 46 | #define MMC_SPI_READ_OCR 58 /* spi spi_R3 */ |
45 | #define MMC_SPI_CRC_ON_OFF 59 /* spi [0:0] flag spi_R1 */ | 47 | #define MMC_SPI_CRC_ON_OFF 59 /* spi [0:0] flag spi_R1 */ |
46 | 48 | ||
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h index 1fdc673f2396..83bd9f76709a 100644 --- a/include/linux/mmc/sdhci.h +++ b/include/linux/mmc/sdhci.h | |||
@@ -83,6 +83,8 @@ struct sdhci_host { | |||
83 | #define SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 (1<<28) | 83 | #define SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 (1<<28) |
84 | /* Controller doesn't have HISPD bit field in HI-SPEED SD card */ | 84 | /* Controller doesn't have HISPD bit field in HI-SPEED SD card */ |
85 | #define SDHCI_QUIRK_NO_HISPD_BIT (1<<29) | 85 | #define SDHCI_QUIRK_NO_HISPD_BIT (1<<29) |
86 | /* Controller treats ADMA descriptors with length 0000h incorrectly */ | ||
87 | #define SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC (1<<30) | ||
86 | 88 | ||
87 | int irq; /* Device IRQ */ | 89 | int irq; /* Device IRQ */ |
88 | void __iomem *ioaddr; /* Mapped address */ | 90 | void __iomem *ioaddr; /* Mapped address */ |
@@ -139,6 +141,10 @@ struct sdhci_host { | |||
139 | 141 | ||
140 | unsigned int caps; /* Alternative capabilities */ | 142 | unsigned int caps; /* Alternative capabilities */ |
141 | 143 | ||
144 | unsigned int ocr_avail_sdio; /* OCR bit masks */ | ||
145 | unsigned int ocr_avail_sd; | ||
146 | unsigned int ocr_avail_mmc; | ||
147 | |||
142 | unsigned long private[0] ____cacheline_aligned; | 148 | unsigned long private[0] ____cacheline_aligned; |
143 | }; | 149 | }; |
144 | #endif /* __SDHCI_H */ | 150 | #endif /* __SDHCI_H */ |
diff --git a/include/linux/mmc/sh_mmcif.h b/include/linux/mmc/sh_mmcif.h index d19e2114fd86..38d393092812 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,19 +66,48 @@ 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 | ||
62 | extern inline u32 sh_mmcif_readl(void __iomem *addr, int reg) | 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 | |||
95 | static inline u32 sh_mmcif_readl(void __iomem *addr, int reg) | ||
63 | { | 96 | { |
64 | return readl(addr + reg); | 97 | return __raw_readl(addr + reg); |
65 | } | 98 | } |
66 | 99 | ||
67 | extern inline void sh_mmcif_writel(void __iomem *addr, int reg, u32 val) | 100 | static inline void sh_mmcif_writel(void __iomem *addr, int reg, u32 val) |
68 | { | 101 | { |
69 | writel(val, addr + reg); | 102 | __raw_writel(val, addr + reg); |
70 | } | 103 | } |
71 | 104 | ||
72 | #define SH_MMCIF_BBS 512 /* boot block size */ | 105 | #define SH_MMCIF_BBS 512 /* boot block size */ |
73 | 106 | ||
74 | extern inline void sh_mmcif_boot_cmd_send(void __iomem *base, | 107 | enum { MMCIF_PROGRESS_ENTER, MMCIF_PROGRESS_INIT, |
108 | MMCIF_PROGRESS_LOAD, MMCIF_PROGRESS_DONE }; | ||
109 | |||
110 | static inline void sh_mmcif_boot_cmd_send(void __iomem *base, | ||
75 | unsigned long cmd, unsigned long arg) | 111 | unsigned long cmd, unsigned long arg) |
76 | { | 112 | { |
77 | sh_mmcif_writel(base, MMCIF_CE_INT, 0); | 113 | sh_mmcif_writel(base, MMCIF_CE_INT, 0); |
@@ -79,7 +115,7 @@ extern inline void sh_mmcif_boot_cmd_send(void __iomem *base, | |||
79 | sh_mmcif_writel(base, MMCIF_CE_CMD_SET, cmd); | 115 | sh_mmcif_writel(base, MMCIF_CE_CMD_SET, cmd); |
80 | } | 116 | } |
81 | 117 | ||
82 | extern inline int sh_mmcif_boot_cmd_poll(void __iomem *base, unsigned long mask) | 118 | static inline int sh_mmcif_boot_cmd_poll(void __iomem *base, unsigned long mask) |
83 | { | 119 | { |
84 | unsigned long tmp; | 120 | unsigned long tmp; |
85 | int cnt; | 121 | int cnt; |
@@ -95,14 +131,14 @@ extern inline int sh_mmcif_boot_cmd_poll(void __iomem *base, unsigned long mask) | |||
95 | return -1; | 131 | return -1; |
96 | } | 132 | } |
97 | 133 | ||
98 | extern inline int sh_mmcif_boot_cmd(void __iomem *base, | 134 | static inline int sh_mmcif_boot_cmd(void __iomem *base, |
99 | unsigned long cmd, unsigned long arg) | 135 | unsigned long cmd, unsigned long arg) |
100 | { | 136 | { |
101 | sh_mmcif_boot_cmd_send(base, cmd, arg); | 137 | sh_mmcif_boot_cmd_send(base, cmd, arg); |
102 | return sh_mmcif_boot_cmd_poll(base, 0x00010000); | 138 | return sh_mmcif_boot_cmd_poll(base, 0x00010000); |
103 | } | 139 | } |
104 | 140 | ||
105 | extern inline int sh_mmcif_boot_do_read_single(void __iomem *base, | 141 | static inline int sh_mmcif_boot_do_read_single(void __iomem *base, |
106 | unsigned int block_nr, | 142 | unsigned int block_nr, |
107 | unsigned long *buf) | 143 | unsigned long *buf) |
108 | { | 144 | { |
@@ -125,7 +161,7 @@ extern inline int sh_mmcif_boot_do_read_single(void __iomem *base, | |||
125 | return 0; | 161 | return 0; |
126 | } | 162 | } |
127 | 163 | ||
128 | extern inline int sh_mmcif_boot_do_read(void __iomem *base, | 164 | static inline int sh_mmcif_boot_do_read(void __iomem *base, |
129 | unsigned long first_block, | 165 | unsigned long first_block, |
130 | unsigned long nr_blocks, | 166 | unsigned long nr_blocks, |
131 | void *buf) | 167 | void *buf) |
@@ -133,6 +169,17 @@ extern inline int sh_mmcif_boot_do_read(void __iomem *base, | |||
133 | unsigned long k; | 169 | unsigned long k; |
134 | int ret = 0; | 170 | int ret = 0; |
135 | 171 | ||
172 | /* In data transfer mode: Set clock to Bus clock/4 (about 20Mhz) */ | ||
173 | sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL, | ||
174 | CLK_ENABLE | CLKDIV_4 | SRSPTO_256 | | ||
175 | SRBSYTO_29 | SRWDTO_29 | SCCSTO_29); | ||
176 | |||
177 | /* CMD9 - Get CSD */ | ||
178 | sh_mmcif_boot_cmd(base, 0x09806000, 0x00010000); | ||
179 | |||
180 | /* CMD7 - Select the card */ | ||
181 | sh_mmcif_boot_cmd(base, 0x07400000, 0x00010000); | ||
182 | |||
136 | /* CMD16 - Set the block size */ | 183 | /* CMD16 - Set the block size */ |
137 | sh_mmcif_boot_cmd(base, 0x10400000, SH_MMCIF_BBS); | 184 | sh_mmcif_boot_cmd(base, 0x10400000, SH_MMCIF_BBS); |
138 | 185 | ||
@@ -143,23 +190,22 @@ extern inline int sh_mmcif_boot_do_read(void __iomem *base, | |||
143 | return ret; | 190 | return ret; |
144 | } | 191 | } |
145 | 192 | ||
146 | extern inline void sh_mmcif_boot_init(void __iomem *base) | 193 | static inline void sh_mmcif_boot_init(void __iomem *base) |
147 | { | 194 | { |
148 | unsigned long tmp; | ||
149 | |||
150 | /* reset */ | 195 | /* reset */ |
151 | tmp = sh_mmcif_readl(base, MMCIF_CE_VERSION); | 196 | sh_mmcif_writel(base, MMCIF_CE_VERSION, SOFT_RST_ON); |
152 | sh_mmcif_writel(base, MMCIF_CE_VERSION, tmp | 0x80000000); | 197 | sh_mmcif_writel(base, MMCIF_CE_VERSION, SOFT_RST_OFF); |
153 | sh_mmcif_writel(base, MMCIF_CE_VERSION, tmp & ~0x80000000); | ||
154 | 198 | ||
155 | /* byte swap */ | 199 | /* byte swap */ |
156 | sh_mmcif_writel(base, MMCIF_CE_BUF_ACC, 0x00010000); | 200 | sh_mmcif_writel(base, MMCIF_CE_BUF_ACC, BUF_ACC_ATYP); |
157 | 201 | ||
158 | /* Set block size in MMCIF hardware */ | 202 | /* Set block size in MMCIF hardware */ |
159 | sh_mmcif_writel(base, MMCIF_CE_BLOCK_SET, SH_MMCIF_BBS); | 203 | sh_mmcif_writel(base, MMCIF_CE_BLOCK_SET, SH_MMCIF_BBS); |
160 | 204 | ||
161 | /* Enable the clock, set it to Bus clock/256 (about 325Khz)*/ | 205 | /* Enable the clock, set it to Bus clock/256 (about 325Khz). */ |
162 | sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL, 0x01072fff); | 206 | sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL, |
207 | CLK_ENABLE | CLKDIV_256 | SRSPTO_256 | | ||
208 | SRBSYTO_29 | SRWDTO_29 | SCCSTO_29); | ||
163 | 209 | ||
164 | /* CMD0 */ | 210 | /* CMD0 */ |
165 | sh_mmcif_boot_cmd(base, 0x00000040, 0); | 211 | sh_mmcif_boot_cmd(base, 0x00000040, 0); |
@@ -177,25 +223,4 @@ extern inline void sh_mmcif_boot_init(void __iomem *base) | |||
177 | sh_mmcif_boot_cmd(base, 0x03400040, 0x00010000); | 223 | sh_mmcif_boot_cmd(base, 0x03400040, 0x00010000); |
178 | } | 224 | } |
179 | 225 | ||
180 | extern inline void sh_mmcif_boot_slurp(void __iomem *base, | ||
181 | unsigned char *buf, | ||
182 | unsigned long no_bytes) | ||
183 | { | ||
184 | unsigned long tmp; | ||
185 | |||
186 | /* In data transfer mode: Set clock to Bus clock/4 (about 20Mhz) */ | ||
187 | sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL, 0x01012fff); | ||
188 | |||
189 | /* CMD9 - Get CSD */ | ||
190 | sh_mmcif_boot_cmd(base, 0x09806000, 0x00010000); | ||
191 | |||
192 | /* CMD7 - Select the card */ | ||
193 | sh_mmcif_boot_cmd(base, 0x07400000, 0x00010000); | ||
194 | |||
195 | tmp = no_bytes / SH_MMCIF_BBS; | ||
196 | tmp += (no_bytes % SH_MMCIF_BBS) ? 1 : 0; | ||
197 | |||
198 | sh_mmcif_boot_do_read(base, 512, tmp, buf); | ||
199 | } | ||
200 | |||
201 | #endif /* __SH_MMCIF_H__ */ | 226 | #endif /* __SH_MMCIF_H__ */ |