Vladimir Zapolskiy | 1b15483 | 2023-04-21 20:50:33 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm Generic Interface (GENI) Serial Engine (SE) Wrapper |
| 4 | * |
| 5 | * Copyright (C) 2023 Linaro Ltd. <vladimir.zapolskiy@linaro.org> |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <dm.h> |
| 10 | #include <misc.h> |
| 11 | #include <asm/io.h> |
| 12 | |
| 13 | static int geni_se_qup_read(struct udevice *dev, int offset, |
| 14 | void *buf, int size) |
| 15 | { |
| 16 | fdt_addr_t base = dev_read_addr(dev); |
| 17 | |
| 18 | if (size != sizeof(u32)) |
| 19 | return -EINVAL; |
| 20 | |
| 21 | *(u32 *)buf = readl(base + offset); |
| 22 | |
| 23 | return size; |
| 24 | } |
| 25 | |
| 26 | static struct misc_ops geni_se_qup_ops = { |
| 27 | .read = geni_se_qup_read, |
| 28 | }; |
| 29 | |
| 30 | static const struct udevice_id geni_se_qup_ids[] = { |
| 31 | { .compatible = "qcom,geni-se-qup" }, |
| 32 | {} |
| 33 | }; |
| 34 | |
| 35 | U_BOOT_DRIVER(geni_se_qup) = { |
| 36 | .name = "geni_se_qup", |
| 37 | .id = UCLASS_MISC, |
| 38 | .of_match = geni_se_qup_ids, |
| 39 | .ops = &geni_se_qup_ops, |
| 40 | .flags = DM_FLAG_PRE_RELOC, |
| 41 | }; |