Skip to content

Commit 9c1587d

Browse files
rmsilvagregkh
authored andcommitted
usb: isp1760: otg control register access
The set/clear of the otg control values is done writing to two different 16bit registers, however we setup the regmap width for isp1760/61 to 32bit value bits. So, just access the clear register address (0x376)as the high part of the otg control register set (0x374), and write the values in one go to make sure they get clear/set. Reported-by: Dietmar Eggemann <[email protected]> Tested-by: Dietmar Eggemann <[email protected]> Signed-off-by: Rui Miguel Silva <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 955d0fb commit 9c1587d

File tree

2 files changed

+42
-24
lines changed

2 files changed

+42
-24
lines changed

drivers/usb/isp1760/isp1760-core.c

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static int isp1760_init_core(struct isp1760_device *isp)
3030
{
3131
struct isp1760_hcd *hcd = &isp->hcd;
3232
struct isp1760_udc *udc = &isp->udc;
33+
u32 otg_ctrl;
3334

3435
/* Low-level chip reset */
3536
if (isp->rst_gpio) {
@@ -83,16 +84,17 @@ static int isp1760_init_core(struct isp1760_device *isp)
8384
*
8485
* TODO: Really support OTG. For now we configure port 1 in device mode
8586
*/
86-
if (((isp->devflags & ISP1760_FLAG_ISP1761) ||
87-
(isp->devflags & ISP1760_FLAG_ISP1763)) &&
88-
(isp->devflags & ISP1760_FLAG_PERIPHERAL_EN)) {
89-
isp1760_field_set(hcd->fields, HW_DM_PULLDOWN);
90-
isp1760_field_set(hcd->fields, HW_DP_PULLDOWN);
91-
isp1760_field_set(hcd->fields, HW_OTG_DISABLE);
92-
} else {
93-
isp1760_field_set(hcd->fields, HW_SW_SEL_HC_DC);
94-
isp1760_field_set(hcd->fields, HW_VBUS_DRV);
95-
isp1760_field_set(hcd->fields, HW_SEL_CP_EXT);
87+
if (isp->devflags & ISP1760_FLAG_ISP1761) {
88+
if (isp->devflags & ISP1760_FLAG_PERIPHERAL_EN) {
89+
otg_ctrl = (ISP176x_HW_DM_PULLDOWN_CLEAR |
90+
ISP176x_HW_DP_PULLDOWN_CLEAR |
91+
ISP176x_HW_OTG_DISABLE);
92+
} else {
93+
otg_ctrl = (ISP176x_HW_SW_SEL_HC_DC_CLEAR |
94+
ISP176x_HW_VBUS_DRV |
95+
ISP176x_HW_SEL_CP_EXT);
96+
}
97+
isp1760_reg_write(hcd->regs, ISP176x_HC_OTG_CTRL, otg_ctrl);
9698
}
9799

98100
dev_info(isp->dev, "%s bus width: %u, oc: %s\n",
@@ -235,20 +237,20 @@ static const struct reg_field isp1760_hc_reg_fields[] = {
235237
[HC_ISO_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_ISO_IRQ_MASK_AND, 0, 31),
236238
[HC_INT_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_INT_IRQ_MASK_AND, 0, 31),
237239
[HC_ATL_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_ATL_IRQ_MASK_AND, 0, 31),
238-
[HW_OTG_DISABLE] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 10, 10),
239-
[HW_SW_SEL_HC_DC] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 7, 7),
240-
[HW_VBUS_DRV] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 4, 4),
241-
[HW_SEL_CP_EXT] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 3, 3),
242-
[HW_DM_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 2, 2),
243-
[HW_DP_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 1, 1),
244-
[HW_DP_PULLUP] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 0, 0),
245-
[HW_OTG_DISABLE_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 10, 10),
246-
[HW_SW_SEL_HC_DC_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 7, 7),
247-
[HW_VBUS_DRV_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 4, 4),
248-
[HW_SEL_CP_EXT_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 3, 3),
249-
[HW_DM_PULLDOWN_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 2, 2),
250-
[HW_DP_PULLDOWN_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 1, 1),
251-
[HW_DP_PULLUP_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 0, 0),
240+
[HW_OTG_DISABLE_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 26, 26),
241+
[HW_SW_SEL_HC_DC_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 23, 23),
242+
[HW_VBUS_DRV_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 20, 20),
243+
[HW_SEL_CP_EXT_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 19, 19),
244+
[HW_DM_PULLDOWN_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 18, 18),
245+
[HW_DP_PULLDOWN_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 17, 17),
246+
[HW_DP_PULLUP_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 16, 16),
247+
[HW_OTG_DISABLE] = REG_FIELD(ISP176x_HC_OTG_CTRL, 10, 10),
248+
[HW_SW_SEL_HC_DC] = REG_FIELD(ISP176x_HC_OTG_CTRL, 7, 7),
249+
[HW_VBUS_DRV] = REG_FIELD(ISP176x_HC_OTG_CTRL, 4, 4),
250+
[HW_SEL_CP_EXT] = REG_FIELD(ISP176x_HC_OTG_CTRL, 3, 3),
251+
[HW_DM_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL, 2, 2),
252+
[HW_DP_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL, 1, 1),
253+
[HW_DP_PULLUP] = REG_FIELD(ISP176x_HC_OTG_CTRL, 0, 0),
252254
};
253255

254256
static const struct reg_field isp1763_hc_reg_fields[] = {

drivers/usb/isp1760/isp1760-regs.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#define ISP176x_HC_INT_IRQ_MASK_AND 0x328
6262
#define ISP176x_HC_ATL_IRQ_MASK_AND 0x32c
6363

64+
#define ISP176x_HC_OTG_CTRL 0x374
6465
#define ISP176x_HC_OTG_CTRL_SET 0x374
6566
#define ISP176x_HC_OTG_CTRL_CLEAR 0x376
6667

@@ -179,6 +180,21 @@ enum isp176x_host_controller_fields {
179180
#define ISP176x_DC_IESUSP BIT(3)
180181
#define ISP176x_DC_IEBRST BIT(0)
181182

183+
#define ISP176x_HW_OTG_DISABLE_CLEAR BIT(26)
184+
#define ISP176x_HW_SW_SEL_HC_DC_CLEAR BIT(23)
185+
#define ISP176x_HW_VBUS_DRV_CLEAR BIT(20)
186+
#define ISP176x_HW_SEL_CP_EXT_CLEAR BIT(19)
187+
#define ISP176x_HW_DM_PULLDOWN_CLEAR BIT(18)
188+
#define ISP176x_HW_DP_PULLDOWN_CLEAR BIT(17)
189+
#define ISP176x_HW_DP_PULLUP_CLEAR BIT(16)
190+
#define ISP176x_HW_OTG_DISABLE BIT(10)
191+
#define ISP176x_HW_SW_SEL_HC_DC BIT(7)
192+
#define ISP176x_HW_VBUS_DRV BIT(4)
193+
#define ISP176x_HW_SEL_CP_EXT BIT(3)
194+
#define ISP176x_HW_DM_PULLDOWN BIT(2)
195+
#define ISP176x_HW_DP_PULLDOWN BIT(1)
196+
#define ISP176x_HW_DP_PULLUP BIT(0)
197+
182198
#define ISP176x_DC_ENDPTYP_ISOC 0x01
183199
#define ISP176x_DC_ENDPTYP_BULK 0x02
184200
#define ISP176x_DC_ENDPTYP_INTERRUPT 0x03

0 commit comments

Comments
 (0)