[PATCH 32/36] ARM: OMAP2+: onenand: Use gpmc_generic_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Don't access any GPMC registers here. Use gpmc_generic_init()
to pass GPMC Chip Select settings, platform device and platform data
to the GPMC driver.

Signed-off-by: Roger Quadros <rogerq@xxxxxx>
---
 arch/arm/mach-omap2/gpmc-onenand.c | 53 ++++++++------------------------------
 1 file changed, 11 insertions(+), 42 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc-onenand.c b/arch/arm/mach-omap2/gpmc-onenand.c
index 37ed4f1..139b3dd 100644
--- a/arch/arm/mach-omap2/gpmc-onenand.c
+++ b/arch/arm/mach-omap2/gpmc-onenand.c
@@ -27,7 +27,10 @@
 #define	ONENAND_IO_SIZE	SZ_128K
 
 static struct resource gpmc_onenand_resource = {
+/* GPMC driver will fixup the memory resource, see gpmc_probe_legacy() */
 	.flags		= IORESOURCE_MEM,
+	.start		= 0,
+	.end		= ONENAND_IO_SIZE - 1,
 };
 
 static struct platform_device gpmc_onenand_device = {
@@ -68,29 +71,11 @@ static void omap2_onenand_get_async_timings(struct gpmc_device_timings *dev_t)
 	dev_t->t_wph = t_wph * 1000;
 }
 
-static int omap2_onenand_setup_async(struct omap_onenand_platform_data
-				     *gpmc_onenand_data)
-{
-	struct gpmc_timings gpmc_t;
-	struct gpmc_device_timings dev_t;
-	int ret;
-
-	ret = gpmc_cs_program_settings(gpmc_onenand_data->cs, &onenand_async);
-	if (ret < 0)
-		return ret;
-
-	omap2_onenand_get_async_timings(&dev_t);
-	gpmc_calc_timings(&gpmc_t, &onenand_async, &dev_t);
-	if (gpmc_cs_set_timings(gpmc_onenand_data->cs, &gpmc_t))
-		return -EINVAL;
-
-	return 0;
-}
-
 void gpmc_onenand_init(struct omap_onenand_platform_data *gpmc_onenand_data)
 {
 	int err;
 	struct device *dev = &gpmc_onenand_device.dev;
+	struct gpmc_device_timings dev_t;
 
 	gpmc_onenand_device.dev.platform_data = gpmc_onenand_data;
 
@@ -106,29 +91,13 @@ void gpmc_onenand_init(struct omap_onenand_platform_data *gpmc_onenand_data)
 	else
 		gpmc_onenand_data->flags &= ~ONENAND_IN_OMAP34XX;
 
-	err = gpmc_cs_request(gpmc_onenand_data->cs, ONENAND_IO_SIZE,
-				(unsigned long *)&gpmc_onenand_resource.start);
-	if (err < 0) {
-		dev_err(dev, "Cannot request GPMC CS %d, error %d\n",
-			gpmc_onenand_data->cs, err);
-		return;
-	}
-
-	gpmc_onenand_resource.end = gpmc_onenand_resource.start +
-							ONENAND_IO_SIZE - 1;
-
-	if (omap2_onenand_setup_async(gpmc_onenand_data)) {
-		pr_err("%s: Failed to setup ASYNC timings\n", __func__);
-		goto fail;
-	}
-
-	if (platform_device_register(&gpmc_onenand_device) < 0) {
-		dev_err(dev, "Unable to register OneNAND device\n");
-		goto fail;
-	}
 
-	return;
+	omap2_onenand_get_async_timings(&dev_t);
 
-fail:
-	gpmc_cs_free(gpmc_onenand_data->cs);
+	err = gpmc_generic_init(gpmc_onenand_data->cs, false,
+				&onenand_async, &dev_t, NULL,
+				&gpmc_onenand_device,
+				sizeof(*gpmc_onenand_data));
+	if (err)
+		pr_err("%s: gpmc_generic_init() failed %d\n", __func__, err);
 }
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux