Simon Glass | e98a03c | 2014-10-10 07:49:20 -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> |
Bin Meng | 1eb47ef | 2014-12-31 16:05:13 +0800 | [diff] [blame] | 9 | #include <fdtdec.h> |
Simon Glass | e98a03c | 2014-10-10 07:49:20 -0600 | [diff] [blame] | 10 | #include <ns16550.h> |
| 11 | #include <serial.h> |
| 12 | |
Bin Meng | 1eb47ef | 2014-12-31 16:05:13 +0800 | [diff] [blame] | 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
Bin Meng | 41702ba | 2014-12-17 15:50:47 +0800 | [diff] [blame] | 15 | static const struct udevice_id x86_serial_ids[] = { |
| 16 | { .compatible = "x86-uart" }, |
Simon Glass | e98a03c | 2014-10-10 07:49:20 -0600 | [diff] [blame] | 17 | { } |
| 18 | }; |
| 19 | |
Bin Meng | 41702ba | 2014-12-17 15:50:47 +0800 | [diff] [blame] | 20 | static int x86_serial_ofdata_to_platdata(struct udevice *dev) |
Simon Glass | e98a03c | 2014-10-10 07:49:20 -0600 | [diff] [blame] | 21 | { |
| 22 | struct ns16550_platdata *plat = dev_get_platdata(dev); |
| 23 | int ret; |
| 24 | |
| 25 | ret = ns16550_serial_ofdata_to_platdata(dev); |
| 26 | if (ret) |
| 27 | return ret; |
Bin Meng | 1eb47ef | 2014-12-31 16:05:13 +0800 | [diff] [blame] | 28 | |
| 29 | plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, |
| 30 | "clock-frequency", 1843200); |
Simon Glass | e98a03c | 2014-10-10 07:49:20 -0600 | [diff] [blame] | 31 | |
| 32 | return 0; |
| 33 | } |
Bin Meng | 1eb47ef | 2014-12-31 16:05:13 +0800 | [diff] [blame] | 34 | |
Simon Glass | e98a03c | 2014-10-10 07:49:20 -0600 | [diff] [blame] | 35 | U_BOOT_DRIVER(serial_ns16550) = { |
Bin Meng | 41702ba | 2014-12-17 15:50:47 +0800 | [diff] [blame] | 36 | .name = "serial_x86", |
Simon Glass | e98a03c | 2014-10-10 07:49:20 -0600 | [diff] [blame] | 37 | .id = UCLASS_SERIAL, |
Bin Meng | 41702ba | 2014-12-17 15:50:47 +0800 | [diff] [blame] | 38 | .of_match = x86_serial_ids, |
| 39 | .ofdata_to_platdata = x86_serial_ofdata_to_platdata, |
Simon Glass | e98a03c | 2014-10-10 07:49:20 -0600 | [diff] [blame] | 40 | .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), |
| 41 | .priv_auto_alloc_size = sizeof(struct NS16550), |
| 42 | .probe = ns16550_serial_probe, |
| 43 | .ops = &ns16550_serial_ops, |
| 44 | }; |