2 * (C) Copyright 2007-2009 DENX Software Engineering
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/processor.h>
29 DECLARE_GLOBAL_DATA_PTR;
31 #if defined(CONFIG_IDE_RESET)
33 void ide_set_reset (int idereset)
35 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
36 debug ("ide_set_reset(%d)\n", idereset);
39 out_be32(&im->pata.pata_ata_control, 0);
41 out_be32(&im->pata.pata_ata_control, FSL_ATA_CTRL_ATA_RST_B);
46 void init_ide_reset (void)
48 debug ("init_ide_reset\n");
51 * Clear the reset bit to reset the interface
52 * cf. RefMan MPC5121EE: 28.4.1 Resetting the ATA Bus
56 /* Assert the reset bit to enable the interface */
61 #define CALC_TIMING(t) (t + period - 1) / period
63 int ide_preinit (void)
65 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
96 debug ("IDE preinit using PATA peripheral at IMMR-ADDR %08x\n",
99 /* Set the reset bit to 1 to enable the interface */
102 /* Init timings : we use PIO mode 0 timings */
103 t = 1000000000 / gd->arch.ips_clk; /* period in ns */
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;
109 out_be32(&im->pata.pata_time1, cfg.config);
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;
116 out_be32(&im->pata.pata_time2, cfg.config);
118 cfg.config = in_be32(&im->pata.pata_time3);
119 cfg.bytes.field1 = (pio_specs.t9 + t) / t;
121 out_be32(&im->pata.pata_time3, cfg.config);
123 debug ("PATA preinit complete.\n");
128 #endif /* defined(CONFIG_IDE_RESET) */