ata: New PATA driver for Altera CompactFlash.
PATCH v2 1/1 ata: New PATA driver for Altera CompactFlash.
This patch adds a new PATA driver to support the Altera SOPC Builder CompactFlash component as a PATA device with support for insertion and removal of CF cards. It uses the platform driver model.
For each probed platform device, the driver spawns a kthread to handle insertion and removal of CF cards by creating and removing the underlying ATA host interface. The Altera CompactFlash component includes a register bit to indicate whether a CF card is detected and an interrupt triggered when this bit changes. The driver has a handler for this interrupt which flags that something has changed and wakes up the kthread to deal with it.
The platform device uses 2 IORESOURCE_MEM resources and 2 IORESOURCE_IRQ resources. The first memory resource is for the CompactFlash component's IDE registers and the second is for the component's CF status and control registers. The first IRQ resource is for the IDE and the second is for the CF detection interrupt.
--- drivers/ata/Kconfig | 11 + drivers/ata/Makefile | 1 + drivers/ata/pata_altera_cf.c | 582 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 594 insertions(+), 0 deletions(-) create mode 100644 drivers/ata/pata_altera_cf.c
drivers/ata/Kconfig +11 -0
@@ -781,5 +781,16 @@ config PATA_BF54X If unsure, say N. +config PATA_ALTERA_CF + tristate "Altera SOPC Builder CompactFlash support" + depends on EMBEDDED + help + This option enables support for the CompactFlash core in an + Altera SOPC Builder system. It supports insertion and removal + of CompactFlash cards. It can be used instead of the generic + PATA platform device support if this functionality is desired. + + If unsure, say N. + endif # ATA_SFF endif # ATA
drivers/ata/Makefile +1 -0
@@ -77,6 +77,7 @@ obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o obj-$(CONFIG_PATA_AT91) += pata_at91.o obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o +obj-$(CONFIG_PATA_ALTERA_CF) += pata_altera_cf.o # Should be last but two libata driver obj-$(CONFIG_PATA_ACPI) += pata_acpi.o # Should be last but one libata driver
drivers/ata/pata_altera_cf.c new file +582 -0
582 lines not on this page · raw message
Signature · 1 line
1.6.2.5
Quoted 3 lines · On Thu, 8 Oct 2009 09:58:30 +0800 Thomas Chou <[email protected]> wrote:
This patch adds a new PATA driver to support the Altera SOPC Builder CompactFlash component as a PATA device with support for insertion and removal of CF cards. It uses the platform driver model.
Can you explain why you remove the interface rather than the device on the interface when you detect a card removal ?
Quoted 9 lines · Alan Cox
Quoted 3 lines · On Thu, 8 Oct 2009 09:58:30 +0800 Thomas Chou <[email protected]> wrote:
This patch adds a new PATA driver to support the Altera SOPC Builder CompactFlash component as a PATA device with support for insertion and removal of CF cards. It uses the platform driver model.
Can you explain why you remove the interface rather than the device on the interface when you detect a card removal ?
As the originator of the driver, the only answer I have is "I don't know how." I was hoping for inspiration from some of the other PATA CF drivers, but alas, I couldn't find it. I admit that removing the whole ATA host is a bit on the extreme side.
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
Quoted 8 lines · On Thu, 8 Oct 2009 12:22:22 +0100 Ian Abbott <[email protected]> wrote:
Quoted 7 lines · Alan Cox
Quoted 3 lines · On Thu, 8 Oct 2009 09:58:30 +0800 Thomas Chou <[email protected]> wrote:
This patch adds a new PATA driver to support the Altera SOPC Builder CompactFlash component as a PATA device with support for insertion and removal of CF cards. It uses the platform driver model.
Quoted 7 lines
Quoted 2 lines
Can you explain why you remove the interface rather than the device on the interface when you detect a card removal ?
As the originator of the driver, the only answer I have is "I don't know how." I was hoping for inspiration from some of the other PATA CF drivers, but alas, I couldn't find it. I admit that removing the whole ATA host is a bit on the extreme side.
I think the bit you want is something like:
struct ata_eh_info *ehi = &ap->link->eh_info;
if (mumblemumble & whatever) {
ata_ehi_clear_desc(ehi);
ata_ehi_hotplugged(ehi);
ata_ehi_push_desc(ehi, "CF connection changed");
ata_port_freeze(ap);
}The core code also assumes your freeze method will mask any further connection change reports until the port is unfrozen (so you don't get multiple parallel "in/out/in/out" events at once)
Alan
Quoted 18 lines · Thomas Chou
This patch adds a new PATA driver to support the Altera SOPC Builder CompactFlash component as a PATA device with support for insertion and removal of CF cards. It uses the platform driver model.
For each probed platform device, the driver spawns a kthread to handle insertion and removal of CF cards by creating and removing the underlying ATA host interface. The Altera CompactFlash component includes a register bit to indicate whether a CF card is detected and an interrupt triggered when this bit changes. The driver has a handler for this interrupt which flags that something has changed and wakes up the kthread to deal with it.
The platform device uses 2
IORESOURCE_MEMresources and 2IORESOURCE_IRQresources. The first memory resource is for the CompactFlash component's IDE registers and the second is for the component's CF status and control registers. The first IRQ resource is for the IDE and the second is for the CF detection interrupt.
Quoted 8 lines
Signed-off-by Ian Abbott<[email protected]>Signed-off-by Thomas Chou<[email protected]>--- drivers/ata/Kconfig | 11 + drivers/ata/Makefile | 1 + drivers/ata/pata_altera_cf.c | 582 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 594 insertions(+), 0 deletions(-)create mode 100644
drivers/ata/pata_altera_cf.c
Ping... still waiting on v3, updated with Alan's feedback.