* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/suspend.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
-#include <linux/mutex.h>
#include <asm/irq.h>
#include <asm/mach-types.h>
/*-------------------------------------------------------------------------*/
#define DRIVER_VERSION "2 May 2005"
-#define DRIVER_NAME (tps65010_driver.driver.name)
+#define DRIVER_NAME (tps65010_driver.name)
MODULE_DESCRIPTION("TPS6501x Power Management Driver");
MODULE_LICENSE("GPL");
static unsigned short normal_i2c[] = { 0x48, /* 0x49, */ I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
I2C_CLIENT_INSMOD;
struct tps65010 {
struct i2c_client client;
- struct mutex lock;
+ struct semaphore lock;
int irq;
struct work_struct work;
struct dentry *file;
/* not currently tracking GPIO state */
};
-#define POWER_POLL_DELAY msecs_to_jiffies(5000)
+#define POWER_POLL_DELAY msecs_to_jiffies(800)
/*-------------------------------------------------------------------------*/
seq_printf(s, "driver %s\nversion %s\nchip %s\n\n",
DRIVER_NAME, DRIVER_VERSION, chip);
- mutex_lock(&tps->lock);
+ down(&tps->lock);
/* FIXME how can we tell whether a battery is present?
* likely involves a charge gauging chip (like BQ26501).
(v2 & (1 << (4 + i))) ? "rising" : "falling");
}
- mutex_unlock(&tps->lock);
+ up(&tps->lock);
return 0;
}
static int dbg_tps_open(struct inode *inode, struct file *file)
{
- return single_open(file, dbg_show, inode->i_private);
+ return single_open(file, dbg_show, inode->u.generic_ip);
}
static struct file_operations debug_fops = {
{
struct tps65010 *tps = _tps;
- mutex_lock(&tps->lock);
+ down(&tps->lock);
tps65010_interrupt(tps);
if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags))
enable_irq(tps->irq);
- mutex_unlock(&tps->lock);
+ up(&tps->lock);
}
static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs)
if (!tps)
return 0;
- mutex_init(&tps->lock);
+ init_MUTEX(&tps->lock);
INIT_WORK(&tps->work, tps65010_work, tps);
tps->irq = -1;
tps->client.addr = address;
goto fail1;
}
- /* the IRQ is active low, but many gpio lines can't support that
- * so this driver can use falling-edge triggers instead.
- */
- irqflags = IRQF_SAMPLE_RANDOM;
#ifdef CONFIG_ARM
+ irqflags = SA_SAMPLE_RANDOM | SA_TRIGGER_LOW;
if (machine_is_omap_h2()) {
tps->model = TPS65010;
omap_cfg_reg(W4_GPIO58);
tps->irq = OMAP_GPIO_IRQ(58);
omap_request_gpio(58);
omap_set_gpio_direction(58, 1);
- irqflags |= IRQF_TRIGGER_FALLING;
+ irqflags |= SA_TRIGGER_FALLING;
}
if (machine_is_omap_osk()) {
tps->model = TPS65010;
tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1));
omap_request_gpio(OMAP_MPUIO(1));
omap_set_gpio_direction(OMAP_MPUIO(1), 1);
- irqflags |= IRQF_TRIGGER_FALLING;
+ irqflags |= SA_TRIGGER_FALLING;
}
if (machine_is_omap_h3()) {
tps->model = TPS65013;
// FIXME set up this board's IRQ ...
}
+#else
+ irqflags = SA_SAMPLE_RANDOM;
#endif
if (tps->irq > 0) {
if ((gpio < GPIO1) || (gpio > GPIO4))
return -EINVAL;
- mutex_lock(&the_tps->lock);
+ down(&the_tps->lock);
defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO);
gpio, value ? "high" : "low",
i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO));
- mutex_unlock(&the_tps->lock);
+ up(&the_tps->lock);
return status;
}
EXPORT_SYMBOL(tps65010_set_gpio_out_value);
led = LED2;
}
- mutex_lock(&the_tps->lock);
+ down(&the_tps->lock);
pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led,
i2c_smbus_read_byte_data(&the_tps->client,
default:
printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n",
DRIVER_NAME);
- mutex_unlock(&the_tps->lock);
+ up(&the_tps->lock);
return -EINVAL;
}
if (status != 0) {
printk(KERN_ERR "%s: Failed to write led%i_on register\n",
DRIVER_NAME, led);
- mutex_unlock(&the_tps->lock);
+ up(&the_tps->lock);
return status;
}
if (status != 0) {
printk(KERN_ERR "%s: Failed to write led%i_per register\n",
DRIVER_NAME, led);
- mutex_unlock(&the_tps->lock);
+ up(&the_tps->lock);
return status;
}
i2c_smbus_read_byte_data(&the_tps->client,
TPS_LED1_PER + offs));
- mutex_unlock(&the_tps->lock);
+ up(&the_tps->lock);
return status;
}
if (!the_tps)
return -ENODEV;
- mutex_lock(&the_tps->lock);
+ down(&the_tps->lock);
vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2);
vdcdc2 &= ~(1 << 1);
pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off");
- mutex_unlock(&the_tps->lock);
+ up(&the_tps->lock);
return status;
}
EXPORT_SYMBOL(tps65010_set_vib);
if (!the_tps)
return -ENODEV;
- mutex_lock(&the_tps->lock);
+ down(&the_tps->lock);
pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME,
mode ? "enable" : "disable",
pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
- mutex_unlock(&the_tps->lock);
+ up(&the_tps->lock);
return status;
}
if (!the_tps)
return -ENODEV;
- mutex_lock(&the_tps->lock);
+ down(&the_tps->lock);
pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
- mutex_unlock(&the_tps->lock);
+ up(&the_tps->lock);
return status;
}
if (!the_tps || the_tps->por)
return -ENODEV;
- mutex_lock(&the_tps->lock);
+ down(&the_tps->lock);
pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n",
DRIVER_NAME,
if (status != 0) {
printk(KERN_ERR "%s: Failed to write chconfig register\n",
DRIVER_NAME);
- mutex_unlock(&the_tps->lock);
+ up(&the_tps->lock);
return status;
}
pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
- mutex_unlock(&the_tps->lock);
+ up(&the_tps->lock);
return status;
}