Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Huacai Chen | 3adeb25 | 2014-11-04 14:13:27 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2009 Lemote Inc. |
| 4 | * Author: Wu Zhangjin, wuzhangjin@gmail.com |
| 5 | * Xiang Yu, xiangy@lemote.com |
| 6 | * Chen Huacai, chenhc@lemote.com |
Huacai Chen | 3adeb25 | 2014-11-04 14:13:27 +0800 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/err.h> |
| 10 | #include <linux/slab.h> |
| 11 | #include <linux/platform_device.h> |
| 12 | #include <asm/bootinfo.h> |
| 13 | #include <boot_param.h> |
| 14 | #include <loongson_hwmon.h> |
| 15 | #include <workarounds.h> |
| 16 | |
| 17 | static int __init loongson3_platform_init(void) |
| 18 | { |
| 19 | int i; |
| 20 | struct platform_device *pdev; |
| 21 | |
| 22 | if (loongson_sysconf.ecname[0] != '\0') |
| 23 | platform_device_register_simple(loongson_sysconf.ecname, -1, NULL, 0); |
| 24 | |
| 25 | for (i = 0; i < loongson_sysconf.nr_sensors; i++) { |
| 26 | if (loongson_sysconf.sensors[i].type > SENSOR_FAN) |
| 27 | continue; |
| 28 | |
| 29 | pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL); |
Tiezhu Yang | 72d052e | 2020-01-10 09:30:42 +0800 | [diff] [blame] | 30 | if (!pdev) |
| 31 | return -ENOMEM; |
| 32 | |
Huacai Chen | 3adeb25 | 2014-11-04 14:13:27 +0800 | [diff] [blame] | 33 | pdev->name = loongson_sysconf.sensors[i].name; |
| 34 | pdev->id = loongson_sysconf.sensors[i].id; |
| 35 | pdev->dev.platform_data = &loongson_sysconf.sensors[i]; |
| 36 | platform_device_register(pdev); |
| 37 | } |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | arch_initcall(loongson3_platform_init); |