Alexey Romanov | 6ee101a | 2023-09-21 11:13:34 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (c) 2023 SberDevices, Inc. |
| 4 | * |
| 5 | * Author: Alexey Romanov <avromanov@salutedevices.com> |
| 6 | */ |
| 7 | |
Tom Rini | abb9a04 | 2024-05-18 20:20:43 -0600 | [diff] [blame] | 8 | #include <common.h> |
Alexey Romanov | 6ee101a | 2023-09-21 11:13:34 +0300 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | #include <errno.h> |
| 11 | #include <sm-uclass.h> |
| 12 | |
| 13 | static const struct sm_ops *get_sm_ops(struct udevice *dev) |
| 14 | { |
| 15 | return (const struct sm_ops *)dev->driver->ops; |
| 16 | } |
| 17 | |
| 18 | int sm_call(struct udevice *dev, u32 cmd, s32 *ret, struct pt_regs *args) |
| 19 | { |
| 20 | const struct sm_ops *ops = get_sm_ops(dev); |
| 21 | |
| 22 | if (ops->sm_call) |
| 23 | return ops->sm_call(dev, cmd, ret, args); |
| 24 | |
| 25 | return -ENOSYS; |
| 26 | } |
| 27 | |
| 28 | int sm_call_read(struct udevice *dev, void *buffer, size_t size, |
| 29 | u32 cmd, struct pt_regs *args) |
| 30 | { |
| 31 | const struct sm_ops *ops = get_sm_ops(dev); |
| 32 | |
| 33 | if (ops->sm_call_read) |
| 34 | return ops->sm_call_read(dev, buffer, size, cmd, |
| 35 | args); |
| 36 | |
| 37 | return -ENOSYS; |
| 38 | } |
| 39 | |
| 40 | int sm_call_write(struct udevice *dev, void *buffer, size_t size, |
| 41 | u32 cmd, struct pt_regs *args) |
| 42 | { |
| 43 | const struct sm_ops *ops = get_sm_ops(dev); |
| 44 | |
| 45 | if (ops->sm_call_write) |
| 46 | return ops->sm_call_write(dev, buffer, size, cmd, |
| 47 | args); |
| 48 | |
| 49 | return -ENOSYS; |
| 50 | } |
| 51 | |
| 52 | UCLASS_DRIVER(sm) = { |
| 53 | .name = "sm", |
| 54 | .id = UCLASS_SM, |
| 55 | }; |