2  * via-pmu event device for reporting some events that come through the PMU
 
   4  * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
 
   6  * This program is free software; you can redistribute it and/or modify
 
   7  * it under the terms of the GNU General Public License as published by
 
   8  * the Free Software Foundation; either version 2 of the License, or
 
   9  * (at your option) any later version.
 
  11  * This program is distributed in the hope that it will be useful, but
 
  12  * WITHOUT ANY WARRANTY; without even the implied warranty of
 
  13  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 
  14  * NON INFRINGEMENT.  See the GNU General Public License for more
 
  17  * You should have received a copy of the GNU General Public License
 
  18  * along with this program; if not, write to the Free Software
 
  19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
  23 #include <linux/input.h>
 
  24 #include <linux/adb.h>
 
  25 #include <linux/pmu.h>
 
  26 #include "via-pmu-event.h"
 
  28 static struct input_dev *pmu_input_dev;
 
  30 static int __init via_pmu_event_init(void)
 
  34         /* do other models report button/lid status? */
 
  35         if (pmu_get_model() != PMU_KEYLARGO_BASED)
 
  38         pmu_input_dev = input_allocate_device();
 
  42         pmu_input_dev->name = "PMU";
 
  43         pmu_input_dev->id.bustype = BUS_HOST;
 
  44         pmu_input_dev->id.vendor = 0x0001;
 
  45         pmu_input_dev->id.product = 0x0001;
 
  46         pmu_input_dev->id.version = 0x0100;
 
  48         set_bit(EV_KEY, pmu_input_dev->evbit);
 
  49         set_bit(EV_SW, pmu_input_dev->evbit);
 
  50         set_bit(KEY_POWER, pmu_input_dev->keybit);
 
  51         set_bit(SW_LID, pmu_input_dev->swbit);
 
  53         err = input_register_device(pmu_input_dev);
 
  55                 input_free_device(pmu_input_dev);
 
  59 void via_pmu_event(int key, int down)
 
  62         if (unlikely(!pmu_input_dev))
 
  67                 input_report_key(pmu_input_dev, KEY_POWER, down);
 
  70                 input_report_switch(pmu_input_dev, SW_LID, down);
 
  73                 /* no such key handled */
 
  77         input_sync(pmu_input_dev);
 
  80 late_initcall(via_pmu_event_init);