From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Huang, Tao" Subject: Re: [PATCH] i2c: rk3x: init module as subsys call Date: Tue, 5 Jan 2016 15:42:32 +0800 Message-ID: <568B73E8.3010901@rock-chips.com> References: <1451962938-17398-1-git-send-email-jay.xu@rock-chips.com> <2513923.8oltbpbAin@phil> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Return-path: In-Reply-To: <2513923.8oltbpbAin@phil> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+glpar-linux-rockchip=m.gmane.org-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org To: Heiko Stuebner , "jianqun.xu" Cc: wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, wdc-TNX95d0MmH7DzftRWevZcw@public.gmane.org, linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: linux-i2c@vger.kernel.org SGksIEhlaWtvOgoKT24gMjAxNuW5tDAx5pyIMDXml6UgMTU6MDIsIEhlaWtvIFN0dWVibmVyIHdy b3RlOgo+IEhpIEppYW5xdW4sCj4gCj4gQW0gRGllbnN0YWcsIDUuIEphbnVhciAyMDE2LCAxMTow MjoxOCBzY2hyaWViIGppYW5xdW4ueHU6Cj4+IEZyb206IFh1IEppYW5xdW4gPGpheS54dUByb2Nr LWNoaXBzLmNvbT4KPj4KPj4gVGhlcmUgaXMgYSByZXF1aXJlbWVudCBmcm9tIHBtaWMgZGV2aWNl LCB3aGljaCBpcyBvbiB0aGUgaTJjIGJ1cywKPj4gdGhhdCB0aGUgcG1pYyBuZWVkcyB0byBiZSBj YWxsZWQgZWFybGllciB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W5pdCh2b2lkKQo+PiArewo+PiAr CXJldHVybiBwbGF0Zm9ybV9kcml2ZXJfcmVnaXN0ZXIoJnJrM3hfaTJjX2RyaXZlcik7Cj4+ICt9 Cj4+ICtzdWJzeXNfaW5pdGNhbGwocmszeF9pMmNfaW5pdCk7Cj4+ICsKPj4gK3N0YXRpYyB2b2lk IF9fZXhpdCByazN4X2kyY19leGl0KHZvaWQpCj4+ICt7Cj4+ICsJcGxhdGZvcm1fZHJpdmVyX3Vu cmVnaXN0ZXIoJnJrM3hfaTJjX2RyaXZlcik7Cj4+ICt9Cj4+ICttb2R1bGVfZXhpdChyazN4X2ky Y19leGl0KTsKPj4KPj4gIE1PRFVMRV9ERVNDUklQVElPTigiUm9ja2NoaXAgUkszeHh4IEkyQyBC dXMgZHJpdmVyIik7Cj4+ICBNT0RVTEVfQVVUSE9SKCJNYXggU2Nod2FyeiA8bWF4LnNjaHdhcnpA b25saW5lLmRlPiIpOwo+IAo+IAo+IAo+IAoKCgpfX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fXwpMaW51eC1yb2NrY2hpcCBtYWlsaW5nIGxpc3QKTGludXgtcm9j a2NoaXBAbGlzdHMuaW5mcmFkZWFkLm9yZwpodHRwOi8vbGlzdHMuaW5mcmFkZWFkLm9yZy9tYWls bWFuL2xpc3RpbmZvL2xpbnV4LXJvY2tjaGlwCg== From mboxrd@z Thu Jan 1 00:00:00 1970 From: huangtao@rock-chips.com (Huang, Tao) Date: Tue, 5 Jan 2016 15:42:32 +0800 Subject: [PATCH] i2c: rk3x: init module as subsys call In-Reply-To: <2513923.8oltbpbAin@phil> References: <1451962938-17398-1-git-send-email-jay.xu@rock-chips.com> <2513923.8oltbpbAin@phil> Message-ID: <568B73E8.3010901@rock-chips.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi, Heiko: On 2016?01?05? 15:02, Heiko Stuebner wrote: > Hi Jianqun, > > Am Dienstag, 5. Januar 2016, 11:02:18 schrieb jianqun.xu: >> From: Xu Jianqun >> >> There is a requirement from pmic device, which is on the i2c bus, >> that the pmic needs to be called earlier then devices powered by >> the outputs of the pmic, if not, the devices maybe fail to probe. >> >> For example, a pmic on i2c0, and touchscreen device on i2c2, >> i2c0: - pmic(rk818) >> i2c2: - ts(gt911), powered by rk818 on i2c0 >> >> The problem will happen if the i2c2 node in dts file is ordered >> before i2c0 node, then ts(gt911) will be probed before pmic(rk818), >> since the power from the pmic(rk818) for ts(gt911) hasn't enabled, >> so ts(gt911) will fail to probe due to the failure of i2c test. >> >> But if we set the i2c0 node before i2c2, there is no this issue. >> >> The stable way to make sure that pmic can be intalized before other >> peripher devices is to make the pmic module be subsys call, the i2c >> module need to be subsys call firstly. > > I do believe that came up in the past already and the direction from then > was (and most likely still is) that drivers should make use of the probe- > deferral mechanism instead of wiggling with the initcall ordering. I don't think this is a good idea. This will trigger a lots of init call failed. Before pmic init, all i2c device driver transmit will failed, and because i2c is slow bus, and i2c transmit may failed by other reasons, so the i2c driver and i2c device driver will try many times to make sure the transmit completion. These unnecessary transmission will make Linux boot very slow. I2C bus should be subsys, and we can easy resolve this problem, why we depends on a complicated and slow implementation? > > Your touchscreen will have a "xyz-supply" property and I think the > regulator-framework should already emit a -EPROBE_DEFER at regulator_get, > when the regulator is specified but not available yet. Unfortunately, mostly driver do not support regulator api. They are suppose power is on. Thanks. Huang, Tao > > > Heiko > >> >> Signed-off-by: Xu Jianqun >> --- >> drivers/i2c/busses/i2c-rk3x.c | 12 +++++++++++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c >> index c1935eb..00e5959 100644 >> --- a/drivers/i2c/busses/i2c-rk3x.c >> +++ b/drivers/i2c/busses/i2c-rk3x.c >> @@ -1037,7 +1037,17 @@ static struct platform_driver rk3x_i2c_driver = { >> }, >> }; >> >> -module_platform_driver(rk3x_i2c_driver); >> +static int __init rk3x_i2c_init(void) >> +{ >> + return platform_driver_register(&rk3x_i2c_driver); >> +} >> +subsys_initcall(rk3x_i2c_init); >> + >> +static void __exit rk3x_i2c_exit(void) >> +{ >> + platform_driver_unregister(&rk3x_i2c_driver); >> +} >> +module_exit(rk3x_i2c_exit); >> >> MODULE_DESCRIPTION("Rockchip RK3xxx I2C Bus driver"); >> MODULE_AUTHOR("Max Schwarz "); > > > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751910AbcAEHm5 (ORCPT ); Tue, 5 Jan 2016 02:42:57 -0500 Received: from regular2.263xmail.com ([211.157.152.3]:55344 "EHLO regular2.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751530AbcAEHmw (ORCPT ); Tue, 5 Jan 2016 02:42:52 -0500 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 X-RL-SENDER: huangtao@rock-chips.com X-FST-TO: huangtao@rock-chips.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: huangtao@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Subject: Re: [PATCH] i2c: rk3x: init module as subsys call To: Heiko Stuebner , "jianqun.xu" References: <1451962938-17398-1-git-send-email-jay.xu@rock-chips.com> <2513923.8oltbpbAin@phil> Cc: wsa@the-dreams.de, wdc@rock-chips.com, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org From: "Huang, Tao" Message-ID: <568B73E8.3010901@rock-chips.com> Date: Tue, 5 Jan 2016 15:42:32 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <2513923.8oltbpbAin@phil> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Heiko: On 2016年01月05日 15:02, Heiko Stuebner wrote: > Hi Jianqun, > > Am Dienstag, 5. Januar 2016, 11:02:18 schrieb jianqun.xu: >> From: Xu Jianqun >> >> There is a requirement from pmic device, which is on the i2c bus, >> that the pmic needs to be called earlier then devices powered by >> the outputs of the pmic, if not, the devices maybe fail to probe. >> >> For example, a pmic on i2c0, and touchscreen device on i2c2, >> i2c0: - pmic(rk818) >> i2c2: - ts(gt911), powered by rk818 on i2c0 >> >> The problem will happen if the i2c2 node in dts file is ordered >> before i2c0 node, then ts(gt911) will be probed before pmic(rk818), >> since the power from the pmic(rk818) for ts(gt911) hasn't enabled, >> so ts(gt911) will fail to probe due to the failure of i2c test. >> >> But if we set the i2c0 node before i2c2, there is no this issue. >> >> The stable way to make sure that pmic can be intalized before other >> peripher devices is to make the pmic module be subsys call, the i2c >> module need to be subsys call firstly. > > I do believe that came up in the past already and the direction from then > was (and most likely still is) that drivers should make use of the probe- > deferral mechanism instead of wiggling with the initcall ordering. I don't think this is a good idea. This will trigger a lots of init call failed. Before pmic init, all i2c device driver transmit will failed, and because i2c is slow bus, and i2c transmit may failed by other reasons, so the i2c driver and i2c device driver will try many times to make sure the transmit completion. These unnecessary transmission will make Linux boot very slow. I2C bus should be subsys, and we can easy resolve this problem, why we depends on a complicated and slow implementation? > > Your touchscreen will have a "xyz-supply" property and I think the > regulator-framework should already emit a -EPROBE_DEFER at regulator_get, > when the regulator is specified but not available yet. Unfortunately, mostly driver do not support regulator api. They are suppose power is on. Thanks. Huang, Tao > > > Heiko > >> >> Signed-off-by: Xu Jianqun >> --- >> drivers/i2c/busses/i2c-rk3x.c | 12 +++++++++++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c >> index c1935eb..00e5959 100644 >> --- a/drivers/i2c/busses/i2c-rk3x.c >> +++ b/drivers/i2c/busses/i2c-rk3x.c >> @@ -1037,7 +1037,17 @@ static struct platform_driver rk3x_i2c_driver = { >> }, >> }; >> >> -module_platform_driver(rk3x_i2c_driver); >> +static int __init rk3x_i2c_init(void) >> +{ >> + return platform_driver_register(&rk3x_i2c_driver); >> +} >> +subsys_initcall(rk3x_i2c_init); >> + >> +static void __exit rk3x_i2c_exit(void) >> +{ >> + platform_driver_unregister(&rk3x_i2c_driver); >> +} >> +module_exit(rk3x_i2c_exit); >> >> MODULE_DESCRIPTION("Rockchip RK3xxx I2C Bus driver"); >> MODULE_AUTHOR("Max Schwarz "); > > > >