Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 743411b3 authored by Felipe Balbi's avatar Felipe Balbi
Browse files

usb: musb: make all glue layer export struct musb_platform_ops



preparing to a big refactor on musb code. We need
to be able to compile in all glue layers (or at
least all ARM-based ones) together and have a
working binary.

While preparing for that, we move every glue
layer to export only one symbol, which is
a struct musb_platform_ops, and make all
other functions static.

Later patches will come to allow for compiling
all glue layers together and have a working
binary.

Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 3ca8abb8
Loading
Loading
Loading
Loading
+25 −12
Original line number Diff line number Diff line
@@ -122,9 +122,9 @@ static inline void phy_off(void)
}

/*
 * musb_platform_enable - enable interrupts
 * am35x_musb_enable - enable interrupts
 */
void musb_platform_enable(struct musb *musb)
static void am35x_musb_enable(struct musb *musb)
{
	void __iomem *reg_base = musb->ctrl_base;
	u32 epmask;
@@ -143,9 +143,9 @@ void musb_platform_enable(struct musb *musb)
}

/*
 * musb_platform_disable - disable HDRC and flush interrupts
 * am35x_musb_disable - disable HDRC and flush interrupts
 */
void musb_platform_disable(struct musb *musb)
static void am35x_musb_disable(struct musb *musb)
{
	void __iomem *reg_base = musb->ctrl_base;

@@ -162,7 +162,7 @@ void musb_platform_disable(struct musb *musb)
#define portstate(stmt)
#endif

static void am35x_set_vbus(struct musb *musb, int is_on)
static void am35x_musb_set_vbus(struct musb *musb, int is_on)
{
	WARN_ON(is_on && is_peripheral_active(musb));
}
@@ -221,7 +221,7 @@ static void otg_timer(unsigned long _musb)
	spin_unlock_irqrestore(&musb->lock, flags);
}

void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
{
	static unsigned long last_timer;

@@ -251,7 +251,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
	mod_timer(&otg_workaround, timeout);
}

static irqreturn_t am35x_interrupt(int irq, void *hci)
static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
{
	struct musb  *musb = hci;
	void __iomem *reg_base = musb->ctrl_base;
@@ -362,7 +362,7 @@ static irqreturn_t am35x_interrupt(int irq, void *hci)
	return ret;
}

int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode)
{
	u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);

@@ -391,7 +391,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
	return 0;
}

int __init musb_platform_init(struct musb *musb, void *board_data)
static int am35x_musb_init(struct musb *musb)
{
	void __iomem *reg_base = musb->ctrl_base;
	u32 rev, lvl_intr, sw_reset;
@@ -427,7 +427,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
	if (is_host_enabled(musb))
		setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);

	musb->board_set_vbus = am35x_set_vbus;
	musb->board_set_vbus = am35x_musb_set_vbus;

	/* Global reset */
	sw_reset = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
@@ -446,7 +446,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)

	msleep(5);

	musb->isr = am35x_interrupt;
	musb->isr = am35x_musb_interrupt;

	/* clear level interrupt */
	lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
@@ -461,7 +461,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
	return status;
}

int musb_platform_exit(struct musb *musb)
static int am35x_musb_exit(struct musb *musb)
{
	if (is_host_enabled(musb))
		del_timer_sync(&otg_workaround);
@@ -522,3 +522,16 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
		memcpy(dst, &val, len);
	}
}

const struct musb_platform_ops musb_ops = {
	.init		= am35x_musb_init,
	.exit		= am35x_musb_exit,

	.enable		= am35x_musb_enable,
	.disable	= am35x_musb_disable,

	.set_mode	= am35x_musb_set_mode,
	.try_idle	= am35x_musb_try_idle,

	.set_vbus	= am35x_musb_set_vbus,
};
+73 −33
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
	DBG(4, "state is %s\n", otg_state_string(musb));
}

void musb_platform_enable(struct musb *musb)
static void bfin_musb_enable(struct musb *musb)
{
	if (!is_otg_enabled(musb) && is_host_enabled(musb)) {
		mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
@@ -285,11 +285,11 @@ void musb_platform_enable(struct musb *musb)
	}
}

void musb_platform_disable(struct musb *musb)
static void bfin_musb_disable(struct musb *musb)
{
}

static void bfin_set_vbus(struct musb *musb, int is_on)
static void bfin_musb_set_vbus(struct musb *musb, int is_on)
{
	int value = musb->config->gpio_vrsel_active;
	if (!is_on)
@@ -302,51 +302,29 @@ static void bfin_set_vbus(struct musb *musb, int is_on)
		musb_readb(musb->mregs, MUSB_DEVCTL));
}

static int bfin_set_power(struct otg_transceiver *x, unsigned mA)
static int bfin_musb_set_power(struct otg_transceiver *x, unsigned mA)
{
	return 0;
}

void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
static void bfin_musb_try_idle(struct musb *musb, unsigned long timeout)
{
	if (!is_otg_enabled(musb) && is_host_enabled(musb))
		mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
}

int musb_platform_get_vbus_status(struct musb *musb)
static int bfin_musb_get_vbus_status(struct musb *musb)
{
	return 0;
}

int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
static int bfin_musb_set_mode(struct musb *musb, u8 musb_mode)
{
	return -EIO;
}

int __init musb_platform_init(struct musb *musb)
static void bfin_musb_reg_init(struct musb *musb)
{

	/*
	 * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE
	 * and OTG HOST modes, while rev 1.1 and greater require PE7 to
	 * be low for DEVICE mode and high for HOST mode. We set it high
	 * here because we are in host mode
	 */

	if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) {
		printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d \n",
			musb->config->gpio_vrsel);
		return -ENODEV;
	}
	gpio_direction_output(musb->config->gpio_vrsel, 0);

	usb_nop_xceiv_register();
	musb->xceiv = otg_get_transceiver();
	if (!musb->xceiv) {
		gpio_free(musb->config->gpio_vrsel);
		return -ENODEV;
	}

	if (ANOMALY_05000346) {
		bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value);
		SSYNC();
@@ -380,21 +358,69 @@ int __init musb_platform_init(struct musb *musb)
				EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA |
				EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA);
	SSYNC();
}

static int bfin_musb_init(struct musb *musb)
{

	/*
	 * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE
	 * and OTG HOST modes, while rev 1.1 and greater require PE7 to
	 * be low for DEVICE mode and high for HOST mode. We set it high
	 * here because we are in host mode
	 */

	if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) {
		printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d\n",
			musb->config->gpio_vrsel);
		return -ENODEV;
	}
	gpio_direction_output(musb->config->gpio_vrsel, 0);

	usb_nop_xceiv_register();
	musb->xceiv = otg_get_transceiver();
	if (!musb->xceiv) {
		gpio_free(musb->config->gpio_vrsel);
		return -ENODEV;
	}

	bfin_musb_reg_init(musb);

	if (is_host_enabled(musb)) {
		musb->board_set_vbus = bfin_set_vbus;
		musb->board_set_vbus = bfin_musb_set_vbus;
		setup_timer(&musb_conn_timer,
			musb_conn_timer_handler, (unsigned long) musb);
	}
	if (is_peripheral_enabled(musb))
		musb->xceiv->set_power = bfin_set_power;
		musb->xceiv->set_power = bfin_musb_set_power;

	musb->isr = blackfin_interrupt;

	return 0;
}

int musb_platform_exit(struct musb *musb)
#ifdef CONFIG_PM
void musb_platform_save_context(struct musb *musb,
			struct musb_context_registers *musb_context)
{
	if (is_host_active(musb))
		/*
		 * During hibernate gpio_vrsel will change from high to low
		 * low which will generate wakeup event resume the system
		 * immediately.  Set it to 0 before hibernate to avoid this
		 * wakeup event.
		 */
		gpio_set_value(musb->config->gpio_vrsel, 0);
}

void musb_platform_restore_context(struct musb *musb,
			struct musb_context_registers *musb_context)
{
	bfin_musb_reg_init(musb);
}
#endif

static int bfin_musb_exit(struct musb *musb)
{
	gpio_free(musb->config->gpio_vrsel);

@@ -402,3 +428,17 @@ int musb_platform_exit(struct musb *musb)
	usb_nop_xceiv_unregister();
	return 0;
}

const struct musb_platform_ops musb_ops = {
	.init		= bfin_musb_init,
	.exit		= bfin_musb_exit,

	.enable		= bfin_musb_enable,
	.disable	= bfin_musb_disable,

	.set_mode	= bfin_musb_set_mode,
	.try_idle	= bfin_musb_try_idle,

	.vbus_status	= bfin_musb_vbus_status,
	.set_vbus	= bfin_musb_set_vbus,
};
+25 −12
Original line number Diff line number Diff line
@@ -131,9 +131,9 @@ static inline void phy_off(void)
 */

/**
 * musb_platform_enable - enable interrupts
 * da8xx_musb_enable - enable interrupts
 */
void musb_platform_enable(struct musb *musb)
static void da8xx_musb_enable(struct musb *musb)
{
	void __iomem *reg_base = musb->ctrl_base;
	u32 mask;
@@ -151,9 +151,9 @@ void musb_platform_enable(struct musb *musb)
}

/**
 * musb_platform_disable - disable HDRC and flush interrupts
 * da8xx_musb_disable - disable HDRC and flush interrupts
 */
void musb_platform_disable(struct musb *musb)
static void da8xx_musb_disable(struct musb *musb)
{
	void __iomem *reg_base = musb->ctrl_base;

@@ -170,7 +170,7 @@ void musb_platform_disable(struct musb *musb)
#define portstate(stmt)
#endif

static void da8xx_set_vbus(struct musb *musb, int is_on)
static void da8xx_musb_set_vbus(struct musb *musb, int is_on)
{
	WARN_ON(is_on && is_peripheral_active(musb));
}
@@ -252,7 +252,7 @@ static void otg_timer(unsigned long _musb)
	spin_unlock_irqrestore(&musb->lock, flags);
}

void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
{
	static unsigned long last_timer;

@@ -282,7 +282,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
	mod_timer(&otg_workaround, timeout);
}

static irqreturn_t da8xx_interrupt(int irq, void *hci)
static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
{
	struct musb		*musb = hci;
	void __iomem		*reg_base = musb->ctrl_base;
@@ -380,7 +380,7 @@ static irqreturn_t da8xx_interrupt(int irq, void *hci)
	return ret;
}

int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode)
{
	u32 cfgchip2 = __raw_readl(CFGCHIP2);

@@ -409,7 +409,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
	return 0;
}

int __init musb_platform_init(struct musb *musb, void *board_data)
static int da8xx_musb_init(struct musb *musb)
{
	void __iomem *reg_base = musb->ctrl_base;
	u32 rev;
@@ -431,7 +431,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
	if (is_host_enabled(musb))
		setup_timer(&otg_workaround, otg_timer, (unsigned long)musb);

	musb->board_set_vbus = da8xx_set_vbus;
	musb->board_set_vbus = da8xx_musb_set_vbus;

	/* Reset the controller */
	musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK);
@@ -446,14 +446,14 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
		 rev, __raw_readl(CFGCHIP2),
		 musb_readb(reg_base, DA8XX_USB_CTRL_REG));

	musb->isr = da8xx_interrupt;
	musb->isr = da8xx_musb_interrupt;
	return 0;
fail:
	clk_disable(musb->clock);
	return -ENODEV;
}

int musb_platform_exit(struct musb *musb)
static int da8xx_musb_exit(struct musb *musb)
{
	if (is_host_enabled(musb))
		del_timer_sync(&otg_workaround);
@@ -467,3 +467,16 @@ int musb_platform_exit(struct musb *musb)

	return 0;
}

const struct musb_platform_ops musb_ops = {
	.init		= da8xx_musb_init,
	.exit		= da8xx_musb_exit,

	.enable		= da8xx_musb_enable,
	.disable	= da8xx_musb_disable,

	.set_mode	= da8xx_musb_set_mode,
	.try_idle	= da8xx_musb_try_idle,

	.set_vbus	= da8xx_musb_set_vbus,
};
+26 −14
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ static inline void phy_off(void)

static int dma_off = 1;

void musb_platform_enable(struct musb *musb)
static void davinci_musb_enable(struct musb *musb)
{
	u32	tmp, old, val;

@@ -116,7 +116,7 @@ void musb_platform_enable(struct musb *musb)
/*
 * Disable the HDRC and flush interrupts
 */
void musb_platform_disable(struct musb *musb)
static void davinci_musb_disable(struct musb *musb)
{
	/* because we don't set CTRLR.UINT, "important" to:
	 *  - not read/write INTRUSB/INTRUSBE
@@ -167,7 +167,7 @@ static void evm_deferred_drvvbus(struct work_struct *ignored)

#endif	/* EVM */

static void davinci_source_power(struct musb *musb, int is_on, int immediate)
static void davinci_musb_source_power(struct musb *musb, int is_on, int immediate)
{
#ifdef CONFIG_MACH_DAVINCI_EVM
	if (is_on)
@@ -190,10 +190,10 @@ static void davinci_source_power(struct musb *musb, int is_on, int immediate)
#endif
}

static void davinci_set_vbus(struct musb *musb, int is_on)
static void davinci_musb_set_vbus(struct musb *musb, int is_on)
{
	WARN_ON(is_on && is_peripheral_active(musb));
	davinci_source_power(musb, is_on, 0);
	davinci_musb_source_power(musb, is_on, 0);
}


@@ -259,7 +259,7 @@ static void otg_timer(unsigned long _musb)
	spin_unlock_irqrestore(&musb->lock, flags);
}

static irqreturn_t davinci_interrupt(int irq, void *__hci)
static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
{
	unsigned long	flags;
	irqreturn_t	retval = IRQ_NONE;
@@ -345,7 +345,7 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
		/* NOTE:  this must complete poweron within 100 msec
		 * (OTG_TIME_A_WAIT_VRISE) but we don't check for that.
		 */
		davinci_source_power(musb, drvvbus, 0);
		davinci_musb_source_power(musb, drvvbus, 0);
		DBG(2, "VBUS %s (%s)%s, devctl %02x\n",
				drvvbus ? "on" : "off",
				otg_state_string(musb),
@@ -370,13 +370,13 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
	return retval;
}

int musb_platform_set_mode(struct musb *musb, u8 mode)
static int davinci_musb_set_mode(struct musb *musb, u8 mode)
{
	/* EVM can't do this (right?) */
	return -EIO;
}

int __init musb_platform_init(struct musb *musb)
static int davinci_musb_init(struct musb *musb)
{
	void __iomem	*tibase = musb->ctrl_base;
	u32		revision;
@@ -398,8 +398,8 @@ int __init musb_platform_init(struct musb *musb)
	if (is_host_enabled(musb))
		setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);

	musb->board_set_vbus = davinci_set_vbus;
	davinci_source_power(musb, 0, 1);
	musb->board_set_vbus = davinci_musb_set_vbus;
	davinci_musb_source_power(musb, 0, 1);

	/* dm355 EVM swaps D+/D- for signal integrity, and
	 * is clocked from the main 24 MHz crystal.
@@ -440,7 +440,7 @@ int __init musb_platform_init(struct musb *musb)
		revision, __raw_readl(USB_PHY_CTRL),
		musb_readb(tibase, DAVINCI_USB_CTRL_REG));

	musb->isr = davinci_interrupt;
	musb->isr = davinci_musb_interrupt;
	return 0;

fail:
@@ -451,7 +451,7 @@ int __init musb_platform_init(struct musb *musb)
	return -ENODEV;
}

int musb_platform_exit(struct musb *musb)
static int davinci_musb_exit(struct musb *musb)
{
	if (is_host_enabled(musb))
		del_timer_sync(&otg_workaround);
@@ -465,7 +465,7 @@ int musb_platform_exit(struct musb *musb)
		__raw_writel(deepsleep, DM355_DEEPSLEEP);
	}

	davinci_source_power(musb, 0 /*off*/, 1);
	davinci_musb_source_power(musb, 0 /*off*/, 1);

	/* delay, to avoid problems with module reload */
	if (is_host_enabled(musb) && musb->xceiv->default_a) {
@@ -502,3 +502,15 @@ int musb_platform_exit(struct musb *musb)

	return 0;
}

const struct musb_platform_ops musb_ops = {
	.init		= davinci_musb_init,
	.exit		= davinci_musb_exit,

	.enable		= davinci_musb_enable,
	.disable	= davinci_musb_disable,

	.set_mode	= davinci_musb_set_mode,

	.set_vbus	= davinci_musb_set_vbus,
};
+5 −3
Original line number Diff line number Diff line
@@ -390,7 +390,7 @@ void musb_otg_timer_func(unsigned long data)
	case OTG_STATE_A_SUSPEND:
	case OTG_STATE_A_WAIT_BCON:
		DBG(1, "HNP: %s timeout\n", otg_state_string(musb));
		musb_set_vbus(musb, 0);
		musb_platform_set_vbus(musb, 0);
		musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
		break;
	default:
@@ -570,7 +570,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
		musb->ep0_stage = MUSB_EP0_START;
		musb->xceiv->state = OTG_STATE_A_IDLE;
		MUSB_HST_MODE(musb);
		musb_set_vbus(musb, 1);
		musb_platform_set_vbus(musb, 1);

		handled = IRQ_HANDLED;
	}
@@ -641,7 +641,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,

		/* go through A_WAIT_VFALL then start a new session */
		if (!ignore)
			musb_set_vbus(musb, 0);
			musb_platform_set_vbus(musb, 0);
		handled = IRQ_HANDLED;
	}

@@ -1898,6 +1898,8 @@ allocate_instance(struct device *dev,
	}

	musb->controller = dev;
	musb->ops = &musb_ops;

	return musb;
}

Loading