ata: Compact Flash driver for Netlogic XLR/XLS
PATCH v2 1/1 ata: Compact Flash driver for Netlogic XLR/XLS
From: Kamlakant Patel <[email protected]>
Add a platform ATA driver for the CF interface on Netlogic XLR/XLS MIPS SoCs. Chipselect 6 on the peripheral IO bus on these SoCs can be configured to act as a Compact Flash interface.
The driver expects three resources to be passed to it:
0 - memory region corresponding to the CF chipselect 1 - memory region of the flash interrupt ack register in the
flash configuration region
2 - and the IRQ resource for the Compact Flash.
---
[Changes in V2 :
- fixes for comments by [email protected]
- use static functions
- use devm_request_and_ioremap for register area, and devm_ioremap for ack register area.
- ap->private_data usage - use a structure pata_xlr_priv instead of overloading the pointer.
]
drivers/ata/Kconfig | 9 +++ drivers/ata/Makefile | 1 + drivers/ata/pata_xlr_cf.c | 170 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 180 insertions(+) create mode 100644 drivers/ata/pata_xlr_cf.c
drivers/ata/Kconfig +9 -0
@@ -871,6 +871,15 @@ config PATA_SAMSUNG_CF If unsure, say N. +config PATA_XLR_CF + tristate "Netlogic XLR/XLS CompactFlash support" + depends on CPU_XLR + help + Support for the CompactFlash interface on Netlogic XLR/XLS + SoCs. Say Y if your Netlogic XLR/XLS board has a CF Slot. + + If unsure, say N. + config PATA_WINBOND_VLB tristate "Winbond W83759A VLB PATA support (Experimental)" depends on ISA && EXPERIMENTAL
drivers/ata/Makefile +1 -0
@@ -92,6 +92,7 @@ obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o obj-$(CONFIG_PATA_RB532) += pata_rb532_cf.o obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o obj-$(CONFIG_PATA_SAMSUNG_CF) += pata_samsung_cf.o +obj-$(CONFIG_PATA_XLR_CF) += pata_xlr_cf.o obj-$(CONFIG_PATA_PXA) += pata_pxa.o
drivers/ata/pata_xlr_cf.c new file +170 -0
170 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Hello.
Quoted 6 lines · Jayachandran C
From: Kamlakant Patel<[email protected]>
Add a platform ATA driver for the CF interface on Netlogic XLR/XLS MIPS SoCs. Chipselect 6 on the peripheral IO bus on these SoCs can be configured to act as a Compact Flash interface.
Quoted 8 lines
The driver expects three resources to be passed to it:
0 - memory region corresponding to the CF chipselect 1 - memory region of the flash interrupt ack register in the
flash configuration region
2 - and the IRQ resource for the Compact Flash.Signed-off-by Kamlakant Patel<[email protected]>Signed-off-by Jayachandran C<[email protected]>
Jayachandran, after our chat on #mipslinux I thought your next driver will
be for drivers/pcmcia/ since you're not going to use the True-IDE mode of the PCMCIA interface.
Quoted 6 lines
drivers/ata/pata_xlr_cf.c new file +0
-0@@ -0,0 +1,170 @@
[...]
drivers/ata/pata_xlr_cf.c line 24
Quoted 2 lines
drivers/ata/pata_xlr_cf.c new file +2
-0+#define XLR_CF_REG_BASE 0x1f0 +#define XLR_CF_REG_CTRL 0x3f6
These port addresses are the offsets in the PCMCIA I/O space of the I/O
card you insert. In True IDE mode they are replaced by -CEx signals IIRC.
drivers/ata/pata_xlr_cf.c line 27
Quoted 3 lines
drivers/ata/pata_xlr_cf.c new file +3
-0+ +struct pata_xlr_priv { +void __iomem *xlr_cf_ackreg;
Why not just make that register pointer the private data directly?
drivers/ata/pata_xlr_cf.c line 62
Quoted 7 lines
drivers/ata/pata_xlr_cf.c new file +7
-0+static bool pata_xlr_irq_check (struct ata_port *port) +{ +struct pata_xlr_priv *priv = port->private_data; +unsigned int reg; + + reg =readl (priv->xlr_cf_ackreg); +return (reg !=0 );
Parens not needed.
Quoted 18 lines
drivers/ata/pata_xlr_cf.c new file +18
-0+static int __devinit pata_xlr_cf_probe (struct platform_device *pdev) +{ +struct ata_host *host; +struct ata_port *ap; +struct ata_ioports *ioaddr; +struct resource *io_res, *irq_res, *ack_res; +struct pata_xlr_priv *priv; +struct device *dev =&pdev->dev; +void __iomem *iodata_addr; +int irq =0 ; + +/* Simple resource validation */ +if (pdev->num_resources !=3 ) { +dev_err (&pdev->dev,"invalid number of resources\n" ); +return -EINVAL ; + } + +/* Get the I/O base */
drivers/ata/pata_xlr_cf.c line 107
Quoted 10 lines
drivers/ata/pata_xlr_cf.c new file +10
-0+ io_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (io_res ==NULL ) +return -EINVAL ; + + ack_res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); +if (ack_res ==NULL ) +return -EINVAL ; + +/* And the IRQ */ + irq_res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );
You can use paltform_get_irq() and save on 'irq_res'.
drivers/ata/pata_xlr_cf.c line 140
Quoted 5 lines
drivers/ata/pata_xlr_cf.c new file +5
-0+if (irq_res && irq_res->start>0 ) + irq = irq_res->start; + + ioaddr = &ap->ioaddr; + ioaddr->data_addr = iodata_addr;
This is incorrect and overriden by ata_sff_std_ports() later.
drivers/ata/pata_xlr_cf.c line 147
Quoted 7 lines
drivers/ata/pata_xlr_cf.c new file +7
-0+ ioaddr->cmd_addr = ioaddr->data_addr +XLR_CF_REG_BASE ; + ioaddr->altstatus_addr = ioaddr->data_addr +XLR_CF_REG_CTRL ; + ioaddr->ctl_addr = ioaddr->data_addr +XLR_CF_REG_CTRL ; + +ata_sff_std_ports (ioaddr); + + ata_port_desc(ap, "mmio cmd 0x%x ctl 0x%x",
Why not use "0x%p" without the casts?
drivers/ata/pata_xlr_cf.c line 153
Quoted 6 lines
drivers/ata/pata_xlr_cf.c new file +6
-0+ (unsigned int )ap->ioaddr.cmd_addr, + (unsigned int)ap->ioaddr.ctl_addr); + +/* activate */ +return ata_host_activate (host, irq, irq ? ata_sff_interrupt :NULL , +IRQF_DISABLED , &pata_xlr_sht);
IRQF_DISABLED is a nop now. Don't add another use of this deprecated flag.
MBR, Sergei
Quoted 16 lines · Sergei Shtylyov
Hello.
Quoted 11 lines · Jayachandran C
From: Kamlakant Patel<[email protected]>
Add a platform ATA driver for the CF interface on Netlogic XLR/XLS MIPS SoCs. Chipselect 6 on the peripheral IO bus on these SoCs can be configured to act as a Compact Flash interface.
The driver expects three resources to be passed to it:
0 - memory region corresponding to the CF chipselect 1 - memory region of the flash interrupt ack register in the
flash configuration region
2 - and the IRQ resource for the Compact Flash.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Kamlakant Patel<[email protected]>Signed-off-by Jayachandran C<[email protected]>Jayachandran, after our chat on #mipslinux I thought your next
driver will be fordrivers/pcmcia/since you're not going to use the True-IDE mode of the PCMCIA interface.
Since the CF is expected to be present at boot-time (and initialized by firmware), we can just use a simple PATA driver instead of using the full PCMCIA infrastructure. But we are looking at that option as well.
Quoted 15 lines
Quoted 7 lines
drivers/ata/pata_xlr_cf.c new file +0
-0@@ -0,0 +1,170 @@[...]
drivers/ata/pata_xlr_cf.c line 24
Quoted 2 lines
drivers/ata/pata_xlr_cf.c new file +2
-0+#define XLR_CF_REG_BASE 0x1f0 +#define XLR_CF_REG_CTRL 0x3f6These port addresses are the offsets in the PCMCIA I/O space of
the I/O card you insert. In True IDE mode they are replaced by -CEx signals IIRC.
Quoted 5 lines
drivers/ata/pata_xlr_cf.c line 27
Quoted 3 lines
drivers/ata/pata_xlr_cf.c new file +3
-0+ +struct pata_xlr_priv { +void __iomem *xlr_cf_ackreg;Why not just make that register pointer the private data directly?
That would lose the __iomem attribute.
Quoted 59 lines
drivers/ata/pata_xlr_cf.c line 62
Quoted 7 lines
drivers/ata/pata_xlr_cf.c new file +7
-0+static bool pata_xlr_irq_check (struct ata_port *port) +{ +struct pata_xlr_priv *priv = port->private_data; +unsigned int reg; + + reg =readl (priv->xlr_cf_ackreg); +return (reg !=0 );Parens not needed.
Quoted 18 lines
drivers/ata/pata_xlr_cf.c new file +18
-0+static int __devinit pata_xlr_cf_probe (struct platform_device *pdev) +{ +struct ata_host *host; +struct ata_port *ap; +struct ata_ioports *ioaddr; +struct resource *io_res, *irq_res, *ack_res; +struct pata_xlr_priv *priv; +struct device *dev =&pdev->dev; +void __iomem *iodata_addr; +int irq =0 ; + +/* Simple resource validation */ +if (pdev->num_resources !=3 ) { +dev_err (&pdev->dev,"invalid number of resources\n" ); +return -EINVAL ; + } + +/* Get the I/O base */ drivers/ata/pata_xlr_cf.c line 107
Quoted 10 lines
drivers/ata/pata_xlr_cf.c new file +10
-0+ io_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (io_res ==NULL ) +return -EINVAL ; + + ack_res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); +if (ack_res ==NULL ) +return -EINVAL ; + +/* And the IRQ */ + irq_res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );You can use
paltform_get_irq()and save on 'irq_res'.drivers/ata/pata_xlr_cf.c line 140
Quoted 5 lines
drivers/ata/pata_xlr_cf.c new file +5
-0+if (irq_res && irq_res->start>0 ) + irq = irq_res->start; + + ioaddr = &ap->ioaddr; + ioaddr->data_addr = iodata_addr;This is incorrect and overriden by
ata_sff_std_ports()later.drivers/ata/pata_xlr_cf.c line 147
Quoted 7 lines
drivers/ata/pata_xlr_cf.c new file +7
-0+ ioaddr->cmd_addr = ioaddr->data_addr +XLR_CF_REG_BASE ; + ioaddr->altstatus_addr = ioaddr->data_addr +XLR_CF_REG_CTRL ; + ioaddr->ctl_addr = ioaddr->data_addr +XLR_CF_REG_CTRL ; + +ata_sff_std_ports (ioaddr); + + ata_port_desc(ap, "mmio cmd 0x%x ctl 0x%x",Why not use "0x%p" without the casts?
Quoted 8 lines
drivers/ata/pata_xlr_cf.c line 153
Quoted 6 lines
drivers/ata/pata_xlr_cf.c new file +6
-0+ (unsigned int )ap->ioaddr.cmd_addr, + (unsigned int)ap->ioaddr.ctl_addr); + +/* activate */ +return ata_host_activate (host, irq, irq ? ata_sff_interrupt :NULL , +IRQF_DISABLED , &pata_xlr_sht);
IRQF_DISABLEDis a nop now. Don't add another use of this deprecated flag.
Thanks for the comments, will post an updated patch (after we try the PCMCIA option as well).
Regards,
JC.