diff options
author | Felipe Balbi <balbi@ti.com> | 2010-12-01 06:22:05 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2010-12-07 02:19:39 -0500 |
commit | 743411b3f3e96e8ac4cae73551a0a95392fed1ea (patch) | |
tree | 485f2f1f92768df7b1cc2d44cf3b8d4cc3cdaf3b /drivers/usb/musb/tusb6010.c | |
parent | 3ca8abb84522f4b773678726db6ebd6fc277bc96 (diff) |
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: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/tusb6010.c')
-rw-r--r-- | drivers/usb/musb/tusb6010.c | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 41b04b906ce1..60abd52b2c51 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #include "musb_core.h" | 25 | #include "musb_core.h" |
26 | 26 | ||
27 | static void tusb_source_power(struct musb *musb, int is_on); | 27 | static void tusb_musb_set_vbus(struct musb *musb, int is_on); |
28 | 28 | ||
29 | #define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf) | 29 | #define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf) |
30 | #define TUSB_REV_MINOR(reg_val) (reg_val & 0xf) | 30 | #define TUSB_REV_MINOR(reg_val) (reg_val & 0xf) |
@@ -50,7 +50,7 @@ u8 tusb_get_revision(struct musb *musb) | |||
50 | return rev; | 50 | return rev; |
51 | } | 51 | } |
52 | 52 | ||
53 | static int __init tusb_print_revision(struct musb *musb) | 53 | static int tusb_print_revision(struct musb *musb) |
54 | { | 54 | { |
55 | void __iomem *tbase = musb->ctrl_base; | 55 | void __iomem *tbase = musb->ctrl_base; |
56 | u8 rev; | 56 | u8 rev; |
@@ -348,7 +348,7 @@ static void tusb_set_clock_source(struct musb *musb, unsigned mode) | |||
348 | * USB link is not suspended ... and tells us the relevant wakeup | 348 | * USB link is not suspended ... and tells us the relevant wakeup |
349 | * events. SW_EN for voltage is handled separately. | 349 | * events. SW_EN for voltage is handled separately. |
350 | */ | 350 | */ |
351 | void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) | 351 | static void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) |
352 | { | 352 | { |
353 | void __iomem *tbase = musb->ctrl_base; | 353 | void __iomem *tbase = musb->ctrl_base; |
354 | u32 reg; | 354 | u32 reg; |
@@ -385,7 +385,7 @@ void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) | |||
385 | /* | 385 | /* |
386 | * Updates cable VBUS status. Caller must take care of locking. | 386 | * Updates cable VBUS status. Caller must take care of locking. |
387 | */ | 387 | */ |
388 | int musb_platform_get_vbus_status(struct musb *musb) | 388 | static int tusb_musb_vbus_status(struct musb *musb) |
389 | { | 389 | { |
390 | void __iomem *tbase = musb->ctrl_base; | 390 | void __iomem *tbase = musb->ctrl_base; |
391 | u32 otg_stat, prcm_mngmt; | 391 | u32 otg_stat, prcm_mngmt; |
@@ -431,7 +431,7 @@ static void musb_do_idle(unsigned long _musb) | |||
431 | } | 431 | } |
432 | /* FALLTHROUGH */ | 432 | /* FALLTHROUGH */ |
433 | case OTG_STATE_A_IDLE: | 433 | case OTG_STATE_A_IDLE: |
434 | tusb_source_power(musb, 0); | 434 | tusb_musb_set_vbus(musb, 0); |
435 | default: | 435 | default: |
436 | break; | 436 | break; |
437 | } | 437 | } |
@@ -475,7 +475,7 @@ done: | |||
475 | * we don't want to treat that full speed J as a wakeup event. | 475 | * we don't want to treat that full speed J as a wakeup event. |
476 | * ... peripherals must draw only suspend current after 10 msec. | 476 | * ... peripherals must draw only suspend current after 10 msec. |
477 | */ | 477 | */ |
478 | void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | 478 | static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout) |
479 | { | 479 | { |
480 | unsigned long default_timeout = jiffies + msecs_to_jiffies(3); | 480 | unsigned long default_timeout = jiffies + msecs_to_jiffies(3); |
481 | static unsigned long last_timer; | 481 | static unsigned long last_timer; |
@@ -515,7 +515,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | |||
515 | | TUSB_DEV_OTG_TIMER_ENABLE) \ | 515 | | TUSB_DEV_OTG_TIMER_ENABLE) \ |
516 | : 0) | 516 | : 0) |
517 | 517 | ||
518 | static void tusb_source_power(struct musb *musb, int is_on) | 518 | static void tusb_musb_set_vbus(struct musb *musb, int is_on) |
519 | { | 519 | { |
520 | void __iomem *tbase = musb->ctrl_base; | 520 | void __iomem *tbase = musb->ctrl_base; |
521 | u32 conf, prcm, timer; | 521 | u32 conf, prcm, timer; |
@@ -599,7 +599,7 @@ static void tusb_source_power(struct musb *musb, int is_on) | |||
599 | * and peripheral modes in non-OTG configurations by reconfiguring hardware | 599 | * and peripheral modes in non-OTG configurations by reconfiguring hardware |
600 | * and then setting musb->board_mode. For now, only support OTG mode. | 600 | * and then setting musb->board_mode. For now, only support OTG mode. |
601 | */ | 601 | */ |
602 | int musb_platform_set_mode(struct musb *musb, u8 musb_mode) | 602 | static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode) |
603 | { | 603 | { |
604 | void __iomem *tbase = musb->ctrl_base; | 604 | void __iomem *tbase = musb->ctrl_base; |
605 | u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf; | 605 | u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf; |
@@ -677,7 +677,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
677 | default_a = is_host_enabled(musb); | 677 | default_a = is_host_enabled(musb); |
678 | DBG(2, "Default-%c\n", default_a ? 'A' : 'B'); | 678 | DBG(2, "Default-%c\n", default_a ? 'A' : 'B'); |
679 | musb->xceiv->default_a = default_a; | 679 | musb->xceiv->default_a = default_a; |
680 | tusb_source_power(musb, default_a); | 680 | tusb_musb_set_vbus(musb, default_a); |
681 | 681 | ||
682 | /* Don't allow idling immediately */ | 682 | /* Don't allow idling immediately */ |
683 | if (default_a) | 683 | if (default_a) |
@@ -722,7 +722,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
722 | switch (musb->xceiv->state) { | 722 | switch (musb->xceiv->state) { |
723 | case OTG_STATE_A_IDLE: | 723 | case OTG_STATE_A_IDLE: |
724 | DBG(2, "Got SRP, turning on VBUS\n"); | 724 | DBG(2, "Got SRP, turning on VBUS\n"); |
725 | musb_set_vbus(musb, 1); | 725 | musb_platform_set_vbus(musb, 1); |
726 | 726 | ||
727 | /* CONNECT can wake if a_wait_bcon is set */ | 727 | /* CONNECT can wake if a_wait_bcon is set */ |
728 | if (musb->a_wait_bcon != 0) | 728 | if (musb->a_wait_bcon != 0) |
@@ -748,11 +748,11 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
748 | */ | 748 | */ |
749 | if (musb->vbuserr_retry) { | 749 | if (musb->vbuserr_retry) { |
750 | musb->vbuserr_retry--; | 750 | musb->vbuserr_retry--; |
751 | tusb_source_power(musb, 1); | 751 | tusb_musb_set_vbus(musb, 1); |
752 | } else { | 752 | } else { |
753 | musb->vbuserr_retry | 753 | musb->vbuserr_retry |
754 | = VBUSERR_RETRY_COUNT; | 754 | = VBUSERR_RETRY_COUNT; |
755 | tusb_source_power(musb, 0); | 755 | tusb_musb_set_vbus(musb, 0); |
756 | } | 756 | } |
757 | break; | 757 | break; |
758 | default: | 758 | default: |
@@ -786,7 +786,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
786 | } else { | 786 | } else { |
787 | /* REVISIT report overcurrent to hub? */ | 787 | /* REVISIT report overcurrent to hub? */ |
788 | ERR("vbus too slow, devctl %02x\n", devctl); | 788 | ERR("vbus too slow, devctl %02x\n", devctl); |
789 | tusb_source_power(musb, 0); | 789 | tusb_musb_set_vbus(musb, 0); |
790 | } | 790 | } |
791 | break; | 791 | break; |
792 | case OTG_STATE_A_WAIT_BCON: | 792 | case OTG_STATE_A_WAIT_BCON: |
@@ -807,7 +807,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
807 | return idle_timeout; | 807 | return idle_timeout; |
808 | } | 808 | } |
809 | 809 | ||
810 | static irqreturn_t tusb_interrupt(int irq, void *__hci) | 810 | static irqreturn_t tusb_musb_interrupt(int irq, void *__hci) |
811 | { | 811 | { |
812 | struct musb *musb = __hci; | 812 | struct musb *musb = __hci; |
813 | void __iomem *tbase = musb->ctrl_base; | 813 | void __iomem *tbase = musb->ctrl_base; |
@@ -911,7 +911,7 @@ static irqreturn_t tusb_interrupt(int irq, void *__hci) | |||
911 | musb_writel(tbase, TUSB_INT_SRC_CLEAR, | 911 | musb_writel(tbase, TUSB_INT_SRC_CLEAR, |
912 | int_src & ~TUSB_INT_MASK_RESERVED_BITS); | 912 | int_src & ~TUSB_INT_MASK_RESERVED_BITS); |
913 | 913 | ||
914 | musb_platform_try_idle(musb, idle_timeout); | 914 | tusb_musb_try_idle(musb, idle_timeout); |
915 | 915 | ||
916 | musb_writel(tbase, TUSB_INT_MASK, int_mask); | 916 | musb_writel(tbase, TUSB_INT_MASK, int_mask); |
917 | spin_unlock_irqrestore(&musb->lock, flags); | 917 | spin_unlock_irqrestore(&musb->lock, flags); |
@@ -926,7 +926,7 @@ static int dma_off; | |||
926 | * REVISIT: | 926 | * REVISIT: |
927 | * - Check what is unnecessary in MGC_HdrcStart() | 927 | * - Check what is unnecessary in MGC_HdrcStart() |
928 | */ | 928 | */ |
929 | void musb_platform_enable(struct musb *musb) | 929 | static void tusb_musb_enable(struct musb *musb) |
930 | { | 930 | { |
931 | void __iomem *tbase = musb->ctrl_base; | 931 | void __iomem *tbase = musb->ctrl_base; |
932 | 932 | ||
@@ -970,7 +970,7 @@ void musb_platform_enable(struct musb *musb) | |||
970 | /* | 970 | /* |
971 | * Disables TUSB6010. Caller must take care of locking. | 971 | * Disables TUSB6010. Caller must take care of locking. |
972 | */ | 972 | */ |
973 | void musb_platform_disable(struct musb *musb) | 973 | static void tusb_musb_disable(struct musb *musb) |
974 | { | 974 | { |
975 | void __iomem *tbase = musb->ctrl_base; | 975 | void __iomem *tbase = musb->ctrl_base; |
976 | 976 | ||
@@ -995,7 +995,7 @@ void musb_platform_disable(struct musb *musb) | |||
995 | * Sets up TUSB6010 CPU interface specific signals and registers | 995 | * Sets up TUSB6010 CPU interface specific signals and registers |
996 | * Note: Settings optimized for OMAP24xx | 996 | * Note: Settings optimized for OMAP24xx |
997 | */ | 997 | */ |
998 | static void __init tusb_setup_cpu_interface(struct musb *musb) | 998 | static void tusb_setup_cpu_interface(struct musb *musb) |
999 | { | 999 | { |
1000 | void __iomem *tbase = musb->ctrl_base; | 1000 | void __iomem *tbase = musb->ctrl_base; |
1001 | 1001 | ||
@@ -1022,7 +1022,7 @@ static void __init tusb_setup_cpu_interface(struct musb *musb) | |||
1022 | musb_writel(tbase, TUSB_WAIT_COUNT, 1); | 1022 | musb_writel(tbase, TUSB_WAIT_COUNT, 1); |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | static int __init tusb_start(struct musb *musb) | 1025 | static int tusb_musb_start(struct musb *musb) |
1026 | { | 1026 | { |
1027 | void __iomem *tbase = musb->ctrl_base; | 1027 | void __iomem *tbase = musb->ctrl_base; |
1028 | int ret = 0; | 1028 | int ret = 0; |
@@ -1091,7 +1091,7 @@ err: | |||
1091 | return -ENODEV; | 1091 | return -ENODEV; |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | int __init musb_platform_init(struct musb *musb) | 1094 | static int tusb_musb_init(struct musb *musb) |
1095 | { | 1095 | { |
1096 | struct platform_device *pdev; | 1096 | struct platform_device *pdev; |
1097 | struct resource *mem; | 1097 | struct resource *mem; |
@@ -1131,16 +1131,14 @@ int __init musb_platform_init(struct musb *musb) | |||
1131 | */ | 1131 | */ |
1132 | musb->mregs += TUSB_BASE_OFFSET; | 1132 | musb->mregs += TUSB_BASE_OFFSET; |
1133 | 1133 | ||
1134 | ret = tusb_start(musb); | 1134 | ret = tusb_musb_start(musb); |
1135 | if (ret) { | 1135 | if (ret) { |
1136 | printk(KERN_ERR "Could not start tusb6010 (%d)\n", | 1136 | printk(KERN_ERR "Could not start tusb6010 (%d)\n", |
1137 | ret); | 1137 | ret); |
1138 | goto done; | 1138 | goto done; |
1139 | } | 1139 | } |
1140 | musb->isr = tusb_interrupt; | 1140 | musb->isr = tusb_musb_interrupt; |
1141 | 1141 | ||
1142 | if (is_host_enabled(musb)) | ||
1143 | musb->board_set_vbus = tusb_source_power; | ||
1144 | if (is_peripheral_enabled(musb)) { | 1142 | if (is_peripheral_enabled(musb)) { |
1145 | musb->xceiv->set_power = tusb_draw_power; | 1143 | musb->xceiv->set_power = tusb_draw_power; |
1146 | the_musb = musb; | 1144 | the_musb = musb; |
@@ -1159,7 +1157,7 @@ done: | |||
1159 | return ret; | 1157 | return ret; |
1160 | } | 1158 | } |
1161 | 1159 | ||
1162 | int musb_platform_exit(struct musb *musb) | 1160 | static int tusb_musb_exit(struct musb *musb) |
1163 | { | 1161 | { |
1164 | del_timer_sync(&musb_idle_timer); | 1162 | del_timer_sync(&musb_idle_timer); |
1165 | the_musb = NULL; | 1163 | the_musb = NULL; |
@@ -1173,3 +1171,17 @@ int musb_platform_exit(struct musb *musb) | |||
1173 | usb_nop_xceiv_unregister(); | 1171 | usb_nop_xceiv_unregister(); |
1174 | return 0; | 1172 | return 0; |
1175 | } | 1173 | } |
1174 | |||
1175 | const struct musb_platform_ops musb_ops = { | ||
1176 | .init = tusb_musb_init, | ||
1177 | .exit = tusb_musb_exit, | ||
1178 | |||
1179 | .enable = tusb_musb_enable, | ||
1180 | .disable = tusb_musb_disable, | ||
1181 | |||
1182 | .set_mode = tusb_musb_set_mode, | ||
1183 | .try_idle = tusb_musb_try_idle, | ||
1184 | |||
1185 | .vbus_status = tusb_musb_vbus_status, | ||
1186 | .set_vbus = tusb_musb_set_vbus, | ||
1187 | }; | ||