mirror of
https://xff.cz/git/u-boot/
synced 2025-09-18 00:52:07 +02:00
sandbox: phy: add driver_data for bind test cmd
Add driver data to existing compatible string "sandbox,phy". Add an additional compatible string without driver_data This will verify that bind command parses, finds and passes the correct driver data to device_bind_with_driver_data() by using driver_data in the second sandbox_phy_ids table entry. In sandbox_phy_bind() a check is added to validate driver_data content. Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Simon Glass
parent
84f8e36f03
commit
cfa3ed4390
@@ -8,6 +8,8 @@
|
|||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <generic-phy.h>
|
#include <generic-phy.h>
|
||||||
|
|
||||||
|
#define DRIVER_DATA 0x12345678
|
||||||
|
|
||||||
struct sandbox_phy_priv {
|
struct sandbox_phy_priv {
|
||||||
bool initialized;
|
bool initialized;
|
||||||
bool on;
|
bool on;
|
||||||
@@ -71,6 +73,14 @@ static int sandbox_phy_exit(struct phy *phy)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sandbox_phy_bind(struct udevice *dev)
|
||||||
|
{
|
||||||
|
if (dev_get_driver_data(dev) != DRIVER_DATA)
|
||||||
|
return -ENODATA;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int sandbox_phy_probe(struct udevice *dev)
|
static int sandbox_phy_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct sandbox_phy_priv *priv = dev_get_priv(dev);
|
struct sandbox_phy_priv *priv = dev_get_priv(dev);
|
||||||
@@ -90,13 +100,19 @@ static struct phy_ops sandbox_phy_ops = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct udevice_id sandbox_phy_ids[] = {
|
static const struct udevice_id sandbox_phy_ids[] = {
|
||||||
{ .compatible = "sandbox,phy" },
|
{ .compatible = "sandbox,phy_no_driver_data",
|
||||||
|
},
|
||||||
|
|
||||||
|
{ .compatible = "sandbox,phy",
|
||||||
|
.data = DRIVER_DATA
|
||||||
|
},
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
U_BOOT_DRIVER(phy_sandbox) = {
|
U_BOOT_DRIVER(phy_sandbox) = {
|
||||||
.name = "phy_sandbox",
|
.name = "phy_sandbox",
|
||||||
.id = UCLASS_PHY,
|
.id = UCLASS_PHY,
|
||||||
|
.bind = sandbox_phy_bind,
|
||||||
.of_match = sandbox_phy_ids,
|
.of_match = sandbox_phy_ids,
|
||||||
.ops = &sandbox_phy_ops,
|
.ops = &sandbox_phy_ops,
|
||||||
.probe = sandbox_phy_probe,
|
.probe = sandbox_phy_probe,
|
||||||
|
Reference in New Issue
Block a user