From: Sui Jingfeng <15330273260@189.cn>
To: Rob Herring <robh@kernel.org>
Cc: Qing Zhang <zhangqing@loongson.cn>,
David Airlie <airlied@linux.ie>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
linux-kernel@vger.kernel.org, Sam Ravnborg <sam@ravnborg.org>,
kernel test robot <lkp@intel.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
Dan Carpenter <dan.carpenter@oracle.com>,
devicetree@vger.kernel.org, suijingfeng <suijingfeng@loongson.cn>,
Thomas Zimmermann <tzimmermann@suse.de>,
Roland Scheidegger <sroland@vmware.com>,
Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>,
dri-devel@lists.freedesktop.org,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
linux-mips@vger.kernel.org,
"David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH v11 7/7] drm/lsdc: add drm driver for loongson display controller
Date: Wed, 23 Mar 2022 17:31:57 +0800 [thread overview]
Message-ID: <f0db9bc0-ae9b-e86e-cc14-376dc40b86f4@189.cn> (raw)
In-Reply-To: <Yjo2R5LQrRICr7dC@robh.at.kernel.org>
On 2022/3/23 04:49, Rob Herring wrote:
>> +
>> + if (state) {
>> + val = readb(li2c->dir_reg);
>> + val |= mask;
>> + writeb(val, li2c->dir_reg);
>> + } else {
>> + val = readb(li2c->dir_reg);
>> + val &= ~mask;
>> + writeb(val, li2c->dir_reg);
>> +
>> + val = readb(li2c->dat_reg);
>> + if (state)
> This condition is never true. We're in the 'else' because !state.
>
>> + val |= mask;
>> + else
>> + val &= ~mask;
>> + writeb(val, li2c->dat_reg);
> Shouldn't you set the data register low first and then change the
> direction? Otherwise, you may be driving high for a moment. However, if
> high is always done by setting the direction as input, why write the
> data register each time? I'm assuming whatever is written to the dat_reg
> is maintained regardless of pin state.
To be honest, i have rewrite GPIO emulated i2c several times.
Either give data first, then give the direction
or give the direction first, then the data
will be OK in practice.
In the theory, the GPIO data should be given before the GPIO direction,
I was told doing that way when learning Single-Chip Microcomputer (AT89S52).
But the high "MUST" be done by setting the direction as input.
It is "MUST" not "CAN" because writing code as the following
way works in practice.
if (state) {
val = readb(li2c->dir_reg);
val |= mask;
writeb(val, li2c->dir_reg);
} else {
// ...
}
If the adjust the above code by first set the detection as output,
then set the GPIO data register with high voltage level("1"). as
the following demonstrate code,
if (state) {
/* First set this pin as output */
val = readb(li2c->dir_reg);
val |= mask;
writeb(val, li2c->dir_reg);
/* Then, set the state to high */
val = readb(li2c->dat_reg);
val |= mask;
writeb(val, li2c->dat_reg);
} else {
// ...
}
Then i2c6 will NOT work as exacted, i2c7 will work, so strangely.
It may because the GPIO is open drained, not Push-pull output.
Output high is achieved by externalpull up resistance on the PCB.
next prev parent reply other threads:[~2022-03-23 9:32 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-21 16:29 [PATCH v11 0/7] drm/lsdc: add drm driver for loongson display controller Sui Jingfeng
2022-03-21 16:29 ` [PATCH v11 1/7] MIPS: Loongson64: dts: update the display controller device node Sui Jingfeng
2022-03-21 16:29 ` [PATCH v11 2/7] MIPS: Loongson64: dts: introduce ls3A4000 evaluation board Sui Jingfeng
2022-03-22 13:05 ` Jiaxun Yang
2022-03-22 13:38 ` Sui Jingfeng
2022-03-22 16:06 ` Jiaxun Yang
2022-03-23 1:53 ` Sui Jingfeng
2022-03-23 2:29 ` Jiaxun Yang
2022-03-23 3:07 ` Sui Jingfeng
2022-03-23 3:14 ` Jiaxun Yang
2022-03-23 7:07 ` Sui Jingfeng
2022-03-23 12:29 ` Jiaxun Yang
2022-03-23 12:53 ` Rob Herring
2022-03-24 1:51 ` Sui Jingfeng
2022-03-21 16:29 ` [PATCH v11 3/7] MIPS: Loongson64: dts: introduce lemote A1901 motherboard Sui Jingfeng
2022-03-21 16:29 ` [PATCH v11 4/7] MIPS: Loongson64: dts: introduce ls2k1000 pai evaluation board Sui Jingfeng
2022-03-21 16:29 ` [PATCH v11 5/7] dt-bindings: display: Add Loongson display controller Sui Jingfeng
2022-03-21 23:20 ` Rob Herring
2022-03-22 2:33 ` Sui Jingfeng
2022-03-22 13:08 ` Jiaxun Yang
2022-03-22 13:54 ` Sui Jingfeng
2022-03-22 16:08 ` Jiaxun Yang
2022-03-22 20:03 ` Rob Herring
2022-03-22 20:55 ` Rob Herring
2022-03-23 3:38 ` Sui Jingfeng
2022-03-23 13:03 ` Rob Herring
2022-03-24 1:48 ` Sui Jingfeng
2022-03-24 13:26 ` Rob Herring
2022-03-26 10:04 ` Sui Jingfeng
2022-03-28 14:04 ` Rob Herring
2022-03-29 2:02 ` Sui Jingfeng
2022-03-29 13:24 ` Rob Herring
2022-03-21 16:29 ` [PATCH v11 6/7] MIPS: Loongson64: defconfig: enable display bridge drivers on Loongson64 Sui Jingfeng
2022-03-21 16:29 ` [PATCH v11 7/7] drm/lsdc: add drm driver for loongson display controller Sui Jingfeng
2022-03-22 20:49 ` Rob Herring
2022-03-23 4:12 ` Sui Jingfeng
2022-03-23 13:11 ` Rob Herring
2022-03-24 4:05 ` Sui Jingfeng
2022-04-08 2:09 ` Sui Jingfeng
2022-03-23 4:19 ` Sui Jingfeng
2022-03-23 8:49 ` Sui Jingfeng
2022-03-23 9:31 ` Sui Jingfeng [this message]
2022-03-24 1:39 ` Sui Jingfeng
2022-03-24 13:42 ` Rob Herring
2022-03-24 7:32 ` Sui Jingfeng
2022-03-24 13:56 ` Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f0db9bc0-ae9b-e86e-cc14-376dc40b86f4@189.cn \
--to=15330273260@189.cn \
--cc=airlied@linux.ie \
--cc=andrey.zhizhikin@leica-geosystems.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jiaxun.yang@flygoat.com \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=lkp@intel.com \
--cc=robh@kernel.org \
--cc=sam@ravnborg.org \
--cc=sroland@vmware.com \
--cc=suijingfeng@loongson.cn \
--cc=tsbogend@alpha.franken.de \
--cc=tzimmermann@suse.de \
--cc=zhangqing@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox