From: <Tharunkumar.Pasumarthi@microchip.com>
To: <linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<krzysztof.kozlowski@linaro.org>, <wsa@kernel.org>
Cc: <UNGLinuxDriver@microchip.com>,
<andriy.shevchenko@linux.intel.com>, <robh@kernel.org>,
<jsd@semihalf.com>, <olof@lixom.net>,
<jarkko.nikula@linux.intel.com>, <semen.protsenko@linaro.org>,
<sven@svenpeter.dev>, <rafal@milecki.pl>, <arnd@arndb.de>
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 13:48:39 +0000 [thread overview]
Message-ID: <4e10a6ed7a1707f093a8947237faea075842d6e5.camel@microchip.com> (raw)
In-Reply-To: <8712b866-af22-d9ac-fd84-7d77c2628682@linaro.org>
On Tue, 2022-08-23 at 13:31 +0300, Krzysztof Kozlowski wrote:
>
> On 23/08/2022 17:56, 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.
>
> (...)
>
> > +static int pci1xxxx_i2c_suspend(struct device *dev)
> > +{
> > + struct pci1xxxx_i2c *i2c = dev_get_drvdata(dev);
> > + struct pci_dev *pdev = to_pci_dev(dev);
> > + u32 regval;
> > +
> > + i2c_mark_adapter_suspended(&i2c->adap);
> > +
> > + while ((i2c->i2c_xfer_in_progress))
> > + msleep(20);
> > +
> > + pci1xxxx_i2c_config_high_level_intr(i2c,
> > + SMBALERT_WAKE_INTR_MASK,
> > + true);
> > +
> > + /*Enable the PERST_DIS bit to mask the PERST from
> > + *resetting the core regs
> > + */
>
> Use Linux coding style comments. Everywhere...
Okay. I will fix Linux coding style for comments throughout the file in upcoming
patch.
> (...)
>
> > +
> > +static int pci1xxxx_i2c_probe_pci(struct pci_dev *pdev,
> > + const struct pci_device_id *ent)
> > +{
> > + struct pci1xxxx_i2c *i2c;
> > + int ret;
> > +
> > + i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL);
> > + if (!i2c)
> > + return -ENOMEM;
> > +
> > + pci_set_drvdata(pdev, i2c);
> > +
> > + i2c->i2c_xfer_in_progress = false;
> > +
> > + ret = pcim_enable_device(pdev);
> > + if (ret)
> > + return ret;
> > +
> > + pci_set_master(pdev);
> > +
> > + /* we are getting the base address of the SMB core. SMB core uses
> > + * BAR0 and 32K is the size here pci_resource_len returns 32K by
> > + * reading BAR0
> > + */
> > +
> > + ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
> > + if (ret < 0)
> > + return -ENOMEM;
> > +
> > + i2c->i2c_base = pcim_iomap_table(pdev)[0];
> > +
> > + init_completion(&i2c->i2c_xfer_done);
> > +
> > + pci1xxxx_i2c_init(i2c);
> > +
> > + dev_info(&pdev->dev, "i2c clock freq: %d\n", i2c->freq);
>
> That's not a helpful print. Don't pollute dmesg.
I will remove this print
> > +
> > + ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
> > + if (ret < 0)
> > + return ret;
> > +
> > + /*Register the isr. we are not using any isr flags here.*/
>
> Use Linux coding style comments. Everywhere...
Okay
> > + ret = devm_request_irq(&pdev->dev, pci_irq_vector(pdev, 0),
> > + pci1xxxx_i2c_isr, PCI1XXXX_IRQ_FLAGS,
> > + pci_name(pdev), i2c);
> > + if (ret)
> > + goto err_free_region;
> > +
> > + i2c->adap = pci1xxxx_i2c_ops;
> > + i2c->adap.class = I2C_CLASS_SPD;
> > + i2c->adap.dev.parent = &pdev->dev;
> > +
> > + snprintf(i2c->adap.name, sizeof(i2c->adap.name),
> > + "MCHP PCI1xxxx i2c adapter at %s", pci_name(pdev));
> > +
> > + i2c_set_adapdata(&i2c->adap, i2c);
> > +
> > + ret = i2c_add_adapter(&i2c->adap);
> > + if (ret) {
> > + dev_err(&pdev->dev, "i2c add adapter failed = %d\n", ret);
> > + pci1xxxx_i2c_shutdown(i2c);
>
> Why do you call here pci1xxxx_i2c_shutdown() but not in previous error path?
pci1xxxx_i2c_shutdown API will reset the registers that are set as part of
pci1xxxx_i2c_init API. I will update this API and also include this API in
failure case of pci_alloc_irq_vectors as well as devm_request_irq
> > + goto err_free_region;
> > + }
> > +
> > + return 0;
> > +
> > +err_free_region:
> > + pci_free_irq_vectors(pdev);
> > + return ret;
> > +}
> > +
> > +static void pci1xxxx_i2c_remove_pci(struct pci_dev *pdev)
> > +{
> > + struct pci1xxxx_i2c *i2c = pci_get_drvdata(pdev);
>
> No need for pci_free_irq_vectors()?
>
I will add this API in pci1xxxx_i2c_remove_pci
> > +
> > + i2c_del_adapter(&i2c->adap);
> > + pci1xxxx_i2c_shutdown(i2c);
> > +}
> > +
Thank you,
Tharun Kumar P
next prev parent reply other threads:[~2022-08-24 13:53 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 [this message]
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
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=4e10a6ed7a1707f093a8947237faea075842d6e5.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=krzysztof.kozlowski@linaro.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.