From: <Tharunkumar.Pasumarthi@microchip.com>
To: <andriy.shevchenko@linux.intel.com>
Cc: <UNGLinuxDriver@microchip.com>, <wsa@kernel.org>,
<krzk@kernel.org>, <sven@svenpeter.dev>, <robh@kernel.org>,
<semen.protsenko@linaro.org>, <linux-kernel@vger.kernel.org>,
<jarkko.nikula@linux.intel.com>, <olof@lixom.net>,
<linux-i2c@vger.kernel.org>, <jsd@semihalf.com>, <arnd@arndb.de>,
<rafal@milecki.pl>
Subject: Re: [PATCH RFC i2c-master] i2c: microchip: pci1xxxx: Add driver for I2C host controller in multifunction endpoint of pci1xxxx switch
Date: Wed, 24 Aug 2022 14:38:29 +0000 [thread overview]
Message-ID: <80debd4bbf819cbfa16681172919436df476558a.camel@microchip.com> (raw)
In-Reply-To: <YwTsnCdxM5I6BoJu@smile.fi.intel.com>
On Tue, 2022-08-23 at 18:05 +0300, Andy Shevchenko wrote:
> On Tue, Aug 23, 2022 at 08:26:03PM +0530, Tharun Kumar P wrote:
> > Microchip PCI1XXXX is an unmanaged PCIe3.1a Switch for Consumer,
> > Industrial and Automotive applications. This switch has multiple
> > downstream ports. In one of the Switch's Downstream port, there
> > is a multifunction endpoint for peripherals which includes an I2C
> > host controller. The I2C function in the endpoint operates at 100KHz,
> > 400KHz and 1 MHz and has buffer depth of 128 bytes.
> > This patch provides the I2C controller driver for the I2C endpoint
> > of the switch.
>
> ...
>
> > @@ -1290,6 +1290,16 @@ config I2C_VIPERBOARD
> > River Tech's viperboard.h for detailed meaning
> > of the module parameters.
> >
> > +config I2C_PCI1XXXX
>
> Looks unsorted.
Okay, I will sort in alphabetical order
> > + tristate "PCI1XXXX I2C Host Adapter support"
> > + depends on PCI
> > + help
> > + Say yes here to enable the I2C Host adapter support for the PCI1xxxx
> > card
> > + This is a PCI to I2C adapter
> > +
> > + This driver can be built as a module. If so, the module will be
> > + called as i2c-mchp-pci1xxxx
>
> English grammar and punctuation while keeping lines shorter (~76) please.
Okay
>
> > obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o
> > +obj-$(CONFIG_I2C_PCI1XXXX) += i2c-mchp-pci1xxxx.o
>
> Why unsorted?
I will sort in alphabetical order
>
> > + * Author: Tharun Kumar P <tharunkumar.pasumarthi@microchip.com>
> > + * Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com>
>
> Single or many?
There are 2 authors for this file
>
> > +/*SMB register space*/
>
> Style.
I will take care of styling for comments throughout file
>
> > +#define SMB_CORE_CTRL_ESO 0x40
> > +#define SMB_CORE_CTRL_FW_ACK 0x10
>
> Are they bits or numbers?
These are bits
> ...
>
> > +#define SMB_CORE_CMD_READM 0x10
> > +#define SMB_CORE_CMD_STOP 0x04
> > +#define SMB_CORE_CMD_START 0x01
>
> Ditto.
These are bits
> ...
>
> > +#define SMB_CORE_CMD_M_PROCEED 0x02
> > +#define SMB_CORE_CMD_M_RUN 0x01
>
> Ditto.
These are bits
> ...
>
> > +#define SR_HOLD_TIME_100KHZ 0x85
> > +#define SR_HOLD_TIME_400KHZ 0x14
> > +#define SR_HOLD_TIME_1000KHZ 0x0B
>
> These has to be decimal, and why the ACPI / DT does not provide them?
>
> Also, do they have units or are they proportional coefficients?
There is no direct correlation between the hex value and time. Ex: 0x85
represents 0.5 us. Our device has an OTP region using which user can configure
device to operate at 100KHz, 400KHz and 1MHz. Based on this configuration,
SR_HOLD_TIME, IDLE_SCALING and few other registers will be configured in driver
> ...
>
> > +#define COMPLETION_MDONE 0x40
> > +#define COMPLETION_IDLE 0x20
> > +#define COMPLETION_MNAKX 0x01
>
> Bits? Same Q for the rest similar stuff.
Yes. These are bits.
> ...
>
> > +#define SMB_IDLE_SCALING_100KHZ 0x03E803C9
> > +#define SMB_IDLE_SCALING_400KHZ 0x01F4009D
> > +#define SMB_IDLE_SCALING_1000KHZ 0x01F4009D
>
> Shouldn't these magics be decimals?
> Ditto for the rest similar stuff.
There is no direct correlation between the hex value and time. Configuring
registers with these values in driver will set the time in device.
> ...
>
> > +#define I2C_DIR_WRITE 0
> > +#define I2C_DIR_READ 1
>
> Namespace collision. Doesn't I²C core provide these?
I am unable to find any existing MACROs for WRITE and READ in I2C core. Kindly
let me know the MACROs
> ...
>
> > +#define PCI1XXXX_I2C_TIMEOUT 1000
>
> Units? Same to the rest similar cases.
Unit is milliseconds
> ...
>
> > +#define SMBUS_PERI_LOCK BIT(3)
>
> BIT() out of a sudden. See above.
Will use hex value for this like in other places to maintain uniformity
> ...
>
> > +/*
> > + * struct pci1xxxx_i2c - private structure for the I2C controller
>
> > + *
>
> Redundant blank line.
Will take care of this in upcoming patch
>
> > + * @adap: I2C adapter instance
> > + * @dev: pointer to device struct
> > + * @i2c_base: pci base address of the I2C ctrler
> > + * @i2c_xfer_done: used for synchronisation between foreground & isr
> > + * @freq: frequency of I2C transfer
> > + * @flags: internal flags to store transfer conditions
> > + * @irq: irq number
> > + */
>
> > +
>
> Ditt.
Will take care of this in upcoming patch
> > +struct pci1xxxx_i2c {
> > + struct completion i2c_xfer_done;
> > + bool i2c_xfer_in_progress;
> > + struct i2c_adapter adap;
> > + void __iomem *i2c_base;
> > + u32 freq;
> > + u32 flags;
> > +};
>
> I have lack of time to finish review, but you already have enough for the next
> version.
>
> ...
>
> > + transferlen = min((u16)(SMBUS_MAST_BUF_MAX_SIZE - 1),
> > + remainingbytes);
>
> min_t()
Okay, Will replace min with min_t
> ...
>
> > + if (remainingbytes <= transferlen && (i2c->flags &
> > + I2C_FLAGS_STOP))
>
> Strange indentation.
Okay, Will take care of indentation in upcoming patch
> ...
>
> > + /*
> > + * wait for the DMA_TERM interrupt and if the timer expires,
> > it means
> > + * the transaction has failed due to some bus lock as we dint
> > get
> > + * the interrupt
> > + */
>
> You really have to go through all comments and fix grammar, etc.
Okay
> ...
>
> > + time_left = wait_for_completion_timeout
> > + (&i2c->i2c_xfer_done,
> > msecs_to_jiffies(PCI1XXXX_I2C_TIMEOUT));
>
> Strange indentation.
Okay, Will take care of indentation
> ...
>
> > + i2c_del_adapter(&i2c->adap);
>
> Can't you use devm_ variant?
Okay, I will use devm_ variant
> ...
>
> > + pci1xxxx_i2c_shutdown(i2c);
>
> Do you really need this in ->remove()? I would expect something in
> the ->suspend() / ->shutdown().
pci1xxxx_i2c_shutdown API will reset the registers that are set as part of
pci1xxxx_i2c_init. So, this API is present in ->remove() and not in ->suspend()
callback
Thanks,
Tharun Kumar P
next prev parent reply other threads:[~2022-08-24 14:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-23 14:56 [PATCH RFC i2c-master] i2c: microchip: pci1xxxx: Add driver for I2C host controller in multifunction endpoint of pci1xxxx switch Tharun Kumar P
2022-08-23 10:31 ` Krzysztof Kozlowski
2022-08-24 13:48 ` Tharunkumar.Pasumarthi
2022-08-30 14:21 ` Tharunkumar.Pasumarthi
2022-08-23 11:48 ` Christophe JAILLET
2022-08-24 13:52 ` Tharunkumar.Pasumarthi
2022-08-30 14:25 ` Tharunkumar.Pasumarthi
2022-08-23 15:05 ` Andy Shevchenko
2022-08-24 14:38 ` Tharunkumar.Pasumarthi [this message]
2022-08-24 18:31 ` Andy Shevchenko
2022-08-25 13:15 ` Tharunkumar.Pasumarthi
2022-08-25 14:22 ` Andy Shevchenko
2022-08-26 4:00 ` Tharunkumar.Pasumarthi
2022-08-26 13:03 ` Tharunkumar.Pasumarthi
2022-08-26 15:37 ` Andy Shevchenko
2022-08-29 3:00 ` Tharunkumar.Pasumarthi
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=80debd4bbf819cbfa16681172919436df476558a.camel@microchip.com \
--to=tharunkumar.pasumarthi@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=jarkko.nikula@linux.intel.com \
--cc=jsd@semihalf.com \
--cc=krzk@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=rafal@milecki.pl \
--cc=robh@kernel.org \
--cc=semen.protsenko@linaro.org \
--cc=sven@svenpeter.dev \
--cc=wsa@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.