Microchip's USB224x family of Hi-Speed USB 2.0 flash media card
controllers provide an ultra-fast interface between a USB host
controller and flash media cards.
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.
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.
Piyush Mehta (2):
dt-bindings: usb: misc: Add binding for Microchip usb2244 Controller
usb: misc: usb244: add support for USB2 ultra fast sd controller
.../devicetree/bindings/usb/microchip,usb2244.yaml | 43 ++++++++++++++
drivers/usb/misc/Kconfig | 8 +++
drivers/usb/misc/Makefile | 1 +
drivers/usb/misc/usb2244.c | 69 ++++++++++++++++++++++
4 files changed, 121 insertions(+)
create mode 100644 Documentation/devicetree/bindings/usb/microchip,usb2244.yaml
create mode 100644 drivers/usb/misc/usb2244.c
--
2.7.4
Microchip's USB224x family of Hi-Speed USB 2.0 flash media card controllers
provides an ultra-fast interface between a USB host controller and flash
media cards.
Add dt-bindings documentation for Microchip's usb2244 Controller.
USB224x is a USB 2.0 compliant ultra fast USB 2.0 multi-format,
SD/MMC, and MS Flash Media Controllers.
Signed-off-by: Piyush Mehta <[email protected]>
---
.../devicetree/bindings/usb/microchip,usb2244.yaml | 43 ++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 Documentation/devicetree/bindings/usb/microchip,usb2244.yaml
diff --git a/Documentation/devicetree/bindings/usb/microchip,usb2244.yaml b/Documentation/devicetree/bindings/usb/microchip,usb2244.yaml
new file mode 100644
index 0000000..ecab0cb
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/microchip,usb2244.yaml
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/usb/microchip,usb2244.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Bindings for the Microchip USB2244 Ultra Fast USB-SD Controller
+
+description:
+ Microchip’s USB224x is a USB 2.0 compliant, Hi-Speed bulk only mass
+ storage class peripheral controller intended for reading and writing
+ to popular flash media from the xDPicture Card™, Memory Stick® (MS),
+ Secure Digital (SD), and MultiMediaCard™ (MMC) families.
+
+ USB224x is a flash media card reader solution fully compliant with the
+ USB 2.0 specification
+
+maintainers:
+ - Piyush Mehta <[email protected]>
+
+properties:
+ compatible:
+ const: microchip,usb2244
+
+ reset-gpios:
+ maxItems: 1
+ description:
+ The phandle and specifier for the GPIO that controls the RESET line of
+ flash media controller.
+
+required:
+ - compatible
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+
+ usb {
+ compatible = "microchip,usb2244";
+ reset-gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
+ };
--
2.7.4
Microchip's USB224x family of Hi-Speed USB 2.0 flash media card controllers
provides an ultra-fast interface between a USB host controller and flash
media cards.
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 <[email protected]>
---
drivers/usb/misc/Kconfig | 8 ++++++
drivers/usb/misc/Makefile | 1 +
drivers/usb/misc/usb2244.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 78 insertions(+)
create mode 100644 drivers/usb/misc/usb2244.c
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 8f11443..5480c50 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -233,6 +233,14 @@ config USB_EZUSB_FX2
Say Y here if you need EZUSB device support.
(Cypress FX/FX2/FX2LP microcontrollers)
+config USB_USB2244
+ tristate "Microchip USB2244 Ultra Fast USB 2.0 SD driver"
+ depends on GPIOLIB
+ help
+ This option enables support for Microchip USB2244 Ultra Fast USB 2.0
+ SD controller. This driver reset the gpio pin makes controller out of
+ reset.
+
config USB_HUB_USB251XB
tristate "USB251XB Hub Controller Configuration Driver"
depends on I2C
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 5f4e598..ec22c12 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
obj-$(CONFIG_USB_USS720) += uss720.o
obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o
obj-$(CONFIG_USB_YUREX) += yurex.o
+obj-$(CONFIG_USB_USB2244) += usb2244.o
obj-$(CONFIG_USB_HUB_USB251XB) += usb251xb.o
obj-$(CONFIG_USB_HSIC_USB3503) += usb3503.o
obj-$(CONFIG_USB_HSIC_USB4604) += usb4604.o
diff --git a/drivers/usb/misc/usb2244.c b/drivers/usb/misc/usb2244.c
new file mode 100644
index 0000000..c9613b6
--- /dev/null
+++ b/drivers/usb/misc/usb2244.c
@@ -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 %ld, 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 <[email protected]>");
+MODULE_DESCRIPTION("USB2244 Ultra Fast SD-Controller");
+MODULE_LICENSE("GPL v2");
--
2.7.4
On Sun, Oct 24, 2021 at 1:06 PM Piyush Mehta <[email protected]> wrote:
>
Your email is somewhat corrupted. Lore has a warning:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="y", Size: 2065 bytes --]
Maybe it's the '[email protected]' email...
> Microchip's USB224x family of Hi-Speed USB 2.0 flash media card controllers
> provides an ultra-fast interface between a USB host controller and flash
> media cards.
>
> Add dt-bindings documentation for Microchip's usb2244 Controller.
> USB224x is a USB 2.0 compliant ultra fast USB 2.0 multi-format,
> SD/MMC, and MS Flash Media Controllers.
>
> Signed-off-by: Piyush Mehta <[email protected]>
> ---
> .../devicetree/bindings/usb/microchip,usb2244.yaml | 43 ++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/usb/microchip,usb2244.yaml
>
> diff --git a/Documentation/devicetree/bindings/usb/microchip,usb2244.yaml b/Documentation/devicetree/bindings/usb/microchip,usb2244.yaml
> new file mode 100644
> index 0000000..ecab0cb
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/microchip,usb2244.yaml
> @@ -0,0 +1,43 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/usb/microchip,usb2244.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Bindings for the Microchip USB2244 Ultra Fast USB-SD Controller
> +
> +description:
> + Microchip’s USB224x is a USB 2.0 compliant, Hi-Speed bulk only mass
> + storage class peripheral controller intended for reading and writing
> + to popular flash media from the xDPicture Card™, Memory Stick® (MS),
> + Secure Digital (SD), and MultiMediaCard™ (MMC) families.
> +
> + USB224x is a flash media card reader solution fully compliant with the
> + USB 2.0 specification
> +
> +maintainers:
> + - Piyush Mehta <[email protected]>
> +
> +properties:
> + compatible:
> + const: microchip,usb2244
> +
> + reset-gpios:
> + maxItems: 1
> + description:
> + The phandle and specifier for the GPIO that controls the RESET line of
> + flash media controller.
> +
> +required:
> + - compatible
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/gpio/gpio.h>
> +
> + usb {
> + compatible = "microchip,usb2244";
This needs to be a USB device under a USB controller node. See usb-device.yaml.
> + reset-gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
> + };
> --
> 2.7.4
>