mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-25 22:20:45 +00:00
Merge branch '2023-04-27-IDE-code-cleanups'
To quote the author: This code was converted to driver model a long time again but it was a pretty rough conversion. It introduced a few minor bugs, e.g. the device capacity is incorrect and some flags are lost (such as lba48). This series tidies up the code and fixes these bugs. This involves quite a bit of refactoring, so it is done one patch at a time for easier review.
This commit is contained in:
commit
b197f1f05d
6 changed files with 412 additions and 517 deletions
22
cmd/ide.c
22
cmd/ide.c
|
@ -10,12 +10,15 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <blk.h>
|
||||
#include <dm.h>
|
||||
#include <config.h>
|
||||
#include <watchdog.h>
|
||||
#include <command.h>
|
||||
#include <image.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include <asm/io.h>
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
|
||||
#include <ide.h>
|
||||
#include <ata.h>
|
||||
|
@ -31,8 +34,25 @@ int do_ide(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|||
{
|
||||
if (argc == 2) {
|
||||
if (strncmp(argv[1], "res", 3) == 0) {
|
||||
struct udevice *dev;
|
||||
int ret;
|
||||
|
||||
puts("\nReset IDE: ");
|
||||
ide_init();
|
||||
ret = uclass_find_first_device(UCLASS_IDE, &dev);
|
||||
ret = device_remove(dev, DM_REMOVE_NORMAL);
|
||||
if (!ret)
|
||||
ret = device_chld_unbind(dev, NULL);
|
||||
if (ret) {
|
||||
printf("Cannot remove IDE (err=%dE)\n", ret);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
ret = uclass_first_device_err(UCLASS_IDE, &dev);
|
||||
if (ret) {
|
||||
printf("Init failed (err=%dE)\n", ret);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -519,20 +519,6 @@ static int initr_post(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
|
||||
static int initr_ide(void)
|
||||
{
|
||||
puts("IDE: ");
|
||||
#if defined(CONFIG_START_IDE)
|
||||
if (board_start_ide())
|
||||
ide_init();
|
||||
#else
|
||||
ide_init();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CFG_PRAM)
|
||||
/*
|
||||
* Export available size of memory for Linux, taking into account the
|
||||
|
@ -783,9 +769,6 @@ static init_fnc_t init_sequence_r[] = {
|
|||
#ifdef CONFIG_POST
|
||||
initr_post,
|
||||
#endif
|
||||
#if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
|
||||
initr_ide,
|
||||
#endif
|
||||
#ifdef CONFIG_LAST_STAGE_INIT
|
||||
INIT_FUNC_WATCHDOG_RESET
|
||||
/*
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -62,10 +62,9 @@ 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 */
|
||||
int log2blksz; /* for convenience: log2(blksz) */
|
||||
|
|
|
@ -11,50 +11,14 @@
|
|||
|
||||
#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
|
||||
*/
|
||||
|
||||
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);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* board_start_ide() - Start up the board IDE interfac
|
||||
* ide_set_reset() - Assert or de-assert reset for the IDE device
|
||||
*
|
||||
* Return: 0 if ok
|
||||
* 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
|
||||
*/
|
||||
int board_start_ide(void);
|
||||
void ide_set_reset(int idereset);
|
||||
|
||||
#endif /* _IDE_H */
|
||||
|
|
|
@ -376,7 +376,6 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
|
|||
ut_assert_nextline("Hunting with: simple_bus");
|
||||
ut_assert_nextline("Found 2 extension board(s).");
|
||||
ut_assert_nextline("Hunting with: ide");
|
||||
ut_assert_nextline("Bus 0: not available ");
|
||||
|
||||
/* mmc hunter has already been used so should not run again */
|
||||
|
||||
|
@ -487,7 +486,6 @@ static int bootdev_test_hunt_prio(struct unit_test_state *uts)
|
|||
/* now try a different priority, verbosely */
|
||||
ut_assertok(bootdev_hunt_prio(BOOTDEVP_5_SCAN_SLOW, true));
|
||||
ut_assert_nextline("Hunting with: ide");
|
||||
ut_assert_nextline("Bus 0: not available ");
|
||||
ut_assert_nextline("Hunting with: usb");
|
||||
ut_assert_nextline(
|
||||
"Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found");
|
||||
|
|
Loading…
Reference in a new issue