aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Balbi <felipe.balbi@nokia.com>2010-03-12 03:29:06 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 16:21:31 -0400
commite6c213b2968cbee4cfb8f89f2d685b9ad07eefbd (patch)
treebbe7c6bd630c3fef4dc1062b762c5fba9b7d1d6d
parentbd5afa9eac6daa408412a31a6c69e87e8bd28c7e (diff)
usb: musb: allow board to pass down fifo mode
boards might want to optimize their fifo configuration to the particular needs of that specific board. Allow that by moving all related data structures to <linux/usb/musb.h> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/musb/musb_core.c36
-rw-r--r--include/linux/usb/musb.h35
2 files changed, 51 insertions, 20 deletions
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index ced6d9ea9af3..3f4c158a9f5e 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -995,24 +995,13 @@ static ushort __initdata fifo_mode = 2;
995module_param(fifo_mode, ushort, 0); 995module_param(fifo_mode, ushort, 0);
996MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration"); 996MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration");
997 997
998
999enum fifo_style { FIFO_RXTX, FIFO_TX, FIFO_RX } __attribute__ ((packed));
1000enum buf_mode { BUF_SINGLE, BUF_DOUBLE } __attribute__ ((packed));
1001
1002struct fifo_cfg {
1003 u8 hw_ep_num;
1004 enum fifo_style style;
1005 enum buf_mode mode;
1006 u16 maxpacket;
1007};
1008
1009/* 998/*
1010 * tables defining fifo_mode values. define more if you like. 999 * tables defining fifo_mode values. define more if you like.
1011 * for host side, make sure both halves of ep1 are set up. 1000 * for host side, make sure both halves of ep1 are set up.
1012 */ 1001 */
1013 1002
1014/* mode 0 - fits in 2KB */ 1003/* mode 0 - fits in 2KB */
1015static struct fifo_cfg __initdata mode_0_cfg[] = { 1004static struct musb_fifo_cfg __initdata mode_0_cfg[] = {
1016{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, 1005{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
1017{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, 1006{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
1018{ .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, }, 1007{ .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, },
@@ -1021,7 +1010,7 @@ static struct fifo_cfg __initdata mode_0_cfg[] = {
1021}; 1010};
1022 1011
1023/* mode 1 - fits in 4KB */ 1012/* mode 1 - fits in 4KB */
1024static struct fifo_cfg __initdata mode_1_cfg[] = { 1013static struct musb_fifo_cfg __initdata mode_1_cfg[] = {
1025{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, 1014{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, },
1026{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, 1015{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, },
1027{ .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, }, 1016{ .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, },
@@ -1030,7 +1019,7 @@ static struct fifo_cfg __initdata mode_1_cfg[] = {
1030}; 1019};
1031 1020
1032/* mode 2 - fits in 4KB */ 1021/* mode 2 - fits in 4KB */
1033static struct fifo_cfg __initdata mode_2_cfg[] = { 1022static struct musb_fifo_cfg __initdata mode_2_cfg[] = {
1034{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, 1023{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
1035{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, 1024{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
1036{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 1025{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
@@ -1040,7 +1029,7 @@ static struct fifo_cfg __initdata mode_2_cfg[] = {
1040}; 1029};
1041 1030
1042/* mode 3 - fits in 4KB */ 1031/* mode 3 - fits in 4KB */
1043static struct fifo_cfg __initdata mode_3_cfg[] = { 1032static struct musb_fifo_cfg __initdata mode_3_cfg[] = {
1044{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, 1033{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, },
1045{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, 1034{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, },
1046{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 1035{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
@@ -1050,7 +1039,7 @@ static struct fifo_cfg __initdata mode_3_cfg[] = {
1050}; 1039};
1051 1040
1052/* mode 4 - fits in 16KB */ 1041/* mode 4 - fits in 16KB */
1053static struct fifo_cfg __initdata mode_4_cfg[] = { 1042static struct musb_fifo_cfg __initdata mode_4_cfg[] = {
1054{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, 1043{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
1055{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, 1044{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
1056{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 1045{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
@@ -1081,7 +1070,7 @@ static struct fifo_cfg __initdata mode_4_cfg[] = {
1081}; 1070};
1082 1071
1083/* mode 5 - fits in 8KB */ 1072/* mode 5 - fits in 8KB */
1084static struct fifo_cfg __initdata mode_5_cfg[] = { 1073static struct musb_fifo_cfg __initdata mode_5_cfg[] = {
1085{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, 1074{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
1086{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, 1075{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
1087{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 1076{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
@@ -1119,7 +1108,7 @@ static struct fifo_cfg __initdata mode_5_cfg[] = {
1119 */ 1108 */
1120static int __init 1109static int __init
1121fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, 1110fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
1122 const struct fifo_cfg *cfg, u16 offset) 1111 const struct musb_fifo_cfg *cfg, u16 offset)
1123{ 1112{
1124 void __iomem *mbase = musb->mregs; 1113 void __iomem *mbase = musb->mregs;
1125 int size = 0; 1114 int size = 0;
@@ -1190,17 +1179,23 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
1190 return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0)); 1179 return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0));
1191} 1180}
1192 1181
1193static struct fifo_cfg __initdata ep0_cfg = { 1182static struct musb_fifo_cfg __initdata ep0_cfg = {
1194 .style = FIFO_RXTX, .maxpacket = 64, 1183 .style = FIFO_RXTX, .maxpacket = 64,
1195}; 1184};
1196 1185
1197static int __init ep_config_from_table(struct musb *musb) 1186static int __init ep_config_from_table(struct musb *musb)
1198{ 1187{
1199 const struct fifo_cfg *cfg; 1188 const struct musb_fifo_cfg *cfg;
1200 unsigned i, n; 1189 unsigned i, n;
1201 int offset; 1190 int offset;
1202 struct musb_hw_ep *hw_ep = musb->endpoints; 1191 struct musb_hw_ep *hw_ep = musb->endpoints;
1203 1192
1193 if (musb->config->fifo_cfg) {
1194 cfg = musb->config->fifo_cfg;
1195 n = musb->config->fifo_cfg_size;
1196 goto done;
1197 }
1198
1204 switch (fifo_mode) { 1199 switch (fifo_mode) {
1205 default: 1200 default:
1206 fifo_mode = 0; 1201 fifo_mode = 0;
@@ -1235,6 +1230,7 @@ static int __init ep_config_from_table(struct musb *musb)
1235 musb_driver_name, fifo_mode); 1230 musb_driver_name, fifo_mode);
1236 1231
1237 1232
1233done:
1238 offset = fifo_setup(musb, hw_ep, &ep0_cfg, 0); 1234 offset = fifo_setup(musb, hw_ep, &ep0_cfg, 0);
1239 /* assert(offset > 0) */ 1235 /* assert(offset > 0) */
1240 1236
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
index 7acef0234c0e..f3d68f62dae8 100644
--- a/include/linux/usb/musb.h
+++ b/include/linux/usb/musb.h
@@ -22,12 +22,47 @@ enum musb_mode {
22 22
23struct clk; 23struct clk;
24 24
25enum musb_fifo_style {
26 FIFO_RXTX,
27 FIFO_TX,
28 FIFO_RX
29} __attribute__ ((packed));
30
31enum musb_buf_mode {
32 BUF_SINGLE,
33 BUF_DOUBLE
34} __attribute__ ((packed));
35
36struct musb_fifo_cfg {
37 u8 hw_ep_num;
38 enum musb_fifo_style style;
39 enum musb_buf_mode mode;
40 u16 maxpacket;
41};
42
43#define MUSB_EP_FIFO(ep, st, m, pkt) \
44{ \
45 .hw_ep_num = ep, \
46 .style = st, \
47 .mode = m, \
48 .maxpacket = pkt, \
49}
50
51#define MUSB_EP_FIFO_SINGLE(ep, st, pkt) \
52 MUSB_EP_FIFO(ep, st, BUF_SINGLE, pkt)
53
54#define MUSB_EP_FIFO_DOUBLE(ep, st, pkt) \
55 MUSB_EP_FIFO(ep, st, BUF_DOUBLE, pkt)
56
25struct musb_hdrc_eps_bits { 57struct musb_hdrc_eps_bits {
26 const char name[16]; 58 const char name[16];
27 u8 bits; 59 u8 bits;
28}; 60};
29 61
30struct musb_hdrc_config { 62struct musb_hdrc_config {
63 struct musb_fifo_cfg *fifo_cfg; /* board fifo configuration */
64 unsigned fifo_cfg_size; /* size of the fifo configuration */
65
31 /* MUSB configuration-specific details */ 66 /* MUSB configuration-specific details */
32 unsigned multipoint:1; /* multipoint device */ 67 unsigned multipoint:1; /* multipoint device */
33 unsigned dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */ 68 unsigned dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */