Simon Glass | 0bf2495 | 2014-10-22 21:37:12 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 Google, Inc |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
| 9 | #include <fdtdec.h> |
| 10 | #include <ns16550.h> |
| 11 | #include <serial.h> |
| 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
Mugunthan V N | 3a64845 | 2015-09-28 16:17:47 +0530 | [diff] [blame] | 15 | #define DEFAULT_CLK_SPEED 48000000 /* 48Mhz */ |
| 16 | |
Masahiro Yamada | 0f92582 | 2015-08-12 07:31:55 +0900 | [diff] [blame] | 17 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
Simon Glass | 0bf2495 | 2014-10-22 21:37:12 -0600 | [diff] [blame] | 18 | static const struct udevice_id omap_serial_ids[] = { |
Mugunthan V N | e5a098b | 2015-09-28 16:17:48 +0530 | [diff] [blame] | 19 | { .compatible = "ti,omap2-uart" }, |
Simon Glass | 0bf2495 | 2014-10-22 21:37:12 -0600 | [diff] [blame] | 20 | { .compatible = "ti,omap3-uart" }, |
Tom Rini | 57cd681 | 2015-07-31 19:55:12 -0400 | [diff] [blame] | 21 | { .compatible = "ti,omap4-uart" }, |
Mugunthan V N | e5a098b | 2015-09-28 16:17:48 +0530 | [diff] [blame] | 22 | { .compatible = "ti,am3352-uart" }, |
| 23 | { .compatible = "ti,am4372-uart" }, |
| 24 | { .compatible = "ti,dra742-uart" }, |
Simon Glass | 0bf2495 | 2014-10-22 21:37:12 -0600 | [diff] [blame] | 25 | { } |
| 26 | }; |
| 27 | |
| 28 | static int omap_serial_ofdata_to_platdata(struct udevice *dev) |
| 29 | { |
| 30 | struct ns16550_platdata *plat = dev_get_platdata(dev); |
| 31 | int ret; |
| 32 | |
| 33 | ret = ns16550_serial_ofdata_to_platdata(dev); |
| 34 | if (ret) |
| 35 | return ret; |
| 36 | plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, |
Mugunthan V N | 3a64845 | 2015-09-28 16:17:47 +0530 | [diff] [blame] | 37 | "clock-frequency", DEFAULT_CLK_SPEED); |
Simon Glass | 0bf2495 | 2014-10-22 21:37:12 -0600 | [diff] [blame] | 38 | plat->reg_shift = 2; |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | #endif |
| 43 | |
| 44 | U_BOOT_DRIVER(serial_omap_ns16550) = { |
| 45 | .name = "serial_omap", |
| 46 | .id = UCLASS_SERIAL, |
| 47 | .of_match = of_match_ptr(omap_serial_ids), |
| 48 | .ofdata_to_platdata = of_match_ptr(omap_serial_ofdata_to_platdata), |
| 49 | .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), |
| 50 | .priv_auto_alloc_size = sizeof(struct NS16550), |
| 51 | .probe = ns16550_serial_probe, |
| 52 | .ops = &ns16550_serial_ops, |
| 53 | .flags = DM_FLAG_PRE_RELOC, |
| 54 | }; |