Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2009 Wind River Systems, Inc. |
| 3 | * Tom Rix <Tom.Rix@windriver.com> |
| 4 | * |
| 5 | * This is file is based on |
| 6 | * repository git.gitorious.org/u-boot-omap3/mainline.git, |
| 7 | * branch omap3-dev-usb, file drivers/usb/host/omap3530_usb.c |
| 8 | * |
| 9 | * This is the unique part of its copyright : |
| 10 | * |
| 11 | * ------------------------------------------------------------------------ |
| 12 | * |
| 13 | * Copyright (c) 2009 Texas Instruments |
| 14 | * |
| 15 | * ------------------------------------------------------------------------ |
| 16 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 17 | * SPDX-License-Identifier: GPL-2.0+ |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 18 | */ |
| 19 | |
Lokesh Vutla | 37bce59 | 2013-05-30 02:54:30 +0000 | [diff] [blame] | 20 | #include <asm/omap_common.h> |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 21 | #include <twl4030.h> |
Steve Sakoman | 31367d1 | 2010-06-25 12:42:04 -0700 | [diff] [blame] | 22 | #include <twl6030.h> |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 23 | #include "omap3.h" |
| 24 | |
| 25 | static int platform_needs_initialization = 1; |
| 26 | |
| 27 | struct musb_config musb_cfg = { |
Ajay Kumar Gupta | 7e71dc7 | 2010-06-10 11:20:47 +0530 | [diff] [blame] | 28 | .regs = (struct musb_regs *)MENTOR_USB0_BASE, |
| 29 | .timeout = OMAP3_USB_TIMEOUT, |
| 30 | .musb_speed = 0, |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | /* |
| 34 | * OMAP3 USB OTG registers. |
| 35 | */ |
| 36 | struct omap3_otg_regs { |
| 37 | u32 revision; |
| 38 | u32 sysconfig; |
| 39 | u32 sysstatus; |
| 40 | u32 interfsel; |
| 41 | u32 simenable; |
| 42 | u32 forcestdby; |
| 43 | }; |
| 44 | |
| 45 | static struct omap3_otg_regs *otg; |
| 46 | |
| 47 | #define OMAP3_OTG_SYSCONFIG_SMART_STANDBY_MODE 0x2000 |
| 48 | #define OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE 0x1000 |
| 49 | #define OMAP3_OTG_SYSCONFIG_SMART_IDLE_MODE 0x0010 |
| 50 | #define OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE 0x0008 |
| 51 | #define OMAP3_OTG_SYSCONFIG_ENABLEWAKEUP 0x0004 |
| 52 | #define OMAP3_OTG_SYSCONFIG_SOFTRESET 0x0002 |
| 53 | #define OMAP3_OTG_SYSCONFIG_AUTOIDLE 0x0001 |
| 54 | |
| 55 | #define OMAP3_OTG_SYSSTATUS_RESETDONE 0x0001 |
| 56 | |
Steve Sakoman | 31367d1 | 2010-06-25 12:42:04 -0700 | [diff] [blame] | 57 | /* OMAP4430 has an internal PHY, use it */ |
| 58 | #ifdef CONFIG_OMAP4430 |
| 59 | #define OMAP3_OTG_INTERFSEL_OMAP 0x0000 |
| 60 | #else |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 61 | #define OMAP3_OTG_INTERFSEL_OMAP 0x0001 |
Steve Sakoman | 31367d1 | 2010-06-25 12:42:04 -0700 | [diff] [blame] | 62 | #endif |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 63 | |
| 64 | #define OMAP3_OTG_FORCESTDBY_STANDBY 0x0001 |
| 65 | |
| 66 | |
| 67 | #ifdef DEBUG_MUSB_OMAP3 |
| 68 | static void musb_db_otg_regs(void) |
| 69 | { |
| 70 | u32 l; |
| 71 | l = readl(&otg->revision); |
| 72 | serial_printf("OTG_REVISION 0x%x\n", l); |
| 73 | l = readl(&otg->sysconfig); |
| 74 | serial_printf("OTG_SYSCONFIG 0x%x\n", l); |
| 75 | l = readl(&otg->sysstatus); |
| 76 | serial_printf("OTG_SYSSTATUS 0x%x\n", l); |
| 77 | l = readl(&otg->interfsel); |
| 78 | serial_printf("OTG_INTERFSEL 0x%x\n", l); |
| 79 | l = readl(&otg->forcestdby); |
| 80 | serial_printf("OTG_FORCESTDBY 0x%x\n", l); |
| 81 | } |
| 82 | #endif |
| 83 | |
| 84 | int musb_platform_init(void) |
| 85 | { |
| 86 | int ret = -1; |
| 87 | |
| 88 | if (platform_needs_initialization) { |
| 89 | u32 stdby; |
| 90 | |
Tom Rix | 8526c6f | 2009-10-31 12:37:46 -0500 | [diff] [blame] | 91 | /* |
| 92 | * OMAP3EVM uses ISP1504 phy and so |
| 93 | * twl4030 related init is not required. |
| 94 | */ |
| 95 | #ifdef CONFIG_TWL4030_USB |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 96 | if (twl4030_usb_ulpi_init()) { |
| 97 | serial_printf("ERROR: %s Could not initialize PHY\n", |
| 98 | __PRETTY_FUNCTION__); |
| 99 | goto end; |
| 100 | } |
Tom Rix | 8526c6f | 2009-10-31 12:37:46 -0500 | [diff] [blame] | 101 | #endif |
Steve Sakoman | 31367d1 | 2010-06-25 12:42:04 -0700 | [diff] [blame] | 102 | |
| 103 | #ifdef CONFIG_TWL6030_POWER |
| 104 | twl6030_usb_device_settings(); |
| 105 | #endif |
| 106 | |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 107 | otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE; |
| 108 | |
| 109 | /* Set OTG to always be on */ |
| 110 | writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE | |
| 111 | OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig); |
| 112 | |
| 113 | /* Set the interface */ |
| 114 | writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel); |
| 115 | |
| 116 | /* Clear force standby */ |
| 117 | stdby = readl(&otg->forcestdby); |
| 118 | stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY; |
| 119 | writel(stdby, &otg->forcestdby); |
| 120 | |
Ajay Kumar Gupta | aeeac6b | 2010-06-10 11:20:50 +0530 | [diff] [blame] | 121 | #ifdef CONFIG_OMAP3_EVM |
| 122 | musb_cfg.extvbus = omap3_evm_need_extvbus(); |
| 123 | #endif |
Steve Sakoman | 31367d1 | 2010-06-25 12:42:04 -0700 | [diff] [blame] | 124 | |
| 125 | #ifdef CONFIG_OMAP4430 |
Lokesh Vutla | 37bce59 | 2013-05-30 02:54:30 +0000 | [diff] [blame] | 126 | u32 *usbotghs_control = |
| 127 | (u32 *)((*ctrl)->control_usbotghs_ctrl); |
Steve Sakoman | 31367d1 | 2010-06-25 12:42:04 -0700 | [diff] [blame] | 128 | *usbotghs_control = 0x15; |
| 129 | #endif |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 130 | platform_needs_initialization = 0; |
| 131 | } |
| 132 | |
| 133 | ret = platform_needs_initialization; |
Sanjeev Premi | 3a761ff | 2009-12-24 14:20:41 +0530 | [diff] [blame] | 134 | |
| 135 | #ifdef CONFIG_TWL4030_USB |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 136 | end: |
Sanjeev Premi | 3a761ff | 2009-12-24 14:20:41 +0530 | [diff] [blame] | 137 | #endif |
Tom Rix | 09c82bc | 2009-10-31 12:37:41 -0500 | [diff] [blame] | 138 | return ret; |
| 139 | |
| 140 | } |
| 141 | |
| 142 | void musb_platform_deinit(void) |
| 143 | { |
| 144 | /* noop */ |
| 145 | } |