Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 361319
b: refs/heads/master
c: df545d1
h: refs/heads/master
i:
  361317: 8243e9b
  361315: 23ac4da
  361311: b16db6d
v: v3
  • Loading branch information
Laxman Dewangan authored and Samuel Ortiz committed Mar 12, 2013
1 parent d384d0e commit 037d189
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 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: 5c854aaecea0cd7da95ce2170ff305f8273d552d
refs/heads/master: df545d1cd01aab3ba3f687d5423e6c3687b069d8
36 changes: 33 additions & 3 deletions trunk/drivers/mfd/palmas.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,24 @@ static struct regmap_irq_chip palmas_irq_chip = {
PALMAS_INT1_MASK),
};

static void palmas_dt_to_pdata(struct device_node *node,
static int palmas_set_pdata_irq_flag(struct i2c_client *i2c,
struct palmas_platform_data *pdata)
{
struct irq_data *irq_data = irq_get_irq_data(i2c->irq);
if (!irq_data) {
dev_err(&i2c->dev, "Invalid IRQ: %d\n", i2c->irq);
return -EINVAL;
}

pdata->irq_flags = irqd_get_trigger_type(irq_data);
dev_info(&i2c->dev, "Irq flag is 0x%08x\n", pdata->irq_flags);
return 0;
}

static void palmas_dt_to_pdata(struct i2c_client *i2c,
struct palmas_platform_data *pdata)
{
struct device_node *node = i2c->dev.of_node;
int ret;
u32 prop;

Expand All @@ -283,6 +298,8 @@ static void palmas_dt_to_pdata(struct device_node *node,
pdata->power_ctrl = PALMAS_POWER_CTRL_NSLEEP_MASK |
PALMAS_POWER_CTRL_ENABLE1_MASK |
PALMAS_POWER_CTRL_ENABLE2_MASK;
if (i2c->irq)
palmas_set_pdata_irq_flag(i2c, pdata);
}

static int palmas_i2c_probe(struct i2c_client *i2c,
Expand All @@ -304,7 +321,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
if (!pdata)
return -ENOMEM;

palmas_dt_to_pdata(node, pdata);
palmas_dt_to_pdata(i2c, pdata);
}

if (!pdata)
Expand Down Expand Up @@ -344,6 +361,19 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
}
}

/* Change interrupt line output polarity */
if (pdata->irq_flags & IRQ_TYPE_LEVEL_HIGH)
reg = PALMAS_POLARITY_CTRL_INT_POLARITY;
else
reg = 0;
ret = palmas_update_bits(palmas, PALMAS_PU_PD_OD_BASE,
PALMAS_POLARITY_CTRL, PALMAS_POLARITY_CTRL_INT_POLARITY,
reg);
if (ret < 0) {
dev_err(palmas->dev, "POLARITY_CTRL updat failed: %d\n", ret);
goto err;
}

/* Change IRQ into clear on read mode for efficiency */
slave = PALMAS_BASE_TO_SLAVE(PALMAS_INTERRUPT_BASE);
addr = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE, PALMAS_INT_CTRL);
Expand All @@ -352,7 +382,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
regmap_write(palmas->regmap[slave], addr, reg);

ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq,
IRQF_ONESHOT | IRQF_TRIGGER_LOW, 0, &palmas_irq_chip,
IRQF_ONESHOT | pdata->irq_flags, 0, &palmas_irq_chip,
&palmas->irq_data);
if (ret < 0)
goto err;
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/mfd/palmas.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ struct palmas_clk_platform_data {
};

struct palmas_platform_data {
int irq_flags;
int gpio_base;

/* bit value to be loaded to the POWER_CTRL register */
Expand Down

0 comments on commit 037d189

Please sign in to comment.