Lines Matching +full:isp +full:- +full:0

1 // SPDX-License-Identifier: GPL-2.0
24 #include "isp1760-core.h"
25 #include "isp1760-hcd.h"
26 #include "isp1760-regs.h"
27 #include "isp1760-udc.h"
29 static int isp1760_init_core(struct isp1760_device *isp) in isp1760_init_core() argument
31 struct isp1760_hcd *hcd = &isp->hcd; in isp1760_init_core()
32 struct isp1760_udc *udc = &isp->udc; in isp1760_init_core()
35 /* Low-level chip reset */ in isp1760_init_core()
36 if (isp->rst_gpio) { in isp1760_init_core()
37 gpiod_set_value_cansleep(isp->rst_gpio, 1); in isp1760_init_core()
39 gpiod_set_value_cansleep(isp->rst_gpio, 0); in isp1760_init_core()
46 isp1760_field_set(hcd->fields, SW_RESET_RESET_ALL); in isp1760_init_core()
49 /* Setup HW Mode Control: This assumes a level active-low interrupt */ in isp1760_init_core()
50 if ((isp->devflags & ISP1760_FLAG_ANALOG_OC) && hcd->is_isp1763) { in isp1760_init_core()
51 dev_err(isp->dev, "isp1763 analog overcurrent not available\n"); in isp1760_init_core()
52 return -EINVAL; in isp1760_init_core()
55 if (isp->devflags & ISP1760_FLAG_BUS_WIDTH_16) in isp1760_init_core()
56 isp1760_field_clear(hcd->fields, HW_DATA_BUS_WIDTH); in isp1760_init_core()
57 if (isp->devflags & ISP1760_FLAG_BUS_WIDTH_8) in isp1760_init_core()
58 isp1760_field_set(hcd->fields, HW_DATA_BUS_WIDTH); in isp1760_init_core()
59 if (isp->devflags & ISP1760_FLAG_ANALOG_OC) in isp1760_init_core()
60 isp1760_field_set(hcd->fields, HW_ANA_DIGI_OC); in isp1760_init_core()
61 if (isp->devflags & ISP1760_FLAG_DACK_POL_HIGH) in isp1760_init_core()
62 isp1760_field_set(hcd->fields, HW_DACK_POL_HIGH); in isp1760_init_core()
63 if (isp->devflags & ISP1760_FLAG_DREQ_POL_HIGH) in isp1760_init_core()
64 isp1760_field_set(hcd->fields, HW_DREQ_POL_HIGH); in isp1760_init_core()
65 if (isp->devflags & ISP1760_FLAG_INTR_POL_HIGH) in isp1760_init_core()
66 isp1760_field_set(hcd->fields, HW_INTR_HIGH_ACT); in isp1760_init_core()
67 if (isp->devflags & ISP1760_FLAG_INTR_EDGE_TRIG) in isp1760_init_core()
68 isp1760_field_set(hcd->fields, HW_INTR_EDGE_TRIG); in isp1760_init_core()
76 if (isp->devflags & ISP1760_FLAG_ISP1761) { in isp1760_init_core()
77 isp1760_reg_write(udc->regs, ISP176x_DC_MODE, 0); in isp1760_init_core()
78 isp1760_field_set(hcd->fields, HW_COMN_IRQ); in isp1760_init_core()
87 if (isp->devflags & ISP1760_FLAG_ISP1761) { in isp1760_init_core()
88 if (isp->devflags & ISP1760_FLAG_PERIPHERAL_EN) { in isp1760_init_core()
97 isp1760_reg_write(hcd->regs, ISP176x_HC_OTG_CTRL, otg_ctrl); in isp1760_init_core()
100 dev_info(isp->dev, "%s bus width: %u, oc: %s\n", in isp1760_init_core()
101 hcd->is_isp1763 ? "isp1763" : "isp1760", in isp1760_init_core()
102 isp->devflags & ISP1760_FLAG_BUS_WIDTH_8 ? 8 : in isp1760_init_core()
103 isp->devflags & ISP1760_FLAG_BUS_WIDTH_16 ? 16 : 32, in isp1760_init_core()
104 hcd->is_isp1763 ? "not available" : in isp1760_init_core()
105 isp->devflags & ISP1760_FLAG_ANALOG_OC ? "analog" : "digital"); in isp1760_init_core()
107 return 0; in isp1760_init_core()
110 void isp1760_set_pullup(struct isp1760_device *isp, bool enable) in isp1760_set_pullup() argument
112 struct isp1760_udc *udc = &isp->udc; in isp1760_set_pullup()
115 isp1760_field_set(udc->fields, HW_DP_PULLUP); in isp1760_set_pullup()
117 isp1760_field_set(udc->fields, HW_DP_PULLUP_CLEAR); in isp1760_set_pullup()
124 * - 32 blocks @ 256 bytes
125 * - 20 blocks @ 1024 bytes
126 * - 4 blocks @ 8192 bytes
129 .blocks[0] = 32,
130 .blocks_size[0] = 256,
138 .payload_area_size = 0xf000,
145 * - 8 blocks @ 256 bytes
146 * - 2 blocks @ 1024 bytes
147 * - 4 blocks @ 4096 bytes
150 .blocks[0] = 8,
151 .blocks_size[0] = 256,
159 .payload_area_size = 0x5000,
174 .name = "isp1760-hc",
185 [HCS_N_PORTS] = REG_FIELD(ISP176x_HC_HCSPARAMS, 0, 3),
190 [CMD_RUN] = REG_FIELD(ISP176x_HC_USBCMD, 0, 0),
192 [HC_FRINDEX] = REG_FIELD(ISP176x_HC_FRINDEX, 0, 13),
193 [FLAG_CF] = REG_FIELD(ISP176x_HC_CONFIGFLAG, 0, 0),
194 [HC_ISO_PTD_DONEMAP] = REG_FIELD(ISP176x_HC_ISO_PTD_DONEMAP, 0, 31),
195 [HC_ISO_PTD_SKIPMAP] = REG_FIELD(ISP176x_HC_ISO_PTD_SKIPMAP, 0, 31),
196 [HC_ISO_PTD_LASTPTD] = REG_FIELD(ISP176x_HC_ISO_PTD_LASTPTD, 0, 31),
197 [HC_INT_PTD_DONEMAP] = REG_FIELD(ISP176x_HC_INT_PTD_DONEMAP, 0, 31),
198 [HC_INT_PTD_SKIPMAP] = REG_FIELD(ISP176x_HC_INT_PTD_SKIPMAP, 0, 31),
199 [HC_INT_PTD_LASTPTD] = REG_FIELD(ISP176x_HC_INT_PTD_LASTPTD, 0, 31),
200 [HC_ATL_PTD_DONEMAP] = REG_FIELD(ISP176x_HC_ATL_PTD_DONEMAP, 0, 31),
201 [HC_ATL_PTD_SKIPMAP] = REG_FIELD(ISP176x_HC_ATL_PTD_SKIPMAP, 0, 31),
202 [HC_ATL_PTD_LASTPTD] = REG_FIELD(ISP176x_HC_ATL_PTD_LASTPTD, 0, 31),
211 [PORT_CONNECT] = REG_FIELD(ISP176x_HC_PORTSC1, 0, 0),
220 [HW_GLOBAL_INTR_EN] = REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 0, 0),
223 [HC_CHIP_ID_LOW] = REG_FIELD(ISP176x_HC_CHIP_ID, 0, 7),
224 [HC_SCRATCH] = REG_FIELD(ISP176x_HC_SCRATCH, 0, 31),
225 [SW_RESET_RESET_ALL] = REG_FIELD(ISP176x_HC_RESET, 0, 0),
228 [ATL_BUF_FILL] = REG_FIELD(ISP176x_HC_BUFFER_STATUS, 0, 0),
230 [MEM_START_ADDR] = REG_FIELD(ISP176x_HC_MEMORY, 0, 15),
231 [HC_INTERRUPT] = REG_FIELD(ISP176x_HC_INTERRUPT, 0, 9),
234 [HC_ISO_IRQ_MASK_OR] = REG_FIELD(ISP176x_HC_ISO_IRQ_MASK_OR, 0, 31),
235 [HC_INT_IRQ_MASK_OR] = REG_FIELD(ISP176x_HC_INT_IRQ_MASK_OR, 0, 31),
236 [HC_ATL_IRQ_MASK_OR] = REG_FIELD(ISP176x_HC_ATL_IRQ_MASK_OR, 0, 31),
237 [HC_ISO_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_ISO_IRQ_MASK_AND, 0, 31),
238 [HC_INT_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_INT_IRQ_MASK_AND, 0, 31),
239 [HC_ATL_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_ATL_IRQ_MASK_AND, 0, 31),
253 [HW_DP_PULLUP] = REG_FIELD(ISP176x_HC_OTG_CTRL, 0, 0),
261 [CMD_RUN] = REG_FIELD(ISP1763_HC_USBCMD, 0, 0),
263 [HC_FRINDEX] = REG_FIELD(ISP1763_HC_FRINDEX, 0, 13),
264 [FLAG_CF] = REG_FIELD(ISP1763_HC_CONFIGFLAG, 0, 0),
265 [HC_ISO_PTD_DONEMAP] = REG_FIELD(ISP1763_HC_ISO_PTD_DONEMAP, 0, 15),
266 [HC_ISO_PTD_SKIPMAP] = REG_FIELD(ISP1763_HC_ISO_PTD_SKIPMAP, 0, 15),
267 [HC_ISO_PTD_LASTPTD] = REG_FIELD(ISP1763_HC_ISO_PTD_LASTPTD, 0, 15),
268 [HC_INT_PTD_DONEMAP] = REG_FIELD(ISP1763_HC_INT_PTD_DONEMAP, 0, 15),
269 [HC_INT_PTD_SKIPMAP] = REG_FIELD(ISP1763_HC_INT_PTD_SKIPMAP, 0, 15),
270 [HC_INT_PTD_LASTPTD] = REG_FIELD(ISP1763_HC_INT_PTD_LASTPTD, 0, 15),
271 [HC_ATL_PTD_DONEMAP] = REG_FIELD(ISP1763_HC_ATL_PTD_DONEMAP, 0, 15),
272 [HC_ATL_PTD_SKIPMAP] = REG_FIELD(ISP1763_HC_ATL_PTD_SKIPMAP, 0, 15),
273 [HC_ATL_PTD_LASTPTD] = REG_FIELD(ISP1763_HC_ATL_PTD_LASTPTD, 0, 15),
282 [PORT_CONNECT] = REG_FIELD(ISP1763_HC_PORTSC1, 0, 0),
289 [HW_GLOBAL_INTR_EN] = REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 0, 0),
291 [SW_RESET_RESET_ALL] = REG_FIELD(ISP1763_HC_RESET, 0, 0),
292 [HC_CHIP_ID_HIGH] = REG_FIELD(ISP1763_HC_CHIP_ID, 0, 15),
294 [HC_CHIP_REV] = REG_FIELD(ISP1763_HC_CHIP_REV, 0, 7),
295 [HC_SCRATCH] = REG_FIELD(ISP1763_HC_SCRATCH, 0, 15),
298 [ATL_BUF_FILL] = REG_FIELD(ISP1763_HC_BUFFER_STATUS, 0, 0),
299 [MEM_START_ADDR] = REG_FIELD(ISP1763_HC_MEMORY, 0, 15),
300 [HC_DATA] = REG_FIELD(ISP1763_HC_DATA, 0, 15),
301 [HC_INTERRUPT] = REG_FIELD(ISP1763_HC_INTERRUPT, 0, 10),
304 [HC_ISO_IRQ_MASK_OR] = REG_FIELD(ISP1763_HC_ISO_IRQ_MASK_OR, 0, 15),
305 [HC_INT_IRQ_MASK_OR] = REG_FIELD(ISP1763_HC_INT_IRQ_MASK_OR, 0, 15),
306 [HC_ATL_IRQ_MASK_OR] = REG_FIELD(ISP1763_HC_ATL_IRQ_MASK_OR, 0, 15),
307 [HC_ISO_IRQ_MASK_AND] = REG_FIELD(ISP1763_HC_ISO_IRQ_MASK_AND, 0, 15),
308 [HC_INT_IRQ_MASK_AND] = REG_FIELD(ISP1763_HC_INT_IRQ_MASK_AND, 0, 15),
309 [HC_ATL_IRQ_MASK_AND] = REG_FIELD(ISP1763_HC_ATL_IRQ_MASK_AND, 0, 15),
317 [HW_DP_PULLUP] = REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 0, 0),
325 [HW_DP_PULLUP_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 0, 0),
342 .name = "isp1763-hc",
362 .name = "isp1761-dc",
373 [DC_DEVADDR] = REG_FIELD(ISP176x_DC_ADDRESS, 0, 6),
380 [DC_INTPOL] = REG_FIELD(ISP176x_DC_INTCONF, 0, 0),
394 [DC_IEBRST] = REG_FIELD(ISP176x_DC_INTENABLE, 0, 0),
397 [DC_EPDIR] = REG_FIELD(ISP176x_DC_EPINDEX, 0, 0),
402 [DC_STALL] = REG_FIELD(ISP176x_DC_CTRLFUNC, 0, 0),
403 [DC_BUFLEN] = REG_FIELD(ISP176x_DC_BUFLEN, 0, 15),
404 [DC_FFOSZ] = REG_FIELD(ISP176x_DC_EPMAXPKTSZ, 0, 10),
406 [DC_ENDPTYP] = REG_FIELD(ISP176x_DC_EPTYPE, 0, 1),
408 [DC_FRAMENUM] = REG_FIELD(ISP176x_DC_FRAMENUM, 0, 10),
410 [DC_CHIP_ID_LOW] = REG_FIELD(ISP176x_DC_CHIPID, 0, 15),
411 [DC_SCRATCH] = REG_FIELD(ISP176x_DC_SCRATCH, 0, 15),
428 [DC_DEVADDR] = REG_FIELD(ISP1763_DC_ADDRESS, 0, 6),
435 [DC_INTPOL] = REG_FIELD(ISP1763_DC_INTCONF, 0, 0),
449 [DC_IEBRST] = REG_FIELD(ISP1763_DC_INTENABLE, 0, 0),
452 [DC_EPDIR] = REG_FIELD(ISP1763_DC_EPINDEX, 0, 0),
457 [DC_STALL] = REG_FIELD(ISP1763_DC_CTRLFUNC, 0, 0),
458 [DC_BUFLEN] = REG_FIELD(ISP1763_DC_BUFLEN, 0, 15),
459 [DC_FFOSZ] = REG_FIELD(ISP1763_DC_EPMAXPKTSZ, 0, 10),
461 [DC_ENDPTYP] = REG_FIELD(ISP1763_DC_EPTYPE, 0, 1),
463 [DC_FRAMENUM] = REG_FIELD(ISP1763_DC_FRAMENUM, 0, 10),
464 [DC_CHIP_ID_HIGH] = REG_FIELD(ISP1763_DC_CHIPID_HIGH, 0, 15),
465 [DC_CHIP_ID_LOW] = REG_FIELD(ISP1763_DC_CHIPID_LOW, 0, 15),
466 [DC_SCRATCH] = REG_FIELD(ISP1763_DC_SCRATCH, 0, 15),
472 .name = "isp1763-dc",
488 struct isp1760_device *isp; in isp1760_register() local
505 return -ENODEV; in isp1760_register()
507 isp = devm_kzalloc(dev, sizeof(*isp), GFP_KERNEL); in isp1760_register()
508 if (!isp) in isp1760_register()
509 return -ENOMEM; in isp1760_register()
511 isp->dev = dev; in isp1760_register()
512 isp->devflags = devflags; in isp1760_register()
513 hcd = &isp->hcd; in isp1760_register()
514 udc = &isp->udc; in isp1760_register()
516 hcd->is_isp1763 = !!(devflags & ISP1760_FLAG_ISP1763); in isp1760_register()
517 udc->is_isp1763 = !!(devflags & ISP1760_FLAG_ISP1763); in isp1760_register()
519 if (!hcd->is_isp1763 && (devflags & ISP1760_FLAG_BUS_WIDTH_8)) { in isp1760_register()
521 return -EINVAL; in isp1760_register()
524 if (hcd->is_isp1763) { in isp1760_register()
526 hc_reg_fields = &isp1763_hc_reg_fields[0]; in isp1760_register()
528 dc_reg_fields = &isp1763_dc_reg_fields[0]; in isp1760_register()
531 hc_reg_fields = &isp1760_hc_reg_fields[0]; in isp1760_register()
533 dc_reg_fields = &isp1761_dc_reg_fields[0]; in isp1760_register()
536 isp->rst_gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH); in isp1760_register()
537 if (IS_ERR(isp->rst_gpio)) in isp1760_register()
538 return PTR_ERR(isp->rst_gpio); in isp1760_register()
540 hcd->base = devm_ioremap_resource(dev, mem); in isp1760_register()
541 if (IS_ERR(hcd->base)) in isp1760_register()
542 return PTR_ERR(hcd->base); in isp1760_register()
544 hcd->regs = devm_regmap_init_mmio(dev, hcd->base, hc_regmap); in isp1760_register()
545 if (IS_ERR(hcd->regs)) in isp1760_register()
546 return PTR_ERR(hcd->regs); in isp1760_register()
548 for (i = 0; i < HC_FIELD_MAX; i++) { in isp1760_register()
549 f = devm_regmap_field_alloc(dev, hcd->regs, hc_reg_fields[i]); in isp1760_register()
553 hcd->fields[i] = f; in isp1760_register()
556 udc->regs = devm_regmap_init_mmio(dev, hcd->base, dc_regmap); in isp1760_register()
557 if (IS_ERR(udc->regs)) in isp1760_register()
558 return PTR_ERR(udc->regs); in isp1760_register()
560 for (i = 0; i < DC_FIELD_MAX; i++) { in isp1760_register()
561 f = devm_regmap_field_alloc(dev, udc->regs, dc_reg_fields[i]); in isp1760_register()
565 udc->fields[i] = f; in isp1760_register()
568 if (hcd->is_isp1763) in isp1760_register()
569 hcd->memory_layout = &isp1763_memory_conf; in isp1760_register()
571 hcd->memory_layout = &isp176x_memory_conf; in isp1760_register()
573 ret = isp1760_init_core(isp); in isp1760_register()
574 if (ret < 0) in isp1760_register()
580 if (ret < 0) in isp1760_register()
585 ret = isp1760_udc_register(isp, irq, irqflags); in isp1760_register()
586 if (ret < 0) { in isp1760_register()
592 dev_set_drvdata(dev, isp); in isp1760_register()
594 return 0; in isp1760_register()
599 struct isp1760_device *isp = dev_get_drvdata(dev); in isp1760_unregister() local
601 isp1760_udc_unregister(isp); in isp1760_unregister()
602 isp1760_hcd_unregister(&isp->hcd); in isp1760_unregister()
605 MODULE_DESCRIPTION("Driver for the ISP1760 USB-controller from NXP");