Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147258947
D26348.id77286.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D26348.id77286.diff
View Options
Index: head/sys/arm/allwinner/aw_usbphy.c
===================================================================
--- head/sys/arm/allwinner/aw_usbphy.c
+++ head/sys/arm/allwinner/aw_usbphy.c
@@ -102,7 +102,7 @@
.num_phys = 4,
.phy_type = AWUSBPHY_TYPE_H3,
.pmu_unk1 = true,
- .phy0_route = false,
+ .phy0_route = true,
};
static const struct aw_usbphy_conf a64_usbphy_conf = {
@@ -175,8 +175,10 @@
#define FORCE_ID (0x3 << 14)
#define FORCE_ID_SHIFT 14
#define FORCE_ID_LOW 2
+#define FORCE_ID_HIGH 3
#define FORCE_VBUS_VALID (0x3 << 12)
#define FORCE_VBUS_VALID_SHIFT 12
+#define FORCE_VBUS_VALID_LOW 2
#define FORCE_VBUS_VALID_HIGH 3
#define VBUS_CHANGE_DET (1 << 6)
#define ID_CHANGE_DET (1 << 5)
@@ -190,18 +192,6 @@
#define PMU_ULPI_BYPASS (1 << 0)
#define PMU_UNK_H3 0x10
#define PMU_UNK_H3_CLR 0x2
-#define PHY_CSR 0x00
-#define ID_PULLUP_EN (1 << 17)
-#define DPDM_PULLUP_EN (1 << 16)
-#define FORCE_ID (0x3 << 14)
-#define FORCE_ID_SHIFT 14
-#define FORCE_ID_LOW 2
-#define FORCE_VBUS_VALID (0x3 << 12)
-#define FORCE_VBUS_VALID_SHIFT 12
-#define FORCE_VBUS_VALID_HIGH 3
-#define VBUS_CHANGE_DET (1 << 6)
-#define ID_CHANGE_DET (1 << 5)
-#define DPDM_CHANGE_DET (1 << 4)
static void
awusbphy_configure(device_t dev, int phyno)
@@ -335,7 +325,12 @@
return (0);
}
- *val = 0;
+ /* TODO check vbus_power-supply. */
+
+ /*
+ * If there is no way to detect, assume present.
+ */
+ *val = 1;
return (0);
}
@@ -369,10 +364,11 @@
if (error)
goto out;
- if (vbus_det == 1) {
+ /* TODO check vbus_power-supply as well. */
+ if (sc->vbus_det_valid && vbus_det == 1) {
if (bootverbose)
- device_printf(dev, "External VBUS detected, not enabling the regulator\n");
-
+ device_printf(dev, "External VBUS detected, "
+ "not enabling the regulator\n");
return (0);
}
}
@@ -426,36 +422,40 @@
return (0);
}
+ if (sc->mode == mode)
+ return (0);
+ if (mode == PHY_USB_MODE_OTG) /* TODO */
+ return (EOPNOTSUPP);
+
+ error = awusbphy_vbus_detect(dev, &vbus_det);
+ if (error != 0)
+ return (error);
+
+ val = bus_read_4(sc->phy_ctrl, PHY_CSR);
+ val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET);
+ val |= (ID_PULLUP_EN | DPDM_PULLUP_EN);
+ val &= ~FORCE_VBUS_VALID;
+ val |= (vbus_det ? FORCE_VBUS_VALID_HIGH : FORCE_VBUS_VALID_LOW) <<
+ FORCE_VBUS_VALID_SHIFT;
+ val &= ~FORCE_ID;
+
switch (mode) {
case PHY_USB_MODE_HOST:
- val = bus_read_4(sc->phy_ctrl, PHY_CSR);
- val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET);
- val |= (ID_PULLUP_EN | DPDM_PULLUP_EN);
- val &= ~FORCE_ID;
val |= (FORCE_ID_LOW << FORCE_ID_SHIFT);
- val &= ~FORCE_VBUS_VALID;
- val |= (FORCE_VBUS_VALID_HIGH << FORCE_VBUS_VALID_SHIFT);
- bus_write_4(sc->phy_ctrl, PHY_CSR, val);
- if (sc->phy_conf->phy0_route == true) {
- error = awusbphy_vbus_detect(dev, &vbus_det);
- if (error)
- goto out;
- if (vbus_det == 0)
- CLR4(sc->phy_ctrl, OTG_PHY_CFG,
- OTG_PHY_ROUTE_OTG);
- else
- SET4(sc->phy_ctrl, OTG_PHY_CFG,
- OTG_PHY_ROUTE_OTG);
- }
+ if (sc->phy_conf->phy0_route)
+ CLR4(sc->phy_ctrl, OTG_PHY_CFG, OTG_PHY_ROUTE_OTG);
break;
- case PHY_USB_MODE_OTG:
- /* TODO */
+ case PHY_USB_MODE_DEVICE:
+ val |= (FORCE_ID_HIGH << FORCE_ID_SHIFT);
+ if (sc->phy_conf->phy0_route)
+ SET4(sc->phy_ctrl, OTG_PHY_CFG, OTG_PHY_ROUTE_OTG);
break;
+ default:
+ return (EINVAL);
}
+ bus_write_4(sc->phy_ctrl, PHY_CSR, val);
sc->mode = mode;
-
-out:
return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 10, 12:30 PM (9 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29447810
Default Alt Text
D26348.id77286.diff (3 KB)
Attached To
Mode
D26348: aw_usbphy: add support for device mode operation
Attached
Detach File
Event Timeline
Log In to Comment