mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Clear.Zhang@uli.com.tw
To: davej@codemonkey.org.uk
Cc: alan@redhat.com, Peer.Chen@uli.com.tw, Emily.Jiang@uli.com.tw,
	Eric.Lo@uli.com.tw, andrebalsa@mailingaddress.org,
	linux-kernel@vger.kernel.org
Subject: [patch] char/agp: Add support for ULi M1681,M1683,M1689
Date: Fri, 19 Nov 2004 14:43:38 +0800	[thread overview]
Message-ID: <OFDCFDB653.BD918882-ON48256F51.0024609A@uli.com.tw> (raw)

[-- Attachment #1: Type: text/plain, Size: 408 bytes --]

Hi,

We add the support for ULi's AGP M1681,M1683,M1689 in directory
drivers/char/agp.
This patch(the attachmemt) is applied to kernel 2.6.9. Please apply to new
kernels, thanks.

We do some modification to the driver for compatible with our chip except
for
adding verdor ID and device ID.

Signed-off-by: Clear Zhang <Clear.Zhang@uli.com.tw>

Thanks

Clear                   (See attached file: patch_agp)


[-- Attachment #2: patch_agp --]
[-- Type: application/octet-stream, Size: 4917 bytes --]

diff -uprN linux-2.6.9-vanilla/drivers/char/agp/ali-agp.c linux-2.6.9/drivers/char/agp/ali-agp.c
--- linux-2.6.9-vanilla/drivers/char/agp/ali-agp.c	2004-10-19 05:54:38.000000000 +0800
+++ linux-2.6.9/drivers/char/agp/ali-agp.c	2004-11-19 14:21:27.815734928 +0800
@@ -277,6 +277,14 @@ static struct agp_device_ids ali_agp_dev
 		.device_id	= PCI_DEVICE_ID_AL_M1671,
 		.chipset_name	= "M1671",
 	},
+	{
+		.device_id	= PCI_DEVICE_ID_AL_M1681,
+		.chipset_name	= "M1681",
+	},
+	{
+		.device_id	= PCI_DEVICE_ID_AL_M1683,
+		.chipset_name	= "M1683",
+	},
 	{ }, /* dummy final entry, always present */
 };
 
diff -uprN linux-2.6.9-vanilla/drivers/char/agp/amd64-agp.c linux-2.6.9/drivers/char/agp/amd64-agp.c
--- linux-2.6.9-vanilla/drivers/char/agp/amd64-agp.c	2004-10-19 05:54:38.000000000 +0800
+++ linux-2.6.9/drivers/char/agp/amd64-agp.c	2004-11-19 14:21:37.120320416 +0800
@@ -46,6 +46,15 @@
 #define NVIDIA_X86_64_1_APBASE2		0xd8
 #define NVIDIA_X86_64_1_APLIMIT2	0xdc
 
+////////////////////////////////////////////
+// ++ ULi
+/* ULi K8 registers */
+#define ULI_X86_64_BASE_ADDR		0x10
+#define ULI_X86_64_HTT_FEA_REG		0x50
+#define ULI_X86_64_ENU_SCR_REG		0x54
+// -- ULi
+////////////////////////////////////////////
+
 static int nr_garts;
 static struct pci_dev * hammers[MAX_HAMMER_GARTS];
 
@@ -405,6 +414,66 @@ static void __devinit amd8151_init(struc
 	}
 }
 
+
+//////////////////////////////////////////////////////
+// ++ULi
+static struct aper_size_info_32 uli_sizes[7] =
+{
+	{256, 65536, 6, 10},
+        {128, 32768, 5, 9},
+        {64, 16384, 4, 8},
+        {32, 8192, 3, 7},
+        {16, 4096, 2, 6},
+        {8, 2048, 1, 4},
+        {4, 1024, 0, 3}
+};
+static int __devinit uli_agp_init(struct pci_dev *pdev)
+{
+	u32 httfea,baseaddr,enuscr;
+	struct pci_dev *dev1;
+	int i;
+	unsigned size = amd64_fetch_size();
+	printk(KERN_INFO "Setting up ULi AGP. \n");
+	dev1 = pci_find_slot ((unsigned int)pdev->bus->number,PCI_DEVFN(0,0));
+	if (dev1 == NULL) {
+		printk(KERN_INFO PFX "agpgart: Detected a ULi chipset, "
+			"but could not fine the secondary device.\n");
+		return -ENODEV;
+	}
+        for (i = 0; i < ARRAY_SIZE(uli_sizes); i++)
+                if (uli_sizes[i].size == size)
+                        break;
+
+        if (i == ARRAY_SIZE(uli_sizes)) {
+                printk(KERN_INFO PFX "No ULi size found for %d\n", size);
+                return -ENODEV;
+        }
+
+
+        /* shadow x86-64 registers into ULi registers */
+        pci_read_config_dword (hammers[0], AMD64_GARTAPERTUREBASE, &httfea);
+
+        /* if x86-64 aperture base is beyond 4G, exit here */
+        if ( (httfea & 0x7fff) >> (32 - 25) )
+                 return -ENODEV;
+
+        httfea = (httfea& 0x7fff) << 25;
+
+        pci_read_config_dword(pdev, ULI_X86_64_BASE_ADDR, &baseaddr);
+        baseaddr&= ~PCI_BASE_ADDRESS_MEM_MASK;
+        baseaddr|= httfea;
+        pci_write_config_dword(pdev, ULI_X86_64_BASE_ADDR, baseaddr);
+
+        enuscr= httfea+ (size * 1024 * 1024) - 1;
+        pci_write_config_dword(dev1, ULI_X86_64_HTT_FEA_REG, httfea);
+        pci_write_config_dword(dev1, ULI_X86_64_ENU_SCR_REG, enuscr);
+        return 0;
+}
+// --ULi
+/////////////////////////////////////////////////////////////////////
+
+
+
 static struct aper_size_info_32 nforce3_sizes[5] =
 {
 	{512,  131072, 7, 0x00000000 },
@@ -513,6 +582,18 @@ static int __devinit agp_amd64_probe(str
 		}
 	}
 
+	////////////////////////////////////////////
+	// ++ULi
+	if (pdev->vendor == PCI_VENDOR_ID_AL) {
+		int ret = uli_agp_init(pdev);
+		if (ret) {
+			agp_put_bridge(bridge);
+			return ret;
+		}
+	}
+	// --ULi
+	////////////////////////////////////////////
+
 	pci_set_drvdata(pdev, bridge);
 	return agp_add_bridge(bridge);
 }
@@ -536,6 +617,19 @@ static struct pci_device_id agp_amd64_pc
 	.subvendor	= PCI_ANY_ID,
 	.subdevice	= PCI_ANY_ID,
 	},
+	///////////////////////////////////////////////
+	// ++ULi
+	/* ULi M1689 */
+	{
+	.class		= (PCI_CLASS_BRIDGE_HOST << 8),
+	.class_mask	= ~0,
+	.vendor		= PCI_VENDOR_ID_AL,
+	.device		= PCI_DEVICE_ID_AL_M1689,
+	.subvendor	= PCI_ANY_ID,
+	.subdevice	= PCI_ANY_ID,
+	},
+	// --ULi
+	///////////////////////////////////////////////
 	/* VIA K8T800Pro */
 	{
 	.class		= (PCI_CLASS_BRIDGE_HOST << 8),
diff -uprN linux-2.6.9-vanilla/include/linux/pci_ids.h linux-2.6.9/include/linux/pci_ids.h
--- linux-2.6.9-vanilla/include/linux/pci_ids.h	2004-10-19 05:55:36.000000000 +0800
+++ linux-2.6.9/include/linux/pci_ids.h	2004-11-19 14:22:13.000000000 +0800
@@ -1022,6 +1022,9 @@
 #define PCI_DEVICE_ID_AL_M1647		0x1647
 #define PCI_DEVICE_ID_AL_M1651		0x1651
 #define PCI_DEVICE_ID_AL_M1671		0x1671
+#define PCI_DEVICE_ID_AL_M1681		0x1681
+#define PCI_DEVICE_ID_AL_M1683  	0x1683
+#define PCI_DEVICE_ID_AL_M1689  	0x1689
 #define PCI_DEVICE_ID_AL_M1543		0x1543
 #define PCI_DEVICE_ID_AL_M3307		0x3307
 #define PCI_DEVICE_ID_AL_M4803		0x5215

                 reply	other threads:[~2004-11-19  6:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OFDCFDB653.BD918882-ON48256F51.0024609A@uli.com.tw \
    --to=clear.zhang@uli.com.tw \
    --cc=Emily.Jiang@uli.com.tw \
    --cc=Eric.Lo@uli.com.tw \
    --cc=Peer.Chen@uli.com.tw \
    --cc=alan@redhat.com \
    --cc=andrebalsa@mailingaddress.org \
    --cc=davej@codemonkey.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®