diff options
| -rw-r--r-- | drivers/mfd/palmas.c | 36 | ||||
| -rw-r--r-- | include/linux/mfd/palmas.h | 1 |
2 files changed, 34 insertions, 3 deletions
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index bbdbc50a3cca..73bf76df1044 100644 --- a/drivers/mfd/palmas.c +++ b/drivers/mfd/palmas.c | |||
| @@ -257,9 +257,24 @@ static struct regmap_irq_chip palmas_irq_chip = { | |||
| 257 | PALMAS_INT1_MASK), | 257 | PALMAS_INT1_MASK), |
| 258 | }; | 258 | }; |
| 259 | 259 | ||
| 260 | static void palmas_dt_to_pdata(struct device_node *node, | 260 | static int palmas_set_pdata_irq_flag(struct i2c_client *i2c, |
| 261 | struct palmas_platform_data *pdata) | 261 | struct palmas_platform_data *pdata) |
| 262 | { | 262 | { |
| 263 | struct irq_data *irq_data = irq_get_irq_data(i2c->irq); | ||
| 264 | if (!irq_data) { | ||
| 265 | dev_err(&i2c->dev, "Invalid IRQ: %d\n", i2c->irq); | ||
| 266 | return -EINVAL; | ||
| 267 | } | ||
| 268 | |||
| 269 | pdata->irq_flags = irqd_get_trigger_type(irq_data); | ||
| 270 | dev_info(&i2c->dev, "Irq flag is 0x%08x\n", pdata->irq_flags); | ||
| 271 | return 0; | ||
| 272 | } | ||
| 273 | |||
| 274 | static void palmas_dt_to_pdata(struct i2c_client *i2c, | ||
| 275 | struct palmas_platform_data *pdata) | ||
| 276 | { | ||
| 277 | struct device_node *node = i2c->dev.of_node; | ||
| 263 | int ret; | 278 | int ret; |
| 264 | u32 prop; | 279 | u32 prop; |
| 265 | 280 | ||
| @@ -283,6 +298,8 @@ static void palmas_dt_to_pdata(struct device_node *node, | |||
| 283 | pdata->power_ctrl = PALMAS_POWER_CTRL_NSLEEP_MASK | | 298 | pdata->power_ctrl = PALMAS_POWER_CTRL_NSLEEP_MASK | |
| 284 | PALMAS_POWER_CTRL_ENABLE1_MASK | | 299 | PALMAS_POWER_CTRL_ENABLE1_MASK | |
| 285 | PALMAS_POWER_CTRL_ENABLE2_MASK; | 300 | PALMAS_POWER_CTRL_ENABLE2_MASK; |
| 301 | if (i2c->irq) | ||
| 302 | palmas_set_pdata_irq_flag(i2c, pdata); | ||
| 286 | } | 303 | } |
| 287 | 304 | ||
| 288 | static int palmas_i2c_probe(struct i2c_client *i2c, | 305 | static int palmas_i2c_probe(struct i2c_client *i2c, |
| @@ -304,7 +321,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c, | |||
| 304 | if (!pdata) | 321 | if (!pdata) |
| 305 | return -ENOMEM; | 322 | return -ENOMEM; |
| 306 | 323 | ||
| 307 | palmas_dt_to_pdata(node, pdata); | 324 | palmas_dt_to_pdata(i2c, pdata); |
| 308 | } | 325 | } |
| 309 | 326 | ||
| 310 | if (!pdata) | 327 | if (!pdata) |
| @@ -344,6 +361,19 @@ static int palmas_i2c_probe(struct i2c_client *i2c, | |||
| 344 | } | 361 | } |
| 345 | } | 362 | } |
| 346 | 363 | ||
| 364 | /* Change interrupt line output polarity */ | ||
| 365 | if (pdata->irq_flags & IRQ_TYPE_LEVEL_HIGH) | ||
| 366 | reg = PALMAS_POLARITY_CTRL_INT_POLARITY; | ||
| 367 | else | ||
| 368 | reg = 0; | ||
| 369 | ret = palmas_update_bits(palmas, PALMAS_PU_PD_OD_BASE, | ||
| 370 | PALMAS_POLARITY_CTRL, PALMAS_POLARITY_CTRL_INT_POLARITY, | ||
| 371 | reg); | ||
| 372 | if (ret < 0) { | ||
| 373 | dev_err(palmas->dev, "POLARITY_CTRL updat failed: %d\n", ret); | ||
| 374 | goto err; | ||
| 375 | } | ||
| 376 | |||
| 347 | /* Change IRQ into clear on read mode for efficiency */ | 377 | /* Change IRQ into clear on read mode for efficiency */ |
| 348 | slave = PALMAS_BASE_TO_SLAVE(PALMAS_INTERRUPT_BASE); | 378 | slave = PALMAS_BASE_TO_SLAVE(PALMAS_INTERRUPT_BASE); |
| 349 | addr = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE, PALMAS_INT_CTRL); | 379 | addr = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE, PALMAS_INT_CTRL); |
| @@ -352,7 +382,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c, | |||
| 352 | regmap_write(palmas->regmap[slave], addr, reg); | 382 | regmap_write(palmas->regmap[slave], addr, reg); |
| 353 | 383 | ||
| 354 | ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq, | 384 | ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq, |
| 355 | IRQF_ONESHOT | IRQF_TRIGGER_LOW, 0, &palmas_irq_chip, | 385 | IRQF_ONESHOT | pdata->irq_flags, 0, &palmas_irq_chip, |
| 356 | &palmas->irq_data); | 386 | &palmas->irq_data); |
| 357 | if (ret < 0) | 387 | if (ret < 0) |
| 358 | goto err; | 388 | goto err; |
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index a4d13d7cd001..3bbda22721ea 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h | |||
| @@ -221,6 +221,7 @@ struct palmas_clk_platform_data { | |||
| 221 | }; | 221 | }; |
| 222 | 222 | ||
| 223 | struct palmas_platform_data { | 223 | struct palmas_platform_data { |
| 224 | int irq_flags; | ||
| 224 | int gpio_base; | 225 | int gpio_base; |
| 225 | 226 | ||
| 226 | /* bit value to be loaded to the POWER_CTRL register */ | 227 | /* bit value to be loaded to the POWER_CTRL register */ |
