Ma Jun | 717c3db | 2015-12-17 19:56:35 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2015 Hisilicon Limited, All Rights Reserved. |
| 3 | * Author: Jun Ma <majun258@huawei.com> |
| 4 | * Author: Yun Wu <wuyun.wu@huawei.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include <linux/module.h> |
| 20 | #include <linux/of_address.h> |
| 21 | #include <linux/of_irq.h> |
| 22 | #include <linux/of_platform.h> |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/slab.h> |
| 25 | |
| 26 | /** |
| 27 | * struct mbigen_device - holds the information of mbigen device. |
| 28 | * |
| 29 | * @pdev: pointer to the platform device structure of mbigen chip. |
| 30 | * @base: mapped address of this mbigen chip. |
| 31 | */ |
| 32 | struct mbigen_device { |
| 33 | struct platform_device *pdev; |
| 34 | void __iomem *base; |
| 35 | }; |
| 36 | |
| 37 | static int mbigen_device_probe(struct platform_device *pdev) |
| 38 | { |
| 39 | struct mbigen_device *mgn_chip; |
| 40 | struct resource *res; |
| 41 | |
| 42 | mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL); |
| 43 | if (!mgn_chip) |
| 44 | return -ENOMEM; |
| 45 | |
| 46 | mgn_chip->pdev = pdev; |
| 47 | |
| 48 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 49 | mgn_chip->base = devm_ioremap_resource(&pdev->dev, res); |
| 50 | if (IS_ERR(mgn_chip->base)) |
| 51 | return PTR_ERR(mgn_chip->base); |
| 52 | |
| 53 | platform_set_drvdata(pdev, mgn_chip); |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | static const struct of_device_id mbigen_of_match[] = { |
| 59 | { .compatible = "hisilicon,mbigen-v2" }, |
| 60 | { /* END */ } |
| 61 | }; |
| 62 | MODULE_DEVICE_TABLE(of, mbigen_of_match); |
| 63 | |
| 64 | static struct platform_driver mbigen_platform_driver = { |
| 65 | .driver = { |
| 66 | .name = "Hisilicon MBIGEN-V2", |
| 67 | .owner = THIS_MODULE, |
| 68 | .of_match_table = mbigen_of_match, |
| 69 | }, |
| 70 | .probe = mbigen_device_probe, |
| 71 | }; |
| 72 | |
| 73 | module_platform_driver(mbigen_platform_driver); |
| 74 | |
| 75 | MODULE_AUTHOR("Jun Ma <majun258@huawei.com>"); |
| 76 | MODULE_AUTHOR("Yun Wu <wuyun.wu@huawei.com>"); |
| 77 | MODULE_LICENSE("GPL"); |
| 78 | MODULE_DESCRIPTION("Hisilicon MBI Generator driver"); |