common.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. /*
  2. * Renesas USB driver
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. *
  16. */
  17. #include <linux/err.h>
  18. #include <linux/gpio.h>
  19. #include <linux/io.h>
  20. #include <linux/module.h>
  21. #include <linux/pm_runtime.h>
  22. #include <linux/slab.h>
  23. #include <linux/sysfs.h>
  24. #include "common.h"
  25. #include "rcar2.h"
  26. /*
  27. * image of renesas_usbhs
  28. *
  29. * ex) gadget case
  30. * mod.c
  31. * mod_gadget.c
  32. * mod_host.c pipe.c fifo.c
  33. *
  34. * +-------+ +-----------+
  35. * | pipe0 |------>| fifo pio |
  36. * +------------+ +-------+ +-----------+
  37. * | mod_gadget |=====> | pipe1 |--+
  38. * +------------+ +-------+ | +-----------+
  39. * | pipe2 | | +-| fifo dma0 |
  40. * +------------+ +-------+ | | +-----------+
  41. * | mod_host | | pipe3 |<-|--+
  42. * +------------+ +-------+ | +-----------+
  43. * | .... | +--->| fifo dma1 |
  44. * | .... | +-----------+
  45. */
  46. #define USBHSF_RUNTIME_PWCTRL (1 << 0)
  47. /* status */
  48. #define usbhsc_flags_init(p) do {(p)->flags = 0; } while (0)
  49. #define usbhsc_flags_set(p, b) ((p)->flags |= (b))
  50. #define usbhsc_flags_clr(p, b) ((p)->flags &= ~(b))
  51. #define usbhsc_flags_has(p, b) ((p)->flags & (b))
  52. /*
  53. * platform call back
  54. *
  55. * renesas usb support platform callback function.
  56. * Below macro call it.
  57. * if platform doesn't have callback, it return 0 (no error)
  58. */
  59. #define usbhs_platform_call(priv, func, args...)\
  60. (!(priv) ? -ENODEV : \
  61. !((priv)->pfunc.func) ? 0 : \
  62. (priv)->pfunc.func(args))
  63. /*
  64. * common functions
  65. */
  66. u16 usbhs_read(struct usbhs_priv *priv, u32 reg)
  67. {
  68. return ioread16(priv->base + reg);
  69. }
  70. void usbhs_write(struct usbhs_priv *priv, u32 reg, u16 data)
  71. {
  72. iowrite16(data, priv->base + reg);
  73. }
  74. void usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, u16 data)
  75. {
  76. u16 val = usbhs_read(priv, reg);
  77. val &= ~mask;
  78. val |= data & mask;
  79. usbhs_write(priv, reg, val);
  80. }
  81. struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev)
  82. {
  83. return dev_get_drvdata(&pdev->dev);
  84. }
  85. /*
  86. * syscfg functions
  87. */
  88. static void usbhs_sys_clock_ctrl(struct usbhs_priv *priv, int enable)
  89. {
  90. usbhs_bset(priv, SYSCFG, SCKE, enable ? SCKE : 0);
  91. }
  92. void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable)
  93. {
  94. u16 mask = DCFM | DRPD | DPRPU | HSE | USBE;
  95. u16 val = DCFM | DRPD | HSE | USBE;
  96. int has_otg = usbhs_get_dparam(priv, has_otg);
  97. if (has_otg)
  98. usbhs_bset(priv, DVSTCTR, (EXTLP | PWEN), (EXTLP | PWEN));
  99. /*
  100. * if enable
  101. *
  102. * - select Host mode
  103. * - D+ Line/D- Line Pull-down
  104. */
  105. usbhs_bset(priv, SYSCFG, mask, enable ? val : 0);
  106. }
  107. void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable)
  108. {
  109. u16 mask = DCFM | DRPD | DPRPU | HSE | USBE;
  110. u16 val = DPRPU | HSE | USBE;
  111. /*
  112. * if enable
  113. *
  114. * - select Function mode
  115. * - D+ Line Pull-up
  116. */
  117. usbhs_bset(priv, SYSCFG, mask, enable ? val : 0);
  118. }
  119. void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable)
  120. {
  121. usbhs_bset(priv, SYSCFG, DPRPU, enable ? DPRPU : 0);
  122. }
  123. void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode)
  124. {
  125. usbhs_write(priv, TESTMODE, mode);
  126. }
  127. /*
  128. * frame functions
  129. */
  130. int usbhs_frame_get_num(struct usbhs_priv *priv)
  131. {
  132. return usbhs_read(priv, FRMNUM) & FRNM_MASK;
  133. }
  134. /*
  135. * usb request functions
  136. */
  137. void usbhs_usbreq_get_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req)
  138. {
  139. u16 val;
  140. val = usbhs_read(priv, USBREQ);
  141. req->bRequest = (val >> 8) & 0xFF;
  142. req->bRequestType = (val >> 0) & 0xFF;
  143. req->wValue = usbhs_read(priv, USBVAL);
  144. req->wIndex = usbhs_read(priv, USBINDX);
  145. req->wLength = usbhs_read(priv, USBLENG);
  146. }
  147. void usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req)
  148. {
  149. usbhs_write(priv, USBREQ, (req->bRequest << 8) | req->bRequestType);
  150. usbhs_write(priv, USBVAL, req->wValue);
  151. usbhs_write(priv, USBINDX, req->wIndex);
  152. usbhs_write(priv, USBLENG, req->wLength);
  153. usbhs_bset(priv, DCPCTR, SUREQ, SUREQ);
  154. }
  155. /*
  156. * bus/vbus functions
  157. */
  158. void usbhs_bus_send_sof_enable(struct usbhs_priv *priv)
  159. {
  160. u16 status = usbhs_read(priv, DVSTCTR) & (USBRST | UACT);
  161. if (status != USBRST) {
  162. struct device *dev = usbhs_priv_to_dev(priv);
  163. dev_err(dev, "usbhs should be reset\n");
  164. }
  165. usbhs_bset(priv, DVSTCTR, (USBRST | UACT), UACT);
  166. }
  167. void usbhs_bus_send_reset(struct usbhs_priv *priv)
  168. {
  169. usbhs_bset(priv, DVSTCTR, (USBRST | UACT), USBRST);
  170. }
  171. int usbhs_bus_get_speed(struct usbhs_priv *priv)
  172. {
  173. u16 dvstctr = usbhs_read(priv, DVSTCTR);
  174. switch (RHST & dvstctr) {
  175. case RHST_LOW_SPEED:
  176. return USB_SPEED_LOW;
  177. case RHST_FULL_SPEED:
  178. return USB_SPEED_FULL;
  179. case RHST_HIGH_SPEED:
  180. return USB_SPEED_HIGH;
  181. }
  182. return USB_SPEED_UNKNOWN;
  183. }
  184. int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable)
  185. {
  186. struct platform_device *pdev = usbhs_priv_to_pdev(priv);
  187. return usbhs_platform_call(priv, set_vbus, pdev, enable);
  188. }
  189. static void usbhsc_bus_init(struct usbhs_priv *priv)
  190. {
  191. usbhs_write(priv, DVSTCTR, 0);
  192. usbhs_vbus_ctrl(priv, 0);
  193. }
  194. /*
  195. * device configuration
  196. */
  197. int usbhs_set_device_config(struct usbhs_priv *priv, int devnum,
  198. u16 upphub, u16 hubport, u16 speed)
  199. {
  200. struct device *dev = usbhs_priv_to_dev(priv);
  201. u16 usbspd = 0;
  202. u32 reg = DEVADD0 + (2 * devnum);
  203. if (devnum > 10) {
  204. dev_err(dev, "cannot set speed to unknown device %d\n", devnum);
  205. return -EIO;
  206. }
  207. if (upphub > 0xA) {
  208. dev_err(dev, "unsupported hub number %d\n", upphub);
  209. return -EIO;
  210. }
  211. switch (speed) {
  212. case USB_SPEED_LOW:
  213. usbspd = USBSPD_SPEED_LOW;
  214. break;
  215. case USB_SPEED_FULL:
  216. usbspd = USBSPD_SPEED_FULL;
  217. break;
  218. case USB_SPEED_HIGH:
  219. usbspd = USBSPD_SPEED_HIGH;
  220. break;
  221. default:
  222. dev_err(dev, "unsupported speed %d\n", speed);
  223. return -EIO;
  224. }
  225. usbhs_write(priv, reg, UPPHUB(upphub) |
  226. HUBPORT(hubport)|
  227. USBSPD(usbspd));
  228. return 0;
  229. }
  230. /*
  231. * local functions
  232. */
  233. static void usbhsc_set_buswait(struct usbhs_priv *priv)
  234. {
  235. int wait = usbhs_get_dparam(priv, buswait_bwait);
  236. /* set bus wait if platform have */
  237. if (wait)
  238. usbhs_bset(priv, BUSWAIT, 0x000F, wait);
  239. }
  240. /*
  241. * platform default param
  242. */
  243. /* commonly used on old SH-Mobile SoCs */
  244. static u32 usbhsc_default_pipe_type[] = {
  245. USB_ENDPOINT_XFER_CONTROL,
  246. USB_ENDPOINT_XFER_ISOC,
  247. USB_ENDPOINT_XFER_ISOC,
  248. USB_ENDPOINT_XFER_BULK,
  249. USB_ENDPOINT_XFER_BULK,
  250. USB_ENDPOINT_XFER_BULK,
  251. USB_ENDPOINT_XFER_INT,
  252. USB_ENDPOINT_XFER_INT,
  253. USB_ENDPOINT_XFER_INT,
  254. USB_ENDPOINT_XFER_INT,
  255. };
  256. /* commonly used on newer SH-Mobile and R-Car SoCs */
  257. static u32 usbhsc_new_pipe_type[] = {
  258. USB_ENDPOINT_XFER_CONTROL,
  259. USB_ENDPOINT_XFER_ISOC,
  260. USB_ENDPOINT_XFER_ISOC,
  261. USB_ENDPOINT_XFER_BULK,
  262. USB_ENDPOINT_XFER_BULK,
  263. USB_ENDPOINT_XFER_BULK,
  264. USB_ENDPOINT_XFER_INT,
  265. USB_ENDPOINT_XFER_INT,
  266. USB_ENDPOINT_XFER_INT,
  267. USB_ENDPOINT_XFER_BULK,
  268. USB_ENDPOINT_XFER_BULK,
  269. USB_ENDPOINT_XFER_BULK,
  270. USB_ENDPOINT_XFER_BULK,
  271. USB_ENDPOINT_XFER_BULK,
  272. USB_ENDPOINT_XFER_BULK,
  273. USB_ENDPOINT_XFER_BULK,
  274. };
  275. /*
  276. * power control
  277. */
  278. static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable)
  279. {
  280. struct platform_device *pdev = usbhs_priv_to_pdev(priv);
  281. struct device *dev = usbhs_priv_to_dev(priv);
  282. if (enable) {
  283. /* enable PM */
  284. pm_runtime_get_sync(dev);
  285. /* enable platform power */
  286. usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable);
  287. /* USB on */
  288. usbhs_sys_clock_ctrl(priv, enable);
  289. } else {
  290. /* USB off */
  291. usbhs_sys_clock_ctrl(priv, enable);
  292. /* disable platform power */
  293. usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable);
  294. /* disable PM */
  295. pm_runtime_put_sync(dev);
  296. }
  297. }
  298. /*
  299. * hotplug
  300. */
  301. static void usbhsc_hotplug(struct usbhs_priv *priv)
  302. {
  303. struct platform_device *pdev = usbhs_priv_to_pdev(priv);
  304. struct usbhs_mod *mod = usbhs_mod_get_current(priv);
  305. int id;
  306. int enable;
  307. int ret;
  308. /*
  309. * get vbus status from platform
  310. */
  311. enable = usbhs_platform_call(priv, get_vbus, pdev);
  312. /*
  313. * get id from platform
  314. */
  315. id = usbhs_platform_call(priv, get_id, pdev);
  316. if (enable && !mod) {
  317. ret = usbhs_mod_change(priv, id);
  318. if (ret < 0)
  319. return;
  320. dev_dbg(&pdev->dev, "%s enable\n", __func__);
  321. /* power on */
  322. if (usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
  323. usbhsc_power_ctrl(priv, enable);
  324. /* bus init */
  325. usbhsc_set_buswait(priv);
  326. usbhsc_bus_init(priv);
  327. /* module start */
  328. usbhs_mod_call(priv, start, priv);
  329. } else if (!enable && mod) {
  330. dev_dbg(&pdev->dev, "%s disable\n", __func__);
  331. /* module stop */
  332. usbhs_mod_call(priv, stop, priv);
  333. /* bus init */
  334. usbhsc_bus_init(priv);
  335. /* power off */
  336. if (usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
  337. usbhsc_power_ctrl(priv, enable);
  338. usbhs_mod_change(priv, -1);
  339. /* reset phy for next connection */
  340. usbhs_platform_call(priv, phy_reset, pdev);
  341. }
  342. }
  343. /*
  344. * notify hotplug
  345. */
  346. static void usbhsc_notify_hotplug(struct work_struct *work)
  347. {
  348. struct usbhs_priv *priv = container_of(work,
  349. struct usbhs_priv,
  350. notify_hotplug_work.work);
  351. usbhsc_hotplug(priv);
  352. }
  353. static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
  354. {
  355. struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
  356. int delay = usbhs_get_dparam(priv, detection_delay);
  357. /*
  358. * This functions will be called in interrupt.
  359. * To make sure safety context,
  360. * use workqueue for usbhs_notify_hotplug
  361. */
  362. schedule_delayed_work(&priv->notify_hotplug_work,
  363. msecs_to_jiffies(delay));
  364. return 0;
  365. }
  366. /*
  367. * platform functions
  368. */
  369. static int usbhs_probe(struct platform_device *pdev)
  370. {
  371. struct renesas_usbhs_platform_info *info = dev_get_platdata(&pdev->dev);
  372. struct renesas_usbhs_driver_callback *dfunc;
  373. struct usbhs_priv *priv;
  374. struct resource *res, *irq_res;
  375. int ret;
  376. /* check platform information */
  377. if (!info) {
  378. dev_err(&pdev->dev, "no platform information\n");
  379. return -EINVAL;
  380. }
  381. /* platform data */
  382. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  383. irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  384. if (!res || !irq_res) {
  385. dev_err(&pdev->dev, "Not enough Renesas USB platform resources.\n");
  386. return -ENODEV;
  387. }
  388. /* usb private data */
  389. priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
  390. if (!priv) {
  391. dev_err(&pdev->dev, "Could not allocate priv\n");
  392. return -ENOMEM;
  393. }
  394. priv->base = devm_ioremap_resource(&pdev->dev, res);
  395. if (IS_ERR(priv->base))
  396. return PTR_ERR(priv->base);
  397. /*
  398. * care platform info
  399. */
  400. memcpy(&priv->dparam,
  401. &info->driver_param,
  402. sizeof(struct renesas_usbhs_driver_param));
  403. switch (priv->dparam.type) {
  404. case USBHS_TYPE_R8A7790:
  405. case USBHS_TYPE_R8A7791:
  406. priv->pfunc = usbhs_rcar2_ops;
  407. if (!priv->dparam.pipe_type) {
  408. priv->dparam.pipe_type = usbhsc_new_pipe_type;
  409. priv->dparam.pipe_size =
  410. ARRAY_SIZE(usbhsc_new_pipe_type);
  411. }
  412. break;
  413. default:
  414. if (!info->platform_callback.get_id) {
  415. dev_err(&pdev->dev, "no platform callbacks");
  416. return -EINVAL;
  417. }
  418. memcpy(&priv->pfunc,
  419. &info->platform_callback,
  420. sizeof(struct renesas_usbhs_platform_callback));
  421. break;
  422. }
  423. /* set driver callback functions for platform */
  424. dfunc = &info->driver_callback;
  425. dfunc->notify_hotplug = usbhsc_drvcllbck_notify_hotplug;
  426. /* set default param if platform doesn't have */
  427. if (!priv->dparam.pipe_type) {
  428. priv->dparam.pipe_type = usbhsc_default_pipe_type;
  429. priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_default_pipe_type);
  430. }
  431. if (!priv->dparam.pio_dma_border)
  432. priv->dparam.pio_dma_border = 64; /* 64byte */
  433. /* FIXME */
  434. /* runtime power control ? */
  435. if (priv->pfunc.get_vbus)
  436. usbhsc_flags_set(priv, USBHSF_RUNTIME_PWCTRL);
  437. /*
  438. * priv settings
  439. */
  440. priv->irq = irq_res->start;
  441. if (irq_res->flags & IORESOURCE_IRQ_SHAREABLE)
  442. priv->irqflags = IRQF_SHARED;
  443. priv->pdev = pdev;
  444. INIT_DELAYED_WORK(&priv->notify_hotplug_work, usbhsc_notify_hotplug);
  445. spin_lock_init(usbhs_priv_to_lock(priv));
  446. /* call pipe and module init */
  447. ret = usbhs_pipe_probe(priv);
  448. if (ret < 0)
  449. return ret;
  450. ret = usbhs_fifo_probe(priv);
  451. if (ret < 0)
  452. goto probe_end_pipe_exit;
  453. ret = usbhs_mod_probe(priv);
  454. if (ret < 0)
  455. goto probe_end_fifo_exit;
  456. /* dev_set_drvdata should be called after usbhs_mod_init */
  457. platform_set_drvdata(pdev, priv);
  458. /*
  459. * deviece reset here because
  460. * USB device might be used in boot loader.
  461. */
  462. usbhs_sys_clock_ctrl(priv, 0);
  463. /* check GPIO determining if USB function should be enabled */
  464. if (priv->dparam.enable_gpio) {
  465. gpio_request_one(priv->dparam.enable_gpio, GPIOF_IN, NULL);
  466. ret = !gpio_get_value(priv->dparam.enable_gpio);
  467. gpio_free(priv->dparam.enable_gpio);
  468. if (ret) {
  469. dev_warn(&pdev->dev,
  470. "USB function not selected (GPIO %d)\n",
  471. priv->dparam.enable_gpio);
  472. ret = -ENOTSUPP;
  473. goto probe_end_mod_exit;
  474. }
  475. }
  476. /*
  477. * platform call
  478. *
  479. * USB phy setup might depend on CPU/Board.
  480. * If platform has its callback functions,
  481. * call it here.
  482. */
  483. ret = usbhs_platform_call(priv, hardware_init, pdev);
  484. if (ret < 0) {
  485. dev_err(&pdev->dev, "platform prove failed.\n");
  486. goto probe_end_mod_exit;
  487. }
  488. /* reset phy for connection */
  489. usbhs_platform_call(priv, phy_reset, pdev);
  490. /* power control */
  491. pm_runtime_enable(&pdev->dev);
  492. if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) {
  493. usbhsc_power_ctrl(priv, 1);
  494. usbhs_mod_autonomy_mode(priv);
  495. }
  496. /*
  497. * manual call notify_hotplug for cold plug
  498. */
  499. ret = usbhsc_drvcllbck_notify_hotplug(pdev);
  500. if (ret < 0)
  501. goto probe_end_call_remove;
  502. dev_info(&pdev->dev, "probed\n");
  503. return ret;
  504. probe_end_call_remove:
  505. usbhs_platform_call(priv, hardware_exit, pdev);
  506. probe_end_mod_exit:
  507. usbhs_mod_remove(priv);
  508. probe_end_fifo_exit:
  509. usbhs_fifo_remove(priv);
  510. probe_end_pipe_exit:
  511. usbhs_pipe_remove(priv);
  512. dev_info(&pdev->dev, "probe failed\n");
  513. return ret;
  514. }
  515. static int usbhs_remove(struct platform_device *pdev)
  516. {
  517. struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
  518. struct renesas_usbhs_platform_info *info = dev_get_platdata(&pdev->dev);
  519. struct renesas_usbhs_driver_callback *dfunc = &info->driver_callback;
  520. dev_dbg(&pdev->dev, "usb remove\n");
  521. dfunc->notify_hotplug = NULL;
  522. /* power off */
  523. if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
  524. usbhsc_power_ctrl(priv, 0);
  525. pm_runtime_disable(&pdev->dev);
  526. usbhs_platform_call(priv, hardware_exit, pdev);
  527. usbhs_mod_remove(priv);
  528. usbhs_fifo_remove(priv);
  529. usbhs_pipe_remove(priv);
  530. return 0;
  531. }
  532. static int usbhsc_suspend(struct device *dev)
  533. {
  534. struct usbhs_priv *priv = dev_get_drvdata(dev);
  535. struct usbhs_mod *mod = usbhs_mod_get_current(priv);
  536. if (mod) {
  537. usbhs_mod_call(priv, stop, priv);
  538. usbhs_mod_change(priv, -1);
  539. }
  540. if (mod || !usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
  541. usbhsc_power_ctrl(priv, 0);
  542. return 0;
  543. }
  544. static int usbhsc_resume(struct device *dev)
  545. {
  546. struct usbhs_priv *priv = dev_get_drvdata(dev);
  547. struct platform_device *pdev = usbhs_priv_to_pdev(priv);
  548. if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
  549. usbhsc_power_ctrl(priv, 1);
  550. usbhs_platform_call(priv, phy_reset, pdev);
  551. usbhsc_drvcllbck_notify_hotplug(pdev);
  552. return 0;
  553. }
  554. static int usbhsc_runtime_nop(struct device *dev)
  555. {
  556. /* Runtime PM callback shared between ->runtime_suspend()
  557. * and ->runtime_resume(). Simply returns success.
  558. *
  559. * This driver re-initializes all registers after
  560. * pm_runtime_get_sync() anyway so there is no need
  561. * to save and restore registers here.
  562. */
  563. return 0;
  564. }
  565. static const struct dev_pm_ops usbhsc_pm_ops = {
  566. .suspend = usbhsc_suspend,
  567. .resume = usbhsc_resume,
  568. .runtime_suspend = usbhsc_runtime_nop,
  569. .runtime_resume = usbhsc_runtime_nop,
  570. };
  571. static struct platform_driver renesas_usbhs_driver = {
  572. .driver = {
  573. .name = "renesas_usbhs",
  574. .pm = &usbhsc_pm_ops,
  575. },
  576. .probe = usbhs_probe,
  577. .remove = usbhs_remove,
  578. };
  579. module_platform_driver(renesas_usbhs_driver);
  580. MODULE_LICENSE("GPL");
  581. MODULE_DESCRIPTION("Renesas USB driver");
  582. MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");