Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
usb: misc: usb2244: add support for USB2 ultra fast sd controller
This patch adds a GPIO based usb-sd reset for USB2244 USB2 ultra fast SD controller. This usb2244 driver trigger sd reset signal after soft reset or core Reset. The SD needs to be resetted after completion of phy initialization. After the toggling of gpio, controller gets out form reset. USB2244 is a simple platform device driver. As part of the reset, sets the direction of the pin to output before toggling the pin. Delay of microseconds is added in between low and high to meet the setup and hold time requirement of the reset. Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
- Loading branch information
Piyush Mehta
authored and
Michal Simek
committed
Jan 11, 2022
1 parent
5931a54
commit 86b8431235c705e722728c75c641b002bf527c13
Showing
3 changed files
with
78 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,69 @@ | ||
| // SPDX-License-Identifier: GPL-2.0 | ||
| /* | ||
| * Driver for the Microchip USB2244 Ultra Fast USB 2.0 Multi-Format, | ||
| * SD/MMC, and MS Flash Media Controllers | ||
| * | ||
| * Copyright (c) 2021 Xilinx, Inc. | ||
| */ | ||
|
|
||
| #include <linux/delay.h> | ||
| #include <linux/err.h> | ||
| #include <linux/kernel.h> | ||
| #include <linux/module.h> | ||
| #include <linux/of_platform.h> | ||
| #include <linux/gpio/consumer.h> | ||
| #include <linux/platform_device.h> | ||
|
|
||
| struct usb2244 { | ||
| struct gpio_desc *reset_gpio; | ||
| }; | ||
|
|
||
| static int usb2244_init_hw(struct device *dev, struct usb2244 *data) | ||
| { | ||
| data = devm_kzalloc(dev, sizeof(struct usb2244), GFP_KERNEL); | ||
| if (!data) | ||
| return -ENOMEM; | ||
|
|
||
| data->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); | ||
| if (IS_ERR(data->reset_gpio)) { | ||
| dev_err_probe(dev, PTR_ERR(data->reset_gpio), | ||
| "Failed to request reset GPIO %d, errcode", | ||
| PTR_ERR(data->reset_gpio)); | ||
| return PTR_ERR(data->reset_gpio); | ||
| } | ||
|
|
||
| /* Toggle RESET_N to reset the hub. */ | ||
| gpiod_set_value_cansleep(data->reset_gpio, 0); | ||
| usleep_range(5, 10); | ||
| gpiod_set_value_cansleep(data->reset_gpio, 1); | ||
| msleep(5); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| static int usb2244_probe(struct platform_device *pdev) | ||
| { | ||
| struct usb2244 *data = NULL; | ||
|
|
||
| /* Trigger gpio reset to the hub. */ | ||
| return usb2244_init_hw(&pdev->dev, data); | ||
| } | ||
|
|
||
| static const struct of_device_id usb2244_of_match[] = { | ||
| { .compatible = "microchip,usb2244", }, | ||
| { } | ||
| }; | ||
|
|
||
| static struct platform_driver usb2244_driver = { | ||
| .driver = { | ||
| .name = "microchip,usb2244", | ||
| .of_match_table = usb2244_of_match, | ||
| }, | ||
| .probe = usb2244_probe, | ||
| }; | ||
|
|
||
| module_platform_driver(usb2244_driver); | ||
|
|
||
| MODULE_AUTHOR("Piyush Mehta <piyush.mehta@xilinx.com>"); | ||
| MODULE_DESCRIPTION("USB2244 Ultra Fast SD-Controller"); | ||
| MODULE_LICENSE("GPL v2"); |