DAC960.h
上传用户:ajay2009
上传日期:2009-05-22
资源大小:495k
文件大小:149k
源码类别:

驱动编程

开发平台:

Unix_Linux

  1. /*
  2.   Define the DAC960 Driver Command Types.
  3. */
  4. typedef enum
  5. {
  6.   DAC960_ReadCommand = 1,
  7.   DAC960_WriteCommand = 2,
  8.   DAC960_ReadRetryCommand = 3,
  9.   DAC960_WriteRetryCommand = 4,
  10.   DAC960_MonitoringCommand = 5,
  11.   DAC960_ImmediateCommand = 6,
  12.   DAC960_QueuedCommand = 7
  13. }
  14. DAC960_CommandType_T;
  15. /*
  16.   Define the DAC960 Driver Command structure.
  17. */
  18. typedef struct DAC960_Command
  19. {
  20.   int CommandIdentifier;
  21.   DAC960_CommandType_T CommandType;
  22.   struct DAC960_Controller *Controller;
  23.   struct DAC960_Command *Next;
  24.   struct completion *Completion;
  25.   unsigned int LogicalDriveNumber;
  26.   unsigned int BlockNumber;
  27.   unsigned int BlockCount;
  28.   unsigned int SegmentCount;
  29.   int DmaDirection;
  30.   struct scatterlist *cmd_sglist;
  31.   struct request *Request;
  32.   union {
  33.     struct {
  34.       DAC960_V1_CommandMailbox_T CommandMailbox;
  35.       DAC960_V1_KernelCommand_T *KernelCommand;
  36.       DAC960_V1_CommandStatus_T CommandStatus;
  37.       DAC960_V1_ScatterGatherSegment_T *ScatterGatherList;
  38.       dma_addr_t ScatterGatherListDMA;
  39.       struct scatterlist ScatterList[DAC960_V1_ScatterGatherLimit];
  40.       unsigned int EndMarker[0];
  41.     } V1;
  42.     struct {
  43.       DAC960_V2_CommandMailbox_T CommandMailbox;
  44.       DAC960_V2_KernelCommand_T *KernelCommand;
  45.       DAC960_V2_CommandStatus_T CommandStatus;
  46.       unsigned char RequestSenseLength;
  47.       int DataTransferResidue;
  48.       DAC960_V2_ScatterGatherSegment_T *ScatterGatherList;
  49.       dma_addr_t ScatterGatherListDMA;
  50.       DAC960_SCSI_RequestSense_T *RequestSense;
  51.       dma_addr_t RequestSenseDMA;
  52.       struct scatterlist ScatterList[DAC960_V2_ScatterGatherLimit];
  53.       unsigned int EndMarker[0];
  54.     } V2;
  55.   } FW;
  56. }
  57. DAC960_Command_T;
  58. /*
  59.   Define the DAC960 Driver Controller structure.
  60. */
  61. typedef struct DAC960_Controller
  62. {
  63.   void __iomem *BaseAddress;
  64.   void __iomem *MemoryMappedAddress;
  65.   DAC960_FirmwareType_T FirmwareType;
  66.   DAC960_HardwareType_T HardwareType;
  67.   DAC960_IO_Address_T IO_Address;
  68.   DAC960_PCI_Address_T PCI_Address;
  69.   struct pci_dev *PCIDevice;
  70.   unsigned char ControllerNumber;
  71.   unsigned char ControllerName[4];
  72.   unsigned char ModelName[20];
  73.   unsigned char FullModelName[28];
  74.   unsigned char FirmwareVersion[12];
  75.   unsigned char Bus;
  76.   unsigned char Device;
  77.   unsigned char Function;
  78.   unsigned char IRQ_Channel;
  79.   unsigned char Channels;
  80.   unsigned char Targets;
  81.   unsigned char MemorySize;
  82.   unsigned char LogicalDriveCount;
  83.   unsigned short CommandAllocationGroupSize;
  84.   unsigned short ControllerQueueDepth;
  85.   unsigned short DriverQueueDepth;
  86.   unsigned short MaxBlocksPerCommand;
  87.   unsigned short ControllerScatterGatherLimit;
  88.   unsigned short DriverScatterGatherLimit;
  89.   u64 BounceBufferLimit;
  90.   unsigned int CombinedStatusBufferLength;
  91.   unsigned int InitialStatusLength;
  92.   unsigned int CurrentStatusLength;
  93.   unsigned int ProgressBufferLength;
  94.   unsigned int UserStatusLength;
  95.   struct dma_loaf DmaPages;
  96.   unsigned long MonitoringTimerCount;
  97.   unsigned long PrimaryMonitoringTime;
  98.   unsigned long SecondaryMonitoringTime;
  99.   unsigned long ShutdownMonitoringTimer;
  100.   unsigned long LastProgressReportTime;
  101.   unsigned long LastCurrentStatusTime;
  102.   boolean ControllerInitialized;
  103.   boolean MonitoringCommandDeferred;
  104.   boolean EphemeralProgressMessage;
  105.   boolean DriveSpinUpMessageDisplayed;
  106.   boolean MonitoringAlertMode;
  107.   boolean SuppressEnclosureMessages;
  108.   struct timer_list MonitoringTimer;
  109.   struct gendisk *disks[DAC960_MaxLogicalDrives];
  110.   struct pci_pool *ScatterGatherPool;
  111.   DAC960_Command_T *FreeCommands;
  112.   unsigned char *CombinedStatusBuffer;
  113.   unsigned char *CurrentStatusBuffer;
  114.   struct request_queue *RequestQueue[DAC960_MaxLogicalDrives];
  115.   int req_q_index;
  116.   spinlock_t queue_lock;
  117.   wait_queue_head_t CommandWaitQueue;
  118.   wait_queue_head_t HealthStatusWaitQueue;
  119.   DAC960_Command_T InitialCommand;
  120.   DAC960_Command_T *Commands[DAC960_MaxDriverQueueDepth];
  121.   struct proc_dir_entry *ControllerProcEntry;
  122.   boolean LogicalDriveInitiallyAccessible[DAC960_MaxLogicalDrives];
  123.   void (*QueueCommand)(DAC960_Command_T *Command);
  124.   boolean (*ReadControllerConfiguration)(struct DAC960_Controller *);
  125.   boolean (*ReadDeviceConfiguration)(struct DAC960_Controller *);
  126.   boolean (*ReportDeviceConfiguration)(struct DAC960_Controller *);
  127.   void (*QueueReadWriteCommand)(DAC960_Command_T *Command);
  128.   union {
  129.     struct {
  130.       unsigned char GeometryTranslationHeads;
  131.       unsigned char GeometryTranslationSectors;
  132.       unsigned char PendingRebuildFlag;
  133.       unsigned short StripeSize;
  134.       unsigned short SegmentSize;
  135.       unsigned short NewEventLogSequenceNumber;
  136.       unsigned short OldEventLogSequenceNumber;
  137.       unsigned short DeviceStateChannel;
  138.       unsigned short DeviceStateTargetID;
  139.       boolean DualModeMemoryMailboxInterface;
  140.       boolean BackgroundInitializationStatusSupported;
  141.       boolean SAFTE_EnclosureManagementEnabled;
  142.       boolean NeedLogicalDriveInformation;
  143.       boolean NeedErrorTableInformation;
  144.       boolean NeedDeviceStateInformation;
  145.       boolean NeedDeviceInquiryInformation;
  146.       boolean NeedDeviceSerialNumberInformation;
  147.       boolean NeedRebuildProgress;
  148.       boolean NeedConsistencyCheckProgress;
  149.       boolean NeedBackgroundInitializationStatus;
  150.       boolean StartDeviceStateScan;
  151.       boolean RebuildProgressFirst;
  152.       boolean RebuildFlagPending;
  153.       boolean RebuildStatusPending;
  154.       dma_addr_t FirstCommandMailboxDMA;
  155.       DAC960_V1_CommandMailbox_T *FirstCommandMailbox;
  156.       DAC960_V1_CommandMailbox_T *LastCommandMailbox;
  157.       DAC960_V1_CommandMailbox_T *NextCommandMailbox;
  158.       DAC960_V1_CommandMailbox_T *PreviousCommandMailbox1;
  159.       DAC960_V1_CommandMailbox_T *PreviousCommandMailbox2;
  160.       dma_addr_t FirstStatusMailboxDMA;
  161.       DAC960_V1_StatusMailbox_T *FirstStatusMailbox;
  162.       DAC960_V1_StatusMailbox_T *LastStatusMailbox;
  163.       DAC960_V1_StatusMailbox_T *NextStatusMailbox;
  164.       DAC960_V1_DCDB_T *MonitoringDCDB;
  165.       dma_addr_t MonitoringDCDB_DMA;
  166.       DAC960_V1_Enquiry_T Enquiry;
  167.       DAC960_V1_Enquiry_T *NewEnquiry;
  168.       dma_addr_t NewEnquiryDMA;
  169.       DAC960_V1_ErrorTable_T ErrorTable;
  170.       DAC960_V1_ErrorTable_T *NewErrorTable;
  171.       dma_addr_t NewErrorTableDMA;
  172.       DAC960_V1_EventLogEntry_T *EventLogEntry;
  173.       dma_addr_t EventLogEntryDMA;
  174.       DAC960_V1_RebuildProgress_T *RebuildProgress;
  175.       dma_addr_t RebuildProgressDMA;
  176.       DAC960_V1_CommandStatus_T LastRebuildStatus;
  177.       DAC960_V1_CommandStatus_T PendingRebuildStatus;
  178.       DAC960_V1_LogicalDriveInformationArray_T LogicalDriveInformation;
  179.       DAC960_V1_LogicalDriveInformationArray_T *NewLogicalDriveInformation;
  180.       dma_addr_t NewLogicalDriveInformationDMA;
  181.       DAC960_V1_BackgroundInitializationStatus_T
  182.          *BackgroundInitializationStatus;
  183.       dma_addr_t BackgroundInitializationStatusDMA;
  184.       DAC960_V1_BackgroundInitializationStatus_T
  185.          LastBackgroundInitializationStatus;
  186.       DAC960_V1_DeviceState_T
  187. DeviceState[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
  188.       DAC960_V1_DeviceState_T *NewDeviceState;
  189.       dma_addr_t NewDeviceStateDMA;
  190.       DAC960_SCSI_Inquiry_T
  191. InquiryStandardData[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
  192.       DAC960_SCSI_Inquiry_T *NewInquiryStandardData;
  193.       dma_addr_t NewInquiryStandardDataDMA;
  194.       DAC960_SCSI_Inquiry_UnitSerialNumber_T
  195. InquiryUnitSerialNumber[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
  196.       DAC960_SCSI_Inquiry_UnitSerialNumber_T *NewInquiryUnitSerialNumber;
  197.       dma_addr_t NewInquiryUnitSerialNumberDMA;
  198.       int DeviceResetCount[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
  199.       boolean DirectCommandActive[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
  200.     } V1;
  201.     struct {
  202.       unsigned int StatusChangeCounter;
  203.       unsigned int NextEventSequenceNumber;
  204.       unsigned int PhysicalDeviceIndex;
  205.       boolean NeedLogicalDeviceInformation;
  206.       boolean NeedPhysicalDeviceInformation;
  207.       boolean NeedDeviceSerialNumberInformation;
  208.       boolean StartLogicalDeviceInformationScan;
  209.       boolean StartPhysicalDeviceInformationScan;
  210.       struct pci_pool *RequestSensePool;
  211.       dma_addr_t FirstCommandMailboxDMA;
  212.       DAC960_V2_CommandMailbox_T *FirstCommandMailbox;
  213.       DAC960_V2_CommandMailbox_T *LastCommandMailbox;
  214.       DAC960_V2_CommandMailbox_T *NextCommandMailbox;
  215.       DAC960_V2_CommandMailbox_T *PreviousCommandMailbox1;
  216.       DAC960_V2_CommandMailbox_T *PreviousCommandMailbox2;
  217.       dma_addr_t FirstStatusMailboxDMA;
  218.       DAC960_V2_StatusMailbox_T *FirstStatusMailbox;
  219.       DAC960_V2_StatusMailbox_T *LastStatusMailbox;
  220.       DAC960_V2_StatusMailbox_T *NextStatusMailbox;
  221.       dma_addr_t HealthStatusBufferDMA;
  222.       DAC960_V2_HealthStatusBuffer_T *HealthStatusBuffer;
  223.       DAC960_V2_ControllerInfo_T ControllerInformation;
  224.       DAC960_V2_ControllerInfo_T *NewControllerInformation;
  225.       dma_addr_t NewControllerInformationDMA;
  226.       DAC960_V2_LogicalDeviceInfo_T
  227. *LogicalDeviceInformation[DAC960_MaxLogicalDrives];
  228.       DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInformation;
  229.       dma_addr_t  NewLogicalDeviceInformationDMA;
  230.       DAC960_V2_PhysicalDeviceInfo_T
  231. *PhysicalDeviceInformation[DAC960_V2_MaxPhysicalDevices];
  232.       DAC960_V2_PhysicalDeviceInfo_T *NewPhysicalDeviceInformation;
  233.       dma_addr_t NewPhysicalDeviceInformationDMA;
  234.       DAC960_SCSI_Inquiry_UnitSerialNumber_T *NewInquiryUnitSerialNumber;
  235.       dma_addr_t NewInquiryUnitSerialNumberDMA;
  236.       DAC960_SCSI_Inquiry_UnitSerialNumber_T
  237. *InquiryUnitSerialNumber[DAC960_V2_MaxPhysicalDevices];
  238.       DAC960_V2_Event_T *Event;
  239.       dma_addr_t EventDMA;
  240.       DAC960_V2_PhysicalToLogicalDevice_T *PhysicalToLogicalDevice;
  241.       dma_addr_t PhysicalToLogicalDeviceDMA;
  242.       DAC960_V2_PhysicalDevice_T
  243. LogicalDriveToVirtualDevice[DAC960_MaxLogicalDrives];
  244.       boolean LogicalDriveFoundDuringScan[DAC960_MaxLogicalDrives];
  245.     } V2;
  246.   } FW;
  247.   unsigned char ProgressBuffer[DAC960_ProgressBufferSize];
  248.   unsigned char UserStatusBuffer[DAC960_UserMessageSize];
  249. }
  250. DAC960_Controller_T;
  251. /*
  252.   Simplify access to Firmware Version Dependent Data Structure Components
  253.   and Functions.
  254. */
  255. #define V1 FW.V1
  256. #define V2 FW.V2
  257. #define DAC960_QueueCommand(Command) 
  258.   (Controller->QueueCommand)(Command)
  259. #define DAC960_ReadControllerConfiguration(Controller) 
  260.   (Controller->ReadControllerConfiguration)(Controller)
  261. #define DAC960_ReadDeviceConfiguration(Controller) 
  262.   (Controller->ReadDeviceConfiguration)(Controller)
  263. #define DAC960_ReportDeviceConfiguration(Controller) 
  264.   (Controller->ReportDeviceConfiguration)(Controller)
  265. #define DAC960_QueueReadWriteCommand(Command) 
  266.   (Controller->QueueReadWriteCommand)(Command)
  267. /*
  268.  * dma_addr_writeql is provided to write dma_addr_t types
  269.  * to a 64-bit pci address space register.  The controller
  270.  * will accept having the register written as two 32-bit
  271.  * values.
  272.  *
  273.  * In HIGHMEM kernels, dma_addr_t is a 64-bit value.
  274.  * without HIGHMEM,  dma_addr_t is a 32-bit value.
  275.  *
  276.  * The compiler should always fix up the assignment
  277.  * to u.wq appropriately, depending upon the size of
  278.  * dma_addr_t.
  279.  */
  280. static inline
  281. void dma_addr_writeql(dma_addr_t addr, void __iomem *write_address)
  282. {
  283. union {
  284. u64 wq;
  285. uint wl[2];
  286. } u;
  287. u.wq = addr;
  288. writel(u.wl[0], write_address);
  289. writel(u.wl[1], write_address + 4);
  290. }
  291. /*
  292.   Define the DAC960 GEM Series Controller Interface Register Offsets.
  293.  */
  294. #define DAC960_GEM_RegisterWindowSize 0x600
  295. typedef enum
  296. {
  297.   DAC960_GEM_InboundDoorBellRegisterReadSetOffset   =   0x214,
  298.   DAC960_GEM_InboundDoorBellRegisterClearOffset     =   0x218,
  299.   DAC960_GEM_OutboundDoorBellRegisterReadSetOffset  =   0x224,
  300.   DAC960_GEM_OutboundDoorBellRegisterClearOffset    =   0x228,
  301.   DAC960_GEM_InterruptStatusRegisterOffset          =   0x208,
  302.   DAC960_GEM_InterruptMaskRegisterReadSetOffset     =   0x22C,
  303.   DAC960_GEM_InterruptMaskRegisterClearOffset       =   0x230,
  304.   DAC960_GEM_CommandMailboxBusAddressOffset         =   0x510,
  305.   DAC960_GEM_CommandStatusOffset                    =   0x518,
  306.   DAC960_GEM_ErrorStatusRegisterReadSetOffset       =   0x224,
  307.   DAC960_GEM_ErrorStatusRegisterClearOffset         =   0x228,
  308. }
  309. DAC960_GEM_RegisterOffsets_T;
  310. /*
  311.   Define the structure of the DAC960 GEM Series Inbound Door Bell
  312.  */
  313. typedef union DAC960_GEM_InboundDoorBellRegister
  314. {
  315.   unsigned int All;
  316.   struct {
  317.     unsigned int :24;
  318.     boolean HardwareMailboxNewCommand:1;
  319.     boolean AcknowledgeHardwareMailboxStatus:1;
  320.     boolean GenerateInterrupt:1;
  321.     boolean ControllerReset:1;
  322.     boolean MemoryMailboxNewCommand:1;
  323.     unsigned int :3;
  324.   } Write;
  325.   struct {
  326.     unsigned int :24;
  327.     boolean HardwareMailboxFull:1;
  328.     boolean InitializationInProgress:1;
  329.     unsigned int :6;
  330.   } Read;
  331. }
  332. DAC960_GEM_InboundDoorBellRegister_T;
  333. /*
  334.   Define the structure of the DAC960 GEM Series Outbound Door Bell Register.
  335.  */
  336. typedef union DAC960_GEM_OutboundDoorBellRegister
  337. {
  338.   unsigned int All;
  339.   struct {
  340.     unsigned int :24;
  341.     boolean AcknowledgeHardwareMailboxInterrupt:1;
  342.     boolean AcknowledgeMemoryMailboxInterrupt:1;
  343.     unsigned int :6;
  344.   } Write;
  345.   struct {
  346.     unsigned int :24;
  347.     boolean HardwareMailboxStatusAvailable:1;
  348.     boolean MemoryMailboxStatusAvailable:1;
  349.     unsigned int :6;
  350.   } Read;
  351. }
  352. DAC960_GEM_OutboundDoorBellRegister_T;
  353. /*
  354.   Define the structure of the DAC960 GEM Series Interrupt Mask Register.
  355.  */
  356. typedef union DAC960_GEM_InterruptMaskRegister
  357. {
  358.   unsigned int All;
  359.   struct {
  360.     unsigned int :16;
  361.     unsigned int :8;
  362.     unsigned int HardwareMailboxInterrupt:1;
  363.     unsigned int MemoryMailboxInterrupt:1;
  364.     unsigned int :6;
  365.   } Bits;
  366. }
  367. DAC960_GEM_InterruptMaskRegister_T;
  368. /*
  369.   Define the structure of the DAC960 GEM Series Error Status Register.
  370.  */
  371. typedef union DAC960_GEM_ErrorStatusRegister
  372. {
  373.   unsigned int All;
  374.   struct {
  375.     unsigned int :24;
  376.     unsigned int :5;
  377.     boolean ErrorStatusPending:1;
  378.     unsigned int :2;
  379.   } Bits;
  380. }
  381. DAC960_GEM_ErrorStatusRegister_T;
  382. /*
  383.   Define inline functions to provide an abstraction for reading and writing the
  384.   DAC960 GEM Series Controller Interface Registers.
  385. */
  386. static inline
  387. void DAC960_GEM_HardwareMailboxNewCommand(void __iomem *ControllerBaseAddress)
  388. {
  389.   DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
  390.   InboundDoorBellRegister.All = 0;
  391.   InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  392.   writel(InboundDoorBellRegister.All,
  393.  ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
  394. }
  395. static inline
  396. void DAC960_GEM_AcknowledgeHardwareMailboxStatus(void __iomem *ControllerBaseAddress)
  397. {
  398.   DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
  399.   InboundDoorBellRegister.All = 0;
  400.   InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  401.   writel(InboundDoorBellRegister.All,
  402.  ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterClearOffset);
  403. }
  404. static inline
  405. void DAC960_GEM_GenerateInterrupt(void __iomem *ControllerBaseAddress)
  406. {
  407.   DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
  408.   InboundDoorBellRegister.All = 0;
  409.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  410.   writel(InboundDoorBellRegister.All,
  411.  ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
  412. }
  413. static inline
  414. void DAC960_GEM_ControllerReset(void __iomem *ControllerBaseAddress)
  415. {
  416.   DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
  417.   InboundDoorBellRegister.All = 0;
  418.   InboundDoorBellRegister.Write.ControllerReset = true;
  419.   writel(InboundDoorBellRegister.All,
  420.  ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
  421. }
  422. static inline
  423. void DAC960_GEM_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
  424. {
  425.   DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
  426.   InboundDoorBellRegister.All = 0;
  427.   InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  428.   writel(InboundDoorBellRegister.All,
  429.  ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
  430. }
  431. static inline
  432. boolean DAC960_GEM_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
  433. {
  434.   DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
  435.   InboundDoorBellRegister.All =
  436.     readl(ControllerBaseAddress +
  437.           DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
  438.   return InboundDoorBellRegister.Read.HardwareMailboxFull;
  439. }
  440. static inline
  441. boolean DAC960_GEM_InitializationInProgressP(void __iomem *ControllerBaseAddress)
  442. {
  443.   DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
  444.   InboundDoorBellRegister.All =
  445.     readl(ControllerBaseAddress +
  446.           DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
  447.   return InboundDoorBellRegister.Read.InitializationInProgress;
  448. }
  449. static inline
  450. void DAC960_GEM_AcknowledgeHardwareMailboxInterrupt(void __iomem *ControllerBaseAddress)
  451. {
  452.   DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  453.   OutboundDoorBellRegister.All = 0;
  454.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  455.   writel(OutboundDoorBellRegister.All,
  456.  ControllerBaseAddress + DAC960_GEM_OutboundDoorBellRegisterClearOffset);
  457. }
  458. static inline
  459. void DAC960_GEM_AcknowledgeMemoryMailboxInterrupt(void __iomem *ControllerBaseAddress)
  460. {
  461.   DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  462.   OutboundDoorBellRegister.All = 0;
  463.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  464.   writel(OutboundDoorBellRegister.All,
  465.  ControllerBaseAddress + DAC960_GEM_OutboundDoorBellRegisterClearOffset);
  466. }
  467. static inline
  468. void DAC960_GEM_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
  469. {
  470.   DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  471.   OutboundDoorBellRegister.All = 0;
  472.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  473.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  474.   writel(OutboundDoorBellRegister.All,
  475.  ControllerBaseAddress + DAC960_GEM_OutboundDoorBellRegisterClearOffset);
  476. }
  477. static inline
  478. boolean DAC960_GEM_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
  479. {
  480.   DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  481.   OutboundDoorBellRegister.All =
  482.     readl(ControllerBaseAddress +
  483.           DAC960_GEM_OutboundDoorBellRegisterReadSetOffset);
  484.   return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
  485. }
  486. static inline
  487. boolean DAC960_GEM_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
  488. {
  489.   DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  490.   OutboundDoorBellRegister.All =
  491.     readl(ControllerBaseAddress +
  492.           DAC960_GEM_OutboundDoorBellRegisterReadSetOffset);
  493.   return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
  494. }
  495. static inline
  496. void DAC960_GEM_EnableInterrupts(void __iomem *ControllerBaseAddress)
  497. {
  498.   DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
  499.   InterruptMaskRegister.All = 0;
  500.   InterruptMaskRegister.Bits.HardwareMailboxInterrupt = true;
  501.   InterruptMaskRegister.Bits.MemoryMailboxInterrupt = true;
  502.   writel(InterruptMaskRegister.All,
  503.  ControllerBaseAddress + DAC960_GEM_InterruptMaskRegisterClearOffset);
  504. }
  505. static inline
  506. void DAC960_GEM_DisableInterrupts(void __iomem *ControllerBaseAddress)
  507. {
  508.   DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
  509.   InterruptMaskRegister.All = 0;
  510.   InterruptMaskRegister.Bits.HardwareMailboxInterrupt = true;
  511.   InterruptMaskRegister.Bits.MemoryMailboxInterrupt = true;
  512.   writel(InterruptMaskRegister.All,
  513.  ControllerBaseAddress + DAC960_GEM_InterruptMaskRegisterReadSetOffset);
  514. }
  515. static inline
  516. boolean DAC960_GEM_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
  517. {
  518.   DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
  519.   InterruptMaskRegister.All =
  520.     readl(ControllerBaseAddress +
  521.           DAC960_GEM_InterruptMaskRegisterReadSetOffset);
  522.   return !(InterruptMaskRegister.Bits.HardwareMailboxInterrupt ||
  523.            InterruptMaskRegister.Bits.MemoryMailboxInterrupt);
  524. }
  525. static inline
  526. void DAC960_GEM_WriteCommandMailbox(DAC960_V2_CommandMailbox_T
  527.      *MemoryCommandMailbox,
  528.    DAC960_V2_CommandMailbox_T
  529.      *CommandMailbox)
  530. {
  531.   memcpy(&MemoryCommandMailbox->Words[1], &CommandMailbox->Words[1],
  532.  sizeof(DAC960_V2_CommandMailbox_T) - sizeof(unsigned int));
  533.   wmb();
  534.   MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
  535.   mb();
  536. }
  537. static inline
  538. void DAC960_GEM_WriteHardwareMailbox(void __iomem *ControllerBaseAddress,
  539.     dma_addr_t CommandMailboxDMA)
  540. {
  541. dma_addr_writeql(CommandMailboxDMA,
  542. ControllerBaseAddress +
  543. DAC960_GEM_CommandMailboxBusAddressOffset);
  544. }
  545. static inline DAC960_V2_CommandIdentifier_T
  546. DAC960_GEM_ReadCommandIdentifier(void __iomem *ControllerBaseAddress)
  547. {
  548.   return readw(ControllerBaseAddress + DAC960_GEM_CommandStatusOffset);
  549. }
  550. static inline DAC960_V2_CommandStatus_T
  551. DAC960_GEM_ReadCommandStatus(void __iomem *ControllerBaseAddress)
  552. {
  553.   return readw(ControllerBaseAddress + DAC960_GEM_CommandStatusOffset + 2);
  554. }
  555. static inline boolean
  556. DAC960_GEM_ReadErrorStatus(void __iomem *ControllerBaseAddress,
  557.   unsigned char *ErrorStatus,
  558.   unsigned char *Parameter0,
  559.   unsigned char *Parameter1)
  560. {
  561.   DAC960_GEM_ErrorStatusRegister_T ErrorStatusRegister;
  562.   ErrorStatusRegister.All =
  563.     readl(ControllerBaseAddress + DAC960_GEM_ErrorStatusRegisterReadSetOffset);
  564.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  565.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  566.   *ErrorStatus = ErrorStatusRegister.All;
  567.   *Parameter0 =
  568.     readb(ControllerBaseAddress + DAC960_GEM_CommandMailboxBusAddressOffset + 0);
  569.   *Parameter1 =
  570.     readb(ControllerBaseAddress + DAC960_GEM_CommandMailboxBusAddressOffset + 1);
  571.   writel(0x03000000, ControllerBaseAddress +
  572.          DAC960_GEM_ErrorStatusRegisterClearOffset);
  573.   return true;
  574. }
  575. /*
  576.   Define the DAC960 BA Series Controller Interface Register Offsets.
  577. */
  578. #define DAC960_BA_RegisterWindowSize 0x80
  579. typedef enum
  580. {
  581.   DAC960_BA_InboundDoorBellRegisterOffset = 0x60,
  582.   DAC960_BA_OutboundDoorBellRegisterOffset = 0x61,
  583.   DAC960_BA_InterruptStatusRegisterOffset = 0x30,
  584.   DAC960_BA_InterruptMaskRegisterOffset = 0x34,
  585.   DAC960_BA_CommandMailboxBusAddressOffset = 0x50,
  586.   DAC960_BA_CommandStatusOffset = 0x58,
  587.   DAC960_BA_ErrorStatusRegisterOffset = 0x63
  588. }
  589. DAC960_BA_RegisterOffsets_T;
  590. /*
  591.   Define the structure of the DAC960 BA Series Inbound Door Bell Register.
  592. */
  593. typedef union DAC960_BA_InboundDoorBellRegister
  594. {
  595.   unsigned char All;
  596.   struct {
  597.     boolean HardwareMailboxNewCommand:1; /* Bit 0 */
  598.     boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
  599.     boolean GenerateInterrupt:1; /* Bit 2 */
  600.     boolean ControllerReset:1; /* Bit 3 */
  601.     boolean MemoryMailboxNewCommand:1; /* Bit 4 */
  602.     unsigned char :3; /* Bits 5-7 */
  603.   } Write;
  604.   struct {
  605.     boolean HardwareMailboxEmpty:1; /* Bit 0 */
  606.     boolean InitializationNotInProgress:1; /* Bit 1 */
  607.     unsigned char :6; /* Bits 2-7 */
  608.   } Read;
  609. }
  610. DAC960_BA_InboundDoorBellRegister_T;
  611. /*
  612.   Define the structure of the DAC960 BA Series Outbound Door Bell Register.
  613. */
  614. typedef union DAC960_BA_OutboundDoorBellRegister
  615. {
  616.   unsigned char All;
  617.   struct {
  618.     boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
  619.     boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
  620.     unsigned char :6; /* Bits 2-7 */
  621.   } Write;
  622.   struct {
  623.     boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */
  624.     boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */
  625.     unsigned char :6; /* Bits 2-7 */
  626.   } Read;
  627. }
  628. DAC960_BA_OutboundDoorBellRegister_T;
  629. /*
  630.   Define the structure of the DAC960 BA Series Interrupt Mask Register.
  631. */
  632. typedef union DAC960_BA_InterruptMaskRegister
  633. {
  634.   unsigned char All;
  635.   struct {
  636.     unsigned int :2; /* Bits 0-1 */
  637.     boolean DisableInterrupts:1; /* Bit 2 */
  638.     boolean DisableInterruptsI2O:1; /* Bit 3 */
  639.     unsigned int :4; /* Bits 4-7 */
  640.   } Bits;
  641. }
  642. DAC960_BA_InterruptMaskRegister_T;
  643. /*
  644.   Define the structure of the DAC960 BA Series Error Status Register.
  645. */
  646. typedef union DAC960_BA_ErrorStatusRegister
  647. {
  648.   unsigned char All;
  649.   struct {
  650.     unsigned int :2; /* Bits 0-1 */
  651.     boolean ErrorStatusPending:1; /* Bit 2 */
  652.     unsigned int :5; /* Bits 3-7 */
  653.   } Bits;
  654. }
  655. DAC960_BA_ErrorStatusRegister_T;
  656. /*
  657.   Define inline functions to provide an abstraction for reading and writing the
  658.   DAC960 BA Series Controller Interface Registers.
  659. */
  660. static inline
  661. void DAC960_BA_HardwareMailboxNewCommand(void __iomem *ControllerBaseAddress)
  662. {
  663.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  664.   InboundDoorBellRegister.All = 0;
  665.   InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  666.   writeb(InboundDoorBellRegister.All,
  667.  ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  668. }
  669. static inline
  670. void DAC960_BA_AcknowledgeHardwareMailboxStatus(void __iomem *ControllerBaseAddress)
  671. {
  672.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  673.   InboundDoorBellRegister.All = 0;
  674.   InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  675.   writeb(InboundDoorBellRegister.All,
  676.  ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  677. }
  678. static inline
  679. void DAC960_BA_GenerateInterrupt(void __iomem *ControllerBaseAddress)
  680. {
  681.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  682.   InboundDoorBellRegister.All = 0;
  683.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  684.   writeb(InboundDoorBellRegister.All,
  685.  ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  686. }
  687. static inline
  688. void DAC960_BA_ControllerReset(void __iomem *ControllerBaseAddress)
  689. {
  690.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  691.   InboundDoorBellRegister.All = 0;
  692.   InboundDoorBellRegister.Write.ControllerReset = true;
  693.   writeb(InboundDoorBellRegister.All,
  694.  ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  695. }
  696. static inline
  697. void DAC960_BA_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
  698. {
  699.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  700.   InboundDoorBellRegister.All = 0;
  701.   InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  702.   writeb(InboundDoorBellRegister.All,
  703.  ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  704. }
  705. static inline
  706. boolean DAC960_BA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
  707. {
  708.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  709.   InboundDoorBellRegister.All =
  710.     readb(ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  711.   return !InboundDoorBellRegister.Read.HardwareMailboxEmpty;
  712. }
  713. static inline
  714. boolean DAC960_BA_InitializationInProgressP(void __iomem *ControllerBaseAddress)
  715. {
  716.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  717.   InboundDoorBellRegister.All =
  718.     readb(ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  719.   return !InboundDoorBellRegister.Read.InitializationNotInProgress;
  720. }
  721. static inline
  722. void DAC960_BA_AcknowledgeHardwareMailboxInterrupt(void __iomem *ControllerBaseAddress)
  723. {
  724.   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  725.   OutboundDoorBellRegister.All = 0;
  726.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  727.   writeb(OutboundDoorBellRegister.All,
  728.  ControllerBaseAddress + DAC960_BA_OutboundDoorBellRegisterOffset);
  729. }
  730. static inline
  731. void DAC960_BA_AcknowledgeMemoryMailboxInterrupt(void __iomem *ControllerBaseAddress)
  732. {
  733.   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  734.   OutboundDoorBellRegister.All = 0;
  735.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  736.   writeb(OutboundDoorBellRegister.All,
  737.  ControllerBaseAddress + DAC960_BA_OutboundDoorBellRegisterOffset);
  738. }
  739. static inline
  740. void DAC960_BA_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
  741. {
  742.   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  743.   OutboundDoorBellRegister.All = 0;
  744.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  745.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  746.   writeb(OutboundDoorBellRegister.All,
  747.  ControllerBaseAddress + DAC960_BA_OutboundDoorBellRegisterOffset);
  748. }
  749. static inline
  750. boolean DAC960_BA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
  751. {
  752.   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  753.   OutboundDoorBellRegister.All =
  754.     readb(ControllerBaseAddress + DAC960_BA_OutboundDoorBellRegisterOffset);
  755.   return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
  756. }
  757. static inline
  758. boolean DAC960_BA_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
  759. {
  760.   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  761.   OutboundDoorBellRegister.All =
  762.     readb(ControllerBaseAddress + DAC960_BA_OutboundDoorBellRegisterOffset);
  763.   return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
  764. }
  765. static inline
  766. void DAC960_BA_EnableInterrupts(void __iomem *ControllerBaseAddress)
  767. {
  768.   DAC960_BA_InterruptMaskRegister_T InterruptMaskRegister;
  769.   InterruptMaskRegister.All = 0xFF;
  770.   InterruptMaskRegister.Bits.DisableInterrupts = false;
  771.   InterruptMaskRegister.Bits.DisableInterruptsI2O = true;
  772.   writeb(InterruptMaskRegister.All,
  773.  ControllerBaseAddress + DAC960_BA_InterruptMaskRegisterOffset);
  774. }
  775. static inline
  776. void DAC960_BA_DisableInterrupts(void __iomem *ControllerBaseAddress)
  777. {
  778.   DAC960_BA_InterruptMaskRegister_T InterruptMaskRegister;
  779.   InterruptMaskRegister.All = 0xFF;
  780.   InterruptMaskRegister.Bits.DisableInterrupts = true;
  781.   InterruptMaskRegister.Bits.DisableInterruptsI2O = true;
  782.   writeb(InterruptMaskRegister.All,
  783.  ControllerBaseAddress + DAC960_BA_InterruptMaskRegisterOffset);
  784. }
  785. static inline
  786. boolean DAC960_BA_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
  787. {
  788.   DAC960_BA_InterruptMaskRegister_T InterruptMaskRegister;
  789.   InterruptMaskRegister.All =
  790.     readb(ControllerBaseAddress + DAC960_BA_InterruptMaskRegisterOffset);
  791.   return !InterruptMaskRegister.Bits.DisableInterrupts;
  792. }
  793. static inline
  794. void DAC960_BA_WriteCommandMailbox(DAC960_V2_CommandMailbox_T
  795.      *MemoryCommandMailbox,
  796.    DAC960_V2_CommandMailbox_T
  797.      *CommandMailbox)
  798. {
  799.   memcpy(&MemoryCommandMailbox->Words[1], &CommandMailbox->Words[1],
  800.  sizeof(DAC960_V2_CommandMailbox_T) - sizeof(unsigned int));
  801.   wmb();
  802.   MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
  803.   mb();
  804. }
  805. static inline
  806. void DAC960_BA_WriteHardwareMailbox(void __iomem *ControllerBaseAddress,
  807.     dma_addr_t CommandMailboxDMA)
  808. {
  809. dma_addr_writeql(CommandMailboxDMA,
  810. ControllerBaseAddress +
  811. DAC960_BA_CommandMailboxBusAddressOffset);
  812. }
  813. static inline DAC960_V2_CommandIdentifier_T
  814. DAC960_BA_ReadCommandIdentifier(void __iomem *ControllerBaseAddress)
  815. {
  816.   return readw(ControllerBaseAddress + DAC960_BA_CommandStatusOffset);
  817. }
  818. static inline DAC960_V2_CommandStatus_T
  819. DAC960_BA_ReadCommandStatus(void __iomem *ControllerBaseAddress)
  820. {
  821.   return readw(ControllerBaseAddress + DAC960_BA_CommandStatusOffset + 2);
  822. }
  823. static inline boolean
  824. DAC960_BA_ReadErrorStatus(void __iomem *ControllerBaseAddress,
  825.   unsigned char *ErrorStatus,
  826.   unsigned char *Parameter0,
  827.   unsigned char *Parameter1)
  828. {
  829.   DAC960_BA_ErrorStatusRegister_T ErrorStatusRegister;
  830.   ErrorStatusRegister.All =
  831.     readb(ControllerBaseAddress + DAC960_BA_ErrorStatusRegisterOffset);
  832.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  833.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  834.   *ErrorStatus = ErrorStatusRegister.All;
  835.   *Parameter0 =
  836.     readb(ControllerBaseAddress + DAC960_BA_CommandMailboxBusAddressOffset + 0);
  837.   *Parameter1 =
  838.     readb(ControllerBaseAddress + DAC960_BA_CommandMailboxBusAddressOffset + 1);
  839.   writeb(0xFF, ControllerBaseAddress + DAC960_BA_ErrorStatusRegisterOffset);
  840.   return true;
  841. }
  842. /*
  843.   Define the DAC960 LP Series Controller Interface Register Offsets.
  844. */
  845. #define DAC960_LP_RegisterWindowSize 0x80
  846. typedef enum
  847. {
  848.   DAC960_LP_InboundDoorBellRegisterOffset = 0x20,
  849.   DAC960_LP_OutboundDoorBellRegisterOffset = 0x2C,
  850.   DAC960_LP_InterruptStatusRegisterOffset = 0x30,
  851.   DAC960_LP_InterruptMaskRegisterOffset = 0x34,
  852.   DAC960_LP_CommandMailboxBusAddressOffset = 0x10,
  853.   DAC960_LP_CommandStatusOffset = 0x18,
  854.   DAC960_LP_ErrorStatusRegisterOffset = 0x2E
  855. }
  856. DAC960_LP_RegisterOffsets_T;
  857. /*
  858.   Define the structure of the DAC960 LP Series Inbound Door Bell Register.
  859. */
  860. typedef union DAC960_LP_InboundDoorBellRegister
  861. {
  862.   unsigned char All;
  863.   struct {
  864.     boolean HardwareMailboxNewCommand:1; /* Bit 0 */
  865.     boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
  866.     boolean GenerateInterrupt:1; /* Bit 2 */
  867.     boolean ControllerReset:1; /* Bit 3 */
  868.     boolean MemoryMailboxNewCommand:1; /* Bit 4 */
  869.     unsigned char :3; /* Bits 5-7 */
  870.   } Write;
  871.   struct {
  872.     boolean HardwareMailboxFull:1; /* Bit 0 */
  873.     boolean InitializationInProgress:1; /* Bit 1 */
  874.     unsigned char :6; /* Bits 2-7 */
  875.   } Read;
  876. }
  877. DAC960_LP_InboundDoorBellRegister_T;
  878. /*
  879.   Define the structure of the DAC960 LP Series Outbound Door Bell Register.
  880. */
  881. typedef union DAC960_LP_OutboundDoorBellRegister
  882. {
  883.   unsigned char All;
  884.   struct {
  885.     boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
  886.     boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
  887.     unsigned char :6; /* Bits 2-7 */
  888.   } Write;
  889.   struct {
  890.     boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */
  891.     boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */
  892.     unsigned char :6; /* Bits 2-7 */
  893.   } Read;
  894. }
  895. DAC960_LP_OutboundDoorBellRegister_T;
  896. /*
  897.   Define the structure of the DAC960 LP Series Interrupt Mask Register.
  898. */
  899. typedef union DAC960_LP_InterruptMaskRegister
  900. {
  901.   unsigned char All;
  902.   struct {
  903.     unsigned int :2; /* Bits 0-1 */
  904.     boolean DisableInterrupts:1; /* Bit 2 */
  905.     unsigned int :5; /* Bits 3-7 */
  906.   } Bits;
  907. }
  908. DAC960_LP_InterruptMaskRegister_T;
  909. /*
  910.   Define the structure of the DAC960 LP Series Error Status Register.
  911. */
  912. typedef union DAC960_LP_ErrorStatusRegister
  913. {
  914.   unsigned char All;
  915.   struct {
  916.     unsigned int :2; /* Bits 0-1 */
  917.     boolean ErrorStatusPending:1; /* Bit 2 */
  918.     unsigned int :5; /* Bits 3-7 */
  919.   } Bits;
  920. }
  921. DAC960_LP_ErrorStatusRegister_T;
  922. /*
  923.   Define inline functions to provide an abstraction for reading and writing the
  924.   DAC960 LP Series Controller Interface Registers.
  925. */
  926. static inline
  927. void DAC960_LP_HardwareMailboxNewCommand(void __iomem *ControllerBaseAddress)
  928. {
  929.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  930.   InboundDoorBellRegister.All = 0;
  931.   InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  932.   writeb(InboundDoorBellRegister.All,
  933.  ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  934. }
  935. static inline
  936. void DAC960_LP_AcknowledgeHardwareMailboxStatus(void __iomem *ControllerBaseAddress)
  937. {
  938.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  939.   InboundDoorBellRegister.All = 0;
  940.   InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  941.   writeb(InboundDoorBellRegister.All,
  942.  ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  943. }
  944. static inline
  945. void DAC960_LP_GenerateInterrupt(void __iomem *ControllerBaseAddress)
  946. {
  947.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  948.   InboundDoorBellRegister.All = 0;
  949.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  950.   writeb(InboundDoorBellRegister.All,
  951.  ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  952. }
  953. static inline
  954. void DAC960_LP_ControllerReset(void __iomem *ControllerBaseAddress)
  955. {
  956.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  957.   InboundDoorBellRegister.All = 0;
  958.   InboundDoorBellRegister.Write.ControllerReset = true;
  959.   writeb(InboundDoorBellRegister.All,
  960.  ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  961. }
  962. static inline
  963. void DAC960_LP_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
  964. {
  965.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  966.   InboundDoorBellRegister.All = 0;
  967.   InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  968.   writeb(InboundDoorBellRegister.All,
  969.  ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  970. }
  971. static inline
  972. boolean DAC960_LP_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
  973. {
  974.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  975.   InboundDoorBellRegister.All =
  976.     readb(ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  977.   return InboundDoorBellRegister.Read.HardwareMailboxFull;
  978. }
  979. static inline
  980. boolean DAC960_LP_InitializationInProgressP(void __iomem *ControllerBaseAddress)
  981. {
  982.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  983.   InboundDoorBellRegister.All =
  984.     readb(ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  985.   return InboundDoorBellRegister.Read.InitializationInProgress;
  986. }
  987. static inline
  988. void DAC960_LP_AcknowledgeHardwareMailboxInterrupt(void __iomem *ControllerBaseAddress)
  989. {
  990.   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  991.   OutboundDoorBellRegister.All = 0;
  992.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  993.   writeb(OutboundDoorBellRegister.All,
  994.  ControllerBaseAddress + DAC960_LP_OutboundDoorBellRegisterOffset);
  995. }
  996. static inline
  997. void DAC960_LP_AcknowledgeMemoryMailboxInterrupt(void __iomem *ControllerBaseAddress)
  998. {
  999.   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1000.   OutboundDoorBellRegister.All = 0;
  1001.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  1002.   writeb(OutboundDoorBellRegister.All,
  1003.  ControllerBaseAddress + DAC960_LP_OutboundDoorBellRegisterOffset);
  1004. }
  1005. static inline
  1006. void DAC960_LP_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
  1007. {
  1008.   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1009.   OutboundDoorBellRegister.All = 0;
  1010.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  1011.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  1012.   writeb(OutboundDoorBellRegister.All,
  1013.  ControllerBaseAddress + DAC960_LP_OutboundDoorBellRegisterOffset);
  1014. }
  1015. static inline
  1016. boolean DAC960_LP_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
  1017. {
  1018.   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1019.   OutboundDoorBellRegister.All =
  1020.     readb(ControllerBaseAddress + DAC960_LP_OutboundDoorBellRegisterOffset);
  1021.   return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
  1022. }
  1023. static inline
  1024. boolean DAC960_LP_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
  1025. {
  1026.   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1027.   OutboundDoorBellRegister.All =
  1028.     readb(ControllerBaseAddress + DAC960_LP_OutboundDoorBellRegisterOffset);
  1029.   return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
  1030. }
  1031. static inline
  1032. void DAC960_LP_EnableInterrupts(void __iomem *ControllerBaseAddress)
  1033. {
  1034.   DAC960_LP_InterruptMaskRegister_T InterruptMaskRegister;
  1035.   InterruptMaskRegister.All = 0xFF;
  1036.   InterruptMaskRegister.Bits.DisableInterrupts = false;
  1037.   writeb(InterruptMaskRegister.All,
  1038.  ControllerBaseAddress + DAC960_LP_InterruptMaskRegisterOffset);
  1039. }
  1040. static inline
  1041. void DAC960_LP_DisableInterrupts(void __iomem *ControllerBaseAddress)
  1042. {
  1043.   DAC960_LP_InterruptMaskRegister_T InterruptMaskRegister;
  1044.   InterruptMaskRegister.All = 0xFF;
  1045.   InterruptMaskRegister.Bits.DisableInterrupts = true;
  1046.   writeb(InterruptMaskRegister.All,
  1047.  ControllerBaseAddress + DAC960_LP_InterruptMaskRegisterOffset);
  1048. }
  1049. static inline
  1050. boolean DAC960_LP_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
  1051. {
  1052.   DAC960_LP_InterruptMaskRegister_T InterruptMaskRegister;
  1053.   InterruptMaskRegister.All =
  1054.     readb(ControllerBaseAddress + DAC960_LP_InterruptMaskRegisterOffset);
  1055.   return !InterruptMaskRegister.Bits.DisableInterrupts;
  1056. }
  1057. static inline
  1058. void DAC960_LP_WriteCommandMailbox(DAC960_V2_CommandMailbox_T
  1059.      *MemoryCommandMailbox,
  1060.    DAC960_V2_CommandMailbox_T
  1061.      *CommandMailbox)
  1062. {
  1063.   memcpy(&MemoryCommandMailbox->Words[1], &CommandMailbox->Words[1],
  1064.  sizeof(DAC960_V2_CommandMailbox_T) - sizeof(unsigned int));
  1065.   wmb();
  1066.   MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
  1067.   mb();
  1068. }
  1069. static inline
  1070. void DAC960_LP_WriteHardwareMailbox(void __iomem *ControllerBaseAddress,
  1071.     dma_addr_t CommandMailboxDMA)
  1072. {
  1073. dma_addr_writeql(CommandMailboxDMA,
  1074. ControllerBaseAddress +
  1075. DAC960_LP_CommandMailboxBusAddressOffset);
  1076. }
  1077. static inline DAC960_V2_CommandIdentifier_T
  1078. DAC960_LP_ReadCommandIdentifier(void __iomem *ControllerBaseAddress)
  1079. {
  1080.   return readw(ControllerBaseAddress + DAC960_LP_CommandStatusOffset);
  1081. }
  1082. static inline DAC960_V2_CommandStatus_T
  1083. DAC960_LP_ReadCommandStatus(void __iomem *ControllerBaseAddress)
  1084. {
  1085.   return readw(ControllerBaseAddress + DAC960_LP_CommandStatusOffset + 2);
  1086. }
  1087. static inline boolean
  1088. DAC960_LP_ReadErrorStatus(void __iomem *ControllerBaseAddress,
  1089.   unsigned char *ErrorStatus,
  1090.   unsigned char *Parameter0,
  1091.   unsigned char *Parameter1)
  1092. {
  1093.   DAC960_LP_ErrorStatusRegister_T ErrorStatusRegister;
  1094.   ErrorStatusRegister.All =
  1095.     readb(ControllerBaseAddress + DAC960_LP_ErrorStatusRegisterOffset);
  1096.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  1097.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  1098.   *ErrorStatus = ErrorStatusRegister.All;
  1099.   *Parameter0 =
  1100.     readb(ControllerBaseAddress + DAC960_LP_CommandMailboxBusAddressOffset + 0);
  1101.   *Parameter1 =
  1102.     readb(ControllerBaseAddress + DAC960_LP_CommandMailboxBusAddressOffset + 1);
  1103.   writeb(0xFF, ControllerBaseAddress + DAC960_LP_ErrorStatusRegisterOffset);
  1104.   return true;
  1105. }
  1106. /*
  1107.   Define the DAC960 LA Series Controller Interface Register Offsets.
  1108. */
  1109. #define DAC960_LA_RegisterWindowSize 0x80
  1110. typedef enum
  1111. {
  1112.   DAC960_LA_InboundDoorBellRegisterOffset = 0x60,
  1113.   DAC960_LA_OutboundDoorBellRegisterOffset = 0x61,
  1114.   DAC960_LA_InterruptMaskRegisterOffset = 0x34,
  1115.   DAC960_LA_CommandOpcodeRegisterOffset = 0x50,
  1116.   DAC960_LA_CommandIdentifierRegisterOffset = 0x51,
  1117.   DAC960_LA_MailboxRegister2Offset = 0x52,
  1118.   DAC960_LA_MailboxRegister3Offset = 0x53,
  1119.   DAC960_LA_MailboxRegister4Offset = 0x54,
  1120.   DAC960_LA_MailboxRegister5Offset = 0x55,
  1121.   DAC960_LA_MailboxRegister6Offset = 0x56,
  1122.   DAC960_LA_MailboxRegister7Offset = 0x57,
  1123.   DAC960_LA_MailboxRegister8Offset = 0x58,
  1124.   DAC960_LA_MailboxRegister9Offset = 0x59,
  1125.   DAC960_LA_MailboxRegister10Offset = 0x5A,
  1126.   DAC960_LA_MailboxRegister11Offset = 0x5B,
  1127.   DAC960_LA_MailboxRegister12Offset = 0x5C,
  1128.   DAC960_LA_StatusCommandIdentifierRegOffset = 0x5D,
  1129.   DAC960_LA_StatusRegisterOffset = 0x5E,
  1130.   DAC960_LA_ErrorStatusRegisterOffset = 0x63
  1131. }
  1132. DAC960_LA_RegisterOffsets_T;
  1133. /*
  1134.   Define the structure of the DAC960 LA Series Inbound Door Bell Register.
  1135. */
  1136. typedef union DAC960_LA_InboundDoorBellRegister
  1137. {
  1138.   unsigned char All;
  1139.   struct {
  1140.     boolean HardwareMailboxNewCommand:1; /* Bit 0 */
  1141.     boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
  1142.     boolean GenerateInterrupt:1; /* Bit 2 */
  1143.     boolean ControllerReset:1; /* Bit 3 */
  1144.     boolean MemoryMailboxNewCommand:1; /* Bit 4 */
  1145.     unsigned char :3; /* Bits 5-7 */
  1146.   } Write;
  1147.   struct {
  1148.     boolean HardwareMailboxEmpty:1; /* Bit 0 */
  1149.     boolean InitializationNotInProgress:1; /* Bit 1 */
  1150.     unsigned char :6; /* Bits 2-7 */
  1151.   } Read;
  1152. }
  1153. DAC960_LA_InboundDoorBellRegister_T;
  1154. /*
  1155.   Define the structure of the DAC960 LA Series Outbound Door Bell Register.
  1156. */
  1157. typedef union DAC960_LA_OutboundDoorBellRegister
  1158. {
  1159.   unsigned char All;
  1160.   struct {
  1161.     boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
  1162.     boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
  1163.     unsigned char :6; /* Bits 2-7 */
  1164.   } Write;
  1165.   struct {
  1166.     boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */
  1167.     boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */
  1168.     unsigned char :6; /* Bits 2-7 */
  1169.   } Read;
  1170. }
  1171. DAC960_LA_OutboundDoorBellRegister_T;
  1172. /*
  1173.   Define the structure of the DAC960 LA Series Interrupt Mask Register.
  1174. */
  1175. typedef union DAC960_LA_InterruptMaskRegister
  1176. {
  1177.   unsigned char All;
  1178.   struct {
  1179.     unsigned char :2; /* Bits 0-1 */
  1180.     boolean DisableInterrupts:1; /* Bit 2 */
  1181.     unsigned char :5; /* Bits 3-7 */
  1182.   } Bits;
  1183. }
  1184. DAC960_LA_InterruptMaskRegister_T;
  1185. /*
  1186.   Define the structure of the DAC960 LA Series Error Status Register.
  1187. */
  1188. typedef union DAC960_LA_ErrorStatusRegister
  1189. {
  1190.   unsigned char All;
  1191.   struct {
  1192.     unsigned int :2; /* Bits 0-1 */
  1193.     boolean ErrorStatusPending:1; /* Bit 2 */
  1194.     unsigned int :5; /* Bits 3-7 */
  1195.   } Bits;
  1196. }
  1197. DAC960_LA_ErrorStatusRegister_T;
  1198. /*
  1199.   Define inline functions to provide an abstraction for reading and writing the
  1200.   DAC960 LA Series Controller Interface Registers.
  1201. */
  1202. static inline
  1203. void DAC960_LA_HardwareMailboxNewCommand(void __iomem *ControllerBaseAddress)
  1204. {
  1205.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1206.   InboundDoorBellRegister.All = 0;
  1207.   InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  1208.   writeb(InboundDoorBellRegister.All,
  1209.  ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1210. }
  1211. static inline
  1212. void DAC960_LA_AcknowledgeHardwareMailboxStatus(void __iomem *ControllerBaseAddress)
  1213. {
  1214.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1215.   InboundDoorBellRegister.All = 0;
  1216.   InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  1217.   writeb(InboundDoorBellRegister.All,
  1218.  ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1219. }
  1220. static inline
  1221. void DAC960_LA_GenerateInterrupt(void __iomem *ControllerBaseAddress)
  1222. {
  1223.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1224.   InboundDoorBellRegister.All = 0;
  1225.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  1226.   writeb(InboundDoorBellRegister.All,
  1227.  ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1228. }
  1229. static inline
  1230. void DAC960_LA_ControllerReset(void __iomem *ControllerBaseAddress)
  1231. {
  1232.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1233.   InboundDoorBellRegister.All = 0;
  1234.   InboundDoorBellRegister.Write.ControllerReset = true;
  1235.   writeb(InboundDoorBellRegister.All,
  1236.  ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1237. }
  1238. static inline
  1239. void DAC960_LA_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
  1240. {
  1241.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1242.   InboundDoorBellRegister.All = 0;
  1243.   InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  1244.   writeb(InboundDoorBellRegister.All,
  1245.  ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1246. }
  1247. static inline
  1248. boolean DAC960_LA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
  1249. {
  1250.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1251.   InboundDoorBellRegister.All =
  1252.     readb(ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1253.   return !InboundDoorBellRegister.Read.HardwareMailboxEmpty;
  1254. }
  1255. static inline
  1256. boolean DAC960_LA_InitializationInProgressP(void __iomem *ControllerBaseAddress)
  1257. {
  1258.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1259.   InboundDoorBellRegister.All =
  1260.     readb(ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1261.   return !InboundDoorBellRegister.Read.InitializationNotInProgress;
  1262. }
  1263. static inline
  1264. void DAC960_LA_AcknowledgeHardwareMailboxInterrupt(void __iomem *ControllerBaseAddress)
  1265. {
  1266.   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1267.   OutboundDoorBellRegister.All = 0;
  1268.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  1269.   writeb(OutboundDoorBellRegister.All,
  1270.  ControllerBaseAddress + DAC960_LA_OutboundDoorBellRegisterOffset);
  1271. }
  1272. static inline
  1273. void DAC960_LA_AcknowledgeMemoryMailboxInterrupt(void __iomem *ControllerBaseAddress)
  1274. {
  1275.   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1276.   OutboundDoorBellRegister.All = 0;
  1277.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  1278.   writeb(OutboundDoorBellRegister.All,
  1279.  ControllerBaseAddress + DAC960_LA_OutboundDoorBellRegisterOffset);
  1280. }
  1281. static inline
  1282. void DAC960_LA_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
  1283. {
  1284.   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1285.   OutboundDoorBellRegister.All = 0;
  1286.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  1287.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  1288.   writeb(OutboundDoorBellRegister.All,
  1289.  ControllerBaseAddress + DAC960_LA_OutboundDoorBellRegisterOffset);
  1290. }
  1291. static inline
  1292. boolean DAC960_LA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
  1293. {
  1294.   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1295.   OutboundDoorBellRegister.All =
  1296.     readb(ControllerBaseAddress + DAC960_LA_OutboundDoorBellRegisterOffset);
  1297.   return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
  1298. }
  1299. static inline
  1300. boolean DAC960_LA_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
  1301. {
  1302.   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1303.   OutboundDoorBellRegister.All =
  1304.     readb(ControllerBaseAddress + DAC960_LA_OutboundDoorBellRegisterOffset);
  1305.   return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
  1306. }
  1307. static inline
  1308. void DAC960_LA_EnableInterrupts(void __iomem *ControllerBaseAddress)
  1309. {
  1310.   DAC960_LA_InterruptMaskRegister_T InterruptMaskRegister;
  1311.   InterruptMaskRegister.All = 0xFF;
  1312.   InterruptMaskRegister.Bits.DisableInterrupts = false;
  1313.   writeb(InterruptMaskRegister.All,
  1314.  ControllerBaseAddress + DAC960_LA_InterruptMaskRegisterOffset);
  1315. }
  1316. static inline
  1317. void DAC960_LA_DisableInterrupts(void __iomem *ControllerBaseAddress)
  1318. {
  1319.   DAC960_LA_InterruptMaskRegister_T InterruptMaskRegister;
  1320.   InterruptMaskRegister.All = 0xFF;
  1321.   InterruptMaskRegister.Bits.DisableInterrupts = true;
  1322.   writeb(InterruptMaskRegister.All,
  1323.  ControllerBaseAddress + DAC960_LA_InterruptMaskRegisterOffset);
  1324. }
  1325. static inline
  1326. boolean DAC960_LA_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
  1327. {
  1328.   DAC960_LA_InterruptMaskRegister_T InterruptMaskRegister;
  1329.   InterruptMaskRegister.All =
  1330.     readb(ControllerBaseAddress + DAC960_LA_InterruptMaskRegisterOffset);
  1331.   return !InterruptMaskRegister.Bits.DisableInterrupts;
  1332. }
  1333. static inline
  1334. void DAC960_LA_WriteCommandMailbox(DAC960_V1_CommandMailbox_T
  1335.      *MemoryCommandMailbox,
  1336.    DAC960_V1_CommandMailbox_T
  1337.      *CommandMailbox)
  1338. {
  1339.   MemoryCommandMailbox->Words[1] = CommandMailbox->Words[1];
  1340.   MemoryCommandMailbox->Words[2] = CommandMailbox->Words[2];
  1341.   MemoryCommandMailbox->Words[3] = CommandMailbox->Words[3];
  1342.   wmb();
  1343.   MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
  1344.   mb();
  1345. }
  1346. static inline
  1347. void DAC960_LA_WriteHardwareMailbox(void __iomem *ControllerBaseAddress,
  1348.     DAC960_V1_CommandMailbox_T *CommandMailbox)
  1349. {
  1350.   writel(CommandMailbox->Words[0],
  1351.  ControllerBaseAddress + DAC960_LA_CommandOpcodeRegisterOffset);
  1352.   writel(CommandMailbox->Words[1],
  1353.  ControllerBaseAddress + DAC960_LA_MailboxRegister4Offset);
  1354.   writel(CommandMailbox->Words[2],
  1355.  ControllerBaseAddress + DAC960_LA_MailboxRegister8Offset);
  1356.   writeb(CommandMailbox->Bytes[12],
  1357.  ControllerBaseAddress + DAC960_LA_MailboxRegister12Offset);
  1358. }
  1359. static inline DAC960_V1_CommandIdentifier_T
  1360. DAC960_LA_ReadStatusCommandIdentifier(void __iomem *ControllerBaseAddress)
  1361. {
  1362.   return readb(ControllerBaseAddress
  1363.        + DAC960_LA_StatusCommandIdentifierRegOffset);
  1364. }
  1365. static inline DAC960_V1_CommandStatus_T
  1366. DAC960_LA_ReadStatusRegister(void __iomem *ControllerBaseAddress)
  1367. {
  1368.   return readw(ControllerBaseAddress + DAC960_LA_StatusRegisterOffset);
  1369. }
  1370. static inline boolean
  1371. DAC960_LA_ReadErrorStatus(void __iomem *ControllerBaseAddress,
  1372.   unsigned char *ErrorStatus,
  1373.   unsigned char *Parameter0,
  1374.   unsigned char *Parameter1)
  1375. {
  1376.   DAC960_LA_ErrorStatusRegister_T ErrorStatusRegister;
  1377.   ErrorStatusRegister.All =
  1378.     readb(ControllerBaseAddress + DAC960_LA_ErrorStatusRegisterOffset);
  1379.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  1380.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  1381.   *ErrorStatus = ErrorStatusRegister.All;
  1382.   *Parameter0 =
  1383.     readb(ControllerBaseAddress + DAC960_LA_CommandOpcodeRegisterOffset);
  1384.   *Parameter1 =
  1385.     readb(ControllerBaseAddress + DAC960_LA_CommandIdentifierRegisterOffset);
  1386.   writeb(0xFF, ControllerBaseAddress + DAC960_LA_ErrorStatusRegisterOffset);
  1387.   return true;
  1388. }
  1389. /*
  1390.   Define the DAC960 PG Series Controller Interface Register Offsets.
  1391. */
  1392. #define DAC960_PG_RegisterWindowSize 0x2000
  1393. typedef enum
  1394. {
  1395.   DAC960_PG_InboundDoorBellRegisterOffset = 0x0020,
  1396.   DAC960_PG_OutboundDoorBellRegisterOffset = 0x002C,
  1397.   DAC960_PG_InterruptMaskRegisterOffset = 0x0034,
  1398.   DAC960_PG_CommandOpcodeRegisterOffset = 0x1000,
  1399.   DAC960_PG_CommandIdentifierRegisterOffset = 0x1001,
  1400.   DAC960_PG_MailboxRegister2Offset = 0x1002,
  1401.   DAC960_PG_MailboxRegister3Offset = 0x1003,
  1402.   DAC960_PG_MailboxRegister4Offset = 0x1004,
  1403.   DAC960_PG_MailboxRegister5Offset = 0x1005,
  1404.   DAC960_PG_MailboxRegister6Offset = 0x1006,
  1405.   DAC960_PG_MailboxRegister7Offset = 0x1007,
  1406.   DAC960_PG_MailboxRegister8Offset = 0x1008,
  1407.   DAC960_PG_MailboxRegister9Offset = 0x1009,
  1408.   DAC960_PG_MailboxRegister10Offset = 0x100A,
  1409.   DAC960_PG_MailboxRegister11Offset = 0x100B,
  1410.   DAC960_PG_MailboxRegister12Offset = 0x100C,
  1411.   DAC960_PG_StatusCommandIdentifierRegOffset = 0x1018,
  1412.   DAC960_PG_StatusRegisterOffset = 0x101A,
  1413.   DAC960_PG_ErrorStatusRegisterOffset = 0x103F
  1414. }
  1415. DAC960_PG_RegisterOffsets_T;
  1416. /*
  1417.   Define the structure of the DAC960 PG Series Inbound Door Bell Register.
  1418. */
  1419. typedef union DAC960_PG_InboundDoorBellRegister
  1420. {
  1421.   unsigned int All;
  1422.   struct {
  1423.     boolean HardwareMailboxNewCommand:1; /* Bit 0 */
  1424.     boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
  1425.     boolean GenerateInterrupt:1; /* Bit 2 */
  1426.     boolean ControllerReset:1; /* Bit 3 */
  1427.     boolean MemoryMailboxNewCommand:1; /* Bit 4 */
  1428.     unsigned int :27; /* Bits 5-31 */
  1429.   } Write;
  1430.   struct {
  1431.     boolean HardwareMailboxFull:1; /* Bit 0 */
  1432.     boolean InitializationInProgress:1; /* Bit 1 */
  1433.     unsigned int :30; /* Bits 2-31 */
  1434.   } Read;
  1435. }
  1436. DAC960_PG_InboundDoorBellRegister_T;
  1437. /*
  1438.   Define the structure of the DAC960 PG Series Outbound Door Bell Register.
  1439. */
  1440. typedef union DAC960_PG_OutboundDoorBellRegister
  1441. {
  1442.   unsigned int All;
  1443.   struct {
  1444.     boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
  1445.     boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
  1446.     unsigned int :30; /* Bits 2-31 */
  1447.   } Write;
  1448.   struct {
  1449.     boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */
  1450.     boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */
  1451.     unsigned int :30; /* Bits 2-31 */
  1452.   } Read;
  1453. }
  1454. DAC960_PG_OutboundDoorBellRegister_T;
  1455. /*
  1456.   Define the structure of the DAC960 PG Series Interrupt Mask Register.
  1457. */
  1458. typedef union DAC960_PG_InterruptMaskRegister
  1459. {
  1460.   unsigned int All;
  1461.   struct {
  1462.     unsigned int MessageUnitInterruptMask1:2; /* Bits 0-1 */
  1463.     boolean DisableInterrupts:1; /* Bit 2 */
  1464.     unsigned int MessageUnitInterruptMask2:5; /* Bits 3-7 */
  1465.     unsigned int Reserved0:24; /* Bits 8-31 */
  1466.   } Bits;
  1467. }
  1468. DAC960_PG_InterruptMaskRegister_T;
  1469. /*
  1470.   Define the structure of the DAC960 PG Series Error Status Register.
  1471. */
  1472. typedef union DAC960_PG_ErrorStatusRegister
  1473. {
  1474.   unsigned char All;
  1475.   struct {
  1476.     unsigned int :2; /* Bits 0-1 */
  1477.     boolean ErrorStatusPending:1; /* Bit 2 */
  1478.     unsigned int :5; /* Bits 3-7 */
  1479.   } Bits;
  1480. }
  1481. DAC960_PG_ErrorStatusRegister_T;
  1482. /*
  1483.   Define inline functions to provide an abstraction for reading and writing the
  1484.   DAC960 PG Series Controller Interface Registers.
  1485. */
  1486. static inline
  1487. void DAC960_PG_HardwareMailboxNewCommand(void __iomem *ControllerBaseAddress)
  1488. {
  1489.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1490.   InboundDoorBellRegister.All = 0;
  1491.   InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  1492.   writel(InboundDoorBellRegister.All,
  1493.  ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1494. }
  1495. static inline
  1496. void DAC960_PG_AcknowledgeHardwareMailboxStatus(void __iomem *ControllerBaseAddress)
  1497. {
  1498.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1499.   InboundDoorBellRegister.All = 0;
  1500.   InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  1501.   writel(InboundDoorBellRegister.All,
  1502.  ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1503. }
  1504. static inline
  1505. void DAC960_PG_GenerateInterrupt(void __iomem *ControllerBaseAddress)
  1506. {
  1507.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1508.   InboundDoorBellRegister.All = 0;
  1509.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  1510.   writel(InboundDoorBellRegister.All,
  1511.  ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1512. }
  1513. static inline
  1514. void DAC960_PG_ControllerReset(void __iomem *ControllerBaseAddress)
  1515. {
  1516.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1517.   InboundDoorBellRegister.All = 0;
  1518.   InboundDoorBellRegister.Write.ControllerReset = true;
  1519.   writel(InboundDoorBellRegister.All,
  1520.  ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1521. }
  1522. static inline
  1523. void DAC960_PG_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
  1524. {
  1525.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1526.   InboundDoorBellRegister.All = 0;
  1527.   InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  1528.   writel(InboundDoorBellRegister.All,
  1529.  ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1530. }
  1531. static inline
  1532. boolean DAC960_PG_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
  1533. {
  1534.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1535.   InboundDoorBellRegister.All =
  1536.     readl(ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1537.   return InboundDoorBellRegister.Read.HardwareMailboxFull;
  1538. }
  1539. static inline
  1540. boolean DAC960_PG_InitializationInProgressP(void __iomem *ControllerBaseAddress)
  1541. {
  1542.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1543.   InboundDoorBellRegister.All =
  1544.     readl(ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1545.   return InboundDoorBellRegister.Read.InitializationInProgress;
  1546. }
  1547. static inline
  1548. void DAC960_PG_AcknowledgeHardwareMailboxInterrupt(void __iomem *ControllerBaseAddress)
  1549. {
  1550.   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1551.   OutboundDoorBellRegister.All = 0;
  1552.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  1553.   writel(OutboundDoorBellRegister.All,
  1554.  ControllerBaseAddress + DAC960_PG_OutboundDoorBellRegisterOffset);
  1555. }
  1556. static inline
  1557. void DAC960_PG_AcknowledgeMemoryMailboxInterrupt(void __iomem *ControllerBaseAddress)
  1558. {
  1559.   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1560.   OutboundDoorBellRegister.All = 0;
  1561.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  1562.   writel(OutboundDoorBellRegister.All,
  1563.  ControllerBaseAddress + DAC960_PG_OutboundDoorBellRegisterOffset);
  1564. }
  1565. static inline
  1566. void DAC960_PG_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
  1567. {
  1568.   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1569.   OutboundDoorBellRegister.All = 0;
  1570.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  1571.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  1572.   writel(OutboundDoorBellRegister.All,
  1573.  ControllerBaseAddress + DAC960_PG_OutboundDoorBellRegisterOffset);
  1574. }
  1575. static inline
  1576. boolean DAC960_PG_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
  1577. {
  1578.   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1579.   OutboundDoorBellRegister.All =
  1580.     readl(ControllerBaseAddress + DAC960_PG_OutboundDoorBellRegisterOffset);
  1581.   return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
  1582. }
  1583. static inline
  1584. boolean DAC960_PG_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
  1585. {
  1586.   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1587.   OutboundDoorBellRegister.All =
  1588.     readl(ControllerBaseAddress + DAC960_PG_OutboundDoorBellRegisterOffset);
  1589.   return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
  1590. }
  1591. static inline
  1592. void DAC960_PG_EnableInterrupts(void __iomem *ControllerBaseAddress)
  1593. {
  1594.   DAC960_PG_InterruptMaskRegister_T InterruptMaskRegister;
  1595.   InterruptMaskRegister.All = 0;
  1596.   InterruptMaskRegister.Bits.MessageUnitInterruptMask1 = 0x3;
  1597.   InterruptMaskRegister.Bits.DisableInterrupts = false;
  1598.   InterruptMaskRegister.Bits.MessageUnitInterruptMask2 = 0x1F;
  1599.   writel(InterruptMaskRegister.All,
  1600.  ControllerBaseAddress + DAC960_PG_InterruptMaskRegisterOffset);
  1601. }
  1602. static inline
  1603. void DAC960_PG_DisableInterrupts(void __iomem *ControllerBaseAddress)
  1604. {
  1605.   DAC960_PG_InterruptMaskRegister_T InterruptMaskRegister;
  1606.   InterruptMaskRegister.All = 0;
  1607.   InterruptMaskRegister.Bits.MessageUnitInterruptMask1 = 0x3;
  1608.   InterruptMaskRegister.Bits.DisableInterrupts = true;
  1609.   InterruptMaskRegister.Bits.MessageUnitInterruptMask2 = 0x1F;
  1610.   writel(InterruptMaskRegister.All,
  1611.  ControllerBaseAddress + DAC960_PG_InterruptMaskRegisterOffset);
  1612. }
  1613. static inline
  1614. boolean DAC960_PG_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
  1615. {
  1616.   DAC960_PG_InterruptMaskRegister_T InterruptMaskRegister;
  1617.   InterruptMaskRegister.All =
  1618.     readl(ControllerBaseAddress + DAC960_PG_InterruptMaskRegisterOffset);
  1619.   return !InterruptMaskRegister.Bits.DisableInterrupts;
  1620. }
  1621. static inline
  1622. void DAC960_PG_WriteCommandMailbox(DAC960_V1_CommandMailbox_T
  1623.      *MemoryCommandMailbox,
  1624.    DAC960_V1_CommandMailbox_T
  1625.      *CommandMailbox)
  1626. {
  1627.   MemoryCommandMailbox->Words[1] = CommandMailbox->Words[1];
  1628.   MemoryCommandMailbox->Words[2] = CommandMailbox->Words[2];
  1629.   MemoryCommandMailbox->Words[3] = CommandMailbox->Words[3];
  1630.   wmb();
  1631.   MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
  1632.   mb();
  1633. }
  1634. static inline
  1635. void DAC960_PG_WriteHardwareMailbox(void __iomem *ControllerBaseAddress,
  1636.     DAC960_V1_CommandMailbox_T *CommandMailbox)
  1637. {
  1638.   writel(CommandMailbox->Words[0],
  1639.  ControllerBaseAddress + DAC960_PG_CommandOpcodeRegisterOffset);
  1640.   writel(CommandMailbox->Words[1],
  1641.  ControllerBaseAddress + DAC960_PG_MailboxRegister4Offset);
  1642.   writel(CommandMailbox->Words[2],
  1643.  ControllerBaseAddress + DAC960_PG_MailboxRegister8Offset);
  1644.   writeb(CommandMailbox->Bytes[12],
  1645.  ControllerBaseAddress + DAC960_PG_MailboxRegister12Offset);
  1646. }
  1647. static inline DAC960_V1_CommandIdentifier_T
  1648. DAC960_PG_ReadStatusCommandIdentifier(void __iomem *ControllerBaseAddress)
  1649. {
  1650.   return readb(ControllerBaseAddress
  1651.        + DAC960_PG_StatusCommandIdentifierRegOffset);
  1652. }
  1653. static inline DAC960_V1_CommandStatus_T
  1654. DAC960_PG_ReadStatusRegister(void __iomem *ControllerBaseAddress)
  1655. {
  1656.   return readw(ControllerBaseAddress + DAC960_PG_StatusRegisterOffset);
  1657. }
  1658. static inline boolean
  1659. DAC960_PG_ReadErrorStatus(void __iomem *ControllerBaseAddress,
  1660.   unsigned char *ErrorStatus,
  1661.   unsigned char *Parameter0,
  1662.   unsigned char *Parameter1)
  1663. {
  1664.   DAC960_PG_ErrorStatusRegister_T ErrorStatusRegister;
  1665.   ErrorStatusRegister.All =
  1666.     readb(ControllerBaseAddress + DAC960_PG_ErrorStatusRegisterOffset);
  1667.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  1668.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  1669.   *ErrorStatus = ErrorStatusRegister.All;
  1670.   *Parameter0 =
  1671.     readb(ControllerBaseAddress + DAC960_PG_CommandOpcodeRegisterOffset);
  1672.   *Parameter1 =
  1673.     readb(ControllerBaseAddress + DAC960_PG_CommandIdentifierRegisterOffset);
  1674.   writeb(0, ControllerBaseAddress + DAC960_PG_ErrorStatusRegisterOffset);
  1675.   return true;
  1676. }
  1677. /*
  1678.   Define the DAC960 PD Series Controller Interface Register Offsets.
  1679. */
  1680. #define DAC960_PD_RegisterWindowSize 0x80
  1681. typedef enum
  1682. {
  1683.   DAC960_PD_CommandOpcodeRegisterOffset = 0x00,
  1684.   DAC960_PD_CommandIdentifierRegisterOffset = 0x01,
  1685.   DAC960_PD_MailboxRegister2Offset = 0x02,
  1686.   DAC960_PD_MailboxRegister3Offset = 0x03,
  1687.   DAC960_PD_MailboxRegister4Offset = 0x04,
  1688.   DAC960_PD_MailboxRegister5Offset = 0x05,
  1689.   DAC960_PD_MailboxRegister6Offset = 0x06,
  1690.   DAC960_PD_MailboxRegister7Offset = 0x07,
  1691.   DAC960_PD_MailboxRegister8Offset = 0x08,
  1692.   DAC960_PD_MailboxRegister9Offset = 0x09,
  1693.   DAC960_PD_MailboxRegister10Offset = 0x0A,
  1694.   DAC960_PD_MailboxRegister11Offset = 0x0B,
  1695.   DAC960_PD_MailboxRegister12Offset = 0x0C,
  1696.   DAC960_PD_StatusCommandIdentifierRegOffset = 0x0D,
  1697.   DAC960_PD_StatusRegisterOffset = 0x0E,
  1698.   DAC960_PD_ErrorStatusRegisterOffset = 0x3F,
  1699.   DAC960_PD_InboundDoorBellRegisterOffset = 0x40,
  1700.   DAC960_PD_OutboundDoorBellRegisterOffset = 0x41,
  1701.   DAC960_PD_InterruptEnableRegisterOffset = 0x43
  1702. }
  1703. DAC960_PD_RegisterOffsets_T;
  1704. /*
  1705.   Define the structure of the DAC960 PD Series Inbound Door Bell Register.
  1706. */
  1707. typedef union DAC960_PD_InboundDoorBellRegister
  1708. {
  1709.   unsigned char All;
  1710.   struct {
  1711.     boolean NewCommand:1; /* Bit 0 */
  1712.     boolean AcknowledgeStatus:1; /* Bit 1 */
  1713.     boolean GenerateInterrupt:1; /* Bit 2 */
  1714.     boolean ControllerReset:1; /* Bit 3 */
  1715.     unsigned char :4; /* Bits 4-7 */
  1716.   } Write;
  1717.   struct {
  1718.     boolean MailboxFull:1; /* Bit 0 */
  1719.     boolean InitializationInProgress:1; /* Bit 1 */
  1720.     unsigned char :6; /* Bits 2-7 */
  1721.   } Read;
  1722. }
  1723. DAC960_PD_InboundDoorBellRegister_T;
  1724. /*
  1725.   Define the structure of the DAC960 PD Series Outbound Door Bell Register.
  1726. */
  1727. typedef union DAC960_PD_OutboundDoorBellRegister
  1728. {
  1729.   unsigned char All;
  1730.   struct {
  1731.     boolean AcknowledgeInterrupt:1; /* Bit 0 */
  1732.     unsigned char :7; /* Bits 1-7 */
  1733.   } Write;
  1734.   struct {
  1735.     boolean StatusAvailable:1; /* Bit 0 */
  1736.     unsigned char :7; /* Bits 1-7 */
  1737.   } Read;
  1738. }
  1739. DAC960_PD_OutboundDoorBellRegister_T;
  1740. /*
  1741.   Define the structure of the DAC960 PD Series Interrupt Enable Register.
  1742. */
  1743. typedef union DAC960_PD_InterruptEnableRegister
  1744. {
  1745.   unsigned char All;
  1746.   struct {
  1747.     boolean EnableInterrupts:1; /* Bit 0 */
  1748.     unsigned char :7; /* Bits 1-7 */
  1749.   } Bits;
  1750. }
  1751. DAC960_PD_InterruptEnableRegister_T;
  1752. /*
  1753.   Define the structure of the DAC960 PD Series Error Status Register.
  1754. */
  1755. typedef union DAC960_PD_ErrorStatusRegister
  1756. {
  1757.   unsigned char All;
  1758.   struct {
  1759.     unsigned int :2; /* Bits 0-1 */
  1760.     boolean ErrorStatusPending:1; /* Bit 2 */
  1761.     unsigned int :5; /* Bits 3-7 */
  1762.   } Bits;
  1763. }
  1764. DAC960_PD_ErrorStatusRegister_T;
  1765. /*
  1766.   Define inline functions to provide an abstraction for reading and writing the
  1767.   DAC960 PD Series Controller Interface Registers.
  1768. */
  1769. static inline
  1770. void DAC960_PD_NewCommand(void __iomem *ControllerBaseAddress)
  1771. {
  1772.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1773.   InboundDoorBellRegister.All = 0;
  1774.   InboundDoorBellRegister.Write.NewCommand = true;
  1775.   writeb(InboundDoorBellRegister.All,
  1776.  ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1777. }
  1778. static inline
  1779. void DAC960_PD_AcknowledgeStatus(void __iomem *ControllerBaseAddress)
  1780. {
  1781.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1782.   InboundDoorBellRegister.All = 0;
  1783.   InboundDoorBellRegister.Write.AcknowledgeStatus = true;
  1784.   writeb(InboundDoorBellRegister.All,
  1785.  ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1786. }
  1787. static inline
  1788. void DAC960_PD_GenerateInterrupt(void __iomem *ControllerBaseAddress)
  1789. {
  1790.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1791.   InboundDoorBellRegister.All = 0;
  1792.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  1793.   writeb(InboundDoorBellRegister.All,
  1794.  ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1795. }
  1796. static inline
  1797. void DAC960_PD_ControllerReset(void __iomem *ControllerBaseAddress)
  1798. {
  1799.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1800.   InboundDoorBellRegister.All = 0;
  1801.   InboundDoorBellRegister.Write.ControllerReset = true;
  1802.   writeb(InboundDoorBellRegister.All,
  1803.  ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1804. }
  1805. static inline
  1806. boolean DAC960_PD_MailboxFullP(void __iomem *ControllerBaseAddress)
  1807. {
  1808.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1809.   InboundDoorBellRegister.All =
  1810.     readb(ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1811.   return InboundDoorBellRegister.Read.MailboxFull;
  1812. }
  1813. static inline
  1814. boolean DAC960_PD_InitializationInProgressP(void __iomem *ControllerBaseAddress)
  1815. {
  1816.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1817.   InboundDoorBellRegister.All =
  1818.     readb(ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1819.   return InboundDoorBellRegister.Read.InitializationInProgress;
  1820. }
  1821. static inline
  1822. void DAC960_PD_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
  1823. {
  1824.   DAC960_PD_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1825.   OutboundDoorBellRegister.All = 0;
  1826.   OutboundDoorBellRegister.Write.AcknowledgeInterrupt = true;
  1827.   writeb(OutboundDoorBellRegister.All,
  1828.  ControllerBaseAddress + DAC960_PD_OutboundDoorBellRegisterOffset);
  1829. }
  1830. static inline
  1831. boolean DAC960_PD_StatusAvailableP(void __iomem *ControllerBaseAddress)
  1832. {
  1833.   DAC960_PD_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1834.   OutboundDoorBellRegister.All =
  1835.     readb(ControllerBaseAddress + DAC960_PD_OutboundDoorBellRegisterOffset);
  1836.   return OutboundDoorBellRegister.Read.StatusAvailable;
  1837. }
  1838. static inline
  1839. void DAC960_PD_EnableInterrupts(void __iomem *ControllerBaseAddress)
  1840. {
  1841.   DAC960_PD_InterruptEnableRegister_T InterruptEnableRegister;
  1842.   InterruptEnableRegister.All = 0;
  1843.   InterruptEnableRegister.Bits.EnableInterrupts = true;
  1844.   writeb(InterruptEnableRegister.All,
  1845.  ControllerBaseAddress + DAC960_PD_InterruptEnableRegisterOffset);
  1846. }
  1847. static inline
  1848. void DAC960_PD_DisableInterrupts(void __iomem *ControllerBaseAddress)
  1849. {
  1850.   DAC960_PD_InterruptEnableRegister_T InterruptEnableRegister;
  1851.   InterruptEnableRegister.All = 0;
  1852.   InterruptEnableRegister.Bits.EnableInterrupts = false;
  1853.   writeb(InterruptEnableRegister.All,
  1854.  ControllerBaseAddress + DAC960_PD_InterruptEnableRegisterOffset);
  1855. }
  1856. static inline
  1857. boolean DAC960_PD_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
  1858. {
  1859.   DAC960_PD_InterruptEnableRegister_T InterruptEnableRegister;
  1860.   InterruptEnableRegister.All =
  1861.     readb(ControllerBaseAddress + DAC960_PD_InterruptEnableRegisterOffset);
  1862.   return InterruptEnableRegister.Bits.EnableInterrupts;
  1863. }
  1864. static inline
  1865. void DAC960_PD_WriteCommandMailbox(void __iomem *ControllerBaseAddress,
  1866.    DAC960_V1_CommandMailbox_T *CommandMailbox)
  1867. {
  1868.   writel(CommandMailbox->Words[0],
  1869.  ControllerBaseAddress + DAC960_PD_CommandOpcodeRegisterOffset);
  1870.   writel(CommandMailbox->Words[1],
  1871.  ControllerBaseAddress + DAC960_PD_MailboxRegister4Offset);
  1872.   writel(CommandMailbox->Words[2],
  1873.  ControllerBaseAddress + DAC960_PD_MailboxRegister8Offset);
  1874.   writeb(CommandMailbox->Bytes[12],
  1875.  ControllerBaseAddress + DAC960_PD_MailboxRegister12Offset);
  1876. }
  1877. static inline DAC960_V1_CommandIdentifier_T
  1878. DAC960_PD_ReadStatusCommandIdentifier(void __iomem *ControllerBaseAddress)
  1879. {
  1880.   return readb(ControllerBaseAddress
  1881.        + DAC960_PD_StatusCommandIdentifierRegOffset);
  1882. }
  1883. static inline DAC960_V1_CommandStatus_T
  1884. DAC960_PD_ReadStatusRegister(void __iomem *ControllerBaseAddress)
  1885. {
  1886.   return readw(ControllerBaseAddress + DAC960_PD_StatusRegisterOffset);
  1887. }
  1888. static inline boolean
  1889. DAC960_PD_ReadErrorStatus(void __iomem *ControllerBaseAddress,
  1890.   unsigned char *ErrorStatus,
  1891.   unsigned char *Parameter0,
  1892.   unsigned char *Parameter1)
  1893. {
  1894.   DAC960_PD_ErrorStatusRegister_T ErrorStatusRegister;
  1895.   ErrorStatusRegister.All =
  1896.     readb(ControllerBaseAddress + DAC960_PD_ErrorStatusRegisterOffset);
  1897.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  1898.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  1899.   *ErrorStatus = ErrorStatusRegister.All;
  1900.   *Parameter0 =
  1901.     readb(ControllerBaseAddress + DAC960_PD_CommandOpcodeRegisterOffset);
  1902.   *Parameter1 =
  1903.     readb(ControllerBaseAddress + DAC960_PD_CommandIdentifierRegisterOffset);
  1904.   writeb(0, ControllerBaseAddress + DAC960_PD_ErrorStatusRegisterOffset);
  1905.   return true;
  1906. }
  1907. static inline void DAC960_P_To_PD_TranslateEnquiry(void *Enquiry)
  1908. {
  1909.   memcpy(Enquiry + 132, Enquiry + 36, 64);
  1910.   memset(Enquiry + 36, 0, 96);
  1911. }
  1912. static inline void DAC960_P_To_PD_TranslateDeviceState(void *DeviceState)
  1913. {
  1914.   memcpy(DeviceState + 2, DeviceState + 3, 1);
  1915.   memcpy(DeviceState + 4, DeviceState + 5, 2);
  1916.   memcpy(DeviceState + 6, DeviceState + 8, 4);
  1917. }
  1918. static inline
  1919. void DAC960_PD_To_P_TranslateReadWriteCommand(DAC960_V1_CommandMailbox_T
  1920.       *CommandMailbox)
  1921. {
  1922.   int LogicalDriveNumber = CommandMailbox->Type5.LD.LogicalDriveNumber;
  1923.   CommandMailbox->Bytes[3] &= 0x7;
  1924.   CommandMailbox->Bytes[3] |= CommandMailbox->Bytes[7] << 6;
  1925.   CommandMailbox->Bytes[7] = LogicalDriveNumber;
  1926. }
  1927. static inline
  1928. void DAC960_P_To_PD_TranslateReadWriteCommand(DAC960_V1_CommandMailbox_T
  1929.       *CommandMailbox)
  1930. {
  1931.   int LogicalDriveNumber = CommandMailbox->Bytes[7];
  1932.   CommandMailbox->Bytes[7] = CommandMailbox->Bytes[3] >> 6;
  1933.   CommandMailbox->Bytes[3] &= 0x7;
  1934.   CommandMailbox->Bytes[3] |= LogicalDriveNumber << 3;
  1935. }
  1936. /*
  1937.   Define prototypes for the forward referenced DAC960 Driver Internal Functions.
  1938. */
  1939. static void DAC960_FinalizeController(DAC960_Controller_T *);
  1940. static void DAC960_V1_QueueReadWriteCommand(DAC960_Command_T *);
  1941. static void DAC960_V2_QueueReadWriteCommand(DAC960_Command_T *); 
  1942. static void DAC960_RequestFunction(struct request_queue *);
  1943. static irqreturn_t DAC960_BA_InterruptHandler(int, void *, struct pt_regs *);
  1944. static irqreturn_t DAC960_LP_InterruptHandler(int, void *, struct pt_regs *);
  1945. static irqreturn_t DAC960_LA_InterruptHandler(int, void *, struct pt_regs *);
  1946. static irqreturn_t DAC960_PG_InterruptHandler(int, void *, struct pt_regs *);
  1947. static irqreturn_t DAC960_PD_InterruptHandler(int, void *, struct pt_regs *);
  1948. static irqreturn_t DAC960_P_InterruptHandler(int, void *, struct pt_regs *);
  1949. static void DAC960_V1_QueueMonitoringCommand(DAC960_Command_T *);
  1950. static void DAC960_V2_QueueMonitoringCommand(DAC960_Command_T *);
  1951. static void DAC960_MonitoringTimerFunction(unsigned long);
  1952. static void DAC960_Message(DAC960_MessageLevel_T, unsigned char *,
  1953.    DAC960_Controller_T *, ...);
  1954. static void DAC960_CreateProcEntries(DAC960_Controller_T *);
  1955. static void DAC960_DestroyProcEntries(DAC960_Controller_T *);
  1956. #endif /* DAC960_DriverVersion */