OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel-0-3-0-rc3/] [or1ksim/] [peripheral/] [atahost.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1748 jeremybenn
/* atahost.h -- ATA Host code simulation
2 876 rherveille
 
3 1748 jeremybenn
   Copyright (C) 2002 Richard Herveille, rherveille@opencores.org
4
   Copyright (C) 2008 Embecosm Limited
5 876 rherveille
 
6 1748 jeremybenn
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
7 876 rherveille
 
8 1748 jeremybenn
   This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.
9 876 rherveille
 
10 1748 jeremybenn
   This program is free software; you can redistribute it and/or modify it
11
   under the terms of the GNU General Public License as published by the Free
12
   Software Foundation; either version 3 of the License, or (at your option)
13
   any later version.
14 876 rherveille
 
15 1748 jeremybenn
   This program is distributed in the hope that it will be useful, but WITHOUT
16
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
18
   more details.
19 876 rherveille
 
20 1748 jeremybenn
   You should have received a copy of the GNU General Public License along
21
   with this program.  If not, see <http://www.gnu.org/licenses/>.  */
22 876 rherveille
 
23 1748 jeremybenn
/* This program is commented throughout in a fashion suitable for processing
24
   with Doxygen. */
25
 
26
/* Definitions for the Opencores ATA Host Controller Core */
27
 
28
 
29
#ifndef ATAHOST__H
30
#define ATAHOST__H
31
 
32
#include "arch.h"
33 876 rherveille
#include "atadevice.h"
34
 
35
/* --- Register definitions --- */
36
 
37
/* ----- Core Registers                                              */
38 1748 jeremybenn
#define ATA_CTRL  0x00          /* Control register                   */
39
#define ATA_STAT  0x04          /* Status register                    */
40
#define ATA_PCTR  0x08          /* PIO command timing register        */
41
#define ATA_PFTR0 0x0c          /* PIO Fast Timing register Device0   */
42
#define ATA_PFTR1 0x10          /* PIO Fast Timing register Device1   */
43
#define ATA_DTR0  0x14          /* DMA Timing register Device2        */
44
#define ATA_DTR1  0x18          /* DMA Timing register Device1        */
45
#define ATA_TXB   0x3c          /* DMA Transmit buffer                */
46
#define ATA_RXB   0x3c          /* DMA Receive buffer                 */
47 876 rherveille
 
48
 
49
/* ----------------------------                                       */
50
/* ----- Bits definitions -----                                       */
51
/* ----------------------------                                       */
52
 
53
/* ----- Core Control register                                        */
54 1748 jeremybenn
                                /* bits 31-16 are reserved            */
55
#define ATA_DMA_EN  (0<<15)     /* DMAen, DMA enable bit              */
56
                                /* bit 14 is reserved                 */
57
#define ATA_DMA_WR  (1<<14)     /* DMA Write transaction              */
58
#define ATA_DMA_RD  (0<<14)     /* DMA Read transaction               */
59
                                /* bits 13-10 are reserved            */
60
#define ATA_BELEC1  (1<< 9)     /* Big-Little endian conversion       */
61
                                /* enable bit for Device1             */
62
#define ATA_BELEC0  (1<< 8)     /* Big-Little endian conversion       */
63
                                /* enable bit for Device0             */
64
#define ATA_IDE_EN  (1<< 7)     /* IDE core enable bit                */
65
#define ATA_FTE1    (1<< 6)     /* Device1 Fast PIO Timing Enable bit */
66
#define ATA_FTE0    (1<< 5)     /* Device0 Fast PIO Timing Enable bit */
67
#define ATA_PWPP    (1<< 4)     /* PIO Write Ping-Pong Enable bit     */
68
#define ATA_IORDY_FTE1 (1<< 3)  /* Device1 Fast PIO Timing IORDY      */
69
                                /* enable bit                         */
70
#define ATA_IORDY_FTE0 (1<< 2)  /* Device0 Fast PIO Timing IORDY      */
71
                                /* enable bit                         */
72
#define ATA_IORDY   (1<< 1)     /* PIO Command Timing IORDY enable bit */
73
#define ATA_RST     (1<< 0)     /* ATA Reset bit                      */
74 876 rherveille
 
75
/* ----- Core Status register                                         */
76 1748 jeremybenn
#define ATA_DEVID   0xf0000000  /* bits 31-28 Device-ID               */
77
#define ATA_REVNO   0x0f000000  /* bits 27-24 Revision number         */
78
                                /* bits 23-16 are reserved            */
79
#define ATA_DMA_TIP (1<<15)     /* DMA Transfer in progress           */
80
                                /* bits 14-10 are reserved            */
81
#define ATA_DRBE    (1<<10)     /* DMA Receive buffer empty           */
82
#define ATA_DTBF    (1<< 9)     /* DMA Transmit buffer full           */
83
#define ATA_DMARQ   (1<< 8)     /* DMARQ Line status                  */
84
#define ATA_PIO_TIP (1<< 7      /* PIO Transfer in progress           */
85
#define ATA_PWPPF   (1<< 6)     /* PIO write ping-pong full           */
86
                                /* bits 5-1 are reserved              */
87
#define ATA_IDEIS  (1<< 0)      /* IDE Interrupt status               */
88 876 rherveille
 
89
 
90
/* -----  Core Timing registers                                       */
91 1748 jeremybenn
#define ATA_TEOC       24       /* End of cycle time          DMA/PIO */
92
#define ATA_T4         16       /* DIOW- data hold time           PIO */
93
#define ATA_T2          8       /* DIOR-/DIOW- pulse width        PIO */
94
#define ATA_TD          8       /* DIOR-/DIOW- pulse width        DMA */
95
#define ATA_T1          0       /* Address valid to DIOR-/DIOW-   PIO */
96
#define ATA_TM          0       /* CS[1:0]valid to DIOR-/DIOW-    DMA */
97 876 rherveille
 
98
 
99
/* -----------------------------                                      */
100
/* ----- Simulator defines -----                                      */
101
/* -----------------------------                                      */
102
#define ATA_ADDR_SPACE 0x80
103
 
104
 
105
/* ----------------------------                                       */
106
/* ----- Structs          -----                                       */
107
/* ----------------------------                                       */
108 1748 jeremybenn
struct ata_host
109
{
110
  /* Is peripheral enabled? */
111
  int enabled;
112 1461 nogj
 
113 1748 jeremybenn
  /* Base address in memory                                     */
114
  oraddr_t baseaddr;
115 876 rherveille
 
116 1748 jeremybenn
  /* Registered memory area                                     */
117
  struct dev_memarea *mem;
118 1486 nogj
 
119 1748 jeremybenn
  /* Which IRQ to generate                                      */
120
  int irq;
121 876 rherveille
 
122 1748 jeremybenn
  /* Which ocidec version is implemented                        */
123
  int dev_id;
124 1701 nogj
 
125 1748 jeremybenn
  /* OCIDEC revision                                            */
126
  int rev;
127 1701 nogj
 
128 1748 jeremybenn
  /* Current selected device                                    */
129
  int dev_sel;
130 1701 nogj
 
131 1748 jeremybenn
  /* PIO T1 reset value                                         */
132
  uint8_t pio_mode0_t1;
133 1702 nogj
 
134 1748 jeremybenn
  /* PIO T2 reset value                                         */
135
  uint8_t pio_mode0_t2;
136 1702 nogj
 
137 1748 jeremybenn
  /* PIO T4 reset value                                         */
138
  uint8_t pio_mode0_t4;
139 1702 nogj
 
140 1748 jeremybenn
  /* PIO Teoc reset value                                       */
141
  uint8_t pio_mode0_teoc;
142 1702 nogj
 
143 1748 jeremybenn
  /* DMA Tm reset value                                         */
144
  uint8_t dma_mode0_tm;
145 1702 nogj
 
146 1748 jeremybenn
  /* DMA Td reset value                                         */
147
  uint8_t dma_mode0_td;
148 1702 nogj
 
149 1748 jeremybenn
  /* DMA Teoc reset value                                       */
150
  uint8_t dma_mode0_teoc;
151 1702 nogj
 
152 1748 jeremybenn
  /* ata host registers                                         */
153
  struct
154
  {
155
    uint32_t ctrl;
156
    uint32_t stat;
157
    uint32_t pctr;
158
    uint32_t pftr0;
159
    uint32_t pftr1;
160
    uint32_t dtr0;
161
    uint32_t dtr1;
162
    uint32_t txb;
163
    uint32_t rxb;
164
  } regs;
165 876 rherveille
 
166 1748 jeremybenn
  /* connected ATA devices (slaves)                             */
167
  struct ata_devices  devices;
168
};
169 876 rherveille
 
170
/* ----------------------------                                       */
171
/* ----- Prototypes       -----                                       */
172
/* ----------------------------                                       */
173 1748 jeremybenn
void ata_int (void *dat);
174 876 rherveille
 
175
 
176
/* ----------------------------                                       */
177
/* ----- Macros           -----                                       */
178
/* ----------------------------                                       */
179
#define is_ata_hostadr(adr) (!(adr & 0x40))
180
 
181 919 rherveille
// FIXME
182
#define ata_pio_delay(pioreg) ( (((pioreg >> ATA_T1) & 0xff) +1) + (((pioreg >> ATA_T2) & 0xff) +1) + (((pioreg >> ATA_T4) & 0xff) +1) +1 )
183
#define ata_dma_delay(dmareg) ( (((dmareg >> ATA_TD) & 0xff) +1) + (((pioreg >> ATA_TM) & 0xff) +1) +1 )
184
 
185 1748 jeremybenn
/* Prototypes for external use */
186
void reg_ata_sec ();
187
 
188
#endif /* ATAHOST__H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.