mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
efi_loader: allow creation of more device part nodes
Create device path nodes for UCLASS_ETH udevices. Create device path nodes of block device children of UCLASS_MMC udevices. Consistently use debug for unsupported nodes. Set the log level to error. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: Fix build failure by adding #ifdef CONFIG_DM_ETH] Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:

committed by
Alexander Graf

parent
f768619239
commit
9dfd84da8c
@ -6,6 +6,8 @@
|
|||||||
* SPDX-License-Identifier: GPL-2.0+
|
* SPDX-License-Identifier: GPL-2.0+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define LOG_CATEGORY LOGL_ERR
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <blk.h>
|
#include <blk.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
@ -111,7 +113,6 @@ int efi_dp_match(const struct efi_device_path *a,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See UEFI spec (section 3.1.2, about short-form device-paths..
|
* See UEFI spec (section 3.1.2, about short-form device-paths..
|
||||||
* tl;dr: we can have a device-path that starts with a USB WWID
|
* tl;dr: we can have a device-path that starts with a USB WWID
|
||||||
@ -184,7 +185,6 @@ static struct efi_object *find_obj(struct efi_device_path *dp, bool short_path,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find an efiobj from device-path, if 'rem' is not NULL, returns the
|
* Find an efiobj from device-path, if 'rem' is not NULL, returns the
|
||||||
* remaining part of the device path after the matched object.
|
* remaining part of the device path after the matched object.
|
||||||
@ -328,6 +328,9 @@ static unsigned dp_size(struct udevice *dev)
|
|||||||
case UCLASS_SIMPLE_BUS:
|
case UCLASS_SIMPLE_BUS:
|
||||||
/* stop traversing parents at this point: */
|
/* stop traversing parents at this point: */
|
||||||
return sizeof(ROOT);
|
return sizeof(ROOT);
|
||||||
|
case UCLASS_ETH:
|
||||||
|
return dp_size(dev->parent) +
|
||||||
|
sizeof(struct efi_device_path_mac_addr);
|
||||||
#ifdef CONFIG_BLK
|
#ifdef CONFIG_BLK
|
||||||
case UCLASS_BLK:
|
case UCLASS_BLK:
|
||||||
switch (dev->parent->uclass->uc_drv->id) {
|
switch (dev->parent->uclass->uc_drv->id) {
|
||||||
@ -340,14 +343,21 @@ static unsigned dp_size(struct udevice *dev)
|
|||||||
case UCLASS_SCSI:
|
case UCLASS_SCSI:
|
||||||
return dp_size(dev->parent) +
|
return dp_size(dev->parent) +
|
||||||
sizeof(struct efi_device_path_scsi);
|
sizeof(struct efi_device_path_scsi);
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC)
|
||||||
|
case UCLASS_MMC:
|
||||||
|
return dp_size(dev->parent) +
|
||||||
|
sizeof(struct efi_device_path_sd_mmc_path);
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return dp_size(dev->parent);
|
return dp_size(dev->parent);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC)
|
||||||
case UCLASS_MMC:
|
case UCLASS_MMC:
|
||||||
return dp_size(dev->parent) +
|
return dp_size(dev->parent) +
|
||||||
sizeof(struct efi_device_path_sd_mmc_path);
|
sizeof(struct efi_device_path_sd_mmc_path);
|
||||||
|
#endif
|
||||||
case UCLASS_MASS_STORAGE:
|
case UCLASS_MASS_STORAGE:
|
||||||
case UCLASS_USB_HUB:
|
case UCLASS_USB_HUB:
|
||||||
return dp_size(dev->parent) +
|
return dp_size(dev->parent) +
|
||||||
@ -378,6 +388,23 @@ static void *dp_fill(void *buf, struct udevice *dev)
|
|||||||
*vdp = ROOT;
|
*vdp = ROOT;
|
||||||
return &vdp[1];
|
return &vdp[1];
|
||||||
}
|
}
|
||||||
|
#ifdef CONFIG_DM_ETH
|
||||||
|
case UCLASS_ETH: {
|
||||||
|
struct efi_device_path_mac_addr *dp =
|
||||||
|
dp_fill(buf, dev->parent);
|
||||||
|
struct eth_pdata *pdata = dev->platdata;
|
||||||
|
|
||||||
|
dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
|
||||||
|
dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR;
|
||||||
|
dp->dp.length = sizeof(*dp);
|
||||||
|
memset(&dp->mac, 0, sizeof(dp->mac));
|
||||||
|
/* We only support IPv4 */
|
||||||
|
memcpy(&dp->mac, &pdata->enetaddr, ARP_HLEN);
|
||||||
|
/* Ethernet */
|
||||||
|
dp->if_type = 1;
|
||||||
|
return &dp[1];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_BLK
|
#ifdef CONFIG_BLK
|
||||||
case UCLASS_BLK:
|
case UCLASS_BLK:
|
||||||
switch (dev->parent->uclass->uc_drv->id) {
|
switch (dev->parent->uclass->uc_drv->id) {
|
||||||
@ -411,10 +438,26 @@ static void *dp_fill(void *buf, struct udevice *dev)
|
|||||||
dp->target_id = desc->target;
|
dp->target_id = desc->target;
|
||||||
return &dp[1];
|
return &dp[1];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC)
|
||||||
|
case UCLASS_MMC: {
|
||||||
|
struct efi_device_path_sd_mmc_path *sddp =
|
||||||
|
dp_fill(buf, dev->parent);
|
||||||
|
struct blk_desc *desc = dev_get_uclass_platdata(dev);
|
||||||
|
|
||||||
|
sddp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
|
||||||
|
sddp->dp.sub_type = is_sd(desc) ?
|
||||||
|
DEVICE_PATH_SUB_TYPE_MSG_SD :
|
||||||
|
DEVICE_PATH_SUB_TYPE_MSG_MMC;
|
||||||
|
sddp->dp.length = sizeof(*sddp);
|
||||||
|
sddp->slot_number = dev->seq;
|
||||||
|
return &sddp[1];
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
printf("unhandled parent class: %s (%u)\n",
|
debug("%s(%u) %s: unhandled parent class: %s (%u)\n",
|
||||||
dev->name, dev->driver->id);
|
__FILE__, __LINE__, __func__,
|
||||||
|
dev->name, dev->parent->uclass->uc_drv->id);
|
||||||
return dp_fill(buf, dev->parent);
|
return dp_fill(buf, dev->parent);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -454,7 +497,8 @@ static void *dp_fill(void *buf, struct udevice *dev)
|
|||||||
return &udp[1];
|
return &udp[1];
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
debug("unhandled device class: %s (%u)\n",
|
debug("%s(%u) %s: unhandled device class: %s (%u)\n",
|
||||||
|
__FILE__, __LINE__, __func__,
|
||||||
dev->name, dev->driver->id);
|
dev->name, dev->driver->id);
|
||||||
return dp_fill(buf, dev->parent);
|
return dp_fill(buf, dev->parent);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user