diff options
author | Eduardo Valentin <eduardo.valentin@ti.com> | 2012-05-30 10:22:19 -0500 |
---|---|---|
committer | Xavier Boudet <x-boudet@ti.com> | 2012-07-10 17:26:55 +0200 |
commit | e8b07f805b99d576119974c0b71d5d78fbeebc82 (patch) | |
tree | f462514034135be17dc75d5c35821abb41fe2fbc | |
parent | 47b1d0b2fefbd0245ccd3d948dd664848b8cefff (diff) |
mfd: omap: control: usb-phy: introduce the ctrl-module usb driver
Created a new platform driver for the platform device created by the
control module mfd core, wrt usb. This driver has API's to power on/off
the phy and the API's to write to musb mailbox.
(p.s. the mailbox for musb in omap4 is present in system control
module)
Change-Id: I3260e7e9b2091b75620b85ede5b2a09d097a9b37
[kishon@ti.com: wrote the original API's related to USB functions]
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Radhesh Fadnis <radhesh.fadnis@ti.com>
-rw-r--r-- | drivers/usb/otg/Kconfig | 13 | ||||
-rw-r--r-- | drivers/usb/otg/Makefile | 1 | ||||
-rw-r--r-- | drivers/usb/otg/omap4-usb-phy.c | 129 | ||||
-rw-r--r-- | include/linux/mfd/omap_control.h | 3 | ||||
-rw-r--r-- | include/linux/usb/omap4_usb_phy.h | 51 |
5 files changed, 197 insertions, 0 deletions
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index 1720ccc76ef9..b91614cc9db7 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig @@ -86,6 +86,19 @@ config TWL6030_USB are hooked to this driver through platform_data structure. The definition of internal PHY APIs are in the mach-omap2 layer. +config OMAP4_USB_PHY + tristate "Texas Instruments OMAP4+ USB pin control driver" + depends on MFD_OMAP_CONTROL + help + If you say yes here you get support for the Texas Instruments + OMAP4+ USB pin control driver. The register set is part of system + control module. + + USB phy in OMAP configures control module register for powering on + the phy, configuring VBUSVALID, AVALID, IDDIG and SESSEND. For + performing the above mentioned configuration, API's are added in + by this children of the control module driver. + config NOP_USB_XCEIV tristate "NOP USB Transceiver Driver" select USB_OTG_UTILS diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile index b64b18e719a4..049238468082 100644 --- a/drivers/usb/otg/Makefile +++ b/drivers/usb/otg/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o obj-$(CONFIG_TWL6030_USB) += twl6030-usb.o +obj-$(CONFIG_OMAP4_USB_PHY) += omap4-usb-phy.o obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o obj-$(CONFIG_USB_ULPI) += ulpi.o obj-$(CONFIG_USB_ULPI_VIEWPORT) += ulpi_viewport.o diff --git a/drivers/usb/otg/omap4-usb-phy.c b/drivers/usb/otg/omap4-usb-phy.c new file mode 100644 index 000000000000..4fb29fc9be47 --- /dev/null +++ b/drivers/usb/otg/omap4-usb-phy.c @@ -0,0 +1,129 @@ +/* + * OMAP4 system control module driver, USB control children + * + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ + * + * Contact: + * Kishon Vijay Abraham I <kishon@ti.com> + * Eduardo Valentin <eduardo.valentin@ti.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/platform_device.h> +#include <linux/mfd/omap_control.h> +#include <linux/usb/omap4_usb_phy.h> + +/** + * omap4_usb_phy_power - power on/off the phy using control module reg + * @dev: struct device * + * @on: 0 or 1, based on powering on or off the PHY + * + * omap_usb2 can call this API to power on or off the PHY. + */ +int omap4_usb_phy_power(struct device *dev, int on) +{ + u32 val; + int ret; + + if (on) { + ret = omap_control_readl(dev, CONTROL_DEV_CONF, &val); + if (!ret && (val & PHY_PD)) { + ret = omap_control_writel(dev, ~PHY_PD, + CONTROL_DEV_CONF); + mdelay(200); + } + } else { + ret = omap_control_writel(dev, PHY_PD, CONTROL_DEV_CONF); + } + + return ret; +} +EXPORT_SYMBOL_GPL(omap4_usb_phy_power); + +/** + * omap4_usb_phy_mailbox - write to usb otg mailbox + * @dev: struct device * + * @val: the value to be written to the mailbox + * + * On detection of a device (ID pin is grounded), the phy should call this API + * to set AVALID, VBUSVALID and ID pin is grounded. + * + * When OMAP is connected to a host (OMAP in device mode), the phy should call + * this API to set AVALID, VBUSVALID and ID pin in high impedance. + * + * The phy should call this API, if OMAP is disconnected from host or device. + */ +int omap4_usb_phy_mailbox(struct device *dev, u32 val) +{ + return omap_control_writel(dev, val, CONTROL_USBOTGHS_CONTROL); +} +EXPORT_SYMBOL_GPL(omap4_usb_phy_mailbox); + +static int __devinit omap_usb_phy_probe(struct platform_device *pdev) +{ + struct omap_control *omap_control; + + omap_control = dev_get_drvdata(pdev->dev.parent); + /* just for the sake */ + if (!omap_control) { + dev_err(&pdev->dev, "no omap_control in our parent\n"); + return -EINVAL; + } + + return 0; +} + +static int __devexit omap_usb_phy_remove(struct platform_device *pdev) +{ + return 0; +} + +static const struct of_device_id of_omap_usb_phy_match[] = { + { .compatible = "ti,omap4-usb-phy", }, + { }, +}; + +static struct platform_driver omap_usb_phy_driver = { + .probe = omap_usb_phy_probe, + .remove = __devexit_p(omap_usb_phy_remove), + .driver = { + .name = "omap4-usb-phy", + .owner = THIS_MODULE, + .of_match_table = of_omap_usb_phy_match, + }, +}; + +static int __init omap_usb_phy_init(void) +{ + return platform_driver_register(&omap_usb_phy_driver); +} +postcore_initcall(omap_usb_phy_init); + +static void __exit omap_usb_phy_exit(void) +{ + platform_driver_unregister(&omap_usb_phy_driver); +} +module_exit(omap_usb_phy_exit); + +MODULE_DESCRIPTION("OMAP4+ USB-phy driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform: omap4-usb-phy"); +MODULE_AUTHOR("Texas Instrument Inc."); diff --git a/include/linux/mfd/omap_control.h b/include/linux/mfd/omap_control.h index b9198828fee0..0ad5dd36c0e6 100644 --- a/include/linux/mfd/omap_control.h +++ b/include/linux/mfd/omap_control.h @@ -22,6 +22,9 @@ #ifndef __DRIVERS_OMAP_CONTROL_H #define __DRIVERS_OMAP_CONTROL_H +#define CONTROL_DEV_CONF 0x00000300 +#define CONTROL_USBOTGHS_CONTROL 0x0000033C + /** * struct system control module - scm device structure * @dev: device pointer diff --git a/include/linux/usb/omap4_usb_phy.h b/include/linux/usb/omap4_usb_phy.h new file mode 100644 index 000000000000..218ce93b39ea --- /dev/null +++ b/include/linux/usb/omap4_usb_phy.h @@ -0,0 +1,51 @@ +/* + * OMAP4 USB-phy + * + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ + * + * Contact: + * Kishon Vijay Abraham I <kishon@ti.com> + * Eduardo Valentin <eduardo.valentin@ti.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#ifndef __OMAP4_USB_PHY_H +#define __OMAP4_USB_PHY_H + +#define PHY_PD 0x1 +#define AVALID BIT(0) +#define BVALID BIT(1) +#define VBUSVALID BIT(2) +#define SESSEND BIT(3) +#define IDDIG BIT(4) + +/* USB-PHY helpers */ +#if (defined(CONFIG_OMAP4_USB_PHY)) || (defined(CONFIG_OMAP4_USB_PHY_MODULE)) +extern int omap4_usb_phy_mailbox(struct device *dev, u32 val); +extern int omap4_usb_phy_power(struct device *dev, int on); +#else +static int omap4_usb_phy_mailbox(struct device *dev, u32 val) +{ + return 0; +} +static int omap4_usb_phy_power(struct device *dev, int on) +{ + return 0; +} +#endif + +#endif |