2 * Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 #include <linux/module.h>
19 #include <linux/kernel.h>
20 #include <linux/types.h>
22 #include <linux/uaccess.h>
23 #include <linux/string.h>
24 #include <linux/pci.h>
26 #include <linux/delay.h>
27 #include <linux/mutex.h>
28 #include <linux/if_ether.h>
29 #include <linux/ctype.h>
31 #define PHUB_STATUS 0x00 /* Status Register offset */
32 #define PHUB_CONTROL 0x04 /* Control Register offset */
33 #define PHUB_TIMEOUT 0x05 /* Time out value for Status Register */
34 #define PCH_PHUB_ROM_WRITE_ENABLE 0x01 /* Enabling for writing ROM */
35 #define PCH_PHUB_ROM_WRITE_DISABLE 0x00 /* Disabling for writing ROM */
36 #define PCH_PHUB_MAC_START_ADDR 0x20C /* MAC data area start address offset */
37 #define PCH_PHUB_ROM_START_ADDR_EG20T 0x14 /* ROM data area start address offset
39 #define PCH_PHUB_ROM_START_ADDR_ML7213 0x400 /* ROM data area start address
40 offset(OKI SEMICONDUCTOR ML7213)
43 /* MAX number of INT_REDUCE_CONTROL registers */
44 #define MAX_NUM_INT_REDUCE_CONTROL_REG 128
45 #define PCI_DEVICE_ID_PCH1_PHUB 0x8801
46 #define PCH_MINOR_NOS 1
47 #define CLKCFG_CAN_50MHZ 0x12000000
48 #define CLKCFG_CANCLK_MASK 0xFF000000
50 /* Macros for ML7213 */
51 #define PCI_VENDOR_ID_ROHM 0x10db
52 #define PCI_DEVICE_ID_ROHM_ML7213_PHUB 0x801A
54 /* SROM ACCESS Macro */
55 #define PCH_WORD_ADDR_MASK (~((1 << 2) - 1))
57 /* Registers address offset */
58 #define PCH_PHUB_ID_REG 0x0000
59 #define PCH_PHUB_QUEUE_PRI_VAL_REG 0x0004
60 #define PCH_PHUB_RC_QUEUE_MAXSIZE_REG 0x0008
61 #define PCH_PHUB_BRI_QUEUE_MAXSIZE_REG 0x000C
62 #define PCH_PHUB_COMP_RESP_TIMEOUT_REG 0x0010
63 #define PCH_PHUB_BUS_SLAVE_CONTROL_REG 0x0014
64 #define PCH_PHUB_DEADLOCK_AVOID_TYPE_REG 0x0018
65 #define PCH_PHUB_INTPIN_REG_WPERMIT_REG0 0x0020
66 #define PCH_PHUB_INTPIN_REG_WPERMIT_REG1 0x0024
67 #define PCH_PHUB_INTPIN_REG_WPERMIT_REG2 0x0028
68 #define PCH_PHUB_INTPIN_REG_WPERMIT_REG3 0x002C
69 #define PCH_PHUB_INT_REDUCE_CONTROL_REG_BASE 0x0040
70 #define CLKCFG_REG_OFFSET 0x500
72 #define PCH_PHUB_OROM_SIZE 15360
75 * struct pch_phub_reg - PHUB register structure
76 * @phub_id_reg: PHUB_ID register val
77 * @q_pri_val_reg: QUEUE_PRI_VAL register val
78 * @rc_q_maxsize_reg: RC_QUEUE_MAXSIZE register val
79 * @bri_q_maxsize_reg: BRI_QUEUE_MAXSIZE register val
80 * @comp_resp_timeout_reg: COMP_RESP_TIMEOUT register val
81 * @bus_slave_control_reg: BUS_SLAVE_CONTROL_REG register val
82 * @deadlock_avoid_type_reg: DEADLOCK_AVOID_TYPE register val
83 * @intpin_reg_wpermit_reg0: INTPIN_REG_WPERMIT register 0 val
84 * @intpin_reg_wpermit_reg1: INTPIN_REG_WPERMIT register 1 val
85 * @intpin_reg_wpermit_reg2: INTPIN_REG_WPERMIT register 2 val
86 * @intpin_reg_wpermit_reg3: INTPIN_REG_WPERMIT register 3 val
87 * @int_reduce_control_reg: INT_REDUCE_CONTROL registers val
88 * @clkcfg_reg: CLK CFG register val
89 * @pch_phub_base_address: Register base address
90 * @pch_phub_extrom_base_address: external rom base address
96 u32 bri_q_maxsize_reg;
97 u32 comp_resp_timeout_reg;
98 u32 bus_slave_control_reg;
99 u32 deadlock_avoid_type_reg;
100 u32 intpin_reg_wpermit_reg0;
101 u32 intpin_reg_wpermit_reg1;
102 u32 intpin_reg_wpermit_reg2;
103 u32 intpin_reg_wpermit_reg3;
104 u32 int_reduce_control_reg[MAX_NUM_INT_REDUCE_CONTROL_REG];
106 void __iomem *pch_phub_base_address;
107 void __iomem *pch_phub_extrom_base_address;
110 /* SROM SPEC for MAC address assignment offset */
111 static const int pch_phub_mac_offset[ETH_ALEN] = {0x3, 0x2, 0x1, 0x0, 0xb, 0xa};
113 static DEFINE_MUTEX(pch_phub_mutex);
116 * pch_phub_read_modify_write_reg() - Reading modifying and writing register
117 * @reg_addr_offset: Register offset address value.
118 * @data: Writing value.
121 static void pch_phub_read_modify_write_reg(struct pch_phub_reg *chip,
122 unsigned int reg_addr_offset,
123 unsigned int data, unsigned int mask)
125 void __iomem *reg_addr = chip->pch_phub_base_address + reg_addr_offset;
126 iowrite32(((ioread32(reg_addr) & ~mask)) | data, reg_addr);
129 /* pch_phub_save_reg_conf - saves register configuration */
130 static void pch_phub_save_reg_conf(struct pci_dev *pdev)
133 struct pch_phub_reg *chip = pci_get_drvdata(pdev);
135 void __iomem *p = chip->pch_phub_base_address;
137 chip->phub_id_reg = ioread32(p + PCH_PHUB_ID_REG);
138 chip->q_pri_val_reg = ioread32(p + PCH_PHUB_QUEUE_PRI_VAL_REG);
139 chip->rc_q_maxsize_reg = ioread32(p + PCH_PHUB_RC_QUEUE_MAXSIZE_REG);
140 chip->bri_q_maxsize_reg = ioread32(p + PCH_PHUB_BRI_QUEUE_MAXSIZE_REG);
141 chip->comp_resp_timeout_reg =
142 ioread32(p + PCH_PHUB_COMP_RESP_TIMEOUT_REG);
143 chip->bus_slave_control_reg =
144 ioread32(p + PCH_PHUB_BUS_SLAVE_CONTROL_REG);
145 chip->deadlock_avoid_type_reg =
146 ioread32(p + PCH_PHUB_DEADLOCK_AVOID_TYPE_REG);
147 chip->intpin_reg_wpermit_reg0 =
148 ioread32(p + PCH_PHUB_INTPIN_REG_WPERMIT_REG0);
149 chip->intpin_reg_wpermit_reg1 =
150 ioread32(p + PCH_PHUB_INTPIN_REG_WPERMIT_REG1);
151 chip->intpin_reg_wpermit_reg2 =
152 ioread32(p + PCH_PHUB_INTPIN_REG_WPERMIT_REG2);
153 chip->intpin_reg_wpermit_reg3 =
154 ioread32(p + PCH_PHUB_INTPIN_REG_WPERMIT_REG3);
155 dev_dbg(&pdev->dev, "%s : "
156 "chip->phub_id_reg=%x, "
157 "chip->q_pri_val_reg=%x, "
158 "chip->rc_q_maxsize_reg=%x, "
159 "chip->bri_q_maxsize_reg=%x, "
160 "chip->comp_resp_timeout_reg=%x, "
161 "chip->bus_slave_control_reg=%x, "
162 "chip->deadlock_avoid_type_reg=%x, "
163 "chip->intpin_reg_wpermit_reg0=%x, "
164 "chip->intpin_reg_wpermit_reg1=%x, "
165 "chip->intpin_reg_wpermit_reg2=%x, "
166 "chip->intpin_reg_wpermit_reg3=%x\n", __func__,
169 chip->rc_q_maxsize_reg,
170 chip->bri_q_maxsize_reg,
171 chip->comp_resp_timeout_reg,
172 chip->bus_slave_control_reg,
173 chip->deadlock_avoid_type_reg,
174 chip->intpin_reg_wpermit_reg0,
175 chip->intpin_reg_wpermit_reg1,
176 chip->intpin_reg_wpermit_reg2,
177 chip->intpin_reg_wpermit_reg3);
178 for (i = 0; i < MAX_NUM_INT_REDUCE_CONTROL_REG; i++) {
179 chip->int_reduce_control_reg[i] =
180 ioread32(p + PCH_PHUB_INT_REDUCE_CONTROL_REG_BASE + 4 * i);
181 dev_dbg(&pdev->dev, "%s : "
182 "chip->int_reduce_control_reg[%d]=%x\n",
183 __func__, i, chip->int_reduce_control_reg[i]);
185 chip->clkcfg_reg = ioread32(p + CLKCFG_REG_OFFSET);
188 /* pch_phub_restore_reg_conf - restore register configuration */
189 static void pch_phub_restore_reg_conf(struct pci_dev *pdev)
192 struct pch_phub_reg *chip = pci_get_drvdata(pdev);
194 p = chip->pch_phub_base_address;
196 iowrite32(chip->phub_id_reg, p + PCH_PHUB_ID_REG);
197 iowrite32(chip->q_pri_val_reg, p + PCH_PHUB_QUEUE_PRI_VAL_REG);
198 iowrite32(chip->rc_q_maxsize_reg, p + PCH_PHUB_RC_QUEUE_MAXSIZE_REG);
199 iowrite32(chip->bri_q_maxsize_reg, p + PCH_PHUB_BRI_QUEUE_MAXSIZE_REG);
200 iowrite32(chip->comp_resp_timeout_reg,
201 p + PCH_PHUB_COMP_RESP_TIMEOUT_REG);
202 iowrite32(chip->bus_slave_control_reg,
203 p + PCH_PHUB_BUS_SLAVE_CONTROL_REG);
204 iowrite32(chip->deadlock_avoid_type_reg,
205 p + PCH_PHUB_DEADLOCK_AVOID_TYPE_REG);
206 iowrite32(chip->intpin_reg_wpermit_reg0,
207 p + PCH_PHUB_INTPIN_REG_WPERMIT_REG0);
208 iowrite32(chip->intpin_reg_wpermit_reg1,
209 p + PCH_PHUB_INTPIN_REG_WPERMIT_REG1);
210 iowrite32(chip->intpin_reg_wpermit_reg2,
211 p + PCH_PHUB_INTPIN_REG_WPERMIT_REG2);
212 iowrite32(chip->intpin_reg_wpermit_reg3,
213 p + PCH_PHUB_INTPIN_REG_WPERMIT_REG3);
214 dev_dbg(&pdev->dev, "%s : "
215 "chip->phub_id_reg=%x, "
216 "chip->q_pri_val_reg=%x, "
217 "chip->rc_q_maxsize_reg=%x, "
218 "chip->bri_q_maxsize_reg=%x, "
219 "chip->comp_resp_timeout_reg=%x, "
220 "chip->bus_slave_control_reg=%x, "
221 "chip->deadlock_avoid_type_reg=%x, "
222 "chip->intpin_reg_wpermit_reg0=%x, "
223 "chip->intpin_reg_wpermit_reg1=%x, "
224 "chip->intpin_reg_wpermit_reg2=%x, "
225 "chip->intpin_reg_wpermit_reg3=%x\n", __func__,
228 chip->rc_q_maxsize_reg,
229 chip->bri_q_maxsize_reg,
230 chip->comp_resp_timeout_reg,
231 chip->bus_slave_control_reg,
232 chip->deadlock_avoid_type_reg,
233 chip->intpin_reg_wpermit_reg0,
234 chip->intpin_reg_wpermit_reg1,
235 chip->intpin_reg_wpermit_reg2,
236 chip->intpin_reg_wpermit_reg3);
237 for (i = 0; i < MAX_NUM_INT_REDUCE_CONTROL_REG; i++) {
238 iowrite32(chip->int_reduce_control_reg[i],
239 p + PCH_PHUB_INT_REDUCE_CONTROL_REG_BASE + 4 * i);
240 dev_dbg(&pdev->dev, "%s : "
241 "chip->int_reduce_control_reg[%d]=%x\n",
242 __func__, i, chip->int_reduce_control_reg[i]);
245 iowrite32(chip->clkcfg_reg, p + CLKCFG_REG_OFFSET);
249 * pch_phub_read_serial_rom() - Reading Serial ROM
250 * @offset_address: Serial ROM offset address to read.
251 * @data: Read buffer for specified Serial ROM value.
253 static void pch_phub_read_serial_rom(struct pch_phub_reg *chip,
254 unsigned int offset_address, u8 *data)
256 void __iomem *mem_addr = chip->pch_phub_extrom_base_address +
259 *data = ioread8(mem_addr);
263 * pch_phub_write_serial_rom() - Writing Serial ROM
264 * @offset_address: Serial ROM offset address.
265 * @data: Serial ROM value to write.
267 static int pch_phub_write_serial_rom(struct pch_phub_reg *chip,
268 unsigned int offset_address, u8 data)
270 void __iomem *mem_addr = chip->pch_phub_extrom_base_address +
271 (offset_address & PCH_WORD_ADDR_MASK);
273 unsigned int word_data;
276 pos = (offset_address % 4) * 8;
277 mask = ~(0xFF << pos);
279 iowrite32(PCH_PHUB_ROM_WRITE_ENABLE,
280 chip->pch_phub_extrom_base_address + PHUB_CONTROL);
282 word_data = ioread32(mem_addr);
283 iowrite32((word_data & mask) | (u32)data << pos, mem_addr);
286 while (ioread8(chip->pch_phub_extrom_base_address +
287 PHUB_STATUS) != 0x00) {
289 if (i == PHUB_TIMEOUT)
294 iowrite32(PCH_PHUB_ROM_WRITE_DISABLE,
295 chip->pch_phub_extrom_base_address + PHUB_CONTROL);
301 * pch_phub_read_serial_rom_val() - Read Serial ROM value
302 * @offset_address: Serial ROM address offset value.
303 * @data: Serial ROM value to read.
305 static void pch_phub_read_serial_rom_val(struct pch_phub_reg *chip,
306 unsigned int offset_address, u8 *data)
308 unsigned int mem_addr;
310 mem_addr = PCH_PHUB_ROM_START_ADDR_EG20T +
311 pch_phub_mac_offset[offset_address];
313 pch_phub_read_serial_rom(chip, mem_addr, data);
317 * pch_phub_write_serial_rom_val() - writing Serial ROM value
318 * @offset_address: Serial ROM address offset value.
319 * @data: Serial ROM value.
321 static int pch_phub_write_serial_rom_val(struct pch_phub_reg *chip,
322 unsigned int offset_address, u8 data)
325 unsigned int mem_addr;
327 mem_addr = PCH_PHUB_ROM_START_ADDR_EG20T +
328 pch_phub_mac_offset[offset_address];
330 retval = pch_phub_write_serial_rom(chip, mem_addr, data);
335 /* pch_phub_gbe_serial_rom_conf - makes Serial ROM header format configuration
336 * for Gigabit Ethernet MAC address
338 static int pch_phub_gbe_serial_rom_conf(struct pch_phub_reg *chip)
342 retval = pch_phub_write_serial_rom(chip, 0x0b, 0xbc);
343 retval |= pch_phub_write_serial_rom(chip, 0x0a, 0x10);
344 retval |= pch_phub_write_serial_rom(chip, 0x09, 0x01);
345 retval |= pch_phub_write_serial_rom(chip, 0x08, 0x02);
347 retval |= pch_phub_write_serial_rom(chip, 0x0f, 0x00);
348 retval |= pch_phub_write_serial_rom(chip, 0x0e, 0x00);
349 retval |= pch_phub_write_serial_rom(chip, 0x0d, 0x00);
350 retval |= pch_phub_write_serial_rom(chip, 0x0c, 0x80);
352 retval |= pch_phub_write_serial_rom(chip, 0x13, 0xbc);
353 retval |= pch_phub_write_serial_rom(chip, 0x12, 0x10);
354 retval |= pch_phub_write_serial_rom(chip, 0x11, 0x01);
355 retval |= pch_phub_write_serial_rom(chip, 0x10, 0x18);
357 retval |= pch_phub_write_serial_rom(chip, 0x1b, 0xbc);
358 retval |= pch_phub_write_serial_rom(chip, 0x1a, 0x10);
359 retval |= pch_phub_write_serial_rom(chip, 0x19, 0x01);
360 retval |= pch_phub_write_serial_rom(chip, 0x18, 0x19);
362 retval |= pch_phub_write_serial_rom(chip, 0x23, 0xbc);
363 retval |= pch_phub_write_serial_rom(chip, 0x22, 0x10);
364 retval |= pch_phub_write_serial_rom(chip, 0x21, 0x01);
365 retval |= pch_phub_write_serial_rom(chip, 0x20, 0x3a);
367 retval |= pch_phub_write_serial_rom(chip, 0x27, 0x01);
368 retval |= pch_phub_write_serial_rom(chip, 0x26, 0x00);
369 retval |= pch_phub_write_serial_rom(chip, 0x25, 0x00);
370 retval |= pch_phub_write_serial_rom(chip, 0x24, 0x00);
376 * pch_phub_read_gbe_mac_addr() - Read Gigabit Ethernet MAC address
377 * @offset_address: Gigabit Ethernet MAC address offset value.
378 * @data: Buffer of the Gigabit Ethernet MAC address value.
380 static void pch_phub_read_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data)
383 for (i = 0; i < ETH_ALEN; i++)
384 pch_phub_read_serial_rom_val(chip, i, &data[i]);
388 * pch_phub_write_gbe_mac_addr() - Write MAC address
389 * @offset_address: Gigabit Ethernet MAC address offset value.
390 * @data: Gigabit Ethernet MAC address value.
392 static int pch_phub_write_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data)
397 retval = pch_phub_gbe_serial_rom_conf(chip);
401 for (i = 0; i < ETH_ALEN; i++) {
402 retval = pch_phub_write_serial_rom_val(chip, i, data[i]);
410 static ssize_t pch_phub_bin_read(struct file *filp, struct kobject *kobj,
411 struct bin_attribute *attr, char *buf,
412 loff_t off, size_t count)
414 unsigned int rom_signature;
415 unsigned char rom_length;
417 unsigned int addr_offset;
418 unsigned int orom_size;
422 struct pch_phub_reg *chip =
423 dev_get_drvdata(container_of(kobj, struct device, kobj));
425 ret = mutex_lock_interruptible(&pch_phub_mutex);
428 goto return_err_nomutex;
431 /* Get Rom signature */
432 pch_phub_read_serial_rom(chip, 0x80, (unsigned char *)&rom_signature);
433 rom_signature &= 0xff;
434 pch_phub_read_serial_rom(chip, 0x81, (unsigned char *)&tmp);
435 rom_signature |= (tmp & 0xff) << 8;
436 if (rom_signature == 0xAA55) {
437 pch_phub_read_serial_rom(chip, 0x82, &rom_length);
438 orom_size = rom_length * 512;
439 if (orom_size < off) {
443 if (orom_size < count) {
448 for (addr_offset = 0; addr_offset < count; addr_offset++) {
449 pch_phub_read_serial_rom(chip, 0x80 + addr_offset + off,
457 mutex_unlock(&pch_phub_mutex);
461 mutex_unlock(&pch_phub_mutex);
466 static ssize_t pch_phub_bin_write(struct file *filp, struct kobject *kobj,
467 struct bin_attribute *attr,
468 char *buf, loff_t off, size_t count)
471 unsigned int addr_offset;
473 struct pch_phub_reg *chip =
474 dev_get_drvdata(container_of(kobj, struct device, kobj));
476 ret = mutex_lock_interruptible(&pch_phub_mutex);
480 if (off > PCH_PHUB_OROM_SIZE) {
484 if (count > PCH_PHUB_OROM_SIZE) {
489 for (addr_offset = 0; addr_offset < count; addr_offset++) {
490 if (PCH_PHUB_OROM_SIZE < off + addr_offset)
493 ret = pch_phub_write_serial_rom(chip, 0x80 + addr_offset + off,
502 mutex_unlock(&pch_phub_mutex);
506 mutex_unlock(&pch_phub_mutex);
510 static ssize_t show_pch_mac(struct device *dev, struct device_attribute *attr,
514 struct pch_phub_reg *chip = dev_get_drvdata(dev);
516 pch_phub_read_gbe_mac_addr(chip, mac);
518 return sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x\n",
519 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
522 static ssize_t store_pch_mac(struct device *dev, struct device_attribute *attr,
523 const char *buf, size_t count)
526 struct pch_phub_reg *chip = dev_get_drvdata(dev);
531 sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
532 (u32 *)&mac[0], (u32 *)&mac[1], (u32 *)&mac[2], (u32 *)&mac[3],
533 (u32 *)&mac[4], (u32 *)&mac[5]);
535 pch_phub_write_gbe_mac_addr(chip, mac);
540 static DEVICE_ATTR(pch_mac, S_IRUGO | S_IWUSR, show_pch_mac, store_pch_mac);
542 static struct bin_attribute pch_bin_attr = {
544 .name = "pch_firmware",
545 .mode = S_IRUGO | S_IWUSR,
547 .size = PCH_PHUB_OROM_SIZE + 1,
548 .read = pch_phub_bin_read,
549 .write = pch_phub_bin_write,
552 static int __devinit pch_phub_probe(struct pci_dev *pdev,
553 const struct pci_device_id *id)
559 struct pch_phub_reg *chip;
561 chip = kzalloc(sizeof(struct pch_phub_reg), GFP_KERNEL);
565 ret = pci_enable_device(pdev);
568 "%s : pci_enable_device FAILED(ret=%d)", __func__, ret);
569 goto err_pci_enable_dev;
571 dev_dbg(&pdev->dev, "%s : pci_enable_device returns %d\n", __func__,
574 ret = pci_request_regions(pdev, KBUILD_MODNAME);
577 "%s : pci_request_regions FAILED(ret=%d)", __func__, ret);
578 goto err_req_regions;
580 dev_dbg(&pdev->dev, "%s : "
581 "pci_request_regions returns %d\n", __func__, ret);
583 chip->pch_phub_base_address = pci_iomap(pdev, 1, 0);
586 if (chip->pch_phub_base_address == 0) {
587 dev_err(&pdev->dev, "%s : pci_iomap FAILED", __func__);
591 dev_dbg(&pdev->dev, "%s : pci_iomap SUCCESS and value "
592 "in pch_phub_base_address variable is %p\n", __func__,
593 chip->pch_phub_base_address);
594 chip->pch_phub_extrom_base_address = pci_map_rom(pdev, &rom_size);
596 if (chip->pch_phub_extrom_base_address == 0) {
597 dev_err(&pdev->dev, "%s : pci_map_rom FAILED", __func__);
601 dev_dbg(&pdev->dev, "%s : "
602 "pci_map_rom SUCCESS and value in "
603 "pch_phub_extrom_base_address variable is %p\n", __func__,
604 chip->pch_phub_extrom_base_address);
606 if (id->driver_data == 1) {
607 retval = sysfs_create_file(&pdev->dev.kobj,
608 &dev_attr_pch_mac.attr);
610 goto err_sysfs_create;
612 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
616 pch_phub_read_modify_write_reg(chip,
617 (unsigned int)CLKCFG_REG_OFFSET,
621 /* set the prefech value */
622 iowrite32(0x000affaa, chip->pch_phub_base_address + 0x14);
623 /* set the interrupt delay value */
624 iowrite32(0x25, chip->pch_phub_base_address + 0x44);
625 } else if (id->driver_data == 2) {
626 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
628 goto err_sysfs_create;
629 /* set the prefech value
630 * Device2(USB OHCI #1/ USB EHCI #1/ USB Device):a
631 * Device4(SDIO #0,1,2):f
633 * Device8(USB OHCI #0/ USB EHCI #0):a
635 iowrite32(0x000affa0, chip->pch_phub_base_address + 0x14);
637 pci_set_drvdata(pdev, chip);
641 sysfs_remove_file(&pdev->dev.kobj, &dev_attr_pch_mac.attr);
644 pci_unmap_rom(pdev, chip->pch_phub_extrom_base_address);
646 pci_iounmap(pdev, chip->pch_phub_base_address);
648 pci_release_regions(pdev);
650 pci_disable_device(pdev);
653 dev_err(&pdev->dev, "%s returns %d\n", __func__, ret);
657 static void __devexit pch_phub_remove(struct pci_dev *pdev)
659 struct pch_phub_reg *chip = pci_get_drvdata(pdev);
661 sysfs_remove_file(&pdev->dev.kobj, &dev_attr_pch_mac.attr);
662 sysfs_remove_bin_file(&pdev->dev.kobj, &pch_bin_attr);
663 pci_unmap_rom(pdev, chip->pch_phub_extrom_base_address);
664 pci_iounmap(pdev, chip->pch_phub_base_address);
665 pci_release_regions(pdev);
666 pci_disable_device(pdev);
672 static int pch_phub_suspend(struct pci_dev *pdev, pm_message_t state)
676 pch_phub_save_reg_conf(pdev);
677 ret = pci_save_state(pdev);
680 " %s -pci_save_state returns %d\n", __func__, ret);
683 pci_enable_wake(pdev, PCI_D3hot, 0);
684 pci_disable_device(pdev);
685 pci_set_power_state(pdev, pci_choose_state(pdev, state));
690 static int pch_phub_resume(struct pci_dev *pdev)
694 pci_set_power_state(pdev, PCI_D0);
695 pci_restore_state(pdev);
696 ret = pci_enable_device(pdev);
699 "%s-pci_enable_device failed(ret=%d) ", __func__, ret);
703 pci_enable_wake(pdev, PCI_D3hot, 0);
704 pch_phub_restore_reg_conf(pdev);
709 #define pch_phub_suspend NULL
710 #define pch_phub_resume NULL
711 #endif /* CONFIG_PM */
713 static struct pci_device_id pch_phub_pcidev_id[] = {
714 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH1_PHUB), 1, },
715 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7213_PHUB), 2, },
719 static struct pci_driver pch_phub_driver = {
721 .id_table = pch_phub_pcidev_id,
722 .probe = pch_phub_probe,
723 .remove = __devexit_p(pch_phub_remove),
724 .suspend = pch_phub_suspend,
725 .resume = pch_phub_resume
728 static int __init pch_phub_pci_init(void)
730 return pci_register_driver(&pch_phub_driver);
733 static void __exit pch_phub_pci_exit(void)
735 pci_unregister_driver(&pch_phub_driver);
738 module_init(pch_phub_pci_init);
739 module_exit(pch_phub_pci_exit);
741 MODULE_DESCRIPTION("PCH Packet Hub PCI Driver");
742 MODULE_LICENSE("GPL");