1 // SPDX-License-Identifier: GPL-2.0+
3 * Texas Instruments System Control Interface (TI SCI) power domain driver
5 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
6 * Andreas Dannenberg <dannenberg@ti.com>
8 * Loosely based on Linux kernel ti_sci_pm_domains.c...
14 #include <power-domain-uclass.h>
15 #include <linux/soc/ti/ti_sci_protocol.h>
18 * struct ti_sci_power_domain_data - pm domain controller information structure
19 * @sci: TI SCI handle used for communication with system controller
21 struct ti_sci_power_domain_data
{
22 const struct ti_sci_handle
*sci
;
25 static int ti_sci_power_domain_probe(struct udevice
*dev
)
27 struct ti_sci_power_domain_data
*data
= dev_get_priv(dev
);
29 debug("%s(dev=%p)\n", __func__
, dev
);
34 /* Store handle for communication with the system controller */
35 data
->sci
= ti_sci_get_handle(dev
);
36 if (IS_ERR(data
->sci
))
37 return PTR_ERR(data
->sci
);
42 static int ti_sci_power_domain_request(struct power_domain
*pd
)
44 debug("%s(pd=%p)\n", __func__
, pd
);
48 static int ti_sci_power_domain_free(struct power_domain
*pd
)
50 debug("%s(pd=%p)\n", __func__
, pd
);
54 static int ti_sci_power_domain_on(struct power_domain
*pd
)
56 struct ti_sci_power_domain_data
*data
= dev_get_priv(pd
->dev
);
57 const struct ti_sci_handle
*sci
= data
->sci
;
58 const struct ti_sci_dev_ops
*dops
= &sci
->ops
.dev_ops
;
61 debug("%s(pd=%p)\n", __func__
, pd
);
63 ret
= dops
->get_device(sci
, pd
->id
);
65 dev_err(power_domain
->dev
, "%s: get_device failed (%d)\n",
71 static int ti_sci_power_domain_off(struct power_domain
*pd
)
73 struct ti_sci_power_domain_data
*data
= dev_get_priv(pd
->dev
);
74 const struct ti_sci_handle
*sci
= data
->sci
;
75 const struct ti_sci_dev_ops
*dops
= &sci
->ops
.dev_ops
;
78 debug("%s(pd=%p)\n", __func__
, pd
);
80 ret
= dops
->put_device(sci
, pd
->id
);
82 dev_err(power_domain
->dev
, "%s: put_device failed (%d)\n",
88 static const struct udevice_id ti_sci_power_domain_of_match
[] = {
89 { .compatible
= "ti,sci-pm-domain" },
93 static struct power_domain_ops ti_sci_power_domain_ops
= {
94 .request
= ti_sci_power_domain_request
,
95 .free
= ti_sci_power_domain_free
,
96 .on
= ti_sci_power_domain_on
,
97 .off
= ti_sci_power_domain_off
,
100 U_BOOT_DRIVER(ti_sci_pm_domains
) = {
101 .name
= "ti-sci-pm-domains",
102 .id
= UCLASS_POWER_DOMAIN
,
103 .of_match
= ti_sci_power_domain_of_match
,
104 .probe
= ti_sci_power_domain_probe
,
105 .priv_auto_alloc_size
= sizeof(struct ti_sci_power_domain_data
),
106 .ops
= &ti_sci_power_domain_ops
,