Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: omap-usb-tll: Move configuration code to omap_tll_init()

This is because we want to get rid of platform_data usage from probe().
The only information we need is PORT_MODE, and this can be supplied
to us by the user (i.e. omap-usb-host.c).

We also move channel clock management from runtime PM handlers into
omap_tll_enable/disable().

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Roger Quadros and committed by
Samuel Ortiz
9f4a3ece 662e469e

+109 -111
+5 -2
drivers/mfd/omap-usb-host.c
··· 278 278 279 279 dev_dbg(dev, "usbhs_runtime_resume\n"); 280 280 281 - omap_tll_enable(); 281 + omap_tll_enable(pdata); 282 282 283 283 if (!IS_ERR(omap->ehci_logic_fck)) 284 284 clk_enable(omap->ehci_logic_fck); ··· 353 353 if (!IS_ERR(omap->ehci_logic_fck)) 354 354 clk_disable(omap->ehci_logic_fck); 355 355 356 - omap_tll_disable(); 356 + omap_tll_disable(pdata); 357 357 358 358 return 0; 359 359 } ··· 526 526 } 527 527 528 528 omap->pdata = pdata; 529 + 530 + /* Initialize the TLL subsystem */ 531 + omap_tll_init(pdata); 529 532 530 533 pm_runtime_enable(dev); 531 534
+101 -107
drivers/mfd/omap-usb-tll.c
··· 1 1 /** 2 2 * omap-usb-tll.c - The USB TLL driver for OMAP EHCI & OHCI 3 3 * 4 - * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com 4 + * Copyright (C) 2012-2013 Texas Instruments Incorporated - http://www.ti.com 5 5 * Author: Keshava Munegowda <keshava_mgowda@ti.com> 6 + * Author: Roger Quadros <rogerq@ti.com> 6 7 * 7 8 * This program is free software: you can redistribute it and/or modify 8 9 * it under the terms of the GNU General Public License version 2 of ··· 106 105 107 106 struct usbtll_omap { 108 107 int nch; /* num. of channels */ 109 - struct usbhs_omap_platform_data *pdata; 110 108 struct clk **ch_clk; 109 + void __iomem *base; 111 110 }; 112 111 113 112 /*-------------------------------------------------------------------------*/ ··· 211 210 static int usbtll_omap_probe(struct platform_device *pdev) 212 211 { 213 212 struct device *dev = &pdev->dev; 214 - struct usbhs_omap_platform_data *pdata = dev->platform_data; 215 - void __iomem *base; 216 213 struct resource *res; 217 214 struct usbtll_omap *tll; 218 - unsigned reg; 219 215 int ret = 0; 220 216 int i, ver; 221 - bool needs_tll; 222 217 223 218 dev_dbg(dev, "starting TI HSUSB TLL Controller\n"); 224 219 ··· 224 227 return -ENOMEM; 225 228 } 226 229 227 - if (!pdata) { 228 - dev_err(dev, "Platform data missing\n"); 229 - return -ENODEV; 230 - } 231 - 232 - tll->pdata = pdata; 233 - 234 230 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 235 - base = devm_request_and_ioremap(dev, res); 236 - if (!base) { 231 + tll->base = devm_request_and_ioremap(dev, res); 232 + if (!tll->base) { 237 233 ret = -EADDRNOTAVAIL; 238 234 dev_err(dev, "Resource request/ioremap failed:%d\n", ret); 239 235 return ret; ··· 236 246 pm_runtime_enable(dev); 237 247 pm_runtime_get_sync(dev); 238 248 239 - ver = usbtll_read(base, OMAP_USBTLL_REVISION); 249 + ver = usbtll_read(tll->base, OMAP_USBTLL_REVISION); 240 250 switch (ver) { 241 251 case OMAP_USBTLL_REV1: 242 252 case OMAP_USBTLL_REV4: ··· 273 283 dev_dbg(dev, "can't get clock : %s\n", clkname); 274 284 } 275 285 286 + pm_runtime_put_sync(dev); 287 + /* only after this can omap_tll_enable/disable work */ 288 + spin_lock(&tll_lock); 289 + tll_dev = dev; 290 + spin_unlock(&tll_lock); 291 + 292 + return 0; 293 + 294 + err_clk_alloc: 295 + pm_runtime_put_sync(dev); 296 + pm_runtime_disable(dev); 297 + 298 + return ret; 299 + } 300 + 301 + /** 302 + * usbtll_omap_remove - shutdown processing for UHH & TLL HCDs 303 + * @pdev: USB Host Controller being removed 304 + * 305 + * Reverses the effect of usbtll_omap_probe(). 306 + */ 307 + static int usbtll_omap_remove(struct platform_device *pdev) 308 + { 309 + struct usbtll_omap *tll = platform_get_drvdata(pdev); 310 + int i; 311 + 312 + spin_lock(&tll_lock); 313 + tll_dev = NULL; 314 + spin_unlock(&tll_lock); 315 + 316 + for (i = 0; i < tll->nch; i++) 317 + if (!IS_ERR(tll->ch_clk[i])) 318 + clk_put(tll->ch_clk[i]); 319 + 320 + pm_runtime_disable(&pdev->dev); 321 + return 0; 322 + } 323 + 324 + static struct platform_driver usbtll_omap_driver = { 325 + .driver = { 326 + .name = (char *)usbtll_driver_name, 327 + .owner = THIS_MODULE, 328 + }, 329 + .probe = usbtll_omap_probe, 330 + .remove = usbtll_omap_remove, 331 + }; 332 + 333 + int omap_tll_init(struct usbhs_omap_platform_data *pdata) 334 + { 335 + int i; 336 + bool needs_tll; 337 + unsigned reg; 338 + struct usbtll_omap *tll; 339 + 340 + spin_lock(&tll_lock); 341 + 342 + if (!tll_dev) { 343 + spin_unlock(&tll_lock); 344 + return -ENODEV; 345 + } 346 + 347 + tll = dev_get_drvdata(tll_dev); 348 + 276 349 needs_tll = false; 277 350 for (i = 0; i < tll->nch; i++) 278 351 needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]); 279 352 353 + pm_runtime_get_sync(tll_dev); 354 + 280 355 if (needs_tll) { 356 + void __iomem *base = tll->base; 281 357 282 358 /* Program Common TLL register */ 283 359 reg = usbtll_read(base, OMAP_TLL_SHARED_CONF); ··· 392 336 } 393 337 } 394 338 395 - pm_runtime_put_sync(dev); 396 - /* only after this can omap_tll_enable/disable work */ 397 - spin_lock(&tll_lock); 398 - tll_dev = dev; 339 + pm_runtime_put_sync(tll_dev); 340 + 399 341 spin_unlock(&tll_lock); 400 342 401 343 return 0; 402 - 403 - err_clk_alloc: 404 - pm_runtime_put_sync(dev); 405 - pm_runtime_disable(dev); 406 - 407 - return ret; 408 344 } 345 + EXPORT_SYMBOL_GPL(omap_tll_init); 409 346 410 - /** 411 - * usbtll_omap_remove - shutdown processing for UHH & TLL HCDs 412 - * @pdev: USB Host Controller being removed 413 - * 414 - * Reverses the effect of usbtll_omap_probe(). 415 - */ 416 - static int usbtll_omap_remove(struct platform_device *pdev) 347 + int omap_tll_enable(struct usbhs_omap_platform_data *pdata) 417 348 { 418 - struct usbtll_omap *tll = platform_get_drvdata(pdev); 419 349 int i; 350 + struct usbtll_omap *tll; 420 351 421 352 spin_lock(&tll_lock); 422 - tll_dev = NULL; 423 - spin_unlock(&tll_lock); 424 353 425 - for (i = 0; i < tll->nch; i++) 426 - if (!IS_ERR(tll->ch_clk[i])) 427 - clk_put(tll->ch_clk[i]); 354 + if (!tll_dev) { 355 + spin_unlock(&tll_lock); 356 + return -ENODEV; 357 + } 428 358 429 - pm_runtime_disable(&pdev->dev); 430 - return 0; 431 - } 359 + tll = dev_get_drvdata(tll_dev); 432 360 433 - static int usbtll_runtime_resume(struct device *dev) 434 - { 435 - struct usbtll_omap *tll = dev_get_drvdata(dev); 436 - struct usbhs_omap_platform_data *pdata = tll->pdata; 437 - int i; 438 - 439 - dev_dbg(dev, "usbtll_runtime_resume\n"); 361 + pm_runtime_get_sync(tll_dev); 440 362 441 363 for (i = 0; i < tll->nch; i++) { 442 364 if (omap_usb_mode_needs_tll(pdata->port_mode[i])) { ··· 425 391 426 392 r = clk_enable(tll->ch_clk[i]); 427 393 if (r) { 428 - dev_err(dev, 394 + dev_err(tll_dev, 429 395 "Error enabling ch %d clock: %d\n", i, r); 430 396 } 431 397 } 432 398 } 433 399 400 + spin_unlock(&tll_lock); 401 + 434 402 return 0; 435 403 } 404 + EXPORT_SYMBOL_GPL(omap_tll_enable); 436 405 437 - static int usbtll_runtime_suspend(struct device *dev) 406 + int omap_tll_disable(struct usbhs_omap_platform_data *pdata) 438 407 { 439 - struct usbtll_omap *tll = dev_get_drvdata(dev); 440 - struct usbhs_omap_platform_data *pdata = tll->pdata; 441 408 int i; 409 + struct usbtll_omap *tll; 442 410 443 - dev_dbg(dev, "usbtll_runtime_suspend\n"); 411 + spin_lock(&tll_lock); 412 + 413 + if (!tll_dev) { 414 + spin_unlock(&tll_lock); 415 + return -ENODEV; 416 + } 417 + 418 + tll = dev_get_drvdata(tll_dev); 444 419 445 420 for (i = 0; i < tll->nch; i++) { 446 421 if (omap_usb_mode_needs_tll(pdata->port_mode[i])) { ··· 458 415 } 459 416 } 460 417 418 + pm_runtime_put_sync(tll_dev); 419 + 420 + spin_unlock(&tll_lock); 421 + 461 422 return 0; 462 - } 463 - 464 - static const struct dev_pm_ops usbtllomap_dev_pm_ops = { 465 - SET_RUNTIME_PM_OPS(usbtll_runtime_suspend, 466 - usbtll_runtime_resume, 467 - NULL) 468 - }; 469 - 470 - static struct platform_driver usbtll_omap_driver = { 471 - .driver = { 472 - .name = (char *)usbtll_driver_name, 473 - .owner = THIS_MODULE, 474 - .pm = &usbtllomap_dev_pm_ops, 475 - }, 476 - .probe = usbtll_omap_probe, 477 - .remove = usbtll_omap_remove, 478 - }; 479 - 480 - int omap_tll_enable(void) 481 - { 482 - int ret; 483 - 484 - spin_lock(&tll_lock); 485 - 486 - if (!tll_dev) { 487 - pr_err("%s: OMAP USB TLL not initialized\n", __func__); 488 - ret = -ENODEV; 489 - } else { 490 - ret = pm_runtime_get_sync(tll_dev); 491 - } 492 - 493 - spin_unlock(&tll_lock); 494 - 495 - return ret; 496 - } 497 - EXPORT_SYMBOL_GPL(omap_tll_enable); 498 - 499 - int omap_tll_disable(void) 500 - { 501 - int ret; 502 - 503 - spin_lock(&tll_lock); 504 - 505 - if (!tll_dev) { 506 - pr_err("%s: OMAP USB TLL not initialized\n", __func__); 507 - ret = -ENODEV; 508 - } else { 509 - ret = pm_runtime_put_sync(tll_dev); 510 - } 511 - 512 - spin_unlock(&tll_lock); 513 - 514 - return ret; 515 423 } 516 424 EXPORT_SYMBOL_GPL(omap_tll_disable); 517 425
+3 -2
drivers/mfd/omap-usb.h
··· 1 - extern int omap_tll_enable(void); 2 - extern int omap_tll_disable(void); 1 + extern int omap_tll_init(struct usbhs_omap_platform_data *pdata); 2 + extern int omap_tll_enable(struct usbhs_omap_platform_data *pdata); 3 + extern int omap_tll_disable(struct usbhs_omap_platform_data *pdata);