omap3530/beagle_drivers/wb/api/src/cyasintr.c
changeset 27 117faf51deac
equal deleted inserted replaced
26:b7e488c49d0d 27:117faf51deac
       
     1 /* Cypress West Bridge API source file (cyasintr.c)
       
     2  ## ===========================
       
     3  ##
       
     4  ##  Copyright Cypress Semiconductor Corporation, 2006-2009,
       
     5  ##  All Rights Reserved
       
     6  ##  UNPUBLISHED, LICENSED SOFTWARE.
       
     7  ##
       
     8  ##  CONFIDENTIAL AND PROPRIETARY INFORMATION
       
     9  ##  WHICH IS THE PROPERTY OF CYPRESS.
       
    10  ##
       
    11  ##  Use of this file is governed
       
    12  ##  by the license agreement included in the file
       
    13  ##
       
    14  ##     <install>/license/license.txt
       
    15  ##
       
    16  ##  where <install> is the Cypress software
       
    17  ##  installation root directory path.
       
    18  ##
       
    19  ## ===========================
       
    20 */
       
    21 
       
    22 #include "cyashal.h"
       
    23 #include "cyasdevice.h"
       
    24 #include "cyasregs.h"
       
    25 #include "cyaserr.h"
       
    26 
       
    27 extern void CyAsMailBoxInterruptHandler(CyAsDevice *) ;
       
    28 
       
    29 void
       
    30 CyAsMcuInterruptHandler(CyAsDevice *dev_p)
       
    31 {
       
    32     /* Read and clear the interrupt. */
       
    33     uint16_t v ;
       
    34 
       
    35     v = CyAsHalReadRegister(dev_p->tag, CY_AS_MEM_P0_MCU_STAT) ;
       
    36     v = v ;
       
    37 }
       
    38 
       
    39 void
       
    40 CyAsPowerManagementInterruptHandler(CyAsDevice *dev_p)
       
    41 {
       
    42     uint16_t v ;
       
    43 
       
    44     v = CyAsHalReadRegister(dev_p->tag, CY_AS_MEM_PWR_MAGT_STAT) ;
       
    45     v = v ;
       
    46 }
       
    47 
       
    48 void
       
    49 CyAsPllLockLossInterruptHandler(CyAsDevice *dev_p)
       
    50 {
       
    51     uint16_t v ;
       
    52 
       
    53     v = CyAsHalReadRegister(dev_p->tag, CY_AS_MEM_PLL_LOCK_LOSS_STAT) ;
       
    54     v = v ;
       
    55 }
       
    56 
       
    57 uint32_t CyAsIntrStart(CyAsDevice *dev_p, CyBool dmaintr)
       
    58 {
       
    59     uint16_t v ;
       
    60 
       
    61     CyAsHalAssert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE) ;
       
    62 
       
    63     if (CyAsDeviceIsIntrRunning(dev_p) != 0)
       
    64         return CY_AS_ERROR_ALREADY_RUNNING ;
       
    65 
       
    66     v = CY_AS_MEM_P0_INT_MASK_REG_MMCUINT |
       
    67         CY_AS_MEM_P0_INT_MASK_REG_MMBINT |
       
    68         CY_AS_MEM_P0_INT_MASK_REG_MPMINT ;
       
    69 
       
    70     if (dmaintr)
       
    71         v |= CY_AS_MEM_P0_INT_MASK_REG_MDRQINT ;
       
    72 
       
    73     /* Enable the interrupts of interest */
       
    74     CyAsHalWriteRegister(dev_p->tag, CY_AS_MEM_P0_INT_MASK_REG, v) ;
       
    75 
       
    76     /* Mark the interrupt module as initialized */
       
    77     CyAsDeviceSetIntrRunning(dev_p) ;
       
    78 
       
    79     return CY_AS_ERROR_SUCCESS ;
       
    80 }
       
    81 
       
    82 uint32_t CyAsIntrStop(CyAsDevice *dev_p)
       
    83 {
       
    84     CyAsHalAssert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE) ;
       
    85 
       
    86     if (CyAsDeviceIsIntrRunning(dev_p) == 0)
       
    87         return CY_AS_ERROR_NOT_RUNNING ;
       
    88 
       
    89     CyAsHalWriteRegister(dev_p->tag, CY_AS_MEM_P0_INT_MASK_REG, 0) ;
       
    90     CyAsDeviceSetIntrStopped(dev_p) ;
       
    91 
       
    92     return CY_AS_ERROR_SUCCESS ;
       
    93 }
       
    94 
       
    95 void CyAsIntrServiceInterrupt(CyAsHalDeviceTag tag)
       
    96 {
       
    97     uint16_t v ;
       
    98     CyAsDevice *dev_p ;
       
    99 
       
   100     dev_p = CyAsDeviceFindFromTag(tag) ;
       
   101 
       
   102     /*
       
   103        Only power management interrupts can occur before the Antioch API setup is complete.
       
   104        If this is a PM interrupt, handle it here; otherwise output a warning message.
       
   105      */
       
   106     if (dev_p == 0)
       
   107     {
       
   108         v = CyAsHalReadRegister(tag, CY_AS_MEM_P0_INTR_REG) ;
       
   109         if (v == CY_AS_MEM_P0_INTR_REG_PMINT)
       
   110         {
       
   111             /* Read the PWR_MAGT_STAT register to clear this interrupt. */
       
   112             v = CyAsHalReadRegister(tag, CY_AS_MEM_PWR_MAGT_STAT) ;
       
   113         }
       
   114         else
       
   115             ;//CyAsHalPrintMessage("Stray Antioch interrupt detected, tag not associated with any created device.") ;
       
   116         return ;
       
   117     }
       
   118 
       
   119     /* Make sure we got a valid object from CyAsDeviceFindFromTag */
       
   120     CyAsHalAssert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE) ;
       
   121 
       
   122     v = CyAsHalReadRegister(dev_p->tag, CY_AS_MEM_P0_INTR_REG) ;
       
   123 
       
   124     if (v & CY_AS_MEM_P0_INTR_REG_MCUINT)
       
   125         CyAsMcuInterruptHandler(dev_p) ;
       
   126 
       
   127     if (v & CY_AS_MEM_P0_INTR_REG_PMINT)
       
   128         CyAsPowerManagementInterruptHandler(dev_p) ;
       
   129 
       
   130     if (v & CY_AS_MEM_P0_INTR_REG_PLLLOCKINT)
       
   131         CyAsPllLockLossInterruptHandler(dev_p) ;
       
   132 
       
   133     /* If the interrupt module is not running, no mailbox interrupts are expected
       
   134      * from the Antioch. */
       
   135     if (CyAsDeviceIsIntrRunning(dev_p) == 0)
       
   136         return ;
       
   137 
       
   138     if (v & CY_AS_MEM_P0_INTR_REG_MBINT)
       
   139         CyAsMailBoxInterruptHandler(dev_p) ;
       
   140 }
       
   141