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