2 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
3 * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics.
5 * SPDX-License-Identifier: GPL-2.0+
15 DECLARE_GLOBAL_DATA_PTR
;
17 struct sti_sysreset_priv
{
21 static int sti_sysreset_request(struct udevice
*dev
, enum sysreset_t type
)
23 struct sti_sysreset_priv
*priv
= dev_get_priv(dev
);
25 generic_clear_bit(0, (void __iomem
*)priv
->base
);
30 static int sti_sysreset_probe(struct udevice
*dev
)
32 struct sti_sysreset_priv
*priv
= dev_get_priv(dev
);
33 struct udevice
*syscon
;
34 struct regmap
*regmap
;
35 struct fdtdec_phandle_args syscfg_phandle
;
38 /* get corresponding syscon phandle */
39 ret
= fdtdec_parse_phandle_with_args(gd
->fdt_blob
, dev_of_offset(dev
),
40 "st,syscfg", NULL
, 0, 0,
43 pr_err("Can't get syscfg phandle: %d\n", ret
);
47 ret
= uclass_get_device_by_of_offset(UCLASS_SYSCON
,
51 pr_err("%s: uclass_get_device_by_of_offset failed: %d\n",
56 regmap
= syscon_get_regmap(syscon
);
58 pr_err("unable to get regmap for %s\n", syscon
->name
);
62 priv
->base
= regmap
->base
;
67 static struct sysreset_ops sti_sysreset
= {
68 .request
= sti_sysreset_request
,
71 static const struct udevice_id sti_sysreset_ids
[] = {
72 { .compatible
= "st,stih407-restart" },
76 U_BOOT_DRIVER(sysreset_sti
) = {
77 .name
= "sysreset_sti",
78 .id
= UCLASS_SYSRESET
,
80 .probe
= sti_sysreset_probe
,
81 .of_match
= sti_sysreset_ids
,
82 .priv_auto_alloc_size
= sizeof(struct sti_sysreset_priv
),