i2c: meson: add suspend/resume to set gpio status [1/1]

PD#SWPL-17544

Problem:
it will cause Current reverse irrigation if the gpio
to i2c function when the system is in STR mode

Solution:
keep the gpio to sleep mode to protect to slave device

there are two sleep mode for i2c pins, and it depends the
pull up power. we can choose the exact sleep mode.

1)pull up power is on, set the sleep mode to input
2)pull up power if off, set low the gpio

Verify:
verified on x301

Change-Id: Ie62f70449be2ff2cef7e3ab5c918ac379d861ca1
Signed-off-by: Jian Hu <jian.hu@amlogic.com>
This commit is contained in:
Jian Hu
2019-11-27 20:01:32 +08:00
committed by Luke Go
parent 2bdb3aecd3
commit ae8733d2f9
9 changed files with 160 additions and 41 deletions

View File

@@ -921,8 +921,9 @@
&i2c0 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c0_dv_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c0_dv_pins>;
pinctrl-1 = <&i2c0_dv_pins_slp_input>;
};
&audiobus {
@@ -1296,8 +1297,9 @@
&i2c2 {
status = "okay";
pinctrl-names="default";
pinctrl-0=<&i2c2_z_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c2_z_pins>;
pinctrl-1 = <&i2c2_z_pins_slp_input>;
clock-frequency = <400000>;
tas5805: tas5805@36 {
@@ -1482,6 +1484,31 @@
&pwm_ab {
status = "okay";
clock-frequency = <300000>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c1_h_pins>;
pinctrl-1 = <&i2c1_h_pins_slp_input>;
lcd_extern_i2c0: lcd_extern_i2c@0 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_T5800Q";
reg = <0x1c>;
status = "okay";
};
lcd_extern_i2c1: lcd_extern_i2c@1 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_ANX6862";
reg = <0x20>;
status = "okay";
};
lcd_extern_i2c2: lcd_extern_i2c@2 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_ANX7911";
reg = <0x74>;
status = "okay";
};
};
&efuse {

View File

@@ -1237,8 +1237,9 @@
&i2c0 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c0_dv_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c0_dv_pins>;
pinctrl-1 = <&i2c0_dv_pins_slp_input>;
};
&audiobus {
@@ -1589,8 +1590,9 @@
&i2c2 {
status = "okay";
pinctrl-names="default";
pinctrl-0=<&i2c2_z_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c2_z_pins>;
pinctrl-1 = <&i2c2_z_pins_slp_input>;
clock-frequency = <400000>;
ad82584f: ad82584f@62 {
@@ -1758,8 +1760,9 @@
&i2c1 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c1_h_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c1_h_pins>;
pinctrl-1 = <&i2c1_h_pins_slp_input>;
lcd_extern_i2c0: lcd_extern_i2c@0 {
compatible = "lcd_ext, i2c";

View File

@@ -925,8 +925,9 @@
&i2c0 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c0_dv_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c0_dv_pins>;
pinctrl-1 = <&i2c0_dv_pins_slp_input>;
};
&audiobus {
@@ -1277,8 +1278,9 @@
&i2c2 {
status = "okay";
pinctrl-names="default";
pinctrl-0=<&i2c2_z_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c2_z_pins>;
pinctrl-1 = <&i2c2_z_pins_slp_input>;
clock-frequency = <400000>;
tas5805: tas5805@36 {
@@ -1478,6 +1480,35 @@
status = "okay";
};
&i2c1 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c1_h_pins>;
pinctrl-1 = <&i2c1_h_pins_slp_input>;
lcd_extern_i2c0: lcd_extern_i2c@0 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_T5800Q";
reg = <0x1c>;
status = "okay";
};
lcd_extern_i2c1: lcd_extern_i2c@1 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_ANX6862";
reg = <0x20>;
status = "okay";
};
lcd_extern_i2c2: lcd_extern_i2c@2 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_ANX7911";
reg = <0x74>;
status = "okay";
};
};
&pwm_ab {
status = "okay";
};

View File

@@ -1506,8 +1506,9 @@
&i2c0 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c0_dv_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c0_dv_pins>;
pinctrl-1 = <&i2c0_dv_pins_slp_input>;
};
&audiobus {
@@ -1893,8 +1894,9 @@
&i2c2 {
status = "okay";
pinctrl-names="default";
pinctrl-0=<&i2c2_z_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c2_z_pins>;
pinctrl-1 = <&i2c2_z_pins_slp_input>;
clock-frequency = <400000>;
tas5805: tas5805@36 {
@@ -2070,8 +2072,9 @@
&i2c1 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c1_h_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c1_h_pins>;
pinctrl-1 = <&i2c1_h_pins_slp_input>;
lcd_extern_i2c0: lcd_extern_i2c@0 {
compatible = "lcd_ext, i2c";

View File

@@ -1880,4 +1880,31 @@
&dvfs800_cfg
&dvfs800_cfg>;
};
&i2c1 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c1_h_pins>;
lcd_extern_i2c0: lcd_extern_i2c@0 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_T5800Q";
reg = <0x1c>;
status = "okay";
};
lcd_extern_i2c1: lcd_extern_i2c@1 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_ANX6862";
reg = <0x20>;
status = "okay";
};
lcd_extern_i2c2: lcd_extern_i2c@2 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_ANX7911";
reg = <0x74>;
status = "okay";
};
};

View File

@@ -1428,8 +1428,9 @@
&i2c0 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c0_dv_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c0_dv_pins>;
pinctrl-1 = <&i2c0_dv_pins_slp_input>;
};
&audiobus {
@@ -1781,8 +1782,9 @@
&i2c2 {
status = "okay";
pinctrl-names="default";
pinctrl-0=<&i2c2_z_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c2_z_pins>;
pinctrl-1 = <&i2c2_z_pins_slp_input>;
clock-frequency = <400000>;
tas5805: tas5805@36 {
@@ -1959,27 +1961,28 @@
&i2c1 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c1_h_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c1_h_pins>;
pinctrl-1 = <&i2c1_h_pins_slp_input>;
lcd_extern_i2c0: lcd_extern_i2c@0 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_T5800Q";
reg = <0x0 0x1c>;
reg = <0x1c>;
status = "okay";
};
lcd_extern_i2c1: lcd_extern_i2c@1 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_ANX6862";
reg = <0x0 0x20>;
reg = <0x20>;
status = "okay";
};
lcd_extern_i2c2: lcd_extern_i2c@2 {
compatible = "lcd_ext, i2c";
dev_name = "i2c_ANX7911";
reg = <0x0 0x74>;
reg = <0x74>;
status = "okay";
};
};

View File

@@ -1313,8 +1313,9 @@
&i2c0 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c0_dv_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c0_dv_pins>;
pinctrl-1 = <&i2c0_dv_pins_slp_input>;
};
&audiobus {
@@ -1665,8 +1666,9 @@
&i2c2 {
status = "okay";
pinctrl-names="default";
pinctrl-0=<&i2c2_z_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c2_z_pins>;
pinctrl-1 = <&i2c2_z_pins_slp_input>;
clock-frequency = <400000>;
tas5805: tas5805@36 {
@@ -1842,8 +1844,9 @@
&i2c1 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c1_h_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c1_h_pins>;
pinctrl-1 = <&i2c1_h_pins_slp_input>;
lcd_extern_i2c0: lcd_extern_i2c@0 {
compatible = "lcd_ext, i2c";

View File

@@ -1307,8 +1307,9 @@
&i2c0 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c0_dv_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c0_dv_pins>;
pinctrl-1 = <&i2c0_dv_pins_slp_input>;
};
&audiobus {
@@ -1660,8 +1661,9 @@
&i2c2 {
status = "okay";
pinctrl-names="default";
pinctrl-0=<&i2c2_z_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c2_z_pins>;
pinctrl-1 = <&i2c2_z_pins_slp_input>;
clock-frequency = <400000>;
tas5805: tas5805@36 {
@@ -1837,8 +1839,9 @@
&i2c1 {
status = "okay";
clock-frequency = <300000>;
pinctrl-names="default";
pinctrl-0=<&i2c1_h_pins>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&i2c1_h_pins>;
pinctrl-1 = <&i2c1_h_pins_slp_input>;
lcd_extern_i2c0: lcd_extern_i2c@0 {
compatible = "lcd_ext, i2c";

View File

@@ -667,6 +667,24 @@ static int meson_i2c_remove(struct platform_device *pdev)
return 0;
}
static int __maybe_unused meson_i2c_resume(struct device *dev)
{
pinctrl_pm_select_default_state(dev);
return 0;
}
static int __maybe_unused meson_i2c_suspend(struct device *dev)
{
pinctrl_pm_select_sleep_state(dev);
return 0;
}
static const struct dev_pm_ops meson_i2c_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(meson_i2c_suspend, meson_i2c_resume)
};
static const struct meson_i2c_data i2c_meson6_data = {
.div_factor = 4,
.delay_ajust = 15,
@@ -727,6 +745,7 @@ static struct platform_driver meson_i2c_driver = {
.remove = meson_i2c_remove,
.driver = {
.name = "meson-i2c",
.pm = &meson_i2c_pm_ops,
.of_match_table = meson_i2c_match,
},
};