Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Generic platform device PATA driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2006 - 2007  Paul Mundt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Based on pata_pcmcia:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *   Copyright 2005-2006 Red Hat Inc, all rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * License.  See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <scsi/scsi_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/ata.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/libata.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/ata_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define DRV_NAME "pata_platform"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define DRV_VERSION "1.2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) static int pio_mask = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * Provide our own set_mode() as we don't want to change anything that has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * already been configured..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) static int pata_platform_set_mode(struct ata_link *link, struct ata_device **unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct ata_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	ata_for_each_dev(dev, link, ENABLED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		/* We don't really care */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		dev->pio_mode = dev->xfer_mode = XFER_PIO_0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		dev->xfer_shift = ATA_SHIFT_PIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		dev->flags |= ATA_DFLAG_PIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		ata_dev_info(dev, "configured for PIO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) static struct scsi_host_template pata_platform_sht = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	ATA_PIO_SHT(DRV_NAME),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static void pata_platform_setup_port(struct ata_ioports *ioaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 				     unsigned int shift)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	/* Fixup the port shift for platforms that need it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	ioaddr->data_addr	= ioaddr->cmd_addr + (ATA_REG_DATA    << shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	ioaddr->error_addr	= ioaddr->cmd_addr + (ATA_REG_ERR     << shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	ioaddr->feature_addr	= ioaddr->cmd_addr + (ATA_REG_FEATURE << shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	ioaddr->nsect_addr	= ioaddr->cmd_addr + (ATA_REG_NSECT   << shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	ioaddr->lbal_addr	= ioaddr->cmd_addr + (ATA_REG_LBAL    << shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	ioaddr->lbam_addr	= ioaddr->cmd_addr + (ATA_REG_LBAM    << shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	ioaddr->lbah_addr	= ioaddr->cmd_addr + (ATA_REG_LBAH    << shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	ioaddr->device_addr	= ioaddr->cmd_addr + (ATA_REG_DEVICE  << shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	ioaddr->status_addr	= ioaddr->cmd_addr + (ATA_REG_STATUS  << shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	ioaddr->command_addr	= ioaddr->cmd_addr + (ATA_REG_CMD     << shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  *	__pata_platform_probe		-	attach a platform interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  *	@dev: device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  *	@io_res: Resource representing I/O base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *	@ctl_res: Resource representing CTL base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *	@irq_res: Resource representing IRQ and its flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  *	@ioport_shift: I/O port shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  *	@__pio_mask: PIO mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  *	@sht: scsi_host_template to use when registering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *	@use16bit: Flag to indicate 16-bit IO instead of 32-bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  *	Register a platform bus IDE interface. Such interfaces are PIO and we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  *	assume do not support IRQ sharing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  *	Platform devices are expected to contain at least 2 resources per port:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  *		- I/O Base (IORESOURCE_IO or IORESOURCE_MEM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  *		- CTL Base (IORESOURCE_IO or IORESOURCE_MEM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  *	and optionally:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  *		- IRQ	   (IORESOURCE_IRQ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  *	If the base resources are both mem types, the ioremap() is handled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  *	here. For IORESOURCE_IO, it's assumed that there's no remapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *	necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  *	If no IRQ resource is present, PIO polling mode is used instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) int __pata_platform_probe(struct device *dev, struct resource *io_res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			  struct resource *ctl_res, struct resource *irq_res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			  unsigned int ioport_shift, int __pio_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			  struct scsi_host_template *sht, bool use16bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct ata_host *host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	struct ata_port *ap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	unsigned int mmio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	int irq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	int irq_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	 * Check for MMIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	mmio = (( io_res->flags == IORESOURCE_MEM) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		(ctl_res->flags == IORESOURCE_MEM));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	 * And the IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	if (irq_res && irq_res->start > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		irq = irq_res->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		irq_flags = (irq_res->flags & IRQF_TRIGGER_MASK) | IRQF_SHARED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	 * Now that that's out of the way, wire up the port..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	host = ata_host_alloc(dev, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	if (!host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	ap = host->ports[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	ap->ops = devm_kzalloc(dev, sizeof(*ap->ops), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	ap->ops->inherits = &ata_sff_port_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	ap->ops->cable_detect = ata_cable_unknown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	ap->ops->set_mode = pata_platform_set_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	if (use16bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		ap->ops->sff_data_xfer = ata_sff_data_xfer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		ap->ops->sff_data_xfer = ata_sff_data_xfer32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	ap->pio_mask = __pio_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	ap->flags |= ATA_FLAG_SLAVE_POSS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	 * Use polling mode if there's no IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	if (!irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		ap->flags |= ATA_FLAG_PIO_POLLING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		ata_port_desc(ap, "no IRQ, using PIO polling");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	 * Handle the MMIO case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (mmio) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		ap->ioaddr.cmd_addr = devm_ioremap(dev, io_res->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 				resource_size(io_res));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		ap->ioaddr.ctl_addr = devm_ioremap(dev, ctl_res->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 				resource_size(ctl_res));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		ap->ioaddr.cmd_addr = devm_ioport_map(dev, io_res->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 				resource_size(io_res));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		ap->ioaddr.ctl_addr = devm_ioport_map(dev, ctl_res->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 				resource_size(ctl_res));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		dev_err(dev, "failed to map IO/CTL base\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	ap->ioaddr.altstatus_addr = ap->ioaddr.ctl_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	pata_platform_setup_port(&ap->ioaddr, ioport_shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	ata_port_desc(ap, "%s cmd 0x%llx ctl 0x%llx", mmio ? "mmio" : "ioport",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		      (unsigned long long)io_res->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		      (unsigned long long)ctl_res->start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	/* activate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	return ata_host_activate(host, irq, irq ? ata_sff_interrupt : NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 				 irq_flags, sht);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) EXPORT_SYMBOL_GPL(__pata_platform_probe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static int pata_platform_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	struct resource *io_res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	struct resource *ctl_res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	struct resource *irq_res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct pata_platform_info *pp_info = dev_get_platdata(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	 * Simple resource validation ..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	if ((pdev->num_resources != 3) && (pdev->num_resources != 2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		dev_err(&pdev->dev, "invalid number of resources\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	 * Get the I/O base first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	io_res = platform_get_resource(pdev, IORESOURCE_IO, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	if (io_res == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		if (unlikely(io_res == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	 * Then the CTL base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	ctl_res = platform_get_resource(pdev, IORESOURCE_IO, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (ctl_res == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		ctl_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		if (unlikely(ctl_res == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	 * And the IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	return __pata_platform_probe(&pdev->dev, io_res, ctl_res, irq_res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 				     pp_info ? pp_info->ioport_shift : 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 				     pio_mask, &pata_platform_sht, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static struct platform_driver pata_platform_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	.probe		= pata_platform_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	.remove		= ata_platform_remove_one,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		.name		= DRV_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) module_platform_driver(pata_platform_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) module_param(pio_mask, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) MODULE_AUTHOR("Paul Mundt");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) MODULE_DESCRIPTION("low-level driver for platform device ATA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) MODULE_VERSION(DRV_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) MODULE_ALIAS("platform:" DRV_NAME);