Devicetree
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: devicetree-discuss@ozlabs.org, albrecht.dress@arcor.de,
	linuxppc-dev@ozlabs.org, linux-mtd@lists.infradead.org,
	Ben Dooks <ben-linux@fluff.org>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH V2 2/2] mtd/maps/mtd-ram: add an of-platform driver
Date: Fri, 5 Jun 2009 09:53:51 -0600	[thread overview]
Message-ID: <fa686aa40906050853n76f12c4habd1f4e82566fa9@mail.gmail.com> (raw)
In-Reply-To: <1244203514-12516-3-git-send-email-w.sang@pengutronix.de>

On Fri, Jun 5, 2009 at 6:05 AM, Wolfram Sang <w.sang@pengutronix.de> wrote:
> Create an of-aware driver using the now exported generic functions from
> plat-ram.c. Also add the documentation for the binding. Partitions are
> not yet supported. Tested on a phyCORE-MPC5200B-IO.
>
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Albrecht Dreß <albrecht.dress@arcor.de>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Ben Dooks <ben-linux@fluff.org>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: linuxppc-dev@ozlabs.org
> Cc: devicetree-discuss@ozlabs.org
> Cc: linux-mtd@lists.infradead.org

On brief review, looks good to me (for both patches).
Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
> Changes in V2:
>
> - added binding documentation
> - added __devinit & friends
> - put struct resource on stack during probe
> - simplified getting the name of the of-device
> - made error path more readable & add check for valid bank-width-pointer
> - rename driver to "of-mtd-ram"
>
>  Documentation/powerpc/dts-bindings/mtd-ram.txt |   18 ++++
>  drivers/mtd/maps/Kconfig                       |    7 ++
>  drivers/mtd/maps/Makefile                      |    1 +
>  drivers/mtd/maps/of-ram.c                      |  102 ++++++++++++++++++++++++
>  4 files changed, 128 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/powerpc/dts-bindings/mtd-ram.txt
>  create mode 100644 drivers/mtd/maps/of-ram.c
>
> diff --git a/Documentation/powerpc/dts-bindings/mtd-ram.txt b/Documentation/powerpc/dts-bindings/mtd-ram.txt
> new file mode 100644
> index 0000000..a2e9932
> --- /dev/null
> +++ b/Documentation/powerpc/dts-bindings/mtd-ram.txt
> @@ -0,0 +1,18 @@
> +RAM emulating an MTD
> +
> +An external RAM like SRAM or FRAM can also be treated as an MTD.
> +
> + - compatible : should contain the specific model of the RAM chip
> +   used, if known, followed by "mtd-ram".
> + - reg : Address range of the RAM chip
> + - bank-width : Width (in bytes) of the RAM bank.
> +
> +Partitions are not yet supported.
> +
> +Example:
> +
> +       sram@2,0 {
> +               compatible = "samsung,k6f1616u6a", "mtd-ram";
> +               reg = <2 0 0x00200000>;
> +               bank-width = <2>;
> +       };
> diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
> index 82923bd..bdd9ebc 100644
> --- a/drivers/mtd/maps/Kconfig
> +++ b/drivers/mtd/maps/Kconfig
> @@ -551,6 +551,13 @@ config MTD_PLATRAM
>
>          This selection automatically selects the map_ram driver.
>
> +config MTD_OFRAM
> +       tristate "Map driver for of-device RAM (of-mtd-ram)"
> +       depends on MTD_PLATRAM && OF
> +       help
> +         Map driver for RAM areas described via the of-device
> +         system.
> +
>  config MTD_VMU
>        tristate "Map driver for Dreamcast VMU"
>        depends on MAPLE
> diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
> index 2dbc1be..a7a2db3 100644
> --- a/drivers/mtd/maps/Makefile
> +++ b/drivers/mtd/maps/Makefile
> @@ -57,6 +57,7 @@ obj-$(CONFIG_MTD_IXP2000)     += ixp2000.o
>  obj-$(CONFIG_MTD_WRSBC8260)    += wr_sbc82xx_flash.o
>  obj-$(CONFIG_MTD_DMV182)       += dmv182.o
>  obj-$(CONFIG_MTD_PLATRAM)      += plat-ram.o
> +obj-$(CONFIG_MTD_OFRAM)                += of-ram.o
>  obj-$(CONFIG_MTD_OMAP_NOR)     += omap_nor.o
>  obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o
>  obj-$(CONFIG_MTD_BFIN_ASYNC)   += bfin-async-flash.o
> diff --git a/drivers/mtd/maps/of-ram.c b/drivers/mtd/maps/of-ram.c
> new file mode 100644
> index 0000000..e2f4476
> --- /dev/null
> +++ b/drivers/mtd/maps/of-ram.c
> @@ -0,0 +1,102 @@
> +/*
> + * Generic of device based RAM map
> + *
> + * Copyright (C) 2009 Wolfram Sang, Pengutronix
> + *
> + * Using plat-ram.c by Ben Dooks
> + *
> + * 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/init.h>
> +#include <linux/kernel.h>
> +#include <linux/device.h>
> +#include <linux/platform_device.h>
> +#include <linux/of_device.h>
> +#include <linux/of_platform.h>
> +#include <linux/mtd/plat-ram.h>
> +
> +static __devinit int of_ram_probe(struct of_device *op,
> +                       const struct of_device_id *match)
> +{
> +       struct platdata_mtd_ram *pdata;
> +       struct resource res;
> +       const u32 *bankwidth;
> +       int ret = -ENOENT;
> +
> +       pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
> +       if (!pdata)
> +               return -ENOMEM;
> +       op->dev.platform_data = pdata;
> +
> +       ret = of_address_to_resource(op->node, 0, &res);
> +       if (ret) {
> +               dev_dbg(&op->dev, "could not create resource (%d)\n", ret);
> +               goto out_free;
> +       }
> +
> +       bankwidth = of_get_property(op->node, "bank-width", NULL);
> +       if (!bankwidth || *bankwidth == 0) {
> +               dev_dbg(&op->dev, "bank width not set\n");
> +               goto out_free;
> +       }
> +       pdata->bankwidth = *bankwidth;
> +
> +       ret = __platram_probe(&op->dev, op->node->name, &res, pdata);
> +       if (ret) {
> +               dev_dbg(&op->dev, "error probing device (%d)\n", ret);
> +               goto out_free;
> +       }
> +
> +       return 0;
> +
> +out_free:
> +       op->dev.platform_data = NULL;
> +       kfree(pdata);
> +       return ret;
> +}
> +
> +static __devexit int of_ram_remove(struct of_device *op)
> +{
> +       int ret;
> +       struct platdata_mtd_ram *pdata = op->dev.platform_data;
> +
> +       ret = __platram_remove(&op->dev);
> +       op->dev.platform_data = NULL;
> +       kfree(pdata);
> +       return ret;
> +}
> +
> +static const struct of_device_id __devinitconst of_ram_match[] = {
> +       { .compatible = "mtd-ram", },
> +       {},
> +};
> +MODULE_DEVICE_TABLE(of, of_ram_match);
> +
> +static struct of_platform_driver of_ram_driver = {
> +       .owner = THIS_MODULE,
> +       .name = "of-mtd-ram",
> +       .match_table = of_ram_match,
> +       .probe = of_ram_probe,
> +       .remove = __devexit_p(of_ram_remove),
> +};
> +
> +static int __init of_ram_init(void)
> +{
> +       return of_register_platform_driver(&of_ram_driver);
> +}
> +module_init(of_ram_init);
> +
> +static void __exit of_ram_exit(void)
> +{
> +       of_unregister_platform_driver(&of_ram_driver);
> +}
> +module_exit(of_ram_exit);
> +
> +MODULE_AUTHOR("Wolfram Sang");
> +MODULE_DESCRIPTION("OF-MTD-RAM map driver");
> +MODULE_LICENSE("GPL v2");
> --
> 1.6.2
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2009-06-05 15:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-05 12:05 [PATCH V2 0/2] mtd/maps/mtd-ram: Make driver usable for the device tree Wolfram Sang
     [not found] ` <1244203514-12516-1-git-send-email-w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-06-05 12:05   ` [PATCH V2 1/2] mtd/maps/mtd-ram: refactor probe and remove Wolfram Sang
2009-06-05 12:05   ` [PATCH V2 2/2] mtd/maps/mtd-ram: add an of-platform driver Wolfram Sang
2009-06-05 15:53     ` Grant Likely [this message]
2009-06-05 16:22     ` Albrecht Dreß
     [not found]     ` <1244203514-12516-3-git-send-email-w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-06-06  8:14       ` David Woodhouse
     [not found]         ` <1244276049.3751.1176.camel-uXGAPMMVk8bAQYKIod7YupZV94DADvEd@public.gmane.org>
2009-06-06 11:19           ` Wolfram Sang
2009-06-16  9:09           ` Wolfram Sang
2009-06-06 16:05       ` Grant Likely
     [not found]         ` <fa686aa40906060905y1d39dce1j87d993ceb94273be-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-06-06 16:16           ` Albrecht Dreß
2009-06-08 16:35           ` Wolfram Sang
     [not found]             ` <20090608163540.GA16384-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-06-08 17:30               ` Albrecht Dreß
2009-06-15 17:43       ` Albrecht Dreß
2009-06-16  9:18         ` Wolfram Sang
     [not found]           ` <20090616091801.GC21321-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-06-16 12:53             ` Grant Likely
     [not found]               ` <fa686aa40906160553m2f0e7cc4n644c3893573845f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-06-16 13:20                 ` Wolfram Sang
     [not found]                   ` <fa686aa40906160833g1d77466ekf8b8d4350ab32a24@mail.gmail.com>
     [not found]                     ` <fa686aa40906160833g1d77466ekf8b8d4350ab32a24-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-06-16 15:34                       ` Grant Likely
2009-06-16 17:19                 ` Albrecht Dreß

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=fa686aa40906050853n76f12c4habd1f4e82566fa9@mail.gmail.com \
    --to=grant.likely@secretlab.ca \
    --cc=albrecht.dress@arcor.de \
    --cc=ben-linux@fluff.org \
    --cc=devicetree-discuss@ozlabs.org \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=w.sang@pengutronix.de \
    /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