V4L/DVB (13741): [Mantis] Implement HIF Mem Read/Write operations
authorManu Abraham <abraham.manu@gmail.com>
Fri, 4 Dec 2009 08:09:47 +0000 (05:09 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 17 Jan 2010 13:55:34 +0000 (11:55 -0200)
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/mantis/Makefile
drivers/media/dvb/mantis/mantis_dma.c
drivers/media/dvb/mantis/mantis_evm.c
drivers/media/dvb/mantis/mantis_hif.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_link.h
drivers/media/dvb/mantis/mantis_reg.h

index c4da0d8ed1868ee0be3e70eed26e4ceabd02606f..d002ef9f744946053c8d87763f0bfe4f3845bf4b 100644 (file)
@@ -4,6 +4,7 @@ mantis-objs =   mantis_core.o   \
                mantis_i2c.o    \
                mantis_dvb.o    \
                mantis_evm.o    \
+               mantis_hif.o    \
                mantis_ca.o     \
                mantis_pcmcia.o \
                mantis_vp1033.o \
index f685992f7d0a3d9b47e466f0fd6ed316f84fddb5..250f49a913aaf3d02e13b93f5899b0e8f2f2f013 100644 (file)
@@ -190,7 +190,7 @@ void mantis_dma_start(struct mantis_pci *mantis)
 
        mantis_risc_program(mantis);
        mmwrite(mantis->risc_dma, MANTIS_RISC_START);
-       mmwrite(mmread(MANTIS_GPIF_ADDR) | MANTIS_GPIF_RDWRN, MANTIS_GPIF_ADDR);
+       mmwrite(mmread(MANTIS_GPIF_HIFADDR) | MANTIS_GPIF_HIFRDWRN, MANTIS_GPIF_HIFADDR);
 
        mmwrite(0, MANTIS_DMA_CTL);
        mantis->last_block = mantis->finished_block = 0;
@@ -210,7 +210,7 @@ void mantis_dma_stop(struct mantis_pci *mantis)
        mask = mmread(MANTIS_INT_MASK);
        dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Stop DMA engine");
 
-       mmwrite((mmread(MANTIS_GPIF_ADDR) & (~(MANTIS_GPIF_RDWRN))), MANTIS_GPIF_ADDR);
+       mmwrite((mmread(MANTIS_GPIF_HIFADDR) & (~(MANTIS_GPIF_HIFRDWRN))), MANTIS_GPIF_HIFADDR);
 
        mmwrite((mmread(MANTIS_DMA_CTL) & ~(MANTIS_FIFO_EN |
                                            MANTIS_DCAP_EN |
index 745148399981f21a6d17a4296b2f62ba3c35a39e..dbcdca3a8f034f5477a50a950d0935939d6c3f6a 100644 (file)
@@ -92,7 +92,7 @@ int mantis_evmgr_init(struct mantis_ca *ca)
        INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work);
        mantis_pcmcia_init(ca);
        schedule_work(&ca->hif_evm_work);
-
+       mantis_hif_init(ca);
        return 0;
 }
 
@@ -102,5 +102,6 @@ void mantis_evmgr_exit(struct mantis_ca *ca)
 
        dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");
        flush_scheduled_work();
+       mantis_hif_exit(ca);
        mantis_pcmcia_exit(ca);
 }
diff --git a/drivers/media/dvb/mantis/mantis_hif.c b/drivers/media/dvb/mantis/mantis_hif.c
new file mode 100644 (file)
index 0000000..1472008
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com)
+
+       This program is free software; you can redistribute it and/or modify
+       it under the terms of the GNU General Public License as published by
+       the Free Software Foundation; either version 2 of the License, or
+       (at your option) any later version.
+
+       This program is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       GNU General Public License for more details.
+
+       You should have received a copy of the GNU General Public License
+       along with this program; if not, write to the Free Software
+       Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "mantis_common.h"
+#include "mantis_hif.h"
+#include "mantis_link.h" /* temporary due to physical layer stuff */
+
+static int mantis_hif_data_available(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       int rc = 0;
+
+       if (wait_event_interruptible_timeout(ca->hif_data_wq,
+                                            ca->sbuf_status & MANTIS_SBUF_DATA_AVAIL,
+                                            msecs_to_jiffies(500)) == -ERESTARTSYS) {
+
+               dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Read wait event timeout !", mantis->num);
+               rc = -EREMOTEIO;
+       }
+       ca->sbuf_status &= ~MANTIS_SBUF_DATA_AVAIL;
+       udelay(2);
+       return rc;
+}
+
+static int mantis_hif_sbuf_opdone_wait(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       int rc = 0;
+
+       if (wait_event_interruptible_timeout(ca->hif_opdone_wq,
+                                            ca->hif_event & MANTIS_SBUF_OPDONE,
+                                            msecs_to_jiffies(500)) == -ERESTARTSYS) {
+
+               dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): Smart buffer operation timeout !", mantis->num);
+               rc = -EREMOTEIO;
+       }
+       ca->hif_event &= ~MANTIS_SBUF_OPDONE;
+       udelay(5);
+       return rc;
+}
+
+int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 hif_addr = 0, data, count = 4;
+
+       hif_addr |=  MANTIS_GPIF_HIFRDWRN;
+       hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
+       hif_addr &= ~MANTIS_GPIF_PCMCIAIOM;
+       hif_addr |=  addr;
+
+       mmwrite(hif_addr, MANTIS_GPIF_BRADDR);
+       mmwrite(count, MANTIS_GPIF_BRBYTES);
+
+       udelay(20);
+
+       mmwrite(hif_addr, MANTIS_GPIF_HIFADDR);
+       if (mantis_hif_data_available(ca) != 0) {
+               dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): GPIF Smart Buffer burst read failed", mantis->num);
+               return -EREMOTEIO;
+       }
+       if (mantis_hif_sbuf_opdone_wait(ca) != 0) {
+               dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): GPIF Smart Buffer operation failed", mantis->num);
+               return -EREMOTEIO;
+       }
+       data = mmread(MANTIS_GPIF_HIFDIN);
+
+       return (data >> 24) & 0xff;
+}
+
+int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data)
+{
+       struct mantis_slot *slot = ca->slot;
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 hif_addr = 0;
+
+       hif_addr &= ~MANTIS_GPIF_HIFRDWRN;
+       hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
+       hif_addr &= ~MANTIS_GPIF_PCMCIAIOM;
+       hif_addr |= addr;
+
+       mmwrite(slot->slave_cfg, MANTIS_GPIF_CFGSLA); /* Slot0 alone for now */
+
+       mmwrite(hif_addr, MANTIS_GPIF_HIFADDR);
+       mmwrite(data, MANTIS_GPIF_HIFDOUT);
+       ca->hif_job_queue = MANTIS_HIF_MEMWR;
+
+       if (mantis_hif_sbuf_opdone_wait(ca) != 0) {
+               ca->hif_job_queue &= ~MANTIS_HIF_MEMWR;
+               dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num);
+               return -EREMOTEIO;
+       }
+       ca->hif_job_queue &= ~MANTIS_HIF_MEMWR;
+       return 0;
+}
+
+int mantis_hif_init(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 irqcfg;
+
+       dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Initializing Mantis Host Interface", mantis->num);
+       init_waitqueue_head(&ca->hif_data_wq);
+       init_waitqueue_head(&ca->hif_opdone_wq);
+
+       irqcfg  = mmread(MANTIS_GPIF_IRQCFG);
+       irqcfg |= MANTIS_MASK_BRRDY;
+       mmwrite(irqcfg, MANTIS_GPIF_IRQCFG);
+
+       return 0;
+}
+
+void mantis_hif_exit(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 irqcfg;
+
+       dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Exiting Mantis Host Interface", mantis->num);
+       irqcfg = mmread(MANTIS_GPIF_IRQCFG);
+       irqcfg &= ~MANTIS_MASK_BRRDY;
+       mmwrite(irqcfg, MANTIS_GPIF_IRQCFG);
+}
index 33b39b781d2eb7d619f1d2e7c70378e9d7355c89..8862502866c5246b3c6fb76a895e89e6683a3fb3 100644 (file)
@@ -31,6 +31,8 @@ enum mantis_sbuf_status {
 
 struct mantis_slot {
        u32                             timeout;
+       u32                             slave_cfg;
+       u32                             bar;
 };
 
 /* Physical layer */
@@ -40,7 +42,7 @@ enum mantis_slot_state {
 };
 
 struct mantis_ca {
-       struct mantis_slot              slot;
+       struct mantis_slot              slot[4];
 
        struct work_struct              hif_evm_work;
 
@@ -66,4 +68,10 @@ extern void mantis_pcmcia_exit(struct mantis_ca *ca);
 extern int mantis_evmgr_init(struct mantis_ca *ca);
 extern void mantis_evmgr_exit(struct mantis_ca *ca);
 
+/* HIF */
+extern int mantis_hif_init(struct mantis_ca *ca);
+extern void mantis_hif_exit(struct mantis_ca *ca);
+extern int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr);
+extern int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data);
+
 #endif // __MANTIS_LINK_H
index d9862b7dbf03179ce4b6f4431d16961d378ff820..6f5cd49367632cbf5a5890d62574d99b6d0b194f 100644 (file)
 #define MANTIS_CARD_RESET              0xac
 
 #define MANTIS_GPIF_ADDR               0xb0
-#define MANTIS_GPIF_RDWRN              (0x01           << 31)
+#define MANTIS_GPIF_HIFRDWRN           (0x01           << 31)
 #define MANTIS_GPIF_PCMCIAREG          (0x01           << 27)
 #define MANTIS_GPIF_PCMCIAIOM          (0x01           << 26)
-#define MANTIS_GPIF_HIF_ADDR           (0xfffffff      <<  0)
+#define MANTIS_GPIF_HIFADDR            (0xfffffff      <<  0)
 
 #define MANTIS_GPIF_DOUT               0xb4
-#define MANTIS_GPIF_HIF_DOUT           (0xfffffff      <<  0)
+#define MANTIS_GPIF_HIFDOUT            (0xfffffff      <<  0)
 
 #define MANTIS_GPIF_DIN                        0xb8
-#define MANTIS_GPIF_HIF_DIN            (0xfffffff      <<  0)
+#define MANTIS_GPIF_HIFDIN             (0xfffffff      <<  0)
 
 #define MANTIS_GPIF_SPARE              0xbc
 #define MANTIS_GPIF_LOGICRD            (0xffff         << 16)
This page took 0.031028 seconds and 5 git commands to generate.