Simon Glass | 9880c4b | 2015-08-30 16:55:19 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Google, Inc |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
| 9 | #include <ns16550.h> |
| 10 | #include <serial.h> |
| 11 | #include <asm/arch/clock.h> |
| 12 | |
| 13 | static const struct udevice_id rockchip_serial_ids[] = { |
| 14 | { .compatible = "rockchip,rk3288-uart" }, |
| 15 | { } |
| 16 | }; |
| 17 | |
| 18 | static int rockchip_serial_ofdata_to_platdata(struct udevice *dev) |
| 19 | { |
| 20 | struct ns16550_platdata *plat = dev_get_platdata(dev); |
| 21 | int ret; |
| 22 | |
| 23 | ret = ns16550_serial_ofdata_to_platdata(dev); |
| 24 | if (ret) |
| 25 | return ret; |
| 26 | |
| 27 | /* Do all Rockchip parts use 24MHz? */ |
| 28 | plat->clock = 24 * 1000000; |
| 29 | |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | U_BOOT_DRIVER(serial_ns16550) = { |
| 34 | .name = "serial_rockchip", |
| 35 | .id = UCLASS_SERIAL, |
| 36 | .of_match = rockchip_serial_ids, |
| 37 | .ofdata_to_platdata = rockchip_serial_ofdata_to_platdata, |
| 38 | .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), |
| 39 | .priv_auto_alloc_size = sizeof(struct NS16550), |
| 40 | .probe = ns16550_serial_probe, |
| 41 | .ops = &ns16550_serial_ops, |
| 42 | .flags = DM_FLAG_PRE_RELOC, |
| 43 | }; |