Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*
  2  * $Id: iq80310.c,v 1.20 2004/11/04 13:24:15 gleixner Exp $
  3  *
  4  * Mapping for the Intel XScale IQ80310 evaluation board
  5  *
  6  * Author:      Nicolas Pitre
  7  * Copyright:   (C) 2001 MontaVista Software Inc.
  8  * 
  9  * This program is free software; you can redistribute it and/or modify
 10  * it under the terms of the GNU General Public License version 2 as
 11  * published by the Free Software Foundation.
 12  */
 13 
 14 #include <linux/module.h>
 15 #include <linux/types.h>
 16 #include <linux/kernel.h>
 17 #include <linux/init.h>
 18 #include <linux/slab.h>
 19 #include <asm/io.h>
 20 #include <linux/mtd/mtd.h>
 21 #include <linux/mtd/map.h>
 22 #include <linux/mtd/partitions.h>
 23 
 24 
 25 #define WINDOW_ADDR     0
 26 #define WINDOW_SIZE     8*1024*1024
 27 #define BUSWIDTH        1
 28 
 29 static struct mtd_info *mymtd;
 30 
 31 static struct map_info iq80310_map = {
 32         .name = "IQ80310 flash",
 33         .size = WINDOW_SIZE,
 34         .bankwidth = BUSWIDTH,
 35         .phys = WINDOW_ADDR
 36 };
 37 
 38 static struct mtd_partition iq80310_partitions[4] = {
 39         {
 40                 .name =         "Firmware",
 41                 .size =         0x00080000,
 42                 .offset =       0,
 43                 .mask_flags =   MTD_WRITEABLE  /* force read-only */
 44         },{
 45                 .name =         "Kernel",
 46                 .size =         0x000a0000,
 47                 .offset =       0x00080000,
 48         },{
 49                 .name =         "Filesystem",
 50                 .size =         0x00600000,
 51                 .offset =       0x00120000
 52         },{
 53                 .name =         "RedBoot",
 54                 .size =         0x000e0000,
 55                 .offset =       0x00720000,
 56                 .mask_flags =   MTD_WRITEABLE
 57         }
 58 };
 59 
 60 static struct mtd_info *mymtd;
 61 static struct mtd_partition *parsed_parts;
 62 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
 63 
 64 static int __init init_iq80310(void)
 65 {
 66         struct mtd_partition *parts;
 67         int nb_parts = 0;
 68         int parsed_nr_parts = 0;
 69         int ret;
 70 
 71         iq80310_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
 72         if (!iq80310_map.virt) {
 73                 printk("Failed to ioremap\n");
 74                 return -EIO;
 75         }
 76         simple_map_init(&iq80310_map);
 77 
 78         mymtd = do_map_probe("cfi_probe", &iq80310_map);
 79         if (!mymtd) {
 80                 iounmap((void *)iq80310_map.virt);
 81                 return -ENXIO;
 82         }
 83         mymtd->owner = THIS_MODULE;
 84 
 85         ret = parse_mtd_partitions(mymtd, probes, &parsed_parts, 0);
 86 
 87         if (ret > 0)
 88                 parsed_nr_parts = ret;
 89 
 90         if (parsed_nr_parts > 0) {
 91                 parts = parsed_parts;
 92                 nb_parts = parsed_nr_parts;
 93         } else {
 94                 parts = iq80310_partitions;
 95                 nb_parts = ARRAY_SIZE(iq80310_partitions);
 96         }
 97         add_mtd_partitions(mymtd, parts, nb_parts);
 98         return 0;
 99 }
100 
101 static void __exit cleanup_iq80310(void)
102 {
103         if (mymtd) {
104                 del_mtd_partitions(mymtd);
105                 map_destroy(mymtd);
106                 if (parsed_parts)
107                         kfree(parsed_parts);
108         }
109         if (iq80310_map.virt)
110                 iounmap((void *)iq80310_map.virt);
111 }
112 
113 module_init(init_iq80310);
114 module_exit(cleanup_iq80310);
115 
116 
117 MODULE_LICENSE("GPL");
118 MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
119 MODULE_DESCRIPTION("MTD map driver for Intel XScale IQ80310 evaluation board");
120 
  This page was automatically generated by the LXR engine.