]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
Adapted for modified version of VME bridge driver (ca91c042).
authorwentasah <wentasah>
Mon, 23 Aug 2004 15:40:30 +0000 (15:40 +0000)
committerwentasah <wentasah>
Mon, 23 Aug 2004 15:40:30 +0000 (15:40 +0000)
lincan/src/setup.c
lincan/src/unican_vme.c

index 564b3c0ecd5995323dc54a0ea61ef93767b167bb..394704c72f18a7a0ddad918170cb4c8af2cedc5c 100644 (file)
 #include "../include/setup.h"
 #include "../include/finish.h"
 
+#ifdef CAN_ENABLE_VME_SUPPORT
+#include "ca91c042.h"
+/* Modified version of ca91c042 driver can be found in
+ * components/comm/contrib directory. */
+#endif
+
 int init_hwspecops(struct candevice_t *candev, int *irqnum_p);
 int init_device_struct(int card, int *chan_param_idx_p, int *irq_param_idx_p);
 int init_chip_struct(struct candevice_t *candev, int chipnr, int irq, long baudrate);
@@ -583,10 +589,15 @@ int can_chip_setup_irq(struct chip_t *chip)
                        chip->flags |= CHIP_IRQ_SETUP;
                }
        } else {
-#ifdef CAN_ENABLE_VME_SUPPORT          
-               /* TODO: Move here the irq setup from
-                * unican_vme_request_io(). To do this, the VME bridge
-                * driver should be modified. */
+#ifdef CAN_ENABLE_VME_SUPPORT
+               if (chip->chip_irq < 1 || chip->chip_irq > 255) {
+                       CANMSG("Bad irq parameter. (1 <= irq <= 255).\n");
+                       return -EINVAL;
+               }
+               
+               request_vmeirq(chip->chip_irq, chip->chipspecops->irq_handler, chip);
+               DEBUGMSG("Registered VME interrupt vector %d\n",chip->chip_irq);
+               chip->flags |= CHIP_IRQ_SETUP;
 #endif
        }
        return 1;
@@ -604,9 +615,7 @@ void can_chip_free_irq(struct chip_t *chip)
                        free_irq(chip->chip_irq, chip);
                else { 
 #ifdef CAN_ENABLE_VME_SUPPORT
-               /* TODO: Move here the irq cleanup from
-                * unican_vme_release_io(). To do this, the VME bridge
-                * driver should be modified. */
+                       free_vmeirq(chip->chip_irq);
 #endif
                }
                        chip->flags &= ~CHIP_IRQ_SETUP;
index e44a39da3f61ddca96ed77182a7334226c39c687..94f122bbb61aeac53a6f1064673b8895b7fef83e 100644 (file)
@@ -6,75 +6,9 @@
  * Version lincan-0.3  17 Jun 2004
  */ 
 
-/* This file is included in unican.c when CAN_ENABLE_VME_SUPPORT is
+/* This file is included in unican.c if CAN_ENABLE_VME_SUPPORT is
  * set. */
 
-#include "ca91c042.h"
-
-#define UNICAN_VME_IRQ 1
-
-/* Used to pass chip pointer to irq handler. This sould be done in VME
- * bridge driver */
-#define VME_CHIPS_SIZE 8
-struct chip_t *vme_chips[VME_CHIPS_SIZE];
-
-can_irqreturn_t unican_vme_irq_handler(int vmeirq, int vector, void *dev_id, struct pt_regs *regs)
-{
-/*     struct chip_t *chip = vme_chips[vector < VME_CHIPS_SIZE && vector >= 0 ? vector : 0]; */
-       struct chip_t *chip = vme_chips[0];
-
-       DEBUGMSG("unican_vme_irq_handler: vmeirq=0x%08x vector=0x%08x\n", vmeirq, vector);
-       return  unican_irq_handler(vmeirq, chip, regs);
-}
-
-/**
- * unican_program_irq - program interrupts
- * @candev: Pointer to candevice/board structure
- *
- * Return value: The function returns zero on success or %-ENODEV on failure
- * File: src/unican.c
- */
-int unican_vme_program_irq(struct candevice_t *candev)
-{
-       struct chip_t *chip = candev->chip[0];
-
-       if (chip->chip_irq < 0 || chip->chip_irq >= VME_CHIPS_SIZE) {
-               CANMSG("Bad irq parameter. Maximum is %d.\n", VME_CHIPS_SIZE-1);
-               return -EINVAL;
-       }
-
-/*     vme_chips[chip->chip_irq] = chip; */
-       vme_chips[0] = chip;
-
-       request_vmeirq(UNICAN_VME_IRQ, unican_vme_irq_handler);
-       enable_vmeirq(UNICAN_VME_IRQ);
-
-       return 0;
-}
-
-int unican_vme_request_io(struct candevice_t *candev)
-{
-       unican_request_io(candev);
-
-       return 0;
-}
-
-/**
- * unican_vme_release_io - free reserved io memory range
- * @candev: pointer to candevice/board which releases io
- *
- * Return Value: The function always returns zero
- * File: src/unican.c
- */
-int unican_vme_release_io(struct candevice_t *candev)
-{
-       disable_vmeirq(UNICAN_VME_IRQ);
-       free_vmeirq(UNICAN_VME_IRQ);
-
-       unican_release_io(candev);
-
-       return 0;
-}
 
 /**
  * unican_vme_init_hw_data - Initialize hardware cards
@@ -92,8 +26,7 @@ int unican_vme_reset(struct candevice_t *candev)
 
        /* Setup VME interrupt vector */
        if (ret == 0) 
-               unican_writew(0x1234/* chip->chip_irq */,chip->chip_base_addr+CL2_VME_INT_VECTOR);
-
+               unican_writew(chip->chip_irq, chip->chip_base_addr+CL2_VME_INT_VECTOR);
 
        return ret;
 }
@@ -113,7 +46,7 @@ int unican_vme_init_chip_data(struct candevice_t *candev, int chipnr)
        unican_init_chip_data(candev, chipnr);
 
        chip->flags |= CHIP_IRQ_VME;
-       chip->chipspecops->irq_handler=unican_vme_irq_handler;
+       chip->chipspecops->irq_handler=unican_irq_handler;
        return 0;
 }
 
@@ -132,9 +65,8 @@ int unican_vme_register(struct hwspecops_t *hwspecops)
 
        hwspecops->init_hw_data = unican_vme_init_hw_data;
        hwspecops->init_chip_data = unican_vme_init_chip_data;
-       hwspecops->request_io = unican_vme_request_io;
+       hwspecops->request_io = unican_request_io;
        hwspecops->reset = unican_vme_reset;
-       hwspecops->program_irq = unican_vme_program_irq;
-       hwspecops->release_io = unican_vme_release_io;
+       hwspecops->release_io = unican_release_io;
        return 0;
 }