diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2018-04-01 22:19:19 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2018-04-01 22:19:19 +0000 |
commit | 5fdcf970d9cf7fb20e077a644b77e323e5efbd8c (patch) | |
tree | 2d07ae8dee8cc377049108b41892dfe07a1b85ce /sys/arch/armv7/imx | |
parent | 0c7591555fb2cb7fdea70fbf560eda3cecfd1f5b (diff) |
Disable the USB charging detection using a regmap instead of cross-
calling imxccm using a special function.
ok kettenis@
Diffstat (limited to 'sys/arch/armv7/imx')
-rw-r--r-- | sys/arch/armv7/imx/imxccm.c | 24 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxccmvar.h | 4 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxehci.c | 45 |
3 files changed, 44 insertions, 29 deletions
diff --git a/sys/arch/armv7/imx/imxccm.c b/sys/arch/armv7/imx/imxccm.c index 4bd436544f6..f75a3a727ed 100644 --- a/sys/arch/armv7/imx/imxccm.c +++ b/sys/arch/armv7/imx/imxccm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxccm.c,v 1.14 2018/04/01 19:18:22 patrick Exp $ */ +/* $OpenBSD: imxccm.c,v 1.15 2018/04/01 22:19:18 patrick Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * @@ -239,8 +239,6 @@ uint32_t imxccm_get_ipg_perclk(struct imxccm_softc *); uint32_t imxccm_get_uartclk(struct imxccm_softc *); void imxccm_enable(void *, uint32_t *, int); uint32_t imxccm_get_frequency(void *, uint32_t *); -void imxccm_disable_usb1_chrg_detect(void); -void imxccm_disable_usb2_chrg_detect(void); void imxccm_enable_pll_usb1(void); void imxccm_enable_pll_usb2(void); void imxccm_enable_pll_enet(void); @@ -593,26 +591,6 @@ imxccm_enable_sata(void) } void -imxccm_disable_usb1_chrg_detect(void) -{ - struct imxccm_softc *sc = imxccm_sc; - - HWRITE4(sc, CCM_ANALOG_USB1_CHRG_DETECT_SET, - CCM_ANALOG_USB1_CHRG_DETECT_CHK_CHRG_B - | CCM_ANALOG_USB1_CHRG_DETECT_EN_B); -} - -void -imxccm_disable_usb2_chrg_detect(void) -{ - struct imxccm_softc *sc = imxccm_sc; - - HWRITE4(sc, CCM_ANALOG_USB2_CHRG_DETECT_SET, - CCM_ANALOG_USB2_CHRG_DETECT_CHK_CHRG_B - | CCM_ANALOG_USB2_CHRG_DETECT_EN_B); -} - -void imxccm_enable_pll_usb1(void) { struct imxccm_softc *sc = imxccm_sc; diff --git a/sys/arch/armv7/imx/imxccmvar.h b/sys/arch/armv7/imx/imxccmvar.h index 06dadbf1c10..b99f3adfe3e 100644 --- a/sys/arch/armv7/imx/imxccmvar.h +++ b/sys/arch/armv7/imx/imxccmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: imxccmvar.h,v 1.6 2018/04/01 19:07:31 patrick Exp $ */ +/* $OpenBSD: imxccmvar.h,v 1.7 2018/04/01 22:19:18 patrick Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * @@ -18,8 +18,6 @@ #ifndef IMXCCMVAR_H #define IMXCCMVAR_H -void imxccm_disable_usb1_chrg_detect(void); -void imxccm_disable_usb2_chrg_detect(void); void imxccm_enable_pll_usb1(void); void imxccm_enable_pll_usb2(void); void imxccm_enable_enet(void); diff --git a/sys/arch/armv7/imx/imxehci.c b/sys/arch/armv7/imx/imxehci.c index b664cba2223..98f950d5711 100644 --- a/sys/arch/armv7/imx/imxehci.c +++ b/sys/arch/armv7/imx/imxehci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxehci.c,v 1.20 2018/03/30 20:32:50 patrick Exp $ */ +/* $OpenBSD: imxehci.c,v 1.21 2018/04/01 22:19:18 patrick Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * @@ -36,6 +36,7 @@ #include <dev/ofw/openfirm.h> #include <dev/ofw/ofw_clock.h> #include <dev/ofw/ofw_gpio.h> +#include <dev/ofw/ofw_misc.h> #include <dev/ofw/ofw_pinctrl.h> #include <dev/ofw/ofw_regulator.h> #include <dev/ofw/fdt.h> @@ -69,6 +70,18 @@ #define USBNC_USB_UH1_CTRL_OVER_CUR_POL (1 << 8) #define USBNC_USB_UH1_CTRL_OVER_CUR_DIS (1 << 7) +/* anatop */ +#define ANALOG_USB1_CHRG_DETECT 0x1b0 +#define ANALOG_USB1_CHRG_DETECT_SET 0x1b4 +#define ANALOG_USB1_CHRG_DETECT_CLR 0x1b8 +#define ANALOG_USB1_CHRG_DETECT_CHK_CHRG_B (1 << 19) +#define ANALOG_USB1_CHRG_DETECT_EN_B (1 << 20) +#define ANALOG_USB2_CHRG_DETECT 0x210 +#define ANALOG_USB2_CHRG_DETECT_SET 0x214 +#define ANALOG_USB2_CHRG_DETECT_CLR 0x218 +#define ANALOG_USB2_CHRG_DETECT_CHK_CHRG_B (1 << 19) +#define ANALOG_USB2_CHRG_DETECT_EN_B (1 << 20) + int imxehci_match(struct device *, void *, void *); void imxehci_attach(struct device *, struct device *, void *); int imxehci_detach(struct device *, int); @@ -103,11 +116,13 @@ imxehci_attach(struct device *parent, struct device *self, void *aux) { struct imxehci_softc *sc = (struct imxehci_softc *)self; struct fdt_attach_args *faa = aux; + struct regmap *rm; usbd_status r; char *devname = sc->sc.sc_bus.bdev.dv_xname; uint32_t phy[1], misc[2]; uint32_t phy_reg[2]; uint32_t misc_reg[2]; + uint32_t anatop[1]; uint32_t vbus; int node; @@ -180,8 +195,20 @@ imxehci_attach(struct device *parent, struct device *self, void *aux) switch (misc[1]) { case 0: + node = OF_getnodebyphandle(phy[0]); + if (OF_getpropintarray(node, "fsl,anatop", + anatop, sizeof(anatop)) != sizeof(anatop)) + break; + + rm = regmap_byphandle(anatop[0]); + if (rm == NULL) + break; + /* disable the carger detection, else signal on DP will be poor */ - imxccm_disable_usb1_chrg_detect(); + regmap_write_4(rm, ANALOG_USB1_CHRG_DETECT_SET, + ANALOG_USB1_CHRG_DETECT_CHK_CHRG_B | + ANALOG_USB1_CHRG_DETECT_EN_B); + /* power host 0 */ imxccm_enable_pll_usb1(); @@ -191,8 +218,20 @@ imxehci_attach(struct device *parent, struct device *self, void *aux) (USBNC_USB_OTG_CTRL_OVER_CUR_POL | USBNC_USB_OTG_CTRL_OVER_CUR_DIS)); break; case 1: + node = OF_getnodebyphandle(phy[0]); + if (OF_getpropintarray(node, "fsl,anatop", + anatop, sizeof(anatop)) != sizeof(anatop)) + break; + + rm = regmap_byphandle(anatop[0]); + if (rm == NULL) + break; + /* disable the carger detection, else signal on DP will be poor */ - imxccm_disable_usb2_chrg_detect(); + regmap_write_4(rm, ANALOG_USB2_CHRG_DETECT_SET, + ANALOG_USB2_CHRG_DETECT_CHK_CHRG_B | + ANALOG_USB2_CHRG_DETECT_EN_B); + /* power host 1 */ imxccm_enable_pll_usb2(); |