From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Tharun Kumar P <tharunkumar.pasumarthi@microchip.com>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
wsa@kernel.org, krzk@kernel.org, jarkko.nikula@linux.intel.com,
robh@kernel.org, semen.protsenko@linaro.org, sven@svenpeter.dev,
jsd@semihalf.com, rafal@milecki.pl, olof@lixom.net,
arnd@arndb.de, UNGLinuxDriver@microchip.com
Subject: Re: [PATCH RFC i2c-master] i2c: microchip: pci1xxxx: Add driver for I2C host controller in multifunction endpoint of pci1xxxx switch
Date: Tue, 23 Aug 2022 18:05:00 +0300 [thread overview]
Message-ID: <YwTsnCdxM5I6BoJu@smile.fi.intel.com> (raw)
In-Reply-To: <20220823145603.2606475-1-tharunkumar.pasumarthi@microchip.com>
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.
> + 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.
...
> obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o
> +obj-$(CONFIG_I2C_PCI1XXXX) += i2c-mchp-pci1xxxx.o
Why unsorted?
...
> + * Author: Tharun Kumar P <tharunkumar.pasumarthi@microchip.com>
> + * Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com>
Single or many?
...
> +/*SMB register space*/
Style.
...
> +#define SMB_CORE_CTRL_ESO 0x40
> +#define SMB_CORE_CTRL_FW_ACK 0x10
Are they bits or numbers?
...
> +#define SMB_CORE_CMD_READM 0x10
> +#define SMB_CORE_CMD_STOP 0x04
> +#define SMB_CORE_CMD_START 0x01
Ditto.
...
> +#define SMB_CORE_CMD_M_PROCEED 0x02
> +#define SMB_CORE_CMD_M_RUN 0x01
Ditto.
...
> +#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?
...
> +#define COMPLETION_MDONE 0x40
> +#define COMPLETION_IDLE 0x20
> +#define COMPLETION_MNAKX 0x01
Bits? Same Q for the rest similar stuff.
...
> +#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.
...
> +#define I2C_DIR_WRITE 0
> +#define I2C_DIR_READ 1
Namespace collision. Doesn't I²C core provide these?
...
> +#define PCI1XXXX_I2C_TIMEOUT 1000
Units? Same to the rest similar cases.
...
> +#define SMBUS_PERI_LOCK BIT(3)
BIT() out of a sudden. See above.
...
> +/*
> + * struct pci1xxxx_i2c - private structure for the I2C controller
> + *
Redundant blank line.
> + * @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.
> +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()
...
> + if (remainingbytes <= transferlen && (i2c->flags &
> + I2C_FLAGS_STOP))
Strange indentation.
...
> + /*
> + * 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.
...
> + time_left = wait_for_completion_timeout
> + (&i2c->i2c_xfer_done, msecs_to_jiffies(PCI1XXXX_I2C_TIMEOUT));
Strange indentation.
...
> + i2c_del_adapter(&i2c->adap);
Can't you use devm_ variant?
...
> + pci1xxxx_i2c_shutdown(i2c);
Do you really need this in ->remove()? I would expect something in
the ->suspend() / ->shutdown().
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-08-23 17:28 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 [this message]
2022-08-24 14:38 ` Tharunkumar.Pasumarthi
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=YwTsnCdxM5I6BoJu@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=UNGLinuxDriver@microchip.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=tharunkumar.pasumarthi@microchip.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox