OF-platform PATA driver
v4 cover OF-platform PATA driver
Hi all,
Here is the resend (aka v4) version of the OF-platform PATA driver and related patches.
Changes since v3:
- Acked-by: Paul Mundt <[email protected]>
- In the powerpc specific patch: update defconfig and use machine_device_initcall -- this is new call found in the galak/powerpc.git.
Changes since v2:
- "PPC" added to PATA_PLATFORM "depends on" Kconfig entry; I didn't remove EMBEDDED "depends on" -- this wasn't discussed much and these patches should not depend on the decision.
- cosmetic fixes;
- "s/ioport_shift/reg_shift/g" patch dropped.
Changes since v1:
- __pata_platform_probe now accepts pio_mask argument;
- pata-platform compatible property renamed to ata-generic;
- pata_of_platform understands pio-mode property. It's used to pass pio_mask to the __pata_platform_probe. That is, in ata-generic context pio-mode means "pio mode the bus already configured for";
- New optional patch that renames pata_platform_info's ioport_shift to reg_shift.
Changes since RFC:
- nuked drivers/ata/pata_platform.h;
- powerpc bits: proper localbus node added.
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
PATCH v4 1/3 pata_platform: make probe and remove functions device type neutral
Split pata_platform_{probe,remove} into two pieces:
1. pata_platform_{probe,remove} -- platform_device-dependant bits;
2. __ptata_platform_{probe,remove} -- device type neutral bits.
This is done to not duplicate code for the OF-platform driver.
--- drivers/ata/pata_platform.c | 144 ++++++++++++++++++++++++---------------- include/linux/pata_platform.h | 9 +++ 2 files changed, 95 insertions(+), 58 deletions(-)
drivers/ata/pata_platform.c +86 -58
@@ -93,14 +93,9 @@ static struct ata_port_operations pata_platform_port_ops = { };static void pata_platform_setup_port (struct ata_ioports *ioaddr, -struct pata_platform_info *info) +unsigned int shift) { -unsigned int shift =0 ; -/* Fixup the port shift for platforms that need it */ -if (info && info->ioport_shift) - shift = info->ioport_shift; - ioaddr->data_addr = ioaddr->cmd_addr + (ATA_REG_DATA << shift); ioaddr->error_addr = ioaddr->cmd_addr + (ATA_REG_ERR << shift); ioaddr->feature_addr = ioaddr->cmd_addr + (ATA_REG_FEATURE << shift);
@@ -114,8 +109,13 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr, }/** -* pata_platform_probe - attach a platform interface -* @pdev: platform device +* __pata_platform_probe - attach a platform interface +* @dev: device +* @io_res: Resource representing I/O base +* @ctl_res: Resource representing CTL base +* @irq_res: Resource representing IRQ and its flags +* @ioport_shift: I/O port shift +* @__pio_mask: PIO mask * * Register a platform bus IDE interface. Such interfaces are PIO and we * assume do not support IRQ sharing.
@@ -135,42 +135,18 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr,* * If no IRQ resource is present, PIO polling mode is used instead. */ -static int __devinit pata_platform_probe (struct platform_device *pdev) +int __devinit __pata_platform_probe (struct device *dev, +struct resource *io_res, +struct resource *ctl_res, +struct resource *irq_res, +unsigned int ioport_shift, +int __pio_mask) { -struct resource *io_res, *ctl_res;struct ata_host *host;struct ata_port *ap; -struct pata_platform_info *pp_info;unsigned int mmio; -int irq; - -/* -* Simple resource validation .. -*/ -if ((pdev->num_resources !=3 ) && (pdev->num_resources !=2 )) { -dev_err (&pdev->dev,"invalid number of resources\n" ); -return -EINVAL ; - } - -/* -* Get the I/O base first -*/ - io_res =platform_get_resource (pdev,IORESOURCE_IO ,0 ); -if (io_res ==NULL ) { - io_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (unlikely (io_res ==NULL )) -return -EINVAL ; - } - -/* -* Then the CTL base -*/ - ctl_res =platform_get_resource (pdev,IORESOURCE_IO ,1 ); -if (ctl_res ==NULL ) { - ctl_res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -if (unlikely (ctl_res ==NULL )) -return -EINVAL ; - } +int irq =0 ; +int irq_flags =0 ;/* * Check for MMIO
@@ -181,20 +157,21 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)/* * And the IRQ */ - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) - irq =0 ;/* no irq */ +if (irq_res && irq_res->start >0 ) { + irq = irq_res->start; + irq_flags = irq_res->flags; + }/* * Now that that's out of the way, wire up the port.. */ - host =ata_host_alloc (&pdev->dev,1 ); + host =ata_host_alloc (dev,1 );if (!host)return -ENOMEM ; ap = host->ports[0 ]; ap->ops = &pata_platform_port_ops; - ap->pio_mask = pio_mask; + ap->pio_mask = __pio_mask; ap->flags |=ATA_FLAG_SLAVE_POSS ;/*
@@ -209,25 +186,24 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)* Handle the MMIO case */ if (mmio) { - ap->ioaddr.cmd_addr =devm_ioremap (&pdev->dev, io_res->start, + ap->ioaddr.cmd_addr =devm_ioremap (dev, io_res->start, io_res->end - io_res->start +1 ); - ap->ioaddr.ctl_addr =devm_ioremap (&pdev->dev, ctl_res->start, + ap->ioaddr.ctl_addr =devm_ioremap (dev, ctl_res->start, ctl_res->end - ctl_res->start +1 ); }else { - ap->ioaddr.cmd_addr =devm_ioport_map (&pdev->dev, io_res->start, + ap->ioaddr.cmd_addr =devm_ioport_map (dev, io_res->start, io_res->end - io_res->start +1 ); - ap->ioaddr.ctl_addr =devm_ioport_map (&pdev->dev, ctl_res->start, + ap->ioaddr.ctl_addr =devm_ioport_map (dev, ctl_res->start, ctl_res->end - ctl_res->start +1 ); }if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr) { -dev_err (&pdev->dev,"failed to map IO/CTL base\n" ); +dev_err (dev,"failed to map IO/CTL base\n" );return -ENOMEM ; } ap->ioaddr.altstatus_addr = ap->ioaddr.ctl_addr; - pp_info = pdev->dev.platform_data; -pata_platform_setup_port (&ap->ioaddr, pp_info); +pata_platform_setup_port (&ap->ioaddr, ioport_shift); ata_port_desc(ap, "%s cmd 0x%llx ctl 0x%llx", mmio ? "mmio" : "ioport", (unsigned long long)io_res->start,
@@ -235,26 +211,78 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)/* activate */ return ata_host_activate (host, irq, irq ? ata_interrupt :NULL , - pp_info ? pp_info->irq_flags :0 , - &pata_platform_sht); + irq_flags, &pata_platform_sht); } +EXPORT_SYMBOL_GPL (__pata_platform_probe);/** -* pata_platform_remove - unplug a platform interface -* @pdev: platform device +* __pata_platform_remove - unplug a platform interface +* @dev: device * * A platform bus ATA device has been unplugged. Perform the needed * cleanup. Also called on module unload for any active devices. */ -static int __devexit pata_platform_remove(struct platform_device *pdev) +int __devexit __pata_platform_remove(struct device *dev) { -struct device *dev = &pdev->dev;struct ata_host *host =dev_get_drvdata (dev);ata_host_detach (host);return 0 ; } +EXPORT_SYMBOL_GPL (__pata_platform_remove); + +static int __devinit pata_platform_probe (struct platform_device *pdev) +{ +struct resource *io_res; +struct resource *ctl_res; +struct resource *irq_res; +struct pata_platform_info *pp_info = pdev->dev.platform_data; + +/* +* Simple resource validation .. +*/ +if ((pdev->num_resources !=3 ) && (pdev->num_resources !=2 )) { +dev_err (&pdev->dev,"invalid number of resources\n" ); +return -EINVAL ; + } + +/* +* Get the I/O base first +*/ + io_res =platform_get_resource (pdev,IORESOURCE_IO ,0 ); +if (io_res ==NULL ) { + io_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (unlikely (io_res ==NULL )) +return -EINVAL ; + } + +/* +* Then the CTL base +*/ + ctl_res =platform_get_resource (pdev,IORESOURCE_IO ,1 ); +if (ctl_res ==NULL ) { + ctl_res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); +if (unlikely (ctl_res ==NULL )) +return -EINVAL ; + } + +/* +* And the IRQ +*/ + irq_res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); +if (irq_res) + irq_res->flags = pp_info ? pp_info->irq_flags :0 ; + +return __pata_platform_probe (&pdev->dev, io_res, ctl_res, irq_res, + pp_info ? pp_info->ioport_shift :0 , + pio_mask); +} + +static int __devexit pata_platform_remove(struct platform_device *pdev) +{ +return __pata_platform_remove (&pdev->dev); +}static struct platform_driver pata_platform_driver = { .probe = pata_platform_probe,
include/linux/pata_platform.h +9 -0
@@ -15,4 +15,13 @@ struct pata_platform_info {unsigned int irq_flags; }; +extern int __devinit __pata_platform_probe (struct device *dev, +struct resource *io_res, +struct resource *ctl_res, +struct resource *irq_res, +unsigned int ioport_shift, +int __pio_mask); + +extern int __devexit __pata_platform_remove(struct device *dev); +#endif /* __LINUX_PATA_PLATFORM_H */
Signature · 1 line
1.5.2.2
PATCH v4 2/3 pata_of_platform: OF-Platform PATA device driver
In reply to Anton VorontsovThis driver nicely wraps around pata_platform library functions, and provides OF platform bus bindings to the PATA devices.
Also add || PPC to the PATA_PLATFORM's "depends on" Kconfig entry, needed for PA Semi Electra.
--- drivers/ata/Kconfig | 12 ++++- drivers/ata/Makefile | 1 + drivers/ata/pata_of_platform.c | 104 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletions(-) create mode 100644 drivers/ata/pata_of_platform.c
drivers/ata/Kconfig +11 -1
@@ -607,13 +607,23 @@ config PATA_WINBOND_VLB config PATA_PLATFORM tristate "Generic platform device PATA support" - depends on EMBEDDED || ARCH_RPC + depends on EMBEDDED || ARCH_RPC || PPC help This option enables support for generic directly connected ATA devices commonly found on embedded systems. If unsure, say N. +config PATA_OF_PLATFORM + tristate "OpenFirmware platform device PATA support" + depends on PATA_PLATFORM && PPC_OF + help + This option enables support for generic directly connected ATA + devices commonly found on embedded systems with OpenFirmware + bindings. + + If unsure, say N. + config PATA_ICSIDE tristate "Acorn ICS PATA support" depends on ARM && ARCH_ACORN
drivers/ata/Makefile +1 -0
@@ -67,6 +67,7 @@ obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o obj-$(CONFIG_PATA_SCC) += pata_scc.o obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o +obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o # Should be last but two libata driver obj-$(CONFIG_PATA_ACPI) += pata_acpi.o
drivers/ata/pata_of_platform.c new file +104 -0
104 lines not on this page · raw message
Signature · 1 line
1.5.2.2
PATCH v4 3/3 MPC8349E-mITX: introduce localbus and pata nodes
In reply to Anton VorontsovThis patch adds localbus and pata nodes to use CF IDE interface on MPC8349E-mITX boards.
Patch also updates defconfig and adds some code to probe localbus.
--- arch/powerpc/boot/dts/mpc8349emitx.dts | 17 ++++++++++++++++- arch/powerpc/configs/mpc834x_itx_defconfig | 3 ++- arch/powerpc/platforms/83xx/mpc834x_itx.c | 12 ++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-)
arch/powerpc/boot/dts/mpc8349emitx.dts +16 -1
@@ -253,6 +253,21 @@ device_type = "pci"; }; + localbus@e0005000 { + #address-cells = <2>; + #size-cells = <1>; + compatible = "fsl,mpc8349e-localbus", + "fsl,pq2pro-localbus"; + reg = <e0005000 d8>; + ranges = <3 0 f0000000 210>; - + pata@3,0 { + compatible = "fsl,mpc8349emitx-pata", "ata-generic"; + reg = <3 0 10 3 20c 4>; + reg-shift = <1>; + pio-mode = <6>; + interrupts = <17 8>; + interrupt-parent = <&ipic>; + }; + }; };
arch/powerpc/configs/mpc834x_itx_defconfig +2 -1
@@ -570,7 +570,8 @@ CONFIG_SATA_SIL=y # CONFIG_PATA_SIS is not set # CONFIG_PATA_VIA is not set # CONFIG_PATA_WINBOND is not set -# CONFIG_PATA_PLATFORM is not set +CONFIG_PATA_PLATFORM=y +CONFIG_PATA_OF_PLATFORM=y CONFIG_MD=y CONFIG_BLK_DEV_MD=y CONFIG_MD_LINEAR=y
arch/powerpc/platforms/83xx/mpc834x_itx.c +12 -0
@@ -23,6 +23,7 @@#include <linux/delay.h> #include <linux/seq_file.h> #include <linux/root_dev.h> +#include <linux/of_platform.h> #include <asm/system.h> #include <asm/atomic.h>
@@ -37,6 +38,17 @@#include "mpc83xx.h" +static struct of_device_id __initdata mpc834x_itx_ids[] = { + { .compatible ="fsl,pq2pro-localbus" , }, + {}, +}; + +static int __init mpc834x_itx_declare_of_platform_devices (void ) +{ +return of_platform_bus_probe (NULL , mpc834x_itx_ids,NULL ); +} +machine_device_initcall (mpc834x_itx, mpc834x_itx_declare_of_platform_devices); +/* ************************************************************************ * * Setup the architecture
Signature · 1 line
1.5.2.2
Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
In reply to Anton VorontsovHi Anton,
Juts one small trivial comment (could be fixed later).
Quoted 2 lines · On Wed, 9 Jan 2008 22:10:41 +0300 Anton Vorontsov <[email protected]>…
+static struct
of_device_idpata_of_platform_match[] = {
This could be declared const.
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
Quoted 9 lines · Stephen Rothwell
Hi Anton,
Juts one small trivial comment (could be fixed later).
Quoted 2 lines · On Wed, 9 Jan 2008 22:10:41 +0300 Anton Vorontsov <[email protected]>…
+static struct
of_device_idpata_of_platform_match[] = {This could be declared const.
Good point, but let's not hold up merge based on this. Need something for janitors to do too, and it's good enough to merge as-is. :)
-Olof
Re: [PATCH 2/3] [libata] pata_of_platform: OF-Platform PATA device driver
Quoted 6 lines · On Wed, 9 Jan 2008 18:36:34 -0600 Olof Johansson <[email protected]> wrote:
Quoted 4 lines · Stephen Rothwell
Hi Anton,
Juts one small trivial comment (could be fixed later).
Quoted 8 lines
Quoted 5 lines · On Wed, 9 Jan 2008 22:10:41 +0300 Anton Vorontsov <[email protected]>…
Quoted 2 lines
+static struct
of_device_idpata_of_platform_match[] = {This could be declared const.
Good point, but let's not hold up merge based on this. Need something for janitors to do too, and it's good enough to merge as-is. :)
Absolutely. To me that is what "(could be fixed later)" means. :-)
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Olof Johansson
AppliedHi,
I've applied 1/3 and 2/3 together with my electra_ide move to pasemi.git for-2.6.25, and will ask Paul to pull that. Kumar said he'd take 3/3.
I also added the const to the match table as spotted by Stephen.
-Olof
Quoted 40 lines · Anton Vorontsov
Hi all,
Here is the resend (aka v4) version of the OF-platform PATA driver and related patches.
Changes since v3:
- Acked-by: Paul Mundt <[email protected]>
- In the powerpc specific patch: update defconfig and usemachine_device_initcall-- this is new call found in the galak/powerpc.git.Changes since v2:
- "PPC" added toPATA_PLATFORM"depends on"Kconfigentry; I didn't remove EMBEDDED "depends on" -- this wasn't discussed much and these patches should not depend on the decision.
- cosmetic fixes;
- "s/ioport_shift/reg_shift/g" patch dropped.Changes since v1:
-__pata_platform_probenow acceptspio_maskargument;
- pata-platform compatible property renamed to ata-generic;
-pata_of_platformunderstands pio-mode property. It's used to passpio_maskto the__pata_platform_probe. That is, in ata-generic context pio-mode means "pio mode the bus already configured for";
- New optional patch that renames pata_platform_info'sioport_shifttoreg_shift.Changes since RFC:
- nukeddrivers/ata/pata_platform.h;
- powerpc bits: proper localbus node added.Signature · 8 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2 _______________________________________________ Linuxppc-dev mailing list [email protected] https://ozlabs.org/mailman/listinfo/linuxppc-dev
PATCH 1/1 pasemi: Move electra-ide to pata_of_platform
In reply to Anton VorontsovMove electra-ide glue over to the new pata_of_platform framework, and add the quirks needed to that driver.
---
Applied with the rest of the patches to pasemi.git for-2.6.25
arch/powerpc/platforms/pasemi/electra_ide.c | 96 ---------------------------- b/arch/powerpc/configs/pasemi_defconfig | 4 - b/arch/powerpc/platforms/pasemi/Kconfig | 9 -- b/arch/powerpc/platforms/pasemi/Makefile | 1 b/drivers/ata/pata_of_platform.c | 20 ++++- 5 files changed, 17 insertions(+), 113 deletions(-)
arch/powerpc/configs/pasemi_defconfig +2 -2
@@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Linux kernel version: 2.6.24-rc6 -# Fri Dec 28 11:01:53 2007 +# Tue Jan 15 10:26:10 2008 # CONFIG_PPC64=y
@@ -152,7 +152,6 @@ CONFIG_PPC_PASEMI=y CONFIG_PPC_PASEMI_IOMMU=y # CONFIG_PPC_PASEMI_IOMMU_DMA_FORCE is not set CONFIG_PPC_PASEMI_MDIO=y -CONFIG_ELECTRA_IDE=y # CONFIG_PPC_CELLEB is not set # CONFIG_PPC_PS3 is not set # CONFIG_PPC_CELL is not set
@@ -663,6 +662,7 @@ CONFIG_PATA_PCMCIA=y # CONFIG_PATA_VIA is not set # CONFIG_PATA_WINBOND is not set CONFIG_PATA_PLATFORM=y +CONFIG_PATA_OF_PLATFORM=y CONFIG_MD=y CONFIG_BLK_DEV_MD=y CONFIG_MD_LINEAR=y
arch/powerpc/platforms/pasemi/Kconfig +0 -9
@@ -37,13 +37,4 @@ config PPC_PASEMI_MDIO help Driver for MDIO via GPIO on PWRficient platforms -config ELECTRA_IDE - tristate "Electra IDE driver" - default y - depends on PPC_PASEMI && ATA - select PATA_PLATFORM - help - This includes driver support for the Electra on-board IDE - interface. - endmenu
arch/powerpc/platforms/pasemi/Makefile +0 -1
@@ -1,4 +1,3 @@ obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o -obj-$(CONFIG_ELECTRA_IDE) += electra_ide.o obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += cpufreq.o
arch/powerpc/platforms/pasemi/electra_ide.c deleted +0 -96
96 lines not on this page · raw message
drivers/ata/pata_of_platform.c +15 -5
@@ -34,11 +34,20 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev,return -EINVAL ; } - ret =of_address_to_resource (dn,1 , &ctl_res); -if (ret) { -dev_err (&ofdev->dev,"can't get CTL address from " -"device tree\n" ); -return -EINVAL ; +if (of_device_is_compatible (dn,"electra-ide" )) { +/* Altstatus is really at offset 0x3f6 from the primary window +* on electra-ide. Adjust ctl_res and io_res accordingly. +*/ + ctl_res = io_res; + ctl_res.start = ctl_res.start+0x3f6 ; + io_res.end = ctl_res.start-1 ; + }else { + ret =of_address_to_resource (dn,1 , &ctl_res); +if (ret) { +dev_err (&ofdev->dev,"can't get CTL address from " +"device tree\n" ); +return -EINVAL ; + } } ret =of_irq_to_resource (dn,0 , &irq_res);
@@ -76,6 +85,7 @@ static int __devexit pata_of_platform_remove(struct of_device *ofdev)static struct of_device_id pata_of_platform_match[] = { { .compatible ="ata-generic" , }, + { .compatible ="electra-ide" , }, {}, };MODULE_DEVICE_TABLE (of, pata_of_platform_match);
Re: [PATCH] [POWERPC] pasemi: Move electra-ide to pata_of_platform
Quoted 5 lines · Olof Johansson
Move electra-ide glue over to the new
pata_of_platformframework, and add the quirks needed to that driver.---
Quoted 8 lines
Applied with the rest of the patches to pasemi.git for-2.6.25
arch/powerpc/platforms/pasemi/electra_ide.c | 96 ---------------------------- b/arch/powerpc/configs/pasemi_defconfig | 4 - b/arch/powerpc/platforms/pasemi/Kconfig | 9 -- b/arch/powerpc/platforms/pasemi/Makefile | 1 b/drivers/ata/pata_of_platform.c | 20 ++++- 5 files changed, 17 insertions(+), 113 deletions(-)
ACK
Quoted 6 lines · Olof Johansson
Hi,
I've applied 1/3 and 2/3 together with my
electra_idemove to pasemi.git for-2.6.25, and will ask Paul to pull that. Kumar said he'd take 3/3.I also added the const to the match table as spotted by Stephen.
Great news, thank you!
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2