10f9cfa09Swdenk /* 20f9cfa09Swdenk * (C) Copyright 2000 30f9cfa09Swdenk * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 40f9cfa09Swdenk * 50f9cfa09Swdenk * See file CREDITS for list of people who contributed to this 60f9cfa09Swdenk * project. 70f9cfa09Swdenk * 80f9cfa09Swdenk * This program is free software; you can redistribute it and/or 90f9cfa09Swdenk * modify it under the terms of the GNU General Public License as 100f9cfa09Swdenk * published by the Free Software Foundation; either version 2 of 110f9cfa09Swdenk * the License, or (at your option) any later version. 120f9cfa09Swdenk * 130f9cfa09Swdenk * This program is distributed in the hope that it will be useful, 140f9cfa09Swdenk * but WITHOUT ANY WARRANTY; without even the implied warranty of 150f9cfa09Swdenk * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 160f9cfa09Swdenk * GNU General Public License for more details. 170f9cfa09Swdenk * 180f9cfa09Swdenk * You should have received a copy of the GNU General Public License 190f9cfa09Swdenk * along with this program; if not, write to the Free Software 200f9cfa09Swdenk * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 210f9cfa09Swdenk * MA 02111-1307 USA 220f9cfa09Swdenk */ 230f9cfa09Swdenk 240f9cfa09Swdenk #ifndef _IDE_H 250f9cfa09Swdenk #define _IDE_H 260f9cfa09Swdenk 278a10180dSLuka Perkov #define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS)) 280f9cfa09Swdenk 296d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)]) 30f5b82c0fSPavel Herrmann extern ulong ide_bus_offset[]; 31f98984cbSHeiko Schocher 320f9cfa09Swdenk #ifdef CONFIG_IDE_LED 330f9cfa09Swdenk 340f9cfa09Swdenk /* 350f9cfa09Swdenk * LED Port 360f9cfa09Swdenk */ 370f9cfa09Swdenk #define LED_PORT ((uchar *)(PER8_BASE + 0x3000)) 380f9cfa09Swdenk #define LED_IDE1 0x01 390f9cfa09Swdenk #define LED_IDE2 0x02 400f9cfa09Swdenk #define DEVICE_LED(d) ((d & 2) | ((d & 2) == 0)) /* depends on bit positions! */ 410f9cfa09Swdenk 420f9cfa09Swdenk #endif /* CONFIG_IDE_LED */ 430f9cfa09Swdenk 446d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_SYS_64BIT_LBA 45c40b2956Swdenk typedef uint64_t lbaint_t; 4624a3fdd6SGabe Black #define LBAF "%llx" 47*04735e9cSFrederic Leroy #define LBAFU "%llu" 48c40b2956Swdenk #else 49c40b2956Swdenk typedef ulong lbaint_t; 5024a3fdd6SGabe Black #define LBAF "%lx" 51*04735e9cSFrederic Leroy #define LBAFU "%lu" 52c40b2956Swdenk #endif 53c40b2956Swdenk 540f9cfa09Swdenk /* 550f9cfa09Swdenk * Function Prototypes 560f9cfa09Swdenk */ 570f9cfa09Swdenk 580f9cfa09Swdenk void ide_init(void); 59ff8fef56SSascha Silbe ulong ide_read(int device, lbaint_t blknr, lbaint_t blkcnt, void *buffer); 60ff8fef56SSascha Silbe ulong ide_write(int device, lbaint_t blknr, lbaint_t blkcnt, 61ff8fef56SSascha Silbe const void *buffer); 620f9cfa09Swdenk 638d1165e1SPavel Herrmann #ifdef CONFIG_IDE_PREINIT 648d1165e1SPavel Herrmann int ide_preinit(void); 658d1165e1SPavel Herrmann #endif 668d1165e1SPavel Herrmann 678d1165e1SPavel Herrmann #ifdef CONFIG_IDE_INIT_POSTRESET 688d1165e1SPavel Herrmann int ide_init_postreset(void); 698d1165e1SPavel Herrmann #endif 708d1165e1SPavel Herrmann 713887c3fbSHeiko Schocher #if defined(CONFIG_OF_IDE_FIXUP) 723887c3fbSHeiko Schocher int ide_device_present(int dev); 733887c3fbSHeiko Schocher #endif 740abddf82SMacpaul Lin 750abddf82SMacpaul Lin #if defined(CONFIG_IDE_AHB) 760abddf82SMacpaul Lin unsigned char ide_read_register(int dev, unsigned int port); 770abddf82SMacpaul Lin void ide_write_register(int dev, unsigned int port, unsigned char val); 780abddf82SMacpaul Lin void ide_read_data(int dev, ulong *sect_buf, int words); 790abddf82SMacpaul Lin void ide_write_data(int dev, ulong *sect_buf, int words); 800abddf82SMacpaul Lin #endif 81f5b82c0fSPavel Herrmann 82f5b82c0fSPavel Herrmann /* 83f5b82c0fSPavel Herrmann * I/O function overrides 84f5b82c0fSPavel Herrmann */ 85f5b82c0fSPavel Herrmann void ide_input_swap_data(int dev, ulong *sect_buf, int words); 86f5b82c0fSPavel Herrmann void ide_input_data(int dev, ulong *sect_buf, int words); 87f5b82c0fSPavel Herrmann void ide_output_data(int dev, const ulong *sect_buf, int words); 88f5b82c0fSPavel Herrmann void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts); 89f5b82c0fSPavel Herrmann void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts); 90f5b82c0fSPavel Herrmann 91c2240d4dSSimon Glass /** 92c2240d4dSSimon Glass * board_start_ide() - Start up the board IDE interfac 93c2240d4dSSimon Glass * 94c2240d4dSSimon Glass * @return 0 if ok 95c2240d4dSSimon Glass */ 96c2240d4dSSimon Glass int board_start_ide(void); 97c2240d4dSSimon Glass 980f9cfa09Swdenk #endif /* _IDE_H */ 99