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

Configure Feed

Select the types of activity you want to include in your feed.

at 77b2555b52a894a2e39a42e43d993df875c46a6a 122 lines 3.0 kB view raw
1/* 2 * $Id: walnut.c,v 1.2 2004/12/10 12:07:42 holindho Exp $ 3 * 4 * Mapping for Walnut flash 5 * (used ebony.c as a "framework") 6 * 7 * Heikki Lindholm <holindho@infradead.org> 8 * 9 * 10 * This program is free software; you can redistribute it and/or modify it 11 * under the terms of the GNU General Public License as published by the 12 * Free Software Foundation; either version 2 of the License, or (at your 13 * option) any later version. 14 */ 15 16#include <linux/module.h> 17#include <linux/types.h> 18#include <linux/kernel.h> 19#include <linux/init.h> 20#include <linux/mtd/mtd.h> 21#include <linux/mtd/map.h> 22#include <linux/mtd/partitions.h> 23#include <linux/config.h> 24#include <linux/version.h> 25#include <asm/io.h> 26#include <asm/ibm4xx.h> 27#include <platforms/4xx/walnut.h> 28 29/* these should be in platforms/4xx/walnut.h ? */ 30#define WALNUT_FLASH_ONBD_N(x) (x & 0x02) 31#define WALNUT_FLASH_SRAM_SEL(x) (x & 0x01) 32#define WALNUT_FLASH_LOW 0xFFF00000 33#define WALNUT_FLASH_HIGH 0xFFF80000 34#define WALNUT_FLASH_SIZE 0x80000 35 36static struct mtd_info *flash; 37 38static struct map_info walnut_map = { 39 .name = "Walnut flash", 40 .size = WALNUT_FLASH_SIZE, 41 .bankwidth = 1, 42}; 43 44/* Actually, OpenBIOS is the last 128 KiB of the flash - better 45 * partitioning could be made */ 46static struct mtd_partition walnut_partitions[] = { 47 { 48 .name = "OpenBIOS", 49 .offset = 0x0, 50 .size = WALNUT_FLASH_SIZE, 51 /*.mask_flags = MTD_WRITEABLE, */ /* force read-only */ 52 } 53}; 54 55int __init init_walnut(void) 56{ 57 u8 fpga_brds1; 58 void *fpga_brds1_adr; 59 void *fpga_status_adr; 60 unsigned long flash_base; 61 62 /* this should already be mapped (platform/4xx/walnut.c) */ 63 fpga_status_adr = ioremap(WALNUT_FPGA_BASE, 8); 64 if (!fpga_status_adr) 65 return -ENOMEM; 66 67 fpga_brds1_adr = fpga_status_adr+5; 68 fpga_brds1 = readb(fpga_brds1_adr); 69 /* iounmap(fpga_status_adr); */ 70 71 if (WALNUT_FLASH_ONBD_N(fpga_brds1)) { 72 printk("The on-board flash is disabled (U79 sw 5)!"); 73 return -EIO; 74 } 75 if (WALNUT_FLASH_SRAM_SEL(fpga_brds1)) 76 flash_base = WALNUT_FLASH_LOW; 77 else 78 flash_base = WALNUT_FLASH_HIGH; 79 80 walnut_map.phys = flash_base; 81 walnut_map.virt = 82 (void __iomem *)ioremap(flash_base, walnut_map.size); 83 84 if (!walnut_map.virt) { 85 printk("Failed to ioremap flash.\n"); 86 return -EIO; 87 } 88 89 simple_map_init(&walnut_map); 90 91 flash = do_map_probe("jedec_probe", &walnut_map); 92 if (flash) { 93 flash->owner = THIS_MODULE; 94 add_mtd_partitions(flash, walnut_partitions, 95 ARRAY_SIZE(walnut_partitions)); 96 } else { 97 printk("map probe failed for flash\n"); 98 return -ENXIO; 99 } 100 101 return 0; 102} 103 104static void __exit cleanup_walnut(void) 105{ 106 if (flash) { 107 del_mtd_partitions(flash); 108 map_destroy(flash); 109 } 110 111 if (walnut_map.virt) { 112 iounmap((void *)walnut_map.virt); 113 walnut_map.virt = 0; 114 } 115} 116 117module_init(init_walnut); 118module_exit(cleanup_walnut); 119 120MODULE_LICENSE("GPL"); 121MODULE_AUTHOR("Heikki Lindholm <holindho@infradead.org>"); 122MODULE_DESCRIPTION("MTD map and partitions for IBM 405GP Walnut boards");