Re: [RFC PATCH net-next v5 4/9] net: txgbe: Register I2C platform device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wed, Apr 26, 2023 at 03:14:29PM +0800, Jiawen Wu kirjoitti:
> Register the platform device to use Designware I2C bus master driver.

...

> +static int txgbe_i2c_register(struct txgbe *txgbe)
> +{
> +	struct pci_dev *pdev = txgbe->wx->pdev;
> +	struct platform_device_info info = {};
> +	struct platform_device *i2c_dev;
> +	struct resource res[2] = {};
> +
> +	info.parent = &pdev->dev;
> +	info.fwnode = software_node_fwnode(txgbe->nodes.group[SWNODE_I2C]);
> +	info.name = "i2c_designware";
> +	info.id = (pdev->bus->number << 8) | pdev->devfn;

> +	res[0].start = pci_resource_start(pdev, 0) + TXGBE_I2C_BASE;
> +	res[0].end = pci_resource_start(pdev, 0) + TXGBE_I2C_BASE + 0x100 - 1;
> +	res[0].flags = IORESOURCE_MEM;

DEFINE_RES_MEM()

> +	res[1].start = pdev->irq;
> +	res[1].end = pdev->irq;
> +	res[1].flags = IORESOURCE_IRQ;

DEFINE_RES_IRQ()

> +	info.res = res;
> +	info.num_res = 2;

ARRAY_SIZE()

> +	i2c_dev = platform_device_register_full(&info);
> +	if (IS_ERR(i2c_dev))
> +		return PTR_ERR(i2c_dev);
> +
> +	txgbe->i2c_dev = i2c_dev;
> +
> +	return 0;
> +}

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux