Skip to content

Commit

Permalink
arch/risc-v/src/mpfs: Set USB DMA upper addr offset
Browse files Browse the repository at this point in the history
Use a configuration register to set the upper address lines [37:32] for USB DMA engine.

Signed-off-by: Jani Paalijarvi <[email protected]>
  • Loading branch information
jpaali committed Sep 4, 2023
1 parent 3ce090e commit 2563e16
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions arch/risc-v/src/mpfs/hardware/mpfs_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
#define MPFS_USB_C_T_HHSRTN_OFFSET 0x346
#define MPFS_USB_C_T_HSBT_OFFSET 0x348

#define MPFS_USB_DMA_ADDR_UPPER_REG_OFFSET 0x3FC

#define MPFS_USB_POWER (MPFS_USB_BASE + MPFS_USB_POWER_OFFSET)
#define MPFS_USB_POWER_ENABLE_SUSPENDM (1 << 0)
#define MPFS_USB_POWER_SUSPEND_MODE (1 << 1)
Expand Down Expand Up @@ -175,6 +177,12 @@
#define MPFS_USB_RX_DPBUF_DIS (MPFS_USB_BASE + MPFS_USB_RX_DPBUF_DIS_OFFSET)
#define MPFS_USB_TX_DPBUF_DIS (MPFS_USB_BASE + MPFS_USB_TX_DPBUF_DIS_OFFSET)

/* MPFS_USB_DMA_ADDR_UPPER_REG is used to set the upper 6-bits of
* the Address bus for USB DMA operations.
*/

#define MPFS_USB_DMA_ADDR_UPPER_REG (MPFS_USB_BASE + MPFS_USB_DMA_ADDR_UPPER_REG_OFFSET)

#define MPFS_USB_DMA_CHANNEL(n) (MPFS_USB_BASE + MPFS_USB_DMA_CHANNEL_OFFSET + MPFS_USB_DMA_CHANNEL_SIZE * n)

/****************************************************************************
Expand Down
8 changes: 8 additions & 0 deletions arch/risc-v/src/mpfs/mpfs_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
# define MSB 1
#endif

#ifndef MPFS_USB_DMA_ADDR_UPPER_OFFSET
# define MPFS_USB_DMA_ADDR_UPPER_OFFSET 0x14u
#endif

#define MPFS_NUM_USB_PKT 1
#define MPFS_MIN_EP_FIFO_SIZE 8
#define MPFS_USB_REG_MAX 0x2000
Expand Down Expand Up @@ -3685,6 +3689,10 @@ static void mpfs_hw_setup(struct mpfs_usbdev_s *priv)
modifyreg32(MPFS_SYSREG_SOFT_RESET_CR, SYSREG_SOFT_RESET_CR_USB |
SYSREG_SOFT_RESET_CR_FPGA, 0);

/* Set USB upper address offset to enable USB DMA support for himen */

mpfs_putreg32(MPFS_USB_DMA_ADDR_UPPER_OFFSET, MPFS_USB_DMA_ADDR_UPPER_REG);

/* Reset the controller */

mpfs_putreg8(SOFT_RESET_REG_MASK, MPFS_USB_SOFT_RST);
Expand Down
2 changes: 2 additions & 0 deletions boards/risc-v/mpfs/icicle/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
# define MPFS_SD_CLOCK_4BIT MPFS_MMC_CLOCK_25MHZ
#endif

#define MPFS_USB_DMA_ADDR_UPPER_OFFSET 0x14u

/* Clocking TODO: */

#define MPFS_MSS_EXT_SGMII_REF_CLK (125000000UL)
Expand Down

0 comments on commit 2563e16

Please sign in to comment.