Skip to content

Commit

Permalink
usb: musb: make all glue layer export struct musb_platform_ops
Browse files Browse the repository at this point in the history
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: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Felipe Balbi committed Dec 7, 2010
1 parent 3ca8abb commit 743411b
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 177 deletions.
37 changes: 25 additions & 12 deletions drivers/usb/musb/am35x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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));
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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,
};
106 changes: 73 additions & 33 deletions drivers/usb/musb/blackfin.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,19 @@ 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);
musb->a_wait_bcon = TIMER_DELAY;
}
}

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)
Expand All @@ -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();
Expand Down Expand Up @@ -380,25 +358,87 @@ 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);

otg_put_transceiver(musb->xceiv);
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,
};
37 changes: 25 additions & 12 deletions drivers/usb/musb/da8xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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));
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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,
};
Loading

0 comments on commit 743411b

Please sign in to comment.