Masahiro Yamada | 9c5a5dd | 2017-08-26 01:12:31 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 Socionext Inc. |
| 3 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <dm.h> |
| 10 | #include <linux/io.h> |
| 11 | #include <linux/ioport.h> |
| 12 | |
| 13 | #include "denali.h" |
| 14 | |
| 15 | static const struct udevice_id denali_nand_dt_ids[] = { |
| 16 | { |
| 17 | .compatible = "altr,socfpga-denali-nand", |
| 18 | }, |
| 19 | { |
| 20 | .compatible = "socionext,uniphier-denali-nand-v5a", |
| 21 | }, |
| 22 | { |
| 23 | .compatible = "socionext,uniphier-denali-nand-v5b", |
| 24 | }, |
| 25 | { /* sentinel */ } |
| 26 | }; |
| 27 | |
| 28 | static int denali_dt_probe(struct udevice *dev) |
| 29 | { |
| 30 | struct denali_nand_info *denali = dev_get_priv(dev); |
| 31 | struct resource res; |
| 32 | int ret; |
| 33 | |
| 34 | ret = dev_read_resource_byname(dev, "denali_reg", &res); |
| 35 | if (ret) |
| 36 | return ret; |
| 37 | |
| 38 | denali->flash_reg = devm_ioremap(dev, res.start, resource_size(&res)); |
| 39 | |
| 40 | ret = dev_read_resource_byname(dev, "nand_data", &res); |
| 41 | if (ret) |
| 42 | return ret; |
| 43 | |
| 44 | denali->flash_mem = devm_ioremap(dev, res.start, resource_size(&res)); |
| 45 | |
| 46 | return denali_init(denali); |
| 47 | } |
| 48 | |
| 49 | U_BOOT_DRIVER(denali_nand_dt) = { |
| 50 | .name = "denali-nand-dt", |
| 51 | .id = UCLASS_MISC, |
| 52 | .of_match = denali_nand_dt_ids, |
| 53 | .probe = denali_dt_probe, |
| 54 | .priv_auto_alloc_size = sizeof(struct denali_nand_info), |
| 55 | }; |
| 56 | |
| 57 | void board_nand_init(void) |
| 58 | { |
| 59 | struct udevice *dev; |
| 60 | int ret; |
| 61 | |
| 62 | ret = uclass_get_device_by_driver(UCLASS_MISC, |
| 63 | DM_GET_DRIVER(denali_nand_dt), |
| 64 | &dev); |
| 65 | if (ret && ret != -ENODEV) |
| 66 | printf("Failed to initialize Denali NAND controller. (error %d)\n", |
| 67 | ret); |
| 68 | } |