📄 liftmon_snowcon_mediaengine.c.txt
字号:
int rv = 0;
/* Create the trailblazer /proc entry */
tb_dir = proc_mkdir("trailblazer", NULL);
if(tb_dir == NULL) {
rv = -ENOMEM;
goto out;
}
tb_dir->owner = THIS_MODULE;
/* Create liftacmains and make it readable by all - 0444 */
liftacmains_file = create_proc_entry("liftacmains", 0444, tb_dir);
if(liftacmains_file == NULL) {
rv = -ENOMEM;
goto no_liftacmains;
}
liftacmains_data.mask = LIFTACMAINS;
liftacmains_file->data = &liftacmains_data;
liftacmains_file->read_proc = &proc_read_liftmon;
liftacmains_file->write_proc = NULL;
liftacmains_file->owner = THIS_MODULE;
/* Create liftmotorcontroller and make it readable by all - 0444 */
liftmotorcontroller_file = create_proc_entry("liftmotorcontroller",
0444, tb_dir);
if(liftmotorcontroller_file == NULL) {
rv = -ENOMEM;
goto no_liftmotorcontroller;
}
liftmotorcontroller_data.mask = LIFTMOTORCONTROLLER;
liftmotorcontroller_file->data = &liftmotorcontroller_data;
liftmotorcontroller_file->read_proc = &proc_read_liftmon;
liftmotorcontroller_file->write_proc = NULL;
liftmotorcontroller_file->owner = THIS_MODULE;
/* Create liftslowspeed and make it readable by all - 0444 */
liftslowspeed_file = create_proc_entry("liftslowspeed", 0444, tb_dir);
if(liftslowspeed_file == NULL) {
rv = -ENOMEM;
goto no_liftslowspeed;
}
liftslowspeed_data.mask = LIFTSLOWSPEED;
liftslowspeed_file->data = &liftslowspeed_data;
liftslowspeed_file->read_proc = &proc_read_liftmon;
liftslowspeed_file->write_proc = NULL;
liftslowspeed_file->owner = THIS_MODULE;
/* Create lifthighspeed and make it readable by all - 0444 */
lifthighspeed_file = create_proc_entry("lifthighspeed", 0444, tb_dir);
if(lifthighspeed_file == NULL) {
rv = -ENOMEM;
goto no_lifthighspeed;
}
lifthighspeed_data.mask = LIFTHIGHSPEED;
lifthighspeed_file->data = &lifthighspeed_data;
lifthighspeed_file->read_proc = &proc_read_liftmon;
lifthighspeed_file->write_proc = NULL;
lifthighspeed_file->owner = THIS_MODULE;
/* Create liftoperatorswitchbase and make it readable by all - 0444 */
liftoperatorswitchbase_file = create_proc_entry("liftoperatorswitchbase",
0444, tb_dir);
if(liftoperatorswitchbase_file == NULL) {
rv = -ENOMEM;
goto no_liftoperatorswitchbase;
}
liftoperatorswitchbase_data.mask = LIFTOPERATORSWITCHBASE;
liftoperatorswitchbase_file->data = &liftoperatorswitchbase_data;
liftoperatorswitchbase_file->read_proc = &proc_read_liftmon;
liftoperatorswitchbase_file->write_proc = NULL;
liftoperatorswitchbase_file->owner = THIS_MODULE;
/* Create liftoperatorswitchtop and make it readable by all - 0444 */
liftoperatorswitchtop_file = create_proc_entry("liftoperatorswitchtop",
0444, tb_dir);
if(liftoperatorswitchtop_file == NULL) {
rv = -ENOMEM;
goto no_liftoperatorswitchtop;
}
liftoperatorswitchtop_data.mask = LIFTOPERATORSWITCHTOP;
liftoperatorswitchtop_file->data = &liftoperatorswitchtop_data;
liftoperatorswitchtop_file->read_proc = &proc_read_liftmon;
liftoperatorswitchtop_file->write_proc = NULL;
liftoperatorswitchtop_file->owner = THIS_MODULE;
/* Create snowwatervalve1 and make it root writeable, readable by all-0644 */
snowwatervalve1_file = create_proc_entry("snowwatervalve1", 0644, tb_dir);
if(snowwatervalve1_file == NULL) {
rv = -ENOMEM;
goto no_snowwatervalve1;
}
snowwatervalve1_data.mask = SNOWWATERVALVE1;
snowwatervalve1_file->data = &snowwatervalve1_data;
snowwatervalve1_file->read_proc = &proc_read_snowcondata;
snowwatervalve1_file->write_proc = &proc_write_snowcondata;
snowwatervalve1_file->owner = THIS_MODULE;
/* Create snowwatervalve2 and make it root writeable, readable by all-0644 */
snowwatervalve2_file = create_proc_entry("snowwatervalve2", 0644, tb_dir);
if(snowwatervalve2_file == NULL) {
rv = -ENOMEM;
goto no_snowwatervalve2;
}
snowwatervalve2_data.mask = SNOWWATERVALVE2;
snowwatervalve2_file->data = &snowwatervalve2_data;
snowwatervalve2_file->read_proc = &proc_read_snowcondata;
snowwatervalve2_file->write_proc = &proc_write_snowcondata;
snowwatervalve2_file->owner = THIS_MODULE;
/* Create snowwatervalve3 and make it root writeable, readable by all-0644 */
snowwatervalve3_file = create_proc_entry("snowwatervalve3", 0644, tb_dir);
if(snowwatervalve3_file == NULL) {
rv = -ENOMEM;
goto no_snowwatervalve3;
}
snowwatervalve3_data.mask = SNOWWATERVALVE3;
snowwatervalve3_file->data = &snowwatervalve3_data;
snowwatervalve3_file->read_proc = &proc_read_snowcondata;
snowwatervalve3_file->write_proc = &proc_write_snowcondata;
snowwatervalve3_file->owner = THIS_MODULE;
/* Create snowheater1 and make it root writeable, readable by all-0644 */
snowheater1_file = create_proc_entry("snowheater1", 0644, tb_dir);
if(snowheater1_file == NULL) {
rv = -ENOMEM;
goto no_snowheater1;
}
snowheater1_data.mask = SNOWHEATER1;
snowheater1_file->data = &snowheater1_data;
snowheater1_file->read_proc = &proc_read_snowcondata;
snowheater1_file->write_proc = &proc_write_snowcondata;
snowheater1_file->owner = THIS_MODULE;
/* setting up the memory controller to run slowly with /CS5 */
/* get the remapped memory controller base address register */
mem_base = ioremap_nocache(MEMBASE, MEMLENGTH);
printk("mem_base = 0x%08X\n",mem_base);
/* we need to preserve the other bits in msc2 */
msc2 = readl(mem_base + MSC2_OFFSET);
printk("MSC2 = 0x%08X\n",msc2);
/* msc2 is for cs5 and cs4, need to mask off the cs3 part */
/* 0xFFF5, non burst SRAM variable, 16 bits, long delays */
writel((msc2 & 0x0000FFFF) | 0xFFF50000, mem_base + MSC2_OFFSET);
/* read back the new msc2 value and print it */
msc2 = readl(mem_base + MSC2_OFFSET);
printk("MSC2 = 0x%08X\n",msc2);
/* get the remapped GPIO controller base address register */
io_base = ioremap_nocache(EXPANSIONPORT, EXPANSIONPORTLEN);
printk("io_base = 0x%08X\n",io_base);
/* set up the I/O controller for GPIO14 output */
/* get the remapped GPIO controller base address register */
gpio_base = ioremap_nocache(GPIO, GPIOLEN);
printk("gpio_base = 0x%08X\n",gpio_base);
/* we need to preserve the other bits in gpdr */
gpdr = readl(gpio_base + GPDR_OFFSET);
printk("GPDR = 0x%08X\n",gpdr);
/* we need to preserve the other bits in gafr */
gafr = readl(gpio_base + GAFR_OFFSET);
printk("GAFR = 0x%08X\n",gafr);
/* initialize snowcondata to 0xFF, all output modules off */
/* output modules invert */
snowcondata = 0xFF;
writeb(snowcondata, io_base); /* turn off all output modules */
writel(GPIO14 , gpio_base + GPSR_OFFSET); /* set GPIO14 */
writel(gpdr | GPIO_GPIO14, gpio_base + GPDR_OFFSET); /* set GPIO14 output*/
writel(GPIO14 , gpio_base + GPCR_OFFSET); /* clear GPIO14 */
/* clearing GPIO14 turns on output buffer controlling output modules */
/* everything initialized */
printk(KERN_INFO "%s %s initialized\n",MODULE_NAME, MODULE_VERSION);
return 0;
/* this removes /proc entries if we have an error along the way */
no_snowheater1:
remove_proc_entry("snowwatervalve3", tb_dir);
no_snowwatervalve3:
remove_proc_entry("snowwatervalve2", tb_dir);
no_snowwatervalve2:
remove_proc_entry("snowwatervalve1", tb_dir);
no_snowwatervalve1:
remove_proc_entry("liftoperatorswitchtop", tb_dir);
no_liftoperatorswitchtop:
remove_proc_entry("liftoperatorswitchbase", tb_dir);
no_liftoperatorswitchbase:
remove_proc_entry("lifthighspeed", tb_dir);
no_lifthighspeed:
remove_proc_entry("liftslowspeed", tb_dir);
no_liftslowspeed:
remove_proc_entry("liftmotorcontroller", tb_dir);
no_liftmotorcontroller:
remove_proc_entry("liftacmains", tb_dir);
no_liftacmains:
remove_proc_entry("trailblazer", NULL);
out:
return rv;
}
/* exit - cleanup_liftmon_snowcon
* cleanup_liftmon_snowcon turns off the output modules and
* deasserts the OUTPUT_ENABLE signal. It removes the /proc entry files
* prints a message to the system log.
*/
static void __exit cleanup_liftmon_snowcon(void)
{
writel(gpdr, gpio_base + GPDR_OFFSET); /* restore gpdr */
writel(gafr, gpio_base + GAFR_OFFSET); /* restore gafr */
writel(msc2, mem_base + MSC2_OFFSET); /* restore msc2 */
/* release the ioremaps */
iounmap(mem_base);
iounmap(gpio_base);
iounmap(io_base);
/* removing the /proc entries */
remove_proc_entry("liftacmains", tb_dir);
remove_proc_entry("liftmotorcontroller", tb_dir);
remove_proc_entry("liftslowspeed", tb_dir);
remove_proc_entry("lifthighspeed", tb_dir);
remove_proc_entry("liftoperatorswitchbase", tb_dir);
remove_proc_entry("liftoperatorswitchtop", tb_dir);
remove_proc_entry("snowwatervalve1", tb_dir);
remove_proc_entry("snowwatervalve2", tb_dir);
remove_proc_entry("snowwatervalve3", tb_dir);
remove_proc_entry("snowheater1", tb_dir);
remove_proc_entry("trailblazer", NULL);
printk(KERN_INFO "%s %s removed\n", MODULE_NAME, MODULE_VERSION);
}
module_init(init_liftmon_snowcon);
module_exit(cleanup_liftmon_snowcon);
MODULE_AUTHOR("Craig Hollabaugh");
MODULE_DESCRIPTION(
"Trailblazer Lift Monitor and Snowmaking Control for MediaEngine");
EXPORT_NO_SYMBOLS;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -