diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2010-03-21 02:33:08 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2010-10-23 09:11:20 -0400 |
commit | 19d614a45ae4beb4712bb50ba3d816ae3fe0f1f2 (patch) | |
tree | f3f019eebd38d4fa73100593654d0d6dd4d75e6b /drivers/mmc | |
parent | 703aae3d09a4b351866f1a97b2afafb905bdbf1e (diff) |
mmc: cb710: partially demystify clock selection
Clock divider selection in partially verified, so document known facts
in code.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/cb710-mmc.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/mmc/host/cb710-mmc.c b/drivers/mmc/host/cb710-mmc.c index ca3bdc831900..ad61c4c11071 100644 --- a/drivers/mmc/host/cb710-mmc.c +++ b/drivers/mmc/host/cb710-mmc.c | |||
@@ -25,7 +25,7 @@ static const u8 cb710_src_freq_mhz[16] = { | |||
25 | 50, 55, 60, 65, 70, 75, 80, 85 | 25 | 50, 55, 60, 65, 70, 75, 80, 85 |
26 | }; | 26 | }; |
27 | 27 | ||
28 | static void cb710_mmc_set_clock(struct mmc_host *mmc, int hz) | 28 | static void cb710_mmc_select_clock_divider(struct mmc_host *mmc, int hz) |
29 | { | 29 | { |
30 | struct cb710_slot *slot = cb710_mmc_to_slot(mmc); | 30 | struct cb710_slot *slot = cb710_mmc_to_slot(mmc); |
31 | struct pci_dev *pdev = cb710_slot_to_chip(slot)->pdev; | 31 | struct pci_dev *pdev = cb710_slot_to_chip(slot)->pdev; |
@@ -33,8 +33,11 @@ static void cb710_mmc_set_clock(struct mmc_host *mmc, int hz) | |||
33 | u32 divider_idx; | 33 | u32 divider_idx; |
34 | int src_hz; | 34 | int src_hz; |
35 | 35 | ||
36 | /* this is magic, unverifiable for me, unless I get | 36 | /* on CB710 in HP nx9500: |
37 | * MMC card with cables connected to bus signals */ | 37 | * src_freq_idx == 0 |
38 | * indexes 1-7 work as written in the table | ||
39 | * indexes 0,8-15 give no clock output | ||
40 | */ | ||
38 | pci_read_config_dword(pdev, 0x48, &src_freq_idx); | 41 | pci_read_config_dword(pdev, 0x48, &src_freq_idx); |
39 | src_freq_idx = (src_freq_idx >> 16) & 0xF; | 42 | src_freq_idx = (src_freq_idx >> 16) & 0xF; |
40 | src_hz = cb710_src_freq_mhz[src_freq_idx] * 1000000; | 43 | src_hz = cb710_src_freq_mhz[src_freq_idx] * 1000000; |
@@ -46,13 +49,15 @@ static void cb710_mmc_set_clock(struct mmc_host *mmc, int hz) | |||
46 | 49 | ||
47 | if (src_freq_idx) | 50 | if (src_freq_idx) |
48 | divider_idx |= 0x8; | 51 | divider_idx |= 0x8; |
52 | else if (divider_idx == 0) | ||
53 | divider_idx = 1; | ||
49 | 54 | ||
50 | cb710_pci_update_config_reg(pdev, 0x40, ~0xF0000000, divider_idx << 28); | 55 | cb710_pci_update_config_reg(pdev, 0x40, ~0xF0000000, divider_idx << 28); |
51 | 56 | ||
52 | dev_dbg(cb710_slot_dev(slot), | 57 | dev_dbg(cb710_slot_dev(slot), |
53 | "clock set to %d Hz, wanted %d Hz; flag = %d\n", | 58 | "clock set to %d Hz, wanted %d Hz; src_freq_idx = %d, divider_idx = %d|%d\n", |
54 | src_hz >> cb710_clock_divider_log2[divider_idx & 7], | 59 | src_hz >> cb710_clock_divider_log2[divider_idx & 7], |
55 | hz, (divider_idx & 8) != 0); | 60 | hz, src_freq_idx, divider_idx & 7, divider_idx & 8); |
56 | } | 61 | } |
57 | 62 | ||
58 | static void __cb710_mmc_enable_irq(struct cb710_slot *slot, | 63 | static void __cb710_mmc_enable_irq(struct cb710_slot *slot, |
@@ -512,7 +517,7 @@ static int cb710_mmc_powerup(struct cb710_slot *slot) | |||
512 | #endif | 517 | #endif |
513 | int err; | 518 | int err; |
514 | 519 | ||
515 | /* a lot of magic; see comment in cb710_mmc_set_clock() */ | 520 | /* a lot of magic for now */ |
516 | dev_dbg(cb710_slot_dev(slot), "bus powerup\n"); | 521 | dev_dbg(cb710_slot_dev(slot), "bus powerup\n"); |
517 | cb710_dump_regs(chip, CB710_DUMP_REGS_MMC); | 522 | cb710_dump_regs(chip, CB710_DUMP_REGS_MMC); |
518 | err = cb710_wait_while_busy(slot, CB710_MMC_S2_BUSY_20); | 523 | err = cb710_wait_while_busy(slot, CB710_MMC_S2_BUSY_20); |
@@ -572,7 +577,7 @@ static void cb710_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
572 | struct cb710_mmc_reader *reader = mmc_priv(mmc); | 577 | struct cb710_mmc_reader *reader = mmc_priv(mmc); |
573 | int err; | 578 | int err; |
574 | 579 | ||
575 | cb710_mmc_set_clock(mmc, ios->clock); | 580 | cb710_mmc_select_clock_divider(mmc, ios->clock); |
576 | 581 | ||
577 | if (!cb710_mmc_is_card_inserted(slot)) { | 582 | if (!cb710_mmc_is_card_inserted(slot)) { |
578 | dev_dbg(cb710_slot_dev(slot), | 583 | dev_dbg(cb710_slot_dev(slot), |