Commit 9d9c6ae7 authored by Roger Quadros's avatar Roger Quadros

mfd: omap-usb-host: Consolidate OMAP USB-HS platform data (part 2/3)

Let's have a single platform data structure for the OMAP's High-Speed
USB host subsystem instead of having 3 separate ones i.e. one for
board data, one for USB Host (UHH) module and one for USB-TLL module.

This makes the code much simpler and avoids creating multiple copies of
platform data.
Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
Reviewed-by: default avatarFelipe Balbi <balbi@ti.com>
For the ehci-omap.c part:
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
parent 7f07863e
...@@ -102,7 +102,7 @@ struct usbhs_hcd_omap { ...@@ -102,7 +102,7 @@ struct usbhs_hcd_omap {
void __iomem *uhh_base; void __iomem *uhh_base;
struct usbhs_omap_platform_data platdata; struct usbhs_omap_platform_data *pdata;
u32 usbhs_rev; u32 usbhs_rev;
spinlock_t lock; spinlock_t lock;
...@@ -184,19 +184,13 @@ static struct platform_device *omap_usbhs_alloc_child(const char *name, ...@@ -184,19 +184,13 @@ static struct platform_device *omap_usbhs_alloc_child(const char *name,
static int omap_usbhs_alloc_children(struct platform_device *pdev) static int omap_usbhs_alloc_children(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct usbhs_hcd_omap *omap; struct usbhs_omap_platform_data *pdata = dev->platform_data;
struct ehci_hcd_omap_platform_data *ehci_data;
struct ohci_hcd_omap_platform_data *ohci_data;
struct platform_device *ehci; struct platform_device *ehci;
struct platform_device *ohci; struct platform_device *ohci;
struct resource *res; struct resource *res;
struct resource resources[2]; struct resource resources[2];
int ret; int ret;
omap = platform_get_drvdata(pdev);
ehci_data = omap->platdata.ehci_data;
ohci_data = omap->platdata.ohci_data;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ehci"); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ehci");
if (!res) { if (!res) {
dev_err(dev, "EHCI get resource IORESOURCE_MEM failed\n"); dev_err(dev, "EHCI get resource IORESOURCE_MEM failed\n");
...@@ -213,8 +207,8 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev) ...@@ -213,8 +207,8 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev)
} }
resources[1] = *res; resources[1] = *res;
ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, ehci_data, ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, pdata,
sizeof(*ehci_data), dev); sizeof(*pdata), dev);
if (!ehci) { if (!ehci) {
dev_err(dev, "omap_usbhs_alloc_child failed\n"); dev_err(dev, "omap_usbhs_alloc_child failed\n");
...@@ -238,8 +232,8 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev) ...@@ -238,8 +232,8 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev)
} }
resources[1] = *res; resources[1] = *res;
ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, ohci_data, ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, pdata,
sizeof(*ohci_data), dev); sizeof(*pdata), dev);
if (!ohci) { if (!ohci) {
dev_err(dev, "omap_usbhs_alloc_child failed\n"); dev_err(dev, "omap_usbhs_alloc_child failed\n");
ret = -ENOMEM; ret = -ENOMEM;
...@@ -278,7 +272,7 @@ static bool is_ohci_port(enum usbhs_omap_port_mode pmode) ...@@ -278,7 +272,7 @@ static bool is_ohci_port(enum usbhs_omap_port_mode pmode)
static int usbhs_runtime_resume(struct device *dev) static int usbhs_runtime_resume(struct device *dev)
{ {
struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = &omap->platdata; struct usbhs_omap_platform_data *pdata = omap->pdata;
unsigned long flags; unsigned long flags;
dev_dbg(dev, "usbhs_runtime_resume\n"); dev_dbg(dev, "usbhs_runtime_resume\n");
...@@ -310,7 +304,7 @@ static int usbhs_runtime_resume(struct device *dev) ...@@ -310,7 +304,7 @@ static int usbhs_runtime_resume(struct device *dev)
static int usbhs_runtime_suspend(struct device *dev) static int usbhs_runtime_suspend(struct device *dev)
{ {
struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = &omap->platdata; struct usbhs_omap_platform_data *pdata = omap->pdata;
unsigned long flags; unsigned long flags;
dev_dbg(dev, "usbhs_runtime_suspend\n"); dev_dbg(dev, "usbhs_runtime_suspend\n");
...@@ -342,19 +336,19 @@ static int usbhs_runtime_suspend(struct device *dev) ...@@ -342,19 +336,19 @@ static int usbhs_runtime_suspend(struct device *dev)
static void omap_usbhs_init(struct device *dev) static void omap_usbhs_init(struct device *dev)
{ {
struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = &omap->platdata; struct usbhs_omap_platform_data *pdata = omap->pdata;
unsigned long flags; unsigned long flags;
unsigned reg; unsigned reg;
dev_dbg(dev, "starting TI HSUSB Controller\n"); dev_dbg(dev, "starting TI HSUSB Controller\n");
if (pdata->ehci_data->phy_reset) { if (pdata->phy_reset) {
if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) if (gpio_is_valid(pdata->reset_gpio_port[0]))
gpio_request_one(pdata->ehci_data->reset_gpio_port[0], gpio_request_one(pdata->reset_gpio_port[0],
GPIOF_OUT_INIT_LOW, "USB1 PHY reset"); GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) if (gpio_is_valid(pdata->reset_gpio_port[1]))
gpio_request_one(pdata->ehci_data->reset_gpio_port[1], gpio_request_one(pdata->reset_gpio_port[1],
GPIOF_OUT_INIT_LOW, "USB2 PHY reset"); GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
/* Hold the PHY in RESET for enough time till DIR is high */ /* Hold the PHY in RESET for enough time till DIR is high */
...@@ -430,33 +424,33 @@ static void omap_usbhs_init(struct device *dev) ...@@ -430,33 +424,33 @@ static void omap_usbhs_init(struct device *dev)
spin_unlock_irqrestore(&omap->lock, flags); spin_unlock_irqrestore(&omap->lock, flags);
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
if (pdata->ehci_data->phy_reset) { if (pdata->phy_reset) {
/* Hold the PHY in RESET for enough time till /* Hold the PHY in RESET for enough time till
* PHY is settled and ready * PHY is settled and ready
*/ */
udelay(10); udelay(10);
if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) if (gpio_is_valid(pdata->reset_gpio_port[0]))
gpio_set_value_cansleep gpio_set_value_cansleep
(pdata->ehci_data->reset_gpio_port[0], 1); (pdata->reset_gpio_port[0], 1);
if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) if (gpio_is_valid(pdata->reset_gpio_port[1]))
gpio_set_value_cansleep gpio_set_value_cansleep
(pdata->ehci_data->reset_gpio_port[1], 1); (pdata->reset_gpio_port[1], 1);
} }
} }
static void omap_usbhs_deinit(struct device *dev) static void omap_usbhs_deinit(struct device *dev)
{ {
struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = &omap->platdata; struct usbhs_omap_platform_data *pdata = omap->pdata;
if (pdata->ehci_data->phy_reset) { if (pdata->phy_reset) {
if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) if (gpio_is_valid(pdata->reset_gpio_port[0]))
gpio_free(pdata->ehci_data->reset_gpio_port[0]); gpio_free(pdata->reset_gpio_port[0]);
if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) if (gpio_is_valid(pdata->reset_gpio_port[1]))
gpio_free(pdata->ehci_data->reset_gpio_port[1]); gpio_free(pdata->reset_gpio_port[1]);
} }
} }
...@@ -490,15 +484,10 @@ static int usbhs_omap_probe(struct platform_device *pdev) ...@@ -490,15 +484,10 @@ static int usbhs_omap_probe(struct platform_device *pdev)
spin_lock_init(&omap->lock); spin_lock_init(&omap->lock);
for (i = 0; i < OMAP3_HS_USB_PORTS; i++) omap->pdata = pdata;
omap->platdata.port_mode[i] = pdata->port_mode[i];
omap->platdata.ehci_data = pdata->ehci_data;
omap->platdata.ohci_data = pdata->ohci_data;
pm_runtime_enable(dev); pm_runtime_enable(dev);
for (i = 0; i < OMAP3_HS_USB_PORTS; i++) for (i = 0; i < OMAP3_HS_USB_PORTS; i++)
if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) || if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) ||
is_ehci_hsic_mode(i)) { is_ehci_hsic_mode(i)) {
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
struct usbtll_omap { struct usbtll_omap {
struct clk *usbtll_p1_fck; struct clk *usbtll_p1_fck;
struct clk *usbtll_p2_fck; struct clk *usbtll_p2_fck;
struct usbtll_omap_platform_data platdata; struct usbhs_omap_platform_data *pdata;
/* secure the register updates */ /* secure the register updates */
spinlock_t lock; spinlock_t lock;
}; };
...@@ -203,7 +203,7 @@ static unsigned ohci_omap3_fslsmode(enum usbhs_omap_port_mode mode) ...@@ -203,7 +203,7 @@ static unsigned ohci_omap3_fslsmode(enum usbhs_omap_port_mode mode)
static int usbtll_omap_probe(struct platform_device *pdev) static int usbtll_omap_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct usbtll_omap_platform_data *pdata = dev->platform_data; struct usbhs_omap_platform_data *pdata = dev->platform_data;
void __iomem *base; void __iomem *base;
struct resource *res; struct resource *res;
struct usbtll_omap *tll; struct usbtll_omap *tll;
...@@ -223,8 +223,7 @@ static int usbtll_omap_probe(struct platform_device *pdev) ...@@ -223,8 +223,7 @@ static int usbtll_omap_probe(struct platform_device *pdev)
spin_lock_init(&tll->lock); spin_lock_init(&tll->lock);
for (i = 0; i < OMAP3_HS_USB_PORTS; i++) tll->pdata = pdata;
tll->platdata.port_mode[i] = pdata->port_mode[i];
tll->usbtll_p1_fck = clk_get(dev, "usb_tll_hs_usb_ch0_clk"); tll->usbtll_p1_fck = clk_get(dev, "usb_tll_hs_usb_ch0_clk");
if (IS_ERR(tll->usbtll_p1_fck)) { if (IS_ERR(tll->usbtll_p1_fck)) {
...@@ -362,7 +361,7 @@ static int usbtll_omap_remove(struct platform_device *pdev) ...@@ -362,7 +361,7 @@ static int usbtll_omap_remove(struct platform_device *pdev)
static int usbtll_runtime_resume(struct device *dev) static int usbtll_runtime_resume(struct device *dev)
{ {
struct usbtll_omap *tll = dev_get_drvdata(dev); struct usbtll_omap *tll = dev_get_drvdata(dev);
struct usbtll_omap_platform_data *pdata = &tll->platdata; struct usbhs_omap_platform_data *pdata = tll->pdata;
unsigned long flags; unsigned long flags;
dev_dbg(dev, "usbtll_runtime_resume\n"); dev_dbg(dev, "usbtll_runtime_resume\n");
...@@ -388,7 +387,7 @@ static int usbtll_runtime_resume(struct device *dev) ...@@ -388,7 +387,7 @@ static int usbtll_runtime_resume(struct device *dev)
static int usbtll_runtime_suspend(struct device *dev) static int usbtll_runtime_suspend(struct device *dev)
{ {
struct usbtll_omap *tll = dev_get_drvdata(dev); struct usbtll_omap *tll = dev_get_drvdata(dev);
struct usbtll_omap_platform_data *pdata = &tll->platdata; struct usbhs_omap_platform_data *pdata = tll->pdata;
unsigned long flags; unsigned long flags;
dev_dbg(dev, "usbtll_runtime_suspend\n"); dev_dbg(dev, "usbtll_runtime_suspend\n");
......
...@@ -107,7 +107,7 @@ static int omap_ehci_init(struct usb_hcd *hcd) ...@@ -107,7 +107,7 @@ static int omap_ehci_init(struct usb_hcd *hcd)
{ {
struct ehci_hcd *ehci = hcd_to_ehci(hcd); struct ehci_hcd *ehci = hcd_to_ehci(hcd);
int rc; int rc;
struct ehci_hcd_omap_platform_data *pdata; struct usbhs_omap_platform_data *pdata;
pdata = hcd->self.controller->platform_data; pdata = hcd->self.controller->platform_data;
...@@ -151,7 +151,7 @@ static int omap_ehci_init(struct usb_hcd *hcd) ...@@ -151,7 +151,7 @@ static int omap_ehci_init(struct usb_hcd *hcd)
} }
static void disable_put_regulator( static void disable_put_regulator(
struct ehci_hcd_omap_platform_data *pdata) struct usbhs_omap_platform_data *pdata)
{ {
int i; int i;
...@@ -176,7 +176,7 @@ static void disable_put_regulator( ...@@ -176,7 +176,7 @@ static void disable_put_regulator(
static int ehci_hcd_omap_probe(struct platform_device *pdev) static int ehci_hcd_omap_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct ehci_hcd_omap_platform_data *pdata = dev->platform_data; struct usbhs_omap_platform_data *pdata = dev->platform_data;
struct resource *res; struct resource *res;
struct usb_hcd *hcd; struct usb_hcd *hcd;
void __iomem *regs; void __iomem *regs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment