-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
usb: phytium: Add support for Phytium USB controller
This patch adds the Phytium USBHS DRD controller support. Signed-off-by: Wang Zhimin <[email protected]> Signed-off-by: Li Mingzhe <[email protected]> Signed-off-by: Zuo Qian <[email protected]> Signed-off-by: Chen Zhenhua <[email protected]> Signed-off-by: Chen Baozi <[email protected]> Signed-off-by: Wang Yinfeng <[email protected]>
- Loading branch information
1 parent
f9eead8
commit 38ee0fb
Showing
15 changed files
with
7,677 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
config USB_PHYTIUM | ||
tristate "Phytium USB Support" | ||
depends on USB | ||
depends on USB_GADGET | ||
help | ||
Say Y or M here if your system has a OTG USB Controller based on PHYTIUM SOC. | ||
like Pe220x. | ||
|
||
If you choose to build this driver is a dynamically linked modules, the module will | ||
be called phytium-usb.ko | ||
|
||
config USB_PHYTIUM_PCI | ||
tristate "Phytium PCI USB Support" | ||
default n | ||
depends on USB | ||
depends on USB_GADGET | ||
help | ||
Say Y or M here if your system has a OTG USB Controller based on PHYTIUM SOC. | ||
like Pe220x. | ||
|
||
If you choose to build this driver is a dynamically linked modules, the module will | ||
be called phytium-usb.ko |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
obj-$(CONFIG_USB_PHYTIUM) += phytium-usb.o | ||
obj-$(CONFIG_USB_PHYTIUM_PCI) += phytium-usb-pci.o | ||
|
||
phytium-usb-y := core.o dma.o platform.o host.o gadget.o | ||
phytium-usb-pci-y := core.o dma.o pci.o host.o gadget.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include "core.h" | ||
|
||
int phytium_core_reset(struct phytium_cusb *config, bool skip_wait) | ||
{ | ||
if (!config) | ||
return 0; | ||
|
||
spin_lock_init(&config->lock); | ||
|
||
return 0; | ||
} | ||
|
||
uint32_t phytium_read32(uint32_t *address) | ||
{ | ||
return readl(address); | ||
} | ||
|
||
void phytium_write32(uint32_t *address, uint32_t value) | ||
{ | ||
writel(value, address); | ||
} | ||
|
||
uint16_t phytium_read16(uint16_t *address) | ||
{ | ||
return readw(address); | ||
} | ||
|
||
void phytium_write16(uint16_t *address, uint16_t value) | ||
{ | ||
writew(value, address); | ||
} | ||
|
||
uint8_t phytium_read8(uint8_t *address) | ||
{ | ||
return readb(address); | ||
} | ||
|
||
void phytium_write8(uint8_t *address, uint8_t value) | ||
{ | ||
writeb(value, address); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
|
||
#ifndef __PHYTIUM_CORE_H__ | ||
#define __PHYTIUM_CORE_H__ | ||
|
||
#include <linux/usb/gadget.h> | ||
#include <linux/usb/otg.h> | ||
#include "host_api.h" | ||
#include "gadget.h" | ||
|
||
#define MAX_EPS_CHANNELS 16 | ||
|
||
struct phytium_ep { | ||
struct phytium_cusb *config; | ||
u16 max_packet; | ||
u8 ep_num; | ||
struct GADGET_EP *gadget_ep; | ||
struct list_head req_list; | ||
struct usb_ep end_point; | ||
char name[12]; | ||
u8 is_tx; | ||
const struct usb_endpoint_descriptor *desc; | ||
u8 busy; | ||
}; | ||
|
||
struct phytium_request { | ||
struct usb_request request; | ||
struct GADGET_REQ *gadget_request; | ||
struct list_head list; | ||
struct phytium_ep *ep; | ||
struct phytium_cusb *config; | ||
u8 is_tx; | ||
u8 epnum; | ||
}; | ||
|
||
struct phytium_cusb { | ||
struct device *dev; | ||
void __iomem *regs; | ||
void __iomem *phy_regs; | ||
int irq; | ||
spinlock_t lock; | ||
enum usb_dr_mode dr_mode; | ||
|
||
struct GADGET_OBJ *gadget_obj; | ||
struct GADGET_CFG gadget_cfg; | ||
struct GADGET_CALLBACKS gadget_callbacks; | ||
struct GADGET_SYSREQ gadget_sysreq; | ||
struct GADGET_DEV *gadget_dev; | ||
void *gadget_priv; | ||
|
||
struct usb_gadget gadget; | ||
struct usb_gadget_driver *gadget_driver; | ||
struct phytium_ep endpoints_tx[MAX_EPS_CHANNELS]; | ||
struct phytium_ep endpoints_rx[MAX_EPS_CHANNELS]; | ||
u8 ep0_data_stage_is_tx; | ||
|
||
struct HOST_OBJ *host_obj; | ||
struct HOST_CFG host_cfg; | ||
struct HOST_CALLBACKS host_callbacks; | ||
struct HOST_SYSREQ host_sysreq; | ||
void *host_priv; | ||
struct usb_hcd *hcd; | ||
|
||
struct DMA_OBJ *dma_obj; | ||
struct DMA_CFG dma_cfg; | ||
struct DMA_CALLBACKS dma_callbacks; | ||
struct DMA_SYSREQ dma_sysreq; | ||
bool isVhubHost; | ||
}; | ||
|
||
int phytium_core_reset(struct phytium_cusb *config, bool skip_wait); | ||
|
||
int phytium_host_init(struct phytium_cusb *config); | ||
int phytium_host_uninit(struct phytium_cusb *config); | ||
|
||
#ifdef CONFIG_PM | ||
int phytium_host_resume(void *priv); | ||
int phytium_host_suspend(void *priv); | ||
int phytium_gadget_resume(void *priv); | ||
int phytium_gadget_suspend(void *priv); | ||
#endif | ||
|
||
int phytium_gadget_init(struct phytium_cusb *config); | ||
int phytium_gadget_uninit(struct phytium_cusb *config); | ||
|
||
uint32_t phytium_read32(uint32_t *address); | ||
|
||
void phytium_write32(uint32_t *address, uint32_t value); | ||
|
||
uint16_t phytium_read16(uint16_t *address); | ||
|
||
void phytium_write16(uint16_t *address, uint16_t value); | ||
|
||
uint8_t phytium_read8(uint8_t *address); | ||
|
||
void phytium_write8(uint8_t *address, uint8_t value); | ||
|
||
#endif |
Oops, something went wrong.