diff options
author | Shardar Shariff Md <smohammed@nvidia.com> | 2016-08-31 09:28:42 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2016-09-08 16:33:51 -0400 |
commit | 89120d66fce9b6df4b9300fab373676648994cb8 (patch) | |
tree | 87d2b8e4bf58d273a431d889908f91bc25ed2732 | |
parent | 2148c01ccea9203a153eadadf068c1be5a935495 (diff) |
i2c: tegra: add separate function for config_load programing
Define separate function for configuration load register handling
to make it use by different functions later.
Signed-off-by: Shardar Shariff Md <smohammed@nvidia.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r-- | drivers/i2c/busses/i2c-tegra.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 07a39b7c293a..daab0cea20b4 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c | |||
@@ -446,6 +446,29 @@ static int tegra_i2c_runtime_suspend(struct device *dev) | |||
446 | return pinctrl_pm_select_idle_state(i2c_dev->dev); | 446 | return pinctrl_pm_select_idle_state(i2c_dev->dev); |
447 | } | 447 | } |
448 | 448 | ||
449 | static int tegra_i2c_wait_for_config_load(struct tegra_i2c_dev *i2c_dev) | ||
450 | { | ||
451 | unsigned long reg_offset; | ||
452 | void __iomem *addr; | ||
453 | u32 val; | ||
454 | int err; | ||
455 | |||
456 | if (i2c_dev->hw->has_config_load_reg) { | ||
457 | reg_offset = tegra_i2c_reg_addr(i2c_dev, I2C_CONFIG_LOAD); | ||
458 | addr = i2c_dev->base + reg_offset; | ||
459 | i2c_writel(i2c_dev, I2C_MSTR_CONFIG_LOAD, I2C_CONFIG_LOAD); | ||
460 | err = readl_poll_timeout(addr, val, val == 0, 1000, | ||
461 | I2C_CONFIG_LOAD_TIMEOUT); | ||
462 | if (err) { | ||
463 | dev_warn(i2c_dev->dev, | ||
464 | "timeout waiting for config load\n"); | ||
465 | return err; | ||
466 | } | ||
467 | } | ||
468 | |||
469 | return 0; | ||
470 | } | ||
471 | |||
449 | static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) | 472 | static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) |
450 | { | 473 | { |
451 | u32 val; | 474 | u32 val; |
@@ -500,21 +523,9 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) | |||
500 | if (i2c_dev->is_multimaster_mode && i2c_dev->hw->has_slcg_override_reg) | 523 | if (i2c_dev->is_multimaster_mode && i2c_dev->hw->has_slcg_override_reg) |
501 | i2c_writel(i2c_dev, I2C_MST_CORE_CLKEN_OVR, I2C_CLKEN_OVERRIDE); | 524 | i2c_writel(i2c_dev, I2C_MST_CORE_CLKEN_OVR, I2C_CLKEN_OVERRIDE); |
502 | 525 | ||
503 | if (i2c_dev->hw->has_config_load_reg) { | 526 | err = tegra_i2c_wait_for_config_load(i2c_dev); |
504 | unsigned long reg_offset; | 527 | if (err) |
505 | void __iomem *addr; | 528 | goto err; |
506 | |||
507 | reg_offset = tegra_i2c_reg_addr(i2c_dev, I2C_CONFIG_LOAD); | ||
508 | addr = i2c_dev->base + reg_offset; | ||
509 | i2c_writel(i2c_dev, I2C_MSTR_CONFIG_LOAD, I2C_CONFIG_LOAD); | ||
510 | err = readl_poll_timeout(addr, val, val == 0, 1000, | ||
511 | I2C_CONFIG_LOAD_TIMEOUT); | ||
512 | if (err) { | ||
513 | dev_warn(i2c_dev->dev, | ||
514 | "timeout waiting for config load\n"); | ||
515 | goto err; | ||
516 | } | ||
517 | } | ||
518 | 529 | ||
519 | if (i2c_dev->irq_disabled) { | 530 | if (i2c_dev->irq_disabled) { |
520 | i2c_dev->irq_disabled = 0; | 531 | i2c_dev->irq_disabled = 0; |