-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
usb: phytium: Add support for Phytium USB controller #140
Closed
wangzhimin1179
wants to merge
2
commits into
deepin-community:linux-6.6.y
from
wangzhimin1179:linux-6.6.y
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause | ||
%YAML 1.2 | ||
--- | ||
$id: http://devicetree.org/schemas/usb/phytium,usb2.yaml# | ||
$schema: http://devicetree.org/meta-schemas/core.yaml# | ||
|
||
title: Phytium USBHS-DRD controller bindings | ||
|
||
maintainers: | ||
- Chen Baozi <[email protected]> | ||
|
||
properties: | ||
compatible: | ||
const: phytium,usb2 | ||
|
||
reg: | ||
items: | ||
- description: USB controller registers | ||
- description: PHY registers | ||
|
||
interrupts: | ||
maxItems: 1 | ||
|
||
dr_mode: | ||
enum: [host, otg, peripheral] | ||
|
||
required: | ||
- compatible | ||
- reg | ||
- interrupts | ||
|
||
additionalProperties: false | ||
|
||
examples: | ||
- | | ||
usb2_0: usb2@31800000 { | ||
compatible = "phytium,usb2"; | ||
reg = <0x0 0x31800000 0x0 0x80000>, | ||
<0x0 0x31990000 0x0 0x10000>; | ||
interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>; | ||
}; |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议和飞腾其它驱动配置项保持一致,PHYTIUM改为Phytium