aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/pch_phub.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2011-12-05 18:20:17 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-12-05 18:20:17 -0500
commit742eaa6a6e356a16788ce6530271de89bc4f8fb5 (patch)
tree12fc040daab06ac796c61c1d92bfad9bb054d1c1 /drivers/misc/pch_phub.c
parentba8bb18a03f8c7508565c385576a5431a4ad804a (diff)
parentae72fd588a2b302222769b44775912b83f0785eb (diff)
Merge branch 'for-rmk' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux into devel-stable
Conflicts: arch/arm/common/gic.c arch/arm/plat-omap/include/plat/common.h
Diffstat (limited to 'drivers/misc/pch_phub.c')
-rw-r--r--drivers/misc/pch_phub.c81
1 files changed, 59 insertions, 22 deletions
diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c
index dee33addcae..10fc4785dba 100644
--- a/drivers/misc/pch_phub.c
+++ b/drivers/misc/pch_phub.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD. 2 * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 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 5 * it under the terms of the GNU General Public License as published by
@@ -41,10 +41,10 @@
41#define PCH_PHUB_ROM_START_ADDR_EG20T 0x80 /* ROM data area start address offset 41#define PCH_PHUB_ROM_START_ADDR_EG20T 0x80 /* ROM data area start address offset
42 (Intel EG20T PCH)*/ 42 (Intel EG20T PCH)*/
43#define PCH_PHUB_ROM_START_ADDR_ML7213 0x400 /* ROM data area start address 43#define PCH_PHUB_ROM_START_ADDR_ML7213 0x400 /* ROM data area start address
44 offset(OKI SEMICONDUCTOR ML7213) 44 offset(LAPIS Semicon ML7213)
45 */ 45 */
46#define PCH_PHUB_ROM_START_ADDR_ML7223 0x400 /* ROM data area start address 46#define PCH_PHUB_ROM_START_ADDR_ML7223 0x400 /* ROM data area start address
47 offset(OKI SEMICONDUCTOR ML7223) 47 offset(LAPIS Semicon ML7223)
48 */ 48 */
49 49
50/* MAX number of INT_REDUCE_CONTROL registers */ 50/* MAX number of INT_REDUCE_CONTROL registers */
@@ -73,6 +73,9 @@
73#define PCI_DEVICE_ID_ROHM_ML7223_mPHUB 0x8012 /* for Bus-m */ 73#define PCI_DEVICE_ID_ROHM_ML7223_mPHUB 0x8012 /* for Bus-m */
74#define PCI_DEVICE_ID_ROHM_ML7223_nPHUB 0x8002 /* for Bus-n */ 74#define PCI_DEVICE_ID_ROHM_ML7223_nPHUB 0x8002 /* for Bus-n */
75 75
76/* Macros for ML7831 */
77#define PCI_DEVICE_ID_ROHM_ML7831_PHUB 0x8801
78
76/* SROM ACCESS Macro */ 79/* SROM ACCESS Macro */
77#define PCH_WORD_ADDR_MASK (~((1 << 2) - 1)) 80#define PCH_WORD_ADDR_MASK (~((1 << 2) - 1))
78 81
@@ -115,6 +118,7 @@
115 * @pch_mac_start_address: MAC address area start address 118 * @pch_mac_start_address: MAC address area start address
116 * @pch_opt_rom_start_address: Option ROM start address 119 * @pch_opt_rom_start_address: Option ROM start address
117 * @ioh_type: Save IOH type 120 * @ioh_type: Save IOH type
121 * @pdev: pointer to pci device struct
118 */ 122 */
119struct pch_phub_reg { 123struct pch_phub_reg {
120 u32 phub_id_reg; 124 u32 phub_id_reg;
@@ -136,6 +140,7 @@ struct pch_phub_reg {
136 u32 pch_mac_start_address; 140 u32 pch_mac_start_address;
137 u32 pch_opt_rom_start_address; 141 u32 pch_opt_rom_start_address;
138 int ioh_type; 142 int ioh_type;
143 struct pci_dev *pdev;
139}; 144};
140 145
141/* SROM SPEC for MAC address assignment offset */ 146/* SROM SPEC for MAC address assignment offset */
@@ -471,7 +476,7 @@ static int pch_phub_write_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data)
471 int retval; 476 int retval;
472 int i; 477 int i;
473 478
474 if (chip->ioh_type == 1) /* EG20T */ 479 if ((chip->ioh_type == 1) || (chip->ioh_type == 5)) /* EG20T or ML7831*/
475 retval = pch_phub_gbe_serial_rom_conf(chip); 480 retval = pch_phub_gbe_serial_rom_conf(chip);
476 else /* ML7223 */ 481 else /* ML7223 */
477 retval = pch_phub_gbe_serial_rom_conf_mp(chip); 482 retval = pch_phub_gbe_serial_rom_conf_mp(chip);
@@ -498,6 +503,7 @@ static ssize_t pch_phub_bin_read(struct file *filp, struct kobject *kobj,
498 unsigned int orom_size; 503 unsigned int orom_size;
499 int ret; 504 int ret;
500 int err; 505 int err;
506 ssize_t rom_size;
501 507
502 struct pch_phub_reg *chip = 508 struct pch_phub_reg *chip =
503 dev_get_drvdata(container_of(kobj, struct device, kobj)); 509 dev_get_drvdata(container_of(kobj, struct device, kobj));
@@ -509,6 +515,10 @@ static ssize_t pch_phub_bin_read(struct file *filp, struct kobject *kobj,
509 } 515 }
510 516
511 /* Get Rom signature */ 517 /* Get Rom signature */
518 chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size);
519 if (!chip->pch_phub_extrom_base_address)
520 goto exrom_map_err;
521
512 pch_phub_read_serial_rom(chip, chip->pch_opt_rom_start_address, 522 pch_phub_read_serial_rom(chip, chip->pch_opt_rom_start_address,
513 (unsigned char *)&rom_signature); 523 (unsigned char *)&rom_signature);
514 rom_signature &= 0xff; 524 rom_signature &= 0xff;
@@ -539,10 +549,13 @@ static ssize_t pch_phub_bin_read(struct file *filp, struct kobject *kobj,
539 goto return_err; 549 goto return_err;
540 } 550 }
541return_ok: 551return_ok:
552 pci_unmap_rom(chip->pdev, chip->pch_phub_extrom_base_address);
542 mutex_unlock(&pch_phub_mutex); 553 mutex_unlock(&pch_phub_mutex);
543 return addr_offset; 554 return addr_offset;
544 555
545return_err: 556return_err:
557 pci_unmap_rom(chip->pdev, chip->pch_phub_extrom_base_address);
558exrom_map_err:
546 mutex_unlock(&pch_phub_mutex); 559 mutex_unlock(&pch_phub_mutex);
547return_err_nomutex: 560return_err_nomutex:
548 return err; 561 return err;
@@ -555,6 +568,7 @@ static ssize_t pch_phub_bin_write(struct file *filp, struct kobject *kobj,
555 int err; 568 int err;
556 unsigned int addr_offset; 569 unsigned int addr_offset;
557 int ret; 570 int ret;
571 ssize_t rom_size;
558 struct pch_phub_reg *chip = 572 struct pch_phub_reg *chip =
559 dev_get_drvdata(container_of(kobj, struct device, kobj)); 573 dev_get_drvdata(container_of(kobj, struct device, kobj));
560 574
@@ -571,6 +585,12 @@ static ssize_t pch_phub_bin_write(struct file *filp, struct kobject *kobj,
571 goto return_ok; 585 goto return_ok;
572 } 586 }
573 587
588 chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size);
589 if (!chip->pch_phub_extrom_base_address) {
590 err = -ENOMEM;
591 goto exrom_map_err;
592 }
593
574 for (addr_offset = 0; addr_offset < count; addr_offset++) { 594 for (addr_offset = 0; addr_offset < count; addr_offset++) {
575 if (PCH_PHUB_OROM_SIZE < off + addr_offset) 595 if (PCH_PHUB_OROM_SIZE < off + addr_offset)
576 goto return_ok; 596 goto return_ok;
@@ -585,10 +605,14 @@ static ssize_t pch_phub_bin_write(struct file *filp, struct kobject *kobj,
585 } 605 }
586 606
587return_ok: 607return_ok:
608 pci_unmap_rom(chip->pdev, chip->pch_phub_extrom_base_address);
588 mutex_unlock(&pch_phub_mutex); 609 mutex_unlock(&pch_phub_mutex);
589 return addr_offset; 610 return addr_offset;
590 611
591return_err: 612return_err:
613 pci_unmap_rom(chip->pdev, chip->pch_phub_extrom_base_address);
614
615exrom_map_err:
592 mutex_unlock(&pch_phub_mutex); 616 mutex_unlock(&pch_phub_mutex);
593 return err; 617 return err;
594} 618}
@@ -598,8 +622,14 @@ static ssize_t show_pch_mac(struct device *dev, struct device_attribute *attr,
598{ 622{
599 u8 mac[8]; 623 u8 mac[8];
600 struct pch_phub_reg *chip = dev_get_drvdata(dev); 624 struct pch_phub_reg *chip = dev_get_drvdata(dev);
625 ssize_t rom_size;
626
627 chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size);
628 if (!chip->pch_phub_extrom_base_address)
629 return -ENOMEM;
601 630
602 pch_phub_read_gbe_mac_addr(chip, mac); 631 pch_phub_read_gbe_mac_addr(chip, mac);
632 pci_unmap_rom(chip->pdev, chip->pch_phub_extrom_base_address);
603 633
604 return sprintf(buf, "%pM\n", mac); 634 return sprintf(buf, "%pM\n", mac);
605} 635}
@@ -608,6 +638,7 @@ static ssize_t store_pch_mac(struct device *dev, struct device_attribute *attr,
608 const char *buf, size_t count) 638 const char *buf, size_t count)
609{ 639{
610 u8 mac[6]; 640 u8 mac[6];
641 ssize_t rom_size;
611 struct pch_phub_reg *chip = dev_get_drvdata(dev); 642 struct pch_phub_reg *chip = dev_get_drvdata(dev);
612 643
613 if (count != 18) 644 if (count != 18)
@@ -617,7 +648,12 @@ static ssize_t store_pch_mac(struct device *dev, struct device_attribute *attr,
617 (u32 *)&mac[0], (u32 *)&mac[1], (u32 *)&mac[2], (u32 *)&mac[3], 648 (u32 *)&mac[0], (u32 *)&mac[1], (u32 *)&mac[2], (u32 *)&mac[3],
618 (u32 *)&mac[4], (u32 *)&mac[5]); 649 (u32 *)&mac[4], (u32 *)&mac[5]);
619 650
651 chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size);
652 if (!chip->pch_phub_extrom_base_address)
653 return -ENOMEM;
654
620 pch_phub_write_gbe_mac_addr(chip, mac); 655 pch_phub_write_gbe_mac_addr(chip, mac);
656 pci_unmap_rom(chip->pdev, chip->pch_phub_extrom_base_address);
621 657
622 return count; 658 return count;
623} 659}
@@ -640,7 +676,6 @@ static int __devinit pch_phub_probe(struct pci_dev *pdev,
640 int retval; 676 int retval;
641 677
642 int ret; 678 int ret;
643 ssize_t rom_size;
644 struct pch_phub_reg *chip; 679 struct pch_phub_reg *chip;
645 680
646 chip = kzalloc(sizeof(struct pch_phub_reg), GFP_KERNEL); 681 chip = kzalloc(sizeof(struct pch_phub_reg), GFP_KERNEL);
@@ -677,19 +712,7 @@ static int __devinit pch_phub_probe(struct pci_dev *pdev,
677 "in pch_phub_base_address variable is %p\n", __func__, 712 "in pch_phub_base_address variable is %p\n", __func__,
678 chip->pch_phub_base_address); 713 chip->pch_phub_base_address);
679 714
680 if (id->driver_data != 3) { 715 chip->pdev = pdev; /* Save pci device struct */
681 chip->pch_phub_extrom_base_address =\
682 pci_map_rom(pdev, &rom_size);
683 if (chip->pch_phub_extrom_base_address == 0) {
684 dev_err(&pdev->dev, "%s: pci_map_rom FAILED", __func__);
685 ret = -ENOMEM;
686 goto err_pci_map;
687 }
688 dev_dbg(&pdev->dev, "%s : "
689 "pci_map_rom SUCCESS and value in "
690 "pch_phub_extrom_base_address variable is %p\n",
691 __func__, chip->pch_phub_extrom_base_address);
692 }
693 716
694 if (id->driver_data == 1) { /* EG20T PCH */ 717 if (id->driver_data == 1) { /* EG20T PCH */
695 const char *board_name; 718 const char *board_name;
@@ -763,6 +786,22 @@ static int __devinit pch_phub_probe(struct pci_dev *pdev,
763 chip->pch_opt_rom_start_address =\ 786 chip->pch_opt_rom_start_address =\
764 PCH_PHUB_ROM_START_ADDR_ML7223; 787 PCH_PHUB_ROM_START_ADDR_ML7223;
765 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_ML7223; 788 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_ML7223;
789 } else if (id->driver_data == 5) { /* ML7831 */
790 retval = sysfs_create_file(&pdev->dev.kobj,
791 &dev_attr_pch_mac.attr);
792 if (retval)
793 goto err_sysfs_create;
794
795 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
796 if (retval)
797 goto exit_bin_attr;
798
799 /* set the prefech value */
800 iowrite32(0x000affaa, chip->pch_phub_base_address + 0x14);
801 /* set the interrupt delay value */
802 iowrite32(0x25, chip->pch_phub_base_address + 0x44);
803 chip->pch_opt_rom_start_address = PCH_PHUB_ROM_START_ADDR_EG20T;
804 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_EG20T;
766 } 805 }
767 806
768 chip->ioh_type = id->driver_data; 807 chip->ioh_type = id->driver_data;
@@ -773,8 +812,6 @@ exit_bin_attr:
773 sysfs_remove_file(&pdev->dev.kobj, &dev_attr_pch_mac.attr); 812 sysfs_remove_file(&pdev->dev.kobj, &dev_attr_pch_mac.attr);
774 813
775err_sysfs_create: 814err_sysfs_create:
776 pci_unmap_rom(pdev, chip->pch_phub_extrom_base_address);
777err_pci_map:
778 pci_iounmap(pdev, chip->pch_phub_base_address); 815 pci_iounmap(pdev, chip->pch_phub_base_address);
779err_pci_iomap: 816err_pci_iomap:
780 pci_release_regions(pdev); 817 pci_release_regions(pdev);
@@ -792,7 +829,6 @@ static void __devexit pch_phub_remove(struct pci_dev *pdev)
792 829
793 sysfs_remove_file(&pdev->dev.kobj, &dev_attr_pch_mac.attr); 830 sysfs_remove_file(&pdev->dev.kobj, &dev_attr_pch_mac.attr);
794 sysfs_remove_bin_file(&pdev->dev.kobj, &pch_bin_attr); 831 sysfs_remove_bin_file(&pdev->dev.kobj, &pch_bin_attr);
795 pci_unmap_rom(pdev, chip->pch_phub_extrom_base_address);
796 pci_iounmap(pdev, chip->pch_phub_base_address); 832 pci_iounmap(pdev, chip->pch_phub_base_address);
797 pci_release_regions(pdev); 833 pci_release_regions(pdev);
798 pci_disable_device(pdev); 834 pci_disable_device(pdev);
@@ -847,6 +883,7 @@ static struct pci_device_id pch_phub_pcidev_id[] = {
847 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7213_PHUB), 2, }, 883 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7213_PHUB), 2, },
848 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7223_mPHUB), 3, }, 884 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7223_mPHUB), 3, },
849 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7223_nPHUB), 4, }, 885 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7223_nPHUB), 4, },
886 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7831_PHUB), 5, },
850 { } 887 { }
851}; 888};
852MODULE_DEVICE_TABLE(pci, pch_phub_pcidev_id); 889MODULE_DEVICE_TABLE(pci, pch_phub_pcidev_id);
@@ -873,5 +910,5 @@ static void __exit pch_phub_pci_exit(void)
873module_init(pch_phub_pci_init); 910module_init(pch_phub_pci_init);
874module_exit(pch_phub_pci_exit); 911module_exit(pch_phub_pci_exit);
875 912
876MODULE_DESCRIPTION("Intel EG20T PCH/OKI SEMICONDUCTOR IOH(ML7213/ML7223) PHUB"); 913MODULE_DESCRIPTION("Intel EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7223) PHUB");
877MODULE_LICENSE("GPL"); 914MODULE_LICENSE("GPL");