From 14a4f52b0d1b561ce52c4590bdd339497dfd5be5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 25 Apr 2023 10:54:26 -0600 Subject: ide: Move ATA_CURR_BASE to C file This is not used outside one C file. Move it out of the header to reduce its visbility. Signed-off-by: Simon Glass --- include/ide.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/ide.h b/include/ide.h index 426cef4e39e..58f6640c61b 100644 --- a/include/ide.h +++ b/include/ide.h @@ -11,9 +11,6 @@ #define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS)) -#define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)]) -extern ulong ide_bus_offset[]; - /* * Function Prototypes */ -- cgit v1.2.3 From 091785110031efe1f417a727ac7db68f2beb3116 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 25 Apr 2023 10:54:28 -0600 Subject: ide: Drop CONFIG_START_IDE This is not used by any board. Drop it. Signed-off-by: Simon Glass --- include/ide.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include') diff --git a/include/ide.h b/include/ide.h index 58f6640c61b..9c0d40364a8 100644 --- a/include/ide.h +++ b/include/ide.h @@ -47,11 +47,4 @@ void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts); void ide_led(uchar led, uchar status); -/** - * board_start_ide() - Start up the board IDE interfac - * - * Return: 0 if ok - */ -int board_start_ide(void); - #endif /* _IDE_H */ -- cgit v1.2.3 From 00a79f21c1c178d312635b96035da6aa48eb5321 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 25 Apr 2023 10:54:29 -0600 Subject: ide: Drop init for not using BLK ALl boards use CONFIG_BLK now so this code is not used. Drop it and the header-file #ifdef Signed-off-by: Simon Glass --- include/ide.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include') diff --git a/include/ide.h b/include/ide.h index 9c0d40364a8..457f275c61b 100644 --- a/include/ide.h +++ b/include/ide.h @@ -18,17 +18,10 @@ void ide_init(void); struct blk_desc; struct udevice; -#ifdef CONFIG_BLK ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer); ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); -#else -ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, - void *buffer); -ulong ide_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, - const void *buffer); -#endif #if defined(CONFIG_OF_IDE_FIXUP) int ide_device_present(int dev); -- cgit v1.2.3 From 80778f505c8c7ee18c24cfbcfe011f8a2abf7bcd Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 25 Apr 2023 10:54:30 -0600 Subject: ide: Move ide_init() into probing At present the code does ide_init() as a separate operation, then calls device_probe() to copy over the information. We can call ide_init() from probe just as easily. The only difference is that using 'ide init' twice will do nothing. However it already fails to copy over the new data in that case, so the effect is the same. For now, unbind the block devices and remove the IDE device, which causes the bus to be probed again. Later patches will fix this up fully, so that all blk_desc data is copied across. Since ide_reset() is only called from ide_init(), there is no need to init the ide_dev_desc[] array. This is already done at the end of ide_init() so drop this code. The call to uclass_first_device() is now within the probe() function of the same device, so does nothing. Drop it. Signed-off-by: Simon Glass --- include/ide.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/ide.h b/include/ide.h index 457f275c61b..3f36b4340d0 100644 --- a/include/ide.h +++ b/include/ide.h @@ -15,7 +15,6 @@ * Function Prototypes */ -void ide_init(void); struct blk_desc; struct udevice; ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, -- cgit v1.2.3 From 62d13fa6349e66f839fa855ac3f7ec71a1adfe87 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 25 Apr 2023 10:54:31 -0600 Subject: ide: Drop ide_device_present() This function is not used anymore. Drop it. Signed-off-by: Simon Glass --- include/ide.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/ide.h b/include/ide.h index 3f36b4340d0..09b0117879f 100644 --- a/include/ide.h +++ b/include/ide.h @@ -22,10 +22,6 @@ ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); -#if defined(CONFIG_OF_IDE_FIXUP) -int ide_device_present(int dev); -#endif - /* * I/O function overrides */ -- cgit v1.2.3 From f8e87e73e496d3f53307d5330c02185ee0b06131 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 25 Apr 2023 10:54:33 -0600 Subject: ide: Drop weak functions These are not used from outside this file anymore. Make them static and remove them from the header file. Signed-off-by: Simon Glass --- include/ide.h | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'include') diff --git a/include/ide.h b/include/ide.h index 09b0117879f..8c0eb2a022f 100644 --- a/include/ide.h +++ b/include/ide.h @@ -22,17 +22,4 @@ ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); -/* - * I/O function overrides - */ -unsigned char ide_inb(int dev, int port); -void ide_outb(int dev, int port, unsigned char val); -void ide_input_swap_data(int dev, ulong *sect_buf, int words); -void ide_input_data(int dev, ulong *sect_buf, int words); -void ide_output_data(int dev, const ulong *sect_buf, int words); -void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts); -void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts); - -void ide_led(uchar led, uchar status); - #endif /* _IDE_H */ -- cgit v1.2.3 From 1486c906230ca61580a65421adb26a24f5128a4e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 25 Apr 2023 10:54:34 -0600 Subject: ide: Create a prototype for ide_set_reset() This is used by a board so should be in the header file. Add it. Signed-off-by: Simon Glass --- include/ide.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/ide.h b/include/ide.h index 8c0eb2a022f..b586ba3df4b 100644 --- a/include/ide.h +++ b/include/ide.h @@ -22,4 +22,14 @@ ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); +/** + * ide_set_reset() - Assert or de-assert reset for the IDE device + * + * This is provided by boards which need to reset the device through another + * means, e.g. a GPIO. + * + * @idereset: 1 to assert reset, 0 to de-assert it + */ +void ide_set_reset(int idereset); + #endif /* _IDE_H */ -- cgit v1.2.3 From 646deed40b8ffe9aa9c10b86f1addbb4a9788e91 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 25 Apr 2023 10:54:35 -0600 Subject: ide: Correct use of ATAPI The use of atapi_read() was incorrect dropped. Fix this so that it will be used when needed. Use a udevice for the first argument of atapi_read() so it is consistent with ide_read(). This requires much of the ATAPI code to be brought out from behind the existing #ifdef. It will still be removed by the compiler if it is not needed. Add an atapi flag to struct blk_desc so the information can be retained. Fixes: 145df842b44 ("dm: ide: Add support for driver-model block devices") Fixes: d0075059e4d ("ide: Drop non-DM code for BLK") Reviewed-by: Mattijs Korpershoek Signed-off-by: Simon Glass --- include/blk.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index 1db203c1bab..871922dcde0 100644 --- a/include/blk.h +++ b/include/blk.h @@ -66,6 +66,7 @@ struct blk_desc { /* device can use 48bit addr (ATA/ATAPI v7) */ unsigned char lba48; #endif + unsigned char atapi; /* Use ATAPI protocol */ lbaint_t lba; /* number of blocks */ unsigned long blksz; /* block size */ int log2blksz; /* for convenience: log2(blksz) */ -- cgit v1.2.3 From 1b33fd83179c8f09b79930c9ffca6e8b9dfa37cf Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 25 Apr 2023 10:54:36 -0600 Subject: ide: Make function static Only one function is called from outside this file. Make all the others static. Signed-off-by: Simon Glass --- include/ide.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'include') diff --git a/include/ide.h b/include/ide.h index b586ba3df4b..2c25e74ede0 100644 --- a/include/ide.h +++ b/include/ide.h @@ -11,17 +11,6 @@ #define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS)) -/* - * Function Prototypes - */ - -struct blk_desc; -struct udevice; -ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, - void *buffer); -ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, - const void *buffer); - /** * ide_set_reset() - Assert or de-assert reset for the IDE device * -- cgit v1.2.3 From 8b1b943a7aa3c2d071982b99220cdee49ed2c5fb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 25 Apr 2023 10:54:41 -0600 Subject: ide: Avoid preprocessor for CONFIG_LBA48 Use IS_ENABLED() instead for all conditions. Add the 'lba48' flag into struct blk_desc always, since it uses very little space. Use a bool so the meaning is clearer. Signed-off-by: Simon Glass Reviewed-by: Mattijs Korpershoek --- include/blk.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index 871922dcde0..2c9c7985a88 100644 --- a/include/blk.h +++ b/include/blk.h @@ -62,10 +62,8 @@ struct blk_desc { unsigned char hwpart; /* HW partition, e.g. for eMMC */ unsigned char type; /* device type */ unsigned char removable; /* removable device */ -#ifdef CONFIG_LBA48 /* device can use 48bit addr (ATA/ATAPI v7) */ - unsigned char lba48; -#endif + bool lba48; unsigned char atapi; /* Use ATAPI protocol */ lbaint_t lba; /* number of blocks */ unsigned long blksz; /* block size */ -- cgit v1.2.3