drivers/usb/isp1760/isp1760-if.c

Source file repositories/reference/linux-study-clean/drivers/usb/isp1760/isp1760-if.c

File Facts

System
Linux kernel
Corpus path
drivers/usb/isp1760/isp1760-if.c
Extension
.c
Size
7180 bytes
Lines
303
Domain
Driver Families
Bucket
drivers/usb
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

static struct pci_driver isp1761_pci_driver = {
	.name =         "isp1760",
	.id_table =     isp1760_plx,
	.probe =        isp1761_pci_probe,
	.remove =       isp1761_pci_remove,
	.shutdown =     isp1761_pci_shutdown,
};
#endif

static int isp1760_plat_probe(struct platform_device *pdev)
{
	unsigned long irqflags;
	unsigned int devflags = 0;
	struct resource *mem_res;
	int irq;
	int ret;

	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

	irq = platform_get_irq(pdev, 0);
	if (irq < 0)
		return irq;
	irqflags = irq_get_trigger_type(irq);

	if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
		struct device_node *dp = pdev->dev.of_node;
		u32 bus_width = 0;

		if (of_device_is_compatible(dp, "nxp,usb-isp1761"))
			devflags |= ISP1760_FLAG_ISP1761;

		if (of_device_is_compatible(dp, "nxp,usb-isp1763"))
			devflags |= ISP1760_FLAG_ISP1763;

		/*
		 * Some systems wire up only 8 of 16 data lines or
		 * 16 of the 32 data lines
		 */
		of_property_read_u32(dp, "bus-width", &bus_width);
		if (bus_width == 16)
			devflags |= ISP1760_FLAG_BUS_WIDTH_16;
		else if (bus_width == 8)
			devflags |= ISP1760_FLAG_BUS_WIDTH_8;

		if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL)
			devflags |= ISP1760_FLAG_PERIPHERAL_EN;

		if (of_property_read_bool(dp, "analog-oc"))
			devflags |= ISP1760_FLAG_ANALOG_OC;

		if (of_property_read_bool(dp, "dack-polarity"))
			devflags |= ISP1760_FLAG_DACK_POL_HIGH;

		if (of_property_read_bool(dp, "dreq-polarity"))
			devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
	} else {
		pr_err("isp1760: no platform data\n");
		return -ENXIO;
	}

	ret = isp1760_register(mem_res, irq, irqflags, &pdev->dev, devflags);
	if (ret < 0)
		return ret;

	pr_info("ISP1760 USB device initialised\n");
	return 0;
}

static void isp1760_plat_remove(struct platform_device *pdev)
{
	isp1760_unregister(&pdev->dev);
}

#ifdef CONFIG_OF
static const struct of_device_id isp1760_of_match[] = {
	{ .compatible = "nxp,usb-isp1760", },
	{ .compatible = "nxp,usb-isp1761", },
	{ .compatible = "nxp,usb-isp1763", },
	{ },
};
MODULE_DEVICE_TABLE(of, isp1760_of_match);
#endif

static struct platform_driver isp1760_plat_driver = {
	.probe	= isp1760_plat_probe,
	.remove = isp1760_plat_remove,
	.driver	= {
		.name	= "isp1760",
		.of_match_table = of_match_ptr(isp1760_of_match),
	},

Annotation

Implementation Notes