Skip to content

Commit

Permalink
USB: FHCI: Reusing QUICC Engine USB Controller registers from immap_qe.h
Browse files Browse the repository at this point in the history
The struct fhci_regs (in drivers/usb/host/fhci.h) is basically a redefinition
of the struct qe_usb_ctlr (in arch/powerpc/include/asm/immap_qe.h).

The qe_usb_ctlr struct is preferrable once it uses accurately the registers'
names found in the Freescale's QUICC Engine Block Reference Manuals (QEIWRM.pdf
Rev.4.4 Chapter 19 for MPC836xE series and MPC8323ERM.pdf Rev.2 Chapter 36 for
MPC832xE series), making easier to map the FHCI device driver to the hardware
manual. Also, as the FHCI driver uses the USB Controller registers, the name
qe_usb_ctlr is a more precise representation of the hardware than fhci_regs.

Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Guilherme Maciel Ferreira authored and Greg Kroah-Hartman committed Jun 27, 2012
1 parent 023b515 commit cf61fdb
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 72 deletions.
12 changes: 6 additions & 6 deletions drivers/usb/host/fhci-dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void fhci_dbg_isr(struct fhci_hcd *fhci, int usb_er)
static int fhci_dfs_regs_show(struct seq_file *s, void *v)
{
struct fhci_hcd *fhci = s->private;
struct fhci_regs __iomem *regs = fhci->regs;
struct qe_usb_ctlr __iomem *regs = fhci->regs;

seq_printf(s,
"mode: 0x%x\n" "addr: 0x%x\n"
Expand All @@ -50,11 +50,11 @@ static int fhci_dfs_regs_show(struct seq_file *s, void *v)
"status: 0x%x\n" "SOF timer: %d\n"
"frame number: %d\n"
"lines status: 0x%x\n",
in_8(&regs->usb_mod), in_8(&regs->usb_addr),
in_8(&regs->usb_comm), in_be16(&regs->usb_ep[0]),
in_be16(&regs->usb_event), in_be16(&regs->usb_mask),
in_8(&regs->usb_status), in_be16(&regs->usb_sof_tmr),
in_be16(&regs->usb_frame_num),
in_8(&regs->usb_usmod), in_8(&regs->usb_usadr),
in_8(&regs->usb_uscom), in_be16(&regs->usb_usep[0]),
in_be16(&regs->usb_usber), in_be16(&regs->usb_usbmr),
in_8(&regs->usb_usbs), in_be16(&regs->usb_ussft),
in_be16(&regs->usb_usfrn),
fhci_ioports_check_bus_state(fhci));

return 0;
Expand Down
32 changes: 16 additions & 16 deletions drivers/usb/host/fhci-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void fhci_start_sof_timer(struct fhci_hcd *fhci)
/* clear frame_n */
out_be16(&fhci->pram->frame_num, 0);

out_be16(&fhci->regs->usb_sof_tmr, 0);
setbits8(&fhci->regs->usb_mod, USB_MODE_SFTE);
out_be16(&fhci->regs->usb_ussft, 0);
setbits8(&fhci->regs->usb_usmod, USB_MODE_SFTE);

fhci_dbg(fhci, "<- %s\n", __func__);
}
Expand All @@ -50,15 +50,15 @@ void fhci_stop_sof_timer(struct fhci_hcd *fhci)
{
fhci_dbg(fhci, "-> %s\n", __func__);

clrbits8(&fhci->regs->usb_mod, USB_MODE_SFTE);
clrbits8(&fhci->regs->usb_usmod, USB_MODE_SFTE);
gtm_stop_timer16(fhci->timer);

fhci_dbg(fhci, "<- %s\n", __func__);
}

u16 fhci_get_sof_timer_count(struct fhci_usb *usb)
{
return be16_to_cpu(in_be16(&usb->fhci->regs->usb_sof_tmr) / 12);
return be16_to_cpu(in_be16(&usb->fhci->regs->usb_ussft) / 12);
}

/* initialize the endpoint zero */
Expand Down Expand Up @@ -88,8 +88,8 @@ void fhci_usb_enable_interrupt(struct fhci_usb *usb)
enable_irq(fhci_to_hcd(fhci)->irq);

/* initialize the event register and mask register */
out_be16(&usb->fhci->regs->usb_event, 0xffff);
out_be16(&usb->fhci->regs->usb_mask, usb->saved_msk);
out_be16(&usb->fhci->regs->usb_usber, 0xffff);
out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk);

/* enable the timer interrupts */
enable_irq(fhci->timer->irq);
Expand All @@ -109,7 +109,7 @@ void fhci_usb_disable_interrupt(struct fhci_usb *usb)

/* disable the usb interrupt */
disable_irq_nosync(fhci_to_hcd(fhci)->irq);
out_be16(&usb->fhci->regs->usb_mask, 0);
out_be16(&usb->fhci->regs->usb_usbmr, 0);
}
usb->intr_nesting_cnt++;
}
Expand All @@ -119,9 +119,9 @@ static u32 fhci_usb_enable(struct fhci_hcd *fhci)
{
struct fhci_usb *usb = fhci->usb_lld;

out_be16(&usb->fhci->regs->usb_event, 0xffff);
out_be16(&usb->fhci->regs->usb_mask, usb->saved_msk);
setbits8(&usb->fhci->regs->usb_mod, USB_MODE_EN);
out_be16(&usb->fhci->regs->usb_usber, 0xffff);
out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk);
setbits8(&usb->fhci->regs->usb_usmod, USB_MODE_EN);

mdelay(100);

Expand All @@ -141,7 +141,7 @@ static u32 fhci_usb_disable(struct fhci_hcd *fhci)
usb->port_status == FHCI_PORT_LOW)
fhci_device_disconnected_interrupt(fhci);

clrbits8(&usb->fhci->regs->usb_mod, USB_MODE_EN);
clrbits8(&usb->fhci->regs->usb_usmod, USB_MODE_EN);

return 0;
}
Expand Down Expand Up @@ -285,13 +285,13 @@ static int fhci_usb_init(struct fhci_hcd *fhci)
USB_E_IDLE_MASK |
USB_E_RESET_MASK | USB_E_SFT_MASK | USB_E_MSF_MASK);

out_8(&usb->fhci->regs->usb_mod, USB_MODE_HOST | USB_MODE_EN);
out_8(&usb->fhci->regs->usb_usmod, USB_MODE_HOST | USB_MODE_EN);

/* clearing the mask register */
out_be16(&usb->fhci->regs->usb_mask, 0);
out_be16(&usb->fhci->regs->usb_usbmr, 0);

/* initialing the event register */
out_be16(&usb->fhci->regs->usb_event, 0xffff);
out_be16(&usb->fhci->regs->usb_usber, 0xffff);

if (endpoint_zero_init(usb, DEFAULT_DATA_MEM, DEFAULT_RING_LEN) != 0) {
fhci_usb_free(usb);
Expand Down Expand Up @@ -745,8 +745,8 @@ static int __devinit of_fhci_probe(struct platform_device *ofdev)
}

/* Clear and disable any pending interrupts. */
out_be16(&fhci->regs->usb_event, 0xffff);
out_be16(&fhci->regs->usb_mask, 0);
out_be16(&fhci->regs->usb_usber, 0xffff);
out_be16(&fhci->regs->usb_usbmr, 0);

ret = usb_add_hcd(hcd, usb_irq, 0);
if (ret < 0)
Expand Down
16 changes: 8 additions & 8 deletions drivers/usb/host/fhci-hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void fhci_port_disable(struct fhci_hcd *fhci)

/* Enable IDLE since we want to know if something comes along */
usb->saved_msk |= USB_E_IDLE_MASK;
out_be16(&usb->fhci->regs->usb_mask, usb->saved_msk);
out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk);

/* check if during the disconnection process attached new device */
if (port_status == FHCI_PORT_WAITING)
Expand Down Expand Up @@ -158,21 +158,21 @@ void fhci_port_reset(void *lld)

fhci_stop_sof_timer(fhci);
/* disable the USB controller */
mode = in_8(&fhci->regs->usb_mod);
out_8(&fhci->regs->usb_mod, mode & (~USB_MODE_EN));
mode = in_8(&fhci->regs->usb_usmod);
out_8(&fhci->regs->usb_usmod, mode & (~USB_MODE_EN));

/* disable idle interrupts */
mask = in_be16(&fhci->regs->usb_mask);
out_be16(&fhci->regs->usb_mask, mask & (~USB_E_IDLE_MASK));
mask = in_be16(&fhci->regs->usb_usbmr);
out_be16(&fhci->regs->usb_usbmr, mask & (~USB_E_IDLE_MASK));

fhci_io_port_generate_reset(fhci);

/* enable interrupt on this endpoint */
out_be16(&fhci->regs->usb_mask, mask);
out_be16(&fhci->regs->usb_usbmr, mask);

/* enable the USB controller */
mode = in_8(&fhci->regs->usb_mod);
out_8(&fhci->regs->usb_mod, mode | USB_MODE_EN);
mode = in_8(&fhci->regs->usb_usmod);
out_8(&fhci->regs->usb_usmod, mode | USB_MODE_EN);
fhci_start_sof_timer(fhci);

fhci_dbg(fhci, "<- %s\n", __func__);
Expand Down
30 changes: 15 additions & 15 deletions drivers/usb/host/fhci-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ void fhci_flush_all_transmissions(struct fhci_usb *usb)
u8 mode;
struct td *td;

mode = in_8(&usb->fhci->regs->usb_mod);
clrbits8(&usb->fhci->regs->usb_mod, USB_MODE_EN);
mode = in_8(&usb->fhci->regs->usb_usmod);
clrbits8(&usb->fhci->regs->usb_usmod, USB_MODE_EN);

fhci_flush_bds(usb);

Expand All @@ -147,9 +147,9 @@ void fhci_flush_all_transmissions(struct fhci_usb *usb)
usb->actual_frame->frame_status = FRAME_END_TRANSMISSION;

/* reset the event register */
out_be16(&usb->fhci->regs->usb_event, 0xffff);
out_be16(&usb->fhci->regs->usb_usber, 0xffff);
/* enable the USB controller */
out_8(&usb->fhci->regs->usb_mod, mode | USB_MODE_EN);
out_8(&usb->fhci->regs->usb_usmod, mode | USB_MODE_EN);
}

/*
Expand Down Expand Up @@ -414,7 +414,7 @@ static void sof_interrupt(struct fhci_hcd *fhci)
usb->port_status = FHCI_PORT_FULL;
/* Disable IDLE */
usb->saved_msk &= ~USB_E_IDLE_MASK;
out_be16(&usb->fhci->regs->usb_mask, usb->saved_msk);
out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk);
}

gtm_set_exact_timer16(fhci->timer, usb->max_frame_usage, false);
Expand All @@ -433,14 +433,14 @@ void fhci_device_disconnected_interrupt(struct fhci_hcd *fhci)
fhci_dbg(fhci, "-> %s\n", __func__);

fhci_usb_disable_interrupt(usb);
clrbits8(&usb->fhci->regs->usb_mod, USB_MODE_LSS);
clrbits8(&usb->fhci->regs->usb_usmod, USB_MODE_LSS);
usb->port_status = FHCI_PORT_DISABLED;

fhci_stop_sof_timer(fhci);

/* Enable IDLE since we want to know if something comes along */
usb->saved_msk |= USB_E_IDLE_MASK;
out_be16(&usb->fhci->regs->usb_mask, usb->saved_msk);
out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk);

usb->vroot_hub->port.wPortStatus &= ~USB_PORT_STAT_CONNECTION;
usb->vroot_hub->port.wPortChange |= USB_PORT_STAT_C_CONNECTION;
Expand Down Expand Up @@ -473,7 +473,7 @@ void fhci_device_connected_interrupt(struct fhci_hcd *fhci)
}

usb->port_status = FHCI_PORT_LOW;
setbits8(&usb->fhci->regs->usb_mod, USB_MODE_LSS);
setbits8(&usb->fhci->regs->usb_usmod, USB_MODE_LSS);
usb->vroot_hub->port.wPortStatus |=
(USB_PORT_STAT_LOW_SPEED |
USB_PORT_STAT_CONNECTION);
Expand All @@ -491,7 +491,7 @@ void fhci_device_connected_interrupt(struct fhci_hcd *fhci)
}

usb->port_status = FHCI_PORT_FULL;
clrbits8(&usb->fhci->regs->usb_mod, USB_MODE_LSS);
clrbits8(&usb->fhci->regs->usb_usmod, USB_MODE_LSS);
usb->vroot_hub->port.wPortStatus &=
~USB_PORT_STAT_LOW_SPEED;
usb->vroot_hub->port.wPortStatus |=
Expand Down Expand Up @@ -535,7 +535,7 @@ static void abort_transmission(struct fhci_usb *usb)
/* issue stop Tx command */
qe_issue_cmd(QE_USB_STOP_TX, QE_CR_SUBBLOCK_USB, EP_ZERO, 0);
/* flush Tx FIFOs */
out_8(&usb->fhci->regs->usb_comm, USB_CMD_FLUSH_FIFO | EP_ZERO);
out_8(&usb->fhci->regs->usb_uscom, USB_CMD_FLUSH_FIFO | EP_ZERO);
udelay(1000);
/* reset Tx BDs */
fhci_flush_bds(usb);
Expand All @@ -555,11 +555,11 @@ irqreturn_t fhci_irq(struct usb_hcd *hcd)

usb = fhci->usb_lld;

usb_er |= in_be16(&usb->fhci->regs->usb_event) &
in_be16(&usb->fhci->regs->usb_mask);
usb_er |= in_be16(&usb->fhci->regs->usb_usber) &
in_be16(&usb->fhci->regs->usb_usbmr);

/* clear event bits for next time */
out_be16(&usb->fhci->regs->usb_event, usb_er);
out_be16(&usb->fhci->regs->usb_usber, usb_er);

fhci_dbg_isr(fhci, usb_er);

Expand All @@ -573,7 +573,7 @@ irqreturn_t fhci_irq(struct usb_hcd *hcd)

/* Turn on IDLE since we want to disconnect */
usb->saved_msk |= USB_E_IDLE_MASK;
out_be16(&usb->fhci->regs->usb_event,
out_be16(&usb->fhci->regs->usb_usber,
usb->saved_msk);
} else if (usb->port_status == FHCI_PORT_DISABLED) {
if (fhci_ioports_check_bus_state(fhci) == 1)
Expand Down Expand Up @@ -611,7 +611,7 @@ irqreturn_t fhci_irq(struct usb_hcd *hcd)
/* XXX usb->port_status = FHCI_PORT_WAITING; */
/* Disable IDLE */
usb->saved_msk &= ~USB_E_IDLE_MASK;
out_be16(&usb->fhci->regs->usb_mask,
out_be16(&usb->fhci->regs->usb_usbmr,
usb->saved_msk);
} else {
fhci_dbg_isr(fhci, -1);
Expand Down
14 changes: 7 additions & 7 deletions drivers/usb/host/fhci-tds.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void fhci_init_ep_registers(struct fhci_usb *usb, struct endpoint *ep,
u8 rt;

/* set the endpoint registers according to the endpoint */
out_be16(&usb->fhci->regs->usb_ep[0],
out_be16(&usb->fhci->regs->usb_usep[0],
USB_TRANS_CTR | USB_EP_MF | USB_EP_RTE);
out_be16(&usb->fhci->pram->ep_ptr[0],
cpm_muram_offset(ep->ep_pram_ptr));
Expand Down Expand Up @@ -463,7 +463,7 @@ u32 fhci_host_transaction(struct fhci_usb *usb,
cq_put(&ep->conf_frame_Q, pkt);

if (cq_howmany(&ep->conf_frame_Q) == 1)
out_8(&usb->fhci->regs->usb_comm, USB_CMD_STR_FIFO);
out_8(&usb->fhci->regs->usb_uscom, USB_CMD_STR_FIFO);

return 0;
}
Expand Down Expand Up @@ -535,8 +535,8 @@ void fhci_flush_actual_frame(struct fhci_usb *usb)
struct endpoint *ep = usb->ep0;

/* disable the USB controller */
mode = in_8(&usb->fhci->regs->usb_mod);
out_8(&usb->fhci->regs->usb_mod, mode & ~USB_MODE_EN);
mode = in_8(&usb->fhci->regs->usb_usmod);
out_8(&usb->fhci->regs->usb_usmod, mode & ~USB_MODE_EN);

tb_ptr = in_be16(&ep->ep_pram_ptr->tx_bd_ptr);
td = cpm_muram_addr(tb_ptr);
Expand Down Expand Up @@ -571,9 +571,9 @@ void fhci_flush_actual_frame(struct fhci_usb *usb)
usb->actual_frame->frame_status = FRAME_TIMER_END_TRANSMISSION;

/* reset the event register */
out_be16(&usb->fhci->regs->usb_event, 0xffff);
out_be16(&usb->fhci->regs->usb_usber, 0xffff);
/* enable the USB controller */
out_8(&usb->fhci->regs->usb_mod, mode | USB_MODE_EN);
out_8(&usb->fhci->regs->usb_usmod, mode | USB_MODE_EN);
}

/* handles Tx confirm and Tx error interrupt */
Expand Down Expand Up @@ -613,7 +613,7 @@ void fhci_host_transmit_actual_frame(struct fhci_usb *usb)

/* start transmit only if we have something in the TDs */
if (in_be16(&td->status) & TD_R)
out_8(&usb->fhci->regs->usb_comm, USB_CMD_STR_FIFO);
out_8(&usb->fhci->regs->usb_uscom, USB_CMD_STR_FIFO);

if (in_be32(&ep->conf_td->buf_ptr) == DUMMY_BD_BUFFER) {
out_be32(&old_td->buf_ptr, 0);
Expand Down
22 changes: 2 additions & 20 deletions drivers/usb/host/fhci.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/usb.h>
#include <linux/usb/hcd.h>
#include <asm/qe.h>
#include <asm/immap_qe.h>

#define USB_CLOCK 48000000

Expand Down Expand Up @@ -173,25 +174,6 @@
#define USB_E_TXB_MASK 0x0002
#define USB_E_RXB_MASK 0x0001

/* Freescale USB Host controller registers */
struct fhci_regs {
u8 usb_mod; /* mode register */
u8 usb_addr; /* address register */
u8 usb_comm; /* command register */
u8 reserved1[1];
__be16 usb_ep[4]; /* endpoint register */
u8 reserved2[4];
__be16 usb_event; /* event register */
u8 reserved3[2];
__be16 usb_mask; /* mask register */
u8 reserved4[1];
u8 usb_status; /* status register */
__be16 usb_sof_tmr; /* Start Of Frame timer */
u8 reserved5[2];
__be16 usb_frame_num; /* frame number register */
u8 reserved6[1];
};

/* Freescale USB HOST */
struct fhci_pram {
__be16 ep_ptr[4]; /* Endpoint porter reg */
Expand Down Expand Up @@ -267,7 +249,7 @@ struct fhci_hcd {
int gpios[NUM_GPIOS];
bool alow_gpios[NUM_GPIOS];

struct fhci_regs __iomem *regs; /* I/O memory used to communicate */
struct qe_usb_ctlr __iomem *regs; /* I/O memory used to communicate */
struct fhci_pram __iomem *pram; /* Parameter RAM */
struct gtm_timer *timer;

Expand Down

0 comments on commit cf61fdb

Please sign in to comment.