Ver código fonte

1、更新cash驱动。2、屏蔽power驱动的打印

2 arquivos alterados com 27 adições e 3 exclusões
  1. 24 0
      cash_drawers.c
  2. 3 3
      power.c

+ 24 - 0
cash_drawers.c

@@ -38,12 +38,33 @@ struct cashd_device {
     bool can_write;
     unsigned int ctl_status;
     unsigned int in_status;
+    struct delayed_work delay_work1;
 };
 
 static int cashd_major = 0;
 static struct class *cashd_class = NULL;
 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)
 {
     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);
     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)
         {
             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 |= 0x1;
         writel(value, reg_base);
+        schedule_delayed_work(&dev->delay_work1, msecs_to_jiffies(1000));
     }
     else
     {
@@ -215,6 +238,7 @@ static int __init cashd_init_device(struct cashd_device *dev, int minor)
     init_waitqueue_head(&dev->write_wait);
     
     mutex_init(&dev->lock);
+    INIT_DELAYED_WORK(&dev->delay_work1, delay_work_func);
     
     cdev_init(&dev->cdev, &cashd_fops);
     dev->cdev.owner = THIS_MODULE;

+ 3 - 3
power.c

@@ -117,7 +117,7 @@ uint8_t ac_present(void) //read GPIO of DC IN
     if (oem_ec_read_ram(2, 0x36, &val) < 0)
         return 0;
 
-    printk(" AC state is : %d\n", (val  & 0x03) ? 1 : 0);
+    // printk(" AC state is : %d\n", (val  & 0x03) ? 1 : 0);
     return (val & 0x03) ? 1 : 0;
 }
 
@@ -127,7 +127,7 @@ uint8_t soft_rest_btn(void)//read GPIO of btn SW_HRST1
     if (oem_ec_read_ram(2, 0x34, &val) < 0)
         return 0;
 
-    printk(" btn state is : %d\n", (val & 0x01) ? 1 : 0);
+    // printk(" btn state is : %d\n", (val & 0x01) ? 1 : 0);
     return (val & 0x01) ? 1 : 0;
 }
 
@@ -286,7 +286,7 @@ static void delay_work_func(struct work_struct *work)
         chardev_dev->data_len = 1;
         wake_up_interruptible(&chardev_dev->read_queue);
     }
-    printk("ac_flag = %d, rst_flag = %d\n", ac_flag, rst_flag);
+    // printk("ac_flag = %d, rst_flag = %d\n", ac_flag, rst_flag);
 	schedule_delayed_work(&chardev_dev->delay_work1, msecs_to_jiffies(500));
 }