linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sanjay R Mehta <sanju.mehta@amd.com>
Cc: wsa+renesas@sang-engineering.com, jarkko.nikula@linux.intel.com,
	jdelvare@suse.de, Sergey.Semin@baikalelectronics.ru,
	krzk@kernel.org, kblaiech@mellanox.com, loic.poulain@linaro.org,
	rppt@kernel.org, bjorn.andersson@linaro.org, linux@roeck-us.net,
	vadimp@mellanox.com, tali.perry1@gmail.com,
	linux-i2c@vger.kernel.org,
	Nehal Bakulchandra Shah <Nehal-Bakulchandra.Shah@amd.com>
Subject: Re: [PATCH] i2c: add i2c bus driver for AMD NAVI GPU
Date: Mon, 30 Nov 2020 13:19:09 +0200	[thread overview]
Message-ID: <20201130111909.GJ4077@smile.fi.intel.com> (raw)
In-Reply-To: <1606505439-39836-1-git-send-email-sanju.mehta@amd.com>

On Fri, Nov 27, 2020 at 01:30:39PM -0600, Sanjay R Mehta wrote:
> From: Nehal Bakulchandra Shah <Nehal-Bakulchandra.Shah@amd.com>
> 
> Latest AMD GPU card has USB Type-C interface. There is a
> Type-C controller which can be accessed over I2C.
> 
> This driver adds I2C bus driver to communicate with Type-C controller.
> I2C client driver will be part of USB Type-C UCSI driver.

...

> +I2C CONTROLLER DRIVER FOR AMD NAVI GPU

>  I2C MUXES

I always thought that NVIDIA should come after AMD...
You still didn't learn to run checkpatch.pl?

...

> +#include <asm/unaligned.h>

Move this after linux/* ones, or explain why should it be first.

> +#include <linux/delay.h>
> +#include <linux/i2c.h>
> +#include <linux/interrupt.h>
> +#include <linux/module.h>
> +#include <linux/pci.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm.h>
> +#include <linux/pm_runtime.h>

...

> +#define DRIVER_DESC "AMD I2C Controller Driver for Navi"
> +#define AMD_UCSI_INTR_REG 0x474
> +#define AMD_UCSI_INTR_EN 0xD
> +#define AMD_MASTERCFG_MASK GENMASK_ULL(15, 0)

linux/bits.h is missing.

May you create a better indentation of the values to make it easier to read?

> +struct amdgpu_i2c_dev {
> +	void __iomem *regs;

DesignWare driver has been converted to use regmap. How comes you are using old
approach?

> +	struct device *dev;
> +	u32 master_cfg;
> +	u32 slave_adr;
> +	u32			tx_fifo_depth;
> +	u32			rx_fifo_depth;
> +	u32			sda_hold_time;
> +	u16			ss_hcnt;
> +	u16			ss_lcnt;
> +	u16			fs_hcnt;
> +	u16			fs_lcnt;
> +	u16			fp_hcnt;
> +	u16			fp_lcnt;
> +	u16			hs_hcnt;
> +	u16			hs_lcnt;
> +	struct i2c_adapter adapter;
> +	struct i2c_board_info *gpu_ccgx_ucsi;
> +	struct i2c_client *ccgx_client;
> +};

...

> +	while (readl(i2cd->regs + DW_IC_STATUS) & DW_IC_STATUS_ACTIVITY) {
> +		if (timeout <= 0) {
> +			dev_dbg(i2cd->dev, "timeout waiting for bus ready\n");
> +			if (readl(i2cd->regs + DW_IC_STATUS) & DW_IC_STATUS_ACTIVITY)
> +				return -ETIMEDOUT;
> +			return 0;
> +		}
> +		timeout--;
> +		usleep_range(1000, 1100);
> +	}

Homework: discover iopoll.h (or regmap.h if we take into account previous
comment). Bonus: try to read newest kernel submission in the area to see what's
new.

I stopped here. I think it's enough to revisit entire patch.
It will look differently for sure when you address all given comments.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2020-11-30 11:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27 19:30 [PATCH] i2c: add i2c bus driver for AMD NAVI GPU Sanjay R Mehta
2020-11-30 11:19 ` Andy Shevchenko [this message]
2020-12-02  4:44   ` Sanjay R Mehta
  -- strict thread matches above, loose matches on Subject: below --
2021-03-09 13:31 [PATCH] i2c: add i2c bus driver for amd navi gpu Sanket Goswami
2021-03-09 14:23 ` kernel test robot
2021-03-09 14:26 ` Andy Shevchenko
2021-03-22 16:56   ` Goswami, Sanket
2021-03-25 17:05     ` Andy Shevchenko
2021-03-26 10:23       ` Goswami, Sanket
2021-03-26 10:40         ` Andy Shevchenko
2021-03-29  5:55           ` Goswami, Sanket
2021-03-29 12:36             ` Andy Shevchenko
2021-03-09 15:35 ` kernel test robot
2021-03-09 15:36 ` kernel test robot

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=20201130111909.GJ4077@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=Nehal-Bakulchandra.Shah@amd.com \
    --cc=Sergey.Semin@baikalelectronics.ru \
    --cc=bjorn.andersson@linaro.org \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=jdelvare@suse.de \
    --cc=kblaiech@mellanox.com \
    --cc=krzk@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=loic.poulain@linaro.org \
    --cc=rppt@kernel.org \
    --cc=sanju.mehta@amd.com \
    --cc=tali.perry1@gmail.com \
    --cc=vadimp@mellanox.com \
    --cc=wsa+renesas@sang-engineering.com \
    /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;
as well as URLs for NNTP newsgroup(s).