#include <asm/arch/gpio.h>
#include <asm/arch/mux.h>
+#define DRIVER_NAME "twl4030"
+
+#define pr_err(fmt, arg...) printk(KERN_ERR DRIVER_NAME ": " fmt, ##arg);
+
/**** Macro Definitions */
#define TWL_CLIENT_STRING "TWL4030-ID"
#define TWL_CLIENT_USED 1
struct i2c_msg *msg;
if (unlikely(mod_no > TWL4030_MODULE_LAST)) {
- printk(KERN_ERR "TWL4030: Invalid module Number\n");
+ pr_err("Invalid module Number\n");
return -EPERM;
}
sid = twl4030_map[mod_no].sid;
client = &(twl4030_modules[sid]);
if (unlikely(client->inuse != TWL_CLIENT_USED)) {
- printk(KERN_ERR
- "TWL4030: I2C Client[%d] is not initialized[%d]\n",
- sid, __LINE__);
+ pr_err("I2C Client[%d] is not initialized[%d]\n",
+ sid,__LINE__);
return -EPERM;
}
down(&(client->xfer_lock));
int sid;
struct twl4030_client *client;
struct i2c_msg *msg;
+
if (unlikely(mod_no > TWL4030_MODULE_LAST)) {
- printk(KERN_ERR "TWL4030: Invalid module Number\n");
+ pr_err("Invalid module Number\n");
return -EPERM;
}
sid = twl4030_map[mod_no].sid;
client = &(twl4030_modules[sid]);
if (unlikely(client->inuse != TWL_CLIENT_USED)) {
- printk(KERN_ERR
- "TWL4030: I2C Client[%d] is not initialized[%d]\n",
- sid, __LINE__);
+ pr_err("I2C Client[%d] is not initialized[%d]\n", sid,
+ __LINE__);
return -EPERM;
}
down(&(client->xfer_lock));
int twl4030_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
{
int ret;
+
/* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */
u8 temp_buffer[2] = { 0 };
/* offset 1 contains the data */
int twl4030_i2c_read_u8(u8 mod_no, u8 * value, u8 reg)
{
int ret = 0;
+
ret = twl4030_i2c_read(mod_no, value, reg, 1);
return ret;
}
{
int err = 0;
struct twl4030_client *client;
+
if (unlikely(sid >= TWL4030_NUM_SLAVES)) {
- printk(KERN_ERR "TWL4030: sid[%d] >MOD_LAST[%d]\n", sid,
- TWL4030_NUM_SLAVES);
+ pr_err("sid[%d] > MOD_LAST[%d]\n", sid, TWL4030_NUM_SLAVES);
return -EPERM;
}
/* Check basic functionality */
if (!(err = i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA |
I2C_FUNC_SMBUS_WRITE_BYTE))) {
- printk(KERN_WARNING
- "TWL4030: SlaveID=%d functionality check failed\n", sid);
+ pr_err("SlaveID=%d functionality check failed\n", sid);
return err;
}
client = &(twl4030_modules[sid]);
if (unlikely(client->inuse)) {
- printk(KERN_ERR "TWL4030: Client is already in Use.....\n");
- printk("%s[ID=0x%x] NOT attached to I2c Adapter %s\n",
- client->client_name, client->address, adapter->name);
+ pr_err("Client %s is already in use\n", client->client_name);
return -EPERM;
}
memcpy(&(client->client.name), client->client_name,
sizeof(TWL_CLIENT_STRING) + 1);
- printk("TWL4030: TRY attach Slave %s on Adapter %s[%d][%x]\n",
- client->client_name, adapter->name, err, err);
- if ((err = i2c_attach_client(&(client->client))))
- printk(KERN_WARNING
- "TWL4030: Couldn't attach Slave %s on Adapter "
- "%s[%d][%x]\n",
- client->client_name, adapter->name, err, err);
- else {
+
+ pr_info("TWL4030: TRY attach Slave %s on Adapter %s [%x]\n",
+ client->client_name, adapter->name, err);
+
+ if ((err = i2c_attach_client(&(client->client)))) {
+ pr_err("Couldn't attach Slave %s on Adapter"
+ "%s [%x]\n", client->client_name, adapter->name, err);
+ } else {
client->inuse = TWL_CLIENT_USED;
init_MUTEX(&client->xfer_lock);
}
+
return err;
}
int i;
int ret = 0;
static int twl_i2c_adapter = 1;
+
for (i = 0; i < TWL4030_NUM_SLAVES; i++) {
/* Check if I need to hook on to this adapter or not */
if (twl4030_modules[i].adapter_index == twl_i2c_adapter) {
return 0;
free_client:
- printk(KERN_ERR
- "TWL4030: TWL_CLIENT(Idx=%d] REGISTRATION FAILED=%d[0x%x]\n", i,
- ret, ret);
+ pr_err("TWL_CLIENT(Idx=%d] registration failed[0x%x]\n",i,ret);
/* ignore current slave..it never got registered */
i--;
{
int err;
if ((err = i2c_detach_client(iclient))) {
- printk(KERN_ERR
- "TWL4030: Client deregistration failed, client not detached.\n");
+ pr_err("Client detach failed\n");
return err;
}
return 0;
thread = kthread_create(twl4030_irq_thread, (void *)irq,
"twl4030 irq %d", irq);
if (!thread)
- printk(KERN_ERR "%s: could not create twl4030 irq %d thread!\n",
- __FUNCTION__, irq);
+ pr_err("%s: could not create twl4030 irq %d thread!\n",
+ __FUNCTION__,irq);
return thread;
}
static int protect_pm_master(void)
{
int e = 0;
+
e = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_LOCK,
R_PROTECT_KEY);
return e;
static int unprotect_pm_master(void)
{
int e = 0;
+
e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK1,
R_PROTECT_KEY);
e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK2,
int i = 0;
int res = 0;
int line = 0;
+
/*
* We end up with interrupts from other modules before
* they get a chance to handle them...
irq_exit_path:
if (res)
- printk(KERN_ERR
- "TWL4030: Unable to register interrupt "
- "subsystem[%d][%d]\n", res, line);
+ pr_err("Unable to register interrupt subsystem[%d][%d]\n",
+ res,line);
}
static int __init twl4030_init(void)
{
int res;
- if ((res = i2c_register_driver(THIS_MODULE, &twl4030_driver))) {
+
+ if ((res = i2c_add_driver(&twl4030_driver))) {
printk(KERN_ERR "TWL4030: Driver registration failed \n");
return res;
}
- printk(KERN_INFO "TWL4030: Driver registration complete.\n");
- return res;
+
+ pr_info(KERN_INFO "TWL4030: Driver registration complete.\n");
+
+ return 0;
}
static void __exit twl4030_exit(void)