Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 1 | /* |
Googler | 695f9d9 | 2023-09-11 15:38:29 +0800 | [diff] [blame^] | 2 | * Copyright (c) 2014 Google, Inc |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 3 | * |
Googler | 695f9d9 | 2023-09-11 15:38:29 +0800 | [diff] [blame^] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
Googler | 695f9d9 | 2023-09-11 15:38:29 +0800 | [diff] [blame^] | 9 | #include <fdtdec.h> |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 10 | #include <ns16550.h> |
| 11 | #include <serial.h> |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 12 | |
Googler | 695f9d9 | 2023-09-11 15:38:29 +0800 | [diff] [blame^] | 13 | DECLARE_GLOBAL_DATA_PTR; |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 14 | |
Googler | 695f9d9 | 2023-09-11 15:38:29 +0800 | [diff] [blame^] | 15 | #ifdef CONFIG_OF_CONTROL |
| 16 | static const struct udevice_id omap_serial_ids[] = { |
| 17 | { .compatible = "ti,omap3-uart" }, |
| 18 | { } |
| 19 | }; |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 20 | |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 21 | static int omap_serial_ofdata_to_platdata(struct udevice *dev) |
| 22 | { |
Googler | 695f9d9 | 2023-09-11 15:38:29 +0800 | [diff] [blame^] | 23 | struct ns16550_platdata *plat = dev_get_platdata(dev); |
| 24 | int ret; |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 25 | |
Googler | 695f9d9 | 2023-09-11 15:38:29 +0800 | [diff] [blame^] | 26 | ret = ns16550_serial_ofdata_to_platdata(dev); |
| 27 | if (ret) |
| 28 | return ret; |
| 29 | plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, |
| 30 | "clock-frequency", -1); |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 31 | plat->reg_shift = 2; |
| 32 | |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 33 | return 0; |
| 34 | } |
Googler | 25e92cf | 2023-12-13 10:05:01 +0000 | [diff] [blame] | 35 | #endif |
Googler | 695f9d9 | 2023-09-11 15:38:29 +0800 | [diff] [blame^] | 36 | |
| 37 | U_BOOT_DRIVER(serial_omap_ns16550) = { |
| 38 | .name = "serial_omap", |
| 39 | .id = UCLASS_SERIAL, |
| 40 | .of_match = of_match_ptr(omap_serial_ids), |
| 41 | .ofdata_to_platdata = of_match_ptr(omap_serial_ofdata_to_platdata), |
| 42 | .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 43 | .priv_auto_alloc_size = sizeof(struct NS16550), |
| 44 | .probe = ns16550_serial_probe, |
| 45 | .ops = &ns16550_serial_ops, |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 46 | .flags = DM_FLAG_PRE_RELOC, |
Googler | e00b8eb | 2019-07-08 16:37:07 -0700 | [diff] [blame] | 47 | }; |