diff options
Diffstat (limited to 'drivers/mmc/host/tmio_mmc_pio.c')
-rw-r--r-- | drivers/mmc/host/tmio_mmc_pio.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index f3b2d8ca1eca..8d8abf23a611 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c | |||
@@ -161,10 +161,8 @@ static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock) | |||
161 | 161 | ||
162 | static void tmio_mmc_clk_stop(struct tmio_mmc_host *host) | 162 | static void tmio_mmc_clk_stop(struct tmio_mmc_host *host) |
163 | { | 163 | { |
164 | struct resource *res = platform_get_resource(host->pdev, IORESOURCE_MEM, 0); | ||
165 | |||
166 | /* implicit BUG_ON(!res) */ | 164 | /* implicit BUG_ON(!res) */ |
167 | if (resource_size(res) > 0x100) { | 165 | if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) { |
168 | sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0000); | 166 | sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0000); |
169 | msleep(10); | 167 | msleep(10); |
170 | } | 168 | } |
@@ -176,14 +174,12 @@ static void tmio_mmc_clk_stop(struct tmio_mmc_host *host) | |||
176 | 174 | ||
177 | static void tmio_mmc_clk_start(struct tmio_mmc_host *host) | 175 | static void tmio_mmc_clk_start(struct tmio_mmc_host *host) |
178 | { | 176 | { |
179 | struct resource *res = platform_get_resource(host->pdev, IORESOURCE_MEM, 0); | ||
180 | |||
181 | sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, 0x0100 | | 177 | sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, 0x0100 | |
182 | sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL)); | 178 | sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL)); |
183 | msleep(10); | 179 | msleep(10); |
184 | 180 | ||
185 | /* implicit BUG_ON(!res) */ | 181 | /* implicit BUG_ON(!res) */ |
186 | if (resource_size(res) > 0x100) { | 182 | if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) { |
187 | sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0100); | 183 | sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0100); |
188 | msleep(10); | 184 | msleep(10); |
189 | } | 185 | } |
@@ -191,16 +187,14 @@ static void tmio_mmc_clk_start(struct tmio_mmc_host *host) | |||
191 | 187 | ||
192 | static void tmio_mmc_reset(struct tmio_mmc_host *host) | 188 | static void tmio_mmc_reset(struct tmio_mmc_host *host) |
193 | { | 189 | { |
194 | struct resource *res = platform_get_resource(host->pdev, IORESOURCE_MEM, 0); | ||
195 | |||
196 | /* FIXME - should we set stop clock reg here */ | 190 | /* FIXME - should we set stop clock reg here */ |
197 | sd_ctrl_write16(host, CTL_RESET_SD, 0x0000); | 191 | sd_ctrl_write16(host, CTL_RESET_SD, 0x0000); |
198 | /* implicit BUG_ON(!res) */ | 192 | /* implicit BUG_ON(!res) */ |
199 | if (resource_size(res) > 0x100) | 193 | if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) |
200 | sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0000); | 194 | sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0000); |
201 | msleep(10); | 195 | msleep(10); |
202 | sd_ctrl_write16(host, CTL_RESET_SD, 0x0001); | 196 | sd_ctrl_write16(host, CTL_RESET_SD, 0x0001); |
203 | if (resource_size(res) > 0x100) | 197 | if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) |
204 | sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0001); | 198 | sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0001); |
205 | msleep(10); | 199 | msleep(10); |
206 | } | 200 | } |
@@ -944,17 +938,25 @@ static const struct mmc_host_ops tmio_mmc_ops = { | |||
944 | .enable_sdio_irq = tmio_mmc_enable_sdio_irq, | 938 | .enable_sdio_irq = tmio_mmc_enable_sdio_irq, |
945 | }; | 939 | }; |
946 | 940 | ||
947 | static void tmio_mmc_init_ocr(struct tmio_mmc_host *host) | 941 | static int tmio_mmc_init_ocr(struct tmio_mmc_host *host) |
948 | { | 942 | { |
949 | struct tmio_mmc_data *pdata = host->pdata; | 943 | struct tmio_mmc_data *pdata = host->pdata; |
950 | struct mmc_host *mmc = host->mmc; | 944 | struct mmc_host *mmc = host->mmc; |
951 | 945 | ||
952 | mmc_regulator_get_supply(mmc); | 946 | mmc_regulator_get_supply(mmc); |
953 | 947 | ||
948 | /* use ocr_mask if no regulator */ | ||
954 | if (!mmc->ocr_avail) | 949 | if (!mmc->ocr_avail) |
955 | mmc->ocr_avail = pdata->ocr_mask ? : MMC_VDD_32_33 | MMC_VDD_33_34; | 950 | mmc->ocr_avail = pdata->ocr_mask; |
956 | else if (pdata->ocr_mask) | 951 | |
957 | dev_warn(mmc_dev(mmc), "Platform OCR mask is ignored\n"); | 952 | /* |
953 | * try again. | ||
954 | * There is possibility that regulator has not been probed | ||
955 | */ | ||
956 | if (!mmc->ocr_avail) | ||
957 | return -EPROBE_DEFER; | ||
958 | |||
959 | return 0; | ||
958 | } | 960 | } |
959 | 961 | ||
960 | static void tmio_mmc_of_parse(struct platform_device *pdev, | 962 | static void tmio_mmc_of_parse(struct platform_device *pdev, |
@@ -1005,8 +1007,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
1005 | _host->set_pwr = pdata->set_pwr; | 1007 | _host->set_pwr = pdata->set_pwr; |
1006 | _host->set_clk_div = pdata->set_clk_div; | 1008 | _host->set_clk_div = pdata->set_clk_div; |
1007 | 1009 | ||
1008 | /* SD control register space size is 0x200, 0x400 for bus_shift=1 */ | 1010 | ret = tmio_mmc_init_ocr(_host); |
1009 | _host->bus_shift = resource_size(res_ctl) >> 10; | 1011 | if (ret < 0) |
1012 | goto host_free; | ||
1010 | 1013 | ||
1011 | _host->ctl = ioremap(res_ctl->start, resource_size(res_ctl)); | 1014 | _host->ctl = ioremap(res_ctl->start, resource_size(res_ctl)); |
1012 | if (!_host->ctl) { | 1015 | if (!_host->ctl) { |
@@ -1016,14 +1019,13 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
1016 | 1019 | ||
1017 | mmc->ops = &tmio_mmc_ops; | 1020 | mmc->ops = &tmio_mmc_ops; |
1018 | mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; | 1021 | mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; |
1019 | mmc->caps2 = pdata->capabilities2; | 1022 | mmc->caps2 |= pdata->capabilities2; |
1020 | mmc->max_segs = 32; | 1023 | mmc->max_segs = 32; |
1021 | mmc->max_blk_size = 512; | 1024 | mmc->max_blk_size = 512; |
1022 | mmc->max_blk_count = (PAGE_CACHE_SIZE / mmc->max_blk_size) * | 1025 | mmc->max_blk_count = (PAGE_CACHE_SIZE / mmc->max_blk_size) * |
1023 | mmc->max_segs; | 1026 | mmc->max_segs; |
1024 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; | 1027 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; |
1025 | mmc->max_seg_size = mmc->max_req_size; | 1028 | mmc->max_seg_size = mmc->max_req_size; |
1026 | tmio_mmc_init_ocr(_host); | ||
1027 | 1029 | ||
1028 | _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD || | 1030 | _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD || |
1029 | mmc->caps & MMC_CAP_NEEDS_POLL || | 1031 | mmc->caps & MMC_CAP_NEEDS_POLL || |