public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Anton Todorov <a.todorov@emness.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
Subject: Re: MTD on MBX860
Date: Thu, 8 Nov 2001 19:12:35 +0200	[thread overview]
Message-ID: <01110819123504.05519@RONIN> (raw)
In-Reply-To: <8307.1005222433@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 856 bytes --]

On Thursday 08 November 2001 14:27, you wrote:
> a.todorov@emness.com said:
> >  I am using linuxppc_2_4 (2.4.6) with current mtd support from cvs
> > tree. The board is with JEDEC AMD 29F016 x4 flash chips (8M Flash
> > space). Map file which I use for this board is attached (I use
> > rpxlite.c and  tqm8xxl.c (for partitioning) as reference). The problem
> > I found is that mtd says:
>
> Thanks. May I add that map driver to CVS?

Yes it is under GPL !

I am attaching another one with more descriptive header :) 

>
> You should hopefully now find that the new jedec_probe stuff will work for
> your chips, and you don't have to use the old jedec code.

I hope it works but for the moment my work on ppc based boards is 
suspended, but I hope soon to came back to it.

> --
> dwmw2

Best Regards,
Anton Todorov
Emness Technology
http://www.emness.com

[-- Attachment #2: mbx860.c --]
[-- Type: text/x-c, Size: 3510 bytes --]

/*
 * $Id: mbx860.c,v 1.1 2001/08/11 10:43:37 anton Exp $
 *
 * Handle mapping of the flash on MBX860 boards
 *
 * Author:	Anton Todorov
 * Copyright:	(C) 2001 Emness Technology
 * 
 * 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.
 *
 */

#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <asm/io.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>


#define WINDOW_ADDR 0xfe000000
#define WINDOW_SIZE 0x00200000

/* Flash / Partition sizing */
#define MAX_SIZE_KiB              8192
#define BOOT_PARTITION_SIZE_KiB    512
#define KERNEL_PARTITION_SIZE_KiB 5632
#define APP_PARTITION_SIZE_KiB    2048

#define NUM_PARTITIONS 3

/* partition_info gives details on the logical partitions that the split the
 * single flash device into. If the size if zero we use up to the end of the
 * device. */
static struct mtd_partition partition_info[]={
	{ name: "MBX flash BOOT partition",
	offset: 0,
	size:   BOOT_PARTITION_SIZE_KiB*1024 },
	{ name: "MBX flash DATA partition",
	offset: BOOT_PARTITION_SIZE_KiB*1024,
	size: (KERNEL_PARTITION_SIZE_KiB)*1024 },
	{ name: "MBX flash APPLICATION partition",
	offset: (BOOT_PARTITION_SIZE_KiB+KERNEL_PARTITION_SIZE_KiB)*1024 }
};
				   

static struct mtd_info *mymtd;

__u8 mbx_read8(struct map_info *map, unsigned long ofs)
{
	return readb(map->map_priv_1 + ofs);
}

__u16 mbx_read16(struct map_info *map, unsigned long ofs)
{
	return readw(map->map_priv_1 + ofs);
}

__u32 mbx_read32(struct map_info *map, unsigned long ofs)
{
	return readl(map->map_priv_1 + ofs);
}

void mbx_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
	memcpy_fromio(to, (void *)(map->map_priv_1 + from), len);
}

void mbx_write8(struct map_info *map, __u8 d, unsigned long adr)
{
	writeb(d, map->map_priv_1 + adr);
}

void mbx_write16(struct map_info *map, __u16 d, unsigned long adr)
{
	writew(d, map->map_priv_1 + adr);
}

void mbx_write32(struct map_info *map, __u32 d, unsigned long adr)
{
	writel(d, map->map_priv_1 + adr);
}

void mbx_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{
	memcpy_toio((void *)(map->map_priv_1 + to), from, len);
}

struct map_info mbx_map = {
	name: "MBX flash",
	size: WINDOW_SIZE,
	buswidth: 4,
	read8: mbx_read8,
	read16: mbx_read16,
	read32: mbx_read32,
	copy_from: mbx_copy_from,
	write8: mbx_write8,
	write16: mbx_write16,
	write32: mbx_write32,
	copy_to: mbx_copy_to
};

#if LINUX_VERSION_CODE < 0x20212 && defined(MODULE)
#define init_mbx init_module
#define cleanup_mbx cleanup_module
#endif

int __init init_mbx(void)
{
	printk(KERN_NOTICE "Motorola MBX flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR);
	mbx_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);

	if (!mbx_map.map_priv_1) {
		printk("Failed to ioremap\n");
		return -EIO;
	}
	mymtd = do_map_probe("jedec", &mbx_map);
	if (mymtd) {
		mymtd->module = THIS_MODULE;
		add_mtd_device(mymtd);
                add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
		return 0;
	}

	iounmap((void *)mbx_map.map_priv_1);
	return -ENXIO;
}

static void __exit cleanup_mbx(void)
{
	if (mymtd) {
		del_mtd_device(mymtd);
		map_destroy(mymtd);
	}
	if (mbx_map.map_priv_1) {
		iounmap((void *)mbx_map.map_priv_1);
		mbx_map.map_priv_1 = 0;
	}
}

module_init(init_mbx);
module_exit(cleanup_mbx);

      reply	other threads:[~2001-11-08 17:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-10 17:22 MTD on MBX860 Anton Todorov
2001-07-10 12:49 ` Steve Kranz
2001-07-10 18:13   ` Anton Todorov
2001-07-10 13:25 ` Help: MTD & SmartMedia Steve Kranz
2001-07-11 10:10   ` David Woodhouse
2001-11-08 12:27 ` MTD on MBX860 David Woodhouse
2001-11-08 17:12   ` Anton Todorov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01110819123504.05519@RONIN \
    --to=a.todorov@emness.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox