#include <linux/module.h>
#include <linux/init.h>
#include <linux/sched/signal.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/dma-mapping.h>
#include <linux/pci.h>
#include <linux/pnp.h>
#include <linux/platform_device.h>
#include <linux/sysctl.h>
#include <linux/io.h>
#include <linux/uaccess.h>
#include <asm/dma.h>
#include <linux/parport.h>
#include <linux/parport_pc.h>
#include <linux/via.h>
#include <asm/parport.h>
#define PARPORT_PC_MAX_PORTS …
#ifdef CONFIG_ISA_DMA_API
#define HAS_DMA
#endif
#define ECR_SPP …
#define ECR_PS2 …
#define ECR_PPF …
#define ECR_ECP …
#define ECR_EPP …
#define ECR_VND …
#define ECR_TST …
#define ECR_CNF …
#define ECR_MODE_MASK …
#define ECR_WRITE(p, v) …
#undef DEBUG
#define NR_SUPERIOS …
static struct superio_struct { … } superios[NR_SUPERIOS] = …;
static int user_specified;
#if defined(CONFIG_PARPORT_PC_SUPERIO) || \
(defined(CONFIG_PARPORT_1284) && defined(CONFIG_PARPORT_PC_FIFO))
static int verbose_probing;
#endif
static int pci_registered_parport;
static int pnp_registered_parport;
static void frob_econtrol(struct parport *pb, unsigned char m,
unsigned char v)
{ … }
static inline void frob_set_mode(struct parport *p, int mode)
{ … }
#ifdef CONFIG_PARPORT_PC_FIFO
static int change_mode(struct parport *p, int m)
{ … }
#endif
static int clear_epp_timeout(struct parport *pb)
{ … }
static void parport_pc_init_state(struct pardevice *dev,
struct parport_state *s)
{ … }
static void parport_pc_save_state(struct parport *p, struct parport_state *s)
{ … }
static void parport_pc_restore_state(struct parport *p,
struct parport_state *s)
{ … }
#ifdef CONFIG_PARPORT_1284
static size_t parport_pc_epp_read_data(struct parport *port, void *buf,
size_t length, int flags)
{ … }
static size_t parport_pc_epp_write_data(struct parport *port, const void *buf,
size_t length, int flags)
{ … }
static size_t parport_pc_epp_read_addr(struct parport *port, void *buf,
size_t length, int flags)
{ … }
static size_t parport_pc_epp_write_addr(struct parport *port,
const void *buf, size_t length,
int flags)
{ … }
static size_t parport_pc_ecpepp_read_data(struct parport *port, void *buf,
size_t length, int flags)
{ … }
static size_t parport_pc_ecpepp_write_data(struct parport *port,
const void *buf, size_t length,
int flags)
{ … }
static size_t parport_pc_ecpepp_read_addr(struct parport *port, void *buf,
size_t length, int flags)
{ … }
static size_t parport_pc_ecpepp_write_addr(struct parport *port,
const void *buf, size_t length,
int flags)
{ … }
#endif
#ifdef CONFIG_PARPORT_PC_FIFO
static size_t parport_pc_fifo_write_block_pio(struct parport *port,
const void *buf, size_t length)
{ … }
#ifdef HAS_DMA
static size_t parport_pc_fifo_write_block_dma(struct parport *port,
const void *buf, size_t length)
{ … }
#endif
static inline size_t parport_pc_fifo_write_block(struct parport *port,
const void *buf, size_t length)
{ … }
static size_t parport_pc_compat_write_block_pio(struct parport *port,
const void *buf, size_t length,
int flags)
{ … }
#ifdef CONFIG_PARPORT_1284
static size_t parport_pc_ecp_write_block_pio(struct parport *port,
const void *buf, size_t length,
int flags)
{ … }
#endif
#endif
static const struct parport_operations parport_pc_ops = …;
#ifdef CONFIG_PARPORT_PC_SUPERIO
static struct superio_struct *find_free_superio(void)
{ … }
static void show_parconfig_smsc37c669(int io, int key)
{ … }
static void show_parconfig_winbond(int io, int key)
{ … }
static void decode_winbond(int efer, int key, int devid, int devrev, int oldid)
{ … }
static void decode_smsc(int efer, int key, int devid, int devrev)
{ … }
static void winbond_check(int io, int key)
{ … }
static void winbond_check2(int io, int key)
{ … }
static void smsc_check(int io, int key)
{ … }
static void detect_and_report_winbond(void)
{ … }
static void detect_and_report_smsc(void)
{ … }
static void detect_and_report_it87(void)
{ … }
#endif
static struct superio_struct *find_superio(struct parport *p)
{ … }
static int get_superio_dma(struct parport *p)
{ … }
static int get_superio_irq(struct parport *p)
{ … }
static int parport_SPP_supported(struct parport *pb)
{ … }
static int parport_ECR_present(struct parport *pb)
{ … }
#ifdef CONFIG_PARPORT_1284
static int parport_PS2_supported(struct parport *pb)
{ … }
#ifdef CONFIG_PARPORT_PC_FIFO
static int parport_ECP_supported(struct parport *pb)
{ … }
#endif
#ifdef CONFIG_X86_32
static int intel_bug_present_check_epp(struct parport *pb)
{
const struct parport_pc_private *priv = pb->private_data;
int bug_present = 0;
if (priv->ecr) {
unsigned char ecr = inb(ECONTROL(pb));
unsigned char i;
for (i = 0x00; i < 0x80; i += 0x20) {
ECR_WRITE(pb, i);
if (clear_epp_timeout(pb)) {
bug_present = 1;
break;
}
}
ECR_WRITE(pb, ecr);
}
return bug_present;
}
static int intel_bug_present(struct parport *pb)
{
if (pb->dev != NULL) {
return 0;
}
return intel_bug_present_check_epp(pb);
}
#else
static int intel_bug_present(struct parport *pb)
{ … }
#endif
static int parport_ECPPS2_supported(struct parport *pb)
{ … }
static int parport_EPP_supported(struct parport *pb)
{ … }
static int parport_ECPEPP_supported(struct parport *pb)
{ … }
#else
static int parport_PS2_supported(struct parport *pb) { return 0; }
#ifdef CONFIG_PARPORT_PC_FIFO
static int parport_ECP_supported(struct parport *pb)
{
return 0;
}
#endif
static int parport_EPP_supported(struct parport *pb)
{
return 0;
}
static int parport_ECPEPP_supported(struct parport *pb)
{
return 0;
}
static int parport_ECPPS2_supported(struct parport *pb)
{
return 0;
}
#endif
static int programmable_irq_support(struct parport *pb)
{ … }
static int irq_probe_ECP(struct parport *pb)
{ … }
static int irq_probe_EPP(struct parport *pb)
{ … }
static int irq_probe_SPP(struct parport *pb)
{ … }
static int parport_irq_probe(struct parport *pb)
{ … }
static int programmable_dma_support(struct parport *p)
{ … }
static int parport_dma_probe(struct parport *p)
{ … }
static LIST_HEAD(ports_list);
static DEFINE_SPINLOCK(ports_lock);
static struct parport *__parport_pc_probe_port(unsigned long int base,
unsigned long int base_hi,
int irq, int dma,
struct device *dev,
int irqflags,
unsigned int mode_mask,
unsigned char ecr_writable)
{ … }
struct parport *parport_pc_probe_port(unsigned long int base,
unsigned long int base_hi,
int irq, int dma,
struct device *dev,
int irqflags)
{ … }
EXPORT_SYMBOL(…);
void parport_pc_unregister_port(struct parport *p)
{ … }
EXPORT_SYMBOL(…);
#ifdef CONFIG_PCI
static int sio_ite_8872_probe(struct pci_dev *pdev, int autoirq, int autodma,
const struct parport_pc_via_data *via)
{ … }
static int parport_init_mode;
static struct parport_pc_via_data via_686a_data = …;
static struct parport_pc_via_data via_8231_data = …;
static int sio_via_probe(struct pci_dev *pdev, int autoirq, int autodma,
const struct parport_pc_via_data *via)
{ … }
enum parport_pc_sio_types { … };
static struct parport_pc_superio { … } parport_pc_superio_info[] = …;
enum parport_pc_pci_cards { … };
static struct parport_pc_pci { … } cards[] = …;
static const struct pci_device_id parport_pc_pci_tbl[] = …;
MODULE_DEVICE_TABLE(pci, parport_pc_pci_tbl);
struct pci_parport_data { … };
static int parport_pc_pci_probe(struct pci_dev *dev,
const struct pci_device_id *id)
{ … }
static void parport_pc_pci_remove(struct pci_dev *dev)
{ … }
static struct pci_driver parport_pc_pci_driver = …;
static int __init parport_pc_init_superio(int autoirq, int autodma)
{ … }
#else
static struct pci_driver parport_pc_pci_driver;
static int __init parport_pc_init_superio(int autoirq, int autodma)
{
return 0;
}
#endif
#ifdef CONFIG_PNP
static const struct pnp_device_id parport_pc_pnp_tbl[] = …;
MODULE_DEVICE_TABLE(pnp, parport_pc_pnp_tbl);
static int parport_pc_pnp_probe(struct pnp_dev *dev,
const struct pnp_device_id *id)
{ … }
static void parport_pc_pnp_remove(struct pnp_dev *dev)
{ … }
static struct pnp_driver parport_pc_pnp_driver = …;
#else
static struct pnp_driver parport_pc_pnp_driver;
#endif
static int parport_pc_platform_probe(struct platform_device *pdev)
{ … }
static struct platform_driver parport_pc_platform_driver = …;
static int __attribute__((unused))
parport_pc_find_isa_ports(int autoirq, int autodma)
{ … }
static void __init parport_pc_find_ports(int autoirq, int autodma)
{ … }
static int __initdata io[PARPORT_PC_MAX_PORTS+1] = …;
static int __initdata io_hi[PARPORT_PC_MAX_PORTS+1] = …;
static int __initdata dmaval[PARPORT_PC_MAX_PORTS] = …;
static int __initdata irqval[PARPORT_PC_MAX_PORTS] = …;
static int __init parport_parse_param(const char *s, int *val,
int automatic, int none, int nofifo)
{ … }
static int __init parport_parse_irq(const char *irqstr, int *val)
{ … }
static int __init parport_parse_dma(const char *dmastr, int *val)
{ … }
#ifdef CONFIG_PCI
static int __init parport_init_mode_setup(char *str)
{ … }
#endif
#ifdef MODULE
static char *irq[PARPORT_PC_MAX_PORTS];
static char *dma[PARPORT_PC_MAX_PORTS];
MODULE_PARM_DESC(io, "Base I/O address (SPP regs)");
module_param_hw_array(io, int, ioport, NULL, 0);
MODULE_PARM_DESC(io_hi, "Base I/O address (ECR)");
module_param_hw_array(io_hi, int, ioport, NULL, 0);
MODULE_PARM_DESC(irq, "IRQ line");
module_param_hw_array(irq, charp, irq, NULL, 0);
MODULE_PARM_DESC(dma, "DMA channel");
module_param_hw_array(dma, charp, dma, NULL, 0);
#if defined(CONFIG_PARPORT_PC_SUPERIO) || \
(defined(CONFIG_PARPORT_1284) && defined(CONFIG_PARPORT_PC_FIFO))
MODULE_PARM_DESC(verbose_probing, "Log chit-chat during initialisation");
module_param(verbose_probing, int, 0644);
#endif
#ifdef CONFIG_PCI
static char *init_mode;
MODULE_PARM_DESC(init_mode,
"Initialise mode for VIA VT8231 port (spp, ps2, epp, ecp or ecpepp)");
module_param(init_mode, charp, 0);
#endif
static int __init parse_parport_params(void)
{
unsigned int i;
int val;
#ifdef CONFIG_PCI
if (init_mode)
parport_init_mode_setup(init_mode);
#endif
for (i = 0; i < PARPORT_PC_MAX_PORTS && io[i]; i++) {
if (parport_parse_irq(irq[i], &val))
return 1;
irqval[i] = val;
if (parport_parse_dma(dma[i], &val))
return 1;
dmaval[i] = val;
}
if (!io[0]) {
if (irq[0] && !parport_parse_irq(irq[0], &val))
switch (val) {
case PARPORT_IRQ_NONE:
case PARPORT_IRQ_AUTO:
irqval[0] = val;
break;
default:
pr_warn("parport_pc: irq specified without base address. Use 'io=' to specify one\n");
}
if (dma[0] && !parport_parse_dma(dma[0], &val))
switch (val) {
case PARPORT_DMA_NONE:
case PARPORT_DMA_AUTO:
dmaval[0] = val;
break;
default:
pr_warn("parport_pc: dma specified without base address. Use 'io=' to specify one\n");
}
}
return 0;
}
#else
static int parport_setup_ptr __initdata;
static int __init parport_setup(char *str)
{ … }
static int __init parse_parport_params(void)
{ … }
__setup(…);
#ifdef CONFIG_PCI
__setup(…);
#endif
#endif
static int __init parport_pc_init(void)
{ … }
static void __exit parport_pc_exit(void)
{ … }
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
module_init(…) …
module_exit(…)