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" 47c40b2956Swdenk #else 48c40b2956Swdenk typedef ulong lbaint_t; 4924a3fdd6SGabe Black #define LBAF "%lx" 50c40b2956Swdenk #endif 51c40b2956Swdenk 520f9cfa09Swdenk /* 530f9cfa09Swdenk * Function Prototypes 540f9cfa09Swdenk */ 550f9cfa09Swdenk 560f9cfa09Swdenk void ide_init(void); 574ac8f8e0STom Rini ulong ide_read(int device, ulong blknr, lbaint_t blkcnt, void *buffer); 584ac8f8e0STom Rini ulong ide_write(int device, ulong blknr, lbaint_t blkcnt, const void *buffer); 590f9cfa09Swdenk 608d1165e1SPavel Herrmann #ifdef CONFIG_IDE_PREINIT 618d1165e1SPavel Herrmann int ide_preinit(void); 628d1165e1SPavel Herrmann #endif 638d1165e1SPavel Herrmann 648d1165e1SPavel Herrmann #ifdef CONFIG_IDE_INIT_POSTRESET 658d1165e1SPavel Herrmann int ide_init_postreset(void); 668d1165e1SPavel Herrmann #endif 678d1165e1SPavel Herrmann 683887c3fbSHeiko Schocher #if defined(CONFIG_OF_IDE_FIXUP) 693887c3fbSHeiko Schocher int ide_device_present(int dev); 703887c3fbSHeiko Schocher #endif 710abddf82SMacpaul Lin 720abddf82SMacpaul Lin #if defined(CONFIG_IDE_AHB) 730abddf82SMacpaul Lin unsigned char ide_read_register(int dev, unsigned int port); 740abddf82SMacpaul Lin void ide_write_register(int dev, unsigned int port, unsigned char val); 750abddf82SMacpaul Lin void ide_read_data(int dev, ulong *sect_buf, int words); 760abddf82SMacpaul Lin void ide_write_data(int dev, ulong *sect_buf, int words); 770abddf82SMacpaul Lin #endif 78f5b82c0fSPavel Herrmann 79f5b82c0fSPavel Herrmann /* 80f5b82c0fSPavel Herrmann * I/O function overrides 81f5b82c0fSPavel Herrmann */ 82f5b82c0fSPavel Herrmann void ide_input_swap_data(int dev, ulong *sect_buf, int words); 83f5b82c0fSPavel Herrmann void ide_input_data(int dev, ulong *sect_buf, int words); 84f5b82c0fSPavel Herrmann void ide_output_data(int dev, const ulong *sect_buf, int words); 85f5b82c0fSPavel Herrmann void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts); 86f5b82c0fSPavel Herrmann void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts); 87f5b82c0fSPavel Herrmann 88*c2240d4dSSimon Glass /** 89*c2240d4dSSimon Glass * board_start_ide() - Start up the board IDE interfac 90*c2240d4dSSimon Glass * 91*c2240d4dSSimon Glass * @return 0 if ok 92*c2240d4dSSimon Glass */ 93*c2240d4dSSimon Glass int board_start_ide(void); 94*c2240d4dSSimon Glass 950f9cfa09Swdenk #endif /* _IDE_H */ 96