@@ -946,6 +946,12 @@ config BLK_DEV_MPC8xx_IDEIfunsure,sayN.+configBLK_DEV_MMIOIDE+tristate"Memory Mapped IDE support"+help+ThisistheIDEdriverforMemoryMappedIDEdevices.Like+CompactFlashrunninginTrueIDEmode.+choiceprompt"Type of MPC8xx IDE interface"depends onBLK_DEV_MPC8xx_IDE
@@ -7,6 +7,8 @@ obj-$(CONFIG_BLK_DEV_UMC8672) += umc8672.oobj-$(CONFIG_BLK_DEV_IDECS)+=ide-cs.o+obj-$(CONFIG_BLK_DEV_MMIOIDE)+=mmio-ide.o+# Last of allobj-$(CONFIG_BLK_DEV_HD)+=hd.o
@@ -0,0 +1,211 @@+/*+*MemoryMappedIDEdriver+*+*Author:KumarGala<galak@kernel.crashing.org>+*+*2007(c)MontaVistaSoftware,Inc.+*VitalyBordug<vitb@kernel.crashing.org>+*AntonVorontsov<avorontsov@ru.mvista.com>+*+*Thisprogramisfreesoftware;youcanredistributeitand/ormodifyit+*underthetermsoftheGNUGeneralPublicLicenseaspublishedbythe+*FreeSoftwareFoundation;eitherversion2oftheLicense,or(atyour+*option)anylaterversion.+*/++#include<linux/types.h>+#include<linux/init.h>+#include<linux/kernel.h>+#include<linux/ide.h>+#include<linux/ioport.h>+#include<linux/module.h>+#include<linux/mmio-ide.h>+#include<asm/io.h>++staticstruct{+void__iomem*mmio_ide_mapbase;+void__iomem*mmio_ide_alt_mapbase;+ide_hwif_t*hwif;+intindex;+}hwif_prop;++staticide_hwif_t*__devinitmmio_ide_locate_hwif(void__iomem*base,+void__iomem*ctrl,structmmio_ide_platform_data*pdata,intirq)+{+unsignedlongport=(unsignedlong)base;+ide_hwif_t*hwif;+intindex,i;++for(index=0;index<MAX_HWIFS;++index){+hwif=ide_hwifs+index;+if(hwif->io_ports[IDE_DATA_OFFSET]==port)+gotofound;+}++for(index=0;index<MAX_HWIFS;++index){+hwif=ide_hwifs+index;+if(hwif->io_ports[IDE_DATA_OFFSET]==0)+gotofound;+}++returnNULL;++found:++hwif->hw.io_ports[IDE_DATA_OFFSET]=port;++port+=pdata->regaddr_step+pdata->byte_lanes_swapping;+for(i=IDE_ERROR_OFFSET;i<=IDE_STATUS_OFFSET;+i++,port+=pdata->regaddr_step)+hwif->hw.io_ports[i]=port;++hwif->hw.io_ports[IDE_CONTROL_OFFSET]=(unsignedlong)ctrl++6*pdata->regaddr_step+pdata->byte_lanes_swapping;++memcpy(hwif->io_ports,hwif->hw.io_ports,sizeof(hwif->hw.io_ports));+hwif->hw.irq=hwif->irq=irq;+hwif->selectproc=pdata->selectproc;++hwif->hw.dma=NO_DMA;+hwif->hw.chipset=ide_generic;++hwif->mmio=2;+pdata->mmiops(hwif);+hwif_prop.hwif=hwif;+hwif_prop.index=index;++returnhwif;+}++staticint__devinitmmio_ide_probe(structplatform_device*pdev)+{+structresource*res_base,*res_alt,*res_irq;+ide_hwif_t*hwif;+structmmio_ide_platform_data*pdata;+intret=0;++pdata=(structmmio_ide_platform_data*)pdev->dev.platform_data;++/* get a pointer to the register memory */+res_base=platform_get_resource(pdev,IORESOURCE_MEM,0);+res_alt=platform_get_resource(pdev,IORESOURCE_MEM,1);+res_irq=platform_get_resource(pdev,IORESOURCE_IRQ,0);++if((!res_base)||(!res_alt)||(!res_irq)){+ret=-ENODEV;+gotoout;+}++if(!request_mem_region(res_base->start,res_base->end-+res_base->start+1,pdev->name)){+dev_dbg(&pdev->dev,"%s: request_mem_region of base failed\n",+pdev->name);+ret=-EBUSY;+gotoout;+}++if(!request_mem_region(res_alt->start,res_alt->end-+res_alt->start+1,pdev->name)){+dev_dbg(&pdev->dev,"%s: request_mem_region of alt failed\n",+pdev->name);+ret=-EBUSY;+gotorelease_base;+}++hwif_prop.mmio_ide_mapbase=ioremap(res_base->start,res_base->end-+res_base->start+1);+if(!hwif_prop.mmio_ide_mapbase){+ret=-ENOMEM;+gotorelease_alt;+}++hwif_prop.mmio_ide_alt_mapbase=ioremap(res_alt->start,res_alt->end-+res_alt->start+1);+if(!hwif_prop.mmio_ide_alt_mapbase){+ret=-ENOMEM;+gotounmap_base;+}++hwif=mmio_ide_locate_hwif(hwif_prop.mmio_ide_mapbase,+hwif_prop.mmio_ide_alt_mapbase,pdata,res_irq->start);++if(!hwif){+ret=-ENODEV;+gotounmap_alt;+}+hwif->gendev.parent=&pdev->dev;+hwif->noprobe=0;++probe_hwif_init(hwif);++platform_set_drvdata(pdev,hwif);+create_proc_ide_interfaces();++return0;++unmap_alt:+iounmap(hwif_prop.mmio_ide_alt_mapbase);+unmap_base:+iounmap(hwif_prop.mmio_ide_mapbase);+release_alt:+release_mem_region(res_alt->start,res_alt->end-res_alt->start+1);+release_base:+release_mem_region(res_base->start,+res_base->end-res_base->start+1);+out:+returnret;+}++staticint__devexitmmio_ide_remove(structplatform_device*pdev)+{+ide_hwif_t*hwif=pdev->dev.driver_data;+structresource*res_base,*res_alt;++/* get a pointer to the register memory */+res_base=platform_get_resource(pdev,IORESOURCE_MEM,0);+res_alt=platform_get_resource(pdev,IORESOURCE_MEM,1);++release_mem_region(res_base->start,+res_base->end-res_base->start+1);+release_mem_region(res_alt->start,res_alt->end-res_alt->start+1);++platform_set_drvdata(pdev,NULL);++if(hwif!=hwif_prop.hwif)+dev_printk(KERN_DEBUG,&pdev->dev,"%s: hwif value error",+pdev->name);+else{+ide_unregister(hwif_prop.index);+hwif_prop.index=0;+hwif_prop.hwif=NULL;+}++iounmap(hwif_prop.mmio_ide_mapbase);+iounmap(hwif_prop.mmio_ide_alt_mapbase);++return0;+}++staticstructplatform_drivermmio_ide_driver={+.driver{+.name="mmio-ide",+},+.probe=mmio_ide_probe,+.remove=__devexit_p(mmio_ide_remove),+};++staticint__initmmio_ide_init(void)+{+returnplatform_driver_register(&mmio_ide_driver);+}++staticvoid__exitmmio_ide_exit(void)+{+platform_driver_unregister(&mmio_ide_driver);+}++MODULE_DESCRIPTION("Memory Mapped IDE driver");+MODULE_LICENSE("GPL");++module_init(mmio_ide_init);+module_exit(mmio_ide_exit);
@@ -1103,3 +1103,116 @@ err:arch_initcall(cpm_smc_uart_of_init);#endif /* CONFIG_8xx */++#ifdef CONFIG_MPC834x_ITX++#include<linux/ide.h>+#include<linux/mmio-ide.h>+#include<asm-ppc/mpc83xx.h>++staticvoidmmio_ide_outsw(unsignedlongport,void*addr,u32count)+{+_outsw_ns((void__iomem*)port,addr,count);+}++staticvoidmmio_ide_insw(unsignedlongport,void*addr,u32count)+{+_insw_ns((void__iomem*)port,addr,count);+}++voidmmio_ide_mmiops(ide_hwif_t*hwif)+{+default_hwif_mmiops(hwif);+hwif->OUTL=NULL;+hwif->OUTSW=mmio_ide_outsw;+hwif->OUTSL=NULL;+hwif->INL=NULL;+hwif->INSW=mmio_ide_insw;+hwif->INSL=NULL;+}++voidmmio_ide_selectproc(ide_drive_t*drive)+{+u8stat;++stat=drive->hwif->INB(IDE_STATUS_REG);+if((stat&READY_STAT)&&(stat&BUSY_STAT))+drive->present=0;+else+drive->present=1;+}++staticint__initfsl_mmio_ide_of_init(void)+{+structdevice_node*np;+unsignedinti;++for(np=NULL,i=0;+(np=of_find_compatible_node(np,"ide","mmio-ide"))!=NULL;+i++){+intret=0;+structresourceres[3];+structplatform_device*pdev=NULL;+staticstructmmio_ide_platform_datapdata={+/* TODO: pass via OF? */+.byte_lanes_swapping=0,+.regaddr_step=2,+.mmiops=mmio_ide_mmiops,+.selectproc=mmio_ide_selectproc,+};++memset(res,0,sizeof(res));++ret=of_address_to_resource(np,0,&res[0]);+if(ret){+printk(KERN_ERR"mmio-ide.%d: unable to get "+"resource from OF\n",i);+gotoerr0;+}++ret=of_address_to_resource(np,1,&res[1]);+if(ret){+printk(KERN_ERR"mmio-ide.%d: unable to get "+"resource from OF\n",i);+gotoerr0;+}++res[2].start=res[2].end=irq_of_parse_and_map(np,0);+if(res[2].start==NO_IRQ){+printk(KERN_ERR"mmio-ide.%d: no IRQ\n",i);+gotoerr0;+}+res[2].name="mmio-ide";+res[2].flags=IORESOURCE_IRQ;;++pdev=platform_device_alloc("mmio-ide",i);+if(!pdev)+gotoerr1;++ret=platform_device_add_data(pdev,&pdata,sizeof(pdata));+if(ret)+gotoerr1;++ret=platform_device_add_resources(pdev,res,ARRAY_SIZE(res));+if(ret)+gotoerr1;++ret=platform_device_register(pdev);+if(ret)+gotoerr1;++continue;+err1:+printk(KERN_ERR"mmio-ide.%d: registration failed\n",i);+platform_device_del(pdev);/* it will free everything */+err0:+/* Even if some device failed, try others */+continue;+}++return0;+}++arch_initcall(fsl_mmio_ide_of_init);++#endif /* CONFIG_MPC834x_ITX */
=20
This adds support for MMIO IDE device like CompactFlash=20
in TrueIDE mode.
=A0
Signed-off-by: Anton Vorontsov <redacted>=20
Signed-off-by: Vitaly Bordug <redacted>
Hmm, are we still adding new IDE drivers? Do you also have a
driver for the new libata layer? I think it would even be
simpler to do.
You could also make it an of_platform_driver at the same time
instead of adding more cruft to fsl_soc.c. Since we're already
about to add the electra_ide.c driver in 2.6.23, I guess there
should really be _one_ driver that is able to handle all
of_device based ATA hosts.
Arnd <><
On Sat, Jul 07, 2007 at 01:49:00PM +0400, Vitaly Bordug wrote:
quoted
This updates relevant platform code
(freescale mpc8349itx target) to make the CompactFlash
work in TrueIDE mode.
Shouldn't you be writing a PCMCIA driver instead for the CF, so it
handles other devices as well? Then you get storage "for free", as
well as hotplug, etc.
CF memory cards can be in either TrueIDE mode or PCMCIA mode. If you
only need to support memory cards, you should always use True-IDE
mode, because that offers a _much_ higher throughput with PIO mode
6 (25 MB/s) or UDMA mode 6 (133MB/s), compared to the PIO mode 0
(3.3 MB/s) in PCMCIA mode.
Of course, if the bus can only sustain PIO mode 0 anyway, you can
just as well do a PCMCIA driver, and get the ability to plug in
other cards, e.g. wlan or modem cards.
Arnd <><
This adds support for MMIO IDE device like CompactFlash
in TrueIDE mode.
quoted
quoted
Signed-off-by: Anton Vorontsov <redacted>
Signed-off-by: Vitaly Bordug <redacted>
quoted
Hmm, are we still adding new IDE drivers? Do you also have a
Yes, why not?
The last time someone (I think Akira Iguchi) wanted to add
a new powerpc specific IDE driver, that was rejected based
on the argument that drivers/ide/ is going away soon. Most
current distros have already moved over to using libata
exclusively.
quoted
about to add the electra_ide.c driver in 2.6.23, I guess there
should really be _one_ driver that is able to handle all
of_device based ATA hosts.
One driver to rule them all. :-)
That may be not so simple as it seems...
It's certainly not easy to support all ATA chips that
have special capabilities and bugs, but the electra and the
mpc8349-itx both seem to support only the most basic ATA
PIO mode anyway, which does not require much special
handling beyond finding the right mmio addresses.
Arnd <><
You could also make it an of_platform_driver at the same time
instead of adding more cruft to fsl_soc.c. Since we're already
about to add the electra_ide.c driver in 2.6.23, I guess there
should really be _one_ driver that is able to handle all
of_device based ATA hosts.
and do so using libata. Preferably ata_platform but it does look like
ata_of would make sense as a companion.
Alan
This adds support for MMIO IDE device like CompactFlash
in TrueIDE mode.
Really we should be working towards libata support for all new devices.
This looks like a candidate for the existing (or a little enhanced)
pata_platform driver.
+config BLK_DEV_MMIOIDE
+ tristate "Memory Mapped IDE support"
Please pick a better description. This isn't a generic option for
enabling MMIO based IDE as you make it sound.
Also we have an accepted match name for ATA platform devices - and adding
another one messes it up irrespective of whether you want libata or
legacy IDE support. If you use the same matches then your platform code,
and everyone elses platform code can work with both drivers, except for
hotpluggability.
Other bugs
- Your remove code releases the resources before the hwif which means it
races another user trying to claim the resource
- Be careful with ide_unregister. It exists and you can call it but its
actually not very safe and there are lots of unfixed races in the IDE
layer if you do
The "should we have a legacy ide driver that matches the libata
pata_platform" question I don't really care about. Its a waste of effort
in many ways but if you've written the code the work is done so why not
use it.
However it needs to be *compatible* so that platform devices can be
claimed by either so the kernel build can pick legacy IDE v libata and
not have to #ifdef all the platform code.
Alan
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2007-07-08 00:54:31
On Sat, 2007-07-07 at 21:02 +0100, Alan Cox wrote:
quoted
You could also make it an of_platform_driver at the same time
instead of adding more cruft to fsl_soc.c. Since we're already
about to add the electra_ide.c driver in 2.6.23, I guess there
should really be _one_ driver that is able to handle all
of_device based ATA hosts.
and do so using libata. Preferably ata_platform but it does look like
ata_of would make sense as a companion.
I wouldn't push for it too much tho. It's perfectly fine to have
"helpers" generate xx_platform from the device-tree. Since I added the
generic dev_archdata to struct device, it's easy for the arch to keep
track of OF devices for anything, it doesn't have to be an of_platform
device or anything like that anymore.
One of the things I have in mind is to provide a way to register
"constructors" that are based on an OF match set. Those would then be
called by the arch code for every OF node that matches, and would then
"construct" the appropriate linux device. Could be some kind of platform
device, could even be PCI devs.
Ben.
I think that already adopted device type is "ata", not "ide".
"ata" is not a hardware thing, "ide" is. Or so I'm told.
I'd leave out the "device_type" completely though, certainly
if you can't point me at a published device binding :-)
Segher
On Sat, 7 Jul 2007 10:01:47 -0500
Olof Johansson wrote:
On Sat, Jul 07, 2007 at 01:48:52PM +0400, Vitaly Bordug wrote:
quoted
This adds support for MMIO IDE device like CompactFlash
in TrueIDE mode.
Doesn't this duplicate most of pata_platform, but as the
no-longer-preferred legacy IDE device? Did you try using
pata_platform instead?
prolly true,
but as Sergei told upper, that's not an option so far due to internal reasons. But it is likely to be followed-up
that way a little bit later.
This adds support for MMIO IDE device like CompactFlash
in TrueIDE mode.
Really we should be working towards libata support for all new
devices. This looks like a candidate for the existing (or a little
enhanced) pata_platform driver.
Yes I am aware of it, yet, the code was created for IDE subsystem due to internal reasons,
and I thought to better make it available for others at least. We'll prolly pick it up to move
to libata/pata_platform but not instantly afaict now.
quoted
+config BLK_DEV_MMIOIDE
+ tristate "Memory Mapped IDE support"
Please pick a better description. This isn't a generic option for
enabling MMIO based IDE as you make it sound.
Also we have an accepted match name for ATA platform devices - and
adding another one messes it up irrespective of whether you want
libata or legacy IDE support. If you use the same matches then your
platform code, and everyone elses platform code can work with both
drivers, except for hotpluggability.
Other bugs
- Your remove code releases the resources before the hwif which means
it races another user trying to claim the resource
- Be careful with ide_unregister. It exists and you can call it but
its actually not very safe and there are lots of unfixed races in the
IDE layer if you do
OK, makes sense.
The "should we have a legacy ide driver that matches the libata
pata_platform" question I don't really care about. Its a waste of
effort in many ways but if you've written the code the work is done
so why not use it.
However it needs to be *compatible* so that platform devices can be
claimed by either so the kernel build can pick legacy IDE v libata and
not have to #ifdef all the platform code.
Sounds good. I'll look forward to address the issues, thanks.
On Sat, 07 Jul 2007 20:46:46 +0400
Sergei Shtylyov wrote:
quoted
+
+#ifdef CONFIG_MPC834x_ITX
Erm, isn't this stuff misplaced? Is this really SoC device? I
remember seeng this in the arch/ppc/ platform code before (in the
internal tree)...
The point is to declare methods bsp, as mmio access may effectively vary (having bugs or intentionally) from platform to platform. All-in-one driver approach is nice but might be an issue to handle/maintain.
Thanks for looking at it, other notes make sense.
--
Sincerely, Vitaly
From: Sergei Shtylyov <hidden> Date: 2007-07-11 19:00:35
Hello.
Vitaly Bordug wrote:
quoted
quoted
+
+#ifdef CONFIG_MPC834x_ITX
quoted
Erm, isn't this stuff misplaced? Is this really SoC device? I
remember seeng this in the arch/ppc/ platform code before (in the
internal tree)...
The point is to declare methods bsp, as mmio access may effectively vary (having bugs or intentionally) from platform to platform. All-in-one driver approach is nice but might be an issue to handle/maintain.
You misunderstood. Why this was placed in fsl_soc.c and not in the proper
platform code (as it was in the internal tree even)?
MBR, Sergei