From: <mar...@us...> - 2007-08-30 02:31:56
|
Revision: 1288 http://hackndev.svn.sourceforge.net/hackndev/?rev=1288&view=rev Author: marex_z71 Date: 2007-08-29 19:31:54 -0700 (Wed, 29 Aug 2007) Log Message: ----------- PalmTX: WORKING NAND Flash driver Modified Paths: -------------- linux4palm/linux/trunk/drivers/mtd/nand/palmtx.c Modified: linux4palm/linux/trunk/drivers/mtd/nand/palmtx.c =================================================================== --- linux4palm/linux/trunk/drivers/mtd/nand/palmtx.c 2007-08-29 15:42:49 UTC (rev 1287) +++ linux4palm/linux/trunk/drivers/mtd/nand/palmtx.c 2007-08-30 02:31:54 UTC (rev 1288) @@ -36,6 +36,12 @@ */ static struct mtd_info *palmtx_nand_mtd = NULL; +/* + * Control lines + */ +void __iomem *nand_ale = NULL; +void __iomem *nand_cle = NULL; + /* * Module stuff */ @@ -55,29 +61,27 @@ #endif /* - * hardware specific access to control-lines + * Hardware specific access to control-lines */ static void palmtx_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) { struct nand_chip *chip = mtd->priv; - unsigned long bits = 0; - if (ctrl & NAND_CTRL_CHANGE) { - /* Select chip */ - SET_PALMTX_GPIO(NAND_CS1_N, (ctrl & NAND_NCE) ? 0 : 1); - - /* Set control lines */ - if (ctrl & NAND_CLE) - bits |= 1<<25; - if (ctrl & NAND_ALE) - bits |= 1<<24; - iowrite32(bits, chip->IO_ADDR_W); - } - /* If there is a command for the chip, send it */ - if (cmd != NAND_CMD_NONE) - iowrite32((cmd & 0xff) | bits, chip->IO_ADDR_W); + if (cmd != NAND_CMD_NONE) { + switch ((ctrl & 0x6) >> 1) { + case 1: /* CLE */ + writeb(cmd, nand_cle); + break; + case 2: /* ALE */ + writeb(cmd, nand_ale); + break; + default: + printk("PalmTX NAND: invalid bit\n"); + break; + } + } } /* @@ -98,7 +102,6 @@ palmtx_nand_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); if (!palmtx_nand_mtd) { printk("Unable to allocate palmtx NAND MTD device structure.\n"); - iounmap((void *)nandaddr); return -ENOMEM; } @@ -106,9 +109,22 @@ nandaddr = ioremap(PALMTX_PHYS_NAND_START, 0x1000); if (!nandaddr) { printk("Failed to ioremap NAND flash.\n"); + iounmap((void *)palmtx_nand_mtd); return -ENOMEM; } + /* Remap physical address of control lines */ + nand_ale = ioremap(PALMTX_PHYS_NAND_START | 1<<24, 0x1000); + if (!nand_ale) { + printk("Failed to ioremap NAND flash.\n"); + return -ENOMEM; + } + nand_cle = ioremap(PALMTX_PHYS_NAND_START | 1<<25, 0x1000); + if (!nand_cle) { + printk("Failed to ioremap NAND flash.\n"); + return -ENOMEM; + } + /* Get pointer to private data */ this = (struct nand_chip *)(&palmtx_nand_mtd[1]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |