From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: Anton Salnikov <asalnikov@ru.mvista.com>
Cc: linux-ide@vger.kernel.org, bzolnier@gmail.com
Subject: Re: [PATCH] Palmchip BK3710 IDE driver
Date: Thu, 24 Jan 2008 22:18:22 +0300 [thread overview]
Message-ID: <4798E47E.3060701@ru.mvista.com> (raw)
In-Reply-To: <200801241801.08201.asalnikov@ru.mvista.com>
Anton Salnikov wrote:
> This is Palmchip BK3710 IDE controller support for kernel version 2.6.24-rc8.
> The IDE controller logic supports PIO, multiword DMA and ultra-DMA modes.
> Supports interface to compact Flash (CF) configured in True-IDE mode.
> Signed-off-by: Anton Salnikov <asalnikov@ru.mvista.com>
> ---
> Index: 2.6.24-rc8.ide/drivers/ide/arm/palm_bk3710.c
> ===================================================================
> --- /dev/null
> +++ 2.6.24-rc8.ide/drivers/ide/arm/palm_bk3710.c
> @@ -0,0 +1,428 @@
> +static inline u8 hwif_read8(u32 base, u32 reg)
> +{
> + return readb(base + reg);
> +}
> +
> +static inline void hwif_write8(u32 base, u8 val, u32 reg)
> +{
> + writeb(val, base + reg);
> +}
> +
> +static inline u16 hwif_read16(u32 base, u32 reg)
> +{
> + return readw(base + reg);
> +}
> +
> +static inline void hwif_write16(u32 base, u16 val, u32 reg)
> +{
> + writew(val, base + reg);
> +}
> +
> +static inline u32 hwif_read32(u32 base, u32 reg)
> +{
> + return readl(base + reg);
> +}
> +
> +static inline void hwif_write32(u32 base, u32 val, u32 reg)
> +{
> + writel(val, base + reg);
> +}
Hm, I don't see why you need those accessors but well...
> +static void palm_bk3710_setudmamode(u32 base, unsigned int dev,
> + unsigned int mode)
> +{
> + u8 tenv, trp, t0;
> + u32 val32;
> + u16 val16;
> +
> + /* DMA Data Setup */
> + t0 = (palm_bk3710_udmatimings[mode].cycletime + ide_palm_clk - 1)
> + / ide_palm_clk - 1;
> + tenv = (20 + ide_palm_clk - 1) / ide_palm_clk - 1;
> + trp = (palm_bk3710_udmatimings[mode].rptime + ide_palm_clk - 1)
> + / ide_palm_clk - 1;
> +
> + /* udmatim Register */
> + val16 = hwif_read16(base, BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0);
> + val16 |= (mode << ((!dev) ? 0 : 4));
Why not (dev ? 4 : 0) like the rest?
> + hwif_write16(base, val16, BK3710_UDMATIM);
> +
> + /* udmastb Ultra DMA Access Strobe Width */
> + val32 = hwif_read32(base, BK3710_UDMASTB) & (0xFF << (dev ? 0 : 8));
> + val32 |= (t0 << (dev ? 8 : 0));
> + hwif_write32(base, val32, BK3710_UDMASTB);
> +
> + /* udmatrp Ultra DMA Ready to Pause Time */
> + val32 = hwif_read32(base, BK3710_UDMATRP) & (0xFF << (dev ? 0 : 8));
> + val32 |= (trp << (dev ? 8 : 0));
> + hwif_write32(base, val32, BK3710_UDMATRP);
> +
> + /* udmaenv Ultra DMA envelop Time */
> + val32 = hwif_read32(base, BK3710_UDMAENV) & (0xFF << (dev ? 0 : 8));
> + val32 |= (tenv << (dev ? 8 : 0));
> + hwif_write32(base, val32, BK3710_UDMAENV);
> +
> + /* Enable UDMA for Device */
> + val16 = hwif_read16(base, BK3710_UDMACTL) | (1 << dev);
> + hwif_write16(base, val16, BK3710_UDMACTL);
> +}
> +
> +static void palm_bk3710_setdmamode(u32 base, unsigned int dev,
> + unsigned short min_cycle,
> + unsigned int mode)
> +{
> + u8 td, tkw, t0;
> + u32 val32;
> + u16 val16;
> +
> + unsigned cycletime = max_t(int, ide_timing_find_mode(mode)->cycle,
> + min_cycle);
Hm, why integer comparison and then unsigned maximum?
> +
> + /* DMA Data Setup */
> + t0 = (cycletime + ide_palm_clk - 1) / ide_palm_clk;
> + td = (ide_timing_find_mode(mode)->active + ide_palm_clk - 1)
> + / ide_palm_clk;
Couldn't you call ide_timing_find_mode() only once?
[...]
> +static int __devinit palm_bk3710_probe(struct platform_device *pdev)
> +{
> + hw_regs_t ide_ctlr_info;
> + int index = 0;
> + int pribase;
> + struct clk *clkp;
> + struct resource *mem, *irq;
> + ide_hwif_t *hwif;
> + u32 base;
> + int ret;
> +
> + clkp = clk_get(NULL, "IDECLK");
> + if (IS_ERR(clkp))
> + return -ENODEV;
> +
> + ideclkp = clkp;
> + clk_enable(ideclkp);
> + ide_palm_clk = clk_get_rate(ideclkp)/100000;
> + ide_palm_clk = (10000/ide_palm_clk) + 1;
> + /* Register the IDE interface with Linux ATA Interface */
> + memset(&ide_ctlr_info, 0, sizeof(ide_ctlr_info));
> +
> + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (mem == NULL) {
> + printk(KERN_INFO "failed to get memory region resource\n");
This deserves KERN_ERR, not KERN_INFO.
> + return -ENODEV;
> + }
> + irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> + if (irq == NULL) {
> + printk(KERN_INFO "failed to get IRQ resource\n");
This too...
> + return -ENODEV;
> + }
> +
> + base = mem->start;
> +
> + /* Configure the Palm Chip controller */
> + palm_bk3710_chipinit(base);
> +
> + pribase = mem->start + IDE_PALM_ATA_PRI_REG_OFFSET;
> + for (index = 0; index < IDE_NR_PORTS - 2; index++)
> + ide_ctlr_info.io_ports[index] = pribase + index;
> + ide_ctlr_info.io_ports[IDE_CONTROL_OFFSET] = mem->start +
> + IDE_PALM_ATA_PRI_CTL_OFFSET;
> + ide_ctlr_info.irq = irq->start;
> + ide_ctlr_info.chipset = ide_palm3710;
> +
> + if (!request_mem_region(mem->start, 8, "palm_bk3710")) {
> + printk(KERN_ERR "Error, memory region in use.\n");
> + return -EBUSY;
> + }
Well, you either have to also register sub-resources for the IDE
command/control register blocks since with hwif->mmiops == 1 the IDE core
won't do this for you, or don't register any sub-resources at all, being
content with what platform_device_add() did for us. BTW, don't forget extend
the platform resource to account for IDE command/control register blocks.
> + if (ide_register_hw(&ide_ctlr_info, NULL, 0, &hwif) < 0) {
> + printk(KERN_WARNING "Palm Chip BK3710 IDE Register Fail\n");
> + return -ENODEV;
> + }
> +
> + hwif->set_pio_mode = &palm_bk3710_set_pio_mode;
> + hwif->set_dma_mode = &palm_bk3710_set_dma_mode;
> + hwif->mmio = 1;
Well, dealing with a memory-mapped IDE device, the driver lack
default_hwif_mmiops() call...
MBR, Sergei
next prev parent reply other threads:[~2008-01-24 19:17 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-24 15:01 [PATCH] Palmchip BK3710 IDE driver Anton Salnikov
2008-01-24 19:18 ` Sergei Shtylyov [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-02-05 16:04 Anton Salnikov
2008-02-06 1:35 ` Bartlomiej Zolnierkiewicz
2008-05-15 18:32 ` Sergei Shtylyov
2008-01-25 12:12 Anton Salnikov
2008-01-29 18:36 ` Sergei Shtylyov
2008-01-29 18:38 ` Alan Cox
2008-02-02 0:29 ` Bartlomiej Zolnierkiewicz
2008-01-21 18:44 Anton Salnikov
2008-01-21 19:51 ` Alan Cox
2008-01-22 12:11 ` Anton Salnikov
2008-01-22 14:37 ` Alan Cox
2008-01-22 19:31 ` Jeff Garzik
2008-01-22 20:30 ` Sergei Shtylyov
2008-01-22 22:22 ` Alan Cox
2008-01-23 13:38 ` Sergei Shtylyov
2008-01-23 14:59 ` Alan Cox
2008-01-23 14:32 ` Sergei Shtylyov
2008-01-17 18:50 Anton Salnikov
2008-01-17 18:57 ` Sergei Shtylyov
2008-01-17 23:23 ` Alan Cox
2008-01-18 14:14 ` Sergei Shtylyov
2008-01-18 15:04 ` Alan Cox
2008-01-18 18:03 ` Sergei Shtylyov
2008-01-18 22:20 ` Bartlomiej Zolnierkiewicz
2008-01-18 22:19 ` Bartlomiej Zolnierkiewicz
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=4798E47E.3060701@ru.mvista.com \
--to=sshtylyov@ru.mvista.com \
--cc=asalnikov@ru.mvista.com \
--cc=bzolnier@gmail.com \
--cc=linux-ide@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.