Skip to content

Adding legacy USB driver #2851

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

Merged
merged 3 commits into from
Jul 21, 2025
Merged

Conversation

UtsavAgarwalADI
Copy link

PR Description

Adding legacy musb driver for sc57x/58x and enabling DMA where applicable

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly (if there is the case)

@@ -0,0 +1,85 @@

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


maintainers:
- Nathan Barrett-Morrison <nathan.morrison@timesys.com>
- Greg Malysa <greg.malysa@timesys.com>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do they still want to maintain these if they ever make it upstream? Either way, I assume these e-mail addresses aren't valid anymore?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should be just adsp-linux@analog.com

*
* Contact: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
* Contact: Greg Malysa <greg.malysa@timesys.com>
*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*

*
* Contact: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
* Contact: Greg Malysa <greg.malysa@timesys.com>
*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*

module_platform_driver(adi_musb_driver);

MODULE_DESCRIPTION("ADI MUSB Glue Layer");
MODULE_AUTHOR("Hao Liang <hliang1025@gmail.com>");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, I see one mainline contribution from Hao Liang:

1569039db006 bfin uart: it will hang when read current y count if not disable dma irq

I wonder why he's listed as the author.

@@ -120,4 +120,6 @@ CONFIG_CRC_CCITT=y
CONFIG_PRINTK_TIME=y
CONFIG_DEBUG_KERNEL=y
CONFIG_DEBUG_FS=y
CONFIG_USB_MUSB_ADI=y
CONFIG_USB_INVENTRA_DMA=y
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is a conflict, but also it is good practice to select through menuconfig and savedefconfig or to run make sc5890-mini_defconfig; make savedefconfig before committing.

Ideally the commit message would be declarative and have a prefix matching mainline:

ARM: configs: sc589-mini: Enable MUSB DMA

ARM: defconfig: would refer to multiple different defconfigs.

}
pdata.mode = class;

pdata.power = get_int_prop(pdev->dev.of_node, "mentor,power")/2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope checkpatch would catch this:

Suggested change
pdata.power = get_int_prop(pdev->dev.of_node, "mentor,power")/2;
pdata.power = get_int_prop(pdev->dev.of_node, "mentor,power") / 2;

Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial comments. The commit message should be improved a lot... That you're adding some glue code we can see :). You need to explain why we need it for our platforms and some explanation on why all those platforms devices are needed would also be great.

.of_match_table = adi_musb_match,
},
};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need for blank line

#define __ADI_H__

static int get_int_prop(struct device_node *node, const char *s);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static?


platform_device_unregister(glue->musb);
usb_phy_generic_unregister(glue->phy);
kfree(glue);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fairly sure the above adi_musb_remove() is not needed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other musb glue layer implementations seem to have kept it:
https://elixir.bootlin.com/linux/v6.12/source/drivers/usb/musb/da8xx.c#L588
https://elixir.bootlin.com/linux/v6.12/source/drivers/usb/musb/mediatek.c#L507

Would this change be more in line with our particular case?

kfree(glue);

err0:
dev_err(&pdev->dev, "ADI MUSB device FAILED\n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use device managed APIs and you should be able to remove all the above labels.

{},
};

MODULE_DEVICE_TABLE(of, adi_musb_match);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be closer to the driver initialization

config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
if (!config) {
ret = -ENOMEM;
goto err2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return dev_err_probe(). Ditto for all other places


musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &musb_dmamask;
musb->dev.coherent_dma_mask = musb_dmamask;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use spaces

}

/*alloc musb platform_device and register */
musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no new line

if (!match) {
dev_err(&pdev->dev, "failed to matching of_match node\n");
return -EINVAL;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why having the above?

return 0;

return val;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above helper does not bring much

Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial comments. The commit message should be improved a lot... That you're adding some glue code we can see :). You need to explain why we need it for our platforms and some explanation on why all those platforms devices are needed would also be great.

@UtsavAgarwalADI
Copy link
Author

Changelog:

Driver:

  • Replaced maintainer info
  • Removed get_int_prop() due to lack of any meaningful contribution
  • Removed unnecessary static function declaration within header
  • Removed explicit dma mask value assignment since we already use the default
  • adi_musb_set_mode() now returns errors upon failure
  • Removed node matching from probe which does not contribute to device functionality
  • Replaced #defined() with #IF_ENABLED()
  • Updated error handling within probe to utilize dev_err_probe()
  • Updated error handling within probe to unregister phy upon failure as well
  • Updated commit description to explain why this driver is required for the kernel
  • Updated maintainer info

Documentation:

  • Updated maintainer info

Configs:

  • Updated SC589-mini defconfig with options generated from make savedefconfig
  • Updated commit subject from defconfig to configs to indicate single platform config change

Adding glue layer for adsp platforms sc57x/sc58x.

This is enables support for the following:

* usbboot: Mount and boot into file systems contained on USB devices by
switching OTG to host mode.

* usb gadget audio: Utilize linux's USB gadget for streaming audio from
another device by switching OTG to device mode.

Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com>
Adding documentation from legacy kernel for ADI musb glue
layer

Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com>
Enabling ADI musb to utilize DMA

Signed-off-by: UtsavAgarwalADI <utsav.agarwal@analog.com>
@UtsavAgarwalADI UtsavAgarwalADI force-pushed the adsp-main-6.12-legacy-usb branch 2 times, most recently from c0e11e5 to 0362992 Compare July 17, 2025 14:24
@UtsavAgarwalADI
Copy link
Author

UtsavAgarwalADI commented Jul 17, 2025

Changelog:

Adding signature to last commit
Updating maintainer contact in adi.c

Copy link

@artursartamonovsadi artursartamonovsadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can mount sdcard from usb adapter on sc589

@UtsavAgarwalADI UtsavAgarwalADI merged commit bde0fbf into adsp-main-6.12 Jul 21, 2025
1 check failed
@UtsavAgarwalADI UtsavAgarwalADI deleted the adsp-main-6.12-legacy-usb branch July 21, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants