596-cbus-tahvo-usb-clk.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. --- a/drivers/cbus/tahvo-usb.c
  2. +++ b/drivers/cbus/tahvo-usb.c
  3. @@ -98,6 +98,7 @@ struct tahvo_usb {
  4. #ifdef CONFIG_USB_OTG
  5. int tahvo_mode;
  6. #endif
  7. + struct clk *ick;
  8. };
  9. static struct tahvo_usb *tahvo_usb_device;
  10. @@ -673,6 +674,14 @@ static int __init tahvo_usb_probe(struct
  11. INIT_WORK(&tu->irq_work, tahvo_usb_irq_work);
  12. mutex_init(&tu->serialize);
  13. + tu->ick = clk_get(NULL, "usb_l4_ick");
  14. + if (IS_ERR(tu->ick)) {
  15. + dev_err(dev, "Failed to get usb_l4_ick\n");
  16. + ret = PTR_ERR(tu->ick);
  17. + goto err_free_tu;
  18. + }
  19. + clk_enable(tu->ick);
  20. +
  21. /* Set initial state, so that we generate kevents only on
  22. * state changes */
  23. tu->vbus_state = tahvo_read_reg(TAHVO_REG_IDSR) & 0x01;
  24. @@ -681,10 +690,8 @@ static int __init tahvo_usb_probe(struct
  25. ret = tahvo_request_irq(TAHVO_INT_VBUSON, tahvo_usb_vbus_interrupt,
  26. (unsigned long) tu, "vbus_interrupt");
  27. if (ret != 0) {
  28. - kfree(tu);
  29. - tahvo_usb_device = NULL;
  30. printk(KERN_ERR "Could not register Tahvo interrupt for VBUS\n");
  31. - return ret;
  32. + goto err_release_clk;
  33. }
  34. /* Attributes */
  35. @@ -709,10 +716,7 @@ static int __init tahvo_usb_probe(struct
  36. ret = otg_set_transceiver(&tu->otg);
  37. if (ret < 0) {
  38. printk(KERN_ERR "Cannot register USB transceiver\n");
  39. - tahvo_usb_device = NULL;
  40. - kfree(tu);
  41. - tahvo_free_irq(TAHVO_INT_VBUSON);
  42. - return ret;
  43. + goto err_free_irq;
  44. }
  45. dev_set_drvdata(dev, tu);
  46. @@ -721,6 +725,17 @@ static int __init tahvo_usb_probe(struct
  47. * may not be generated in addition to this. */
  48. schedule_work(&tu->irq_work);
  49. return 0;
  50. +
  51. +err_free_irq:
  52. + tahvo_free_irq(TAHVO_INT_VBUSON);
  53. +err_release_clk:
  54. + clk_disable(tu->ick);
  55. + clk_put(tu->ick);
  56. +err_free_tu:
  57. + kfree(tu);
  58. + tahvo_usb_device = NULL;
  59. +
  60. + return ret;
  61. }
  62. static int __exit tahvo_usb_remove(struct platform_device *pdev)
  63. @@ -736,6 +751,8 @@ static int __exit tahvo_usb_remove(struc
  64. #ifdef CONFIG_USB_OTG
  65. device_remove_file(&pdev->dev, &dev_attr_otg_mode);
  66. #endif
  67. + clk_disable(tu->ick);
  68. + clk_put(tu->ick);
  69. kfree(tu);
  70. tahvo_usb_device = NULL;