Lines Matching refs:drvdata

86 #define stm_channel_addr(drvdata, ch)	(drvdata->chs.base +	\  argument
150 static void stm_hwevent_enable_hw(struct stm_drvdata *drvdata) in stm_hwevent_enable_hw() argument
152 CS_UNLOCK(drvdata->base); in stm_hwevent_enable_hw()
154 writel_relaxed(drvdata->stmhebsr, drvdata->base + STMHEBSR); in stm_hwevent_enable_hw()
155 writel_relaxed(drvdata->stmheter, drvdata->base + STMHETER); in stm_hwevent_enable_hw()
156 writel_relaxed(drvdata->stmheer, drvdata->base + STMHEER); in stm_hwevent_enable_hw()
159 drvdata->base + STMHEMCR); in stm_hwevent_enable_hw()
161 CS_LOCK(drvdata->base); in stm_hwevent_enable_hw()
164 static void stm_port_enable_hw(struct stm_drvdata *drvdata) in stm_port_enable_hw() argument
166 CS_UNLOCK(drvdata->base); in stm_port_enable_hw()
169 drvdata->base + STMSPTRIGCSR); in stm_port_enable_hw()
170 writel_relaxed(drvdata->stmspscr, drvdata->base + STMSPSCR); in stm_port_enable_hw()
171 writel_relaxed(drvdata->stmsper, drvdata->base + STMSPER); in stm_port_enable_hw()
173 CS_LOCK(drvdata->base); in stm_port_enable_hw()
176 static void stm_enable_hw(struct stm_drvdata *drvdata) in stm_enable_hw() argument
178 if (drvdata->stmheer) in stm_enable_hw()
179 stm_hwevent_enable_hw(drvdata); in stm_enable_hw()
181 stm_port_enable_hw(drvdata); in stm_enable_hw()
183 CS_UNLOCK(drvdata->base); in stm_enable_hw()
186 writel_relaxed(0xFFF, drvdata->base + STMSYNCR); in stm_enable_hw()
187 writel_relaxed((drvdata->traceid << 16 | /* trace id */ in stm_enable_hw()
190 drvdata->base + STMTCSR); in stm_enable_hw()
192 CS_LOCK(drvdata->base); in stm_enable_hw()
199 struct stm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in stm_enable() local
204 val = local_cmpxchg(&drvdata->mode, CS_MODE_DISABLED, mode); in stm_enable()
212 spin_lock(&drvdata->spinlock); in stm_enable()
213 stm_enable_hw(drvdata); in stm_enable()
214 spin_unlock(&drvdata->spinlock); in stm_enable()
220 static void stm_hwevent_disable_hw(struct stm_drvdata *drvdata) in stm_hwevent_disable_hw() argument
222 CS_UNLOCK(drvdata->base); in stm_hwevent_disable_hw()
224 writel_relaxed(0x0, drvdata->base + STMHEMCR); in stm_hwevent_disable_hw()
225 writel_relaxed(0x0, drvdata->base + STMHEER); in stm_hwevent_disable_hw()
226 writel_relaxed(0x0, drvdata->base + STMHETER); in stm_hwevent_disable_hw()
228 CS_LOCK(drvdata->base); in stm_hwevent_disable_hw()
231 static void stm_port_disable_hw(struct stm_drvdata *drvdata) in stm_port_disable_hw() argument
233 CS_UNLOCK(drvdata->base); in stm_port_disable_hw()
235 writel_relaxed(0x0, drvdata->base + STMSPER); in stm_port_disable_hw()
236 writel_relaxed(0x0, drvdata->base + STMSPTRIGCSR); in stm_port_disable_hw()
238 CS_LOCK(drvdata->base); in stm_port_disable_hw()
241 static void stm_disable_hw(struct stm_drvdata *drvdata) in stm_disable_hw() argument
245 CS_UNLOCK(drvdata->base); in stm_disable_hw()
247 val = readl_relaxed(drvdata->base + STMTCSR); in stm_disable_hw()
249 writel_relaxed(val, drvdata->base + STMTCSR); in stm_disable_hw()
251 CS_LOCK(drvdata->base); in stm_disable_hw()
253 stm_port_disable_hw(drvdata); in stm_disable_hw()
254 if (drvdata->stmheer) in stm_disable_hw()
255 stm_hwevent_disable_hw(drvdata); in stm_disable_hw()
261 struct stm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in stm_disable() local
269 if (local_read(&drvdata->mode) == CS_MODE_SYSFS) { in stm_disable()
270 spin_lock(&drvdata->spinlock); in stm_disable()
271 stm_disable_hw(drvdata); in stm_disable()
272 spin_unlock(&drvdata->spinlock); in stm_disable()
279 local_set(&drvdata->mode, CS_MODE_DISABLED); in stm_disable()
332 struct stm_drvdata *drvdata = container_of(stm_data, in stm_generic_link() local
334 if (!drvdata || !drvdata->csdev) in stm_generic_link()
337 return coresight_enable(drvdata->csdev); in stm_generic_link()
343 struct stm_drvdata *drvdata = container_of(stm_data, in stm_generic_unlink() local
345 if (!drvdata || !drvdata->csdev) in stm_generic_unlink()
348 coresight_disable(drvdata->csdev); in stm_generic_unlink()
355 struct stm_drvdata *drvdata = container_of(stm_data, in stm_mmio_addr() local
359 addr = drvdata->chs.phys + channel * BYTES_PER_CHANNEL; in stm_mmio_addr()
374 struct stm_drvdata *drvdata = container_of(stm_data, in stm_generic_set_options() local
376 if (!(drvdata && local_read(&drvdata->mode))) in stm_generic_set_options()
379 if (channel >= drvdata->numsp) in stm_generic_set_options()
384 set_bit(channel, drvdata->chs.guaranteed); in stm_generic_set_options()
388 clear_bit(channel, drvdata->chs.guaranteed); in stm_generic_set_options()
407 struct stm_drvdata *drvdata = container_of(stm_data, in stm_generic_packet() local
411 if (!(drvdata && local_read(&drvdata->mode))) in stm_generic_packet()
414 if (channel >= drvdata->numsp) in stm_generic_packet()
417 ch_addr = stm_channel_addr(drvdata, channel); in stm_generic_packet()
421 stm_flags |= test_bit(channel, drvdata->chs.guaranteed) ? in stm_generic_packet()
424 if (size > drvdata->write_bytes) in stm_generic_packet()
425 size = drvdata->write_bytes; in stm_generic_packet()
438 stm_send(ch_addr, payload, 1, drvdata->write_bytes); in stm_generic_packet()
446 drvdata->write_bytes); in stm_generic_packet()
459 struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); in hwevent_enable_show() local
460 unsigned long val = drvdata->stmheer; in hwevent_enable_show()
469 struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); in hwevent_enable_store() local
477 drvdata->stmheer = val; in hwevent_enable_store()
479 drvdata->stmheter = val; in hwevent_enable_store()
488 struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); in hwevent_select_show() local
489 unsigned long val = drvdata->stmhebsr; in hwevent_select_show()
498 struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); in hwevent_select_store() local
506 drvdata->stmhebsr = val; in hwevent_select_store()
515 struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); in port_select_show() local
518 if (!local_read(&drvdata->mode)) { in port_select_show()
519 val = drvdata->stmspscr; in port_select_show()
521 spin_lock(&drvdata->spinlock); in port_select_show()
522 val = readl_relaxed(drvdata->base + STMSPSCR); in port_select_show()
523 spin_unlock(&drvdata->spinlock); in port_select_show()
533 struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); in port_select_store() local
541 spin_lock(&drvdata->spinlock); in port_select_store()
542 drvdata->stmspscr = val; in port_select_store()
544 if (local_read(&drvdata->mode)) { in port_select_store()
545 CS_UNLOCK(drvdata->base); in port_select_store()
547 stmsper = readl_relaxed(drvdata->base + STMSPER); in port_select_store()
548 writel_relaxed(0x0, drvdata->base + STMSPER); in port_select_store()
549 writel_relaxed(drvdata->stmspscr, drvdata->base + STMSPSCR); in port_select_store()
550 writel_relaxed(stmsper, drvdata->base + STMSPER); in port_select_store()
551 CS_LOCK(drvdata->base); in port_select_store()
553 spin_unlock(&drvdata->spinlock); in port_select_store()
562 struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); in port_enable_show() local
565 if (!local_read(&drvdata->mode)) { in port_enable_show()
566 val = drvdata->stmsper; in port_enable_show()
568 spin_lock(&drvdata->spinlock); in port_enable_show()
569 val = readl_relaxed(drvdata->base + STMSPER); in port_enable_show()
570 spin_unlock(&drvdata->spinlock); in port_enable_show()
580 struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); in port_enable_store() local
588 spin_lock(&drvdata->spinlock); in port_enable_store()
589 drvdata->stmsper = val; in port_enable_store()
591 if (local_read(&drvdata->mode)) { in port_enable_store()
592 CS_UNLOCK(drvdata->base); in port_enable_store()
593 writel_relaxed(drvdata->stmsper, drvdata->base + STMSPER); in port_enable_store()
594 CS_LOCK(drvdata->base); in port_enable_store()
596 spin_unlock(&drvdata->spinlock); in port_enable_store()
606 struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); in traceid_show() local
608 val = drvdata->traceid; in traceid_show()
739 static u32 stm_fundamental_data_size(struct stm_drvdata *drvdata) in stm_fundamental_data_size() argument
746 stmspfeat2r = readl_relaxed(drvdata->base + STMSPFEAT2R); in stm_fundamental_data_size()
756 static u32 stm_num_stimulus_port(struct stm_drvdata *drvdata) in stm_num_stimulus_port() argument
760 numsp = readl_relaxed(drvdata->base + CORESIGHT_DEVID); in stm_num_stimulus_port()
771 static void stm_init_default_data(struct stm_drvdata *drvdata) in stm_init_default_data() argument
774 drvdata->stmspscr = 0x0; in stm_init_default_data()
780 drvdata->stmsper = ~0x0; in stm_init_default_data()
783 bitmap_clear(drvdata->chs.guaranteed, 0, drvdata->numsp); in stm_init_default_data()
786 static void stm_init_generic_data(struct stm_drvdata *drvdata, in stm_init_generic_data() argument
789 drvdata->stm.name = name; in stm_init_generic_data()
795 drvdata->stm.sw_start = 1; in stm_init_generic_data()
796 drvdata->stm.sw_end = 1; in stm_init_generic_data()
797 drvdata->stm.hw_override = true; in stm_init_generic_data()
798 drvdata->stm.sw_nchannels = drvdata->numsp; in stm_init_generic_data()
799 drvdata->stm.sw_mmiosz = BYTES_PER_CHANNEL; in stm_init_generic_data()
800 drvdata->stm.packet = stm_generic_packet; in stm_init_generic_data()
801 drvdata->stm.mmio_addr = stm_mmio_addr; in stm_init_generic_data()
802 drvdata->stm.link = stm_generic_link; in stm_init_generic_data()
803 drvdata->stm.unlink = stm_generic_unlink; in stm_init_generic_data()
804 drvdata->stm.set_options = stm_generic_set_options; in stm_init_generic_data()
813 struct stm_drvdata *drvdata; in stm_probe() local
822 drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); in stm_probe()
823 if (!drvdata) in stm_probe()
826 drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */ in stm_probe()
827 if (!IS_ERR(drvdata->atclk)) { in stm_probe()
828 ret = clk_prepare_enable(drvdata->atclk); in stm_probe()
832 dev_set_drvdata(dev, drvdata); in stm_probe()
837 drvdata->base = base; in stm_probe()
843 drvdata->chs.phys = ch_res.start; in stm_probe()
848 drvdata->chs.base = base; in stm_probe()
850 drvdata->write_bytes = stm_fundamental_data_size(drvdata); in stm_probe()
853 drvdata->numsp = boot_nr_channel; in stm_probe()
855 drvdata->numsp = stm_num_stimulus_port(drvdata); in stm_probe()
857 drvdata->chs.guaranteed = devm_bitmap_zalloc(dev, drvdata->numsp, in stm_probe()
859 if (!drvdata->chs.guaranteed) in stm_probe()
862 spin_lock_init(&drvdata->spinlock); in stm_probe()
864 stm_init_default_data(drvdata); in stm_probe()
865 stm_init_generic_data(drvdata, desc.name); in stm_probe()
867 if (stm_register_device(dev, &drvdata->stm, THIS_MODULE)) { in stm_probe()
887 drvdata->csdev = coresight_register(&desc); in stm_probe()
888 if (IS_ERR(drvdata->csdev)) { in stm_probe()
889 ret = PTR_ERR(drvdata->csdev); in stm_probe()
898 drvdata->traceid = (u8)trace_id; in stm_probe()
902 dev_info(&drvdata->csdev->dev, "%s initialized\n", in stm_probe()
907 coresight_unregister(drvdata->csdev); in stm_probe()
910 stm_unregister_device(&drvdata->stm); in stm_probe()
916 struct stm_drvdata *drvdata = dev_get_drvdata(&adev->dev); in stm_remove() local
918 coresight_trace_id_put_system_id(drvdata->traceid); in stm_remove()
919 coresight_unregister(drvdata->csdev); in stm_remove()
921 stm_unregister_device(&drvdata->stm); in stm_remove()
927 struct stm_drvdata *drvdata = dev_get_drvdata(dev); in stm_runtime_suspend() local
929 if (drvdata && !IS_ERR(drvdata->atclk)) in stm_runtime_suspend()
930 clk_disable_unprepare(drvdata->atclk); in stm_runtime_suspend()
937 struct stm_drvdata *drvdata = dev_get_drvdata(dev); in stm_runtime_resume() local
939 if (drvdata && !IS_ERR(drvdata->atclk)) in stm_runtime_resume()
940 clk_prepare_enable(drvdata->atclk); in stm_runtime_resume()