diff for duplicates of <20060331230309.GE17261@cosmic.amd.com> diff --git a/a/1.txt b/N1/1.txt index 313f825..1e18328 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -10,201 +10,3 @@ Jordan Crouse Senior Linux Engineer AMD - Personal Connectivity Solutions Group <www.amd.com/embeddedprocessors> --------------- next part -------------- -[PATCH] scx200_acb: Use PCI I/O resource when appropriate - -From: Jordan Crouse <jordan.crouse at amd.com> - -On the CS5535 and CS5536, the I/O resource is allocated through PCI, -so use that instead of using the MSR backdoor. - -Signed-off-by: Jordan Crouse <jordan.crouse at amd.com> ---- - - drivers/i2c/busses/scx200_acb.c | 114 +++++++++++++++++++++++++++------------ - 1 files changed, 78 insertions(+), 36 deletions(-) - -diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c -index e7a2225..454492f 100644 ---- a/drivers/i2c/busses/scx200_acb.c -+++ b/drivers/i2c/busses/scx200_acb.c -@@ -33,7 +33,6 @@ - #include <linux/delay.h> - #include <linux/mutex.h> - #include <asm/io.h> --#include <asm/msr.h> - - #include <linux/scx200.h> - -@@ -85,6 +84,10 @@ struct scx200_acb_iface { - u8 *ptr; - char needs_reset; - unsigned len; -+ -+ /* PCI device info */ -+ struct pci_dev *pdev; -+ int bar; - }; - - /* Register Definitions */ -@@ -417,7 +420,8 @@ static int scx200_acb_probe(struct scx20 - return 0; - } - --static int __init scx200_acb_create(const char *text, int base, int index) -+static int __init scx200_acb_create(char *text, unsigned int base, int index, -+ struct pci_dev *pdev, int bar) - { - struct scx200_acb_iface *iface; - struct i2c_adapter *adapter; -@@ -444,13 +448,31 @@ static int __init scx200_acb_create(con - snprintf(description, sizeof(description), "%s ACCESS.bus [%s]", - text, adapter->name); - -- if (request_region(base, 8, description) = 0) { -- printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n", -- base, base + 8-1); -- rc = -EBUSY; -- goto errout_free; -+ if (pdev != NULL) { -+ -+ iface->pdev = pdev; -+ iface->bar = bar; -+ -+ pci_enable_device_bars(iface->pdev, 1 << iface->bar); -+ -+ if (pci_request_region(iface->pdev, iface->bar, description)) { -+ printk(KERN_ERR NAME ": can't allocate PCI region %d\n", -+ iface->bar); -+ rc = -EBUSY; -+ goto errout_free; -+ } -+ -+ iface->base = pci_resource_start(iface->pdev, iface->bar); -+ } else { -+ if (request_region(base, 8, description) = 0) { -+ printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n", -+ base, base + 8 - 1); -+ rc = -EBUSY; -+ goto errout_free; -+ } -+ -+ iface->base = base; - } -- iface->base = base; - - rc = scx200_acb_probe(iface); - if (rc) { -@@ -474,7 +496,11 @@ static int __init scx200_acb_create(con - return 0; - - errout_release: -- release_region(iface->base, 8); -+ if (iface->pdev != NULL) -+ pci_release_region(iface->pdev, iface->bar); -+ else -+ release_region(iface->base, 8); -+ - errout_free: - kfree(iface); - errout: -@@ -487,49 +513,60 @@ static struct pci_device_id scx200[] = { - { }, - }; - --static struct pci_device_id divil_pci[] = { -- { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, -- { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, -- { } /* NULL entry */ -+/* On the CS5535 and CS5536, the SMBUS I/0 base is a PCI resource, so -+ we should allocate that resource through the PCI -+ subsystem. rather then going through the MSR back door. -+*/ -+ -+static struct { -+ unsigned int vendor; -+ unsigned int device; -+ char *name; -+ int bar; -+} divil_pci[] = { -+ { -+ PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA, "CS5535", 0}, { -+ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, "CS5536", 0} - }; - --#define MSR_LBAR_SMB 0x5140000B -+#define DIVIL_LENGTH (sizeof(divil_pci) / sizeof(divil_pci[0])) - - static int scx200_add_cs553x(void) - { -- u32 low, hi; -- u32 smb_base; -- -- /* Grab & reserve the SMB I/O range */ -- rdmsr(MSR_LBAR_SMB, low, hi); -+ int dev; -+ struct pci_dev *pdev; - -- /* Check the IO mask and whether SMB is enabled */ -- if (hi != 0x0000F001) { -- printk(KERN_WARNING NAME ": SMBus not enabled\n"); -- return -ENODEV; -+ for (dev = 0; dev < DIVIL_LENGTH; dev++) { -+ pdev + pci_find_device(divil_pci[dev].vendor, -+ divil_pci[dev].device, NULL); -+ if (pdev != NULL) -+ break; - } - -- /* SMBus IO size is 8 bytes */ -- smb_base = low & 0x0000FFF8; -+ if (pdev = NULL) -+ return -ENODEV; - -- return scx200_acb_create("CS5535", smb_base, 0); -+ return scx200_acb_create(divil_pci[dev].name, 0, 0, pdev, -+ divil_pci[dev].bar); - } - - static int __init scx200_acb_init(void) - { - int i; -- int rc = -ENODEV; -+ int rc = -ENODEV; - - pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); - -- /* Verify that this really is a SCx200 processor */ -- if (pci_dev_present(scx200)) { -- for (i = 0; i < MAX_DEVICES; ++i) { -- if (base[i] > 0) -- rc = scx200_acb_create("SCx200", base[i], i); -- } -- } else if (pci_dev_present(divil_pci)) -- rc = scx200_add_cs553x(); -+ /* If this is a CS5535 or CS5536, then probe the PCI header */ -+ -+ if (!pci_dev_present(scx200)) -+ return scx200_add_cs553x(); -+ -+ for (i = 0; i < MAX_DEVICES; ++i) { -+ if (base[i] > 0) -+ rc = scx200_acb_create("SCx200", base[i], i, NULL, 0); -+ } - - return rc; - } -@@ -544,7 +581,12 @@ static void __exit scx200_acb_cleanup(vo - up(&scx200_acb_list_mutex); - - i2c_del_adapter(&iface->adapter); -- release_region(iface->base, 8); -+ -+ if (iface->pdev != NULL) -+ pci_release_region(iface->pdev, iface->bar); -+ else -+ release_region(iface->base, 8); -+ - kfree(iface); - down(&scx200_acb_list_mutex); - } diff --git a/N1/2.hdr b/N1/2.hdr new file mode 100644 index 0000000..d5a791a --- /dev/null +++ b/N1/2.hdr @@ -0,0 +1,5 @@ +Content-Type: text/plain; + charset=us-ascii +Content-Disposition: inline; + filename=smb-pcifixup.patch +Content-Transfer-Encoding: 7bit diff --git a/N1/2.txt b/N1/2.txt new file mode 100644 index 0000000..be113e6 --- /dev/null +++ b/N1/2.txt @@ -0,0 +1,198 @@ +[PATCH] scx200_acb: Use PCI I/O resource when appropriate + +From: Jordan Crouse <jordan.crouse@amd.com> + +On the CS5535 and CS5536, the I/O resource is allocated through PCI, +so use that instead of using the MSR backdoor. + +Signed-off-by: Jordan Crouse <jordan.crouse@amd.com> +--- + + drivers/i2c/busses/scx200_acb.c | 114 +++++++++++++++++++++++++++------------ + 1 files changed, 78 insertions(+), 36 deletions(-) + +diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c +index e7a2225..454492f 100644 +--- a/drivers/i2c/busses/scx200_acb.c ++++ b/drivers/i2c/busses/scx200_acb.c +@@ -33,7 +33,6 @@ + #include <linux/delay.h> + #include <linux/mutex.h> + #include <asm/io.h> +-#include <asm/msr.h> + + #include <linux/scx200.h> + +@@ -85,6 +84,10 @@ struct scx200_acb_iface { + u8 *ptr; + char needs_reset; + unsigned len; ++ ++ /* PCI device info */ ++ struct pci_dev *pdev; ++ int bar; + }; + + /* Register Definitions */ +@@ -417,7 +420,8 @@ static int scx200_acb_probe(struct scx20 + return 0; + } + +-static int __init scx200_acb_create(const char *text, int base, int index) ++static int __init scx200_acb_create(char *text, unsigned int base, int index, ++ struct pci_dev *pdev, int bar) + { + struct scx200_acb_iface *iface; + struct i2c_adapter *adapter; +@@ -444,13 +448,31 @@ static int __init scx200_acb_create(con + snprintf(description, sizeof(description), "%s ACCESS.bus [%s]", + text, adapter->name); + +- if (request_region(base, 8, description) == 0) { +- printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n", +- base, base + 8-1); +- rc = -EBUSY; +- goto errout_free; ++ if (pdev != NULL) { ++ ++ iface->pdev = pdev; ++ iface->bar = bar; ++ ++ pci_enable_device_bars(iface->pdev, 1 << iface->bar); ++ ++ if (pci_request_region(iface->pdev, iface->bar, description)) { ++ printk(KERN_ERR NAME ": can't allocate PCI region %d\n", ++ iface->bar); ++ rc = -EBUSY; ++ goto errout_free; ++ } ++ ++ iface->base = pci_resource_start(iface->pdev, iface->bar); ++ } else { ++ if (request_region(base, 8, description) == 0) { ++ printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n", ++ base, base + 8 - 1); ++ rc = -EBUSY; ++ goto errout_free; ++ } ++ ++ iface->base = base; + } +- iface->base = base; + + rc = scx200_acb_probe(iface); + if (rc) { +@@ -474,7 +496,11 @@ static int __init scx200_acb_create(con + return 0; + + errout_release: +- release_region(iface->base, 8); ++ if (iface->pdev != NULL) ++ pci_release_region(iface->pdev, iface->bar); ++ else ++ release_region(iface->base, 8); ++ + errout_free: + kfree(iface); + errout: +@@ -487,49 +513,60 @@ static struct pci_device_id scx200[] = { + { }, + }; + +-static struct pci_device_id divil_pci[] = { +- { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, +- { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, +- { } /* NULL entry */ ++/* On the CS5535 and CS5536, the SMBUS I/0 base is a PCI resource, so ++ we should allocate that resource through the PCI ++ subsystem. rather then going through the MSR back door. ++*/ ++ ++static struct { ++ unsigned int vendor; ++ unsigned int device; ++ char *name; ++ int bar; ++} divil_pci[] = { ++ { ++ PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA, "CS5535", 0}, { ++ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, "CS5536", 0} + }; + +-#define MSR_LBAR_SMB 0x5140000B ++#define DIVIL_LENGTH (sizeof(divil_pci) / sizeof(divil_pci[0])) + + static int scx200_add_cs553x(void) + { +- u32 low, hi; +- u32 smb_base; +- +- /* Grab & reserve the SMB I/O range */ +- rdmsr(MSR_LBAR_SMB, low, hi); ++ int dev; ++ struct pci_dev *pdev; + +- /* Check the IO mask and whether SMB is enabled */ +- if (hi != 0x0000F001) { +- printk(KERN_WARNING NAME ": SMBus not enabled\n"); +- return -ENODEV; ++ for (dev = 0; dev < DIVIL_LENGTH; dev++) { ++ pdev = ++ pci_find_device(divil_pci[dev].vendor, ++ divil_pci[dev].device, NULL); ++ if (pdev != NULL) ++ break; + } + +- /* SMBus IO size is 8 bytes */ +- smb_base = low & 0x0000FFF8; ++ if (pdev == NULL) ++ return -ENODEV; + +- return scx200_acb_create("CS5535", smb_base, 0); ++ return scx200_acb_create(divil_pci[dev].name, 0, 0, pdev, ++ divil_pci[dev].bar); + } + + static int __init scx200_acb_init(void) + { + int i; +- int rc = -ENODEV; ++ int rc = -ENODEV; + + pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); + +- /* Verify that this really is a SCx200 processor */ +- if (pci_dev_present(scx200)) { +- for (i = 0; i < MAX_DEVICES; ++i) { +- if (base[i] > 0) +- rc = scx200_acb_create("SCx200", base[i], i); +- } +- } else if (pci_dev_present(divil_pci)) +- rc = scx200_add_cs553x(); ++ /* If this is a CS5535 or CS5536, then probe the PCI header */ ++ ++ if (!pci_dev_present(scx200)) ++ return scx200_add_cs553x(); ++ ++ for (i = 0; i < MAX_DEVICES; ++i) { ++ if (base[i] > 0) ++ rc = scx200_acb_create("SCx200", base[i], i, NULL, 0); ++ } + + return rc; + } +@@ -544,7 +581,12 @@ static void __exit scx200_acb_cleanup(vo + up(&scx200_acb_list_mutex); + + i2c_del_adapter(&iface->adapter); +- release_region(iface->base, 8); ++ ++ if (iface->pdev != NULL) ++ pci_release_region(iface->pdev, iface->bar); ++ else ++ release_region(iface->base, 8); ++ + kfree(iface); + down(&scx200_acb_list_mutex); + } diff --git a/a/content_digest b/N1/content_digest index eefab2a..f32bbe3 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -1,11 +1,11 @@ - "From\0jordan.crouse@amd.com (Jordan Crouse)\0" - "Subject\0[lm-sensors] [PATCH 2.6] scx200_acb: Use PCI I/O resource when\0" - "Date\0Fri, 31 Mar 2006 23:03:09 +0000\0" + "From\0Jordan Crouse <jordan.crouse@amd.com>\0" + "Subject\0[PATCH 2.6] scx200_acb: Use PCI I/O resource when appropriate\0" + "Date\0Fri, 31 Mar 2006 16:03:09 -0700\0" "To\0linux-kernel@vger.kernel.org\0" "Cc\0lm-sensors@lm-sensors.org" info-linux@ldcmail.amd.com " BGardner@wabtec.com\0" - "\00:1\0" + "\01:1\0" "b\0" "The CS5535 and CS5536 both define the I/O base for the SMBUS device in a \n" "PCI header. This patch uses that header for the I/O base rather then \n" @@ -18,16 +18,18 @@ "Jordan Crouse\n" "Senior Linux Engineer\n" "AMD - Personal Connectivity Solutions Group\n" - "<www.amd.com/embeddedprocessors>\n" - "-------------- next part --------------\n" + <www.amd.com/embeddedprocessors> + "\01:2\0" + "fn\0smb-pcifixup.patch\0" + "b\0" "[PATCH] scx200_acb: Use PCI I/O resource when appropriate\n" "\n" - "From: Jordan Crouse <jordan.crouse at amd.com>\n" + "From: Jordan Crouse <jordan.crouse@amd.com>\n" "\n" "On the CS5535 and CS5536, the I/O resource is allocated through PCI,\n" "so use that instead of using the MSR backdoor.\n" "\n" - "Signed-off-by: Jordan Crouse <jordan.crouse at amd.com>\n" + "Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>\n" "---\n" "\n" " drivers/i2c/busses/scx200_acb.c | 114 +++++++++++++++++++++++++++------------\n" @@ -70,7 +72,7 @@ " \tsnprintf(description, sizeof(description), \"%s ACCESS.bus [%s]\",\n" " \t\t text, adapter->name);\n" " \n" - "-\tif (request_region(base, 8, description) = 0) {\n" + "-\tif (request_region(base, 8, description) == 0) {\n" "-\t\tprintk(KERN_ERR NAME \": can't allocate io 0x%x-0x%x\\n\",\n" "-\t\t\tbase, base + 8-1);\n" "-\t\trc = -EBUSY;\n" @@ -91,7 +93,7 @@ "+\n" "+\t\tiface->base = pci_resource_start(iface->pdev, iface->bar);\n" "+\t} else {\n" - "+\t\tif (request_region(base, 8, description) = 0) {\n" + "+\t\tif (request_region(base, 8, description) == 0) {\n" "+\t\t\tprintk(KERN_ERR NAME \": can't allocate io 0x%x-0x%x\\n\",\n" "+\t\t\t base, base + 8 - 1);\n" "+\t\t\trc = -EBUSY;\n" @@ -159,7 +161,8 @@ "-\t\tprintk(KERN_WARNING NAME \": SMBus not enabled\\n\");\n" "-\t\treturn -ENODEV;\n" "+\tfor (dev = 0; dev < DIVIL_LENGTH; dev++) {\n" - "+\t\tpdev +\t\t pci_find_device(divil_pci[dev].vendor,\n" + "+\t\tpdev =\n" + "+\t\t pci_find_device(divil_pci[dev].vendor,\n" "+\t\t\t\t divil_pci[dev].device, NULL);\n" "+\t\tif (pdev != NULL)\n" "+\t\t\tbreak;\n" @@ -167,7 +170,7 @@ " \n" "-\t/* SMBus IO size is 8 bytes */\n" "-\tsmb_base = low & 0x0000FFF8;\n" - "+\tif (pdev = NULL)\n" + "+\tif (pdev == NULL)\n" "+\t\treturn -ENODEV;\n" " \n" "-\treturn scx200_acb_create(\"CS5535\", smb_base, 0);\n" @@ -218,4 +221,4 @@ " \t\tdown(&scx200_acb_list_mutex);\n" " \t}" -eba8e37a7cab6cc9ce94515e3174503afb3bf14bfcb457b8d1cfc200e0634f3f +91998cffd120e87031fd5b7100ef36f9968954a7330ec22365cab8501b99c638
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.