1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-25 12:24:04 +02:00
openwrt-xburst/target/linux/xburst/files-2.6.27/drivers/misc/jz_tcsm.c
Mirko Vogt dc3d3f1c49 yet another patchset - 2.6.27
it's basically also provided by ingenic and nativly based on 2.6.27,
adjusted to fit into the OpenWrt-environment
2009-10-28 03:13:11 +08:00

133 lines
3.0 KiB
C

/*
* linux/drivers/misc/tcsm.c
*
* Virtual device driver with tricky appoach to manage TCSM
*
* Copyright (C) 2006 Ingenic Semiconductor Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/major.h>
#include <linux/string.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/miscdevice.h>
#include <linux/fs.h>
#include <linux/spinlock.h>
#include <asm/mipsregs.h>
#include <asm/mipsmtregs.h>
#include <asm/irq.h>
#include <asm/thread_info.h>
#include <asm/uaccess.h>
#include <asm/jzsoc.h>
MODULE_AUTHOR("Jianli Wei<jlwei@ingenic.cn>");
MODULE_DESCRIPTION("Virtual Driver of TCSM");
MODULE_LICENSE("GPL");
/*
* fops routines
*/
static int tcsm_open(struct inode *inode, struct file *filp);
static int tcsm_release(struct inode *inode, struct file *filp);
static ssize_t tcsm_read(struct file *filp, char *buf, size_t size, loff_t *l);
static ssize_t tcsm_write(struct file *filp, const char *buf, size_t size, loff_t *l);
static int tcsm_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
static struct file_operations tcsm_fops =
{
open: tcsm_open,
release: tcsm_release,
read: tcsm_read,
write: tcsm_write,
ioctl: tcsm_ioctl,
};
static int tcsm_open(struct inode *inode, struct file *filp)
{
struct pt_regs *info = task_pt_regs(current);
printk("pt_regs =%p\n", info);
printk("cp0 status=0x%08x\n", (unsigned int)info->cp0_status);
info->cp0_status &= ~0x10;
info->cp0_status |= 0x08000000; // a tricky
printk("cp0 status=0x%08x\n", (unsigned int)info->cp0_status);
return 0;
}
static int tcsm_release(struct inode *inode, struct file *filp)
{
struct pt_regs *info = task_pt_regs(current);
info->cp0_status |= 0x10;
info->cp0_status &= ~0x08000000; // a tricky
return 0;
}
static ssize_t tcsm_read(struct file *filp, char *buf, size_t size, loff_t *l)
{
printk("tcsm: read is not implemented\n");
return -1;
}
static ssize_t tcsm_write(struct file *filp, const char *buf, size_t size, loff_t *l)
{
printk("tcsm: write is not implemented\n");
return -1;
}
static int tcsm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
{
int ret = 0;
printk("tcsm: ioctl is not implemented\n");
return ret;
}
static struct miscdevice tcsm_dev = {
TCSM_MINOR,
"tcsm",
&tcsm_fops
};
/*
* Module init and exit
*/
static int __init tcsm_init(void)
{
int ret;
ret = misc_register(&tcsm_dev);
if (ret < 0) {
return ret;
}
printk("Virtual Driver of JZ TCSM registered\n");
return 0;
}
static void __exit tcsm_exit(void)
{
misc_deregister(&tcsm_dev);
}
module_init(tcsm_init);
module_exit(tcsm_exit);