Lines Matching refs:whc
30 static void whc_hw_reset(struct whc *whc) in whc_hw_reset() argument
32 le_writel(WUSBCMD_WHCRESET, whc->base + WUSBCMD); in whc_hw_reset()
33 whci_wait_for(&whc->umc->dev, whc->base + WUSBCMD, WUSBCMD_WHCRESET, 0, in whc_hw_reset()
37 static void whc_hw_init_di_buf(struct whc *whc) in whc_hw_init_di_buf() argument
42 for (d = 0; d < whc->n_devices; d++) in whc_hw_init_di_buf()
43 whc->di_buf[d].addr_sec_info = WHC_DI_DISABLE; in whc_hw_init_di_buf()
45 le_writeq(whc->di_buf_dma, whc->base + WUSBDEVICEINFOADDR); in whc_hw_init_di_buf()
48 static void whc_hw_init_dn_buf(struct whc *whc) in whc_hw_init_dn_buf() argument
52 memset(whc->dn_buf, 0, 4096); in whc_hw_init_dn_buf()
54 le_writeq(whc->dn_buf_dma, whc->base + WUSBDNTSBUFADDR); in whc_hw_init_dn_buf()
57 int whc_init(struct whc *whc) in whc_init() argument
63 spin_lock_init(&whc->lock); in whc_init()
64 mutex_init(&whc->mutex); in whc_init()
65 init_waitqueue_head(&whc->cmd_wq); in whc_init()
66 init_waitqueue_head(&whc->async_list_wq); in whc_init()
67 init_waitqueue_head(&whc->periodic_list_wq); in whc_init()
68 whc->workqueue = create_singlethread_workqueue(dev_name(&whc->umc->dev)); in whc_init()
69 if (whc->workqueue == NULL) { in whc_init()
73 INIT_WORK(&whc->dn_work, whc_dn_work); in whc_init()
75 INIT_WORK(&whc->async_work, scan_async_work); in whc_init()
76 INIT_LIST_HEAD(&whc->async_list); in whc_init()
77 INIT_LIST_HEAD(&whc->async_removed_list); in whc_init()
79 INIT_WORK(&whc->periodic_work, scan_periodic_work); in whc_init()
81 INIT_LIST_HEAD(&whc->periodic_list[i]); in whc_init()
82 INIT_LIST_HEAD(&whc->periodic_removed_list); in whc_init()
85 start = whc->umc->resource.start; in whc_init()
86 len = whc->umc->resource.end - start + 1; in whc_init()
88 dev_err(&whc->umc->dev, "can't request HC region\n"); in whc_init()
92 whc->base_phys = start; in whc_init()
93 whc->base = ioremap(start, len); in whc_init()
94 if (!whc->base) { in whc_init()
95 dev_err(&whc->umc->dev, "ioremap\n"); in whc_init()
100 whc_hw_reset(whc); in whc_init()
103 whcsparams = le_readl(whc->base + WHCSPARAMS); in whc_init()
104 whc->n_devices = WHCSPARAMS_TO_N_DEVICES(whcsparams); in whc_init()
105 whc->n_keys = WHCSPARAMS_TO_N_KEYS(whcsparams); in whc_init()
106 whc->n_mmc_ies = WHCSPARAMS_TO_N_MMC_IES(whcsparams); in whc_init()
108 dev_dbg(&whc->umc->dev, "N_DEVICES = %d, N_KEYS = %d, N_MMC_IES = %d\n", in whc_init()
109 whc->n_devices, whc->n_keys, whc->n_mmc_ies); in whc_init()
111 whc->qset_pool = dma_pool_create("qset", &whc->umc->dev, in whc_init()
113 if (whc->qset_pool == NULL) { in whc_init()
118 ret = asl_init(whc); in whc_init()
121 ret = pzl_init(whc); in whc_init()
129 whc->gen_cmd_buf = dma_alloc_coherent(&whc->umc->dev, WHC_GEN_CMD_DATA_LEN, in whc_init()
130 &whc->gen_cmd_buf_dma, GFP_KERNEL); in whc_init()
131 if (whc->gen_cmd_buf == NULL) { in whc_init()
136 whc->dn_buf = dma_alloc_coherent(&whc->umc->dev, in whc_init()
138 &whc->dn_buf_dma, GFP_KERNEL); in whc_init()
139 if (!whc->dn_buf) { in whc_init()
143 whc_hw_init_dn_buf(whc); in whc_init()
145 whc->di_buf = dma_alloc_coherent(&whc->umc->dev, in whc_init()
146 sizeof(struct di_buf_entry) * whc->n_devices, in whc_init()
147 &whc->di_buf_dma, GFP_KERNEL); in whc_init()
148 if (!whc->di_buf) { in whc_init()
152 whc_hw_init_di_buf(whc); in whc_init()
157 whc_clean_up(whc); in whc_init()
161 void whc_clean_up(struct whc *whc) in whc_clean_up() argument
165 if (whc->di_buf) in whc_clean_up()
166 dma_free_coherent(&whc->umc->dev, sizeof(struct di_buf_entry) * whc->n_devices, in whc_clean_up()
167 whc->di_buf, whc->di_buf_dma); in whc_clean_up()
168 if (whc->dn_buf) in whc_clean_up()
169 dma_free_coherent(&whc->umc->dev, sizeof(struct dn_buf_entry) * WHC_N_DN_ENTRIES, in whc_clean_up()
170 whc->dn_buf, whc->dn_buf_dma); in whc_clean_up()
171 if (whc->gen_cmd_buf) in whc_clean_up()
172 dma_free_coherent(&whc->umc->dev, WHC_GEN_CMD_DATA_LEN, in whc_clean_up()
173 whc->gen_cmd_buf, whc->gen_cmd_buf_dma); in whc_clean_up()
175 pzl_clean_up(whc); in whc_clean_up()
176 asl_clean_up(whc); in whc_clean_up()
178 if (whc->qset_pool) in whc_clean_up()
179 dma_pool_destroy(whc->qset_pool); in whc_clean_up()
181 len = whc->umc->resource.end - whc->umc->resource.start + 1; in whc_clean_up()
182 if (whc->base) in whc_clean_up()
183 iounmap(whc->base); in whc_clean_up()
184 if (whc->base_phys) in whc_clean_up()
185 release_mem_region(whc->base_phys, len); in whc_clean_up()
187 if (whc->workqueue) in whc_clean_up()
188 destroy_workqueue(whc->workqueue); in whc_clean_up()