|
@@ -38,12 +38,33 @@ struct cashd_device {
|
|
|
bool can_write;
|
|
bool can_write;
|
|
|
unsigned int ctl_status;
|
|
unsigned int ctl_status;
|
|
|
unsigned int in_status;
|
|
unsigned int in_status;
|
|
|
|
|
+ struct delayed_work delay_work1;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
static int cashd_major = 0;
|
|
static int cashd_major = 0;
|
|
|
static struct class *cashd_class = NULL;
|
|
static struct class *cashd_class = NULL;
|
|
|
static struct cashd_device *cashd_devices[MINOR_COUNT];
|
|
static struct cashd_device *cashd_devices[MINOR_COUNT];
|
|
|
|
|
|
|
|
|
|
+static void delay_work_func(struct work_struct *work)
|
|
|
|
|
+{
|
|
|
|
|
+ void __iomem *reg_base;
|
|
|
|
|
+ unsigned int value = 0;
|
|
|
|
|
+ struct delayed_work *dwork = to_delayed_work(work);
|
|
|
|
|
+ struct cashd_device *dev = container_of(dwork, struct cashd_device, delay_work1);
|
|
|
|
|
+ printk("%s %s %d\n", __FILE__, __func__, __LINE__);
|
|
|
|
|
+ if(dev->dev_minor == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ reg_base = ioremap(GPIO0_CTL, 0x1000);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(dev->dev_minor == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ reg_base = ioremap(GPIO1_CTL, 0x1000);
|
|
|
|
|
+ }
|
|
|
|
|
+ value = readl(reg_base);
|
|
|
|
|
+ value &= 0xfffffffe;
|
|
|
|
|
+ writel(value, reg_base);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static int cashd_open(struct inode *inode, struct file *filp)
|
|
static int cashd_open(struct inode *inode, struct file *filp)
|
|
|
{
|
|
{
|
|
|
struct cashd_device *dev;
|
|
struct cashd_device *dev;
|
|
@@ -141,6 +162,7 @@ static ssize_t cashd_write(struct file *filp, const char __user *buf,
|
|
|
ret = copy_from_user(dev->buffer, buf, count);
|
|
ret = copy_from_user(dev->buffer, buf, count);
|
|
|
if(dev->buffer[0] == 'o' || dev->buffer[0] == 'O')
|
|
if(dev->buffer[0] == 'o' || dev->buffer[0] == 'O')
|
|
|
{
|
|
{
|
|
|
|
|
+ printk("%s %s %d minor=%d\n", __FILE__, __func__, __LINE__, dev->dev_minor);
|
|
|
if(dev->dev_minor == 0)
|
|
if(dev->dev_minor == 0)
|
|
|
{
|
|
{
|
|
|
reg_base = ioremap(GPIO0_CTL, 0x1000);
|
|
reg_base = ioremap(GPIO0_CTL, 0x1000);
|
|
@@ -152,6 +174,7 @@ static ssize_t cashd_write(struct file *filp, const char __user *buf,
|
|
|
value = readl(reg_base);
|
|
value = readl(reg_base);
|
|
|
value |= 0x1;
|
|
value |= 0x1;
|
|
|
writel(value, reg_base);
|
|
writel(value, reg_base);
|
|
|
|
|
+ schedule_delayed_work(&dev->delay_work1, msecs_to_jiffies(1000));
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -215,6 +238,7 @@ static int __init cashd_init_device(struct cashd_device *dev, int minor)
|
|
|
init_waitqueue_head(&dev->write_wait);
|
|
init_waitqueue_head(&dev->write_wait);
|
|
|
|
|
|
|
|
mutex_init(&dev->lock);
|
|
mutex_init(&dev->lock);
|
|
|
|
|
+ INIT_DELAYED_WORK(&dev->delay_work1, delay_work_func);
|
|
|
|
|
|
|
|
cdev_init(&dev->cdev, &cashd_fops);
|
|
cdev_init(&dev->cdev, &cashd_fops);
|
|
|
dev->cdev.owner = THIS_MODULE;
|
|
dev->cdev.owner = THIS_MODULE;
|