From: Chanwoo Choi <cw00.choi@samsung.com>
To: Stephan Gerhold <stephan@gerhold.net>,
MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] extcon: sm5502: Clear pending interrupts during initialization
Date: Thu, 10 Oct 2019 16:33:12 +0900 [thread overview]
Message-ID: <328ccd73-2ceb-2e3f-524c-3fd950ccbf09@samsung.com> (raw)
In-Reply-To: <20191008105434.119346-1-stephan@gerhold.net>
On 19. 10. 8. 오후 7:54, Stephan Gerhold wrote:
> On some devices (e.g. Samsung Galaxy A5 (2015)), the bootloader
> seems to keep interrupts enabled for SM5502 when booting Linux.
> Changing the cable state (i.e. plugging in a cable) - until the driver
> is loaded - will therefore produce an interrupt that is never read.
>
> In this situation, the cable state will be stuck forever on the
> initial state because SM5502 stops sending interrupts.
> This can be avoided by clearing those pending interrupts after
> the driver has been loaded.
>
> Reading the interrupt status registers twice seems to be sufficient
> to make interrupts work in this situation.
>
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
> This makes interrupts work on the Samsung Galaxy A5 (2015), which
> has recently gained mainline support [1].
>
> I was not able to find a datasheet for SM5502, so this patch is
> merely based on testing and comparison with the downstream driver [2].
>
> [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1329c1ab0730b521e6cd3051c56a2ff3d55f21e6
> [2]: https://protect2.fireeye.com/url?k=029d0042-5ffa4464-029c8b0d-0cc47a31384a-14ac0bce09798d1f&u=https://github.com/msm8916-mainline/android_kernel_qcom_msm8916/blob/SM-A500FU/drivers/misc/sm5502.c#L1566-L1578
> ---
> drivers/extcon/extcon-sm5502.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c
> index dc43847ad2b0..c897f1aa4bf5 100644
> --- a/drivers/extcon/extcon-sm5502.c
> +++ b/drivers/extcon/extcon-sm5502.c
> @@ -539,6 +539,12 @@ static void sm5502_init_dev_type(struct sm5502_muic_info *info)
> val = info->reg_data[i].val;
> regmap_write(info->regmap, info->reg_data[i].reg, val);
> }
> +
> + /* Clear pending interrupts */
> + regmap_read(info->regmap, SM5502_REG_INT1, ®_data);
> + regmap_read(info->regmap, SM5502_REG_INT2, ®_data);
> + regmap_read(info->regmap, SM5502_REG_INT1, ®_data);
> + regmap_read(info->regmap, SM5502_REG_INT2, ®_data);
It is not proper. Instead, initialize the SM5502_RET_INT1/2 with zero.
The reset value of SM5502_RET_INT1/2 are zero (0x00) as following:
If you can test it with h/w, please try to test it and then
send the modified patch.
diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c
index c897f1aa4bf5..e168f77a18ba 100644
--- a/drivers/extcon/extcon-sm5502.c
+++ b/drivers/extcon/extcon-sm5502.c
@@ -68,6 +68,14 @@ static struct reg_data sm5502_reg_data[] = {
.reg = SM5502_REG_CONTROL,
.val = SM5502_REG_CONTROL_MASK_INT_MASK,
.invert = false,
+ }, {
+ .reg = SM5502_REG_INT1,
+ .val = SM5502_RET_INT1_MASK,
+ .invert = true,
+ }, {
+ .reg = SM5502_REG_INT2,
+ .val = SM5502_RET_INT1_MASK,
+ .invert = true,
}, {
.reg = SM5502_REG_INTMASK1,
.val = SM5502_REG_INTM1_KP_MASK
diff --git a/drivers/extcon/extcon-sm5502.h b/drivers/extcon/extcon-sm5502.h
index 9dbb634d213b..5c4edb3e7fce 100644
--- a/drivers/extcon/extcon-sm5502.h
+++ b/drivers/extcon/extcon-sm5502.h
@@ -93,6 +93,8 @@ enum sm5502_reg {
#define SM5502_REG_CONTROL_RAW_DATA_MASK (0x1 << SM5502_REG_CONTROL_RAW_DATA_SHIFT)
#define SM5502_REG_CONTROL_SW_OPEN_MASK (0x1 << SM5502_REG_CONTROL_SW_OPEN_SHIFT)
+#define SM5502_RET_INT1_MASK (0xff)
+
#define SM5502_REG_INTM1_ATTACH_SHIFT 0
#define SM5502_REG_INTM1_DETACH_SHIFT 1
#define SM5502_REG_INTM1_KP_SHIFT 2
> }
>
> static int sm5022_muic_i2c_probe(struct i2c_client *i2c,
>
--
Best Regards,
Chanwoo Choi
Samsung Electronics
next prev parent reply other threads:[~2019-10-10 7:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20191008105726epcas3p178e8421ce5062b6955475199efa130e1@epcas3p1.samsung.com>
2019-10-08 10:54 ` Stephan Gerhold
2019-10-10 7:33 ` Chanwoo Choi [this message]
2019-10-10 7:46 ` Chanwoo Choi
2019-10-10 10:15 ` Stephan Gerhold
2019-10-10 10:29 ` Chanwoo Choi
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=328ccd73-2ceb-2e3f-524c-3fd950ccbf09@samsung.com \
--to=cw00.choi@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=stephan@gerhold.net \
/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
all inboxes | Powered by JetHome®