2 * (C) Copyright 2017 Patrice Chotard <patrice.chotard@st.com>
4 * SPDX-License-Identifier: GPL-2.0+
14 DECLARE_GLOBAL_DATA_PTR;
16 struct sti_sysreset_priv {
20 static int sti_sysreset_request(struct udevice *dev, enum sysreset_t type)
22 struct sti_sysreset_priv *priv = dev_get_priv(dev);
24 generic_clear_bit(0, (void __iomem *)priv->base);
29 static int sti_sysreset_probe(struct udevice *dev)
31 struct sti_sysreset_priv *priv = dev_get_priv(dev);
32 struct udevice *syscon;
33 struct regmap *regmap;
34 struct fdtdec_phandle_args syscfg_phandle;
37 /* get corresponding syscon phandle */
38 ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
39 "st,syscfg", NULL, 0, 0,
42 error("Can't get syscfg phandle: %d\n", ret);
46 ret = uclass_get_device_by_of_offset(UCLASS_SYSCON,
50 error("%s: uclass_get_device_by_of_offset failed: %d\n",
55 regmap = syscon_get_regmap(syscon);
57 error("unable to get regmap for %s\n", syscon->name);
61 priv->base = regmap->base;
66 static struct sysreset_ops sti_sysreset = {
67 .request = sti_sysreset_request,
70 static const struct udevice_id sti_sysreset_ids[] = {
71 { .compatible = "st,stih407-restart" },
75 U_BOOT_DRIVER(sysreset_sti) = {
76 .name = "sysreset_sti",
77 .id = UCLASS_SYSRESET,
79 .probe = sti_sysreset_probe,
80 .of_match = sti_sysreset_ids,
81 .priv_auto_alloc_size = sizeof(struct sti_sysreset_priv),