[PATCH v3 5/7] i2c: aspeed: Add aspeed_set_slave_busy()

Ryan Chen ryan_chen at aspeedtech.com
Tue May 25 20:30:36 AEST 2021


> -----Original Message-----
> From: Quan Nguyen <quan at os.amperecomputing.com>
> Sent: Monday, May 24, 2021 6:49 PM
> To: Ryan Chen <ryan_chen at aspeedtech.com>; Corey Minyard
> <minyard at acm.org>; Rob Herring <robh+dt at kernel.org>; Joel Stanley
> <joel at jms.id.au>; Andrew Jeffery <andrew at aj.id.au>; Brendan Higgins
> <brendanhiggins at google.com>; Benjamin Herrenschmidt
> <benh at kernel.crashing.org>; Wolfram Sang <wsa at kernel.org>; Philipp Zabel
> <p.zabel at pengutronix.de>; openipmi-developer at lists.sourceforge.net;
> devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org;
> linux-aspeed at lists.ozlabs.org; linux-kernel at vger.kernel.org;
> linux-i2c at vger.kernel.org
> Cc: Open Source Submission <patches at amperecomputing.com>; Thang Q .
> Nguyen <thang at os.amperecomputing.com>; Phong Vo
> <phong at os.amperecomputing.com>; openbmc at 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 at os.amperecomputing.com>
> >> Sent: Monday, May 24, 2021 6:20 PM
> >> To: Ryan Chen <ryan_chen at aspeedtech.com>; Corey Minyard
> >> <minyard at acm.org>; Rob Herring <robh+dt at kernel.org>; Joel Stanley
> >> <joel at jms.id.au>; Andrew Jeffery <andrew at aj.id.au>; Brendan Higgins
> >> <brendanhiggins at google.com>; Benjamin Herrenschmidt
> >> <benh at kernel.crashing.org>; Wolfram Sang <wsa at kernel.org>; Philipp
> >> Zabel <p.zabel at pengutronix.de>;
> >> openipmi-developer at lists.sourceforge.net;
> >> devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org;
> >> linux-aspeed at lists.ozlabs.org; linux-kernel at vger.kernel.org;
> >> linux-i2c at vger.kernel.org
> >> Cc: Open Source Submission <patches at amperecomputing.com>; Thang Q .
> >> Nguyen <thang at os.amperecomputing.com>; Phong Vo
> >> <phong at os.amperecomputing.com>; openbmc at 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 at lists.ozlabs.org> On
> >> Behalf
> >>>> Of Quan Nguyen
> >>>> Sent: Wednesday, May 19, 2021 3:50 PM
> >>>> To: Corey Minyard <minyard at acm.org>; Rob Herring
> >>>> <robh+dt at kernel.org>; Joel Stanley <joel at jms.id.au>; Andrew Jeffery
> >>>> <andrew at aj.id.au>; Brendan Higgins <brendanhiggins at google.com>;
> >>>> Benjamin Herrenschmidt <benh at kernel.crashing.org>; Wolfram Sang
> >>>> <wsa at kernel.org>; Philipp Zabel <p.zabel at pengutronix.de>;
> >>>> openipmi-developer at lists.sourceforge.net;
> >>>> devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org;
> >>>> linux-aspeed at lists.ozlabs.org; linux-kernel at vger.kernel.org;
> >>>> linux-i2c at vger.kernel.org
> >>>> Cc: Open Source Submission <patches at amperecomputing.com>; Thang
> Q .
> >>>> Nguyen <thang at os.amperecomputing.com>; Phong Vo
> >>>> <phong at os.amperecomputing.com>; openbmc at 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 at 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?
> 
> >> +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
> >>
> >>
> >



More information about the Linux-aspeed mailing list