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