wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef _IDE_H |
| 9 | #define _IDE_H |
| 10 | |
Luka Perkov | 8a10180 | 2012-05-14 09:29:10 +0000 | [diff] [blame] | 11 | #define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS)) |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 12 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 13 | #define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)]) |
Pavel Herrmann | f5b82c0 | 2012-10-09 07:04:39 +0000 | [diff] [blame] | 14 | extern ulong ide_bus_offset[]; |
Heiko Schocher | f98984c | 2007-08-28 17:39:14 +0200 | [diff] [blame] | 15 | |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 16 | #ifdef CONFIG_IDE_LED |
| 17 | |
| 18 | /* |
| 19 | * LED Port |
| 20 | */ |
| 21 | #define LED_PORT ((uchar *)(PER8_BASE + 0x3000)) |
| 22 | #define LED_IDE1 0x01 |
| 23 | #define LED_IDE2 0x02 |
| 24 | #define DEVICE_LED(d) ((d & 2) | ((d & 2) == 0)) /* depends on bit positions! */ |
| 25 | |
| 26 | #endif /* CONFIG_IDE_LED */ |
| 27 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 28 | #ifdef CONFIG_SYS_64BIT_LBA |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 29 | typedef uint64_t lbaint_t; |
Gabe Black | 24a3fdd | 2012-10-12 14:26:06 +0000 | [diff] [blame] | 30 | #define LBAF "%llx" |
Frederic Leroy | 04735e9 | 2013-06-26 18:11:25 +0200 | [diff] [blame] | 31 | #define LBAFU "%llu" |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 32 | #else |
| 33 | typedef ulong lbaint_t; |
Gabe Black | 24a3fdd | 2012-10-12 14:26:06 +0000 | [diff] [blame] | 34 | #define LBAF "%lx" |
Frederic Leroy | 04735e9 | 2013-06-26 18:11:25 +0200 | [diff] [blame] | 35 | #define LBAFU "%lu" |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 36 | #endif |
| 37 | |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 38 | /* |
| 39 | * Function Prototypes |
| 40 | */ |
| 41 | |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 42 | void ide_init(void); |
Sascha Silbe | ff8fef5 | 2013-06-14 13:07:25 +0200 | [diff] [blame] | 43 | ulong ide_read(int device, lbaint_t blknr, lbaint_t blkcnt, void *buffer); |
| 44 | ulong ide_write(int device, lbaint_t blknr, lbaint_t blkcnt, |
| 45 | const void *buffer); |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 46 | |
Pavel Herrmann | 8d1165e11a | 2012-10-09 07:01:56 +0000 | [diff] [blame] | 47 | #ifdef CONFIG_IDE_PREINIT |
| 48 | int ide_preinit(void); |
| 49 | #endif |
| 50 | |
| 51 | #ifdef CONFIG_IDE_INIT_POSTRESET |
| 52 | int ide_init_postreset(void); |
| 53 | #endif |
| 54 | |
Heiko Schocher | 3887c3f | 2009-09-23 07:56:08 +0200 | [diff] [blame] | 55 | #if defined(CONFIG_OF_IDE_FIXUP) |
| 56 | int ide_device_present(int dev); |
| 57 | #endif |
Macpaul Lin | 0abddf8 | 2011-04-11 20:45:32 +0000 | [diff] [blame] | 58 | |
| 59 | #if defined(CONFIG_IDE_AHB) |
| 60 | unsigned char ide_read_register(int dev, unsigned int port); |
| 61 | void ide_write_register(int dev, unsigned int port, unsigned char val); |
| 62 | void ide_read_data(int dev, ulong *sect_buf, int words); |
Gabor Juhos | c575180 | 2013-05-26 12:11:28 +0200 | [diff] [blame] | 63 | void ide_write_data(int dev, const ulong *sect_buf, int words); |
Macpaul Lin | 0abddf8 | 2011-04-11 20:45:32 +0000 | [diff] [blame] | 64 | #endif |
Pavel Herrmann | f5b82c0 | 2012-10-09 07:04:39 +0000 | [diff] [blame] | 65 | |
| 66 | /* |
| 67 | * I/O function overrides |
| 68 | */ |
Jeroen Hofstee | 288afdc | 2014-07-12 15:07:19 +0200 | [diff] [blame] | 69 | unsigned char ide_inb(int dev, int port); |
| 70 | void ide_outb(int dev, int port, unsigned char val); |
Pavel Herrmann | f5b82c0 | 2012-10-09 07:04:39 +0000 | [diff] [blame] | 71 | void ide_input_swap_data(int dev, ulong *sect_buf, int words); |
| 72 | void ide_input_data(int dev, ulong *sect_buf, int words); |
| 73 | void ide_output_data(int dev, const ulong *sect_buf, int words); |
| 74 | void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts); |
| 75 | void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts); |
| 76 | |
Jeroen Hofstee | 288afdc | 2014-07-12 15:07:19 +0200 | [diff] [blame] | 77 | void ide_led(uchar led, uchar status); |
| 78 | |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 79 | /** |
| 80 | * board_start_ide() - Start up the board IDE interfac |
| 81 | * |
| 82 | * @return 0 if ok |
| 83 | */ |
| 84 | int board_start_ide(void); |
| 85 | |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 86 | #endif /* _IDE_H */ |