/*
 * Copyright (c) 2009 Wind River Systems, Inc.
 * Tom Rix <Tom.Rix@windriver.com>
 *
 * This is file is based on
 * repository git.gitorious.org/u-boot-omap3/mainline.git,
 * branch omap3-dev-usb, file drivers/usb/host/omap3530_usb.c
 *
 * This is the unique part of its copyright :
 *
 * ------------------------------------------------------------------------
 *
 * Copyright (c) 2009 Texas Instruments
 *
 * ------------------------------------------------------------------------
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <asm/omap_common.h>
#include <twl4030.h>
#include <twl6030.h>
#include "omap3.h"

static int platform_needs_initialization = 1;

struct musb_config musb_cfg = {
	.regs		= (struct musb_regs *)MENTOR_USB0_BASE,
	.timeout	= OMAP3_USB_TIMEOUT,
	.musb_speed	= 0,
};

/*
 * OMAP3 USB OTG registers.
 */
struct omap3_otg_regs {
	u32	revision;
	u32	sysconfig;
	u32	sysstatus;
	u32	interfsel;
	u32	simenable;
	u32	forcestdby;
};

static struct omap3_otg_regs *otg;

#define OMAP3_OTG_SYSCONFIG_SMART_STANDBY_MODE		0x2000
#define OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE		0x1000
#define OMAP3_OTG_SYSCONFIG_SMART_IDLE_MODE		0x0010
#define OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE		0x0008
#define OMAP3_OTG_SYSCONFIG_ENABLEWAKEUP		0x0004
#define OMAP3_OTG_SYSCONFIG_SOFTRESET			0x0002
#define OMAP3_OTG_SYSCONFIG_AUTOIDLE			0x0001

#define OMAP3_OTG_SYSSTATUS_RESETDONE			0x0001

/* OMAP4430 has an internal PHY, use it */
#ifdef CONFIG_OMAP4430
#define OMAP3_OTG_INTERFSEL_OMAP			0x0000
#else
#define OMAP3_OTG_INTERFSEL_OMAP			0x0001
#endif

#define OMAP3_OTG_FORCESTDBY_STANDBY			0x0001


#ifdef DEBUG_MUSB_OMAP3
static void musb_db_otg_regs(void)
{
	u32 l;
	l = readl(&otg->revision);
	serial_printf("OTG_REVISION 0x%x\n", l);
	l = readl(&otg->sysconfig);
	serial_printf("OTG_SYSCONFIG 0x%x\n", l);
	l = readl(&otg->sysstatus);
	serial_printf("OTG_SYSSTATUS 0x%x\n", l);
	l = readl(&otg->interfsel);
	serial_printf("OTG_INTERFSEL 0x%x\n", l);
	l = readl(&otg->forcestdby);
	serial_printf("OTG_FORCESTDBY 0x%x\n", l);
}
#endif

int musb_platform_init(void)
{
	int ret = -1;

	if (platform_needs_initialization) {
		u32 stdby;

		/*
		 * OMAP3EVM uses ISP1504 phy and so
		 * twl4030 related init is not required.
		 */
#ifdef CONFIG_TWL4030_USB
		if (twl4030_usb_ulpi_init()) {
			serial_printf("ERROR: %s Could not initialize PHY\n",
				__PRETTY_FUNCTION__);
			goto end;
		}
#endif

#ifdef CONFIG_TWL6030_POWER
		twl6030_usb_device_settings();
#endif

		otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;

		/* Set OTG to always be on */
		writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
		       OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);

		/* Set the interface */
		writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);

		/* Clear force standby */
		stdby = readl(&otg->forcestdby);
		stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
		writel(stdby, &otg->forcestdby);

#ifdef CONFIG_OMAP3_EVM
		musb_cfg.extvbus = omap3_evm_need_extvbus();
#endif

#ifdef CONFIG_OMAP4430
		u32 *usbotghs_control =
			(u32 *)((*ctrl)->control_usbotghs_ctrl);
		*usbotghs_control = 0x15;
#endif
		platform_needs_initialization = 0;
	}

	ret = platform_needs_initialization;

#ifdef CONFIG_TWL4030_USB
end:
#endif
	return ret;

}

void musb_platform_deinit(void)
{
	/* noop */
}
