Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2000 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _IDE_H |
| 8 | #define _IDE_H |
| 9 | |
Simon Glass | ac8162f | 2016-02-29 15:25:39 -0700 | [diff] [blame] | 10 | #include <blk.h> |
| 11 | |
Luka Perkov | f5c0be0 | 2012-05-14 09:29:10 +0000 | [diff] [blame] | 12 | #define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS)) |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 13 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 14 | #define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)]) |
Pavel Herrmann | 35ad9a8 | 2012-10-09 07:04:39 +0000 | [diff] [blame] | 15 | extern ulong ide_bus_offset[]; |
Heiko Schocher | 2559e0f | 2007-08-28 17:39:14 +0200 | [diff] [blame] | 16 | |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 17 | /* |
| 18 | * Function Prototypes |
| 19 | */ |
| 20 | |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 21 | void ide_init(void); |
Simon Glass | e339475 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 22 | struct blk_desc; |
Simon Glass | f94bea0 | 2016-05-01 11:36:22 -0600 | [diff] [blame] | 23 | struct udevice; |
| 24 | #ifdef CONFIG_BLK |
| 25 | ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, |
| 26 | void *buffer); |
| 27 | ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, |
| 28 | const void *buffer); |
| 29 | #else |
Simon Glass | e339475 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 30 | ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, |
Stephen Warren | e73f296 | 2015-12-07 11:38:48 -0700 | [diff] [blame] | 31 | void *buffer); |
Simon Glass | e339475 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 32 | ulong ide_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, |
Sascha Silbe | 4bdf6fd | 2013-06-14 13:07:25 +0200 | [diff] [blame] | 33 | const void *buffer); |
Simon Glass | f94bea0 | 2016-05-01 11:36:22 -0600 | [diff] [blame] | 34 | #endif |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 35 | |
Pavel Herrmann | 2c13c4a | 2012-10-09 07:01:56 +0000 | [diff] [blame] | 36 | #ifdef CONFIG_IDE_PREINIT |
| 37 | int ide_preinit(void); |
| 38 | #endif |
| 39 | |
Heiko Schocher | ffb293a | 2009-09-23 07:56:08 +0200 | [diff] [blame] | 40 | #if defined(CONFIG_OF_IDE_FIXUP) |
| 41 | int ide_device_present(int dev); |
| 42 | #endif |
Macpaul Lin | d1e4994 | 2011-04-11 20:45:32 +0000 | [diff] [blame] | 43 | |
| 44 | #if defined(CONFIG_IDE_AHB) |
| 45 | unsigned char ide_read_register(int dev, unsigned int port); |
| 46 | void ide_write_register(int dev, unsigned int port, unsigned char val); |
| 47 | void ide_read_data(int dev, ulong *sect_buf, int words); |
Gabor Juhos | 7aecc98 | 2013-05-26 12:11:28 +0200 | [diff] [blame] | 48 | void ide_write_data(int dev, const ulong *sect_buf, int words); |
Macpaul Lin | d1e4994 | 2011-04-11 20:45:32 +0000 | [diff] [blame] | 49 | #endif |
Pavel Herrmann | 35ad9a8 | 2012-10-09 07:04:39 +0000 | [diff] [blame] | 50 | |
| 51 | /* |
| 52 | * I/O function overrides |
| 53 | */ |
Jeroen Hofstee | 9aa3827 | 2014-07-12 15:07:19 +0200 | [diff] [blame] | 54 | unsigned char ide_inb(int dev, int port); |
| 55 | void ide_outb(int dev, int port, unsigned char val); |
Pavel Herrmann | 35ad9a8 | 2012-10-09 07:04:39 +0000 | [diff] [blame] | 56 | void ide_input_swap_data(int dev, ulong *sect_buf, int words); |
| 57 | void ide_input_data(int dev, ulong *sect_buf, int words); |
| 58 | void ide_output_data(int dev, const ulong *sect_buf, int words); |
| 59 | void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts); |
| 60 | void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts); |
| 61 | |
Jeroen Hofstee | 9aa3827 | 2014-07-12 15:07:19 +0200 | [diff] [blame] | 62 | void ide_led(uchar led, uchar status); |
| 63 | |
Simon Glass | 5af29bd | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 64 | /** |
| 65 | * board_start_ide() - Start up the board IDE interfac |
| 66 | * |
| 67 | * @return 0 if ok |
| 68 | */ |
| 69 | int board_start_ide(void); |
| 70 | |
wdenk | 0f9cfa0 | 2002-08-27 10:38:37 +0000 | [diff] [blame] | 71 | #endif /* _IDE_H */ |