Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: isp1760: add support for isp1763

isp1763 have some differences from the isp1760, 8 bit address for
registers and 16 bit for values, no bulk access to memory addresses,
16 PTD's instead of 32.

Following the regmap work done before add the registers, memory access
and add the functions to support differences in setup sequences.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Link: https://lore.kernel.org/r/20210513084717.2487366-8-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Rui Miguel Silva and committed by
Greg Kroah-Hartman
60d789f3 3eb96e04

+853 -208
+2 -2
drivers/usb/isp1760/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 3 config USB_ISP1760 4 - tristate "NXP ISP 1760/1761 support" 4 + tristate "NXP ISP 1760/1761/1763 support" 5 5 depends on USB || USB_GADGET 6 6 select REGMAP_MMIO 7 7 help 8 - Say Y or M here if your system as an ISP1760 USB host controller 8 + Say Y or M here if your system as an ISP1760/1763 USB host controller 9 9 or an ISP1761 USB dual-role controller. 10 10 11 11 This driver does not support isochronous transfers or OTG.
+266 -35
drivers/usb/isp1760/isp1760-core.c
··· 2 2 /* 3 3 * Driver for the NXP ISP1760 chip 4 4 * 5 + * Copyright 2021 Linaro, Rui Miguel Silva 5 6 * Copyright 2014 Laurent Pinchart 6 7 * Copyright 2007 Sebastian Siewior 7 8 * 8 9 * Contacts: 9 10 * Sebastian Siewior <bigeasy@linutronix.de> 10 11 * Laurent Pinchart <laurent.pinchart@ideasonboard.com> 12 + * Rui Miguel Silva <rui.silva@linaro.org> 11 13 */ 12 14 13 15 #include <linux/delay.h> ··· 26 24 #include "isp1760-regs.h" 27 25 #include "isp1760-udc.h" 28 26 29 - static void isp1760_init_core(struct isp1760_device *isp) 27 + static int isp1760_init_core(struct isp1760_device *isp) 30 28 { 31 29 struct isp1760_hcd *hcd = &isp->hcd; 32 30 struct isp1760_udc *udc = &isp->udc; ··· 46 44 msleep(100); 47 45 48 46 /* Setup HW Mode Control: This assumes a level active-low interrupt */ 47 + if ((isp->devflags & ISP1760_FLAG_ANALOG_OC) && hcd->is_isp1763) { 48 + dev_err(isp->dev, "isp1763 analog overcurrent not available\n"); 49 + return -EINVAL; 50 + } 51 + 49 52 if (isp->devflags & ISP1760_FLAG_BUS_WIDTH_16) 50 53 isp1760_field_clear(hcd->fields, HW_DATA_BUS_WIDTH); 54 + if (isp->devflags & ISP1760_FLAG_BUS_WIDTH_8) 55 + isp1760_field_set(hcd->fields, HW_DATA_BUS_WIDTH); 51 56 if (isp->devflags & ISP1760_FLAG_ANALOG_OC) 52 57 isp1760_field_set(hcd->fields, HW_ANA_DIGI_OC); 53 58 if (isp->devflags & ISP1760_FLAG_DACK_POL_HIGH) ··· 94 85 isp1760_field_set(hcd->fields, HW_SEL_CP_EXT); 95 86 } 96 87 97 - dev_info(isp->dev, "bus width: %u, oc: %s\n", 88 + dev_info(isp->dev, "%s bus width: %u, oc: %s\n", 89 + hcd->is_isp1763 ? "isp1763" : "isp1760", 90 + isp->devflags & ISP1760_FLAG_BUS_WIDTH_8 ? 8 : 98 91 isp->devflags & ISP1760_FLAG_BUS_WIDTH_16 ? 16 : 32, 92 + hcd->is_isp1763 ? "not available" : 99 93 isp->devflags & ISP1760_FLAG_ANALOG_OC ? "analog" : "digital"); 94 + 95 + return 0; 100 96 } 101 97 102 98 void isp1760_set_pullup(struct isp1760_device *isp, bool enable) ··· 115 101 } 116 102 117 103 /* 104 + * ISP1760/61: 105 + * 118 106 * 60kb divided in: 119 107 * - 32 blocks @ 256 bytes 120 108 * - 20 blocks @ 1024 bytes ··· 130 114 .blocks[2] = 4, 131 115 .blocks_size[2] = 8192, 132 116 133 - .ptd_num = 32, 117 + .slot_num = 32, 134 118 .payload_blocks = 32 + 20 + 4, 135 119 .payload_area_size = 0xf000, 120 + }; 121 + 122 + /* 123 + * ISP1763: 124 + * 125 + * 20kb divided in: 126 + * - 8 blocks @ 256 bytes 127 + * - 2 blocks @ 1024 bytes 128 + * - 4 blocks @ 4096 bytes 129 + */ 130 + static const struct isp1760_memory_layout isp1763_memory_conf = { 131 + .blocks[0] = 8, 132 + .blocks_size[0] = 256, 133 + .blocks[1] = 2, 134 + .blocks_size[1] = 1024, 135 + .blocks[2] = 4, 136 + .blocks_size[2] = 4096, 137 + 138 + .slot_num = 16, 139 + .payload_blocks = 8 + 2 + 4, 140 + .payload_area_size = 0x5000, 136 141 }; 137 142 138 143 static const struct regmap_range isp176x_hc_volatile_ranges[] = { 139 144 regmap_reg_range(ISP176x_HC_USBCMD, ISP176x_HC_ATL_PTD_LASTPTD), 140 145 regmap_reg_range(ISP176x_HC_BUFFER_STATUS, ISP176x_HC_MEMORY), 141 - regmap_reg_range(ISP176x_HC_INTERRUPT, ISP176x_HC_ATL_IRQ_MASK_AND), 146 + regmap_reg_range(ISP176x_HC_INTERRUPT, ISP176x_HC_OTG_CTRL_CLEAR), 142 147 }; 143 148 144 149 static const struct regmap_access_table isp176x_hc_volatile_table = { ··· 167 130 .n_yes_ranges = ARRAY_SIZE(isp176x_hc_volatile_ranges), 168 131 }; 169 132 170 - static struct regmap_config isp1760_hc_regmap_conf = { 133 + static const struct regmap_config isp1760_hc_regmap_conf = { 171 134 .name = "isp1760-hc", 172 135 .reg_bits = 16, 173 136 .reg_stride = 4, 174 137 .val_bits = 32, 175 138 .fast_io = true, 176 - .max_register = ISP176x_HC_MEMORY, 139 + .max_register = ISP176x_HC_OTG_CTRL_CLEAR, 177 140 .volatile_table = &isp176x_hc_volatile_table, 178 141 }; 179 142 ··· 188 151 [STS_PCD] = REG_FIELD(ISP176x_HC_USBSTS, 2, 2), 189 152 [HC_FRINDEX] = REG_FIELD(ISP176x_HC_FRINDEX, 0, 13), 190 153 [FLAG_CF] = REG_FIELD(ISP176x_HC_CONFIGFLAG, 0, 0), 154 + [HC_ISO_PTD_DONEMAP] = REG_FIELD(ISP176x_HC_ISO_PTD_DONEMAP, 0, 31), 155 + [HC_ISO_PTD_SKIPMAP] = REG_FIELD(ISP176x_HC_ISO_PTD_SKIPMAP, 0, 31), 156 + [HC_ISO_PTD_LASTPTD] = REG_FIELD(ISP176x_HC_ISO_PTD_LASTPTD, 0, 31), 157 + [HC_INT_PTD_DONEMAP] = REG_FIELD(ISP176x_HC_INT_PTD_DONEMAP, 0, 31), 158 + [HC_INT_PTD_SKIPMAP] = REG_FIELD(ISP176x_HC_INT_PTD_SKIPMAP, 0, 31), 159 + [HC_INT_PTD_LASTPTD] = REG_FIELD(ISP176x_HC_INT_PTD_LASTPTD, 0, 31), 160 + [HC_ATL_PTD_DONEMAP] = REG_FIELD(ISP176x_HC_ATL_PTD_DONEMAP, 0, 31), 161 + [HC_ATL_PTD_SKIPMAP] = REG_FIELD(ISP176x_HC_ATL_PTD_SKIPMAP, 0, 31), 162 + [HC_ATL_PTD_LASTPTD] = REG_FIELD(ISP176x_HC_ATL_PTD_LASTPTD, 0, 31), 191 163 [PORT_OWNER] = REG_FIELD(ISP176x_HC_PORTSC1, 13, 13), 192 164 [PORT_POWER] = REG_FIELD(ISP176x_HC_PORTSC1, 12, 12), 193 165 [PORT_LSTATUS] = REG_FIELD(ISP176x_HC_PORTSC1, 10, 11), ··· 215 169 [HW_INTR_HIGH_ACT] = REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 2, 2), 216 170 [HW_INTR_EDGE_TRIG] = REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 1, 1), 217 171 [HW_GLOBAL_INTR_EN] = REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 0, 0), 172 + [HC_CHIP_REV] = REG_FIELD(ISP176x_HC_CHIP_ID, 16, 31), 173 + [HC_CHIP_ID_HIGH] = REG_FIELD(ISP176x_HC_CHIP_ID, 8, 15), 174 + [HC_CHIP_ID_LOW] = REG_FIELD(ISP176x_HC_CHIP_ID, 0, 7), 175 + [HC_SCRATCH] = REG_FIELD(ISP176x_HC_SCRATCH, 0, 31), 218 176 [SW_RESET_RESET_ALL] = REG_FIELD(ISP176x_HC_RESET, 0, 0), 177 + [ISO_BUF_FILL] = REG_FIELD(ISP176x_HC_BUFFER_STATUS, 2, 2), 219 178 [INT_BUF_FILL] = REG_FIELD(ISP176x_HC_BUFFER_STATUS, 1, 1), 220 179 [ATL_BUF_FILL] = REG_FIELD(ISP176x_HC_BUFFER_STATUS, 0, 0), 221 180 [MEM_BANK_SEL] = REG_FIELD(ISP176x_HC_MEMORY, 16, 17), 222 181 [MEM_START_ADDR] = REG_FIELD(ISP176x_HC_MEMORY, 0, 15), 223 - [HC_INT_ENABLE] = REG_FIELD(ISP176x_HC_INTERRUPT_ENABLE, 7, 8), 182 + [HC_INTERRUPT] = REG_FIELD(ISP176x_HC_INTERRUPT, 0, 9), 183 + [HC_ATL_IRQ_ENABLE] = REG_FIELD(ISP176x_HC_INTERRUPT_ENABLE, 8, 8), 184 + [HC_INT_IRQ_ENABLE] = REG_FIELD(ISP176x_HC_INTERRUPT_ENABLE, 7, 7), 185 + [HC_ISO_IRQ_MASK_OR] = REG_FIELD(ISP176x_HC_ISO_IRQ_MASK_OR, 0, 31), 186 + [HC_INT_IRQ_MASK_OR] = REG_FIELD(ISP176x_HC_INT_IRQ_MASK_OR, 0, 31), 187 + [HC_ATL_IRQ_MASK_OR] = REG_FIELD(ISP176x_HC_ATL_IRQ_MASK_OR, 0, 31), 188 + [HC_ISO_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_ISO_IRQ_MASK_AND, 0, 31), 189 + [HC_INT_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_INT_IRQ_MASK_AND, 0, 31), 190 + [HC_ATL_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_ATL_IRQ_MASK_AND, 0, 31), 191 + [HW_OTG_DISABLE] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 10, 10), 192 + [HW_SW_SEL_HC_DC] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 7, 7), 193 + [HW_VBUS_DRV] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 4, 4), 194 + [HW_SEL_CP_EXT] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 3, 3), 195 + [HW_DM_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 2, 2), 196 + [HW_DP_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 1, 1), 197 + [HW_DP_PULLUP] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 0, 0), 198 + [HW_OTG_DISABLE_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 10, 10), 199 + [HW_SW_SEL_HC_DC_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 7, 7), 200 + [HW_VBUS_DRV_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 4, 4), 201 + [HW_SEL_CP_EXT_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 3, 3), 202 + [HW_DM_PULLDOWN_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 2, 2), 203 + [HW_DP_PULLDOWN_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 1, 1), 204 + [HW_DP_PULLUP_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 0, 0), 205 + }; 206 + 207 + static const struct reg_field isp1763_hc_reg_fields[] = { 208 + [CMD_LRESET] = REG_FIELD(ISP1763_HC_USBCMD, 7, 7), 209 + [CMD_RESET] = REG_FIELD(ISP1763_HC_USBCMD, 1, 1), 210 + [CMD_RUN] = REG_FIELD(ISP1763_HC_USBCMD, 0, 0), 211 + [STS_PCD] = REG_FIELD(ISP1763_HC_USBSTS, 2, 2), 212 + [HC_FRINDEX] = REG_FIELD(ISP1763_HC_FRINDEX, 0, 13), 213 + [FLAG_CF] = REG_FIELD(ISP1763_HC_CONFIGFLAG, 0, 0), 214 + [HC_ISO_PTD_DONEMAP] = REG_FIELD(ISP1763_HC_ISO_PTD_DONEMAP, 0, 15), 215 + [HC_ISO_PTD_SKIPMAP] = REG_FIELD(ISP1763_HC_ISO_PTD_SKIPMAP, 0, 15), 216 + [HC_ISO_PTD_LASTPTD] = REG_FIELD(ISP1763_HC_ISO_PTD_LASTPTD, 0, 15), 217 + [HC_INT_PTD_DONEMAP] = REG_FIELD(ISP1763_HC_INT_PTD_DONEMAP, 0, 15), 218 + [HC_INT_PTD_SKIPMAP] = REG_FIELD(ISP1763_HC_INT_PTD_SKIPMAP, 0, 15), 219 + [HC_INT_PTD_LASTPTD] = REG_FIELD(ISP1763_HC_INT_PTD_LASTPTD, 0, 15), 220 + [HC_ATL_PTD_DONEMAP] = REG_FIELD(ISP1763_HC_ATL_PTD_DONEMAP, 0, 15), 221 + [HC_ATL_PTD_SKIPMAP] = REG_FIELD(ISP1763_HC_ATL_PTD_SKIPMAP, 0, 15), 222 + [HC_ATL_PTD_LASTPTD] = REG_FIELD(ISP1763_HC_ATL_PTD_LASTPTD, 0, 15), 223 + [PORT_OWNER] = REG_FIELD(ISP1763_HC_PORTSC1, 13, 13), 224 + [PORT_POWER] = REG_FIELD(ISP1763_HC_PORTSC1, 12, 12), 225 + [PORT_LSTATUS] = REG_FIELD(ISP1763_HC_PORTSC1, 10, 11), 226 + [PORT_RESET] = REG_FIELD(ISP1763_HC_PORTSC1, 8, 8), 227 + [PORT_SUSPEND] = REG_FIELD(ISP1763_HC_PORTSC1, 7, 7), 228 + [PORT_RESUME] = REG_FIELD(ISP1763_HC_PORTSC1, 6, 6), 229 + [PORT_PE] = REG_FIELD(ISP1763_HC_PORTSC1, 2, 2), 230 + [PORT_CSC] = REG_FIELD(ISP1763_HC_PORTSC1, 1, 1), 231 + [PORT_CONNECT] = REG_FIELD(ISP1763_HC_PORTSC1, 0, 0), 232 + [HW_DATA_BUS_WIDTH] = REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 4, 4), 233 + [HW_DACK_POL_HIGH] = REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 6, 6), 234 + [HW_DREQ_POL_HIGH] = REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 5, 5), 235 + [HW_INTF_LOCK] = REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 3, 3), 236 + [HW_INTR_HIGH_ACT] = REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 2, 2), 237 + [HW_INTR_EDGE_TRIG] = REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 1, 1), 238 + [HW_GLOBAL_INTR_EN] = REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 0, 0), 239 + [SW_RESET_RESET_ATX] = REG_FIELD(ISP1763_HC_RESET, 3, 3), 240 + [SW_RESET_RESET_ALL] = REG_FIELD(ISP1763_HC_RESET, 0, 0), 241 + [HC_CHIP_ID_HIGH] = REG_FIELD(ISP1763_HC_CHIP_ID, 0, 15), 242 + [HC_CHIP_ID_LOW] = REG_FIELD(ISP1763_HC_CHIP_REV, 8, 15), 243 + [HC_CHIP_REV] = REG_FIELD(ISP1763_HC_CHIP_REV, 0, 7), 244 + [HC_SCRATCH] = REG_FIELD(ISP1763_HC_SCRATCH, 0, 15), 245 + [ISO_BUF_FILL] = REG_FIELD(ISP1763_HC_BUFFER_STATUS, 2, 2), 246 + [INT_BUF_FILL] = REG_FIELD(ISP1763_HC_BUFFER_STATUS, 1, 1), 247 + [ATL_BUF_FILL] = REG_FIELD(ISP1763_HC_BUFFER_STATUS, 0, 0), 248 + [MEM_START_ADDR] = REG_FIELD(ISP1763_HC_MEMORY, 0, 15), 249 + [HC_DATA] = REG_FIELD(ISP1763_HC_DATA, 0, 15), 250 + [HC_INTERRUPT] = REG_FIELD(ISP1763_HC_INTERRUPT, 0, 10), 251 + [HC_ATL_IRQ_ENABLE] = REG_FIELD(ISP1763_HC_INTERRUPT_ENABLE, 8, 8), 252 + [HC_INT_IRQ_ENABLE] = REG_FIELD(ISP1763_HC_INTERRUPT_ENABLE, 7, 7), 253 + [HC_ISO_IRQ_MASK_OR] = REG_FIELD(ISP1763_HC_ISO_IRQ_MASK_OR, 0, 15), 254 + [HC_INT_IRQ_MASK_OR] = REG_FIELD(ISP1763_HC_INT_IRQ_MASK_OR, 0, 15), 255 + [HC_ATL_IRQ_MASK_OR] = REG_FIELD(ISP1763_HC_ATL_IRQ_MASK_OR, 0, 15), 256 + [HC_ISO_IRQ_MASK_AND] = REG_FIELD(ISP1763_HC_ISO_IRQ_MASK_AND, 0, 15), 257 + [HC_INT_IRQ_MASK_AND] = REG_FIELD(ISP1763_HC_INT_IRQ_MASK_AND, 0, 15), 258 + [HC_ATL_IRQ_MASK_AND] = REG_FIELD(ISP1763_HC_ATL_IRQ_MASK_AND, 0, 15), 259 + [HW_HC_2_DIS] = REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 15, 15), 260 + [HW_OTG_DISABLE] = REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 10, 10), 261 + [HW_SW_SEL_HC_DC] = REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 7, 7), 262 + [HW_VBUS_DRV] = REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 4, 4), 263 + [HW_SEL_CP_EXT] = REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 3, 3), 264 + [HW_DM_PULLDOWN] = REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 2, 2), 265 + [HW_DP_PULLDOWN] = REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 1, 1), 266 + [HW_DP_PULLUP] = REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 0, 0), 267 + [HW_HC_2_DIS_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 15, 15), 268 + [HW_OTG_DISABLE_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 10, 10), 269 + [HW_SW_SEL_HC_DC_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 7, 7), 270 + [HW_VBUS_DRV_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 4, 4), 271 + [HW_SEL_CP_EXT_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 3, 3), 272 + [HW_DM_PULLDOWN_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 2, 2), 273 + [HW_DP_PULLDOWN_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 1, 1), 274 + [HW_DP_PULLUP_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 0, 0), 275 + }; 276 + 277 + static const struct regmap_range isp1763_hc_volatile_ranges[] = { 278 + regmap_reg_range(ISP1763_HC_USBCMD, ISP1763_HC_ATL_PTD_LASTPTD), 279 + regmap_reg_range(ISP1763_HC_BUFFER_STATUS, ISP1763_HC_DATA), 280 + regmap_reg_range(ISP1763_HC_INTERRUPT, ISP1763_HC_OTG_CTRL_CLEAR), 281 + }; 282 + 283 + static const struct regmap_access_table isp1763_hc_volatile_table = { 284 + .yes_ranges = isp1763_hc_volatile_ranges, 285 + .n_yes_ranges = ARRAY_SIZE(isp1763_hc_volatile_ranges), 286 + }; 287 + 288 + static const struct regmap_config isp1763_hc_regmap_conf = { 289 + .name = "isp1763-hc", 290 + .reg_bits = 8, 291 + .reg_stride = 2, 292 + .val_bits = 16, 293 + .fast_io = true, 294 + .max_register = ISP1763_HC_OTG_CTRL_CLEAR, 295 + .volatile_table = &isp1763_hc_volatile_table, 224 296 }; 225 297 226 298 static const struct regmap_range isp176x_dc_volatile_ranges[] = { 227 299 regmap_reg_range(ISP176x_DC_EPMAXPKTSZ, ISP176x_DC_EPTYPE), 228 300 regmap_reg_range(ISP176x_DC_BUFLEN, ISP176x_DC_EPINDEX), 229 - regmap_reg_range(ISP1761_DC_OTG_CTRL_SET, ISP1761_DC_OTG_CTRL_CLEAR), 230 301 }; 231 302 232 303 static const struct regmap_access_table isp176x_dc_volatile_table = { ··· 351 188 .n_yes_ranges = ARRAY_SIZE(isp176x_dc_volatile_ranges), 352 189 }; 353 190 354 - static struct regmap_config isp1761_dc_regmap_conf = { 191 + static const struct regmap_config isp1761_dc_regmap_conf = { 355 192 .name = "isp1761-dc", 356 193 .reg_bits = 16, 357 194 .reg_stride = 4, 358 195 .val_bits = 32, 359 196 .fast_io = true, 360 - .max_register = ISP1761_DC_OTG_CTRL_CLEAR, 197 + .max_register = ISP176x_DC_TESTMODE, 361 198 .volatile_table = &isp176x_dc_volatile_table, 362 199 }; 363 200 ··· 399 236 [DC_ENDPTYP] = REG_FIELD(ISP176x_DC_EPTYPE, 0, 1), 400 237 [DC_UFRAMENUM] = REG_FIELD(ISP176x_DC_FRAMENUM, 11, 13), 401 238 [DC_FRAMENUM] = REG_FIELD(ISP176x_DC_FRAMENUM, 0, 10), 402 - [HW_OTG_DISABLE] = REG_FIELD(ISP1761_DC_OTG_CTRL_SET, 10, 10), 403 - [HW_SW_SEL_HC_DC] = REG_FIELD(ISP1761_DC_OTG_CTRL_SET, 7, 7), 404 - [HW_VBUS_DRV] = REG_FIELD(ISP1761_DC_OTG_CTRL_SET, 4, 4), 405 - [HW_SEL_CP_EXT] = REG_FIELD(ISP1761_DC_OTG_CTRL_SET, 3, 3), 406 - [HW_DM_PULLDOWN] = REG_FIELD(ISP1761_DC_OTG_CTRL_SET, 2, 2), 407 - [HW_DP_PULLDOWN] = REG_FIELD(ISP1761_DC_OTG_CTRL_SET, 1, 1), 408 - [HW_DP_PULLUP] = REG_FIELD(ISP1761_DC_OTG_CTRL_SET, 0, 0), 409 - [HW_OTG_DISABLE_CLEAR] = REG_FIELD(ISP1761_DC_OTG_CTRL_CLEAR, 10, 10), 410 - [HW_SW_SEL_HC_DC_CLEAR] = REG_FIELD(ISP1761_DC_OTG_CTRL_CLEAR, 7, 7), 411 - [HW_VBUS_DRV_CLEAR] = REG_FIELD(ISP1761_DC_OTG_CTRL_CLEAR, 4, 4), 412 - [HW_SEL_CP_EXT_CLEAR] = REG_FIELD(ISP1761_DC_OTG_CTRL_CLEAR, 3, 3), 413 - [HW_DM_PULLDOWN_CLEAR] = REG_FIELD(ISP1761_DC_OTG_CTRL_CLEAR, 2, 2), 414 - [HW_DP_PULLDOWN_CLEAR] = REG_FIELD(ISP1761_DC_OTG_CTRL_CLEAR, 1, 1), 415 - [HW_DP_PULLUP_CLEAR] = REG_FIELD(ISP1761_DC_OTG_CTRL_CLEAR, 0, 0), 239 + [DC_CHIP_ID_HIGH] = REG_FIELD(ISP176x_DC_CHIPID, 16, 31), 240 + [DC_CHIP_ID_LOW] = REG_FIELD(ISP176x_DC_CHIPID, 0, 15), 241 + [DC_SCRATCH] = REG_FIELD(ISP176x_DC_SCRATCH, 0, 15), 242 + }; 243 + 244 + static const struct regmap_range isp1763_dc_volatile_ranges[] = { 245 + regmap_reg_range(ISP1763_DC_EPMAXPKTSZ, ISP1763_DC_EPTYPE), 246 + regmap_reg_range(ISP1763_DC_BUFLEN, ISP1763_DC_EPINDEX), 247 + }; 248 + 249 + static const struct regmap_access_table isp1763_dc_volatile_table = { 250 + .yes_ranges = isp1763_dc_volatile_ranges, 251 + .n_yes_ranges = ARRAY_SIZE(isp1763_dc_volatile_ranges), 252 + }; 253 + 254 + static const struct reg_field isp1763_dc_reg_fields[] = { 255 + [DC_DEVEN] = REG_FIELD(ISP1763_DC_ADDRESS, 7, 7), 256 + [DC_DEVADDR] = REG_FIELD(ISP1763_DC_ADDRESS, 0, 6), 257 + [DC_VBUSSTAT] = REG_FIELD(ISP1763_DC_MODE, 8, 8), 258 + [DC_SFRESET] = REG_FIELD(ISP1763_DC_MODE, 4, 4), 259 + [DC_GLINTENA] = REG_FIELD(ISP1763_DC_MODE, 3, 3), 260 + [DC_CDBGMOD_ACK] = REG_FIELD(ISP1763_DC_INTCONF, 6, 6), 261 + [DC_DDBGMODIN_ACK] = REG_FIELD(ISP1763_DC_INTCONF, 4, 4), 262 + [DC_DDBGMODOUT_ACK] = REG_FIELD(ISP1763_DC_INTCONF, 2, 2), 263 + [DC_INTPOL] = REG_FIELD(ISP1763_DC_INTCONF, 0, 0), 264 + [DC_IEPRXTX_7] = REG_FIELD(ISP1763_DC_INTENABLE, 25, 25), 265 + [DC_IEPRXTX_6] = REG_FIELD(ISP1763_DC_INTENABLE, 23, 23), 266 + [DC_IEPRXTX_5] = REG_FIELD(ISP1763_DC_INTENABLE, 21, 21), 267 + [DC_IEPRXTX_4] = REG_FIELD(ISP1763_DC_INTENABLE, 19, 19), 268 + [DC_IEPRXTX_3] = REG_FIELD(ISP1763_DC_INTENABLE, 17, 17), 269 + [DC_IEPRXTX_2] = REG_FIELD(ISP1763_DC_INTENABLE, 15, 15), 270 + [DC_IEPRXTX_1] = REG_FIELD(ISP1763_DC_INTENABLE, 13, 13), 271 + [DC_IEPRXTX_0] = REG_FIELD(ISP1763_DC_INTENABLE, 11, 11), 272 + [DC_IEP0SETUP] = REG_FIELD(ISP1763_DC_INTENABLE, 8, 8), 273 + [DC_IEVBUS] = REG_FIELD(ISP1763_DC_INTENABLE, 7, 7), 274 + [DC_IEHS_STA] = REG_FIELD(ISP1763_DC_INTENABLE, 5, 5), 275 + [DC_IERESM] = REG_FIELD(ISP1763_DC_INTENABLE, 4, 4), 276 + [DC_IESUSP] = REG_FIELD(ISP1763_DC_INTENABLE, 3, 3), 277 + [DC_IEBRST] = REG_FIELD(ISP1763_DC_INTENABLE, 0, 0), 278 + [DC_EP0SETUP] = REG_FIELD(ISP1763_DC_EPINDEX, 5, 5), 279 + [DC_ENDPIDX] = REG_FIELD(ISP1763_DC_EPINDEX, 1, 4), 280 + [DC_EPDIR] = REG_FIELD(ISP1763_DC_EPINDEX, 0, 0), 281 + [DC_CLBUF] = REG_FIELD(ISP1763_DC_CTRLFUNC, 4, 4), 282 + [DC_VENDP] = REG_FIELD(ISP1763_DC_CTRLFUNC, 3, 3), 283 + [DC_DSEN] = REG_FIELD(ISP1763_DC_CTRLFUNC, 2, 2), 284 + [DC_STATUS] = REG_FIELD(ISP1763_DC_CTRLFUNC, 1, 1), 285 + [DC_STALL] = REG_FIELD(ISP1763_DC_CTRLFUNC, 0, 0), 286 + [DC_BUFLEN] = REG_FIELD(ISP1763_DC_BUFLEN, 0, 15), 287 + [DC_FFOSZ] = REG_FIELD(ISP1763_DC_EPMAXPKTSZ, 0, 10), 288 + [DC_EPENABLE] = REG_FIELD(ISP1763_DC_EPTYPE, 3, 3), 289 + [DC_ENDPTYP] = REG_FIELD(ISP1763_DC_EPTYPE, 0, 1), 290 + [DC_UFRAMENUM] = REG_FIELD(ISP1763_DC_FRAMENUM, 11, 13), 291 + [DC_FRAMENUM] = REG_FIELD(ISP1763_DC_FRAMENUM, 0, 10), 292 + [DC_CHIP_ID_HIGH] = REG_FIELD(ISP1763_DC_CHIPID_HIGH, 0, 15), 293 + [DC_CHIP_ID_LOW] = REG_FIELD(ISP1763_DC_CHIPID_LOW, 0, 15), 294 + [DC_SCRATCH] = REG_FIELD(ISP1763_DC_SCRATCH, 0, 15), 295 + }; 296 + 297 + static const struct regmap_config isp1763_dc_regmap_conf = { 298 + .name = "isp1763-dc", 299 + .reg_bits = 8, 300 + .reg_stride = 2, 301 + .val_bits = 16, 302 + .fast_io = true, 303 + .max_register = ISP1763_DC_TESTMODE, 304 + .volatile_table = &isp1763_dc_volatile_table, 416 305 }; 417 306 418 307 int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, 419 308 struct device *dev, unsigned int devflags) 420 309 { 310 + bool udc_disabled = !(devflags & ISP1760_FLAG_ISP1761); 311 + const struct regmap_config *hc_regmap; 312 + const struct reg_field *hc_reg_fields; 421 313 struct isp1760_device *isp; 422 314 struct isp1760_hcd *hcd; 423 315 struct isp1760_udc *udc; 424 - bool udc_disabled = !(devflags & ISP1760_FLAG_ISP1761); 425 316 struct regmap_field *f; 426 - void __iomem *base; 427 317 int ret; 428 318 int i; 429 319 ··· 497 281 hcd = &isp->hcd; 498 282 udc = &isp->udc; 499 283 500 - if (devflags & ISP1760_FLAG_BUS_WIDTH_16) { 501 - isp1760_hc_regmap_conf.val_bits = 16; 502 - isp1761_dc_regmap_conf.val_bits = 16; 284 + hcd->is_isp1763 = !!(devflags & ISP1760_FLAG_ISP1763); 285 + 286 + if (!hcd->is_isp1763 && (devflags & ISP1760_FLAG_BUS_WIDTH_8)) { 287 + dev_err(dev, "isp1760/61 do not support data width 8\n"); 288 + return -EINVAL; 289 + } 290 + 291 + if (hcd->is_isp1763) { 292 + hc_regmap = &isp1763_hc_regmap_conf; 293 + hc_reg_fields = &isp1763_hc_reg_fields[0]; 294 + } else { 295 + hc_regmap = &isp1760_hc_regmap_conf; 296 + hc_reg_fields = &isp1760_hc_reg_fields[0]; 503 297 } 504 298 505 299 isp->rst_gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH); ··· 520 294 if (IS_ERR(hcd->base)) 521 295 return PTR_ERR(hcd->base); 522 296 523 - hcd->regs = devm_regmap_init_mmio(dev, base, &isp1760_hc_regmap_conf); 297 + hcd->regs = devm_regmap_init_mmio(dev, hcd->base, hc_regmap); 524 298 if (IS_ERR(hcd->regs)) 525 299 return PTR_ERR(hcd->regs); 526 300 527 301 for (i = 0; i < HC_FIELD_MAX; i++) { 528 - f = devm_regmap_field_alloc(dev, hcd->regs, 529 - isp1760_hc_reg_fields[i]); 302 + f = devm_regmap_field_alloc(dev, hcd->regs, hc_reg_fields[i]); 530 303 if (IS_ERR(f)) 531 304 return PTR_ERR(f); 532 305 533 306 hcd->fields[i] = f; 534 307 } 535 308 536 - udc->regs = devm_regmap_init_mmio(dev, base, &isp1761_dc_regmap_conf); 309 + udc->regs = devm_regmap_init_mmio(dev, hcd->base, 310 + &isp1761_dc_regmap_conf); 537 311 if (IS_ERR(udc->regs)) 538 312 return PTR_ERR(udc->regs); 539 313 ··· 546 320 udc->fields[i] = f; 547 321 } 548 322 549 - hcd->memory_layout = &isp176x_memory_conf; 323 + if (hcd->is_isp1763) 324 + hcd->memory_layout = &isp1763_memory_conf; 325 + else 326 + hcd->memory_layout = &isp176x_memory_conf; 550 327 551 - isp1760_init_core(isp); 328 + ret = isp1760_init_core(isp); 329 + if (ret < 0) 330 + return ret; 552 331 553 332 if (IS_ENABLED(CONFIG_USB_ISP1760_HCD) && !usb_disabled()) { 554 333 ret = isp1760_hcd_register(hcd, mem, irq,
+4
drivers/usb/isp1760/isp1760-core.h
··· 2 2 /* 3 3 * Driver for the NXP ISP1760 chip 4 4 * 5 + * Copyright 2021 Linaro, Rui Miguel Silva 5 6 * Copyright 2014 Laurent Pinchart 6 7 * Copyright 2007 Sebastian Siewior 7 8 * 8 9 * Contacts: 9 10 * Sebastian Siewior <bigeasy@linutronix.de> 10 11 * Laurent Pinchart <laurent.pinchart@ideasonboard.com> 12 + * Rui Miguel Silva <rui.silva@linaro.org> 11 13 */ 12 14 13 15 #ifndef _ISP1760_CORE_H_ ··· 37 35 #define ISP1760_FLAG_ISP1761 0x00000040 /* Chip is ISP1761 */ 38 36 #define ISP1760_FLAG_INTR_POL_HIGH 0x00000080 /* Interrupt polarity active high */ 39 37 #define ISP1760_FLAG_INTR_EDGE_TRIG 0x00000100 /* Interrupt edge triggered */ 38 + #define ISP1760_FLAG_ISP1763 0x00000200 /* Chip is ISP1763 */ 39 + #define ISP1760_FLAG_BUS_WIDTH_8 0x00000400 /* 8-bit data bus width */ 40 40 41 41 struct isp1760_device { 42 42 struct device *dev;
+485 -150
drivers/usb/isp1760/isp1760-hcd.c
··· 11 11 * 12 12 * (c) 2011 Arvid Brodin <arvid.brodin@enea.com> 13 13 * 14 + * Copyright 2021 Linaro, Rui Miguel Silva <rui.silva@linaro.org> 15 + * 14 16 */ 15 17 #include <linux/gpio/consumer.h> 16 18 #include <linux/module.h> ··· 46 44 return *(struct isp1760_hcd **)hcd->hcd_priv; 47 45 } 48 46 47 + #define dw_to_le32(x) (cpu_to_le32((__force u32)x)) 48 + #define le32_to_dw(x) ((__force __dw)(le32_to_cpu(x))) 49 + 49 50 /* urb state*/ 50 51 #define DELETE_URB (0x0008) 51 52 #define NO_TRANSFER_ACTIVE (0xffffffff) ··· 65 60 __dw dw6; 66 61 __dw dw7; 67 62 }; 63 + 64 + struct ptd_le32 { 65 + __le32 dw0; 66 + __le32 dw1; 67 + __le32 dw2; 68 + __le32 dw3; 69 + __le32 dw4; 70 + __le32 dw5; 71 + __le32 dw6; 72 + __le32 dw7; 73 + }; 74 + 68 75 #define PTD_OFFSET 0x0400 69 76 #define ISO_PTD_OFFSET 0x0400 70 77 #define INT_PTD_OFFSET 0x0800 ··· 113 96 #define TO_DW2_RL(x) TO_DW(((x) << 25)) 114 97 #define FROM_DW2_RL(x) ((TO_U32(x) >> 25) & 0xf) 115 98 /* DW3 */ 116 - #define FROM_DW3_NRBYTESTRANSFERRED(x) TO_U32((x) & 0x7fff) 99 + #define FROM_DW3_NRBYTESTRANSFERRED(x) TO_U32((x) & 0x3fff) 117 100 #define FROM_DW3_SCS_NRBYTESTRANSFERRED(x) TO_U32((x) & 0x07ff) 118 101 #define TO_DW3_NAKCOUNT(x) TO_DW(((x) << 19)) 119 102 #define FROM_DW3_NAKCOUNT(x) ((TO_U32(x) >> 19) & 0xf) ··· 140 123 /* Errata 1 */ 141 124 #define RL_COUNTER (0) 142 125 #define NAK_COUNTER (0) 143 - #define ERR_COUNTER (2) 126 + #define ERR_COUNTER (3) 144 127 145 128 struct isp1760_qtd { 146 129 u8 packet_type; ··· 182 165 struct urb *urb; 183 166 }; 184 167 168 + static const u32 isp1763_hc_portsc1_fields[] = { 169 + [PORT_OWNER] = BIT(13), 170 + [PORT_POWER] = BIT(12), 171 + [PORT_LSTATUS] = BIT(10), 172 + [PORT_RESET] = BIT(8), 173 + [PORT_SUSPEND] = BIT(7), 174 + [PORT_RESUME] = BIT(6), 175 + [PORT_PE] = BIT(2), 176 + [PORT_CSC] = BIT(1), 177 + [PORT_CONNECT] = BIT(0), 178 + }; 179 + 185 180 /* 186 181 * Access functions for isp176x registers regmap fields 187 182 */ ··· 204 175 return isp1760_field_read(priv->fields, field); 205 176 } 206 177 178 + /* 179 + * We need, in isp1763, to write directly the values to the portsc1 180 + * register so it will make the other values to trigger. 181 + */ 182 + static void isp1760_hcd_portsc1_set_clear(struct isp1760_hcd *priv, u32 field, 183 + u32 val) 184 + { 185 + u32 bit = isp1763_hc_portsc1_fields[field]; 186 + u32 port_status = readl(priv->base + ISP1763_HC_PORTSC1); 187 + 188 + if (val) 189 + writel(port_status | bit, priv->base + ISP1763_HC_PORTSC1); 190 + else 191 + writel(port_status & ~bit, priv->base + ISP1763_HC_PORTSC1); 192 + } 193 + 207 194 static void isp1760_hcd_write(struct usb_hcd *hcd, u32 field, u32 val) 208 195 { 209 196 struct isp1760_hcd *priv = hcd_to_priv(hcd); 197 + 198 + if (unlikely(priv->is_isp1763 && 199 + (field >= PORT_OWNER && field <= PORT_CONNECT))) 200 + return isp1760_hcd_portsc1_set_clear(priv, field, val); 210 201 211 202 isp1760_field_write(priv->fields, field, val); 212 203 } ··· 241 192 isp1760_hcd_write(hcd, field, 0); 242 193 } 243 194 244 - static int isp1760_hcd_set_poll_timeout(struct usb_hcd *hcd, u32 field, 245 - u32 timeout_us) 195 + static int isp1760_hcd_set_and_wait(struct usb_hcd *hcd, u32 field, 196 + u32 timeout_us) 246 197 { 247 198 struct isp1760_hcd *priv = hcd_to_priv(hcd); 248 - unsigned int val; 199 + u32 val; 249 200 250 201 isp1760_hcd_set(hcd, field); 251 202 252 - return regmap_field_read_poll_timeout(priv->fields[field], val, 1, 1, 253 - timeout_us); 203 + return regmap_field_read_poll_timeout(priv->fields[field], val, 204 + val, 10, timeout_us); 254 205 } 255 206 256 - static int isp1760_hcd_clear_poll_timeout(struct usb_hcd *hcd, u32 field, 257 - u32 timeout_us) 207 + static int isp1760_hcd_set_and_wait_swap(struct usb_hcd *hcd, u32 field, 208 + u32 timeout_us) 258 209 { 259 210 struct isp1760_hcd *priv = hcd_to_priv(hcd); 260 - unsigned int val; 211 + u32 val; 212 + 213 + isp1760_hcd_set(hcd, field); 214 + 215 + return regmap_field_read_poll_timeout(priv->fields[field], val, 216 + !val, 10, timeout_us); 217 + } 218 + 219 + static int isp1760_hcd_clear_and_wait(struct usb_hcd *hcd, u32 field, 220 + u32 timeout_us) 221 + { 222 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 223 + u32 val; 261 224 262 225 isp1760_hcd_clear(hcd, field); 263 226 264 - return regmap_field_read_poll_timeout(priv->fields[field], val, 0, 1, 265 - timeout_us); 227 + return regmap_field_read_poll_timeout(priv->fields[field], val, 228 + !val, 10, timeout_us); 266 229 } 267 230 268 231 static bool isp1760_hcd_is_set(struct usb_hcd *hcd, u32 field) ··· 282 221 return !!isp1760_hcd_read(hcd, field); 283 222 } 284 223 224 + static bool isp1760_hcd_ppc_is_set(struct usb_hcd *hcd) 225 + { 226 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 227 + 228 + if (priv->is_isp1763) 229 + return true; 230 + 231 + return isp1760_hcd_is_set(hcd, HCS_PPC); 232 + } 233 + 234 + static u32 isp1760_hcd_n_ports(struct usb_hcd *hcd) 235 + { 236 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 237 + 238 + if (priv->is_isp1763) 239 + return 1; 240 + 241 + return isp1760_hcd_read(hcd, HCS_N_PORTS); 242 + } 243 + 285 244 /* 286 245 * Access functions for isp176x memory (offset >= 0x0400). 287 246 * 288 247 * bank_reads8() reads memory locations prefetched by an earlier write to 289 248 * HC_MEMORY_REG (see isp176x datasheet). Unless you want to do fancy multi- 290 - * bank optimizations, you should use the more generic mem_reads8() below. 249 + * bank optimizations, you should use the more generic mem_read() below. 291 250 * 292 251 * For access to ptd memory, use the specialized ptd_read() and ptd_write() 293 252 * below. ··· 362 281 } 363 282 } 364 283 365 - static void mem_reads8(struct usb_hcd *hcd, void __iomem *src_base, 366 - u32 src_offset, void *dst, u32 bytes) 284 + static void isp1760_mem_read(struct usb_hcd *hcd, u32 src_offset, void *dst, 285 + u32 bytes) 367 286 { 287 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 288 + 368 289 isp1760_hcd_write(hcd, MEM_BANK_SEL, ISP_BANK_0); 369 290 isp1760_hcd_write(hcd, MEM_START_ADDR, src_offset); 291 + ndelay(100); 370 292 371 - ndelay(90); 372 - 373 - bank_reads8(src_base, src_offset, ISP_BANK_0, dst, bytes); 293 + bank_reads8(priv->base, src_offset, ISP_BANK_0, dst, bytes); 374 294 } 375 295 376 - static void mem_writes8(void __iomem *dst_base, u32 dst_offset, 377 - __u32 const *src, u32 bytes) 296 + /* 297 + * ISP1763 does not have the banks direct host controller memory access, 298 + * needs to use the HC_DATA register. Add data read/write according to this, 299 + * and also adjust 16bit access. 300 + */ 301 + static void isp1763_mem_read(struct usb_hcd *hcd, u16 srcaddr, 302 + u16 *dstptr, u32 bytes) 303 + { 304 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 305 + 306 + /* Write the starting device address to the hcd memory register */ 307 + isp1760_reg_write(priv->regs, ISP1763_HC_MEMORY, srcaddr); 308 + ndelay(100); /* Delay between consecutive access */ 309 + 310 + /* As long there are at least 16-bit to read ... */ 311 + while (bytes >= 2) { 312 + *dstptr = __raw_readw(priv->base + ISP1763_HC_DATA); 313 + bytes -= 2; 314 + dstptr++; 315 + } 316 + 317 + /* If there are no more bytes to read, return */ 318 + if (bytes <= 0) 319 + return; 320 + 321 + *((u8 *)dstptr) = (u8)(readw(priv->base + ISP1763_HC_DATA) & 0xFF); 322 + } 323 + 324 + static void mem_read(struct usb_hcd *hcd, u32 src_offset, __u32 *dst, 325 + u32 bytes) 326 + { 327 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 328 + 329 + if (!priv->is_isp1763) 330 + return isp1760_mem_read(hcd, src_offset, (u16 *)dst, bytes); 331 + 332 + isp1763_mem_read(hcd, (u16)src_offset, (u16 *)dst, bytes); 333 + } 334 + 335 + static void isp1760_mem_write(void __iomem *dst_base, u32 dst_offset, 336 + __u32 const *src, u32 bytes) 378 337 { 379 338 __u32 __iomem *dst; 380 339 ··· 448 327 __raw_writel(*src, dst); 449 328 } 450 329 330 + static void isp1763_mem_write(struct usb_hcd *hcd, u16 dstaddr, u16 *src, 331 + u32 bytes) 332 + { 333 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 334 + 335 + /* Write the starting device address to the hcd memory register */ 336 + isp1760_reg_write(priv->regs, ISP1763_HC_MEMORY, dstaddr); 337 + ndelay(100); /* Delay between consecutive access */ 338 + 339 + while (bytes >= 2) { 340 + /* Get and write the data; then adjust the data ptr and len */ 341 + __raw_writew(*src, priv->base + ISP1763_HC_DATA); 342 + bytes -= 2; 343 + src++; 344 + } 345 + 346 + /* If there are no more bytes to process, return */ 347 + if (bytes <= 0) 348 + return; 349 + 350 + /* 351 + * The only way to get here is if there is a single byte left, 352 + * get it and write it to the data reg; 353 + */ 354 + writew(*((u8 *)src), priv->base + ISP1763_HC_DATA); 355 + } 356 + 357 + static void mem_write(struct usb_hcd *hcd, u32 dst_offset, __u32 *src, 358 + u32 bytes) 359 + { 360 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 361 + 362 + if (!priv->is_isp1763) 363 + return isp1760_mem_write(priv->base, dst_offset, src, bytes); 364 + 365 + isp1763_mem_write(hcd, dst_offset, (u16 *)src, bytes); 366 + } 367 + 451 368 /* 452 369 * Read and write ptds. 'ptd_offset' should be one of ISO_PTD_OFFSET, 453 370 * INT_PTD_OFFSET, and ATL_PTD_OFFSET. 'slot' should be less than 32. 454 371 */ 455 - static void ptd_read(struct usb_hcd *hcd, void __iomem *base, 456 - u32 ptd_offset, u32 slot, struct ptd *ptd) 372 + static void isp1760_ptd_read(struct usb_hcd *hcd, u32 ptd_offset, u32 slot, 373 + struct ptd *ptd) 457 374 { 375 + u16 src_offset = ptd_offset + slot * sizeof(*ptd); 376 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 377 + 458 378 isp1760_hcd_write(hcd, MEM_BANK_SEL, ISP_BANK_0); 459 - isp1760_hcd_write(hcd, MEM_START_ADDR, 460 - ptd_offset + slot * sizeof(*ptd)); 379 + isp1760_hcd_write(hcd, MEM_START_ADDR, src_offset); 461 380 ndelay(90); 462 - bank_reads8(base, ptd_offset + slot * sizeof(*ptd), ISP_BANK_0, 463 - (void *)ptd, sizeof(*ptd)); 381 + 382 + bank_reads8(priv->base, src_offset, ISP_BANK_0, (void *)ptd, 383 + sizeof(*ptd)); 464 384 } 465 385 466 - static void ptd_write(void __iomem *base, u32 ptd_offset, u32 slot, 467 - struct ptd *ptd) 386 + static void isp1763_ptd_read(struct usb_hcd *hcd, u32 ptd_offset, u32 slot, 387 + struct ptd *ptd) 468 388 { 469 - mem_writes8(base, ptd_offset + slot*sizeof(*ptd) + sizeof(ptd->dw0), 470 - (__force u32 *)&ptd->dw1, 7 * sizeof(ptd->dw1)); 471 - /* Make sure dw0 gets written last (after other dw's and after payload) 472 - since it contains the enable bit */ 473 - wmb(); 474 - mem_writes8(base, ptd_offset + slot * sizeof(*ptd), 475 - (__force u32 *)&ptd->dw0, sizeof(ptd->dw0)); 389 + u16 src_offset = ptd_offset + slot * sizeof(*ptd); 390 + struct ptd_le32 le32_ptd; 391 + 392 + isp1763_mem_read(hcd, src_offset, (u16 *)&le32_ptd, sizeof(le32_ptd)); 393 + /* Normalize the data obtained */ 394 + ptd->dw0 = le32_to_dw(le32_ptd.dw0); 395 + ptd->dw1 = le32_to_dw(le32_ptd.dw1); 396 + ptd->dw2 = le32_to_dw(le32_ptd.dw2); 397 + ptd->dw3 = le32_to_dw(le32_ptd.dw3); 398 + ptd->dw4 = le32_to_dw(le32_ptd.dw4); 399 + ptd->dw5 = le32_to_dw(le32_ptd.dw5); 400 + ptd->dw6 = le32_to_dw(le32_ptd.dw6); 401 + ptd->dw7 = le32_to_dw(le32_ptd.dw7); 476 402 } 477 403 404 + static void ptd_read(struct usb_hcd *hcd, u32 ptd_offset, u32 slot, 405 + struct ptd *ptd) 406 + { 407 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 408 + 409 + if (!priv->is_isp1763) 410 + return isp1760_ptd_read(hcd, ptd_offset, slot, ptd); 411 + 412 + isp1763_ptd_read(hcd, ptd_offset, slot, ptd); 413 + } 414 + 415 + static void isp1763_ptd_write(struct usb_hcd *hcd, u32 ptd_offset, u32 slot, 416 + struct ptd *cpu_ptd) 417 + { 418 + u16 dst_offset = ptd_offset + slot * sizeof(*cpu_ptd); 419 + struct ptd_le32 ptd; 420 + 421 + ptd.dw0 = dw_to_le32(cpu_ptd->dw0); 422 + ptd.dw1 = dw_to_le32(cpu_ptd->dw1); 423 + ptd.dw2 = dw_to_le32(cpu_ptd->dw2); 424 + ptd.dw3 = dw_to_le32(cpu_ptd->dw3); 425 + ptd.dw4 = dw_to_le32(cpu_ptd->dw4); 426 + ptd.dw5 = dw_to_le32(cpu_ptd->dw5); 427 + ptd.dw6 = dw_to_le32(cpu_ptd->dw6); 428 + ptd.dw7 = dw_to_le32(cpu_ptd->dw7); 429 + 430 + isp1763_mem_write(hcd, dst_offset, (u16 *)&ptd.dw0, 431 + 8 * sizeof(ptd.dw0)); 432 + } 433 + 434 + static void isp1760_ptd_write(void __iomem *base, u32 ptd_offset, u32 slot, 435 + struct ptd *ptd) 436 + { 437 + u32 dst_offset = ptd_offset + slot * sizeof(*ptd); 438 + 439 + /* 440 + * Make sure dw0 gets written last (after other dw's and after payload) 441 + * since it contains the enable bit 442 + */ 443 + isp1760_mem_write(base, dst_offset + sizeof(ptd->dw0), 444 + (__force u32 *)&ptd->dw1, 7 * sizeof(ptd->dw1)); 445 + wmb(); 446 + isp1760_mem_write(base, dst_offset, (__force u32 *)&ptd->dw0, 447 + sizeof(ptd->dw0)); 448 + } 449 + 450 + static void ptd_write(struct usb_hcd *hcd, u32 ptd_offset, u32 slot, 451 + struct ptd *ptd) 452 + { 453 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 454 + 455 + if (!priv->is_isp1763) 456 + return isp1760_ptd_write(priv->base, ptd_offset, slot, ptd); 457 + 458 + isp1763_ptd_write(hcd, ptd_offset, slot, ptd); 459 + } 478 460 479 461 /* memory management of the 60kb on the chip from 0x1000 to 0xffff */ 480 462 static void init_memory(struct isp1760_hcd *priv) ··· 654 430 hcd->state = HC_STATE_HALT; 655 431 priv->next_statechange = jiffies; 656 432 657 - return isp1760_hcd_set_poll_timeout(hcd, CMD_RESET, 250 * 1000); 433 + return isp1760_hcd_set_and_wait_swap(hcd, CMD_RESET, 250 * 1000); 658 434 } 659 435 660 436 static struct isp1760_qh *qh_alloc(gfp_t flags) ··· 685 461 struct isp1760_hcd *priv = hcd_to_priv(hcd); 686 462 u32 isoc_cache; 687 463 u32 isoc_thres; 688 - 689 464 int i; 690 465 691 466 spin_lock_init(&priv->lock); ··· 697 474 * periodic_size can shrink by USBCMD update if hcc_params allows. 698 475 */ 699 476 priv->periodic_size = DEFAULT_I_TDPS; 477 + 478 + if (priv->is_isp1763) { 479 + priv->i_thresh = 2; 480 + return 0; 481 + } 700 482 701 483 /* controllers may cache some of the periodic schedule ... */ 702 484 isoc_cache = isp1760_hcd_read(hcd, HCC_ISOC_CACHE); ··· 719 491 static int isp1760_hc_setup(struct usb_hcd *hcd) 720 492 { 721 493 struct isp1760_hcd *priv = hcd_to_priv(hcd); 494 + u32 atx_reset; 722 495 int result; 723 496 u32 scratch; 497 + u32 pattern; 724 498 725 - isp1760_reg_write(priv->regs, ISP176x_HC_SCRATCH, 0xdeadbabe); 499 + if (priv->is_isp1763) 500 + pattern = 0xcafe; 501 + else 502 + pattern = 0xdeadcafe; 503 + 504 + isp1760_hcd_write(hcd, HC_SCRATCH, pattern); 726 505 727 506 /* Change bus pattern */ 728 - scratch = isp1760_reg_read(priv->regs, ISP176x_HC_CHIP_ID); 729 - scratch = isp1760_reg_read(priv->regs, ISP176x_HC_SCRATCH); 730 - if (scratch != 0xdeadbabe) { 731 - dev_err(hcd->self.controller, "Scratch test failed.\n"); 507 + scratch = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH); 508 + dev_err(hcd->self.controller, "Scratch test 0x%08x\n", scratch); 509 + scratch = isp1760_hcd_read(hcd, HC_SCRATCH); 510 + if (scratch != pattern) { 511 + dev_err(hcd->self.controller, "Scratch test failed. 0x%08x\n", scratch); 732 512 return -ENODEV; 733 513 } 734 514 ··· 748 512 * the host controller through the EHCI USB Command register. The device 749 513 * has been reset in core code anyway, so this shouldn't matter. 750 514 */ 751 - isp1760_reg_write(priv->regs, ISP176x_HC_BUFFER_STATUS, 0); 752 - isp1760_reg_write(priv->regs, ISP176x_HC_ATL_PTD_SKIPMAP, 753 - NO_TRANSFER_ACTIVE); 754 - isp1760_reg_write(priv->regs, ISP176x_HC_INT_PTD_SKIPMAP, 755 - NO_TRANSFER_ACTIVE); 756 - isp1760_reg_write(priv->regs, ISP176x_HC_ISO_PTD_SKIPMAP, 757 - NO_TRANSFER_ACTIVE); 515 + isp1760_hcd_clear(hcd, ISO_BUF_FILL); 516 + isp1760_hcd_clear(hcd, INT_BUF_FILL); 517 + isp1760_hcd_clear(hcd, ATL_BUF_FILL); 518 + 519 + isp1760_hcd_set(hcd, HC_ATL_PTD_SKIPMAP); 520 + isp1760_hcd_set(hcd, HC_INT_PTD_SKIPMAP); 521 + isp1760_hcd_set(hcd, HC_ISO_PTD_SKIPMAP); 758 522 759 523 result = ehci_reset(hcd); 760 524 if (result) ··· 763 527 /* Step 11 passed */ 764 528 765 529 /* ATL reset */ 766 - isp1760_hcd_set(hcd, ALL_ATX_RESET); 767 - mdelay(10); 768 - isp1760_hcd_clear(hcd, ALL_ATX_RESET); 530 + if (priv->is_isp1763) 531 + atx_reset = SW_RESET_RESET_ATX; 532 + else 533 + atx_reset = ALL_ATX_RESET; 769 534 770 - isp1760_hcd_set(hcd, HC_INT_ENABLE); 535 + isp1760_hcd_set(hcd, atx_reset); 536 + mdelay(10); 537 + isp1760_hcd_clear(hcd, atx_reset); 538 + 539 + if (priv->is_isp1763) { 540 + isp1760_hcd_set(hcd, HW_OTG_DISABLE); 541 + isp1760_hcd_set(hcd, HW_SW_SEL_HC_DC_CLEAR); 542 + isp1760_hcd_set(hcd, HW_HC_2_DIS_CLEAR); 543 + mdelay(10); 544 + 545 + isp1760_hcd_set(hcd, HW_INTF_LOCK); 546 + } 547 + 548 + isp1760_hcd_set(hcd, HC_INT_IRQ_ENABLE); 549 + isp1760_hcd_set(hcd, HC_ATL_IRQ_ENABLE); 771 550 772 551 return priv_init(hcd); 773 552 } ··· 1002 751 struct ptd *ptd) 1003 752 { 1004 753 struct isp1760_hcd *priv = hcd_to_priv(hcd); 754 + const struct isp1760_memory_layout *mem = priv->memory_layout; 1005 755 int skip_map; 1006 756 1007 - WARN_ON((slot < 0) || (slot > 31)); 757 + WARN_ON((slot < 0) || (slot > mem->slot_num - 1)); 1008 758 WARN_ON(qtd->length && !qtd->payload_addr); 1009 759 WARN_ON(slots[slot].qtd); 1010 760 WARN_ON(slots[slot].qh); 1011 761 WARN_ON(qtd->status != QTD_PAYLOAD_ALLOC); 1012 762 763 + if (priv->is_isp1763) 764 + ndelay(100); 765 + 1013 766 /* Make sure done map has not triggered from some unlinked transfer */ 1014 767 if (ptd_offset == ATL_PTD_OFFSET) { 1015 - priv->atl_done_map |= isp1760_reg_read(priv->regs, 1016 - ISP176x_HC_ATL_PTD_DONEMAP); 768 + skip_map = isp1760_hcd_read(hcd, HC_ATL_PTD_SKIPMAP); 769 + isp1760_hcd_write(hcd, HC_ATL_PTD_SKIPMAP, 770 + skip_map | (1 << slot)); 771 + priv->atl_done_map |= isp1760_hcd_read(hcd, HC_ATL_PTD_DONEMAP); 1017 772 priv->atl_done_map &= ~(1 << slot); 1018 773 } else { 1019 - priv->int_done_map |= isp1760_reg_read(priv->regs, 1020 - ISP176x_HC_INT_PTD_DONEMAP); 774 + skip_map = isp1760_hcd_read(hcd, HC_INT_PTD_SKIPMAP); 775 + isp1760_hcd_write(hcd, HC_INT_PTD_SKIPMAP, 776 + skip_map | (1 << slot)); 777 + priv->int_done_map |= isp1760_hcd_read(hcd, HC_INT_PTD_DONEMAP); 1021 778 priv->int_done_map &= ~(1 << slot); 1022 779 } 1023 780 781 + skip_map &= ~(1 << slot); 1024 782 qh->slot = slot; 1025 783 qtd->status = QTD_XFER_STARTED; 1026 784 slots[slot].timestamp = jiffies; 1027 785 slots[slot].qtd = qtd; 1028 786 slots[slot].qh = qh; 1029 - ptd_write(priv->base, ptd_offset, slot, ptd); 787 + ptd_write(hcd, ptd_offset, slot, ptd); 1030 788 1031 - if (ptd_offset == ATL_PTD_OFFSET) { 1032 - skip_map = isp1760_reg_read(priv->regs, 1033 - ISP176x_HC_ATL_PTD_SKIPMAP); 1034 - skip_map &= ~(1 << qh->slot); 1035 - isp1760_reg_write(priv->regs, ISP176x_HC_ATL_PTD_SKIPMAP, 1036 - skip_map); 1037 - } else { 1038 - skip_map = isp1760_reg_read(priv->regs, 1039 - ISP176x_HC_INT_PTD_SKIPMAP); 1040 - skip_map &= ~(1 << qh->slot); 1041 - isp1760_reg_write(priv->regs, ISP176x_HC_INT_PTD_SKIPMAP, 1042 - skip_map); 1043 - } 789 + if (ptd_offset == ATL_PTD_OFFSET) 790 + isp1760_hcd_write(hcd, HC_ATL_PTD_SKIPMAP, skip_map); 791 + else 792 + isp1760_hcd_write(hcd, HC_INT_PTD_SKIPMAP, skip_map); 1044 793 } 1045 794 1046 795 static int is_short_bulk(struct isp1760_qtd *qtd) ··· 1052 801 static void collect_qtds(struct usb_hcd *hcd, struct isp1760_qh *qh, 1053 802 struct list_head *urb_list) 1054 803 { 1055 - struct isp1760_hcd *priv = hcd_to_priv(hcd); 1056 804 struct isp1760_qtd *qtd, *qtd_next; 1057 805 struct urb_listitem *urb_listitem; 1058 806 int last_qtd; ··· 1069 819 if (qtd->actual_length) { 1070 820 switch (qtd->packet_type) { 1071 821 case IN_PID: 1072 - mem_reads8(hcd, priv->base, 1073 - qtd->payload_addr, 1074 - qtd->data_buffer, 1075 - qtd->actual_length); 822 + mem_read(hcd, qtd->payload_addr, 823 + qtd->data_buffer, 824 + qtd->actual_length); 1076 825 fallthrough; 1077 826 case OUT_PID: 1078 827 qtd->urb->actual_length += ··· 1115 866 static void enqueue_qtds(struct usb_hcd *hcd, struct isp1760_qh *qh) 1116 867 { 1117 868 struct isp1760_hcd *priv = hcd_to_priv(hcd); 869 + const struct isp1760_memory_layout *mem = priv->memory_layout; 870 + int slot_num = mem->slot_num; 1118 871 int ptd_offset; 1119 872 struct isp1760_slotinfo *slots; 1120 873 int curr_slot, free_slot; ··· 1143 892 } 1144 893 1145 894 free_slot = -1; 1146 - for (curr_slot = 0; curr_slot < 32; curr_slot++) { 895 + for (curr_slot = 0; curr_slot < slot_num; curr_slot++) { 1147 896 if ((free_slot == -1) && (slots[curr_slot].qtd == NULL)) 1148 897 free_slot = curr_slot; 1149 898 if (slots[curr_slot].qh == qh) ··· 1158 907 if ((qtd->length) && (!qtd->payload_addr)) 1159 908 break; 1160 909 1161 - if ((qtd->length) && 1162 - ((qtd->packet_type == SETUP_PID) || 1163 - (qtd->packet_type == OUT_PID))) { 1164 - mem_writes8(priv->base, qtd->payload_addr, 1165 - qtd->data_buffer, qtd->length); 910 + if (qtd->length && (qtd->packet_type == SETUP_PID || 911 + qtd->packet_type == OUT_PID)) { 912 + mem_write(hcd, qtd->payload_addr, 913 + qtd->data_buffer, qtd->length); 1166 914 } 1167 915 1168 916 qtd->status = QTD_PAYLOAD_ALLOC; ··· 1174 924 "available for transfer\n", __func__); 1175 925 */ 1176 926 /* Start xfer for this endpoint if not already done */ 1177 - if ((curr_slot > 31) && (free_slot > -1)) { 927 + if ((curr_slot > slot_num - 1) && (free_slot > -1)) { 1178 928 if (usb_pipeint(qtd->urb->pipe)) 1179 929 create_ptd_int(qh, qtd, &ptd); 1180 930 else ··· 1361 1111 int modified; 1362 1112 int skip_map; 1363 1113 1364 - skip_map = isp1760_reg_read(priv->regs, ISP176x_HC_INT_PTD_SKIPMAP); 1114 + skip_map = isp1760_hcd_read(hcd, HC_INT_PTD_SKIPMAP); 1365 1115 priv->int_done_map &= ~skip_map; 1366 - skip_map = isp1760_reg_read(priv->regs, ISP176x_HC_ATL_PTD_SKIPMAP); 1116 + skip_map = isp1760_hcd_read(hcd, HC_ATL_PTD_SKIPMAP); 1367 1117 priv->atl_done_map &= ~skip_map; 1368 1118 1369 1119 modified = priv->int_done_map || priv->atl_done_map; ··· 1381 1131 continue; 1382 1132 } 1383 1133 ptd_offset = INT_PTD_OFFSET; 1384 - ptd_read(hcd, priv->base, INT_PTD_OFFSET, slot, &ptd); 1134 + ptd_read(hcd, INT_PTD_OFFSET, slot, &ptd); 1385 1135 state = check_int_transfer(hcd, &ptd, 1386 1136 slots[slot].qtd->urb); 1387 1137 } else { ··· 1396 1146 continue; 1397 1147 } 1398 1148 ptd_offset = ATL_PTD_OFFSET; 1399 - ptd_read(hcd, priv->base, ATL_PTD_OFFSET, slot, &ptd); 1149 + ptd_read(hcd, ATL_PTD_OFFSET, slot, &ptd); 1400 1150 state = check_atl_transfer(hcd, &ptd, 1401 1151 slots[slot].qtd->urb); 1402 1152 } ··· 1489 1239 static irqreturn_t isp1760_irq(struct usb_hcd *hcd) 1490 1240 { 1491 1241 struct isp1760_hcd *priv = hcd_to_priv(hcd); 1492 - u32 imask; 1493 1242 irqreturn_t irqret = IRQ_NONE; 1243 + u32 int_reg; 1244 + u32 imask; 1494 1245 1495 1246 spin_lock(&priv->lock); 1496 1247 1497 1248 if (!(hcd->state & HC_STATE_RUNNING)) 1498 1249 goto leave; 1499 1250 1500 - imask = isp1760_reg_read(priv->regs, ISP176x_HC_INTERRUPT); 1251 + imask = isp1760_hcd_read(hcd, HC_INTERRUPT); 1501 1252 if (unlikely(!imask)) 1502 1253 goto leave; 1503 - isp1760_reg_write(priv->regs, ISP176x_HC_INTERRUPT, imask); /* Clear */ 1504 1254 1505 - priv->int_done_map |= isp1760_reg_read(priv->regs, 1506 - ISP176x_HC_INT_PTD_DONEMAP); 1507 - priv->atl_done_map |= isp1760_reg_read(priv->regs, 1508 - ISP176x_HC_ATL_PTD_DONEMAP); 1255 + int_reg = priv->is_isp1763 ? ISP1763_HC_INTERRUPT : 1256 + ISP176x_HC_INTERRUPT; 1257 + isp1760_reg_write(priv->regs, int_reg, imask); 1258 + 1259 + priv->int_done_map |= isp1760_hcd_read(hcd, HC_INT_PTD_DONEMAP); 1260 + priv->atl_done_map |= isp1760_hcd_read(hcd, HC_ATL_PTD_DONEMAP); 1509 1261 1510 1262 handle_done_ptds(hcd); 1511 1263 1512 1264 irqret = IRQ_HANDLED; 1265 + 1513 1266 leave: 1514 1267 spin_unlock(&priv->lock); 1515 1268 ··· 1553 1300 { 1554 1301 struct usb_hcd *hcd = errata2_timer_hcd; 1555 1302 struct isp1760_hcd *priv = hcd_to_priv(hcd); 1303 + const struct isp1760_memory_layout *mem = priv->memory_layout; 1556 1304 int slot; 1557 1305 struct ptd ptd; 1558 1306 unsigned long spinflags; 1559 1307 1560 1308 spin_lock_irqsave(&priv->lock, spinflags); 1561 1309 1562 - for (slot = 0; slot < 32; slot++) 1310 + for (slot = 0; slot < mem->slot_num; slot++) 1563 1311 if (priv->atl_slots[slot].qh && time_after(jiffies, 1564 1312 priv->atl_slots[slot].timestamp + 1565 1313 msecs_to_jiffies(SLOT_TIMEOUT))) { 1566 - ptd_read(hcd, priv->base, ATL_PTD_OFFSET, slot, &ptd); 1314 + ptd_read(hcd, ATL_PTD_OFFSET, slot, &ptd); 1567 1315 if (!FROM_DW0_VALID(ptd.dw0) && 1568 1316 !FROM_DW3_ACTIVE(ptd.dw3)) 1569 1317 priv->atl_done_map |= 1 << slot; ··· 1579 1325 add_timer(&errata2_timer); 1580 1326 } 1581 1327 1328 + static int isp1763_run(struct usb_hcd *hcd) 1329 + { 1330 + struct isp1760_hcd *priv = hcd_to_priv(hcd); 1331 + int retval; 1332 + u32 chipid_h; 1333 + u32 chipid_l; 1334 + u32 chip_rev; 1335 + u32 ptd_atl_int; 1336 + u32 ptd_iso; 1337 + 1338 + hcd->uses_new_polling = 1; 1339 + hcd->state = HC_STATE_RUNNING; 1340 + 1341 + chipid_h = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH); 1342 + chipid_l = isp1760_hcd_read(hcd, HC_CHIP_ID_LOW); 1343 + chip_rev = isp1760_hcd_read(hcd, HC_CHIP_REV); 1344 + dev_info(hcd->self.controller, "USB ISP %02x%02x HW rev. %d started\n", 1345 + chipid_h, chipid_l, chip_rev); 1346 + 1347 + isp1760_hcd_clear(hcd, ISO_BUF_FILL); 1348 + isp1760_hcd_clear(hcd, INT_BUF_FILL); 1349 + isp1760_hcd_clear(hcd, ATL_BUF_FILL); 1350 + 1351 + isp1760_hcd_set(hcd, HC_ATL_PTD_SKIPMAP); 1352 + isp1760_hcd_set(hcd, HC_INT_PTD_SKIPMAP); 1353 + isp1760_hcd_set(hcd, HC_ISO_PTD_SKIPMAP); 1354 + ndelay(100); 1355 + isp1760_hcd_clear(hcd, HC_ATL_PTD_DONEMAP); 1356 + isp1760_hcd_clear(hcd, HC_INT_PTD_DONEMAP); 1357 + isp1760_hcd_clear(hcd, HC_ISO_PTD_DONEMAP); 1358 + 1359 + isp1760_hcd_set(hcd, HW_OTG_DISABLE); 1360 + isp1760_reg_write(priv->regs, ISP1763_HC_OTG_CTRL_CLEAR, BIT(7)); 1361 + isp1760_reg_write(priv->regs, ISP1763_HC_OTG_CTRL_CLEAR, BIT(15)); 1362 + mdelay(10); 1363 + 1364 + isp1760_hcd_set(hcd, HC_INT_IRQ_ENABLE); 1365 + isp1760_hcd_set(hcd, HC_ATL_IRQ_ENABLE); 1366 + 1367 + isp1760_hcd_set(hcd, HW_GLOBAL_INTR_EN); 1368 + 1369 + isp1760_hcd_clear(hcd, HC_ATL_IRQ_MASK_AND); 1370 + isp1760_hcd_clear(hcd, HC_INT_IRQ_MASK_AND); 1371 + isp1760_hcd_clear(hcd, HC_ISO_IRQ_MASK_AND); 1372 + 1373 + isp1760_hcd_set(hcd, HC_ATL_IRQ_MASK_OR); 1374 + isp1760_hcd_set(hcd, HC_INT_IRQ_MASK_OR); 1375 + isp1760_hcd_set(hcd, HC_ISO_IRQ_MASK_OR); 1376 + 1377 + ptd_atl_int = 0x8000; 1378 + ptd_iso = 0x0001; 1379 + 1380 + isp1760_hcd_write(hcd, HC_ATL_PTD_LASTPTD, ptd_atl_int); 1381 + isp1760_hcd_write(hcd, HC_INT_PTD_LASTPTD, ptd_atl_int); 1382 + isp1760_hcd_write(hcd, HC_ISO_PTD_LASTPTD, ptd_iso); 1383 + 1384 + isp1760_hcd_set(hcd, ATL_BUF_FILL); 1385 + isp1760_hcd_set(hcd, INT_BUF_FILL); 1386 + 1387 + isp1760_hcd_clear(hcd, CMD_LRESET); 1388 + isp1760_hcd_clear(hcd, CMD_RESET); 1389 + 1390 + retval = isp1760_hcd_set_and_wait(hcd, CMD_RUN, 250 * 1000); 1391 + if (retval) 1392 + return retval; 1393 + 1394 + down_write(&ehci_cf_port_reset_rwsem); 1395 + retval = isp1760_hcd_set_and_wait(hcd, FLAG_CF, 250 * 1000); 1396 + up_write(&ehci_cf_port_reset_rwsem); 1397 + retval = 0; 1398 + if (retval) 1399 + return retval; 1400 + 1401 + return 0; 1402 + } 1403 + 1582 1404 static int isp1760_run(struct usb_hcd *hcd) 1583 1405 { 1584 1406 struct isp1760_hcd *priv = hcd_to_priv(hcd); 1585 1407 int retval; 1586 - u32 chipid; 1408 + u32 chipid_h; 1409 + u32 chipid_l; 1410 + u32 chip_rev; 1411 + u32 ptd_atl_int; 1412 + u32 ptd_iso; 1413 + 1414 + /* 1415 + * ISP1763 have some differences in the setup and order to enable 1416 + * the ports, disable otg, setup buffers, and ATL, INT, ISO status. 1417 + * So, just handle it a separate sequence. 1418 + */ 1419 + if (priv->is_isp1763) 1420 + return isp1763_run(hcd); 1587 1421 1588 1422 hcd->uses_new_polling = 1; 1589 1423 1590 1424 hcd->state = HC_STATE_RUNNING; 1591 1425 1592 1426 /* Set PTD interrupt AND & OR maps */ 1593 - isp1760_reg_write(priv->regs, ISP176x_HC_ATL_IRQ_MASK_AND, 0); 1594 - isp1760_reg_write(priv->regs, ISP176x_HC_ATL_IRQ_MASK_OR, 0xffffffff); 1595 - isp1760_reg_write(priv->regs, ISP176x_HC_INT_IRQ_MASK_AND, 0); 1596 - isp1760_reg_write(priv->regs, ISP176x_HC_INT_IRQ_MASK_OR, 0xffffffff); 1597 - isp1760_reg_write(priv->regs, ISP176x_HC_ISO_IRQ_MASK_AND, 0); 1598 - isp1760_reg_write(priv->regs, ISP176x_HC_ISO_IRQ_MASK_OR, 0xffffffff); 1427 + isp1760_hcd_clear(hcd, HC_ATL_IRQ_MASK_AND); 1428 + isp1760_hcd_clear(hcd, HC_INT_IRQ_MASK_AND); 1429 + isp1760_hcd_clear(hcd, HC_ISO_IRQ_MASK_AND); 1430 + 1431 + isp1760_hcd_set(hcd, HC_ATL_IRQ_MASK_OR); 1432 + isp1760_hcd_set(hcd, HC_INT_IRQ_MASK_OR); 1433 + isp1760_hcd_set(hcd, HC_ISO_IRQ_MASK_OR); 1434 + 1599 1435 /* step 23 passed */ 1600 1436 1601 1437 isp1760_hcd_set(hcd, HW_GLOBAL_INTR_EN); ··· 1693 1349 isp1760_hcd_clear(hcd, CMD_LRESET); 1694 1350 isp1760_hcd_clear(hcd, CMD_RESET); 1695 1351 1696 - retval = isp1760_hcd_set_poll_timeout(hcd, CMD_RUN, 250 * 1000); 1352 + retval = isp1760_hcd_set_and_wait(hcd, CMD_RUN, 250 * 1000); 1697 1353 if (retval) 1698 1354 return retval; 1699 1355 ··· 1704 1360 */ 1705 1361 down_write(&ehci_cf_port_reset_rwsem); 1706 1362 1707 - retval = isp1760_hcd_set_poll_timeout(hcd, FLAG_CF, 250 * 1000); 1363 + retval = isp1760_hcd_set_and_wait(hcd, FLAG_CF, 250 * 1000); 1708 1364 up_write(&ehci_cf_port_reset_rwsem); 1709 1365 if (retval) 1710 1366 return retval; ··· 1714 1370 errata2_timer.expires = jiffies + msecs_to_jiffies(SLOT_CHECK_PERIOD); 1715 1371 add_timer(&errata2_timer); 1716 1372 1717 - chipid = isp1760_reg_read(priv->regs, ISP176x_HC_CHIP_ID); 1718 - dev_info(hcd->self.controller, "USB ISP %04x HW rev. %d started\n", 1719 - chipid & 0xffff, chipid >> 16); 1373 + chipid_h = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH); 1374 + chipid_l = isp1760_hcd_read(hcd, HC_CHIP_ID_LOW); 1375 + chip_rev = isp1760_hcd_read(hcd, HC_CHIP_REV); 1376 + dev_info(hcd->self.controller, "USB ISP %02x%02x HW rev. %d started\n", 1377 + chipid_h, chipid_l, chip_rev); 1720 1378 1721 1379 /* PTD Register Init Part 2, Step 28 */ 1722 1380 1723 1381 /* Setup registers controlling PTD checking */ 1724 - isp1760_reg_write(priv->regs, ISP176x_HC_ATL_PTD_LASTPTD, 0x80000000); 1725 - isp1760_reg_write(priv->regs, ISP176x_HC_INT_PTD_LASTPTD, 0x80000000); 1726 - isp1760_reg_write(priv->regs, ISP176x_HC_ISO_PTD_LASTPTD, 0x00000001); 1727 - isp1760_reg_write(priv->regs, ISP176x_HC_ATL_PTD_SKIPMAP, 0xffffffff); 1728 - isp1760_reg_write(priv->regs, ISP176x_HC_INT_PTD_SKIPMAP, 0xffffffff); 1729 - isp1760_reg_write(priv->regs, ISP176x_HC_ISO_PTD_SKIPMAP, 0xffffffff); 1382 + ptd_atl_int = 0x80000000; 1383 + ptd_iso = 0x00000001; 1384 + 1385 + isp1760_hcd_write(hcd, HC_ATL_PTD_LASTPTD, ptd_atl_int); 1386 + isp1760_hcd_write(hcd, HC_INT_PTD_LASTPTD, ptd_atl_int); 1387 + isp1760_hcd_write(hcd, HC_ISO_PTD_LASTPTD, ptd_iso); 1388 + 1389 + isp1760_hcd_set(hcd, HC_ATL_PTD_SKIPMAP); 1390 + isp1760_hcd_set(hcd, HC_INT_PTD_SKIPMAP); 1391 + isp1760_hcd_set(hcd, HC_ISO_PTD_SKIPMAP); 1730 1392 1731 1393 isp1760_hcd_set(hcd, ATL_BUF_FILL); 1732 1394 isp1760_hcd_set(hcd, INT_BUF_FILL); ··· 1973 1623 /* We need to forcefully reclaim the slot since some transfers never 1974 1624 return, e.g. interrupt transfers and NAKed bulk transfers. */ 1975 1625 if (usb_pipecontrol(urb->pipe) || usb_pipebulk(urb->pipe)) { 1976 - skip_map = isp1760_reg_read(priv->regs, 1977 - ISP176x_HC_ATL_PTD_SKIPMAP); 1626 + skip_map = isp1760_hcd_read(hcd, HC_ATL_PTD_SKIPMAP); 1978 1627 skip_map |= (1 << qh->slot); 1979 - isp1760_reg_write(priv->regs, ISP176x_HC_ATL_PTD_SKIPMAP, 1980 - skip_map); 1628 + isp1760_hcd_write(hcd, HC_ATL_PTD_SKIPMAP, skip_map); 1629 + ndelay(100); 1981 1630 priv->atl_slots[qh->slot].qh = NULL; 1982 1631 priv->atl_slots[qh->slot].qtd = NULL; 1983 1632 } else { 1984 - skip_map = isp1760_reg_read(priv->regs, 1985 - ISP176x_HC_INT_PTD_SKIPMAP); 1633 + skip_map = isp1760_hcd_read(hcd, HC_INT_PTD_SKIPMAP); 1986 1634 skip_map |= (1 << qh->slot); 1987 - isp1760_reg_write(priv->regs, ISP176x_HC_INT_PTD_SKIPMAP, 1988 - skip_map); 1635 + isp1760_hcd_write(hcd, HC_INT_PTD_SKIPMAP, skip_map); 1989 1636 priv->int_slots[qh->slot].qh = NULL; 1990 1637 priv->int_slots[qh->slot].qtd = NULL; 1991 1638 } ··· 2138 1791 int ports; 2139 1792 u16 temp; 2140 1793 2141 - ports = isp1760_hcd_read(priv->hcd, HCS_N_PORTS); 1794 + ports = isp1760_hcd_n_ports(priv->hcd); 2142 1795 2143 1796 desc->bDescriptorType = USB_DT_HUB; 2144 1797 /* priv 1.0, 2.3.9 says 20ms max */ ··· 2155 1808 2156 1809 /* per-port overcurrent reporting */ 2157 1810 temp = HUB_CHAR_INDV_PORT_OCPM; 2158 - if (isp1760_hcd_is_set(priv->hcd, HCS_PPC)) 1811 + if (isp1760_hcd_ppc_is_set(priv->hcd)) 2159 1812 /* per-port power control */ 2160 1813 temp |= HUB_CHAR_INDV_PORT_LPSM; 2161 1814 else ··· 2196 1849 int retval = 0; 2197 1850 int ports; 2198 1851 2199 - ports = isp1760_hcd_read(hcd, HCS_N_PORTS); 1852 + ports = isp1760_hcd_n_ports(hcd); 2200 1853 2201 1854 /* 2202 1855 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. ··· 2255 1908 /* we auto-clear this feature */ 2256 1909 break; 2257 1910 case USB_PORT_FEAT_POWER: 2258 - if (isp1760_hcd_is_set(hcd, HCS_PPC)) 1911 + if (isp1760_hcd_ppc_is_set(hcd)) 2259 1912 isp1760_hcd_clear(hcd, PORT_POWER); 2260 1913 break; 2261 1914 case USB_PORT_FEAT_C_CONNECTION: ··· 2270 1923 default: 2271 1924 goto error; 2272 1925 } 2273 - isp1760_reg_read(priv->regs, ISP176x_HC_USBCMD); 1926 + isp1760_hcd_read(hcd, CMD_RUN); 2274 1927 break; 2275 1928 case GetHubDescriptor: 2276 1929 isp1760_hub_descriptor(priv, (struct usb_hub_descriptor *) ··· 2289 1942 /* wPortChange bits */ 2290 1943 if (isp1760_hcd_is_set(hcd, PORT_CSC)) 2291 1944 status |= USB_PORT_STAT_C_CONNECTION << 16; 2292 - 2293 1945 2294 1946 /* whoever resumes must GetPortStatus to complete it!! */ 2295 1947 if (isp1760_hcd_is_set(hcd, PORT_RESUME)) { ··· 2312 1966 /* stop resume signaling */ 2313 1967 isp1760_hcd_clear(hcd, PORT_CSC); 2314 1968 2315 - retval = isp1760_hcd_clear_poll_timeout(hcd, 1969 + retval = isp1760_hcd_clear_and_wait(hcd, 2316 1970 PORT_RESUME, 2000); 2317 1971 if (retval != 0) { 2318 1972 dev_err(hcd->self.controller, ··· 2333 1987 /* REVISIT: some hardware needs 550+ usec to clear 2334 1988 * this bit; seems too long to spin routinely... 2335 1989 */ 2336 - retval = isp1760_hcd_clear_poll_timeout(hcd, PORT_RESET, 2337 - 750); 1990 + retval = isp1760_hcd_clear_and_wait(hcd, PORT_RESET, 1991 + 750); 2338 1992 if (retval != 0) { 2339 1993 dev_err(hcd->self.controller, "port %d reset error %d\n", 2340 - wIndex + 1, retval); 1994 + wIndex + 1, retval); 2341 1995 goto error; 2342 1996 } 2343 1997 ··· 2385 2039 if (!wIndex || wIndex > ports) 2386 2040 goto error; 2387 2041 wIndex--; 2042 + 2388 2043 if (isp1760_hcd_is_set(hcd, PORT_OWNER)) 2389 2044 break; 2390 2045 ··· 2402 2055 isp1760_hcd_set(hcd, PORT_SUSPEND); 2403 2056 break; 2404 2057 case USB_PORT_FEAT_POWER: 2405 - if (isp1760_hcd_is_set(hcd, HCS_PPC)) 2058 + if (isp1760_hcd_ppc_is_set(hcd)) 2406 2059 isp1760_hcd_set(hcd, PORT_POWER); 2407 2060 break; 2408 2061 case USB_PORT_FEAT_RESET: ··· 2431 2084 default: 2432 2085 goto error; 2433 2086 } 2434 - isp1760_reg_read(priv->regs, ISP176x_HC_USBCMD); 2435 2087 break; 2436 2088 2437 2089 default: ··· 2565 2219 2566 2220 priv->hcd = hcd; 2567 2221 2568 - priv->memory_pool = kcalloc(mem_layout->payload_blocks, 2569 - sizeof(struct isp1760_memory_chunk), 2570 - GFP_KERNEL); 2571 - if (!priv->memory_pool) { 2222 + priv->atl_slots = kcalloc(mem_layout->slot_num, 2223 + sizeof(struct isp1760_slotinfo), GFP_KERNEL); 2224 + if (!priv->atl_slots) { 2572 2225 ret = -ENOMEM; 2573 2226 goto put_hcd; 2574 2227 } 2575 2228 2576 - priv->atl_slots = kcalloc(mem_layout->ptd_num, 2577 - sizeof(struct isp1760_slotinfo), GFP_KERNEL); 2578 - if (!priv->atl_slots) { 2579 - ret = -ENOMEM; 2580 - goto free_mem_pool; 2581 - } 2582 - 2583 - priv->int_slots = kcalloc(mem_layout->ptd_num, 2229 + priv->int_slots = kcalloc(mem_layout->slot_num, 2584 2230 sizeof(struct isp1760_slotinfo), GFP_KERNEL); 2585 2231 if (!priv->int_slots) { 2586 2232 ret = -ENOMEM; ··· 2600 2262 kfree(priv->int_slots); 2601 2263 free_atl_slots: 2602 2264 kfree(priv->atl_slots); 2603 - free_mem_pool: 2604 - kfree(priv->memory_pool); 2605 2265 put_hcd: 2606 2266 usb_put_hcd(hcd); 2607 2267 return ret; ··· 2614 2278 usb_put_hcd(priv->hcd); 2615 2279 kfree(priv->atl_slots); 2616 2280 kfree(priv->int_slots); 2617 - kfree(priv->memory_pool); 2618 2281 }
+4 -2
drivers/usb/isp1760/isp1760-hcd.h
··· 19 19 }; 20 20 21 21 /* chip memory management */ 22 + #define ISP176x_BLOCK_MAX (32 + 20 + 4) 22 23 #define ISP176x_BLOCK_NUM 3 23 24 24 25 struct isp1760_memory_layout { 25 26 unsigned int blocks[ISP176x_BLOCK_NUM]; 26 27 unsigned int blocks_size[ISP176x_BLOCK_NUM]; 27 28 28 - unsigned int ptd_num; 29 + unsigned int slot_num; 29 30 unsigned int payload_blocks; 30 31 unsigned int payload_area_size; 31 32 }; ··· 52 51 struct regmap *regs; 53 52 struct regmap_field *fields[HC_FIELD_MAX]; 54 53 54 + bool is_isp1763; 55 55 const struct isp1760_memory_layout *memory_layout; 56 56 57 57 spinlock_t lock; ··· 60 58 int atl_done_map; 61 59 struct isp1760_slotinfo *int_slots; 62 60 int int_done_map; 63 - struct isp1760_memory_chunk *memory_pool; 61 + struct isp1760_memory_chunk memory_pool[ISP176x_BLOCK_MAX]; 64 62 struct list_head qh_list[QH_END]; 65 63 66 64 /* periodic schedule support */
+11 -1
drivers/usb/isp1760/isp1760-if.c
··· 7 7 * - PDEV (generic platform device centralized driver model) 8 8 * 9 9 * (c) 2007 Sebastian Siewior <bigeasy@linutronix.de> 10 + * Copyright 2021 Linaro, Rui Miguel Silva <rui.silva@linaro.org> 10 11 * 11 12 */ 12 13 ··· 210 209 if (of_device_is_compatible(dp, "nxp,usb-isp1761")) 211 210 devflags |= ISP1760_FLAG_ISP1761; 212 211 213 - /* Some systems wire up only 16 of the 32 data lines */ 212 + if (of_device_is_compatible(dp, "nxp,usb-isp1763")) 213 + devflags |= ISP1760_FLAG_ISP1763; 214 + 215 + /* 216 + * Some systems wire up only 8 of 16 data lines or 217 + * 16 of the 32 data lines 218 + */ 214 219 of_property_read_u32(dp, "bus-width", &bus_width); 215 220 if (bus_width == 16) 216 221 devflags |= ISP1760_FLAG_BUS_WIDTH_16; 222 + else if (bus_width == 8) 223 + devflags |= ISP1760_FLAG_BUS_WIDTH_8; 217 224 218 225 if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) 219 226 devflags |= ISP1760_FLAG_PERIPHERAL_EN; ··· 259 250 static const struct of_device_id isp1760_of_match[] = { 260 251 { .compatible = "nxp,usb-isp1760", }, 261 252 { .compatible = "nxp,usb-isp1761", }, 253 + { .compatible = "nxp,usb-isp1763", }, 262 254 { }, 263 255 }; 264 256 MODULE_DEVICE_TABLE(of, isp1760_of_match);
+77 -18
drivers/usb/isp1760/isp1760-regs.h
··· 2 2 /* 3 3 * Driver for the NXP ISP1760 chip 4 4 * 5 + * Copyright 2021 Linaro, Rui Miguel Silva 5 6 * Copyright 2014 Laurent Pinchart 6 7 * Copyright 2007 Sebastian Siewior 7 8 * 8 9 * Contacts: 9 10 * Sebastian Siewior <bigeasy@linutronix.de> 10 11 * Laurent Pinchart <laurent.pinchart@ideasonboard.com> 12 + * Rui Miguel Silva <rui.silva@linaro.org> 11 13 */ 12 14 13 15 #ifndef _ISP176x_REGS_H_ ··· 19 17 * Host Controller 20 18 */ 21 19 20 + /* ISP1760/31 */ 22 21 /* EHCI capability registers */ 23 - #define ISP176x_HC_CAPLENGTH 0x000 24 22 #define ISP176x_HC_VERSION 0x002 25 23 #define ISP176x_HC_HCSPARAMS 0x004 26 24 #define ISP176x_HC_HCCPARAMS 0x008 ··· 61 59 #define ISP176x_HC_INT_IRQ_MASK_AND 0x328 62 60 #define ISP176x_HC_ATL_IRQ_MASK_AND 0x32c 63 61 62 + #define ISP176x_HC_OTG_CTRL_SET 0x374 63 + #define ISP176x_HC_OTG_CTRL_CLEAR 0x376 64 + 64 65 enum isp176x_host_controller_fields { 66 + /* HC_PORTSC1 */ 67 + PORT_OWNER, PORT_POWER, PORT_LSTATUS, PORT_RESET, PORT_SUSPEND, 68 + PORT_RESUME, PORT_PE, PORT_CSC, PORT_CONNECT, 65 69 /* HC_HCSPARAMS */ 66 70 HCS_PPC, HCS_N_PORTS, 67 71 /* HC_HCCPARAMS */ ··· 80 72 HC_FRINDEX, 81 73 /* HC_CONFIGFLAG */ 82 74 FLAG_CF, 83 - /* HC_PORTSC1 */ 84 - PORT_OWNER, PORT_POWER, PORT_LSTATUS, PORT_RESET, PORT_SUSPEND, 85 - PORT_RESUME, PORT_PE, PORT_CSC, PORT_CONNECT, 75 + /* ISO/INT/ATL PTD */ 76 + HC_ISO_PTD_DONEMAP, HC_ISO_PTD_SKIPMAP, HC_ISO_PTD_LASTPTD, 77 + HC_INT_PTD_DONEMAP, HC_INT_PTD_SKIPMAP, HC_INT_PTD_LASTPTD, 78 + HC_ATL_PTD_DONEMAP, HC_ATL_PTD_SKIPMAP, HC_ATL_PTD_LASTPTD, 86 79 /* HC_HW_MODE_CTRL */ 87 80 ALL_ATX_RESET, HW_ANA_DIGI_OC, HW_DEV_DMA, HW_COMN_IRQ, HW_COMN_DMA, 88 81 HW_DATA_BUS_WIDTH, HW_DACK_POL_HIGH, HW_DREQ_POL_HIGH, HW_INTR_HIGH_ACT, 89 - HW_INTR_EDGE_TRIG, HW_GLOBAL_INTR_EN, 82 + HW_INTF_LOCK, HW_INTR_EDGE_TRIG, HW_GLOBAL_INTR_EN, 83 + /* HC_CHIP_ID */ 84 + HC_CHIP_ID_HIGH, HC_CHIP_ID_LOW, HC_CHIP_REV, 85 + /* HC_SCRATCH */ 86 + HC_SCRATCH, 90 87 /* HC_RESET */ 91 - SW_RESET_RESET_HC, SW_RESET_RESET_ALL, 88 + SW_RESET_RESET_ATX, SW_RESET_RESET_HC, SW_RESET_RESET_ALL, 92 89 /* HC_BUFFER_STATUS */ 93 - INT_BUF_FILL, ATL_BUF_FILL, 90 + ISO_BUF_FILL, INT_BUF_FILL, ATL_BUF_FILL, 94 91 /* HC_MEMORY */ 95 92 MEM_BANK_SEL, MEM_START_ADDR, 93 + /* HC_DATA */ 94 + HC_DATA, 95 + /* HC_INTERRUPT */ 96 + HC_INTERRUPT, 96 97 /* HC_INTERRUPT_ENABLE */ 97 - HC_INT_ENABLE, 98 + HC_INT_IRQ_ENABLE, HC_ATL_IRQ_ENABLE, 99 + /* INTERRUPT MASKS */ 100 + HC_ISO_IRQ_MASK_OR, HC_INT_IRQ_MASK_OR, HC_ATL_IRQ_MASK_OR, 101 + HC_ISO_IRQ_MASK_AND, HC_INT_IRQ_MASK_AND, HC_ATL_IRQ_MASK_AND, 102 + /* HW_OTG_CTRL_SET */ 103 + HW_OTG_DISABLE, HW_SW_SEL_HC_DC, HW_VBUS_DRV, HW_SEL_CP_EXT, 104 + HW_DM_PULLDOWN, HW_DP_PULLDOWN, HW_DP_PULLUP, HW_HC_2_DIS, 105 + /* HW_OTG_CTRL_CLR */ 106 + HW_OTG_DISABLE_CLEAR, HW_SW_SEL_HC_DC_CLEAR, HW_VBUS_DRV_CLEAR, 107 + HW_SEL_CP_EXT_CLEAR, HW_DM_PULLDOWN_CLEAR, HW_DP_PULLDOWN_CLEAR, 108 + HW_DP_PULLUP_CLEAR, HW_HC_2_DIS_CLEAR, 98 109 /* Last element */ 99 110 HC_FIELD_MAX, 100 111 }; 112 + 113 + /* ISP1763 */ 114 + /* EHCI operational registers */ 115 + #define ISP1763_HC_USBCMD 0x8c 116 + #define ISP1763_HC_USBSTS 0x90 117 + #define ISP1763_HC_FRINDEX 0x98 118 + 119 + #define ISP1763_HC_CONFIGFLAG 0x9c 120 + #define ISP1763_HC_PORTSC1 0xa0 121 + 122 + #define ISP1763_HC_ISO_PTD_DONEMAP 0xa4 123 + #define ISP1763_HC_ISO_PTD_SKIPMAP 0xa6 124 + #define ISP1763_HC_ISO_PTD_LASTPTD 0xa8 125 + #define ISP1763_HC_INT_PTD_DONEMAP 0xaa 126 + #define ISP1763_HC_INT_PTD_SKIPMAP 0xac 127 + #define ISP1763_HC_INT_PTD_LASTPTD 0xae 128 + #define ISP1763_HC_ATL_PTD_DONEMAP 0xb0 129 + #define ISP1763_HC_ATL_PTD_SKIPMAP 0xb2 130 + #define ISP1763_HC_ATL_PTD_LASTPTD 0xb4 131 + 132 + /* Configuration Register */ 133 + #define ISP1763_HC_HW_MODE_CTRL 0xb6 134 + #define ISP1763_HC_CHIP_REV 0x70 135 + #define ISP1763_HC_CHIP_ID 0x72 136 + #define ISP1763_HC_SCRATCH 0x78 137 + #define ISP1763_HC_RESET 0xb8 138 + #define ISP1763_HC_BUFFER_STATUS 0xba 139 + #define ISP1763_HC_MEMORY 0xc4 140 + #define ISP1763_HC_DATA 0xc6 141 + 142 + /* Interrupt Register */ 143 + #define ISP1763_HC_INTERRUPT 0xd4 144 + #define ISP1763_HC_INTERRUPT_ENABLE 0xd6 145 + #define ISP1763_HC_ISO_IRQ_MASK_OR 0xd8 146 + #define ISP1763_HC_INT_IRQ_MASK_OR 0xda 147 + #define ISP1763_HC_ATL_IRQ_MASK_OR 0xdc 148 + #define ISP1763_HC_ISO_IRQ_MASK_AND 0xde 149 + #define ISP1763_HC_INT_IRQ_MASK_AND 0xe0 150 + #define ISP1763_HC_ATL_IRQ_MASK_AND 0xe2 151 + 152 + #define ISP1763_HC_OTG_CTRL_SET 0xe4 153 + #define ISP1763_HC_OTG_CTRL_CLEAR 0xe6 101 154 102 155 /* ----------------------------------------------------------------------------- 103 156 * Peripheral Controller ··· 200 131 201 132 #define ISP176x_DC_CTRLFUNC 0x0228 202 133 #define ISP176x_DC_EPINDEX 0x022c 203 - 204 - #define ISP1761_DC_OTG_CTRL_SET 0x374 205 - #define ISP1761_DC_OTG_CTRL_CLEAR 0x376 206 134 207 135 /* DMA Registers */ 208 136 #define ISP176x_DC_DMACMD 0x0230 ··· 243 177 DC_EPENABLE, DC_ENDPTYP, 244 178 /* DC_FRAMENUM */ 245 179 DC_FRAMENUM, DC_UFRAMENUM, 246 - /* HW_OTG_CTRL_SET */ 247 - HW_OTG_DISABLE, HW_SW_SEL_HC_DC, HW_VBUS_DRV, HW_SEL_CP_EXT, 248 - HW_DM_PULLDOWN, HW_DP_PULLDOWN, HW_DP_PULLUP, 249 - /* HW_OTG_CTRL_CLR */ 250 - HW_OTG_DISABLE_CLEAR, HW_SW_SEL_HC_DC_CLEAR, HW_VBUS_DRV_CLEAR, 251 - HW_SEL_CP_EXT_CLEAR, HW_DM_PULLDOWN_CLEAR, HW_DP_PULLDOWN_CLEAR, 252 - HW_DP_PULLUP_CLEAR, 253 180 /* Last element */ 254 181 DC_FIELD_MAX, 255 182 };
+2
drivers/usb/isp1760/isp1760-udc.c
··· 2 2 /* 3 3 * Driver for the NXP ISP1761 device controller 4 4 * 5 + * Copyright 2021 Linaro, Rui Miguel Silva 5 6 * Copyright 2014 Ideas on Board Oy 6 7 * 7 8 * Contacts: 8 9 * Laurent Pinchart <laurent.pinchart@ideasonboard.com> 10 + * Rui Miguel Silva <rui.silva@linaro.org> 9 11 */ 10 12 11 13 #include <linux/interrupt.h>
+2
drivers/usb/isp1760/isp1760-udc.h
··· 2 2 /* 3 3 * Driver for the NXP ISP1761 device controller 4 4 * 5 + * Copyright 2021 Linaro, Rui Miguel Silva 5 6 * Copyright 2014 Ideas on Board Oy 6 7 * 7 8 * Contacts: 8 9 * Laurent Pinchart <laurent.pinchart@ideasonboard.com> 10 + * Rui Miguel Silva <rui.silva@linaro.org> 9 11 */ 10 12 11 13 #ifndef _ISP1760_UDC_H_