diff options
Diffstat (limited to 'drivers/usb/imx/imx-usb-misc.c')
-rw-r--r-- | drivers/usb/imx/imx-usb-misc.c | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/drivers/usb/imx/imx-usb-misc.c b/drivers/usb/imx/imx-usb-misc.c index ef3892c220..bf9583e626 100644 --- a/drivers/usb/imx/imx-usb-misc.c +++ b/drivers/usb/imx/imx-usb-misc.c @@ -1,16 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de> * Copyright (C) 2010 Freescale Semiconductor, Inc. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. */ #include <common.h> @@ -18,9 +9,9 @@ #include <io.h> #include <of.h> #include <errno.h> -#include <usb/chipidea-imx.h> -#include <mach/imx6-regs.h> -#include <mach/iomux-mx6.h> +#include <linux/usb/chipidea-imx.h> +#include <mach/imx/imx6-regs.h> +#include <mach/imx/iomux-mx6.h> #define MX25_OTG_SIC_SHIFT 29 #define MX25_OTG_SIC_MASK (0x3 << MX25_OTG_SIC_SHIFT) @@ -353,7 +344,8 @@ static __maybe_unused struct imx_usb_misc_data mx5_data = { #define MX6_USB_CTRL(n) ((n) * 4) #define MX6_USB_CTRL_OVER_CUR_DIS (1 << 7) -#define MX6_USB_CTRL_OVER_CUR_ACT_HIGH (1 << 8) +#define MX6_USB_CTRL_OVER_CUR_ACT_LOW (1 << 8) +#define MX6_USB_CTRL_PWR_POLARITY (1 << 9) static void mx6_hsic_pullup(unsigned long reg, int on) { @@ -378,8 +370,17 @@ static __maybe_unused int mx6_initialize_usb_hw(void __iomem *base, int port, case 0: case 1: val = readl(base + MX6_USB_CTRL(port)); - if (flags & MXC_EHCI_DISABLE_OVERCURRENT) + if (flags & MXC_EHCI_DISABLE_OVERCURRENT) { val |= MX6_USB_CTRL_OVER_CUR_DIS; + } else { + val &= ~MX6_USB_CTRL_OVER_CUR_DIS; + if (flags & MXC_EHCI_OC_PIN_ACTIVE_LOW) + val |= MX6_USB_CTRL_OVER_CUR_ACT_LOW; + else + val &= ~MX6_USB_CTRL_OVER_CUR_ACT_LOW; + } + if (flags & MXC_EHCI_PWR_PIN_ACTIVE_HIGH) + val |= MX6_USB_CTRL_PWR_POLARITY; writel(val, base + MX6_USB_CTRL(port)); break; case 2: /* HSIC port */ @@ -450,10 +451,12 @@ static int usbmisc_imx7d_init(void __iomem *base, int port, } else { reg &= ~MX6_USB_CTRL_OVER_CUR_DIS; if (flags & MXC_EHCI_OC_PIN_ACTIVE_LOW) - reg &= ~MX6_USB_CTRL_OVER_CUR_ACT_HIGH; + reg |= MX6_USB_CTRL_OVER_CUR_ACT_LOW; else - reg |= MX6_USB_CTRL_OVER_CUR_ACT_HIGH; + reg &= ~MX6_USB_CTRL_OVER_CUR_ACT_LOW; } + if (flags & MXC_EHCI_PWR_PIN_ACTIVE_HIGH) + reg |= MX6_USB_CTRL_PWR_POLARITY; writel(reg, base); reg = readl(base + MX7D_USBNC_USB_CTRL2); @@ -599,6 +602,16 @@ static __maybe_unused struct of_device_id imx_usbmisc_dt_ids[] = { .data = &mx7_data, }, #endif +#if defined CONFIG_ARCH_IMX8M || defined CONFIG_ARCH_IMX93 + { + .compatible = "fsl,imx8mm-usbmisc", + .data = &mx7_data, + }, + { + .compatible = "fsl,imx8mn-usbmisc", + .data = &mx7_data, + }, +#endif #ifdef CONFIG_ARCH_VF610 { .compatible = "fsl,vf610-usbmisc", @@ -609,8 +622,9 @@ static __maybe_unused struct of_device_id imx_usbmisc_dt_ids[] = { /* sentinel */ }, }; +MODULE_DEVICE_TABLE(of, imx_usbmisc_dt_ids); -int imx_usbmisc_port_init(struct device_d *dev, int port, unsigned flags) +int imx_usbmisc_port_init(struct device *dev, int port, unsigned flags) { struct imx_usb_misc_priv *usbmisc = dev->priv; @@ -623,7 +637,7 @@ int imx_usbmisc_port_init(struct device_d *dev, int port, unsigned flags) return usbmisc->data->init(usbmisc->base, port, flags); } -int imx_usbmisc_port_post_init(struct device_d *dev, int port, unsigned flags) +int imx_usbmisc_port_post_init(struct device *dev, int port, unsigned flags) { struct imx_usb_misc_priv *usbmisc = dev->priv; @@ -636,7 +650,7 @@ int imx_usbmisc_port_post_init(struct device_d *dev, int port, unsigned flags) return usbmisc->data->post_init(usbmisc->base, port, flags); } -static int imx_usbmisc_probe(struct device_d *dev) +static int imx_usbmisc_probe(struct device *dev) { struct resource *iores; struct imx_usb_misc_data *devtype; @@ -660,17 +674,11 @@ static int imx_usbmisc_probe(struct device_d *dev) return 0; } -static struct driver_d imx_usbmisc_driver = { +static struct driver imx_usbmisc_driver = { .name = "imx-usbmisc", .probe = imx_usbmisc_probe, .id_table = imx_usbmisc_ids, .of_compatible = DRV_OF_COMPAT(imx_usbmisc_dt_ids), }; -static int imx_usbmisc_init(void) -{ - platform_driver_register(&imx_usbmisc_driver); - return 0; -} - -coredevice_initcall(imx_usbmisc_init); +coredevice_platform_driver(imx_usbmisc_driver); |