3 * Pierre AUBERT, Staubli Faverges, <p.aubert@staubli.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * Init is derived from Linux code.
30 #define CALC_TIMING(t) (t + period - 1) / period
32 #define GPIO_PSC1_4 0x01000000ul
34 int ide_preinit (void)
36 DECLARE_GLOBAL_DATA_PTR;
37 long period, t0, t1, t2_8, t2_16, t4, ta;
39 struct mpc5xxx_sdma *psdma = (struct mpc5xxx_sdma *) MPC5XXX_SDMA;
41 reg = *(vu_long *) MPC5XXX_GPS_PORT_CONFIG;
42 reg = (reg & ~0x03000000ul) | 0x01000000ul;
43 *(vu_long *) MPC5XXX_GPS_PORT_CONFIG = reg;
45 /* All sample codes do that... */
46 *(vu_long *) MPC5XXX_ATA_SHARE_COUNT = 0;
48 /* Configure and reset host */
49 *(vu_long *) MPC5XXX_ATA_HOST_CONFIG = MPC5xxx_ATA_HOSTCONF_IORDY |
50 MPC5xxx_ATA_HOSTCONF_SMR | MPC5xxx_ATA_HOSTCONF_FR;
52 *(vu_long *) MPC5XXX_ATA_HOST_CONFIG = MPC5xxx_ATA_HOSTCONF_IORDY;
54 /* Disable prefetch on Commbus */
57 /* Init timings : we use PIO mode 0 timings */
58 period = 1000000000 / gd->ipb_clk; /* period in ns */
60 t0 = CALC_TIMING (600);
61 t2_8 = CALC_TIMING (290);
62 t2_16 = CALC_TIMING (165);
63 reg = (t0 << 24) | (t2_8 << 16) | (t2_16 << 8);
64 *(vu_long *) MPC5XXX_ATA_PIO1 = reg;
66 t4 = CALC_TIMING (30);
67 t1 = CALC_TIMING (70);
68 ta = CALC_TIMING (35);
69 reg = (t4 << 24) | (t1 << 16) | (ta << 8);
71 *(vu_long *) MPC5XXX_ATA_PIO2 = reg;
73 #if defined (CONFIG_ICECUBE) && defined (CONFIG_IDE_RESET)
74 /* Configure PSC1_4 as GPIO output for ATA reset */
75 *(vu_long *) MPC5XXX_WU_GPIO_DATA |= GPIO_PSC1_4;
76 *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
77 *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
78 #endif /* defined (CONFIG_ICECUBE) && defined (CONFIG_IDE_RESET) */
83 #if defined (CONFIG_ICECUBE) && defined (CONFIG_IDE_RESET)
84 void ide_set_reset (int idereset)
87 *(vu_long *) MPC5XXX_WU_GPIO_DATA &= ~GPIO_PSC1_4;
89 *(vu_long *) MPC5XXX_WU_GPIO_DATA |= GPIO_PSC1_4;
92 #endif /* defined (CONFIG_ICECUBE) && defined (CONFIG_IDE_RESET) */
93 #endif /* CFG_CMD_IDE */