// SPDX-License-Identifier: GPL-2.0-or-later /* * Promise PATA TX2/TX4/TX2000/133 IDE driver for pdc20268 to pdc20277. * * Ported to libata by: * Albert Lee <[email protected]> IBM Corporation * * Copyright (C) 1998-2002 Andre Hedrick <[email protected]> * Portions Copyright (C) 1999 Promise Technology, Inc. * * Author: Frank Tiernan ([email protected]) * Released under terms of General Public License * * libata documentation is available via 'make {ps|pdf}docs', * as Documentation/driver-api/libata.rst * * Hardware information only available under NDA. */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/blkdev.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/ktime.h> #include <scsi/scsi.h> #include <scsi/scsi_host.h> #include <scsi/scsi_cmnd.h> #include <linux/libata.h> #define DRV_NAME … #define DRV_VERSION … enum { … }; static int pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); #ifdef CONFIG_PM_SLEEP static int pdc2027x_reinit_one(struct pci_dev *pdev); #endif static int pdc2027x_prereset(struct ata_link *link, unsigned long deadline); static void pdc2027x_set_piomode(struct ata_port *ap, struct ata_device *adev); static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev); static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc); static unsigned int pdc2027x_mode_filter(struct ata_device *adev, unsigned int mask); static int pdc2027x_cable_detect(struct ata_port *ap); static int pdc2027x_set_mode(struct ata_link *link, struct ata_device **r_failed); /* * ATA Timing Tables based on 133MHz controller clock. * These tables are only used when the controller is in 133MHz clock. * If the controller is in 100MHz clock, the ASIC hardware will * set the timing registers automatically when "set feature" command * is issued to the device. However, if the controller clock is 133MHz, * the following tables must be used. */ static const struct pdc2027x_pio_timing { … } pdc2027x_pio_timing_tbl[] = …; static const struct pdc2027x_mdma_timing { … } pdc2027x_mdma_timing_tbl[] = …; static const struct pdc2027x_udma_timing { … } pdc2027x_udma_timing_tbl[] = …; static const struct pci_device_id pdc2027x_pci_tbl[] = …; static struct pci_driver pdc2027x_pci_driver = …; static const struct scsi_host_template pdc2027x_sht = …; static struct ata_port_operations pdc2027x_pata100_ops = …; static struct ata_port_operations pdc2027x_pata133_ops = …; static struct ata_port_info pdc2027x_port_info[] = …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; MODULE_VERSION(…); MODULE_DEVICE_TABLE(pci, pdc2027x_pci_tbl); /** * port_mmio - Get the MMIO address of PDC2027x extended registers * @ap: Port * @offset: offset from mmio base */ static inline void __iomem *port_mmio(struct ata_port *ap, unsigned int offset) { … } /** * dev_mmio - Get the MMIO address of PDC2027x extended registers * @ap: Port * @adev: device * @offset: offset from mmio base */ static inline void __iomem *dev_mmio(struct ata_port *ap, struct ata_device *adev, unsigned int offset) { … } /** * pdc2027x_cable_detect - Probe host controller cable detect info * @ap: Port for which cable detect info is desired * * Read 80c cable indicator from Promise extended register. * This register is latched when the system is reset. * * LOCKING: * None (inherited from caller). */ static int pdc2027x_cable_detect(struct ata_port *ap) { … } /** * pdc2027x_port_enabled - Check PDC ATA control register to see whether the port is enabled. * @ap: Port to check */ static inline int pdc2027x_port_enabled(struct ata_port *ap) { … } /** * pdc2027x_prereset - prereset for PATA host controller * @link: Target link * @deadline: deadline jiffies for the operation * * Probeinit including cable detection. * * LOCKING: * None (inherited from caller). */ static int pdc2027x_prereset(struct ata_link *link, unsigned long deadline) { … } /** * pdc2027x_mode_filter - mode selection filter * @adev: ATA device * @mask: list of modes proposed * * Block UDMA on devices that cause trouble with this controller. */ static unsigned int pdc2027x_mode_filter(struct ata_device *adev, unsigned int mask) { … } /** * pdc2027x_set_piomode - Initialize host controller PATA PIO timings * @ap: Port to configure * @adev: um * * Set PIO mode for device. * * LOCKING: * None (inherited from caller). */ static void pdc2027x_set_piomode(struct ata_port *ap, struct ata_device *adev) { … } /** * pdc2027x_set_dmamode - Initialize host controller PATA UDMA timings * @ap: Port to configure * @adev: um * * Set UDMA mode for device. * * LOCKING: * None (inherited from caller). */ static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev) { … } /** * pdc2027x_set_mode - Set the timing registers back to correct values. * @link: link to configure * @r_failed: Returned device for failure * * The pdc2027x hardware will look at "SET FEATURES" and change the timing registers * automatically. The values set by the hardware might be incorrect, under 133Mhz PLL. * This function overwrites the possibly incorrect values set by the hardware to be correct. */ static int pdc2027x_set_mode(struct ata_link *link, struct ata_device **r_failed) { … } /** * pdc2027x_check_atapi_dma - Check whether ATAPI DMA can be supported for this command * @qc: Metadata associated with taskfile to check * * LOCKING: * None (inherited from caller). * * RETURNS: 0 when ATAPI DMA can be used * 1 otherwise */ static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc) { … } /** * pdc_read_counter - Read the ctr counter * @host: target ATA host */ static long pdc_read_counter(struct ata_host *host) { … } /** * pdc_adjust_pll - Adjust the PLL input clock in Hz. * * @host: target ATA host * @pll_clock: The input of PLL in HZ * @board_idx: board identifier */ static void pdc_adjust_pll(struct ata_host *host, long pll_clock, unsigned int board_idx) { … } /** * pdc_detect_pll_input_clock - Detect the PLL input clock in Hz. * @host: target ATA host * Ex. 16949000 on 33MHz PCI bus for pdc20275. * Half of the PCI clock. */ static long pdc_detect_pll_input_clock(struct ata_host *host) { … } /** * pdc_hardware_init - Initialize the hardware. * @host: target ATA host * @board_idx: board identifier */ static void pdc_hardware_init(struct ata_host *host, unsigned int board_idx) { … } /** * pdc_ata_setup_port - setup the mmio address * @port: ata ioports to setup * @base: base address */ static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base) { … } /** * pdc2027x_init_one - PCI probe function * Called when an instance of PCI adapter is inserted. * This function checks whether the hardware is supported, * initialize hardware and register an instance of ata_host to * libata. (implements struct pci_driver.probe() ) * * @pdev: instance of pci_dev found * @ent: matching entry in the id_tbl[] */ static int pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { … } #ifdef CONFIG_PM_SLEEP static int pdc2027x_reinit_one(struct pci_dev *pdev) { … } #endif module_pci_driver(…) …;