Skip to content

Commit 4fd1a07

Browse files
slongerbeampH5
authored andcommitted
gpu: ipu-v3: Add ipu_idmac_lock_enable()
Adds ipu_idmac_lock_enable(), which enables or disables channel burst locking. Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
1 parent 2bcf577 commit 4fd1a07

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

‎drivers/gpu/ipu-v3/ipu-common.c‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,75 @@ void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
305305
}
306306
EXPORT_SYMBOL_GPL(ipu_idmac_set_double_buffer);
307307

308+
static const struct {
309+
int chnum;
310+
u32 reg;
311+
int shift;
312+
} idmac_lock_en_info[] = {
313+
{ .chnum = 5, .reg = IDMAC_CH_LOCK_EN_1, .shift = 0, },
314+
{ .chnum = 11, .reg = IDMAC_CH_LOCK_EN_1, .shift = 2, },
315+
{ .chnum = 12, .reg = IDMAC_CH_LOCK_EN_1, .shift = 4, },
316+
{ .chnum = 14, .reg = IDMAC_CH_LOCK_EN_1, .shift = 6, },
317+
{ .chnum = 15, .reg = IDMAC_CH_LOCK_EN_1, .shift = 8, },
318+
{ .chnum = 20, .reg = IDMAC_CH_LOCK_EN_1, .shift = 10, },
319+
{ .chnum = 21, .reg = IDMAC_CH_LOCK_EN_1, .shift = 12, },
320+
{ .chnum = 22, .reg = IDMAC_CH_LOCK_EN_1, .shift = 14, },
321+
{ .chnum = 23, .reg = IDMAC_CH_LOCK_EN_1, .shift = 16, },
322+
{ .chnum = 27, .reg = IDMAC_CH_LOCK_EN_1, .shift = 18, },
323+
{ .chnum = 28, .reg = IDMAC_CH_LOCK_EN_1, .shift = 20, },
324+
{ .chnum = 45, .reg = IDMAC_CH_LOCK_EN_2, .shift = 0, },
325+
{ .chnum = 46, .reg = IDMAC_CH_LOCK_EN_2, .shift = 2, },
326+
{ .chnum = 47, .reg = IDMAC_CH_LOCK_EN_2, .shift = 4, },
327+
{ .chnum = 48, .reg = IDMAC_CH_LOCK_EN_2, .shift = 6, },
328+
{ .chnum = 49, .reg = IDMAC_CH_LOCK_EN_2, .shift = 8, },
329+
{ .chnum = 50, .reg = IDMAC_CH_LOCK_EN_2, .shift = 10, },
330+
};
331+
332+
int ipu_idmac_lock_enable(struct ipuv3_channel *channel, int num_bursts)
333+
{
334+
struct ipu_soc *ipu = channel->ipu;
335+
unsigned long flags;
336+
u32 bursts, regval;
337+
int i;
338+
339+
switch (num_bursts) {
340+
case 0:
341+
case 1:
342+
bursts = 0x00; /* locking disabled */
343+
break;
344+
case 2:
345+
bursts = 0x01;
346+
break;
347+
case 4:
348+
bursts = 0x02;
349+
break;
350+
case 8:
351+
bursts = 0x03;
352+
break;
353+
default:
354+
return -EINVAL;
355+
}
356+
357+
for (i = 0; i < ARRAY_SIZE(idmac_lock_en_info); i++) {
358+
if (channel->num == idmac_lock_en_info[i].chnum)
359+
break;
360+
}
361+
if (i >= ARRAY_SIZE(idmac_lock_en_info))
362+
return -EINVAL;
363+
364+
spin_lock_irqsave(&ipu->lock, flags);
365+
366+
regval = ipu_idmac_read(ipu, idmac_lock_en_info[i].reg);
367+
regval &= ~(0x03 << idmac_lock_en_info[i].shift);
368+
regval |= (bursts << idmac_lock_en_info[i].shift);
369+
ipu_idmac_write(ipu, regval, idmac_lock_en_info[i].reg);
370+
371+
spin_unlock_irqrestore(&ipu->lock, flags);
372+
373+
return 0;
374+
}
375+
EXPORT_SYMBOL_GPL(ipu_idmac_lock_enable);
376+
308377
int ipu_module_enable(struct ipu_soc *ipu, u32 mask)
309378
{
310379
unsigned long lock_flags;

‎include/video/imx-ipu-v3.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ void ipu_idmac_put(struct ipuv3_channel *);
161161
int ipu_idmac_enable_channel(struct ipuv3_channel *channel);
162162
int ipu_idmac_disable_channel(struct ipuv3_channel *channel);
163163
void ipu_idmac_enable_watermark(struct ipuv3_channel *channel, bool enable);
164+
int ipu_idmac_lock_enable(struct ipuv3_channel *channel, int num_bursts);
164165
int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms);
165166

166167
void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,

0 commit comments

Comments
 (0)