diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-14 16:46:57 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-14 16:46:57 -0400 |
| commit | 2625b10d8c37656cf410a464ed95942b3abbd1f6 (patch) | |
| tree | f02fc44aaed07dceed2566b3fdf4dc64b786cb89 /drivers/misc/cb710/debug.c | |
| parent | 489f7ab6c18cdd64a2d444e056d60a0e722f4ad7 (diff) | |
| parent | 7f72134c32eb64c77d1fb35123ba8bf815bf797c (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc: (25 commits)
atmel-mci: add MCI2 register definitions
atmel-mci: Integrate AT91 specific definition in header file
tmio_mmc: allow compilation for ASIC3
mmc_block: do not DMA to stack
sdhci: Print ADMA status and pointer on debug
tmio_mmc: fix clock setup
tmio_mmc: map SD control registers after enabling the MFD cell
tmio_mmc: correct probe return value for num_resources != 3
tmio_mmc: don't use set_irq_type
tmio_mmc: add bus_shift support
MFD,mmc: tmio_mmc: make HCLK configurable
mmc_spi: don't use EINVAL for possible transmission errors
cb710: more cleanup for the DEBUG case.
sdhci: platform driver for SDHCI
mxcmmc: remove frequency workaround
cb710: handle DEBUG define in Makefile
cb710: add missing parenthesis
cb710: fix printk format string
mmc: Driver for CB710/720 memory card reader (MMC part)
pxamci: add regulator support.
...
Diffstat (limited to 'drivers/misc/cb710/debug.c')
| -rw-r--r-- | drivers/misc/cb710/debug.c | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/drivers/misc/cb710/debug.c b/drivers/misc/cb710/debug.c new file mode 100644 index 000000000000..02358d086e03 --- /dev/null +++ b/drivers/misc/cb710/debug.c | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | /* | ||
| 2 | * cb710/debug.c | ||
| 3 | * | ||
| 4 | * Copyright by Michał Mirosław, 2008-2009 | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | #include <linux/cb710.h> | ||
| 11 | #include <linux/kernel.h> | ||
| 12 | #include <linux/module.h> | ||
| 13 | #include <linux/slab.h> | ||
| 14 | |||
| 15 | #define CB710_REG_COUNT 0x80 | ||
| 16 | |||
| 17 | static const u16 allow[CB710_REG_COUNT/16] = { | ||
| 18 | 0xFFF0, 0xFFFF, 0xFFFF, 0xFFFF, | ||
| 19 | 0xFFF0, 0xFFFF, 0xFFFF, 0xFFFF, | ||
| 20 | }; | ||
| 21 | static const char *const prefix[ARRAY_SIZE(allow)] = { | ||
| 22 | "MMC", "MMC", "MMC", "MMC", | ||
| 23 | "MS?", "MS?", "SM?", "SM?" | ||
| 24 | }; | ||
| 25 | |||
| 26 | static inline int allow_reg_read(unsigned block, unsigned offset, unsigned bits) | ||
| 27 | { | ||
| 28 | unsigned mask = (1 << bits/8) - 1; | ||
| 29 | offset *= bits/8; | ||
| 30 | return ((allow[block] >> offset) & mask) == mask; | ||
| 31 | } | ||
| 32 | |||
| 33 | #define CB710_READ_REGS_TEMPLATE(t) \ | ||
| 34 | static void cb710_read_regs_##t(void __iomem *iobase, \ | ||
| 35 | u##t *reg, unsigned select) \ | ||
| 36 | { \ | ||
| 37 | unsigned i, j; \ | ||
| 38 | \ | ||
| 39 | for (i = 0; i < ARRAY_SIZE(allow); ++i, reg += 16/(t/8)) { \ | ||
| 40 | if (!(select & (1 << i))) \ | ||
| 41 | continue; \ | ||
| 42 | \ | ||
| 43 | for (j = 0; j < 0x10/(t/8); ++j) { \ | ||
| 44 | if (!allow_reg_read(i, j, t)) \ | ||
| 45 | continue; \ | ||
| 46 | reg[j] = ioread##t(iobase \ | ||
| 47 | + (i << 4) + (j * (t/8))); \ | ||
| 48 | } \ | ||
| 49 | } \ | ||
| 50 | } | ||
| 51 | |||
| 52 | static const char cb710_regf_8[] = "%02X"; | ||
| 53 | static const char cb710_regf_16[] = "%04X"; | ||
| 54 | static const char cb710_regf_32[] = "%08X"; | ||
| 55 | static const char cb710_xes[] = "xxxxxxxx"; | ||
| 56 | |||
| 57 | #define CB710_DUMP_REGS_TEMPLATE(t) \ | ||
| 58 | static void cb710_dump_regs_##t(struct device *dev, \ | ||
| 59 | const u##t *reg, unsigned select) \ | ||
| 60 | { \ | ||
| 61 | const char *const xp = &cb710_xes[8 - t/4]; \ | ||
| 62 | const char *const format = cb710_regf_##t; \ | ||
| 63 | \ | ||
| 64 | char msg[100], *p; \ | ||
| 65 | unsigned i, j; \ | ||
| 66 | \ | ||
| 67 | for (i = 0; i < ARRAY_SIZE(allow); ++i, reg += 16/(t/8)) { \ | ||
| 68 | if (!(select & (1 << i))) \ | ||
| 69 | continue; \ | ||
| 70 | p = msg; \ | ||
| 71 | for (j = 0; j < 0x10/(t/8); ++j) { \ | ||
| 72 | *p++ = ' '; \ | ||
| 73 | if (j == 8/(t/8)) \ | ||
| 74 | *p++ = ' '; \ | ||
| 75 | if (allow_reg_read(i, j, t)) \ | ||
| 76 | p += sprintf(p, format, reg[j]); \ | ||
| 77 | else \ | ||
| 78 | p += sprintf(p, "%s", xp); \ | ||
| 79 | } \ | ||
| 80 | dev_dbg(dev, "%s 0x%02X %s\n", prefix[i], i << 4, msg); \ | ||
| 81 | } \ | ||
| 82 | } | ||
| 83 | |||
| 84 | #define CB710_READ_AND_DUMP_REGS_TEMPLATE(t) \ | ||
| 85 | static void cb710_read_and_dump_regs_##t(struct cb710_chip *chip, \ | ||
| 86 | unsigned select) \ | ||
| 87 | { \ | ||
| 88 | u##t regs[CB710_REG_COUNT/sizeof(u##t)]; \ | ||
| 89 | \ | ||
| 90 | memset(®s, 0, sizeof(regs)); \ | ||
| 91 | cb710_read_regs_##t(chip->iobase, regs, select); \ | ||
| 92 | cb710_dump_regs_##t(cb710_chip_dev(chip), regs, select); \ | ||
| 93 | } | ||
| 94 | |||
| 95 | #define CB710_REG_ACCESS_TEMPLATES(t) \ | ||
| 96 | CB710_READ_REGS_TEMPLATE(t) \ | ||
| 97 | CB710_DUMP_REGS_TEMPLATE(t) \ | ||
| 98 | CB710_READ_AND_DUMP_REGS_TEMPLATE(t) | ||
| 99 | |||
| 100 | CB710_REG_ACCESS_TEMPLATES(8) | ||
| 101 | CB710_REG_ACCESS_TEMPLATES(16) | ||
| 102 | CB710_REG_ACCESS_TEMPLATES(32) | ||
| 103 | |||
| 104 | void cb710_dump_regs(struct cb710_chip *chip, unsigned select) | ||
| 105 | { | ||
| 106 | if (!(select & CB710_DUMP_REGS_MASK)) | ||
| 107 | select = CB710_DUMP_REGS_ALL; | ||
| 108 | if (!(select & CB710_DUMP_ACCESS_MASK)) | ||
| 109 | select |= CB710_DUMP_ACCESS_8; | ||
| 110 | |||
| 111 | if (select & CB710_DUMP_ACCESS_32) | ||
| 112 | cb710_read_and_dump_regs_32(chip, select); | ||
| 113 | if (select & CB710_DUMP_ACCESS_16) | ||
| 114 | cb710_read_and_dump_regs_16(chip, select); | ||
| 115 | if (select & CB710_DUMP_ACCESS_8) | ||
| 116 | cb710_read_and_dump_regs_8(chip, select); | ||
| 117 | } | ||
| 118 | EXPORT_SYMBOL_GPL(cb710_dump_regs); | ||
| 119 | |||
