Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: MigoR NAND flash support using gen_flash

Add NAND flash support to the MigoR board by giving board specific data
to the gen_nand platform driver.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>

authored by

Magnus Damm and committed by
Paul Mundt
3c803a9a b8808786

+73
+73
arch/sh/boards/renesas/migor/setup.c
··· 12 12 #include <linux/interrupt.h> 13 13 #include <linux/input.h> 14 14 #include <linux/mtd/physmap.h> 15 + #include <linux/mtd/nand.h> 15 16 #include <asm/machvec.h> 16 17 #include <asm/io.h> 17 18 #include <asm/sh_keysc.h> ··· 123 122 }, 124 123 }; 125 124 125 + static struct mtd_partition migor_nand_flash_partitions[] = { 126 + { 127 + .name = "nanddata1", 128 + .offset = 0x0, 129 + .size = 512 * 1024 * 1024, 130 + }, 131 + { 132 + .name = "nanddata2", 133 + .offset = MTDPART_OFS_APPEND, 134 + .size = 512 * 1024 * 1024, 135 + }, 136 + }; 137 + 138 + static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd, 139 + unsigned int ctrl) 140 + { 141 + struct nand_chip *chip = mtd->priv; 142 + 143 + if (cmd == NAND_CMD_NONE) 144 + return; 145 + 146 + if (ctrl & NAND_CLE) 147 + writeb(cmd, chip->IO_ADDR_W + 0x00400000); 148 + else if (ctrl & NAND_ALE) 149 + writeb(cmd, chip->IO_ADDR_W + 0x00800000); 150 + else 151 + writeb(cmd, chip->IO_ADDR_W); 152 + } 153 + 154 + static int migor_nand_flash_ready(struct mtd_info *mtd) 155 + { 156 + return ctrl_inb(PORT_PADR) & 0x02; /* PTA1 */ 157 + } 158 + 159 + struct platform_nand_data migor_nand_flash_data = { 160 + .chip = { 161 + .nr_chips = 1, 162 + .partitions = migor_nand_flash_partitions, 163 + .nr_partitions = ARRAY_SIZE(migor_nand_flash_partitions), 164 + .chip_delay = 20, 165 + .part_probe_types = (const char *[]) { "cmdlinepart", NULL }, 166 + }, 167 + .ctrl = { 168 + .dev_ready = migor_nand_flash_ready, 169 + .cmd_ctrl = migor_nand_flash_cmd_ctl, 170 + }, 171 + }; 172 + 173 + static struct resource migor_nand_flash_resources[] = { 174 + [0] = { 175 + .name = "NAND Flash", 176 + .start = 0x18000000, 177 + .end = 0x18ffffff, 178 + .flags = IORESOURCE_MEM, 179 + }, 180 + }; 181 + 182 + static struct platform_device migor_nand_flash_device = { 183 + .name = "gen_nand", 184 + .resource = migor_nand_flash_resources, 185 + .num_resources = ARRAY_SIZE(migor_nand_flash_resources), 186 + .dev = { 187 + .platform_data = &migor_nand_flash_data, 188 + } 189 + }; 190 + 126 191 static struct platform_device *migor_devices[] __initdata = { 127 192 &smc91x_eth_device, 128 193 &sh_keysc_device, 129 194 &migor_nor_flash_device, 195 + &migor_nand_flash_device, 130 196 }; 131 197 132 198 static int __init migor_devices_setup(void) ··· 214 146 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x4000, PORT_HIZCRA); 215 147 ctrl_outw(ctrl_inw(PORT_HIZCRC) & ~0xc000, PORT_HIZCRC); 216 148 ctrl_outl(ctrl_inl(MSTPCR2) & ~0x00004000, MSTPCR2); 149 + 150 + /* NAND Flash */ 151 + ctrl_outw(ctrl_inw(PORT_PXCR) & 0x0fff, PORT_PXCR); 152 + ctrl_outl((ctrl_inl(BSC_CS6ABCR) & ~0x00000600) | 0x00000200, 153 + BSC_CS6ABCR); 217 154 } 218 155 219 156 static struct sh_machine_vector mv_migor __initmv = {