X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fcore%2Fsyscon-uclass.c;h=a69937e63c15d6db1a96baa6b28715c7f3ddb51a;hb=d10fc50f78ebae7c7f52469eced7c0d6d8a89f8c;hp=a0666d0bacd7e2d8cfcaca0f8ae13d85f7256873;hpb=9c3193f8d03d4074fa6ca6b783246b97d8dc2ff5;p=u-boot diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c index a0666d0bac..a69937e63c 100644 --- a/drivers/core/syscon-uclass.c +++ b/drivers/core/syscon-uclass.c @@ -29,7 +29,20 @@ static int syscon_pre_probe(struct udevice *dev) { struct syscon_uc_info *priv = dev_get_uclass_priv(dev); + /* + * With OF_PLATDATA we really have no way of knowing the format of + * the device-specific platform data. So we assume that it starts with + * a 'reg' member, and this holds a single address and size. Drivers + * using OF_PLATDATA will need to ensure that this is true. + */ +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct syscon_base_platdata *plat = dev_get_platdata(dev); + + return regmap_init_mem_platdata(dev, plat->reg, ARRAY_SIZE(plat->reg), + &priv->regmap); +#else return regmap_init_mem(dev, &priv->regmap); +#endif } int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp) @@ -38,6 +51,7 @@ int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp) struct uclass *uc; int ret; + *devp = NULL; ret = uclass_get(UCLASS_SYSCON, &uc); if (ret) return ret; @@ -81,3 +95,17 @@ UCLASS_DRIVER(syscon) = { .per_device_auto_alloc_size = sizeof(struct syscon_uc_info), .pre_probe = syscon_pre_probe, }; + +static const struct udevice_id generic_syscon_ids[] = { + { .compatible = "syscon" }, + { } +}; + +U_BOOT_DRIVER(generic_syscon) = { + .name = "syscon", + .id = UCLASS_SYSCON, +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + .bind = dm_scan_fdt_dev, +#endif + .of_match = generic_syscon_ids, +};