linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Manjunathappa, Prakash" <prakash.pm@ti.com>
To: <linux-arm-kernel@lists.infradead.org>,
	<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Cc: Sekhar Nori <nsekhar@ti.com>,
	<davinci-linux-open-source@linux.davincidsp.com>,
	Russell King <linux@arm.linux.org.uk>,
	David Woodhouse <dwmw2@infradead.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	"Manjunathappa, Prakash" <prakash.pm@ti.com>
Subject: [PATCH v3 2/3] arm:davinci: Move emif driver to drivers/mfd from mach-davinci folder
Date: Tue, 7 Feb 2012 20:41:52 +0530	[thread overview]
Message-ID: <1328627513-30134-3-git-send-email-prakash.pm@ti.com> (raw)
In-Reply-To: <1328627513-30134-1-git-send-email-prakash.pm@ti.com>

Move aemif kernel module from arch/arm/mach-davinci/ to multi functional
devices frame work. "davinci_aemif" MFD driver adds "davinci_nand" and
"physmap-flash" slave devices.

Signed-off-by: Manjunathappa, Prakash <prakash.pm@ti.com>
---
Since v2:
Modified emif MFD driver to load multiple instance of NAND/NOR devices.
Since v1:
Patch generated using -M option.

 arch/arm/Kconfig                                   |    1 +
 arch/arm/mach-davinci/Makefile                     |    2 +-
 drivers/mfd/Makefile                               |    1 +
 .../aemif.c => drivers/mfd/davinci_aemif.c         |   75 +++++++++++++++++++-
 include/linux/mfd/davinci_aemif.h                  |   14 ++++
 5 files changed, 91 insertions(+), 2 deletions(-)
 rename arch/arm/mach-davinci/aemif.c => drivers/mfd/davinci_aemif.c (66%)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a48aecc..09dcb94 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -934,6 +934,7 @@ config ARCH_DAVINCI
 	select GENERIC_ALLOCATOR
 	select GENERIC_IRQ_CHIP
 	select ARCH_HAS_HOLES_MEMORYMODEL
+	select MFD_CORE
 	help
 	  Support for TI's DaVinci platform.
 
diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
index 2db78bd..8bab47c 100644
--- a/arch/arm/mach-davinci/Makefile
+++ b/arch/arm/mach-davinci/Makefile
@@ -5,7 +5,7 @@
 
 # Common objects
 obj-y 			:= time.o clock.o serial.o psc.o \
-			   dma.o usb.o common.o sram.o aemif.o
+			   dma.o usb.o common.o sram.o
 
 obj-$(CONFIG_DAVINCI_MUX)		+= mux.o
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b953bab..54fc267 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_HTC_EGPIO)		+= htc-egpio.o
 obj-$(CONFIG_HTC_PASIC3)	+= htc-pasic3.o
 obj-$(CONFIG_HTC_I2CPLD)	+= htc-i2cpld.o
 
+obj-${CONFIG_ARCH_DAVINCI}	+= davinci_aemif.o
 obj-$(CONFIG_MFD_DAVINCI_VOICECODEC)	+= davinci_voicecodec.o
 obj-$(CONFIG_MFD_DM355EVM_MSP)	+= dm355evm_msp.o
 obj-$(CONFIG_MFD_TI_SSP)	+= ti-ssp.o
diff --git a/arch/arm/mach-davinci/aemif.c b/drivers/mfd/davinci_aemif.c
similarity index 66%
rename from arch/arm/mach-davinci/aemif.c
rename to drivers/mfd/davinci_aemif.c
index b67c115..5fb490d 100644
--- a/arch/arm/mach-davinci/aemif.c
+++ b/drivers/mfd/davinci_aemif.c
@@ -14,8 +14,13 @@
 #include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/time.h>
-
 #include <linux/mfd/davinci_aemif.h>
+#include <linux/mtd/physmap.h>
+#include <linux/slab.h>
+#include <mach/nand.h>
+
+static char *name[] = {"davinci_nand", "physmap-flash",};
+#define MAX ARRAY_SIZE(name)
 
 /* Timing value configuration */
 
@@ -131,3 +136,71 @@ int davinci_aemif_setup_timing(struct davinci_aemif_timing *t,
 	return 0;
 }
 EXPORT_SYMBOL(davinci_aemif_setup_timing);
+
+static int __init davinci_aemif_probe(struct platform_device *pdev)
+{
+	struct davinci_aemif_devices *davinci_aemif_devices =
+		pdev->dev.platform_data;
+	struct platform_device *devices;
+	struct mfd_cell *cells;
+	int ret, i, j, count;
+
+	devices = davinci_aemif_devices->devices;
+
+	cells = kzalloc(sizeof(struct mfd_cell) *
+			davinci_aemif_devices->num_devices, GFP_KERNEL);
+
+	for (j = 0, count = 0; j < MAX; j++) {
+		for (i = 0; i < davinci_aemif_devices->num_devices; i++) {
+			if (strcmp(devices[i].name, name[j]))
+				continue;
+			cells[count].name = name[j];
+			cells[count].platform_data =
+				devices[i].dev.platform_data;
+			cells[count].pdata_size =
+				sizeof(struct davinci_nand_pdata);
+			cells[count].id = devices[i].id;
+			cells[count].resources = devices[i].resource;
+			cells[count].num_resources = devices[i].num_resources;
+			count++;
+		}
+	}
+
+	ret = mfd_add_devices(&pdev->dev, 0, cells,
+			      count, NULL, 0);
+	if (ret != 0)
+		dev_err(&pdev->dev, "fail to register client devices\n");
+
+	return 0;
+}
+
+static int __devexit davinci_aemif_remove(struct platform_device *pdev)
+{
+	mfd_remove_devices(&pdev->dev);
+	return 0;
+}
+
+static struct platform_driver davinci_aemif_driver = {
+	.driver	= {
+		.name = "davinci_aemif",
+		.owner = THIS_MODULE,
+	},
+	.remove	= __devexit_p(davinci_aemif_remove),
+};
+
+static int __init davinci_aemif_init(void)
+{
+	return platform_driver_probe(&davinci_aemif_driver,
+			davinci_aemif_probe);
+}
+module_init(davinci_aemif_init);
+
+static void __exit davinci_aemif_exit(void)
+{
+	platform_driver_unregister(&davinci_aemif_driver);
+}
+module_exit(davinci_aemif_exit);
+
+MODULE_AUTHOR("Prakash Manjunathappa");
+MODULE_DESCRIPTION("Texas Instruments AEMIF Interface");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/davinci_aemif.h b/include/linux/mfd/davinci_aemif.h
index 05b2934..18650c3 100644
--- a/include/linux/mfd/davinci_aemif.h
+++ b/include/linux/mfd/davinci_aemif.h
@@ -10,6 +10,10 @@
 #ifndef _MACH_DAVINCI_AEMIF_H
 #define _MACH_DAVINCI_AEMIF_H
 
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/mfd/core.h>
+
 #define NRCSR_OFFSET		0x00
 #define AWCCR_OFFSET		0x04
 #define A1CR_OFFSET		0x10
@@ -18,6 +22,16 @@
 #define ACR_EW_MASK		BIT(30)
 #define ACR_SS_MASK		BIT(31)
 
+enum davinci_emif_cells {
+	DAVINCI_NAND_DEVICE_CELL,
+	DAVINCI_NOR_FLASH_CELL,
+};
+
+struct davinci_aemif_devices {
+	struct platform_device *devices;
+	unsigned int num_devices;
+};
+
 /* All timings in nanoseconds */
 struct davinci_aemif_timing {
 	u8	wsetup;
-- 
1.7.1


  parent reply	other threads:[~2012-02-07 15:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-07 15:11 [PATCH v3 0/3] Moving EMIF driver to MFD framework Manjunathappa, Prakash
2012-02-07 15:11 ` [PATCH v3 1/3] arm:davinci: prepare to move aemif driver to drivers/mfd Manjunathappa, Prakash
2012-02-07 15:11 ` Manjunathappa, Prakash [this message]
2012-02-07 15:11 ` [PATCH v3 3/3] arm:davinci: move NAND and NOR devices as aemif MFD slaves Manjunathappa, Prakash
2012-02-07 16:45   ` Michael Williamson
2012-02-08  4:00     ` Manjunathappa, Prakash

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=1328627513-30134-3-git-send-email-prakash.pm@ti.com \
    --to=prakash.pm@ti.com \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux@arm.linux.org.uk \
    --cc=nsekhar@ti.com \
    --cc=sameo@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).