Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright IBM Deutschland Entwicklung GmbH 2006 |
| 3 | * |
| 4 | * Author: Maxim Shchetynin <maxim@de.ibm.com> |
| 5 | * |
| 6 | * Axon DDR2 device driver. |
| 7 | * It registers one block device per Axon's DDR2 memory bank found on a system. |
| 8 | * Block devices are called axonram?, their major and minor numbers are |
| 9 | * available in /proc/devices, /proc/partitions or in /sys/block/axonram?/dev. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2, or (at your option) |
| 14 | * any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 | */ |
| 25 | |
| 26 | #include <linux/bio.h> |
| 27 | #include <linux/blkdev.h> |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 28 | #include <linux/device.h> |
| 29 | #include <linux/errno.h> |
| 30 | #include <linux/fs.h> |
| 31 | #include <linux/genhd.h> |
| 32 | #include <linux/interrupt.h> |
| 33 | #include <linux/io.h> |
| 34 | #include <linux/ioport.h> |
| 35 | #include <linux/irq.h> |
| 36 | #include <linux/irqreturn.h> |
| 37 | #include <linux/kernel.h> |
| 38 | #include <linux/mm.h> |
| 39 | #include <linux/mod_devicetable.h> |
| 40 | #include <linux/module.h> |
| 41 | #include <linux/slab.h> |
| 42 | #include <linux/string.h> |
| 43 | #include <linux/types.h> |
Jon Loeliger | eb8f276 | 2007-11-14 04:13:09 +1100 | [diff] [blame] | 44 | #include <linux/of_device.h> |
| 45 | #include <linux/of_platform.h> |
| 46 | |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 47 | #include <asm/page.h> |
| 48 | #include <asm/prom.h> |
| 49 | |
| 50 | #define AXON_RAM_MODULE_NAME "axonram" |
| 51 | #define AXON_RAM_DEVICE_NAME "axonram" |
| 52 | #define AXON_RAM_MINORS_PER_DISK 16 |
| 53 | #define AXON_RAM_BLOCK_SHIFT PAGE_SHIFT |
| 54 | #define AXON_RAM_BLOCK_SIZE 1 << AXON_RAM_BLOCK_SHIFT |
| 55 | #define AXON_RAM_SECTOR_SHIFT 9 |
| 56 | #define AXON_RAM_SECTOR_SIZE 1 << AXON_RAM_SECTOR_SHIFT |
| 57 | #define AXON_RAM_IRQ_FLAGS IRQF_SHARED | IRQF_TRIGGER_RISING |
| 58 | |
Maxim Shchetynin | 9a23409 | 2008-07-16 05:51:41 +1000 | [diff] [blame] | 59 | static int azfs_major, azfs_minor; |
| 60 | |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 61 | struct axon_ram_bank { |
Grant Likely | a454dc5 | 2010-07-22 15:52:34 -0600 | [diff] [blame] | 62 | struct platform_device *device; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 63 | struct gendisk *disk; |
Maxim Shchetynin | fedcd2c | 2007-08-23 03:01:27 +1000 | [diff] [blame] | 64 | unsigned int irq_id; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 65 | unsigned long ph_addr; |
| 66 | unsigned long io_addr; |
| 67 | unsigned long size; |
| 68 | unsigned long ecc_counter; |
| 69 | }; |
| 70 | |
| 71 | static ssize_t |
| 72 | axon_ram_sysfs_ecc(struct device *dev, struct device_attribute *attr, char *buf) |
| 73 | { |
Grant Likely | a454dc5 | 2010-07-22 15:52:34 -0600 | [diff] [blame] | 74 | struct platform_device *device = to_platform_device(dev); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 75 | struct axon_ram_bank *bank = device->dev.platform_data; |
| 76 | |
| 77 | BUG_ON(!bank); |
| 78 | |
| 79 | return sprintf(buf, "%ld\n", bank->ecc_counter); |
| 80 | } |
| 81 | |
| 82 | static DEVICE_ATTR(ecc, S_IRUGO, axon_ram_sysfs_ecc, NULL); |
| 83 | |
| 84 | /** |
| 85 | * axon_ram_irq_handler - interrupt handler for Axon RAM ECC |
| 86 | * @irq: interrupt ID |
| 87 | * @dev: pointer to of_device |
| 88 | */ |
| 89 | static irqreturn_t |
| 90 | axon_ram_irq_handler(int irq, void *dev) |
| 91 | { |
Grant Likely | a454dc5 | 2010-07-22 15:52:34 -0600 | [diff] [blame] | 92 | struct platform_device *device = dev; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 93 | struct axon_ram_bank *bank = device->dev.platform_data; |
| 94 | |
| 95 | BUG_ON(!bank); |
| 96 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 97 | dev_err(&device->dev, "Correctable memory error occurred\n"); |
Maxim Shchetynin | fedcd2c | 2007-08-23 03:01:27 +1000 | [diff] [blame] | 98 | bank->ecc_counter++; |
| 99 | return IRQ_HANDLED; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /** |
| 103 | * axon_ram_make_request - make_request() method for block device |
| 104 | * @queue, @bio: see blk_queue_make_request() |
| 105 | */ |
Christoph Hellwig | 5a7bbad | 2011-09-12 12:12:01 +0200 | [diff] [blame] | 106 | static void |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 107 | axon_ram_make_request(struct request_queue *queue, struct bio *bio) |
| 108 | { |
| 109 | struct axon_ram_bank *bank = bio->bi_bdev->bd_disk->private_data; |
| 110 | unsigned long phys_mem, phys_end; |
| 111 | void *user_mem; |
Kent Overstreet | 7988613 | 2013-11-23 17:19:00 -0800 | [diff] [blame] | 112 | struct bio_vec vec; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 113 | unsigned int transfered; |
Kent Overstreet | 7988613 | 2013-11-23 17:19:00 -0800 | [diff] [blame] | 114 | struct bvec_iter iter; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 115 | |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 116 | phys_mem = bank->io_addr + (bio->bi_iter.bi_sector << |
| 117 | AXON_RAM_SECTOR_SHIFT); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 118 | phys_end = bank->io_addr + bank->size; |
| 119 | transfered = 0; |
Kent Overstreet | 7988613 | 2013-11-23 17:19:00 -0800 | [diff] [blame] | 120 | bio_for_each_segment(vec, bio, iter) { |
| 121 | if (unlikely(phys_mem + vec.bv_len > phys_end)) { |
Al Viro | d81fec0 | 2007-10-12 07:00:19 +0100 | [diff] [blame] | 122 | bio_io_error(bio); |
Christoph Hellwig | 5a7bbad | 2011-09-12 12:12:01 +0200 | [diff] [blame] | 123 | return; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 124 | } |
| 125 | |
Kent Overstreet | 7988613 | 2013-11-23 17:19:00 -0800 | [diff] [blame] | 126 | user_mem = page_address(vec.bv_page) + vec.bv_offset; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 127 | if (bio_data_dir(bio) == READ) |
Kent Overstreet | 7988613 | 2013-11-23 17:19:00 -0800 | [diff] [blame] | 128 | memcpy(user_mem, (void *) phys_mem, vec.bv_len); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 129 | else |
Kent Overstreet | 7988613 | 2013-11-23 17:19:00 -0800 | [diff] [blame] | 130 | memcpy((void *) phys_mem, user_mem, vec.bv_len); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 131 | |
Kent Overstreet | 7988613 | 2013-11-23 17:19:00 -0800 | [diff] [blame] | 132 | phys_mem += vec.bv_len; |
| 133 | transfered += vec.bv_len; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 134 | } |
Al Viro | d81fec0 | 2007-10-12 07:00:19 +0100 | [diff] [blame] | 135 | bio_endio(bio, 0); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | /** |
| 139 | * axon_ram_direct_access - direct_access() method for block device |
| 140 | * @device, @sector, @data: see block_device_operations method |
| 141 | */ |
Matthew Wilcox | dd22f55 | 2015-01-07 18:05:34 +0200 | [diff] [blame] | 142 | static long |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 143 | axon_ram_direct_access(struct block_device *device, sector_t sector, |
Matthew Wilcox | dd22f55 | 2015-01-07 18:05:34 +0200 | [diff] [blame] | 144 | void **kaddr, unsigned long *pfn, long size) |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 145 | { |
| 146 | struct axon_ram_bank *bank = device->bd_disk->private_data; |
Matthew Wilcox | dd22f55 | 2015-01-07 18:05:34 +0200 | [diff] [blame] | 147 | loff_t offset = (loff_t)sector << AXON_RAM_SECTOR_SHIFT; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 148 | |
Jared Hulbert | 30afcb4 | 2008-04-28 02:13:02 -0700 | [diff] [blame] | 149 | *kaddr = (void *)(bank->ph_addr + offset); |
Matthew Wilcox | 91117a2 | 2015-01-07 18:04:18 +0200 | [diff] [blame] | 150 | *pfn = virt_to_phys(*kaddr) >> PAGE_SHIFT; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 151 | |
Matthew Wilcox | dd22f55 | 2015-01-07 18:05:34 +0200 | [diff] [blame] | 152 | return bank->size - offset; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 153 | } |
| 154 | |
Alexey Dobriyan | 83d5cde | 2009-09-21 17:01:13 -0700 | [diff] [blame] | 155 | static const struct block_device_operations axon_ram_devops = { |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 156 | .owner = THIS_MODULE, |
| 157 | .direct_access = axon_ram_direct_access |
| 158 | }; |
| 159 | |
| 160 | /** |
| 161 | * axon_ram_probe - probe() method for platform driver |
Grant Likely | 0000612 | 2011-02-22 19:59:54 -0700 | [diff] [blame] | 162 | * @device: see platform_driver method |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 163 | */ |
Grant Likely | 0000612 | 2011-02-22 19:59:54 -0700 | [diff] [blame] | 164 | static int axon_ram_probe(struct platform_device *device) |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 165 | { |
| 166 | static int axon_ram_bank_id = -1; |
| 167 | struct axon_ram_bank *bank; |
| 168 | struct resource resource; |
| 169 | int rc = 0; |
| 170 | |
| 171 | axon_ram_bank_id++; |
| 172 | |
| 173 | dev_info(&device->dev, "Found memory controller on %s\n", |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 174 | device->dev.of_node->full_name); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 175 | |
| 176 | bank = kzalloc(sizeof(struct axon_ram_bank), GFP_KERNEL); |
| 177 | if (bank == NULL) { |
| 178 | dev_err(&device->dev, "Out of memory\n"); |
| 179 | rc = -ENOMEM; |
| 180 | goto failed; |
| 181 | } |
| 182 | |
| 183 | device->dev.platform_data = bank; |
| 184 | |
| 185 | bank->device = device; |
| 186 | |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 187 | if (of_address_to_resource(device->dev.of_node, 0, &resource) != 0) { |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 188 | dev_err(&device->dev, "Cannot access device tree\n"); |
| 189 | rc = -EFAULT; |
| 190 | goto failed; |
| 191 | } |
| 192 | |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 193 | bank->size = resource_size(&resource); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 194 | |
| 195 | if (bank->size == 0) { |
| 196 | dev_err(&device->dev, "No DDR2 memory found for %s%d\n", |
| 197 | AXON_RAM_DEVICE_NAME, axon_ram_bank_id); |
| 198 | rc = -ENODEV; |
| 199 | goto failed; |
| 200 | } |
| 201 | |
| 202 | dev_info(&device->dev, "Register DDR2 memory device %s%d with %luMB\n", |
| 203 | AXON_RAM_DEVICE_NAME, axon_ram_bank_id, bank->size >> 20); |
| 204 | |
| 205 | bank->ph_addr = resource.start; |
Anton Blanchard | 40f1ce7 | 2011-05-08 21:43:47 +0000 | [diff] [blame] | 206 | bank->io_addr = (unsigned long) ioremap_prot( |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 207 | bank->ph_addr, bank->size, _PAGE_NO_CACHE); |
| 208 | if (bank->io_addr == 0) { |
| 209 | dev_err(&device->dev, "ioremap() failed\n"); |
| 210 | rc = -EFAULT; |
| 211 | goto failed; |
| 212 | } |
| 213 | |
| 214 | bank->disk = alloc_disk(AXON_RAM_MINORS_PER_DISK); |
| 215 | if (bank->disk == NULL) { |
| 216 | dev_err(&device->dev, "Cannot register disk\n"); |
| 217 | rc = -EFAULT; |
| 218 | goto failed; |
| 219 | } |
| 220 | |
Maxim Shchetynin | 9a23409 | 2008-07-16 05:51:41 +1000 | [diff] [blame] | 221 | bank->disk->major = azfs_major; |
| 222 | bank->disk->first_minor = azfs_minor; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 223 | bank->disk->fops = &axon_ram_devops; |
| 224 | bank->disk->private_data = bank; |
| 225 | bank->disk->driverfs_dev = &device->dev; |
| 226 | |
| 227 | sprintf(bank->disk->disk_name, "%s%d", |
| 228 | AXON_RAM_DEVICE_NAME, axon_ram_bank_id); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 229 | |
| 230 | bank->disk->queue = blk_alloc_queue(GFP_KERNEL); |
| 231 | if (bank->disk->queue == NULL) { |
| 232 | dev_err(&device->dev, "Cannot register disk queue\n"); |
| 233 | rc = -EFAULT; |
| 234 | goto failed; |
| 235 | } |
| 236 | |
| 237 | set_capacity(bank->disk, bank->size >> AXON_RAM_SECTOR_SHIFT); |
| 238 | blk_queue_make_request(bank->disk->queue, axon_ram_make_request); |
Martin K. Petersen | e1defc4 | 2009-05-22 17:17:49 -0400 | [diff] [blame] | 239 | blk_queue_logical_block_size(bank->disk->queue, AXON_RAM_SECTOR_SIZE); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 240 | add_disk(bank->disk); |
| 241 | |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 242 | bank->irq_id = irq_of_parse_and_map(device->dev.of_node, 0); |
Maxim Shchetynin | fedcd2c | 2007-08-23 03:01:27 +1000 | [diff] [blame] | 243 | if (bank->irq_id == NO_IRQ) { |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 244 | dev_err(&device->dev, "Cannot access ECC interrupt ID\n"); |
| 245 | rc = -EFAULT; |
| 246 | goto failed; |
| 247 | } |
| 248 | |
Maxim Shchetynin | fedcd2c | 2007-08-23 03:01:27 +1000 | [diff] [blame] | 249 | rc = request_irq(bank->irq_id, axon_ram_irq_handler, |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 250 | AXON_RAM_IRQ_FLAGS, bank->disk->disk_name, device); |
| 251 | if (rc != 0) { |
| 252 | dev_err(&device->dev, "Cannot register ECC interrupt handler\n"); |
Maxim Shchetynin | fedcd2c | 2007-08-23 03:01:27 +1000 | [diff] [blame] | 253 | bank->irq_id = NO_IRQ; |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 254 | rc = -EFAULT; |
| 255 | goto failed; |
| 256 | } |
| 257 | |
| 258 | rc = device_create_file(&device->dev, &dev_attr_ecc); |
| 259 | if (rc != 0) { |
| 260 | dev_err(&device->dev, "Cannot create sysfs file\n"); |
| 261 | rc = -EFAULT; |
| 262 | goto failed; |
| 263 | } |
| 264 | |
Maxim Shchetynin | 9a23409 | 2008-07-16 05:51:41 +1000 | [diff] [blame] | 265 | azfs_minor += bank->disk->minors; |
| 266 | |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 267 | return 0; |
| 268 | |
| 269 | failed: |
| 270 | if (bank != NULL) { |
Maxim Shchetynin | fedcd2c | 2007-08-23 03:01:27 +1000 | [diff] [blame] | 271 | if (bank->irq_id != NO_IRQ) |
| 272 | free_irq(bank->irq_id, device); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 273 | if (bank->disk != NULL) { |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 274 | if (bank->disk->major > 0) |
| 275 | unregister_blkdev(bank->disk->major, |
| 276 | bank->disk->disk_name); |
| 277 | del_gendisk(bank->disk); |
| 278 | } |
| 279 | device->dev.platform_data = NULL; |
| 280 | if (bank->io_addr != 0) |
| 281 | iounmap((void __iomem *) bank->io_addr); |
| 282 | kfree(bank); |
| 283 | } |
| 284 | |
| 285 | return rc; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * axon_ram_remove - remove() method for platform driver |
| 290 | * @device: see of_platform_driver method |
| 291 | */ |
| 292 | static int |
Grant Likely | a454dc5 | 2010-07-22 15:52:34 -0600 | [diff] [blame] | 293 | axon_ram_remove(struct platform_device *device) |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 294 | { |
| 295 | struct axon_ram_bank *bank = device->dev.platform_data; |
| 296 | |
| 297 | BUG_ON(!bank || !bank->disk); |
| 298 | |
| 299 | device_remove_file(&device->dev, &dev_attr_ecc); |
Maxim Shchetynin | fedcd2c | 2007-08-23 03:01:27 +1000 | [diff] [blame] | 300 | free_irq(bank->irq_id, device); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 301 | del_gendisk(bank->disk); |
| 302 | iounmap((void __iomem *) bank->io_addr); |
| 303 | kfree(bank); |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
Uwe Kleine-König | ce6d73c | 2014-09-10 21:56:38 +0200 | [diff] [blame] | 308 | static const struct of_device_id axon_ram_device_id[] = { |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 309 | { |
| 310 | .type = "dma-memory" |
| 311 | }, |
| 312 | {} |
| 313 | }; |
| 314 | |
Grant Likely | 0000612 | 2011-02-22 19:59:54 -0700 | [diff] [blame] | 315 | static struct platform_driver axon_ram_driver = { |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 316 | .probe = axon_ram_probe, |
Stephen Rothwell | 84dd467 | 2007-10-11 15:19:03 +1000 | [diff] [blame] | 317 | .remove = axon_ram_remove, |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 318 | .driver = { |
| 319 | .name = AXON_RAM_MODULE_NAME, |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 320 | .of_match_table = axon_ram_device_id, |
Stephen Rothwell | 84dd467 | 2007-10-11 15:19:03 +1000 | [diff] [blame] | 321 | }, |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 322 | }; |
| 323 | |
| 324 | /** |
| 325 | * axon_ram_init |
| 326 | */ |
| 327 | static int __init |
| 328 | axon_ram_init(void) |
| 329 | { |
Maxim Shchetynin | 9a23409 | 2008-07-16 05:51:41 +1000 | [diff] [blame] | 330 | azfs_major = register_blkdev(azfs_major, AXON_RAM_DEVICE_NAME); |
| 331 | if (azfs_major < 0) { |
| 332 | printk(KERN_ERR "%s cannot become block device major number\n", |
| 333 | AXON_RAM_MODULE_NAME); |
| 334 | return -EFAULT; |
| 335 | } |
| 336 | azfs_minor = 0; |
| 337 | |
Grant Likely | 0000612 | 2011-02-22 19:59:54 -0700 | [diff] [blame] | 338 | return platform_driver_register(&axon_ram_driver); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | /** |
| 342 | * axon_ram_exit |
| 343 | */ |
| 344 | static void __exit |
| 345 | axon_ram_exit(void) |
| 346 | { |
Grant Likely | 0000612 | 2011-02-22 19:59:54 -0700 | [diff] [blame] | 347 | platform_driver_unregister(&axon_ram_driver); |
Maxim Shchetynin | 9a23409 | 2008-07-16 05:51:41 +1000 | [diff] [blame] | 348 | unregister_blkdev(azfs_major, AXON_RAM_DEVICE_NAME); |
Maxim Shchetynin | dbdf04c | 2007-07-20 21:39:26 +0200 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | module_init(axon_ram_init); |
| 352 | module_exit(axon_ram_exit); |
| 353 | |
| 354 | MODULE_LICENSE("GPL"); |
| 355 | MODULE_AUTHOR("Maxim Shchetynin <maxim@de.ibm.com>"); |
| 356 | MODULE_DESCRIPTION("Axon DDR2 RAM device driver for IBM Cell BE"); |