From: Quan Nguyen <quan@os.amperecomputing.com> To: Ryan Chen <ryan_chen@aspeedtech.com>, Corey Minyard <minyard@acm.org>, Rob Herring <robh+dt@kernel.org>, Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>, Brendan Higgins <brendanhiggins@google.com>, Benjamin Herrenschmidt <benh@kernel.crashing.org>, Wolfram Sang <wsa@kernel.org>, Philipp Zabel <p.zabel@pengutronix.de>, "openipmi-developer@lists.sourceforge.net" <openipmi-developer@lists.sourceforge.net>, "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, "linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org> Cc: Open Source Submission <patches@amperecomputing.com>, "Thang Q . Nguyen" <thang@os.amperecomputing.com>, Phong Vo <phong@os.amperecomputing.com>, "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org> Subject: Re: [PATCH v3 5/7] i2c: aspeed: Add aspeed_set_slave_busy() Date: Fri, 28 May 2021 07:53:28 +0700 [thread overview] Message-ID: <14d58497-44e6-265a-af9d-7189379784d5@os.amperecomputing.com> (raw) In-Reply-To: <HK0PR06MB33805BB4A4D35192A0D95E59F2259@HK0PR06MB3380.apcprd06.prod.outlook.com> On 25/05/2021 17:30, Ryan Chen wrote: >> -----Original Message----- >> From: Quan Nguyen <quan@os.amperecomputing.com> >> Sent: Monday, May 24, 2021 6:49 PM >> To: Ryan Chen <ryan_chen@aspeedtech.com>; Corey Minyard >> <minyard@acm.org>; Rob Herring <robh+dt@kernel.org>; Joel Stanley >> <joel@jms.id.au>; Andrew Jeffery <andrew@aj.id.au>; Brendan Higgins >> <brendanhiggins@google.com>; Benjamin Herrenschmidt >> <benh@kernel.crashing.org>; Wolfram Sang <wsa@kernel.org>; Philipp Zabel >> <p.zabel@pengutronix.de>; openipmi-developer@lists.sourceforge.net; >> devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org; >> linux-aspeed@lists.ozlabs.org; linux-kernel@vger.kernel.org; >> linux-i2c@vger.kernel.org >> Cc: Open Source Submission <patches@amperecomputing.com>; Thang Q . >> Nguyen <thang@os.amperecomputing.com>; Phong Vo >> <phong@os.amperecomputing.com>; openbmc@lists.ozlabs.org >> Subject: Re: [PATCH v3 5/7] i2c: aspeed: Add aspeed_set_slave_busy() >> >> On 24/05/2021 17:36, Ryan Chen wrote: >>>> -----Original Message----- >>>> From: Quan Nguyen <quan@os.amperecomputing.com> >>>> Sent: Monday, May 24, 2021 6:20 PM >>>> To: Ryan Chen <ryan_chen@aspeedtech.com>; Corey Minyard >>>> <minyard@acm.org>; Rob Herring <robh+dt@kernel.org>; Joel Stanley >>>> <joel@jms.id.au>; Andrew Jeffery <andrew@aj.id.au>; Brendan Higgins >>>> <brendanhiggins@google.com>; Benjamin Herrenschmidt >>>> <benh@kernel.crashing.org>; Wolfram Sang <wsa@kernel.org>; Philipp >>>> Zabel <p.zabel@pengutronix.de>; >>>> openipmi-developer@lists.sourceforge.net; >>>> devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org; >>>> linux-aspeed@lists.ozlabs.org; linux-kernel@vger.kernel.org; >>>> linux-i2c@vger.kernel.org >>>> Cc: Open Source Submission <patches@amperecomputing.com>; Thang Q . >>>> Nguyen <thang@os.amperecomputing.com>; Phong Vo >>>> <phong@os.amperecomputing.com>; openbmc@lists.ozlabs.org >>>> Subject: Re: [PATCH v3 5/7] i2c: aspeed: Add aspeed_set_slave_busy() >>>> >>>> On 24/05/2021 17:06, Ryan Chen wrote: >>>>>> -----Original Message----- >>>>>> From: openbmc >>>>>> <openbmc-bounces+ryan_chen=aspeedtech.com@lists.ozlabs.org> On >>>> Behalf >>>>>> Of Quan Nguyen >>>>>> Sent: Wednesday, May 19, 2021 3:50 PM >>>>>> To: Corey Minyard <minyard@acm.org>; Rob Herring >>>>>> <robh+dt@kernel.org>; Joel Stanley <joel@jms.id.au>; Andrew Jeffery >>>>>> <andrew@aj.id.au>; Brendan Higgins <brendanhiggins@google.com>; >>>>>> Benjamin Herrenschmidt <benh@kernel.crashing.org>; Wolfram Sang >>>>>> <wsa@kernel.org>; Philipp Zabel <p.zabel@pengutronix.de>; >>>>>> openipmi-developer@lists.sourceforge.net; >>>>>> devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org; >>>>>> linux-aspeed@lists.ozlabs.org; linux-kernel@vger.kernel.org; >>>>>> linux-i2c@vger.kernel.org >>>>>> Cc: Open Source Submission <patches@amperecomputing.com>; Thang >> Q . >>>>>> Nguyen <thang@os.amperecomputing.com>; Phong Vo >>>>>> <phong@os.amperecomputing.com>; openbmc@lists.ozlabs.org >>>>>> Subject: [PATCH v3 5/7] i2c: aspeed: Add aspeed_set_slave_busy() >>>>>> >>>>>> Slave i2c device on AST2500 received a lot of slave irq while it is >>>>>> busy processing the response. To handle this case, adds and exports >>>>>> aspeed_set_slave_busy() for controller to temporary stop slave irq >>>>>> while slave is handling the response, and re-enable them again when >>>>>> the >>>> response is ready. >>>>>> >>>>>> Signed-off-by: Quan Nguyen <quan@os.amperecomputing.com> >>>>>> --- >>>>>> v3: >>>>>> + First introduce in v3 [Quan] >>>>>> >>>>>> drivers/i2c/busses/i2c-aspeed.c | 20 ++++++++++++++++++++ >>>>>> 1 file changed, 20 insertions(+) >>>>>> >>>>>> diff --git a/drivers/i2c/busses/i2c-aspeed.c >>>>>> b/drivers/i2c/busses/i2c-aspeed.c index b2e9c8f0ddf7..9926d04831a2 >>>>>> 100644 >>>>>> --- a/drivers/i2c/busses/i2c-aspeed.c >>>>>> +++ b/drivers/i2c/busses/i2c-aspeed.c >>>>>> @@ -944,6 +944,26 @@ static int aspeed_i2c_init(struct >>>>>> aspeed_i2c_bus *bus, >>>>>> return 0; >>>>>> } >>>>>> >>>>>> +#if IS_ENABLED(CONFIG_I2C_SLAVE) >>>>>> +void aspeed_set_slave_busy(struct i2c_adapter *adap, bool busy) { >>>>>> + struct aspeed_i2c_bus *bus = i2c_get_adapdata(adap); >>>>>> + unsigned long current_mask, flags; >>>>>> + >>>>>> + spin_lock_irqsave(&bus->lock, flags); >>>>>> + >>>>>> + current_mask = readl(bus->base + ASPEED_I2C_INTR_CTRL_REG); >>>>> Hello >>>>> Where the bus->base to be remap? >>>>> >>>> >>>> Hi Ryan, >>>> >>>> In "[PATCH v3 6/7] ipmi: ssif_bmc: Add Aspeed SSIF BMC driver", the >>>> ->priv is retrieved by calling i2c_get_adapdata(client->adapter). And >>>> ->in >>>> aspeed_set_ssif_bmc_status(), call the exported >>>> aspeed_set_slave_busy() using ->priv pointer as code below. >>>> >>> Yes, I see the probe function " ssif_bmc->priv = >> i2c_get_adapdata(client->adapter);" to get priv. >>> But my question I don’t see the bus->base address be assigned. >>> >> Hi Ryan, >> >> In drivers/i2c/busses/i2c-aspeed.c: >> struct aspeed_i2c_bus { >> struct i2c_adapter adap; >> struct device *dev; >> void __iomem *base; >> struct reset_control *rst; >> /* Synchronizes I/O mem access to base. */ >> spinlock_t lock; >> >> So when "struct aspeed_i2c_bus *bus = i2c_get_adapdata(adap);", the >> bus->base should point to the base of the aspeed_i2c_bus, which is >> already initialized by the aspeed i2c bus driver. >> >> Do I miss something? > Hello Quan, > After study. I think the ssif_bmc_aspeed.c assume the priv data is the same struct. > That is trick. > Do we have a better for slave enable/disable call back to implement this? > If add call back in struct i2c_algorithm; is it workable? >> Hi Ryan, I dont know which is better, ie: adding callback to struct i2c_algorithm or to struct i2c_adapter. I have tried to add generic callback to struct i2c_adapter as below and it works. diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 4e7714c88f95..6e9abf2d6abb 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -713,6 +713,10 @@ struct i2c_adapter { const struct i2c_adapter_quirks *quirks; struct irq_domain *host_notify_domain; +#if IS_ENABLED(CONFIG_I2C_SLAVE) + int (*slave_enable)(struct i2c_adapter *adap); + int (*slave_disable)(struct i2c_adapter *adap); +#endif }; #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) >>>> +extern void aspeed_set_slave_busy(struct i2c_adapter *adap, bool busy); >>>> +static void aspeed_set_ssif_bmc_status(struct ssif_bmc_ctx *ssif_bmc, >>>> unsigned int status) >>>> +{ >>>> + if (status & SSIF_BMC_BUSY) >>>> + aspeed_set_slave_busy((struct i2c_adapter *)ssif_bmc->priv, true); >>>> + else if (status & SSIF_BMC_READY) >>>> + aspeed_set_slave_busy((struct i2c_adapter *)ssif_bmc->priv, false); } >>>> + >>>> +static int ssif_bmc_probe(struct i2c_client *client, const struct >>>> i2c_device_id *id) >>>> +{ >>>> + struct ssif_bmc_ctx *ssif_bmc; >>>> + >>>> + ssif_bmc = ssif_bmc_alloc(client, 0); >>>> + if (IS_ERR(ssif_bmc)) >>>> + return PTR_ERR(ssif_bmc); >>>> + >>>> + ssif_bmc->priv = i2c_get_adapdata(client->adapter); >>>> + ssif_bmc->set_ssif_bmc_status = aspeed_set_ssif_bmc_status; >>>> + >>>> + return 0; >>>> +} >>>> >>>> - Quan >>>> >>>> >>> >
next prev parent reply other threads:[~2021-05-28 0:53 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-19 7:49 [PATCH v3 0/7] Add Aspeed SSIF BMC driver Quan Nguyen 2021-05-19 7:49 ` [PATCH v3 1/7] i2c: i2c-core-smbus: Expose PEC calculate function for generic use Quan Nguyen 2021-06-25 15:02 ` Wolfram Sang 2021-05-19 7:49 ` [PATCH v3 2/7] ipmi: ssif_bmc: Add SSIF BMC driver Quan Nguyen 2021-05-19 12:30 ` Corey Minyard 2021-05-20 14:19 ` Quan Nguyen 2021-05-19 7:49 ` [PATCH v3 3/7] i2c: aspeed: Fix unhandled Tx done with NAK Quan Nguyen 2021-05-19 23:28 ` Joel Stanley 2021-05-20 11:28 ` Ryan Chen 2021-05-20 14:15 ` Quan Nguyen 2021-05-20 13:48 ` Quan Nguyen 2021-05-19 7:49 ` [PATCH v3 4/7] i2c: aspeed: Acknowledge Tx done w/wo ACK irq late Quan Nguyen 2021-05-19 23:43 ` Joel Stanley 2021-05-20 1:19 ` Guenter Roeck 2021-05-20 14:03 ` Quan Nguyen 2021-05-20 13:52 ` Quan Nguyen 2021-05-19 7:49 ` [PATCH v3 5/7] i2c: aspeed: Add aspeed_set_slave_busy() Quan Nguyen 2021-05-20 11:06 ` Ryan Chen 2021-05-20 14:10 ` Quan Nguyen 2021-05-21 6:09 ` Ryan Chen 2021-05-28 1:00 ` Quan Nguyen 2021-05-24 10:06 ` Ryan Chen 2021-05-24 10:20 ` Quan Nguyen 2021-05-24 10:36 ` Ryan Chen 2021-05-24 10:48 ` Quan Nguyen 2021-05-25 10:30 ` Ryan Chen 2021-05-28 0:53 ` Quan Nguyen [this message] 2021-05-28 2:57 ` Ryan Chen 2021-06-07 14:57 ` Graeme Gregory 2021-05-19 7:49 ` [PATCH v3 6/7] ipmi: ssif_bmc: Add Aspeed SSIF BMC driver Quan Nguyen 2021-05-19 7:49 ` [PATCH v3 7/7] bindings: ipmi: Add binding for " Quan Nguyen 2021-05-19 15:29 ` Rob Herring 2021-05-20 14:24 ` Quan Nguyen 2021-05-19 12:34 ` [PATCH v3 0/7] Add " Corey Minyard 2021-05-20 14:23 ` Quan Nguyen
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=14d58497-44e6-265a-af9d-7189379784d5@os.amperecomputing.com \ --to=quan@os.amperecomputing.com \ --cc=andrew@aj.id.au \ --cc=benh@kernel.crashing.org \ --cc=brendanhiggins@google.com \ --cc=devicetree@vger.kernel.org \ --cc=joel@jms.id.au \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-aspeed@lists.ozlabs.org \ --cc=linux-i2c@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=minyard@acm.org \ --cc=openbmc@lists.ozlabs.org \ --cc=openipmi-developer@lists.sourceforge.net \ --cc=p.zabel@pengutronix.de \ --cc=patches@amperecomputing.com \ --cc=phong@os.amperecomputing.com \ --cc=robh+dt@kernel.org \ --cc=ryan_chen@aspeedtech.com \ --cc=thang@os.amperecomputing.com \ --cc=wsa@kernel.org \ --subject='Re: [PATCH v3 5/7] i2c: aspeed: Add aspeed_set_slave_busy()' \ /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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).