Blame view

drivers/ide/jmicron.c 4.49 KB
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
1
2
  
  /*
ccd32e221   Alan Cox   ide: Switch to a ...
3
   * Copyright (C) 2006		Red Hat
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
4
5
6
   *
   *  May be copied or modified under the terms of the GNU General Public License
   */
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
7
8
9
  #include <linux/types.h>
  #include <linux/module.h>
  #include <linux/pci.h>
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
10
11
  #include <linux/ide.h>
  #include <linux/init.h>
ced3ec8aa   Bartlomiej Zolnierkiewicz   ide: prefix messa...
12
  #define DRV_NAME "jmicron"
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
13
14
15
16
17
18
19
  typedef enum {
  	PORT_PATA0 = 0,
  	PORT_PATA1 = 1,
  	PORT_SATA = 2,
  } port_type;
  
  /**
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
20
   *	jmicron_cable_detect	-	cable detection
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
21
22
   *	@hwif: IDE port
   *
49521f97c   Bartlomiej Zolnierkiewicz   ide: add short ca...
23
   *	Returns the cable type.
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
24
   */
f454cbe8c   Bartlomiej Zolnierkiewicz   ide: ->cable_dete...
25
  static u8 jmicron_cable_detect(ide_hwif_t *hwif)
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
26
  {
36501650e   Bartlomiej Zolnierkiewicz   ide: keep pointer...
27
  	struct pci_dev *pdev = to_pci_dev(hwif->dev);
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  
  	u32 control;
  	u32 control5;
  
  	int port = hwif->channel;
  	port_type port_map[2];
  
  	pci_read_config_dword(pdev, 0x40, &control);
  
  	/* There are two basic mappings. One has the two SATA ports merged
  	   as master/slave and the secondary as PATA, the other has only the
  	   SATA port mapped */
  	if (control & (1 << 23)) {
  		port_map[0] = PORT_SATA;
  		port_map[1] = PORT_PATA0;
  	} else {
  		port_map[0] = PORT_SATA;
  		port_map[1] = PORT_SATA;
  	}
  
  	/* The 365/366 may have this bit set to map the second PATA port
  	   as the internal primary channel */
  	pci_read_config_dword(pdev, 0x80, &control5);
  	if (control5 & (1<<24))
  		port_map[0] = PORT_PATA1;
  
  	/* The two ports may then be logically swapped by the firmware */
  	if (control & (1 << 22))
  		port = port ^ 1;
  
  	/*
  	 *	Now we know which physical port we are talking about we can
  	 *	actually do our cable checking etc. Thankfully we don't need
  	 *	to do the plumbing for other cases.
  	 */
740694f5e   Paolo Ciarrocchi   IDE: Coding Style...
63
  	switch (port_map[port]) {
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
64
65
  	case PORT_PATA0:
  		if (control & (1 << 3))	/* 40/80 pin primary */
49521f97c   Bartlomiej Zolnierkiewicz   ide: add short ca...
66
67
  			return ATA_CBL_PATA40;
  		return ATA_CBL_PATA80;
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
68
69
  	case PORT_PATA1:
  		if (control5 & (1 << 19))	/* 40/80 pin secondary */
49521f97c   Bartlomiej Zolnierkiewicz   ide: add short ca...
70
71
  			return ATA_CBL_PATA40;
  		return ATA_CBL_PATA80;
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
72
  	case PORT_SATA:
a51545ab2   Andrew Morton   jmicron: fix warning
73
  		break;
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
74
  	}
49521f97c   Bartlomiej Zolnierkiewicz   ide: add short ca...
75
76
  	/* Avoid bogus "control reaches end of non-void function" */
  	return ATA_CBL_PATA80;
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
77
  }
e085b3cae   Bartlomiej Zolnierkiewicz   ide: change ->set...
78
  static void jmicron_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
79
  {
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
80
81
82
  }
  
  /**
88b2b32ba   Bartlomiej Zolnierkiewicz   ide: move ide_con...
83
   *	jmicron_set_dma_mode	-	set host controller for DMA mode
8776168ca   Bartlomiej Zolnierkiewicz   ide: change ->set...
84
   *	@hwif: port
88b2b32ba   Bartlomiej Zolnierkiewicz   ide: move ide_con...
85
   *	@drive: drive
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
86
   *
88b2b32ba   Bartlomiej Zolnierkiewicz   ide: move ide_con...
87
   *	As the JMicron snoops for timings we don't need to do anything here.
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
88
   */
8776168ca   Bartlomiej Zolnierkiewicz   ide: change ->set...
89
  static void jmicron_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
90
  {
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
91
  }
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
92
93
94
95
96
  static const struct ide_port_ops jmicron_port_ops = {
  	.set_pio_mode		= jmicron_set_pio_mode,
  	.set_dma_mode		= jmicron_set_dma_mode,
  	.cable_detect		= jmicron_cable_detect,
  };
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
97

856204360   Bartlomiej Zolnierkiewicz   ide: constify str...
98
  static const struct ide_port_info jmicron_chipset __devinitdata = {
ced3ec8aa   Bartlomiej Zolnierkiewicz   ide: prefix messa...
99
  	.name		= DRV_NAME,
bda7970c2   Tejun Heo   ide: make jmicron...
100
  	.enablebits	= { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } },
ac95beedf   Bartlomiej Zolnierkiewicz   ide: add struct i...
101
  	.port_ops	= &jmicron_port_ops,
bda7970c2   Tejun Heo   ide: make jmicron...
102
  	.pio_mask	= ATA_PIO5,
5f8b6c348   Bartlomiej Zolnierkiewicz   ide: add ->mwdma_...
103
104
  	.mwdma_mask	= ATA_MWDMA2,
  	.udma_mask	= ATA_UDMA6,
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
105
106
107
108
109
110
111
112
113
114
115
116
117
  };
  
  /**
   *	jmicron_init_one	-	pci layer discovery entry
   *	@dev: PCI device
   *	@id: ident table entry
   *
   *	Called by the PCI code when it finds a Jmicron controller.
   *	We then use the IDE PCI generic helper to do most of the work.
   */
  
  static int __devinit jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id)
  {
6cdf6eb35   Bartlomiej Zolnierkiewicz   ide: add ->dev an...
118
  	return ide_pci_init_one(dev, &jmicron_chipset, NULL);
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
119
  }
bda7970c2   Tejun Heo   ide: make jmicron...
120
121
122
123
124
125
126
127
  /* All JMB PATA controllers have and will continue to have the same
   * interface.  Matching vendor and device class is enough for all
   * current and future controllers if the controller is programmed
   * properly.
   *
   * If libata is configured, jmicron PCI quirk programs the controller
   * into the correct mode.  If libata isn't configured, match known
   * device IDs too to maintain backward compatibility.
ebbc20313   Tejun Heo   jmicron: make ide...
128
   */
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
129
  static struct pci_device_id jmicron_pci_tbl[] = {
bda7970c2   Tejun Heo   ide: make jmicron...
130
131
132
133
134
135
136
137
138
  #if !defined(CONFIG_ATA) && !defined(CONFIG_ATA_MODULE)
  	{ PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB361) },
  	{ PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB363) },
  	{ PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB365) },
  	{ PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB366) },
  	{ PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB368) },
  #endif
  	{ PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  	  PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 0 },
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
139
140
141
142
  	{ 0, },
  };
  
  MODULE_DEVICE_TABLE(pci, jmicron_pci_tbl);
a9ab09e26   Bartlomiej Zolnierkiewicz   ide: use unique n...
143
  static struct pci_driver jmicron_pci_driver = {
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
144
145
146
  	.name		= "JMicron IDE",
  	.id_table	= jmicron_pci_tbl,
  	.probe		= jmicron_init_one,
1bcaaba77   Bartlomiej Zolnierkiewicz   jmicron: add ->re...
147
  	.remove		= ide_pci_remove,
feb22b7f8   Bartlomiej Zolnierkiewicz   ide: add proper P...
148
149
  	.suspend	= ide_pci_suspend,
  	.resume		= ide_pci_resume,
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
150
151
152
153
  };
  
  static int __init jmicron_ide_init(void)
  {
a9ab09e26   Bartlomiej Zolnierkiewicz   ide: use unique n...
154
  	return ide_pci_register_driver(&jmicron_pci_driver);
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
155
  }
1bcaaba77   Bartlomiej Zolnierkiewicz   jmicron: add ->re...
156
157
  static void __exit jmicron_ide_exit(void)
  {
a9ab09e26   Bartlomiej Zolnierkiewicz   ide: use unique n...
158
  	pci_unregister_driver(&jmicron_pci_driver);
1bcaaba77   Bartlomiej Zolnierkiewicz   jmicron: add ->re...
159
  }
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
160
  module_init(jmicron_ide_init);
1bcaaba77   Bartlomiej Zolnierkiewicz   jmicron: add ->re...
161
  module_exit(jmicron_ide_exit);
bbb3bbdb0   Alan Cox   [PATCH] non-libat...
162
163
164
165
  
  MODULE_AUTHOR("Alan Cox");
  MODULE_DESCRIPTION("PCI driver module for the JMicron in legacy modes");
  MODULE_LICENSE("GPL");