Skip to content

Commit d91de09

Browse files
jwrdegoedeFelipe Balbi
authored andcommitted
usb: musb: sunxi: Add support for musb controller in A33 SoC
The A33 SoC uses the same musb controller as found on the A31 and later, but allwinner has removed the configdata register, this commit adds special handling for this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
1 parent 132e237 commit d91de09

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Allwinner sun4i A10 musb DRC/OTG controller
22
-------------------------------------------
33

44
Required properties:
5-
- compatible : "allwinner,sun4i-a10-musb" or "allwinner,sun6i-a31-musb"
5+
- compatible : "allwinner,sun4i-a10-musb", "allwinner,sun6i-a31-musb"
6+
or "allwinner,sun8i-a33-musb"
67
- reg : mmio address range of the musb controller
78
- clocks : clock specifier for the musb controller ahb gate clock
89
- reset : reset specifier for the ahb reset (A31 and newer only)

‎drivers/usb/musb/sunxi.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#define SUNXI_MUSB_FL_PHY_ON 4
7474
#define SUNXI_MUSB_FL_HAS_SRAM 5
7575
#define SUNXI_MUSB_FL_HAS_RESET 6
76+
#define SUNXI_MUSB_FL_NO_CONFIGDATA 7
7677

7778
/* Our read/write methods need access and do not get passed in a musb ref :| */
7879
static struct musb *sunxi_musb;
@@ -370,6 +371,8 @@ static u32 sunxi_musb_busctl_offset(u8 epnum, u16 offset)
370371

371372
static u8 sunxi_musb_readb(const void __iomem *addr, unsigned offset)
372373
{
374+
struct sunxi_glue *glue;
375+
373376
if (addr == sunxi_musb->mregs) {
374377
/* generic control or fifo control reg access */
375378
switch (offset) {
@@ -392,6 +395,12 @@ static u8 sunxi_musb_readb(const void __iomem *addr, unsigned offset)
392395
case MUSB_RXFIFOSZ:
393396
return readb(addr + SUNXI_MUSB_RXFIFOSZ);
394397
case MUSB_CONFIGDATA + 0x10: /* See musb_read_configdata() */
398+
glue = dev_get_drvdata(sunxi_musb->controller->parent);
399+
/* A33 saves a reg, and we get to hardcode this */
400+
if (test_bit(SUNXI_MUSB_FL_NO_CONFIGDATA,
401+
&glue->flags))
402+
return 0xde;
403+
395404
return readb(addr + SUNXI_MUSB_CONFIGDATA);
396405
/* Offset for these is fixed by sunxi_musb_busctl_offset() */
397406
case SUNXI_MUSB_TXFUNCADDR:
@@ -643,6 +652,11 @@ static int sunxi_musb_probe(struct platform_device *pdev)
643652
if (of_device_is_compatible(np, "allwinner,sun6i-a31-musb"))
644653
set_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags);
645654

655+
if (of_device_is_compatible(np, "allwinner,sun8i-a33-musb")) {
656+
set_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags);
657+
set_bit(SUNXI_MUSB_FL_NO_CONFIGDATA, &glue->flags);
658+
}
659+
646660
glue->clk = devm_clk_get(&pdev->dev, NULL);
647661
if (IS_ERR(glue->clk)) {
648662
dev_err(&pdev->dev, "Error getting clock: %ld\n",
@@ -723,6 +737,7 @@ static int sunxi_musb_remove(struct platform_device *pdev)
723737
static const struct of_device_id sunxi_musb_match[] = {
724738
{ .compatible = "allwinner,sun4i-a10-musb", },
725739
{ .compatible = "allwinner,sun6i-a31-musb", },
740+
{ .compatible = "allwinner,sun8i-a33-musb", },
726741
{}
727742
};
728743

0 commit comments

Comments
 (0)