Commit e6c213b2 authored by Felipe Balbi's avatar Felipe Balbi Committed by Greg Kroah-Hartman

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: default avatarFelipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent bd5afa9e
...@@ -995,24 +995,13 @@ static ushort __initdata fifo_mode = 2; ...@@ -995,24 +995,13 @@ static ushort __initdata fifo_mode = 2;
module_param(fifo_mode, ushort, 0); module_param(fifo_mode, ushort, 0);
MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration"); MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration");
enum fifo_style { FIFO_RXTX, FIFO_TX, FIFO_RX } __attribute__ ((packed));
enum buf_mode { BUF_SINGLE, BUF_DOUBLE } __attribute__ ((packed));
struct fifo_cfg {
u8 hw_ep_num;
enum fifo_style style;
enum buf_mode mode;
u16 maxpacket;
};
/* /*
* tables defining fifo_mode values. define more if you like. * tables defining fifo_mode values. define more if you like.
* for host side, make sure both halves of ep1 are set up. * for host side, make sure both halves of ep1 are set up.
*/ */
/* mode 0 - fits in 2KB */ /* mode 0 - fits in 2KB */
static struct fifo_cfg __initdata mode_0_cfg[] = { static struct musb_fifo_cfg __initdata mode_0_cfg[] = {
{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
{ .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, }, { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, },
...@@ -1021,7 +1010,7 @@ static struct fifo_cfg __initdata mode_0_cfg[] = { ...@@ -1021,7 +1010,7 @@ static struct fifo_cfg __initdata mode_0_cfg[] = {
}; };
/* mode 1 - fits in 4KB */ /* mode 1 - fits in 4KB */
static struct fifo_cfg __initdata mode_1_cfg[] = { static struct musb_fifo_cfg __initdata mode_1_cfg[] = {
{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, },
{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, },
{ .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, }, { .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,7 +1019,7 @@ static struct fifo_cfg __initdata mode_1_cfg[] = {
}; };
/* mode 2 - fits in 4KB */ /* mode 2 - fits in 4KB */
static struct fifo_cfg __initdata mode_2_cfg[] = { static struct musb_fifo_cfg __initdata mode_2_cfg[] = {
{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
...@@ -1040,7 +1029,7 @@ static struct fifo_cfg __initdata mode_2_cfg[] = { ...@@ -1040,7 +1029,7 @@ static struct fifo_cfg __initdata mode_2_cfg[] = {
}; };
/* mode 3 - fits in 4KB */ /* mode 3 - fits in 4KB */
static struct fifo_cfg __initdata mode_3_cfg[] = { static struct musb_fifo_cfg __initdata mode_3_cfg[] = {
{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, },
{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, },
{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
...@@ -1050,7 +1039,7 @@ static struct fifo_cfg __initdata mode_3_cfg[] = { ...@@ -1050,7 +1039,7 @@ static struct fifo_cfg __initdata mode_3_cfg[] = {
}; };
/* mode 4 - fits in 16KB */ /* mode 4 - fits in 16KB */
static struct fifo_cfg __initdata mode_4_cfg[] = { static struct musb_fifo_cfg __initdata mode_4_cfg[] = {
{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
...@@ -1081,7 +1070,7 @@ static struct fifo_cfg __initdata mode_4_cfg[] = { ...@@ -1081,7 +1070,7 @@ static struct fifo_cfg __initdata mode_4_cfg[] = {
}; };
/* mode 5 - fits in 8KB */ /* mode 5 - fits in 8KB */
static struct fifo_cfg __initdata mode_5_cfg[] = { static struct musb_fifo_cfg __initdata mode_5_cfg[] = {
{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
...@@ -1119,7 +1108,7 @@ static struct fifo_cfg __initdata mode_5_cfg[] = { ...@@ -1119,7 +1108,7 @@ static struct fifo_cfg __initdata mode_5_cfg[] = {
*/ */
static int __init static int __init
fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
const struct fifo_cfg *cfg, u16 offset) const struct musb_fifo_cfg *cfg, u16 offset)
{ {
void __iomem *mbase = musb->mregs; void __iomem *mbase = musb->mregs;
int size = 0; int size = 0;
...@@ -1190,17 +1179,23 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, ...@@ -1190,17 +1179,23 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0)); return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0));
} }
static struct fifo_cfg __initdata ep0_cfg = { static struct musb_fifo_cfg __initdata ep0_cfg = {
.style = FIFO_RXTX, .maxpacket = 64, .style = FIFO_RXTX, .maxpacket = 64,
}; };
static int __init ep_config_from_table(struct musb *musb) static int __init ep_config_from_table(struct musb *musb)
{ {
const struct fifo_cfg *cfg; const struct musb_fifo_cfg *cfg;
unsigned i, n; unsigned i, n;
int offset; int offset;
struct musb_hw_ep *hw_ep = musb->endpoints; struct musb_hw_ep *hw_ep = musb->endpoints;
if (musb->config->fifo_cfg) {
cfg = musb->config->fifo_cfg;
n = musb->config->fifo_cfg_size;
goto done;
}
switch (fifo_mode) { switch (fifo_mode) {
default: default:
fifo_mode = 0; fifo_mode = 0;
...@@ -1235,6 +1230,7 @@ static int __init ep_config_from_table(struct musb *musb) ...@@ -1235,6 +1230,7 @@ static int __init ep_config_from_table(struct musb *musb)
musb_driver_name, fifo_mode); musb_driver_name, fifo_mode);
done:
offset = fifo_setup(musb, hw_ep, &ep0_cfg, 0); offset = fifo_setup(musb, hw_ep, &ep0_cfg, 0);
/* assert(offset > 0) */ /* assert(offset > 0) */
......
...@@ -22,12 +22,47 @@ enum musb_mode { ...@@ -22,12 +22,47 @@ enum musb_mode {
struct clk; struct clk;
enum musb_fifo_style {
FIFO_RXTX,
FIFO_TX,
FIFO_RX
} __attribute__ ((packed));
enum musb_buf_mode {
BUF_SINGLE,
BUF_DOUBLE
} __attribute__ ((packed));
struct musb_fifo_cfg {
u8 hw_ep_num;
enum musb_fifo_style style;
enum musb_buf_mode mode;
u16 maxpacket;
};
#define MUSB_EP_FIFO(ep, st, m, pkt) \
{ \
.hw_ep_num = ep, \
.style = st, \
.mode = m, \
.maxpacket = pkt, \
}
#define MUSB_EP_FIFO_SINGLE(ep, st, pkt) \
MUSB_EP_FIFO(ep, st, BUF_SINGLE, pkt)
#define MUSB_EP_FIFO_DOUBLE(ep, st, pkt) \
MUSB_EP_FIFO(ep, st, BUF_DOUBLE, pkt)
struct musb_hdrc_eps_bits { struct musb_hdrc_eps_bits {
const char name[16]; const char name[16];
u8 bits; u8 bits;
}; };
struct musb_hdrc_config { struct musb_hdrc_config {
struct musb_fifo_cfg *fifo_cfg; /* board fifo configuration */
unsigned fifo_cfg_size; /* size of the fifo configuration */
/* MUSB configuration-specific details */ /* MUSB configuration-specific details */
unsigned multipoint:1; /* multipoint device */ unsigned multipoint:1; /* multipoint device */
unsigned dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */ unsigned dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment