Skip to content

Commit ca6d1b1

Browse files
Felipe Balbigregkh
authored andcommitted
usb: musb: pass configuration specifics via pdata
Use platform_data to pass musb configuration-specific details to musb driver. This patch will prevent that other platforms selecting HAVE_CLK and enabling musb won't break tree building. The other parts of it will come when linux-omap merge up more omap2/3 board-files. Signed-off-by: Felipe Balbi <[email protected]> Acked-by: Paul Mundt <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f362a47 commit ca6d1b1

File tree

5 files changed

+51
-208
lines changed

5 files changed

+51
-208
lines changed

arch/arm/mach-omap2/usb-tusb6010.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ tusb6010_setup_interface(struct musb_hdrc_platform_data *data,
317317
printk(error, 6, status);
318318
return -ENODEV;
319319
}
320-
data->multipoint = 1;
321320
tusb_device.dev.platform_data = data;
322321

323322
/* REVISIT let the driver know what DMA channels work */

drivers/usb/musb/musb_core.c

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -990,12 +990,6 @@ static void musb_shutdown(struct platform_device *pdev)
990990
* We don't currently use dynamic fifo setup capability to do anything
991991
* more than selecting one of a bunch of predefined configurations.
992992
*/
993-
#ifdef MUSB_C_DYNFIFO_DEF
994-
#define can_dynfifo() 1
995-
#else
996-
#define can_dynfifo() 0
997-
#endif
998-
999993
#if defined(CONFIG_USB_TUSB6010) || \
1000994
defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX)
1001995
static ushort __initdata fifo_mode = 4;
@@ -1008,8 +1002,6 @@ module_param(fifo_mode, ushort, 0);
10081002
MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration");
10091003

10101004

1011-
#define DYN_FIFO_SIZE (1<<(MUSB_C_RAM_BITS+2))
1012-
10131005
enum fifo_style { FIFO_RXTX, FIFO_TX, FIFO_RX } __attribute__ ((packed));
10141006
enum buf_mode { BUF_SINGLE, BUF_DOUBLE } __attribute__ ((packed));
10151007

@@ -1119,11 +1111,12 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
11191111

11201112
c_size = size - 3;
11211113
if (cfg->mode == BUF_DOUBLE) {
1122-
if ((offset + (maxpacket << 1)) > DYN_FIFO_SIZE)
1114+
if ((offset + (maxpacket << 1)) >
1115+
(1 << (musb->config->ram_bits + 2)))
11231116
return -EMSGSIZE;
11241117
c_size |= MUSB_FIFOSZ_DPB;
11251118
} else {
1126-
if ((offset + maxpacket) > DYN_FIFO_SIZE)
1119+
if ((offset + maxpacket) > (1 << (musb->config->ram_bits + 2)))
11271120
return -EMSGSIZE;
11281121
}
11291122

@@ -1219,13 +1212,13 @@ static int __init ep_config_from_table(struct musb *musb)
12191212
/* assert(offset > 0) */
12201213

12211214
/* NOTE: for RTL versions >= 1.400 EPINFO and RAMINFO would
1222-
* be better than static MUSB_C_NUM_EPS and DYN_FIFO_SIZE...
1215+
* be better than static musb->config->num_eps and DYN_FIFO_SIZE...
12231216
*/
12241217

12251218
for (i = 0; i < n; i++) {
12261219
u8 epn = cfg->hw_ep_num;
12271220

1228-
if (epn >= MUSB_C_NUM_EPS) {
1221+
if (epn >= musb->config->num_eps) {
12291222
pr_debug("%s: invalid ep %d\n",
12301223
musb_driver_name, epn);
12311224
continue;
@@ -1242,8 +1235,8 @@ static int __init ep_config_from_table(struct musb *musb)
12421235

12431236
printk(KERN_DEBUG "%s: %d/%d max ep, %d/%d memory\n",
12441237
musb_driver_name,
1245-
n + 1, MUSB_C_NUM_EPS * 2 - 1,
1246-
offset, DYN_FIFO_SIZE);
1238+
n + 1, musb->config->num_eps * 2 - 1,
1239+
offset, (1 << (musb->config->ram_bits + 2)));
12471240

12481241
#ifdef CONFIG_USB_MUSB_HDRC_HCD
12491242
if (!musb->bulk_ep) {
@@ -1270,7 +1263,7 @@ static int __init ep_config_from_hw(struct musb *musb)
12701263

12711264
/* FIXME pick up ep0 maxpacket size */
12721265

1273-
for (epnum = 1; epnum < MUSB_C_NUM_EPS; epnum++) {
1266+
for (epnum = 1; epnum < musb->config->num_eps; epnum++) {
12741267
musb_ep_select(mbase, epnum);
12751268
hw_ep = musb->endpoints + epnum;
12761269

@@ -1424,14 +1417,14 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
14241417
musb->epmask = 1;
14251418

14261419
if (reg & MUSB_CONFIGDATA_DYNFIFO) {
1427-
if (can_dynfifo())
1420+
if (musb->config->dyn_fifo)
14281421
status = ep_config_from_table(musb);
14291422
else {
14301423
ERR("reconfigure software for Dynamic FIFOs\n");
14311424
status = -ENODEV;
14321425
}
14331426
} else {
1434-
if (!can_dynfifo())
1427+
if (!musb->config->dyn_fifo)
14351428
status = ep_config_from_hw(musb);
14361429
else {
14371430
ERR("reconfigure software for static FIFOs\n");
@@ -1788,7 +1781,8 @@ static void musb_irq_work(struct work_struct *data)
17881781
*/
17891782

17901783
static struct musb *__init
1791-
allocate_instance(struct device *dev, void __iomem *mbase)
1784+
allocate_instance(struct device *dev,
1785+
struct musb_hdrc_config *config, void __iomem *mbase)
17921786
{
17931787
struct musb *musb;
17941788
struct musb_hw_ep *ep;
@@ -1820,8 +1814,9 @@ allocate_instance(struct device *dev, void __iomem *mbase)
18201814
musb->mregs = mbase;
18211815
musb->ctrl_base = mbase;
18221816
musb->nIrq = -ENODEV;
1817+
musb->config = config;
18231818
for (epnum = 0, ep = musb->endpoints;
1824-
epnum < MUSB_C_NUM_EPS;
1819+
epnum < musb->config->num_eps;
18251820
epnum++, ep++) {
18261821

18271822
ep->musb = musb;
@@ -1929,7 +1924,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
19291924
}
19301925

19311926
/* allocate */
1932-
musb = allocate_instance(dev, ctrl);
1927+
musb = allocate_instance(dev, plat->config, ctrl);
19331928
if (!musb)
19341929
return -ENOMEM;
19351930

@@ -1987,7 +1982,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
19871982
musb_generic_disable(musb);
19881983

19891984
/* setup musb parts of the core (especially endpoints) */
1990-
status = musb_core_init(plat->multipoint
1985+
status = musb_core_init(plat->config->multipoint
19911986
? MUSB_CONTROLLER_MHDRC
19921987
: MUSB_CONTROLLER_HDRC, musb);
19931988
if (status < 0)

drivers/usb/musb/musb_core.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ struct musb_ep;
5656
#include "musb_debug.h"
5757
#include "musb_dma.h"
5858

59-
#ifdef CONFIG_USB_MUSB_SOC
60-
/*
61-
* Get core configuration from a header converted (by cfg_conv)
62-
* from the Verilog config file generated by the core config utility
63-
*
64-
* For now we assume that header is provided along with other
65-
* arch-specific files. Discrete chips will need a build tweak.
66-
* So will using AHB IDs from silicon that provides them.
67-
*/
68-
#include <asm/arch/hdrc_cnf.h>
69-
#endif
70-
7159
#include "musb_io.h"
7260
#include "musb_regs.h"
7361

@@ -440,6 +428,8 @@ struct musb {
440428
struct usb_gadget_driver *gadget_driver; /* its driver */
441429
#endif
442430

431+
struct musb_hdrc_config *config;
432+
443433
#ifdef MUSB_CONFIG_PROC_FS
444434
struct proc_dir_entry *proc_entry;
445435
#endif

drivers/usb/musb/tusb6010.h

Lines changed: 0 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -230,173 +230,4 @@ extern u8 tusb_get_revision(struct musb *musb);
230230
#define TUSB_REV_30 0x30
231231
#define TUSB_REV_31 0x31
232232

233-
/*----------------------------------------------------------------------------*/
234-
235-
#ifdef CONFIG_USB_TUSB6010
236-
237-
/* configuration parameters specific to this silicon */
238-
239-
/* Number of Tx endpoints. Legal values are 1 - 16 (this value includes EP0) */
240-
#define MUSB_C_NUM_EPT 16
241-
242-
/* Number of Rx endpoints. Legal values are 1 - 16 (this value includes EP0) */
243-
#define MUSB_C_NUM_EPR 16
244-
245-
/* Endpoint 1 to 15 direction types. C_EP1_DEF is defined if either Tx endpoint
246-
* 1 or Rx endpoint 1 are used.
247-
*/
248-
#define MUSB_C_EP1_DEF
249-
250-
/* C_EP1_TX_DEF is defined if Tx endpoint 1 is used */
251-
#define MUSB_C_EP1_TX_DEF
252-
253-
/* C_EP1_RX_DEF is defined if Rx endpoint 1 is used */
254-
#define MUSB_C_EP1_RX_DEF
255-
256-
/* C_EP1_TOR_DEF is defined if Tx endpoint 1 and Rx endpoint 1 share a FIFO */
257-
/* #define C_EP1_TOR_DEF */
258-
259-
/* C_EP1_TAR_DEF is defined if both Tx endpoint 1 and Rx endpoint 1 are used
260-
* and do not share a FIFO.
261-
*/
262-
#define MUSB_C_EP1_TAR_DEF
263-
264-
/* Similarly for all other used endpoints */
265-
#define MUSB_C_EP2_DEF
266-
#define MUSB_C_EP2_TX_DEF
267-
#define MUSB_C_EP2_RX_DEF
268-
#define MUSB_C_EP2_TAR_DEF
269-
#define MUSB_C_EP3_DEF
270-
#define MUSB_C_EP3_TX_DEF
271-
#define MUSB_C_EP3_RX_DEF
272-
#define MUSB_C_EP3_TAR_DEF
273-
#define MUSB_C_EP4_DEF
274-
#define MUSB_C_EP4_TX_DEF
275-
#define MUSB_C_EP4_RX_DEF
276-
#define MUSB_C_EP4_TAR_DEF
277-
278-
/* Endpoint 1 to 15 FIFO address bits. Legal values are 3 to 13 - corresponding
279-
* to FIFO sizes of 8 to 8192 bytes. If an Tx endpoint shares a FIFO with an Rx
280-
* endpoint then the Rx FIFO size must be the same as the Tx FIFO size. All
281-
* endpoints 1 to 15 must be defined, unused endpoints should be set to 2.
282-
*/
283-
#define MUSB_C_EP1T_BITS 5
284-
#define MUSB_C_EP1R_BITS 5
285-
#define MUSB_C_EP2T_BITS 5
286-
#define MUSB_C_EP2R_BITS 5
287-
#define MUSB_C_EP3T_BITS 3
288-
#define MUSB_C_EP3R_BITS 3
289-
#define MUSB_C_EP4T_BITS 3
290-
#define MUSB_C_EP4R_BITS 3
291-
292-
#define MUSB_C_EP5T_BITS 2
293-
#define MUSB_C_EP5R_BITS 2
294-
#define MUSB_C_EP6T_BITS 2
295-
#define MUSB_C_EP6R_BITS 2
296-
#define MUSB_C_EP7T_BITS 2
297-
#define MUSB_C_EP7R_BITS 2
298-
#define MUSB_C_EP8T_BITS 2
299-
#define MUSB_C_EP8R_BITS 2
300-
#define MUSB_C_EP9T_BITS 2
301-
#define MUSB_C_EP9R_BITS 2
302-
#define MUSB_C_EP10T_BITS 2
303-
#define MUSB_C_EP10R_BITS 2
304-
#define MUSB_C_EP11T_BITS 2
305-
#define MUSB_C_EP11R_BITS 2
306-
#define MUSB_C_EP12T_BITS 2
307-
#define MUSB_C_EP12R_BITS 2
308-
#define MUSB_C_EP13T_BITS 2
309-
#define MUSB_C_EP13R_BITS 2
310-
#define MUSB_C_EP14T_BITS 2
311-
#define MUSB_C_EP14R_BITS 2
312-
#define MUSB_C_EP15T_BITS 2
313-
#define MUSB_C_EP15R_BITS 2
314-
315-
/* Define the following constant if the USB2.0 Transceiver Macrocell data width
316-
* is 16-bits.
317-
*/
318-
/* #define C_UTM_16 */
319-
320-
/* Define this constant if the CPU uses big-endian byte ordering. */
321-
/* #define C_BIGEND */
322-
323-
/* Define the following constant if any Tx endpoint is required to support
324-
* multiple bulk packets.
325-
*/
326-
/* #define C_MP_TX */
327-
328-
/* Define the following constant if any Rx endpoint is required to support
329-
* multiple bulk packets.
330-
*/
331-
/* #define C_MP_RX */
332-
333-
/* Define the following constant if any Tx endpoint is required to support high
334-
* bandwidth ISO.
335-
*/
336-
/* #define C_HB_TX */
337-
338-
/* Define the following constant if any Rx endpoint is required to support high
339-
* bandwidth ISO.
340-
*/
341-
/* #define C_HB_RX */
342-
343-
/* Define the following constant if software connect/disconnect control is
344-
* required.
345-
*/
346-
#define MUSB_C_SOFT_CON
347-
348-
/* Define the following constant if Vendor Control Registers are required. */
349-
/* #define C_VEND_REG */
350-
351-
/* Vendor control register widths. */
352-
#define MUSB_C_VCTL_BITS 4
353-
#define MUSB_C_VSTAT_BITS 8
354-
355-
/* Define the following constant to include a DMA controller. */
356-
/* #define C_DMA */
357-
358-
/* Define the following constant if 2 or more DMA channels are required. */
359-
/* #define C_DMA2 */
360-
361-
/* Define the following constant if 3 or more DMA channels are required. */
362-
/* #define C_DMA3 */
363-
364-
/* Define the following constant if 4 or more DMA channels are required. */
365-
/* #define C_DMA4 */
366-
367-
/* Define the following constant if 5 or more DMA channels are required. */
368-
/* #define C_DMA5 */
369-
370-
/* Define the following constant if 6 or more DMA channels are required. */
371-
/* #define C_DMA6 */
372-
373-
/* Define the following constant if 7 or more DMA channels are required. */
374-
/* #define C_DMA7 */
375-
376-
/* Define the following constant if 8 or more DMA channels are required. */
377-
/* #define C_DMA8 */
378-
379-
/* Enable Dynamic FIFO Sizing */
380-
#define MUSB_C_DYNFIFO_DEF
381-
382-
/* Derived constants. The following constants are derived from the previous
383-
* configuration constants
384-
*/
385-
386-
/* Total number of endpoints. Legal values are 2 - 16. This must be equal to
387-
* the larger of C_NUM_EPT, C_NUM_EPR
388-
*/
389-
/* #define MUSB_C_NUM_EPS 5 */
390-
391-
/* C_EPMAX_BITS is equal to the largest endpoint FIFO word address bits */
392-
#define MUSB_C_EPMAX_BITS 11
393-
394-
/* C_RAM_BITS is the number of address bits required to address the RAM (32-bit
395-
* addresses). It is defined as log2 of the sum of 2** of all the endpoint FIFO
396-
* dword address bits (rounded up).
397-
*/
398-
#define MUSB_C_RAM_BITS 12
399-
400-
#endif /* CONFIG_USB_TUSB6010 */
401-
402233
#endif /* __TUSB6010_H__ */

include/linux/usb/musb.h

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,36 @@ enum musb_mode {
1919

2020
struct clk;
2121

22+
struct musb_hdrc_eps_bits {
23+
const char name[16];
24+
u8 bits;
25+
};
26+
27+
struct musb_hdrc_config {
28+
/* MUSB configuration-specific details */
29+
unsigned multipoint:1; /* multipoint device */
30+
unsigned dyn_fifo:1; /* supports dynamic fifo sizing */
31+
unsigned soft_con:1; /* soft connect required */
32+
unsigned utm_16:1; /* utm data witdh is 16 bits */
33+
unsigned big_endian:1; /* true if CPU uses big-endian */
34+
unsigned mult_bulk_tx:1; /* Tx ep required for multbulk pkts */
35+
unsigned mult_bulk_rx:1; /* Rx ep required for multbulk pkts */
36+
unsigned high_iso_tx:1; /* Tx ep required for HB iso */
37+
unsigned high_iso_rx:1; /* Rx ep required for HD iso */
38+
unsigned dma:1; /* supports DMA */
39+
unsigned vendor_req:1; /* vendor registers required */
40+
41+
u8 num_eps; /* number of endpoints _with_ ep0 */
42+
u8 dma_channels; /* number of dma channels */
43+
u8 dyn_fifo_size; /* dynamic size in bytes */
44+
u8 vendor_ctrl; /* vendor control reg width */
45+
u8 vendor_stat; /* vendor status reg witdh */
46+
u8 dma_req_chan; /* bitmask for required dma channels */
47+
u8 ram_bits; /* ram address size */
48+
49+
struct musb_hdrc_eps_bits *eps_bits;
50+
};
51+
2252
struct musb_hdrc_platform_data {
2353
/* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
2454
u8 mode;
@@ -38,16 +68,14 @@ struct musb_hdrc_platform_data {
3868
/* (HOST or OTG) msec/2 after VBUS on till power good */
3969
u8 potpgt;
4070

41-
/* TBD: chip defaults should probably go someplace else,
42-
* e.g. number of tx/rx endpoints, etc
43-
*/
44-
unsigned multipoint:1;
45-
4671
/* Power the device on or off */
4772
int (*set_power)(int state);
4873

4974
/* Turn device clock on or off */
5075
int (*set_clock)(struct clk *clock, int is_on);
76+
77+
/* MUSB configuration-specific details */
78+
struct musb_hdrc_config *config;
5179
};
5280

5381

0 commit comments

Comments
 (0)