From: <mar...@us...> - 2007-08-18 16:13:49
|
Revision: 1240 http://hackndev.svn.sourceforge.net/hackndev/?rev=1240&view=rev Author: marex_z71 Date: 2007-08-18 09:13:40 -0700 (Sat, 18 Aug 2007) Log Message: ----------- PalmTX: UNTESTED NAND Flash driver ... looking for stunts ;-) Modified Paths: -------------- linux4palm/linux/trunk/drivers/mtd/nand/Kconfig linux4palm/linux/trunk/drivers/mtd/nand/Makefile linux4palm/linux/trunk/include/asm-arm/arch-pxa/palmtx-gpio.h Added Paths: ----------- linux4palm/linux/trunk/drivers/mtd/nand/palmtx.c Modified: linux4palm/linux/trunk/drivers/mtd/nand/Kconfig =================================================================== --- linux4palm/linux/trunk/drivers/mtd/nand/Kconfig 2007-08-14 15:02:54 UTC (rev 1239) +++ linux4palm/linux/trunk/drivers/mtd/nand/Kconfig 2007-08-18 16:13:40 UTC (rev 1240) @@ -51,6 +51,12 @@ help This enables the driver for the iPAQ h1900 flash. +config MTD_NAND_PALMTX + tristate "Palm T|X NAND flash (!UNTESTED!)" + depends on MTD_NAND && ARCH_PXA && MTD_PARTITIONS + help + This enables the driver for the Palm T|X NAND flash. + config MTD_NAND_SPIA tristate "NAND Flash device on SPIA board" depends on ARCH_P720T && MTD_NAND Modified: linux4palm/linux/trunk/drivers/mtd/nand/Makefile =================================================================== --- linux4palm/linux/trunk/drivers/mtd/nand/Makefile 2007-08-14 15:02:54 UTC (rev 1239) +++ linux4palm/linux/trunk/drivers/mtd/nand/Makefile 2007-08-18 16:13:40 UTC (rev 1240) @@ -18,6 +18,7 @@ obj-$(CONFIG_MTD_NAND_HAMCOP) += hamcop_nand.o obj-$(CONFIG_MTD_NAND_DISKONCHIP) += diskonchip.o obj-$(CONFIG_MTD_NAND_H1900) += h1910.o +obj-$(CONFIG_MTD_NAND_PALMTX) += palmtx.o obj-$(CONFIG_MTD_NAND_RTC_FROM4) += rtc_from4.o obj-$(CONFIG_MTD_NAND_SHARPSL) += sharpsl.o obj-$(CONFIG_MTD_NAND_TS7250) += ts7250.o Added: linux4palm/linux/trunk/drivers/mtd/nand/palmtx.c =================================================================== --- linux4palm/linux/trunk/drivers/mtd/nand/palmtx.c (rev 0) +++ linux4palm/linux/trunk/drivers/mtd/nand/palmtx.c 2007-08-18 16:13:40 UTC (rev 1240) @@ -0,0 +1,191 @@ +/* + * drivers/mtd/nand/palmtx.c + * + * Copyright (C) 2007 Marek Vasut (mar...@gm...) + * + * Derived from drivers/mtd/nand/h1910.c + * Copyright (C) 2003 Joshua Wise (jo...@jo...) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Overview: + * This is a device driver for the NAND flash device found on the + * Palm T|X board which utilizes the Samsung K9F1G08U0A part. This is + * a 1Gbit (128MiB x 8 bits) NAND flash device. + */ + +#include <linux/slab.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/mtd/mtd.h> +#include <linux/mtd/nand.h> +#include <linux/mtd/partitions.h> +#include <asm/io.h> +#include <asm/sizes.h> +#include <asm/arch/palmtx-gpio.h> +#include <asm/arch/pxa-regs.h> +#include <asm/setup.h> +#include <asm/memory.h> +#include <asm/mach-types.h> + +#define PALMTX_NAND_BASE 0x08000000 + +/* + * MTD structure + */ +static struct mtd_info *palmtx_nand_mtd = NULL; + +/* + * Module stuff + */ + +#ifdef CONFIG_MTD_PARTITIONS +/* + * Define static partitions for flash device + */ +static struct mtd_partition partition_info[] = { + {name:"PalmTX NAND Flash", + offset:0, + size:128 * 1024 * 1024} +}; + +#define NUM_PARTITIONS 1 + +#endif + +/* + * hardware specific access to control-lines + * + * NAND_NCE: bit 0 - don't care + * NAND_CLE: bit 1 - address bit 2 + * NAND_ALE: bit 2 - address bit 3 + */ +static void palmtx_hwcontrol(struct mtd_info *mtd, int cmd, + unsigned int ctrl) +{ + struct nand_chip *chip = mtd->priv; + + if (cmd != NAND_CMD_NONE) + writeb(cmd, (void __iomem *)((unsigned long)chip->IO_ADDR_W | ((ctrl & 0x6) << 1))); +} + +/* + * read device ready pin + */ +static int palmtx_device_ready(struct mtd_info *mtd) +{ + return GET_PALMTX_GPIO(NAND_READY); +} + +/* + * Main initialization routine + */ +static int __init palmtx_init(void) +{ + struct nand_chip *this; + const char *part_type = 0; + int mtd_parts_nb = 0; + struct mtd_partition *mtd_parts = 0; + void __iomem *nandaddr; + + if (!machine_is_xscale_palmtx()) + return -ENODEV; + + nandaddr = ioremap(PALMTX_NAND_BASE, 0x1000); + if (!nandaddr) { + printk("Failed to ioremap NAND flash.\n"); + return -ENOMEM; + } + + /* Allocate memory for MTD device structure and private data */ + 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; + } + + /* Get pointer to private data */ + this = (struct nand_chip *)(&palmtx_nand_mtd[1]); + + /* Initialize structures */ + memset(palmtx_nand_mtd, 0, sizeof(struct mtd_info)); + memset(this, 0, sizeof(struct nand_chip)); + + /* Link the private data with the MTD structure */ + palmtx_nand_mtd->priv = this; + palmtx_nand_mtd->owner = THIS_MODULE; + + /* + * Enable VPEN + */ + SET_PALMTX_GPIO(NAND_POWER, 1); + + /* insert callbacks */ + this->IO_ADDR_R = nandaddr; + this->IO_ADDR_W = nandaddr; + this->cmd_ctrl = palmtx_hwcontrol; +#if 0 + this->dev_ready = palmtx_device_ready; +#else + this->dev_ready = NULL; +#endif + /* 15 us command delay time */ + this->chip_delay = 50; + this->ecc.mode = NAND_ECC_SOFT; + this->options = NAND_NO_AUTOINCR; + + /* Scan to find existence of the device */ + if (nand_scan(palmtx_nand_mtd, 1)) { + printk(KERN_NOTICE "No NAND device - returning -ENXIO\n"); + kfree(palmtx_nand_mtd); + iounmap((void *)nandaddr); + return -ENXIO; + } +#ifdef CONFIG_MTD_CMDLINE_PARTS + mtd_parts_nb = parse_cmdline_partitions(palmtx_nand_mtd, &mtd_parts, "palmtx-nand"); + if (mtd_parts_nb > 0) + part_type = "command line"; + else + mtd_parts_nb = 0; +#endif + if (mtd_parts_nb == 0) { + mtd_parts = partition_info; + mtd_parts_nb = NUM_PARTITIONS; + part_type = "static"; + } + + /* Register the partitions */ + printk(KERN_NOTICE "Using %s partition definition\n", part_type); + add_mtd_partitions(palmtx_nand_mtd, mtd_parts, mtd_parts_nb); + + /* Return happy */ + return 0; +} + +module_init(palmtx_init); + +/* + * Clean up routine + */ +static void __exit palmtx_cleanup(void) +{ + struct nand_chip *this = (struct nand_chip *)&palmtx_nand_mtd[1]; + + /* Release resources, unregister device */ + nand_release(palmtx_nand_mtd); + + /* Release io resource */ + iounmap((void *)this->IO_ADDR_W); + + /* Free the MTD device structure */ + kfree(palmtx_nand_mtd); +} + +module_exit(palmtx_cleanup); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Marek Vasut <mar...@gm...>"); +MODULE_DESCRIPTION("NAND flash driver for Palm T|X"); Modified: linux4palm/linux/trunk/include/asm-arm/arch-pxa/palmtx-gpio.h =================================================================== --- linux4palm/linux/trunk/include/asm-arm/arch-pxa/palmtx-gpio.h 2007-08-14 15:02:54 UTC (rev 1239) +++ linux4palm/linux/trunk/include/asm-arm/arch-pxa/palmtx-gpio.h 2007-08-18 16:13:40 UTC (rev 1240) @@ -90,6 +90,11 @@ #define GPIO_NR_PALMTX_PCMCIA_RESET 79 #define GPIO_NR_PALMTX_PCMCIA_READY 116 +/* NAND Flash ... these GPIOs are probably incorrect! */ +#define GPIO_NR_PALMTX_NAND_POWER 19 +#define GPIO_NR_PALMTX_NAND_READY 37 + + /* INTERRUPTS */ #define IRQ_GPIO_PALMTX_SD_DETECT_N IRQ_GPIO(GPIO_NR_PALMTX_SD_DETECT_N) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |