Blame view

arch/arm/mach-omap2/usb-musb.c 3.01 KB
18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  /*
   * linux/arch/arm/mach-omap2/usb-musb.c
   *
   * This file will contain the board specific details for the
   * MENTOR USB OTG controller on OMAP3430
   *
   * Copyright (C) 2007-2008 Texas Instruments
   * Copyright (C) 2008 Nokia Corporation
   * Author: Vikram Pandita
   *
   * Generalization by:
   * Felipe Balbi <felipe.balbi@nokia.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.
   */
  
  #include <linux/types.h>
  #include <linux/errno.h>
  #include <linux/delay.h>
  #include <linux/platform_device.h>
  #include <linux/clk.h>
  #include <linux/dma-mapping.h>
  #include <linux/io.h>
  
  #include <linux/usb/musb.h>
  
  #include <mach/hardware.h>
  #include <mach/irqs.h>
3a0d30bcd   Ajay Kumar Gupta   USB: AM35x: Add m...
31
  #include <mach/am35xx.h>
ce491cf85   Tony Lindgren   omap: headers: Mo...
32
  #include <plat/usb.h>
18a26892d   Hema HK   OMAP2+: musb: hwm...
33
  #include <plat/omap_device.h>
2aae4221e   Anand Gadiyar   arm: omap4: usb: ...
34
  #include "mux.h"
18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
35

18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
36
37
38
  static struct musb_hdrc_config musb_config = {
  	.multipoint	= 1,
  	.dyn_fifo	= 1,
18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
39
  	.num_eps	= 16,
18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
40
  	.ram_bits	= 12,
18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
41
42
43
44
45
46
47
48
49
50
51
  };
  
  static struct musb_hdrc_platform_data musb_plat = {
  #ifdef CONFIG_USB_MUSB_OTG
  	.mode		= MUSB_OTG,
  #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  	.mode		= MUSB_HOST,
  #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  	.mode		= MUSB_PERIPHERAL,
  #endif
  	/* .clock is set dynamically */
18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
52
53
54
55
56
57
58
59
  	.config		= &musb_config,
  
  	/* REVISIT charge pump on TWL4030 can supply up to
  	 * 100 mA ... but this value is board-specific, like
  	 * "mode", and should be passed to usb_musb_init().
  	 */
  	.power		= 50,			/* up to 100 mA */
  };
e930438c4   Yang Hongyang   Replace all DMA_n...
60
  static u64 musb_dmamask = DMA_BIT_MASK(32);
18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
61

9e18630b6   Mike Rapoport   omap: musb: intro...
62
63
64
65
66
67
68
  static struct omap_musb_board_data musb_default_board_data = {
  	.interface_type		= MUSB_INTERFACE_ULPI,
  	.mode			= MUSB_OTG,
  	.power			= 100,
  };
  
  void __init usb_musb_init(struct omap_musb_board_data *musb_board_data)
18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
69
  {
18a26892d   Hema HK   OMAP2+: musb: hwm...
70
  	struct omap_hwmod		*oh;
18a26892d   Hema HK   OMAP2+: musb: hwm...
71
72
73
74
  	struct platform_device		*pdev;
  	struct device			*dev;
  	int				bus_id = -1;
  	const char			*oh_name, *name;
9e18630b6   Mike Rapoport   omap: musb: intro...
75
76
77
78
79
80
  	struct omap_musb_board_data	*board_data;
  
  	if (musb_board_data)
  		board_data = musb_board_data;
  	else
  		board_data = &musb_default_board_data;
2aae4221e   Anand Gadiyar   arm: omap4: usb: ...
81

18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
82
83
84
85
86
  	/*
  	 * REVISIT: This line can be removed once all the platforms using
  	 * musb_core.c have been converted to use use clkdev.
  	 */
  	musb_plat.clock = "ick";
884b8369e   Maulik Mankad   omap: musb: Pass ...
87
88
89
  	musb_plat.board_data = board_data;
  	musb_plat.power = board_data->power >> 1;
  	musb_plat.mode = board_data->mode;
58815fa3b   Ajay Kumar Gupta   usb: musb: Add ex...
90
  	musb_plat.extvbus = board_data->extvbus;
18cb7aca6   Felipe Balbi   ARM: OMAP3: MUSB ...
91

18a26892d   Hema HK   OMAP2+: musb: hwm...
92
93
94
95
96
97
98
  	if (cpu_is_omap3517() || cpu_is_omap3505()) {
  		oh_name = "am35x_otg_hs";
  		name = "musb-am35x";
  	} else {
  		oh_name = "usb_otg_hs";
  		name = "musb-omap2430";
  	}
c541c15fb   Tony Lindgren   Merge branches 'c...
99
100
101
102
103
          oh = omap_hwmod_lookup(oh_name);
          if (WARN(!oh, "%s: could not find omap_hwmod for %s
  ",
                   __func__, oh_name))
                  return;
18a26892d   Hema HK   OMAP2+: musb: hwm...
104

c541c15fb   Tony Lindgren   Merge branches 'c...
105
  	pdev = omap_device_build(name, bus_id, oh, &musb_plat,
f718e2c03   Benoit Cousson   ARM: OMAP2+: devi...
106
  			       sizeof(musb_plat), NULL, 0, false);
c541c15fb   Tony Lindgren   Merge branches 'c...
107
  	if (IS_ERR(pdev)) {
18a26892d   Hema HK   OMAP2+: musb: hwm...
108
109
110
111
112
  		pr_err("Could not build omap_device for %s %s
  ",
  						name, oh_name);
  		return;
  	}
18a26892d   Hema HK   OMAP2+: musb: hwm...
113
114
115
116
117
  	dev = &pdev->dev;
  	get_device(dev);
  	dev->dma_mask = &musb_dmamask;
  	dev->coherent_dma_mask = musb_dmamask;
  	put_device(dev);
1f1584880   Hema HK   usb: musb: OMAP44...
118
119
120
  
  	if (cpu_is_omap44xx())
  		omap4430_phy_init(dev);
94a3ef6f2   Peter 'p2' De Schrijver   OMAP3: PM: Ensure...
121
  }