162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  cx18 System Control Block initialization
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci *  Copyright (C) 2007  Hans Verkuil <hverkuil@xs4all.nl>
662306a36Sopenharmony_ci *  Copyright (C) 2008  Andy Walls <awalls@md.metrocast.net>
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include "cx18-driver.h"
1062306a36Sopenharmony_ci#include "cx18-io.h"
1162306a36Sopenharmony_ci#include "cx18-scb.h"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_civoid cx18_init_scb(struct cx18 *cx)
1462306a36Sopenharmony_ci{
1562306a36Sopenharmony_ci	cx18_setup_page(cx, SCB_OFFSET);
1662306a36Sopenharmony_ci	cx18_memset_io(cx, cx->scb, 0, 0x10000);
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci	cx18_writel(cx, IRQ_APU_TO_CPU,     &cx->scb->apu2cpu_irq);
1962306a36Sopenharmony_ci	cx18_writel(cx, IRQ_CPU_TO_APU_ACK, &cx->scb->cpu2apu_irq_ack);
2062306a36Sopenharmony_ci	cx18_writel(cx, IRQ_HPU_TO_CPU,     &cx->scb->hpu2cpu_irq);
2162306a36Sopenharmony_ci	cx18_writel(cx, IRQ_CPU_TO_HPU_ACK, &cx->scb->cpu2hpu_irq_ack);
2262306a36Sopenharmony_ci	cx18_writel(cx, IRQ_PPU_TO_CPU,     &cx->scb->ppu2cpu_irq);
2362306a36Sopenharmony_ci	cx18_writel(cx, IRQ_CPU_TO_PPU_ACK, &cx->scb->cpu2ppu_irq_ack);
2462306a36Sopenharmony_ci	cx18_writel(cx, IRQ_EPU_TO_CPU,     &cx->scb->epu2cpu_irq);
2562306a36Sopenharmony_ci	cx18_writel(cx, IRQ_CPU_TO_EPU_ACK, &cx->scb->cpu2epu_irq_ack);
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci	cx18_writel(cx, IRQ_CPU_TO_APU,     &cx->scb->cpu2apu_irq);
2862306a36Sopenharmony_ci	cx18_writel(cx, IRQ_APU_TO_CPU_ACK, &cx->scb->apu2cpu_irq_ack);
2962306a36Sopenharmony_ci	cx18_writel(cx, IRQ_HPU_TO_APU,     &cx->scb->hpu2apu_irq);
3062306a36Sopenharmony_ci	cx18_writel(cx, IRQ_APU_TO_HPU_ACK, &cx->scb->apu2hpu_irq_ack);
3162306a36Sopenharmony_ci	cx18_writel(cx, IRQ_PPU_TO_APU,     &cx->scb->ppu2apu_irq);
3262306a36Sopenharmony_ci	cx18_writel(cx, IRQ_APU_TO_PPU_ACK, &cx->scb->apu2ppu_irq_ack);
3362306a36Sopenharmony_ci	cx18_writel(cx, IRQ_EPU_TO_APU,     &cx->scb->epu2apu_irq);
3462306a36Sopenharmony_ci	cx18_writel(cx, IRQ_APU_TO_EPU_ACK, &cx->scb->apu2epu_irq_ack);
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci	cx18_writel(cx, IRQ_CPU_TO_HPU,     &cx->scb->cpu2hpu_irq);
3762306a36Sopenharmony_ci	cx18_writel(cx, IRQ_HPU_TO_CPU_ACK, &cx->scb->hpu2cpu_irq_ack);
3862306a36Sopenharmony_ci	cx18_writel(cx, IRQ_APU_TO_HPU,     &cx->scb->apu2hpu_irq);
3962306a36Sopenharmony_ci	cx18_writel(cx, IRQ_HPU_TO_APU_ACK, &cx->scb->hpu2apu_irq_ack);
4062306a36Sopenharmony_ci	cx18_writel(cx, IRQ_PPU_TO_HPU,     &cx->scb->ppu2hpu_irq);
4162306a36Sopenharmony_ci	cx18_writel(cx, IRQ_HPU_TO_PPU_ACK, &cx->scb->hpu2ppu_irq_ack);
4262306a36Sopenharmony_ci	cx18_writel(cx, IRQ_EPU_TO_HPU,     &cx->scb->epu2hpu_irq);
4362306a36Sopenharmony_ci	cx18_writel(cx, IRQ_HPU_TO_EPU_ACK, &cx->scb->hpu2epu_irq_ack);
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci	cx18_writel(cx, IRQ_CPU_TO_PPU,     &cx->scb->cpu2ppu_irq);
4662306a36Sopenharmony_ci	cx18_writel(cx, IRQ_PPU_TO_CPU_ACK, &cx->scb->ppu2cpu_irq_ack);
4762306a36Sopenharmony_ci	cx18_writel(cx, IRQ_APU_TO_PPU,     &cx->scb->apu2ppu_irq);
4862306a36Sopenharmony_ci	cx18_writel(cx, IRQ_PPU_TO_APU_ACK, &cx->scb->ppu2apu_irq_ack);
4962306a36Sopenharmony_ci	cx18_writel(cx, IRQ_HPU_TO_PPU,     &cx->scb->hpu2ppu_irq);
5062306a36Sopenharmony_ci	cx18_writel(cx, IRQ_PPU_TO_HPU_ACK, &cx->scb->ppu2hpu_irq_ack);
5162306a36Sopenharmony_ci	cx18_writel(cx, IRQ_EPU_TO_PPU,     &cx->scb->epu2ppu_irq);
5262306a36Sopenharmony_ci	cx18_writel(cx, IRQ_PPU_TO_EPU_ACK, &cx->scb->ppu2epu_irq_ack);
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci	cx18_writel(cx, IRQ_CPU_TO_EPU,     &cx->scb->cpu2epu_irq);
5562306a36Sopenharmony_ci	cx18_writel(cx, IRQ_EPU_TO_CPU_ACK, &cx->scb->epu2cpu_irq_ack);
5662306a36Sopenharmony_ci	cx18_writel(cx, IRQ_APU_TO_EPU,     &cx->scb->apu2epu_irq);
5762306a36Sopenharmony_ci	cx18_writel(cx, IRQ_EPU_TO_APU_ACK, &cx->scb->epu2apu_irq_ack);
5862306a36Sopenharmony_ci	cx18_writel(cx, IRQ_HPU_TO_EPU,     &cx->scb->hpu2epu_irq);
5962306a36Sopenharmony_ci	cx18_writel(cx, IRQ_EPU_TO_HPU_ACK, &cx->scb->epu2hpu_irq_ack);
6062306a36Sopenharmony_ci	cx18_writel(cx, IRQ_PPU_TO_EPU,     &cx->scb->ppu2epu_irq);
6162306a36Sopenharmony_ci	cx18_writel(cx, IRQ_EPU_TO_PPU_ACK, &cx->scb->epu2ppu_irq_ack);
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, apu2cpu_mb),
6462306a36Sopenharmony_ci			&cx->scb->apu2cpu_mb_offset);
6562306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, hpu2cpu_mb),
6662306a36Sopenharmony_ci			&cx->scb->hpu2cpu_mb_offset);
6762306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, ppu2cpu_mb),
6862306a36Sopenharmony_ci			&cx->scb->ppu2cpu_mb_offset);
6962306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, epu2cpu_mb),
7062306a36Sopenharmony_ci			&cx->scb->epu2cpu_mb_offset);
7162306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, cpu2apu_mb),
7262306a36Sopenharmony_ci			&cx->scb->cpu2apu_mb_offset);
7362306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, hpu2apu_mb),
7462306a36Sopenharmony_ci			&cx->scb->hpu2apu_mb_offset);
7562306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, ppu2apu_mb),
7662306a36Sopenharmony_ci			&cx->scb->ppu2apu_mb_offset);
7762306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, epu2apu_mb),
7862306a36Sopenharmony_ci			&cx->scb->epu2apu_mb_offset);
7962306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, cpu2hpu_mb),
8062306a36Sopenharmony_ci			&cx->scb->cpu2hpu_mb_offset);
8162306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, apu2hpu_mb),
8262306a36Sopenharmony_ci			&cx->scb->apu2hpu_mb_offset);
8362306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, ppu2hpu_mb),
8462306a36Sopenharmony_ci			&cx->scb->ppu2hpu_mb_offset);
8562306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, epu2hpu_mb),
8662306a36Sopenharmony_ci			&cx->scb->epu2hpu_mb_offset);
8762306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, cpu2ppu_mb),
8862306a36Sopenharmony_ci			&cx->scb->cpu2ppu_mb_offset);
8962306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, apu2ppu_mb),
9062306a36Sopenharmony_ci			&cx->scb->apu2ppu_mb_offset);
9162306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, hpu2ppu_mb),
9262306a36Sopenharmony_ci			&cx->scb->hpu2ppu_mb_offset);
9362306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, epu2ppu_mb),
9462306a36Sopenharmony_ci			&cx->scb->epu2ppu_mb_offset);
9562306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, cpu2epu_mb),
9662306a36Sopenharmony_ci			&cx->scb->cpu2epu_mb_offset);
9762306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, apu2epu_mb),
9862306a36Sopenharmony_ci			&cx->scb->apu2epu_mb_offset);
9962306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, hpu2epu_mb),
10062306a36Sopenharmony_ci			&cx->scb->hpu2epu_mb_offset);
10162306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, ppu2epu_mb),
10262306a36Sopenharmony_ci			&cx->scb->ppu2epu_mb_offset);
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci	cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, cpu_state),
10562306a36Sopenharmony_ci			&cx->scb->ipc_offset);
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci	cx18_writel(cx, 1, &cx->scb->epu_state);
10862306a36Sopenharmony_ci}
109