Skip to contentSkip to conversation

USB: OMAP1: Tahvo USB support for 770

PATCH Superseded Aaro Koskinen 3 participants 10 messages Jun 16, 2013 – Jun 18, 2013

Subsystems (5)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Aaro Koskinen

author maintainer
#0 lore raw

v2 cover USB: OMAP1: Tahvo USB support for 770

Hi,

These patches add support for Tahvo USB transceiver and allow using both host and peripheral modes on Nokia 770.

Tested (peripheral mode, host mode, vbus detection) with 3.10-rc6.

History:

	v2: Use extcon framework to trigger OTG driver mode changes.
	v1: http://marc.info/?l=linux-omap&m=137081763029385&w=2

Earlier RFC versions:

	http://marc.info/?l=linux-omap&m=136553710000679&w=2
	http://marc.info/?l=linux-omap&m=136266725827698&w=2

Aaro Koskinen (5):
ARM: OMAP1: USB: move omap_usb_config to platform data
USB: OMAP1: add extcon to platform data
USB: OMAP1: OTG controller driver
USB: OMAP1: Tahvo USB transceiver driver
ARM: OMAP1: nokia770: enable Tahvo

 arch/arm/mach-omap1/board-nokia770.c    |  11 +
 arch/arm/mach-omap1/include/mach/usb.h  |  38 +--
 drivers/usb/phy/Kconfig                 |  24 ++
 drivers/usb/phy/Makefile                |   2 +
 drivers/usb/phy/phy-omap-otg.c          | 171 ++++++++++++
 drivers/usb/phy/phy-tahvo.c             | 448 ++++++++++++++++++++++++++++++++
 include/linux/platform_data/usb-omap1.h |  53 ++++
 7 files changed, 710 insertions(+), 37 deletions(-)
 create mode 100644 drivers/usb/phy/phy-omap-otg.c
 create mode 100644 drivers/usb/phy/phy-tahvo.c
 create mode 100644 include/linux/platform_data/usb-omap1.h
Signature · 3 lines
1.8.3.1

A.
author maintainer
#1 lore raw

PATCH v2 1/5 ARM: OMAP1: USB: move omap_usb_config to platform data

Move omap_usb_config to platform data, so that OTG driver can include it.

---
 arch/arm/mach-omap1/include/mach/usb.h  | 38 +-----------------------
 include/linux/platform_data/usb-omap1.h | 51 +++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 37 deletions(-)
 create mode 100644 include/linux/platform_data/usb-omap1.h
arch/arm/mach-omap1/include/mach/usb.h +1 -37
index 45e5ac7..2c26305 100644
@@ -8,43 +8,7 @@
 #define	is_usb0_device(config)	0
 #endif
 
-struct omap_usb_config {
-	/* Configure drivers according to the connectors on your board:
-	 *  - "A" connector (rectagular)
-	 *	... for host/OHCI use, set "register_host".
-	 *  - "B" connector (squarish) or "Mini-B"
-	 *	... for device/gadget use, set "register_dev".
-	 *  - "Mini-AB" connector (very similar to Mini-B)
-	 *	... for OTG use as device OR host, initialize "otg"
-	 */
-	unsigned	register_host:1;
-	unsigned	register_dev:1;
-	u8		otg;	/* port number, 1-based:  usb1 == 2 */
-
-	u8		hmc_mode;
-
-	/* implicitly true if otg:  host supports remote wakeup? */
-	u8		rwc;
-
-	/* signaling pins used to talk to transceiver on usbN:
-	 *  0 == usbN unused
-	 *  2 == usb0-only, using internal transceiver
-	 *  3 == 3 wire bidirectional
-	 *  4 == 4 wire bidirectional
-	 *  6 == 6 wire unidirectional (or TLL)
-	 */
-	u8		pins[3];
-
-	struct platform_device *udc_device;
-	struct platform_device *ohci_device;
-	struct platform_device *otg_device;
-
-	u32 (*usb0_init)(unsigned nwires, unsigned is_device);
-	u32 (*usb1_init)(unsigned nwires);
-	u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
-
-	int (*ocpi_enable)(void);
-};
+#include <linux/platform_data/usb-omap1.h>
 
 void omap_otg_init(struct omap_usb_config *config);
 
include/linux/platform_data/usb-omap1.h new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
1.8.3.1
reviewer
#2 lore raw

PATCH v2 1/5 ARM: OMAP1: USB: move omap_usb_config to platform data

Quoted 3 lines · Aaro Koskinen

Move omap_usb_config to platform data, so that OTG driver can include it.

This is probably best queued with the USB transceiver:

Quoted 115 lines
---
 arch/arm/mach-omap1/include/mach/usb.h  | 38 +-----------------------
 include/linux/platform_data/usb-omap1.h | 51 +++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 37 deletions(-)
 create mode 100644 include/linux/platform_data/usb-omap1.h
arch/arm/mach-omap1/include/mach/usb.h +1 -37
index 45e5ac7..2c26305 100644
@@ -8,43 +8,7 @@
 #define	is_usb0_device(config)	0
 #endif
 
-struct omap_usb_config {
-	/* Configure drivers according to the connectors on your board:
-	 *  - "A" connector (rectagular)
-	 *	... for host/OHCI use, set "register_host".
-	 *  - "B" connector (squarish) or "Mini-B"
-	 *	... for device/gadget use, set "register_dev".
-	 *  - "Mini-AB" connector (very similar to Mini-B)
-	 *	... for OTG use as device OR host, initialize "otg"
-	 */
-	unsigned	register_host:1;
-	unsigned	register_dev:1;
-	u8		otg;	/* port number, 1-based:  usb1 == 2 */
-
-	u8		hmc_mode;
-
-	/* implicitly true if otg:  host supports remote wakeup? */
-	u8		rwc;
-
-	/* signaling pins used to talk to transceiver on usbN:
-	 *  0 == usbN unused
-	 *  2 == usb0-only, using internal transceiver
-	 *  3 == 3 wire bidirectional
-	 *  4 == 4 wire bidirectional
-	 *  6 == 6 wire unidirectional (or TLL)
-	 */
-	u8		pins[3];
-
-	struct platform_device *udc_device;
-	struct platform_device *ohci_device;
-	struct platform_device *otg_device;
-
-	u32 (*usb0_init)(unsigned nwires, unsigned is_device);
-	u32 (*usb1_init)(unsigned nwires);
-	u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
-
-	int (*ocpi_enable)(void);
-};
+#include <linux/platform_data/usb-omap1.h>
 
 void omap_otg_init(struct omap_usb_config *config);
 
include/linux/platform_data/usb-omap1.h new file +51 -0
new file mode 100644
index 0000000..8c7764d
@@ -0,0 +1,51 @@
+/*
+ * Platform data for OMAP1 USB
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive for
+ * more details.
+ */
+#ifndef __LINUX_USB_OMAP1_H
+#define __LINUX_USB_OMAP1_H
+
+#include <linux/platform_device.h>
+
+struct omap_usb_config {
+	/* Configure drivers according to the connectors on your board:
+	 *  - "A" connector (rectagular)
+	 *	... for host/OHCI use, set "register_host".
+	 *  - "B" connector (squarish) or "Mini-B"
+	 *	... for device/gadget use, set "register_dev".
+	 *  - "Mini-AB" connector (very similar to Mini-B)
+	 *	... for OTG use as device OR host, initialize "otg"
+	 */
+	unsigned	register_host:1;
+	unsigned	register_dev:1;
+	u8		otg;	/* port number, 1-based:  usb1 == 2 */
+
+	u8		hmc_mode;
+
+	/* implicitly true if otg:  host supports remote wakeup? */
+	u8		rwc;
+
+	/* signaling pins used to talk to transceiver on usbN:
+	 *  0 == usbN unused
+	 *  2 == usb0-only, using internal transceiver
+	 *  3 == 3 wire bidirectional
+	 *  4 == 4 wire bidirectional
+	 *  6 == 6 wire unidirectional (or TLL)
+	 */
+	u8		pins[3];
+
+	struct platform_device *udc_device;
+	struct platform_device *ohci_device;
+	struct platform_device *otg_device;
+
+	u32 (*usb0_init)(unsigned nwires, unsigned is_device);
+	u32 (*usb1_init)(unsigned nwires);
+	u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
+
+	int (*ocpi_enable)(void);
+};
+
+#endif /* __LINUX_USB_OMAP1_H */
Signature · 1 line
1.8.3.1
author maintainer
#3 lore raw

PATCH v2 2/5 USB: OMAP1: add extcon to platform data

In reply to Aaro Koskinen

Add extcon field to platform data.

---
 include/linux/platform_data/usb-omap1.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/platform_data/usb-omap1.h +2 -0
index 8c7764d..43b5ce1 100644
@@ -23,6 +23,8 @@ struct omap_usb_config {
 	unsigned	register_dev:1;
 	u8		otg;	/* port number, 1-based:  usb1 == 2 */
 
+	const char	*extcon;	/* extcon device for OTG */
+
 	u8		hmc_mode;
 
 	/* implicitly true if otg:  host supports remote wakeup? */
Signature · 1 line
1.8.3.1
author maintainer
#4 lore raw

PATCH v2 3/5 USB: OMAP1: OTG controller driver

In reply to Aaro Koskinen

Transceivers need to manage OTG controller state on OMAP1 to enable switching between peripheral and host modes. Provide a driver for that.

---
 drivers/usb/phy/Kconfig        |  10 +++
 drivers/usb/phy/Makefile       |   1 +
 drivers/usb/phy/phy-omap-otg.c | 171 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 182 insertions(+)
 create mode 100644 drivers/usb/phy/phy-omap-otg.c
drivers/usb/phy/Kconfig +10 -0
index 7ef3eb8..14a50bd 100644
@@ -135,6 +135,16 @@ config USB_GPIO_VBUS
 	  optionally control of a D+ pullup GPIO as well as a VBUS
 	  current limit regulator.
 
+config OMAP_OTG
+	tristate "OMAP USB OTG controller driver"
+	depends on ARCH_OMAP_OTG && EXTCON
+	help
+	  Enable this to support some transceivers on OMAP1 platforms. OTG
+	  controller is needed to switch between host and peripheral modes.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called omap-otg.
+
 config USB_ISP1301
 	tristate "NXP ISP1301 USB transceiver support"
 	depends on USB || USB_GADGET
drivers/usb/phy/Makefile +1 -0
index a9169cb..c7f391b 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_ISP1301_OMAP)		+= phy-isp1301-omap.o
 obj-$(CONFIG_MV_U3D_PHY)		+= phy-mv-u3d-usb.o
 obj-$(CONFIG_NOP_USB_XCEIV)		+= phy-nop.o
 obj-$(CONFIG_OMAP_CONTROL_USB)		+= phy-omap-control.o
+obj-$(CONFIG_OMAP_OTG)			+= phy-omap-otg.o
 obj-$(CONFIG_OMAP_USB2)			+= phy-omap-usb2.o
 obj-$(CONFIG_OMAP_USB3)			+= phy-omap-usb3.o
 obj-$(CONFIG_SAMSUNG_USBPHY)		+= phy-samsung-usb.o
drivers/usb/phy/phy-omap-otg.c new file +171 -0

171 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v2 3/5 USB: OMAP1: OTG controller driver

Quoted 69 lines · Aaro Koskinen

Transceivers need to manage OTG controller state on OMAP1 to enable switching between peripheral and host modes. Provide a driver for that.

---
 drivers/usb/phy/Kconfig        |  10 +++
 drivers/usb/phy/Makefile       |   1 +
 drivers/usb/phy/phy-omap-otg.c | 171 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 182 insertions(+)
 create mode 100644 drivers/usb/phy/phy-omap-otg.c
drivers/usb/phy/Kconfig +10 -0
index 7ef3eb8..14a50bd 100644
@@ -135,6 +135,16 @@ config USB_GPIO_VBUS
 	  optionally control of a D+ pullup GPIO as well as a VBUS
 	  current limit regulator.
 
+config OMAP_OTG
+	tristate "OMAP USB OTG controller driver"
+	depends on ARCH_OMAP_OTG && EXTCON
+	help
+	  Enable this to support some transceivers on OMAP1 platforms. OTG
+	  controller is needed to switch between host and peripheral modes.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called omap-otg.
+
 config USB_ISP1301
 	tristate "NXP ISP1301 USB transceiver support"
 	depends on USB || USB_GADGET
drivers/usb/phy/Makefile +1 -0
index a9169cb..c7f391b 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_ISP1301_OMAP)		+= phy-isp1301-omap.o
 obj-$(CONFIG_MV_U3D_PHY)		+= phy-mv-u3d-usb.o
 obj-$(CONFIG_NOP_USB_XCEIV)		+= phy-nop.o
 obj-$(CONFIG_OMAP_CONTROL_USB)		+= phy-omap-control.o
+obj-$(CONFIG_OMAP_OTG)			+= phy-omap-otg.o
 obj-$(CONFIG_OMAP_USB2)			+= phy-omap-usb2.o
 obj-$(CONFIG_OMAP_USB3)			+= phy-omap-usb3.o
 obj-$(CONFIG_SAMSUNG_USBPHY)		+= phy-samsung-usb.o
drivers/usb/phy/phy-omap-otg.c new file +19 -0
new file mode 100644
index 0000000..2a8c674
@@ -0,0 +1,171 @@
+/*
+ * OMAP OTG controller driver
+ *
+ * Based on code from tahvo-usb.c and isp1301_omap.c drivers.
+ *
+ * Copyright (C) 2005-2006 Nokia Corporation
+ * Copyright (C) 2004 Texas Instruments
+ * Copyright (C) 2004 David Brownell
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+

drivers/usb/phy/phy-omap-otg.c line 29

Quoted 10 lines
drivers/usb/phy/phy-omap-otg.c new file +10 -0
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/extcon.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/platform_data/usb-omap1.h>
+
+#include <mach/usb.h>

no mach/* includes under drivers/usb, sorry. It's a pain to fix those up later.

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130618/c0767acf/attachment.sig>
author maintainer
#6 lore raw

PATCH v2 3/5 USB: OMAP1: OTG controller driver

Hi,

Quoted 5 lines · Felipe Balbi
Quoted 1 line · Aaro Koskinen

+#include <mach/usb.h>

no mach/* includes under drivers/usb, sorry. It's a pain to fix those up later.

Sorry, that was left there by a mistake. I will fix.

A.

author maintainer
#7 lore raw

PATCH v2 4/5 USB: OMAP1: Tahvo USB transceiver driver

In reply to Aaro Koskinen

Add Tahvo USB transceiver driver.

Based on old code from linux-omap tree. The original driver was written by Juha Yrj?l?, Tony Lindgren, and Timo Ter?s.

---
 drivers/usb/phy/Kconfig     |  14 ++
 drivers/usb/phy/Makefile    |   1 +
 drivers/usb/phy/phy-tahvo.c | 448 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 463 insertions(+)
 create mode 100644 drivers/usb/phy/phy-tahvo.c
drivers/usb/phy/Kconfig +14 -0
index 14a50bd..a5c7937 100644
@@ -145,6 +145,20 @@ config OMAP_OTG
 	  This driver can also be built as a module. If so, the module
 	  will be called omap-otg.
 
+config TAHVO_USB
+	tristate "Tahvo USB transceiver driver"
+	depends on MFD_RETU && EXTCON
+	help
+	  Enable this to support USB transceiver on Tahvo. This is used
+	  at least on Nokia 770.
+
+config TAHVO_USB_HOST_BY_DEFAULT
+	depends on TAHVO_USB
+	boolean "Device in USB host mode by default"
+	help
+	  Say Y here, if you want the device to enter USB host mode
+	  by default on bootup.
+
 config USB_ISP1301
 	tristate "NXP ISP1301 USB transceiver support"
 	depends on USB || USB_GADGET
drivers/usb/phy/Makefile +1 -0
index c7f391b..f3984d1 100644
@@ -13,6 +13,7 @@ phy-fsl-usb2-objs			:= phy-fsl-usb.o phy-fsm-usb.o
 obj-$(CONFIG_FSL_USB2_OTG)		+= phy-fsl-usb2.o
 obj-$(CONFIG_ISP1301_OMAP)		+= phy-isp1301-omap.o
 obj-$(CONFIG_MV_U3D_PHY)		+= phy-mv-u3d-usb.o
+obj-$(CONFIG_TAHVO_USB)			+= phy-tahvo.o
 obj-$(CONFIG_NOP_USB_XCEIV)		+= phy-nop.o
 obj-$(CONFIG_OMAP_CONTROL_USB)		+= phy-omap-control.o
 obj-$(CONFIG_OMAP_OTG)			+= phy-omap-otg.o
drivers/usb/phy/phy-tahvo.c new file +448 -0

448 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author maintainer
#8 lore raw

PATCH v2 5/5 ARM: OMAP1: nokia770: enable Tahvo

In reply to Aaro Koskinen

Add platform data for Tahvo.

---
 arch/arm/mach-omap1/board-nokia770.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/mach-omap1/board-nokia770.c +11 -0
index 62a15e2..85089d8 100644
@@ -156,6 +156,7 @@ static struct omap_usb_config nokia770_usb_config __initdata = {
 	.register_dev	= 1,
 	.hmc_mode	= 16,
 	.pins[0]	= 6,
+	.extcon		= "tahvo-usb",
 };
 
 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
@@ -234,16 +235,26 @@ static struct i2c_board_info nokia770_i2c_board_info_2[] __initdata = {
 	{
 		I2C_BOARD_INFO("retu-mfd", 0x01),
 	},
+	{
+		I2C_BOARD_INFO("tahvo-mfd", 0x02),
+	},
 };
 
 static void __init nokia770_cbus_init(void)
 {
 	const int retu_irq_gpio = 62;
+	const int tahvo_irq_gpio = 40;
 
 	if (gpio_request_one(retu_irq_gpio, GPIOF_IN, "Retu IRQ"))
 		return;
+	if (gpio_request_one(tahvo_irq_gpio, GPIOF_IN, "Tahvo IRQ")) {
+		gpio_free(retu_irq_gpio);
+		return;
+	}
 	irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
+	irq_set_irq_type(gpio_to_irq(tahvo_irq_gpio), IRQ_TYPE_EDGE_RISING);
 	nokia770_i2c_board_info_2[0].irq = gpio_to_irq(retu_irq_gpio);
+	nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio);
 	i2c_register_board_info(2, nokia770_i2c_board_info_2,
 				ARRAY_SIZE(nokia770_i2c_board_info_2));
 	platform_device_register(&nokia770_cbus_device);
Signature · 1 line
1.8.3.1
reviewer
#9 lore raw

PATCH v2 5/5 ARM: OMAP1: nokia770: enable Tahvo

Quoted 3 lines · Aaro Koskinen

Add platform data for Tahvo.

Thanks, applying into omap-for-v3.11/board. I left out the .extcon entry to remove the dependency to the USB patches.

Then the rest of the series can be queued along with other USB patches, and you can do a follow-up patch to patch in .extcon.

Regards,

Tony