lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 23 Aug 2022 13:48:30 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Tharun Kumar P <tharunkumar.pasumarthi@...rochip.com>,
        linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
        wsa@...nel.org
Cc:     andriy.shevchenko@...ux.intel.com, krzk@...nel.org,
        jarkko.nikula@...ux.intel.com, robh@...nel.org,
        semen.protsenko@...aro.org, sven@...npeter.dev, jsd@...ihalf.com,
        rafal@...ecki.pl, olof@...om.net, arnd@...db.de,
        UNGLinuxDriver@...rochip.com
Subject: Re: [PATCH RFC i2c-master] i2c: microchip: pci1xxxx: Add driver for
 I2C host controller in multifunction endpoint of pci1xxxx switch

Le 23/08/2022 à 16:56, Tharun Kumar P a écrit :
> 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.
> 
> Signed-off-by: Tharun Kumar P <tharunkumar.pasumarthi@...rochip.com>
> ---
>   MAINTAINERS                            |    8 +
>   drivers/i2c/busses/Kconfig             |   10 +
>   drivers/i2c/busses/Makefile            |    1 +
>   drivers/i2c/busses/i2c-mchp-pci1xxxx.c | 1123 ++++++++++++++++++++++++
>   4 files changed, 1142 insertions(+)
>   create mode 100644 drivers/i2c/busses/i2c-mchp-pci1xxxx.c


> +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);
> +
> +	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.*/
> +	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);
> +		goto err_free_region;
> +	}
> +
> +	return 0;
> +
> +err_free_region:
> +	pci_free_irq_vectors(pdev);

Should this also be part of the .remove function?

CJ

> +	return ret;
> +}
> +
> +static void pci1xxxx_i2c_remove_pci(struct pci_dev *pdev)
> +{
> +	struct pci1xxxx_i2c *i2c = pci_get_drvdata(pdev);
> +
> +	i2c_del_adapter(&i2c->adap);
> +	pci1xxxx_i2c_shutdown(i2c);
> +}
> +

Powered by blists - more mailing lists