aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-02-06 07:06:39 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-02-06 14:21:51 -0500
commit2703d4b2e673cc240ad06d79d131fd1d0f77d65d (patch)
tree0e5bd20e88e2de4912ba44de8e0b6764c4028791 /drivers/misc
parent890537b3ac953ad2cc4f5ecb83744e967ae2aa31 (diff)
mei: sperate interface and pci code into two files
leave misc file operations in the main and move PCI related code into pci-me Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/Makefile1
-rw-r--r--drivers/misc/mei/main.c354
-rw-r--r--drivers/misc/mei/mei_dev.h3
-rw-r--r--drivers/misc/mei/pci-me.c393
4 files changed, 409 insertions, 342 deletions
diff --git a/drivers/misc/mei/Makefile b/drivers/misc/mei/Makefile
index 9f719339e594..068f55354811 100644
--- a/drivers/misc/mei/Makefile
+++ b/drivers/misc/mei/Makefile
@@ -11,3 +11,4 @@ mei-objs += main.o
11mei-objs += amthif.o 11mei-objs += amthif.o
12mei-objs += wd.o 12mei-objs += wd.o
13mei-objs += client.o 13mei-objs += client.o
14mei-objs += pci-me.o
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 123c663509ef..018623c9a8e1 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -43,54 +43,6 @@
43#include "hw-me.h" 43#include "hw-me.h"
44#include "client.h" 44#include "client.h"
45 45
46/* AMT device is a singleton on the platform */
47static struct pci_dev *mei_pdev;
48
49/* mei_pci_tbl - PCI Device ID Table */
50static DEFINE_PCI_DEVICE_TABLE(mei_pci_tbl) = {
51 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)},
52 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G35)},
53 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82Q965)},
54 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G965)},
55 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82GM965)},
56 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82GME965)},
57 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82Q35)},
58 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82G33)},
59 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82Q33)},
60 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82X38)},
61 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_3200)},
62 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_6)},
63 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_7)},
64 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_8)},
65 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_9)},
66 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_10)},
67 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_1)},
68 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_2)},
69 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_3)},
70 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_4)},
71 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_1)},
72 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_2)},
73 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_3)},
74 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_4)},
75 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_IBXPK_1)},
76 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_IBXPK_2)},
77 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_CPT_1)},
78 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PBG_1)},
79 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_1)},
80 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_2)},
81 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_3)},
82 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT)},
83 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_LP)},
84
85 /* required last entry */
86 {0, }
87};
88
89MODULE_DEVICE_TABLE(pci, mei_pci_tbl);
90
91static DEFINE_MUTEX(mei_mutex);
92
93
94/** 46/**
95 * mei_open - the open function 47 * mei_open - the open function
96 * 48 *
@@ -101,15 +53,20 @@ static DEFINE_MUTEX(mei_mutex);
101 */ 53 */
102static int mei_open(struct inode *inode, struct file *file) 54static int mei_open(struct inode *inode, struct file *file)
103{ 55{
56 struct miscdevice *misc = file->private_data;
57 struct pci_dev *pdev;
104 struct mei_cl *cl; 58 struct mei_cl *cl;
105 struct mei_device *dev; 59 struct mei_device *dev;
60
106 int err; 61 int err;
107 62
108 err = -ENODEV; 63 err = -ENODEV;
109 if (!mei_pdev) 64 if (!misc->parent)
110 goto out; 65 goto out;
111 66
112 dev = pci_get_drvdata(mei_pdev); 67 pdev = container_of(misc->parent, struct pci_dev, dev);
68
69 dev = pci_get_drvdata(pdev);
113 if (!dev) 70 if (!dev)
114 goto out; 71 goto out;
115 72
@@ -787,7 +744,6 @@ static const struct file_operations mei_fops = {
787 .llseek = no_llseek 744 .llseek = no_llseek
788}; 745};
789 746
790
791/* 747/*
792 * Misc Device Struct 748 * Misc Device Struct
793 */ 749 */
@@ -797,302 +753,16 @@ static struct miscdevice mei_misc_device = {
797 .minor = MISC_DYNAMIC_MINOR, 753 .minor = MISC_DYNAMIC_MINOR,
798}; 754};
799 755
800/** 756int mei_register(struct device *dev)
801 * mei_quirk_probe - probe for devices that doesn't valid ME interface
802 * @pdev: PCI device structure
803 * @ent: entry into pci_device_table
804 *
805 * returns true if ME Interface is valid, false otherwise
806 */
807static bool mei_quirk_probe(struct pci_dev *pdev,
808 const struct pci_device_id *ent)
809{ 757{
810 u32 reg; 758 mei_misc_device.parent = dev;
811 if (ent->device == MEI_DEV_ID_PBG_1) { 759 return misc_register(&mei_misc_device);
812 pci_read_config_dword(pdev, 0x48, &reg);
813 /* make sure that bit 9 is up and bit 10 is down */
814 if ((reg & 0x600) == 0x200) {
815 dev_info(&pdev->dev, "Device doesn't have valid ME Interface\n");
816 return false;
817 }
818 }
819 return true;
820}
821/**
822 * mei_probe - Device Initialization Routine
823 *
824 * @pdev: PCI device structure
825 * @ent: entry in kcs_pci_tbl
826 *
827 * returns 0 on success, <0 on failure.
828 */
829static int mei_probe(struct pci_dev *pdev,
830 const struct pci_device_id *ent)
831{
832 struct mei_device *dev;
833 int err;
834
835 mutex_lock(&mei_mutex);
836
837 if (!mei_quirk_probe(pdev, ent)) {
838 err = -ENODEV;
839 goto end;
840 }
841
842 if (mei_pdev) {
843 err = -EEXIST;
844 goto end;
845 }
846 /* enable pci dev */
847 err = pci_enable_device(pdev);
848 if (err) {
849 dev_err(&pdev->dev, "failed to enable pci device.\n");
850 goto end;
851 }
852 /* set PCI host mastering */
853 pci_set_master(pdev);
854 /* pci request regions for mei driver */
855 err = pci_request_regions(pdev, KBUILD_MODNAME);
856 if (err) {
857 dev_err(&pdev->dev, "failed to get pci regions.\n");
858 goto disable_device;
859 }
860 /* allocates and initializes the mei dev structure */
861 dev = mei_device_init(pdev);
862 if (!dev) {
863 err = -ENOMEM;
864 goto release_regions;
865 }
866 /* mapping IO device memory */
867 dev->mem_addr = pci_iomap(pdev, 0, 0);
868 if (!dev->mem_addr) {
869 dev_err(&pdev->dev, "mapping I/O device memory failure.\n");
870 err = -ENOMEM;
871 goto free_device;
872 }
873 pci_enable_msi(pdev);
874
875 /* request and enable interrupt */
876 if (pci_dev_msi_enabled(pdev))
877 err = request_threaded_irq(pdev->irq,
878 NULL,