Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 296896
b: refs/heads/master
c: ec1a07b
h: refs/heads/master
v: v3
  • Loading branch information
Benoit Cousson authored and Samuel Ortiz committed Mar 22, 2012
1 parent ddf26a4 commit 51838d5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 46 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5a903090e7aa561901b7f052eb744b480d6126d4
refs/heads/master: ec1a07b3440cc28946a77a974c21570bbef6ffa1
33 changes: 19 additions & 14 deletions trunk/drivers/mfd/twl-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1178,17 +1178,15 @@ static int twl_remove(struct i2c_client *client)
return 0;
}

/* NOTE: this driver only handles a single twl4030/tps659x0 chip */
/* NOTE: This driver only handles a single twl4030/tps659x0 chip */
static int __devinit
twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
int irq_base;
int status;
unsigned i;
struct twl4030_platform_data *pdata = client->dev.platform_data;
struct device_node *node = client->dev.of_node;
u8 temp;
int ret = 0;
int irq_base = 0;
int status;
unsigned i;

if (node && !pdata) {
/*
Expand Down Expand Up @@ -1218,12 +1216,12 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
}

for (i = 0; i < TWL_NUM_SLAVES; i++) {
struct twl_client *twl = &twl_modules[i];
struct twl_client *twl = &twl_modules[i];

twl->address = client->addr + i;
if (i == 0)
if (i == 0) {
twl->client = client;
else {
} else {
twl->client = i2c_new_dummy(client->adapter,
twl->address);
if (!twl->client) {
Expand All @@ -1235,7 +1233,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
}
mutex_init(&twl->xfer_lock);
}

inuse = true;

if ((id->driver_data) & TWL6030_CLASS) {
twl_id = TWL6030_CLASS_ID;
twl_map = &twl6030_map[0];
Expand All @@ -1249,8 +1249,8 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)

/* read TWL IDCODE Register */
if (twl_id == TWL4030_CLASS_ID) {
ret = twl_read_idcode_register();
WARN(ret < 0, "Error: reading twl_idcode register value\n");
status = twl_read_idcode_register();
WARN(status < 0, "Error: reading twl_idcode register value\n");
}

/* load power event scripts */
Expand All @@ -1272,18 +1272,22 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
}
}

/* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface.
/*
* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface.
* Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0,
* SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0.
*/

if (twl_class_is_4030()) {
u8 temp;

twl_i2c_read_u8(TWL4030_MODULE_INTBR, &temp, REG_GPPUPDCTR1);
temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \
I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);
I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);
twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
}

status = -ENODEV;

if (node)
status = of_platform_populate(node, NULL, NULL, &client->dev);
if (status)
Expand All @@ -1292,6 +1296,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
fail:
if (status < 0)
twl_remove(client);

return status;
}

Expand Down
19 changes: 8 additions & 11 deletions trunk/drivers/mfd/twl4030-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/slab.h>

#include <linux/of.h>
#include <linux/irqdomain.h>
#include <linux/i2c/twl.h>
Expand Down Expand Up @@ -639,14 +638,14 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base)
int status = -EINVAL;

/* only support modules with standard clear-on-read for now */
for (sih_mod = 0, sih = sih_modules;
sih_mod < nr_sih_modules;
for (sih_mod = 0, sih = sih_modules; sih_mod < nr_sih_modules;
sih_mod++, sih++) {
if (sih->module == module && sih->set_cor) {
status = 0;
break;
}
}

if (status < 0)
return status;

Expand Down Expand Up @@ -676,7 +675,7 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base)
status = request_threaded_irq(irq, NULL, handle_twl4030_sih, 0,
agent->irq_name ?: sih->name, NULL);

pr_info("twl4030: %s (irq %d) chaining IRQs %d..%d\n", sih->name,
dev_info(dev, "%s (irq %d) chaining IRQs %d..%d\n", sih->name,
irq, irq_base, irq_base + i - 1);

return status < 0 ? status : irq_base;
Expand All @@ -692,12 +691,10 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base)
int twl4030_init_irq(struct device *dev, int irq_num)
{
static struct irq_chip twl4030_irq_chip;
int status, i;
int irq_base, irq_end, nr_irqs;
struct device_node *node = dev->of_node;

int status;
int i;

/*
* TWL core and pwr interrupts must be contiguous because
* the hwirqs numbers are defined contiguously from 1 to 15.
Expand Down Expand Up @@ -727,7 +724,7 @@ int twl4030_init_irq(struct device *dev, int irq_num)
twl4030_irq_base = irq_base;

/*
* install an irq handler for each of the SIH modules;
* Install an irq handler for each of the SIH modules;
* clone dummy irq_chip since PIH can't *do* anything
*/
twl4030_irq_chip = dummy_irq_chip;
Expand All @@ -742,13 +739,13 @@ int twl4030_init_irq(struct device *dev, int irq_num)
activate_irq(i);
}

pr_info("twl4030: %s (irq %d) chaining IRQs %d..%d\n", "PIH",
dev_info(dev, "%s (irq %d) chaining IRQs %d..%d\n", "PIH",
irq_num, irq_base, irq_end);

/* ... and the PWR_INT module ... */
status = twl4030_sih_setup(dev, TWL4030_MODULE_INT, irq_end);
if (status < 0) {
pr_err("twl4030: sih_setup PWR INT --> %d\n", status);
dev_err(dev, "sih_setup PWR INT --> %d\n", status);
goto fail;
}

Expand All @@ -757,7 +754,7 @@ int twl4030_init_irq(struct device *dev, int irq_num)
IRQF_ONESHOT,
"TWL4030-PIH", NULL);
if (status < 0) {
pr_err("twl4030: could not claim irq%d: %d\n", irq_num, status);
dev_err(dev, "could not claim irq%d: %d\n", irq_num, status);
goto fail_rqirq;
}

Expand Down
39 changes: 19 additions & 20 deletions trunk/drivers/mfd/twl6030-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
*
* We set up IRQs starting at a platform-specified base. An interrupt map table,
* specifies mapping between interrupt number and the associated module.
*
*/
#define TWL6030_NR_IRQS 20

Expand Down Expand Up @@ -352,14 +351,11 @@ int twl6030_init_irq(struct device *dev, int irq_num)
{
struct device_node *node = dev->of_node;
int nr_irqs, irq_base, irq_end;

int status = 0;
int i;
struct task_struct *task;
int ret;
u8 mask[4];

static struct irq_chip twl6030_irq_chip;
static struct irq_chip twl6030_irq_chip;
int status = 0;
int i;
u8 mask[4];

nr_irqs = TWL6030_NR_IRQS;

Expand All @@ -377,16 +373,18 @@ int twl6030_init_irq(struct device *dev, int irq_num)
mask[1] = 0xFF;
mask[2] = 0xFF;
mask[3] = 0xFF;
ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0],
REG_INT_MSK_LINE_A, 3); /* MASK ALL INT LINES */
ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0],
REG_INT_MSK_STS_A, 3); /* MASK ALL INT STS */
ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0],
REG_INT_STS_A, 3); /* clear INT_STS_A,B,C */

/* mask all int lines */
twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_LINE_A, 3);
/* mask all int sts */
twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_STS_A, 3);
/* clear INT_STS_A,B,C */
twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_STS_A, 3);

twl6030_irq_base = irq_base;

/* install an irq handler for each of the modules;
/*
* install an irq handler for each of the modules;
* clone dummy irq_chip since PIH can't *do* anything
*/
twl6030_irq_chip = dummy_irq_chip;
Expand All @@ -401,22 +399,22 @@ int twl6030_init_irq(struct device *dev, int irq_num)
activate_irq(i);
}

pr_info("twl6030: %s (irq %d) chaining IRQs %d..%d\n", "PIH",
dev_info(dev, "PIH (irq %d) chaining IRQs %d..%d\n",
irq_num, irq_base, irq_end);

/* install an irq handler to demultiplex the TWL6030 interrupt */
init_completion(&irq_event);

status = request_irq(irq_num, handle_twl6030_pih, 0,
"TWL6030-PIH", &irq_event);
status = request_irq(irq_num, handle_twl6030_pih, 0, "TWL6030-PIH",
&irq_event);
if (status < 0) {
pr_err("twl6030: could not claim irq%d: %d\n", irq_num, status);
dev_err(dev, "could not claim irq %d: %d\n", irq_num, status);
goto fail_irq;
}

task = kthread_run(twl6030_irq_thread, (void *)irq_num, "twl6030-irq");
if (IS_ERR(task)) {
pr_err("twl6030: could not create irq %d thread!\n", irq_num);
dev_err(dev, "could not create irq %d thread!\n", irq_num);
status = PTR_ERR(task);
goto fail_kthread;
}
Expand All @@ -431,6 +429,7 @@ int twl6030_init_irq(struct device *dev, int irq_num)
fail_irq:
for (i = irq_base; i < irq_end; i++)
irq_set_chip_and_handler(i, NULL, NULL);

return status;
}

Expand Down

0 comments on commit 51838d5

Please sign in to comment.