1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <command.h>
26#include <asm/io.h>
27#include <asm/processor.h>
28
29DECLARE_GLOBAL_DATA_PTR;
30
31#if defined(CONFIG_IDE_RESET)
32
33void ide_set_reset (int idereset)
34{
35 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
36 debug ("ide_set_reset(%d)\n", idereset);
37
38 if (idereset) {
39 out_be32(&im->pata.pata_ata_control, 0);
40 } else {
41 out_be32(&im->pata.pata_ata_control, FSL_ATA_CTRL_ATA_RST_B);
42 }
43 udelay(100);
44}
45
46void init_ide_reset (void)
47{
48 debug ("init_ide_reset\n");
49
50
51
52
53
54 ide_set_reset(1);
55
56
57 ide_set_reset(0);
58
59}
60
61#define CALC_TIMING(t) (t + period - 1) / period
62
63int ide_preinit (void)
64{
65 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
66 long t;
67 const struct {
68 short t0;
69 short t1;
70 short t2_8;
71 short t2_16;
72 short t2i;
73 short t4;
74 short t9;
75 short tA;
76 } pio_specs = {
77 .t0 = 600,
78 .t1 = 70,
79 .t2_8 = 290,
80 .t2_16 = 165,
81 .t2i = 0,
82 .t4 = 30,
83 .t9 = 20,
84 .tA = 50,
85 };
86 union {
87 u32 config;
88 struct {
89 u8 field1;
90 u8 field2;
91 u8 field3;
92 u8 field4;
93 }bytes;
94 } cfg;
95
96 debug ("IDE preinit using PATA peripheral at IMMR-ADDR %08x\n",
97 (u32)&im->pata);
98
99
100 ide_set_reset(0);
101
102
103 t = 1000000000 / gd->ips_clk;
104 cfg.bytes.field1 = 3;
105 cfg.bytes.field2 = 3;
106 cfg.bytes.field3 = (pio_specs.t1 + t) / t;
107 cfg.bytes.field4 = (pio_specs.t2_8 + t) / t;
108
109 out_be32(&im->pata.pata_time1, cfg.config);
110
111 cfg.bytes.field1 = (pio_specs.t2_8 + t) / t;
112 cfg.bytes.field2 = (pio_specs.tA + t) / t + 2;
113 cfg.bytes.field3 = 1;
114 cfg.bytes.field4 = (pio_specs.t4 + t) / t;
115
116 out_be32(&im->pata.pata_time2, cfg.config);
117
118 cfg.config = in_be32(&im->pata.pata_time3);
119 cfg.bytes.field1 = (pio_specs.t9 + t) / t;
120
121 out_be32(&im->pata.pata_time3, cfg.config);
122
123 debug ("PATA preinit complete.\n");
124
125 return 0;
126}
127
128#endif
129