Exemple #1
0
static void
power_debounce_timer_func(unsigned long junk)
{
    unsigned long flags;

    local_irq_save(flags);
    switch(isr_state) {
    case PB_IDLE:
        printk("Unexpected PB_IDLE\n");
        break;
    case PB_DEBOUNCE:
        if(!pxa_gpio_get_value(GHI270_GPIO0_KEY_nON)) {
            /* Power is still pressed */
            set_irq_type(gpio_to_irq(GHI270_GPIO0_KEY_nON), IRQT_RISING); /* Look for release */
            isr_state = PB_DOWN;
            mod_timer(&power_debounce_timer, jiffies + (pbto * HZ) / 10 + 2);
        } else {
            isr_state = PB_IDLE;
            set_irq_type(gpio_to_irq(GHI270_GPIO0_KEY_nON), IRQT_FALLING);
        }
        enable_irq(gpio_to_irq(GHI270_GPIO0_KEY_nON));
        break;
    case PB_DOWN:
        if(!pxa_gpio_get_value(GHI270_GPIO0_KEY_nON)) {
            /* Still down, so let's suspend. */
            if(time_after64(jiffies_64, off_jiffies64 + msecs_to_jiffies(1500))) {
                /* Prohibit a bunch of power key events to be queued. */
                off_jiffies64 = jiffies_64;
                input_report_key(keydev, KEY_POWER, 1);
                input_report_key(keydev, KEY_POWER, 0);
                input_sync(keydev);
            }
            PWM_PWDUTY0 = 1023;        /* Turn off the LCD light for feedback */
            isr_state = PB_DOWN_POWER_OFF;
        } else {
            /* It's no longer down, so be safe and don't do power off. */
            isr_state = PB_IDLE;
        }
        break;
    case PB_DOWN_POWER_OFF:
        printk("State error in pbto.\n");
        isr_state = PB_IDLE;
        break;
    }
    local_irq_restore(flags);
}
Exemple #2
0
static int ezpxa270_mci_get_ro( struct device *dev )
{
	int gpio;

	pxa_gpio_mode(GPIO1_MMC_WP_MD);
	gpio = pxa_gpio_get_value( GPIO1_MMC_WP );

	// Write Protect
	return gpio;
}
static int
update_params(void)
{
	int status;
	int retval = 1;
	static u64 first_failure = 0;

	if (!ltc4100_attached) return 0;

	down(&update_mutex);

	status = i2c_smbus_read_word_data(&client_ltc4100, 0x13);

	if (status != -1) {
		if (first_failure) {
			printk(KERN_DEBUG "Time between failures: %llu\n",
				jiffies_64 - first_failure);
			first_failure = 0;
		}

		last_update    = jiffies_64;
		onAC           = (status & (1 << 15)) ? 1 : 0;
		batteryPresent = (status & (1 << 14)) ? 1 : 0;

		if (machine_is_ghi270()) {
			batteryCharging =
				pxa_gpio_get_value(GHI270_H_GPIO26_CHGEN)?1:0;
		} else {
			batteryCharging =
				pxa_gpio_get_value(GHI270_HG_GPIO53_CHGEN)?1:0;
		}

		rsoc        = 0;
		voltage     = 0;
		temp        = 0;
		time        = 0;
		current_now = 0;

		if (batteryPresent && bq20z80_attached) {
			/* Only read the battery itself when it is there. */
			int tmp;
			tmp = i2c_smbus_read_word_data(&client_bq20z80, 0xd);
			if (tmp != -1) {
				/* Relative state of charge */
				pr_debug("RSOC: %d\n", tmp);
				rsoc = tmp;
			} else printk(KERN_ERR "rsoc fail\n");
			tmp = i2c_smbus_read_word_data(&client_bq20z80, 0x9);
			if (tmp != -1) {
				pr_debug("Voltage: %d\n", tmp);
				voltage = tmp;
			} else printk(KERN_ERR "voltage fail\n");
			tmp = i2c_smbus_read_word_data(&client_bq20z80, 0x8);
			if (tmp != -1) {
				pr_debug("Temperature: %d\n", tmp);
				temp = tmp;
			} else printk(KERN_ERR "temp fail\n");
			tmp = i2c_smbus_read_word_data(&client_bq20z80, 0x11);
			if (tmp != -1) {
				pr_debug("Time: %d\n", tmp);
				time = tmp;
			} else printk(KERN_ERR "time fail\n");
			tmp = i2c_smbus_read_word_data(&client_bq20z80, 0xa);
			if (tmp != -1) {
				pr_debug("Current: %d\n", tmp);
				current_now = -((short)tmp);
			} else printk(KERN_ERR "current fail\n");
		}
	} else {
		retval = 0;
		if (!first_failure) {
			/* There has been a problem with reading the LTC4100
			 * on the proto HG that I'm using.  Hopefully others
			 * will not have this problem.  The H does not, and
			 * the battery circuitry is the same.
			 */
			printk(KERN_DEBUG "First failure\n");
			first_failure = jiffies_64;
		}
	}

	up(&update_mutex);

	return retval;
}