The driver is usable on the newer SAM9 processors so replace all text
references to AT91RM9200 with just AT91.
The controller bug where all the words are byte-swapped is fixed on the
AT91SAM9 processors. The byte-swapping work-around therefore only needs
to be done if cpu_is_at91rm9200().
[Original patch from Wojtek Kaniewski]
The AT91RM9200 and AT91SAM9260 processors support two MMC/SD slots - the
slot which is connected is now passed via the platform_data and the
correct slot selected in the AT91_MCI_SDCR register.
The driver should not be calling at91_set_gpio_output() since the VCC
pin should have already been configured as an output in the
processor/board setup code. The driver should call
at91_set_gpio_value().
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Some controllers report an invalid iomem size, but seem to work
correctly anyway. Change our current error to just a warning and
hope it doesn't cause too much problems.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Currently on SD/MMC card removal the system exhibits the following message (the platform is ARM Versatile):
prev->state: 2 != TASK_RUNNING??
mmcqd/762[CPU#0]: BUG in __schedule at linux-2.6/kernel/sched.c:3826
(akpm: someone tried to fix this, but it's still wrong)
Signed-off-by: Vitaly Wool <vitalywool@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
A number of small cleanups to the AT91RM9200 MMC driver:
- fix warnings generated by pr_debug().
- prepend "AT91 MMC:" to printk() messages.
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This patch simplifies the AT91RM9200 MMC interrupt handler code so that
it doesn't re-read the Interrupt Status and Interrupt Mask registers
multiple times.
Also defined AT91_MCI_ERRORS instead of using the hard-coded 0xffff0000.
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Move the global 'mci_clk' variable into the local 'at91mci_host'
structure.
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Use the I/O base-address and IRQ passed to the driver via the
platform_device resources instead of using hardcoded values.
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
The I/O base address is now stored in the 'at91mci_host' structure. We
therefore have to pass this structure to at91_mci_read() and
at91_mci_write().
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This facility provides three entry points:
ilog2() Log base 2 of unsigned long
ilog2_u32() Log base 2 of u32
ilog2_u64() Log base 2 of u64
These facilities can either be used inside functions on dynamic data:
int do_something(long q)
{
...;
y = ilog2(x)
...;
}
Or can be used to statically initialise global variables with constant values:
unsigned n = ilog2(27);
When performing static initialisation, the compiler will report "error:
initializer element is not constant" if asked to take a log of zero or of
something not reducible to a constant. They treat negative numbers as
unsigned.
When not dealing with a constant, they fall back to using fls() which permits
them to use arch-specific log calculation instructions - such as BSR on
x86/x86_64 or SCAN on FRV - if available.
[akpm@osdl.org: MMC fix]
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David Howells <dhowells@redhat.com>
Cc: Wojtek Kaniewski <wojtekka@toxygen.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: (76 commits)
[ARM] 4002/1: S3C24XX: leave parent IRQs unmasked
[ARM] 4001/1: S3C24XX: shorten reboot time
[ARM] 3983/2: remove unused argument to __bug()
[ARM] 4000/1: Osiris: add third serial port in
[ARM] 3999/1: RX3715: suspend to RAM support
[ARM] 3998/1: VR1000: LED platform devices
[ARM] 3995/1: iop13xx: add iop13xx support
[ARM] 3968/1: iop13xx: add iop13xx_defconfig
[ARM] Update mach-types
[ARM] Allow gcc to optimise arm_add_memory a little more
[ARM] 3991/1: i.MX/MX1 high resolution time source
[ARM] 3990/1: i.MX/MX1 more precise PLL decode
[ARM] 3986/1: H1940: suspend to RAM support
[ARM] 3985/1: ixp4xx clocksource cleanup
[ARM] 3984/1: ixp4xx/nslu2: Fix disk LED numbering (take 2)
[ARM] 3994/1: ixp23xx: fix handling of pci master aborts
[ARM] 3981/1: sched_clock for PXA2xx
[ARM] 3980/1: extend the ARM Versatile sched_clock implementation from 32 to 63 bit
[ARM] 3979/1: extend the SA11x0 sched_clock implementation from 32 to 63 bit period
[ARM] 3978/1: macro to provide a 63-bit value from a 32-bit hardware counter
...
Conflicts:
drivers/infiniband/core/iwcm.c
drivers/net/chelsio/cxgb2.c
drivers/net/wireless/bcm43xx/bcm43xx_main.c
drivers/net/wireless/prism54/islpci_eth.c
drivers/usb/core/hub.h
drivers/usb/input/hid-core.c
net/core/netpoll.c
Fix up merge failures with Linus's head and fix new compilation failures.
Signed-Off-By: David Howells <dhowells@redhat.com>
This patch has fixed the following build error abou au1xmmc.
drivers/mmc/au1xmmc.c: In function `au1xmmc_poll_event':
drivers/mmc/au1xmmc.c:835: warning: unused variable `status'
drivers/mmc/au1xmmc.c: At top level:
drivers/mmc/au1xmmc.c:878: error: parse error before "const"
drivers/mmc/au1xmmc.c: In function `au1xmmc_probe':
drivers/mmc/au1xmmc.c:909: error: `au1xmmc_ops' undeclared (first use in this function)
drivers/mmc/au1xmmc.c:909: error: (Each undeclared identifier is reported only once
drivers/mmc/au1xmmc.c:909: error: for each function it appears in.)
drivers/mmc/au1xmmc.c: At top level:
drivers/mmc/au1xmmc.c:659: warning: 'au1xmmc_request' defined but not used
drivers/mmc/au1xmmc.c:719: warning: 'au1xmmc_set_ios' defined but not used
make[2]: *** [drivers/mmc/au1xmmc.o] Error 1
make[1]: *** [drivers/mmc] Error 2
make: *** [drivers] Error 2
Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
since commit fcaf71fd51
struct mmc_host does not have a dev field. Retrieve the device with
mmc_dev() instead.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/drzeus/mmc:
mmc: correct request error handling
mmc: Flush block queue when removing card
mmc: sdhci high speed support
mmc: Support for high speed SD cards
mmc: Fix mmc_delay() function
mmc: Add support for mmc v4 wide-bus modes
[PATCH] mmc: Add support for mmc v4 high speed mode
trivial change for mmc/Kconfig: MMC_PXA does not mean only PXA255
Make general code cleanups
Add MMC_CAP_{MULTIWRITE,BYTEBLOCK} flags
Platform device error handling cleanup
Move register definitions away from the header file
Change OMAP_MMC_{READ,WRITE} macros to use the host pointer
Replace base with virt_base and phys_base
mmc: constify mmc_host_ops vectors
mmc: remove kernel_thread()
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (36 commits)
Driver core: show drivers in /sys/module/
Documentation/driver-model/platform.txt update/rewrite
Driver core: platform_driver_probe(), can save codespace
driver core: Use klist_remove() in device_move()
driver core: Introduce device_move(): move a device to a new parent.
Driver core: make drivers/base/core.c:setup_parent() static
driver core: Introduce device_find_child().
sysfs: sysfs_write_file() writes zero terminated data
cpu topology: consider sysfs_create_group return value
Driver core: Call platform_notify_remove later
ACPI: Change ACPI to use dev_archdata instead of firmware_data
Driver core: add dev_archdata to struct device
Driver core: convert sound core to use struct device
Driver core: change mem class_devices to be real devices
Driver core: convert fb code to use struct device
Driver core: convert firmware code to use struct device
Driver core: convert mmc code to use struct device
Driver core: convert ppdev code to use struct device
Driver core: convert PPP code to use struct device
Driver core: convert cpuid code to use struct device
...
Converts from using struct "class_device" to "struct device" making
everything show up properly in /sys/devices/ with symlinks from the
/sys/class directory.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
We need to jump to the part of just flushing the request
when we cannot claim the bus. Sending commands to a bus
we do not own will give unpredictable results.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
After mmc_block's remove function has exited, we must not
touch the card structure in any way. This means we not only
must remove the gendisk, we must also flush out any
remaning requests already queued up.
We previously removed the disk, but didn't flush it,
causing oops:es when removing a card in the middle of a
transfer.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
The SDHCI spec implies that is is incorrect to set a clock
frequency above 25 MHz without setting the high speed bit.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Modern SD cards support a clock speed of 50 MHz. Make sure we test for
this capability and do the song and dance required to activate it.
Activating high speed support actually modifies the TRAN_SPEED field
of the CSD. But as the spec says that the cards must report 50 MHz,
we might as well skip re-reading the CSD.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Several fixes for mmc_delay():
* Repair if-clause that was supposed to detect sub-hz delays.
* Change yield() to cond_resched() as yield() no longer has the
semantics we desire.
* mmc_delay() is used to guarantee protocol delays, so we cannot
return early (i.e. use _interruptable).
Based on patch by Amol Lad.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This change adds support for the mmc4 4-bit wide-bus mode.
The mmc4 spec defines 8-bit and 4-bit transfer modes. As we do not support
any 8-bit hardware, this patch only adds support for the 4-bit mode, but
it can easily be built upon when the time comes.
The 4-bit mode is electrically compatible with SD's 4-bit mode but the
procedure for turning it on is different. This patch implements only
the essential parts of the procedure as defined by the spec. Two additional
steps are recommended but not compulsory. I am documenting them here so
that there's a record.
1) A bus-test mechanism is implemented using dedicated mmc commands which allow
for testing the functionality of the data bus at the electrical level. This is
pretty paranoid and they way the commands work is not compatible with the mmc
subsystem (they don't set valid CRC values).
2) MMC v4 cards can indicate they would like to draw more than the default
amount of current in wide-bus modes. We currently will never switch the card
into a higher draw mode. Supposedly, allowing the card to draw more current
will let it perform better, but the specs seem to indicate that the card will
function correctly without the mode change. Empirical testing supports this
interpretation.
Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This adds support for the high-speed modes defined by mmc v4
(assuming the host controller is up to it). On a TI sdhci controller,
it improves read speed from 1.3MBps to 2.3MBps. The TI controller can
only go up to 24MHz, but everything helps. Another person has taken
this basic patch and used it on a Nokia 770 to get a bigger boost
because that controller can run at 48MHZ.
Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
PXA MMC driver supports not only PXA255 but also PXA250 and newer ones
Signed-off-by: Marcin Juszkiewicz <hrw@openembedded.org>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This patch is part of Juha Yrjola's and Komal Shah's earlier patch to
make general code cleanups
Signed-off-by: Carlos Eduardo Aguiar <carlos.aguiar <at> indt.org.br>
Signed-off-by: Juha Yrjola <juha.yrjola <at> solidboot.com>
Signed-off-by: Komal Shah <komal_shah802003 <at> yahoo.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This patch is part of Tony Lindgren's earlier patch to add
MMC_CAP_{MULTIWRITE,BYTEBLOCK} flags in omap.c
Signed-off-by: Carlos Eduardo Aguiar <carlos.aguiar <at> indt.org.br>
Signed-off-by: Tony Lindgren <tony <at> atomide.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This patch is part of Juha Yrjola's earlier patch to add platform device
error handling and a BUG_ON to verify if host == NULL
Signed-off-by: Carlos Eduardo Aguiar <carlos.aguiar <at> indt.org.br>
Signed-off-by: Juha Yrjola <juha.yrjola <at> solidboot.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This patch is part of Juha Yrjola's earlier patch to move register
definitions away from the header file and the header file is removed.
Signed-off-by: Carlos Eduardo Aguiar <carlos.aguiar <at> indt.org.br>
Signed-off-by: Juha Yrjola <juha.yrjola <at> solidboot.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This patch is part of Juha Yrjola's earlier patch to change
OMAP_MMC_{READ,WRITE} macros to use the host pointer
Signed-off-by: Carlos Eduardo Aguiar <carlos.aguiar <at> indt.org.br>
Signed-off-by: Juha Yrjola <juha.yrjola <at> solidboot.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This patch is part of Juha Yrjola's earlier patch to replace base
with virt_base and phys_base
Signed-off-by: Carlos Eduardo Aguiar <carlos.aguiar <at> indt.org.br>
Signed-off-by: Juha Yrjola <juha.yrjola <at> solidboot.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Now that mmc_host_ops can be constified, update the various drivers
to constify those method tables and shrink the writable data segment.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Replace kernel_thread() with kthread_run()/kthread_stop().
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
A number of configuration file changes.
These are mainly to replace references to ARCH_AT91RM9200 and
ARCH_AT91SAM9261 with the common/generic ARCH_AT91. That way we don't
need to mention every specific AT91 processor explicitly.
Also adds the configuration option for AT91SAM9260-EK and AT91SAM9261-EK
boards.
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This patch updates the drivers (and other files) which include the
hardware headers. This fixes the breakage introduced in patches 3950/1
and 3951/1 (those patches were getting big).
The AVR32 architecture uses the same serial driver and had its own copy
of at91rm9200_pdc.h. Renamed it to at91_pdc.h
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This patch converts a if () BUG(); construct to BUG_ON();
which occupies less space, uses unlikely and is safer when
BUG() is disabled.
Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
The card might go to inactive state (according to specification), if
there are unsupported bits set in the OCR.
Signed-off-by: Timo Teras <timo.teras@solidboot.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Some broken cards seem to process CMD1 even in stand-by state. The result is
that the card replies with ILLEGAL_COMMAND error for the next command sent
after rescanning. Currently the next command is select card, which would
return the error. But CMD7 does actually succeed and retries of the command
will timeout. The workaround is to poll card status after CMD1 to clear the
pending error.
Signed-off-by: Timo Teras <timo.teras@solidboot.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
SD cards extend the protocol by allowing the host to query a card how many
blocks were successfully stored on the medium. This allows us to safely write
chunks of blocks at once.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
Use the new multi block-write error reporting flag and properly tell the block
layer how much data was transferred before the error.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The MMC layer uses the standard work queue for doing card detection. As this
queue is shared with other crucial subsystems, the effects of a long (and
perhaps buggy) detection can cause the system to be unusable. E.g. the
keyboard stops working while the detection routine is running.
The solution is to add a specific mmc work queue to run the detection code in.
This is similar to how other subsystems handle detection (a full kernel
thread is the most common theme).
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Some Ricoh controllers only respect a full reset when there is no card in the
slot. As we wait for the reset to complete, we must avoid even requesting
those resets on the buggy controllers.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Sprinkle some mmiowb() where needed (writeX() before unlock()).
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Alex Dubov <oakad@yahoo.com>
Cc: Daniel Qarras <dqarras@yahoo.com>
Acked-by: Pierre Ossman <drzeus@drzeus.cx>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Driver for TI Flash Media card reader. At present, only MMC/SD cards are
supported.
[akpm@osdl.org: cleanups, build fixes]
Signed-off-by: Alex Dubov <oakad@yahoo.com>
Cc: Daniel Qarras <dqarras@yahoo.com>
Acked-by: Pierre Ossman <drzeus@drzeus.cx>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>