| 1 |
/* |
| 2 |
* Copyright (c) 2024, Rockchip, Inc. All rights reserved. |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <drivers/scmi-msg.h> |
| 8 |
#include <drivers/scmi.h> |
| 9 |
|
| 10 |
#include "scmi_rstd.h" |
| 11 |
|
| 12 |
#pragma weak rockchip_scmi_rstd_count |
| 13 |
#pragma weak rockchip_scmi_get_rstd |
| 14 |
|
| 15 |
size_t rockchip_scmi_rstd_count(unsigned int agent_id __unused) |
| 16 |
{ |
| 17 |
return 0U; |
| 18 |
} |
| 19 |
|
| 20 |
rk_scmi_rstd_t *rockchip_scmi_get_rstd(unsigned int agent_id __unused, |
| 21 |
unsigned int scmi_id __unused) |
| 22 |
{ |
| 23 |
return NULL; |
| 24 |
} |
| 25 |
|
| 26 |
size_t plat_scmi_rstd_count(unsigned int agent_id) |
| 27 |
{ |
| 28 |
return rockchip_scmi_rstd_count(agent_id); |
| 29 |
} |
| 30 |
|
| 31 |
const char *plat_scmi_rstd_get_name(unsigned int agent_id, |
| 32 |
unsigned int scmi_id) |
| 33 |
{ |
| 34 |
rk_scmi_rstd_t *rstd; |
| 35 |
|
| 36 |
rstd = rockchip_scmi_get_rstd(agent_id, scmi_id); |
| 37 |
if (rstd == NULL) |
| 38 |
return NULL; |
| 39 |
|
| 40 |
return rstd->name; |
| 41 |
} |
| 42 |
|
| 43 |
int32_t plat_scmi_rstd_autonomous(unsigned int agent_id, |
| 44 |
unsigned int scmi_id, |
| 45 |
unsigned int state) |
| 46 |
{ |
| 47 |
rk_scmi_rstd_t *rstd; |
| 48 |
|
| 49 |
rstd = rockchip_scmi_get_rstd(agent_id, scmi_id); |
| 50 |
if (rstd == NULL) |
| 51 |
return SCMI_NOT_FOUND; |
| 52 |
|
| 53 |
if ((rstd->rstd_ops && rstd->rstd_ops->reset_auto) != 0) |
| 54 |
return rstd->rstd_ops->reset_auto(rstd, state); |
| 55 |
else |
| 56 |
return SCMI_NOT_SUPPORTED; |
| 57 |
} |
| 58 |
|
| 59 |
int32_t plat_scmi_rstd_set_state(unsigned int agent_id, |
| 60 |
unsigned int scmi_id, |
| 61 |
bool assert_not_deassert) |
| 62 |
{ |
| 63 |
rk_scmi_rstd_t *rstd; |
| 64 |
|
| 65 |
rstd = rockchip_scmi_get_rstd(agent_id, scmi_id); |
| 66 |
if (rstd == NULL) |
| 67 |
return SCMI_NOT_FOUND; |
| 68 |
|
| 69 |
if ((rstd->rstd_ops && rstd->rstd_ops->reset_explicit) != 0) |
| 70 |
return rstd->rstd_ops->reset_explicit(rstd, |
| 71 |
assert_not_deassert); |
| 72 |
else |
| 73 |
return SCMI_NOT_SUPPORTED; |
| 74 |
} |