From 897e90138695dccac0dca1601542fd5f4c85b657 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <nm@ti.com>
Date: Wed, 5 Jan 2011 14:16:59 -0600
Subject: [PATCH 19/20] OMAP3: beagle xm: enable upto 1GHz OPP

Beagle XM uses 3730 and the board design allows enabling 800MHz and 1GHz
OPPs. tweak the default table to allow for higher OPP tables

Reported-by: Koen Kooi <koen@beagleboard.org>
Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/board-omap3beagle.c |   54 +++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index ad0c1d8..1e0870e 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -24,6 +24,7 @@
 #include <linux/irq.h>
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
+#include <linux/opp.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
@@ -45,10 +46,12 @@
 #include <plat/gpmc.h>
 #include <plat/nand.h>
 #include <plat/usb.h>
+#include <plat/omap_device.h>
 
 #include "mux.h"
 #include "hsmmc.h"
 #include "timer-gp.h"
+#include "pm.h"
 
 #define NAND_BLOCK_SIZE		SZ_128K
 
@@ -804,6 +807,56 @@ static int __init expansionboard_setup(char *str)
 	return 0;
 }
 
+static void __init beagle_opp_init(void)
+{
+	int r = 0;
+
+	/* Initialize the omap3 opp table */
+	if (omap3_opp_init()) {
+		pr_err("%s: opp default init failed\n", __func__);
+		return;
+	}
+
+	/* Custom OPP enabled for XM */
+	if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
+		struct omap_hwmod *mh = omap_hwmod_lookup("mpu");
+		struct omap_hwmod *dh = omap_hwmod_lookup("iva");
+		struct device *dev;
+
+		if (!mh || !dh) {
+			pr_err("%s: Aiee.. no mpu/dsp devices? %p %p\n",
+				__func__, mh, dh);
+			r = -EINVAL;
+		} else {
+			/* Enable MPU 1GHz and lower opps */
+			dev = &mh->od->pdev.dev;
+			r = opp_enable(dev, 800000000);
+			r |= opp_enable(dev, 1000000000);
+
+			/* Enable IVA 800MHz and lower opps */
+			dev = &dh->od->pdev.dev;
+			r |= opp_enable(dev, 660000000);
+			r |= opp_enable(dev, 800000000);
+		}
+		if (r) {
+			pr_err("%s: failed to enable higher opp %d\n",
+				__func__, r);
+			/*
+			 * Cleanup - disable the higher freqs - we dont care
+			 * about the results
+			 */
+			dev = &mh->od->pdev.dev;
+			opp_disable(dev, 800000000);
+			opp_disable(dev, 1000000000);
+			dev = &dh->od->pdev.dev;
+			opp_disable(dev, 660000000);
+			opp_disable(dev, 800000000);
+		} else {
+			pr_err("%s: turbo OPPs enabled!\n", __func__);
+		}
+	}
+}
+
 static void __init omap3_beagle_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
@@ -876,6 +929,7 @@ static void __init omap3_beagle_init(void)
 	omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
 
 	beagle_display_init();
+	beagle_opp_init();
 }
 
 early_param("buddy", expansionboard_setup);
-- 
1.6.6.1

