Commit 4552f0cb authored by Alex Dubov's avatar Alex Dubov Committed by Pierre Ossman

tifm: hide details of interrupt processing from socket drivers

Instead of passing transformed value of adapter interrupt status to
socket drivers, implement two separate callbacks - one for card events
and another for dma events.
Signed-off-by: default avatarAlex Dubov <oakad@yahoo.com>
Signed-off-by: default avatarPierre Ossman <drzeus@drzeus.cx>
parent 5721dbf2
...@@ -14,7 +14,13 @@ ...@@ -14,7 +14,13 @@
#include <linux/freezer.h> #include <linux/freezer.h>
#define DRIVER_NAME "tifm_7xx1" #define DRIVER_NAME "tifm_7xx1"
#define DRIVER_VERSION "0.7" #define DRIVER_VERSION "0.8"
#define TIFM_IRQ_ENABLE 0x80000000
#define TIFM_IRQ_SOCKMASK(x) (x)
#define TIFM_IRQ_CARDMASK(x) ((x) << 8)
#define TIFM_IRQ_FIFOMASK(x) ((x) << 16)
#define TIFM_IRQ_SETALL 0xffffffff
static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock) static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
{ {
...@@ -31,7 +37,7 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id) ...@@ -31,7 +37,7 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
struct tifm_adapter *fm = dev_id; struct tifm_adapter *fm = dev_id;
struct tifm_dev *sock; struct tifm_dev *sock;
unsigned int irq_status; unsigned int irq_status;
unsigned int sock_irq_status, cnt; unsigned int cnt;
spin_lock(&fm->lock); spin_lock(&fm->lock);
irq_status = readl(fm->addr + FM_INTERRUPT_STATUS); irq_status = readl(fm->addr + FM_INTERRUPT_STATUS);
...@@ -45,12 +51,12 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id) ...@@ -45,12 +51,12 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
for (cnt = 0; cnt < fm->num_sockets; cnt++) { for (cnt = 0; cnt < fm->num_sockets; cnt++) {
sock = fm->sockets[cnt]; sock = fm->sockets[cnt];
sock_irq_status = (irq_status >> cnt) if (sock) {
& (TIFM_IRQ_FIFOMASK(1) if ((irq_status >> cnt) & TIFM_IRQ_FIFOMASK(1))
| TIFM_IRQ_CARDMASK(1)); sock->data_event(sock);
if ((irq_status >> cnt) & TIFM_IRQ_CARDMASK(1))
if (sock && sock_irq_status) sock->card_event(sock);
sock->signal_irq(sock, sock_irq_status); }
} }
fm->socket_change_set |= irq_status fm->socket_change_set |= irq_status
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <linux/idr.h> #include <linux/idr.h>
#define DRIVER_NAME "tifm_core" #define DRIVER_NAME "tifm_core"
#define DRIVER_VERSION "0.7" #define DRIVER_VERSION "0.8"
static DEFINE_IDR(tifm_adapter_idr); static DEFINE_IDR(tifm_adapter_idr);
static DEFINE_SPINLOCK(tifm_adapter_lock); static DEFINE_SPINLOCK(tifm_adapter_lock);
...@@ -175,8 +175,7 @@ void tifm_free_device(struct device *dev) ...@@ -175,8 +175,7 @@ void tifm_free_device(struct device *dev)
} }
EXPORT_SYMBOL(tifm_free_device); EXPORT_SYMBOL(tifm_free_device);
static void tifm_dummy_signal_irq(struct tifm_dev *sock, static void tifm_dummy_event(struct tifm_dev *sock)
unsigned int sock_irq_status)
{ {
return; return;
} }
...@@ -191,7 +190,8 @@ struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm) ...@@ -191,7 +190,8 @@ struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm)
dev->dev.parent = fm->dev; dev->dev.parent = fm->dev;
dev->dev.bus = &tifm_bus_type; dev->dev.bus = &tifm_bus_type;
dev->dev.release = tifm_free_device; dev->dev.release = tifm_free_device;
dev->signal_irq = tifm_dummy_signal_irq; dev->card_event = tifm_dummy_event;
dev->data_event = tifm_dummy_event;
} }
return dev; return dev;
} }
...@@ -249,7 +249,8 @@ static int tifm_device_remove(struct device *dev) ...@@ -249,7 +249,8 @@ static int tifm_device_remove(struct device *dev)
struct tifm_driver *drv = fm_dev->drv; struct tifm_driver *drv = fm_dev->drv;
if (drv) { if (drv) {
fm_dev->signal_irq = tifm_dummy_signal_irq; fm_dev->card_event = tifm_dummy_event;
fm_dev->data_event = tifm_dummy_event;
if (drv->remove) if (drv->remove)
drv->remove(fm_dev); drv->remove(fm_dev);
fm_dev->drv = NULL; fm_dev->drv = NULL;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <asm/io.h> #include <asm/io.h>
#define DRIVER_NAME "tifm_sd" #define DRIVER_NAME "tifm_sd"
#define DRIVER_VERSION "0.7" #define DRIVER_VERSION "0.8"
static int no_dma = 0; static int no_dma = 0;
static int fixed_timeout = 0; static int fixed_timeout = 0;
...@@ -316,24 +316,38 @@ change_state: ...@@ -316,24 +316,38 @@ change_state:
} }
/* Called from interrupt handler */ /* Called from interrupt handler */
static void tifm_sd_signal_irq(struct tifm_dev *sock, static void tifm_sd_data_event(struct tifm_dev *sock)
unsigned int sock_irq_status)
{ {
struct tifm_sd *host; struct tifm_sd *host;
unsigned int host_status = 0, fifo_status = 0; unsigned int fifo_status = 0;
int error_code = 0;
spin_lock(&sock->lock); spin_lock(&sock->lock);
host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock)); host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
if (sock_irq_status & FIFO_EVENT) {
fifo_status = readl(sock->addr + SOCK_DMA_FIFO_STATUS); fifo_status = readl(sock->addr + SOCK_DMA_FIFO_STATUS);
writel(fifo_status, sock->addr + SOCK_DMA_FIFO_STATUS); writel(fifo_status, sock->addr + SOCK_DMA_FIFO_STATUS);
host->flags |= fifo_status & FIFO_RDY; host->flags |= fifo_status & FIFO_RDY;
}
if (sock_irq_status & CARD_EVENT) { if (host->req)
tifm_sd_process_cmd(sock, host, 0);
dev_dbg(&sock->dev, "fifo_status %x\n", fifo_status);
spin_unlock(&sock->lock);
}
/* Called from interrupt handler */
static void tifm_sd_card_event(struct tifm_dev *sock)
{
struct tifm_sd *host;
unsigned int host_status = 0;
int error_code = 0;
spin_lock(&sock->lock);
host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
host_status = readl(sock->addr + SOCK_MMCSD_STATUS); host_status = readl(sock->addr + SOCK_MMCSD_STATUS);
writel(host_status, sock->addr + SOCK_MMCSD_STATUS); writel(host_status, sock->addr + SOCK_MMCSD_STATUS);
...@@ -377,13 +391,11 @@ static void tifm_sd_signal_irq(struct tifm_dev *sock, ...@@ -377,13 +391,11 @@ static void tifm_sd_signal_irq(struct tifm_dev *sock,
host->written_blocks++; host->written_blocks++;
host->flags &= ~CARD_BUSY; host->flags &= ~CARD_BUSY;
} }
}
if (host->req) if (host->req)
tifm_sd_process_cmd(sock, host, host_status); tifm_sd_process_cmd(sock, host, host_status);
done: done:
dev_dbg(&sock->dev, "host_status %x, fifo_status %x\n", dev_dbg(&sock->dev, "host_status %x\n", host_status);
host_status, fifo_status);
spin_unlock(&sock->lock); spin_unlock(&sock->lock);
} }
...@@ -882,7 +894,8 @@ static int tifm_sd_probe(struct tifm_dev *sock) ...@@ -882,7 +894,8 @@ static int tifm_sd_probe(struct tifm_dev *sock)
mmc->max_blk_size = 2048; mmc->max_blk_size = 2048;
mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
mmc->max_seg_size = mmc->max_req_size; mmc->max_seg_size = mmc->max_req_size;
sock->signal_irq = tifm_sd_signal_irq; sock->card_event = tifm_sd_card_event;
sock->data_event = tifm_sd_data_event;
rc = tifm_sd_initialize_host(host); rc = tifm_sd_initialize_host(host);
if (!rc) if (!rc)
......
...@@ -60,13 +60,6 @@ enum { ...@@ -60,13 +60,6 @@ enum {
SOCK_MS_SYSTEM = 0x190, SOCK_MS_SYSTEM = 0x190,
SOCK_FIFO_ACCESS = 0x200 }; SOCK_FIFO_ACCESS = 0x200 };
#define TIFM_IRQ_ENABLE 0x80000000
#define TIFM_IRQ_SOCKMASK(x) (x)
#define TIFM_IRQ_CARDMASK(x) ((x) << 8)
#define TIFM_IRQ_FIFOMASK(x) ((x) << 16)
#define TIFM_IRQ_SETALL 0xffffffff
#define TIFM_CTRL_LED 0x00000040 #define TIFM_CTRL_LED 0x00000040
#define TIFM_CTRL_FAST_CLK 0x00000100 #define TIFM_CTRL_FAST_CLK 0x00000100
...@@ -90,8 +83,8 @@ struct tifm_dev { ...@@ -90,8 +83,8 @@ struct tifm_dev {
tifm_media_id media_id; tifm_media_id media_id;
unsigned int socket_id; unsigned int socket_id;
void (*signal_irq)(struct tifm_dev *sock, void (*card_event)(struct tifm_dev *sock);
unsigned int sock_irq_status); void (*data_event)(struct tifm_dev *sock);
struct tifm_driver *drv; struct tifm_driver *drv;
struct device dev; struct device dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment