2009-03-24 04:34:06 +03:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/mach-omap2/usb-musb.c
|
|
|
|
*
|
|
|
|
* This file will contain the board specific details for the
|
|
|
|
* MENTOR USB OTG controller on OMAP3430
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007-2008 Texas Instruments
|
|
|
|
* Copyright (C) 2008 Nokia Corporation
|
|
|
|
* Author: Vikram Pandita
|
|
|
|
*
|
|
|
|
* Generalization by:
|
|
|
|
* Felipe Balbi <felipe.balbi@nokia.com>
|
|
|
|
*
|
|
|
|
* 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/types.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/usb/musb.h>
|
|
|
|
|
2009-10-20 20:40:47 +04:00
|
|
|
#include <plat/usb.h>
|
2011-02-17 09:37:21 +03:00
|
|
|
#include <plat/omap_device.h>
|
2012-08-31 21:59:07 +04:00
|
|
|
|
2012-09-20 22:40:52 +04:00
|
|
|
#include "am35xx.h"
|
2012-08-31 21:59:07 +04:00
|
|
|
|
2011-02-16 13:12:15 +03:00
|
|
|
#include "mux.h"
|
2009-03-24 04:34:06 +03:00
|
|
|
|
|
|
|
static struct musb_hdrc_config musb_config = {
|
|
|
|
.multipoint = 1,
|
|
|
|
.dyn_fifo = 1,
|
|
|
|
.num_eps = 16,
|
|
|
|
.ram_bits = 12,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct musb_hdrc_platform_data musb_plat = {
|
2012-06-20 18:18:15 +04:00
|
|
|
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
|
2009-03-24 04:34:06 +03:00
|
|
|
.mode = MUSB_OTG,
|
2012-06-20 18:18:15 +04:00
|
|
|
#else
|
2009-03-24 04:34:06 +03:00
|
|
|
.mode = MUSB_HOST,
|
|
|
|
#endif
|
|
|
|
/* .clock is set dynamically */
|
|
|
|
.config = &musb_config,
|
|
|
|
|
|
|
|
/* REVISIT charge pump on TWL4030 can supply up to
|
|
|
|
* 100 mA ... but this value is board-specific, like
|
|
|
|
* "mode", and should be passed to usb_musb_init().
|
|
|
|
*/
|
|
|
|
.power = 50, /* up to 100 mA */
|
|
|
|
};
|
|
|
|
|
2009-04-14 01:40:14 +04:00
|
|
|
static u64 musb_dmamask = DMA_BIT_MASK(32);
|
2009-03-24 04:34:06 +03:00
|
|
|
|
2011-04-27 12:56:12 +04:00
|
|
|
static struct omap_musb_board_data musb_default_board_data = {
|
|
|
|
.interface_type = MUSB_INTERFACE_ULPI,
|
|
|
|
.mode = MUSB_OTG,
|
|
|
|
.power = 100,
|
|
|
|
};
|
|
|
|
|
|
|
|
void __init usb_musb_init(struct omap_musb_board_data *musb_board_data)
|
2009-03-24 04:34:06 +03:00
|
|
|
{
|
2011-02-17 09:37:21 +03:00
|
|
|
struct omap_hwmod *oh;
|
|
|
|
struct platform_device *pdev;
|
|
|
|
struct device *dev;
|
|
|
|
int bus_id = -1;
|
|
|
|
const char *oh_name, *name;
|
2011-04-27 12:56:12 +04:00
|
|
|
struct omap_musb_board_data *board_data;
|
|
|
|
|
|
|
|
if (musb_board_data)
|
|
|
|
board_data = musb_board_data;
|
|
|
|
else
|
|
|
|
board_data = &musb_default_board_data;
|
2011-02-16 13:12:15 +03:00
|
|
|
|
2009-03-24 04:34:06 +03:00
|
|
|
/*
|
|
|
|
* REVISIT: This line can be removed once all the platforms using
|
|
|
|
* musb_core.c have been converted to use use clkdev.
|
|
|
|
*/
|
|
|
|
musb_plat.clock = "ick";
|
2010-02-18 01:09:30 +03:00
|
|
|
musb_plat.board_data = board_data;
|
|
|
|
musb_plat.power = board_data->power >> 1;
|
|
|
|
musb_plat.mode = board_data->mode;
|
2010-03-25 14:25:27 +03:00
|
|
|
musb_plat.extvbus = board_data->extvbus;
|
2009-03-24 04:34:06 +03:00
|
|
|
|
2012-05-01 03:37:10 +04:00
|
|
|
if (soc_is_am35xx()) {
|
2011-02-17 09:37:21 +03:00
|
|
|
oh_name = "am35x_otg_hs";
|
|
|
|
name = "musb-am35x";
|
2011-12-13 22:50:58 +04:00
|
|
|
} else if (cpu_is_ti81xx()) {
|
|
|
|
oh_name = "usb_otg_hs";
|
|
|
|
name = "musb-ti81xx";
|
2011-02-17 09:37:21 +03:00
|
|
|
} else {
|
|
|
|
oh_name = "usb_otg_hs";
|
|
|
|
name = "musb-omap2430";
|
|
|
|
}
|
|
|
|
|
2011-10-04 20:47:06 +04:00
|
|
|
oh = omap_hwmod_lookup(oh_name);
|
|
|
|
if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
|
|
|
|
__func__, oh_name))
|
|
|
|
return;
|
2011-02-17 09:37:21 +03:00
|
|
|
|
2011-10-04 20:47:06 +04:00
|
|
|
pdev = omap_device_build(name, bus_id, oh, &musb_plat,
|
2011-08-10 17:30:09 +04:00
|
|
|
sizeof(musb_plat), NULL, 0, false);
|
2011-10-04 20:47:06 +04:00
|
|
|
if (IS_ERR(pdev)) {
|
2011-02-17 09:37:21 +03:00
|
|
|
pr_err("Could not build omap_device for %s %s\n",
|
|
|
|
name, oh_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev = &pdev->dev;
|
|
|
|
get_device(dev);
|
|
|
|
dev->dma_mask = &musb_dmamask;
|
|
|
|
dev->coherent_dma_mask = musb_dmamask;
|
|
|
|
put_device(dev);
|
2009-01-19 20:09:22 +03:00
|
|
|
}
|