pata_cs5536: ATA driver for Geode companion chip
PATCH 1/1 pata_cs5536: ATA driver for Geode companion chip
This is a driver specifically for the ATA controller on the Geode CS5536 companion chip. The PCI device ID for this device was previously claimed by pata_amd.c but there were two problems with that:
- Not all Geode platforms emulate the ATA registers in PCI config space
- CS5536 PIO timings are not identical to AMD74XX/8111
pata_cs5536.c relies on Geode Machine Specific Registers to configure the ATA function and uses the correct PIO timings for the chip.
---
arch/i386/kernel/reboot_fixups.c +0 -0
drivers/ata/Kconfig +9 -0
@@ -254,6 +254,15 @@ config PATA_CS5535 If unsure, say N. +config PATA_CS5536 + tristate "CS5536 PATA support (Experimental)" + depends on PCI && X86 && !X86_64 && EXPERIMENTAL + help + This option enables support for the AMD CS5536 + companion chip used with the Geode LX processor family. + + If unsure, say N. + config PATA_CYPRESS tristate "Cypress CY82C693 PATA support (Very Experimental)" depends on PCI && EXPERIMENTAL
drivers/ata/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_PATA_CMD64X) += pata_cmd64x.o obj-$(CONFIG_PATA_CS5520) += pata_cs5520.o obj-$(CONFIG_PATA_CS5530) += pata_cs5530.o obj-$(CONFIG_PATA_CS5535) += pata_cs5535.o +obj-$(CONFIG_PATA_CS5536) += pata_cs5536.o obj-$(CONFIG_PATA_CYPRESS) += pata_cypress.o obj-$(CONFIG_PATA_EFAR) += pata_efar.o obj-$(CONFIG_PATA_HPT366) += pata_hpt366.o
drivers/ata/pata_amd.c +0 -9
@@ -611,14 +611,6 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = ATA_UDMA6, /* UDMA 133, no swdma */ .port_ops = &nv133_port_ops }, - {/* 9: AMD CS5536 (Geode companion) */ - .sht = &amd_sht, - .flags = ATA_FLAG_SLAVE_POSS, - .pio_mask = 0x1f, - .mwdma_mask = 0x07, - .udma_mask = ATA_UDMA5, /* UDMA 100 */ - .port_ops = &amd100_port_ops - } };const struct ata_port_info *ppi[] = {NULL ,NULL };static int printed_version;
@@ -693,7 +685,6 @@ static const struct pci_device_id amd[] = { { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 8 }, { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 8 }, { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 8 }, - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 9 }, { }, };
drivers/ata/pata_cs5536.c new file +320 -0
320 lines not on this page · raw message
Quoted 4 lines
pata_cs5536.crelies on Geode Machine Specific Registers to configure the ATA function and uses the correct PIO timings for the chip.Signed-off-by Martin K. Petersen <[email protected]>
I'm basically happy with this but would appreciate some feedback from AMD on the subject.
(cc added therefore : [email protected])
drivers/ata/pata_cs5536.c line 244
Quoted 1 line
drivers/ata/pata_cs5536.c new file +1
-0+ .qc_issue = ata_qc_issue_prot,
The older AMD ex NS ex Cyrix chipsets mishandle 64K DMA blocks - is that the case for the CS5536 or not - does it consider a PRD entry with zero length as 64K or 0 bytes
drivers/ata/pata_cs5536.c line 280
Quoted 2 lines
drivers/ata/pata_cs5536.c new file +2
-0+if ((cfg &IDE_CFG_CHANEN ) ==0 ) { +printk (KERN_ERR "CS5536: disabled by BIOS\n" );
To save Jeff whining - he'll want that to be DRV_NAME or similar and to call it pata_cs5536
Quoted 8 lines · Alan Cox
Quoted 4 lines
pata_cs5536.crelies on Geode Machine Specific Registers to configure the ATA function and uses the correct PIO timings for the chip.Signed-off-by Martin K. Petersen <[email protected]>I'm basically happy with this but would appreciate some feedback from AMD on the subject.
Quoted 7 lines
(cc added therefore : [email protected])
drivers/ata/pata_cs5536.c line 244
Quoted 1 line
drivers/ata/pata_cs5536.c new file +1
-0+ .qc_issue = ata_qc_issue_prot,The older AMD ex NS ex Cyrix chipsets mishandle 64K DMA blocks - is that the case for the CS5536 or not - does it consider a PRD entry with zero length as 64K or 0 bytes
Good point.
Quoted 5 lines
drivers/ata/pata_cs5536.c line 280
Quoted 2 lines
drivers/ata/pata_cs5536.c new file +2
-0+if ((cfg &IDE_CFG_CHANEN ) ==0 ) { +printk (KERN_ERR "CS5536: disabled by BIOS\n" );To save Jeff whining - he'll want that to be
DRV_NAMEor similar and to call itpata_cs5536
Now I'm embarrassed... I looked over the driver and missed this ;-) ;-)
Jeff
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Alan" == Alan Cox <[email protected]> writes:
Alan> The older AMD ex NS ex Cyrix chipsets mishandle 64K DMA blocks - Alan> is that the case for the CS5536 or not - does it consider a PRD Alan> entry with zero length as 64K or 0 bytes
The databook says: "The size must be in multiples of 1 WORD (2 bytes) or zero (which means a 64 KB transfer)."
Quoted 2 lines
Quoted 2 lines
+ if ((cfg &
IDE_CFG_CHANEN) == 0) { + printk(KERN_ERR "CS5536:
disabled by BIOS\n");
Alan> To save Jeff whining - he'll want that to be DRV_NAME or similar Alan> and to call it pata_cs5536
Ok.
Signature · 1 line
Martin K. Petersen http://mkp.net/
Quoted 8 lines · On Wed, 03 Oct 2007 14:45:12 -0400 "Martin K. Petersen" <[email protected]> wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Alan" == Alan Cox <[email protected]> writes:
Alan> The older AMD ex NS ex Cyrix chipsets mishandle 64K DMA blocks - Alan> is that the case for the CS5536 or not - does it consider a PRD Alan> entry with zero length as 64K or 0 bytes
The databook says: "The size must be in multiples of 1 WORD (2 bytes) or zero (which means a 64 KB transfer)."
So does the older databook for the ones that get it wrong 8)
Alan
Quoted 5 lines · Martin K. Petersen
This is a driver specifically for the ATA controller on the Geode CS5536 companion chip. The PCI device ID for this device was previously claimed by
pata_amd.cbut there were two problems with that:
Hmm - I had to ruminate on this for a while. As a general rule of thumb
I try to discourage working around the PCI virtualization - both because it encumbers Linux with one off drivers such as this one, and we lose any benefit from bug fixes in the firmware (not to mention bug fixes in the common shared driver). AMD has gone to a lot of trouble and expense to make a decidedly non-PCI bus Just Work (TM) like a PCI bus, and it takes a lot to convince me to diverge from that.
Quoted 2 lines
- Not all Geode platforms emulate the ATA registers in PCI config space
If you system has any sort of PCI virtualization support at all, and it doesn't support these registers, then thats a big fat bug, IMHO, and should be resolved post haste. But that said, the VSA doesn't do any sort of messy workaround here, so the direct route isn't going to lose us anything in terms of bug fixes.
Quoted 1 line
- CS5536 PIO timings are not identical to AMD74XX/8111
This is true, and it was brought up when we first pushed the drivers. Tests showed that the timings generated by the Thor driver were within the optimal tolerances for the 5536 controller, and we decided that a custom driver wasn't indicated. But if we *are* going to have a custom driver, then we should get these right.
Quoted 2 lines
pata_cs5536.crelies on Geode Machine Specific Registers to configure the ATA function and uses the correct PIO timings for the chip.
I have to discourage this patch just on principle, because I don't like the idea of working around the VSA. That said, it seems that Alan is willing to take on the extra code, and there isn't anything technically deficient here, so I'm fine with this going in.
Jordan
Quoted 4 lines
I have to discourage this patch just on principle, because I don't like the idea of working around the VSA. That said, it seems that Alan is willing to take on the extra code, and there isn't anything technically deficient here, so I'm fine with this going in.
I'd prefer to go via the PCI virtualisation(but with the timings fixed) but there are boxes out there where this doesn't work.
Ideally what I'd like would be a suggestion of how to tell if the VSA is active on this so that we can use VSA if present.
Quoted 10 lines · Alan Cox
Quoted 4 lines
I have to discourage this patch just on principle, because I don't like the idea of working around the VSA. That said, it seems that Alan is willing to take on the extra code, and there isn't anything technically deficient here, so I'm fine with this going in.
I'd prefer to go via the PCI virtualisation(but with the timings fixed) but there are boxes out there where this doesn't work.
Ideally what I'd like would be a suggestion of how to tell if the VSA is active on this so that we can use VSA if present.
int geode_has_vsa() {
outw(0xFC53, 0xAC1C);
outw(0x0003, 0xAC1C);
rev = inw(0xAC1E);
return (rev == 0x4132) ? 1 : 0;
}That should work on any AMD VSA derivatives. There are some who may have rolled their own, and they don't support the same virtual registers. in that case, you can check if SMIs are enabled - that would be a reasonable indication that there is something VSAish out there.
But you bring up another point - I'm not sure that Martin _doesn't_ have VSA. He is initializing this as a PCI driver, so he has something out there listening to CF8/CFC, or he's emulating the OLPC spoof mechanism [1]. If its the former, and it doesn't handle the 5536 IDE config space, then thats something that should be fixed by the BIOS vendor just on general principle (other OSes aren't as lucky as we are working around the PCI space). If its the OLPC method, then I could argue that fudging the registers belongs in that code, and not in the driver.
Jordan
(I refer this only as an example, and not something to be emulated by other platforms. This works great for OLPC, but it would be a nightmare for arbitrary platforms).
Signature · 3 lines
Jordan Crouse Systems Software Development Engineer Advanced Micro Devices, Inc.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Jordan" == Jordan Crouse <[email protected]> writes:
Jordan> That should work on any AMD VSA derivatives. There are some Jordan> who may have rolled their own, and they don't support the same Jordan> virtual registers. in that case, you can check if SMIs are Jordan> enabled - that would be a reasonable indication that there is Jordan> something VSAish out there.
I'll try this later and see what comes up. But I'm not sure I see the advantage of having two ways to configure the 5536.
I was simply interested in getting things configured correctly. I agree that ideally all platforms would simply Do The Right Thing. However, I took the pragmatic/safe approach and used the MSRs to configure the beast. The only reason I even tried is that this is a setup issue exclusively. Had the actual I/O interface been hiding in a similar fashion I wouldn't have bothered.
Early on I also had some funny results with PIO so another reason I wrote pata_cs5536 was to use the values specified in the databook. It seemed cleaner to have a tiny separate driver than to wedge another set of timings into pata_amd.c.
I agree that it would be silly to have two drivers if there was actual functionality lurking in them. But as it stands most of the pata_* drivers are simply configuration templates and nothing more.
Anyway. That's my personal take on it. If there's a general consensus that the timings should be in pata_amd.c then so be it.
Jordan> But you bring up another point - I'm not sure that Martin Jordan> _doesn't_ have VSA. He is initializing this as a PCI driver, Jordan> so he has something out there listening to CF8/CFC, or he's Jordan> emulating the OLPC spoof mechanism [1].
The board I'm using has a BIOS which exposes the IDE registers in PCI space but doesn't appear to listen when they are written to. I'm hoping that will get fixed eventually.
PS. So what's the story wrt. a PRD length of 0?
Signature · 1 line
Martin K. Petersen http://mkp.net/
Quoted 1 line · Martin K. Petersen
PS. So what's the story wrt. a PRD length of 0?
That's what I'm quite interested in hearing, too...
Jeff
Quoted 8 lines · Martin K. Petersen
This is a driver specifically for the ATA controller on the Geode CS5536 companion chip. The PCI device ID for this device was previously claimed by
pata_amd.cbut there were two problems with that:- Not all Geode platforms emulate the ATA registers in PCI config space
Quoted 6 lines
- CS5536 PIO timings are not identical to AMD74XX/8111
pata_cs5536.crelies on Geode Machine Specific Registers to configure the ATA function and uses the correct PIO timings for the chip.Signed-off-by Martin K. Petersen <[email protected]>
Just FWIW... one you guys are happy with things, I'm ready to merge the driver whenever.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Jeff" == Jeff Garzik <[email protected]> writes:
Jeff> Just FWIW... one you guys are happy with things, I'm ready to Jeff> merge the driver whenever.
I'm waiting for Jordan to get back to me with feedback on test results on other boards as well as preference wrt. MSR or PCI configuration...
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 7 lines · Martin K. Petersen
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Jeff" == Jeff Garzik <[email protected]> writes:
Jeff> Just FWIW... one you guys are happy with things, I'm ready to Jeff> merge the driver whenever.
I'm waiting for Jordan to get back to me with feedback on test results on other boards as well as preference wrt. MSR or PCI configuration...
I never heard back from anybody - so either nobody is using pata_amd (which I suspect), or they didn't have any problems. Go ahead and merge, and I'll do a sanity check on a few boards next week just to make sure.
Thanks,
Jordan
Quoted 5 lines
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Signature · 3 lines
Jordan Crouse Systems Software Development Engineer Advanced Micro Devices, Inc.
Quoted 3 lines · Jordan Crouse
I never heard back from anybody - so either nobody is using
pata_amd(which I suspect), or they didn't have any problems. Go ahead and merge, and I'll do a sanity check on a few boards next week just to make sure.
I am using the CS5536 currently with pata_amd and it worked without issue. I only used the PATA port for a short time, though, before switching to USB + SATA. I will now be going back to using the PATA this week, so I'll try out the new driver in place of pata_amd and write back if there are any problems.
Thanks,
-Andrew
Martin,
Just wanted to report that the 2.6.23 libata-dev with the MSR pata_cs5536 applied to it is working fine with my LX board. I am using the first PATA port as my boot/root drive right now.
Thanks,
-Andrew
scsi4 : pata_cs5536
scsi5 : pata_cs5536
ata5: PATA max UDMA/100 cmd 0x000101f0 ctl 0x000103f6 bmdma 0x0001ff00 irq 14
ata6: DUMMY
ata5.00: ATA-0: , 060729DA, max MWDMA2
ata5.00: 256000 sectors, multi 1: LBA
ata5.00: configured for MWDMA2
scsi 4:0:0:0: Direct-Access ATA 0607 PQ: 0 ANSI: 5
sd 4:0:0:0: [sdc] 256000 512-byte hardware sectors (131 MB)
sd 4:0:0:0: [sdc] Write Protect is off
sd 4:0:0:0: [sdc] Mode Sense: 00 3a 00 00
sd 4:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA