developer | e0cea0f | 2021-12-16 16:08:26 +0800 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | |
| 3 | #include <linux/module.h> |
| 4 | #include <linux/kernel.h> |
| 5 | #include <linux/moduleparam.h> |
| 6 | #include "proslic_sys.h" |
| 7 | |
| 8 | #define PROSLIC_SYS_SERVICES_VER "0.0.1" |
| 9 | #define DRIVER_DESCRIPTION "ProSLIC API compatible system services" |
| 10 | #define DRIVER_AUTHOR "Silicon Laboratories" |
| 11 | |
| 12 | int proslic_debug_setting = SILABS_DEFAULT_DBG; |
| 13 | int proslic_channel_count = SILABS_MAX_CHANNELS; |
| 14 | |
| 15 | module_param(proslic_debug_setting, int, S_IRUSR | S_IWUSR |S_IRGRP | S_IWGRP); |
| 16 | MODULE_PARM_DESC(proslic_debug_setting, "debug mode bitmask, 1 = TRC, 2 = DBG, 4 = ERR"); |
| 17 | module_param(proslic_channel_count, int, S_IRUSR | S_IRGRP ); |
| 18 | MODULE_PARM_DESC(proslic_channel_count, "Number of actual channels on the platform"); |
| 19 | |
| 20 | /*****************************************************************************************************/ |
| 21 | |
| 22 | int init_module(void) |
| 23 | { |
| 24 | int rc; |
| 25 | |
| 26 | printk( KERN_INFO "ProSLIC API system services module loaded, version: %s\n", PROSLIC_SYS_SERVICES_VER); |
| 27 | printk( KERN_INFO "Debug = 0x%0x\n", proslic_debug_setting); |
| 28 | |
| 29 | if(proslic_channel_count > SILABS_MAX_CHANNELS) |
| 30 | { |
| 31 | printk( KERN_ERR "proslic_channel_count max is: %d, got: %d\n", SILABS_MAX_CHANNELS, proslic_channel_count); |
| 32 | return -EINVAL; |
| 33 | } |
| 34 | |
| 35 | rc = proslic_spi_setup(); |
| 36 | |
| 37 | if(rc == 0) |
| 38 | { |
| 39 | /* TODO: any other init we may want tot do here... */ |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | printk( KERN_ERR "proslic_spi_setup returned: %d\n", rc); |
| 44 | return rc; |
| 45 | } |
| 46 | |
| 47 | return 0; |
| 48 | |
| 49 | } |
| 50 | |
| 51 | void cleanup_module(void) |
| 52 | { |
| 53 | proslic_spi_shutdown(); |
| 54 | printk( KERN_INFO "ProSLIC API system services module unloaded.\n"); |
| 55 | } |
| 56 | |
| 57 | MODULE_DESCRIPTION(DRIVER_DESCRIPTION); |
| 58 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 59 | MODULE_LICENSE("Dual MPL/GPL"); |
| 60 | |
| 61 | EXPORT_SYMBOL(proslic_spi_if); |
| 62 | EXPORT_SYMBOL(proslic_timer_if); |
| 63 | EXPORT_SYMBOL(proslic_get_channel_count); |
| 64 | EXPORT_SYMBOL(proslic_get_device_type); |
| 65 | EXPORT_SYMBOL(proslic_get_hCtrl); |