Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
[linux-2.6] / drivers / media / video / cx18 / cx18-scb.c
1 /*
2  *  cx18 System Control Block initialization
3  *
4  *  Copyright (C) 2007  Hans Verkuil <hverkuil@xs4all.nl>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19  *  02111-1307  USA
20  */
21
22 #include "cx18-driver.h"
23 #include "cx18-io.h"
24 #include "cx18-scb.h"
25
26 void cx18_init_scb(struct cx18 *cx)
27 {
28         cx18_setup_page(cx, SCB_OFFSET);
29         cx18_memset_io(cx, cx->scb, 0, 0x10000);
30
31         cx18_writel(cx, IRQ_APU_TO_CPU,     &cx->scb->apu2cpu_irq);
32         cx18_writel(cx, IRQ_CPU_TO_APU_ACK, &cx->scb->cpu2apu_irq_ack);
33         cx18_writel(cx, IRQ_HPU_TO_CPU,     &cx->scb->hpu2cpu_irq);
34         cx18_writel(cx, IRQ_CPU_TO_HPU_ACK, &cx->scb->cpu2hpu_irq_ack);
35         cx18_writel(cx, IRQ_PPU_TO_CPU,     &cx->scb->ppu2cpu_irq);
36         cx18_writel(cx, IRQ_CPU_TO_PPU_ACK, &cx->scb->cpu2ppu_irq_ack);
37         cx18_writel(cx, IRQ_EPU_TO_CPU,     &cx->scb->epu2cpu_irq);
38         cx18_writel(cx, IRQ_CPU_TO_EPU_ACK, &cx->scb->cpu2epu_irq_ack);
39
40         cx18_writel(cx, IRQ_CPU_TO_APU,     &cx->scb->cpu2apu_irq);
41         cx18_writel(cx, IRQ_APU_TO_CPU_ACK, &cx->scb->apu2cpu_irq_ack);
42         cx18_writel(cx, IRQ_HPU_TO_APU,     &cx->scb->hpu2apu_irq);
43         cx18_writel(cx, IRQ_APU_TO_HPU_ACK, &cx->scb->apu2hpu_irq_ack);
44         cx18_writel(cx, IRQ_PPU_TO_APU,     &cx->scb->ppu2apu_irq);
45         cx18_writel(cx, IRQ_APU_TO_PPU_ACK, &cx->scb->apu2ppu_irq_ack);
46         cx18_writel(cx, IRQ_EPU_TO_APU,     &cx->scb->epu2apu_irq);
47         cx18_writel(cx, IRQ_APU_TO_EPU_ACK, &cx->scb->apu2epu_irq_ack);
48
49         cx18_writel(cx, IRQ_CPU_TO_HPU,     &cx->scb->cpu2hpu_irq);
50         cx18_writel(cx, IRQ_HPU_TO_CPU_ACK, &cx->scb->hpu2cpu_irq_ack);
51         cx18_writel(cx, IRQ_APU_TO_HPU,     &cx->scb->apu2hpu_irq);
52         cx18_writel(cx, IRQ_HPU_TO_APU_ACK, &cx->scb->hpu2apu_irq_ack);
53         cx18_writel(cx, IRQ_PPU_TO_HPU,     &cx->scb->ppu2hpu_irq);
54         cx18_writel(cx, IRQ_HPU_TO_PPU_ACK, &cx->scb->hpu2ppu_irq_ack);
55         cx18_writel(cx, IRQ_EPU_TO_HPU,     &cx->scb->epu2hpu_irq);
56         cx18_writel(cx, IRQ_HPU_TO_EPU_ACK, &cx->scb->hpu2epu_irq_ack);
57
58         cx18_writel(cx, IRQ_CPU_TO_PPU,     &cx->scb->cpu2ppu_irq);
59         cx18_writel(cx, IRQ_PPU_TO_CPU_ACK, &cx->scb->ppu2cpu_irq_ack);
60         cx18_writel(cx, IRQ_APU_TO_PPU,     &cx->scb->apu2ppu_irq);
61         cx18_writel(cx, IRQ_PPU_TO_APU_ACK, &cx->scb->ppu2apu_irq_ack);
62         cx18_writel(cx, IRQ_HPU_TO_PPU,     &cx->scb->hpu2ppu_irq);
63         cx18_writel(cx, IRQ_PPU_TO_HPU_ACK, &cx->scb->ppu2hpu_irq_ack);
64         cx18_writel(cx, IRQ_EPU_TO_PPU,     &cx->scb->epu2ppu_irq);
65         cx18_writel(cx, IRQ_PPU_TO_EPU_ACK, &cx->scb->ppu2epu_irq_ack);
66
67         cx18_writel(cx, IRQ_CPU_TO_EPU,     &cx->scb->cpu2epu_irq);
68         cx18_writel(cx, IRQ_EPU_TO_CPU_ACK, &cx->scb->epu2cpu_irq_ack);
69         cx18_writel(cx, IRQ_APU_TO_EPU,     &cx->scb->apu2epu_irq);
70         cx18_writel(cx, IRQ_EPU_TO_APU_ACK, &cx->scb->epu2apu_irq_ack);
71         cx18_writel(cx, IRQ_HPU_TO_EPU,     &cx->scb->hpu2epu_irq);
72         cx18_writel(cx, IRQ_EPU_TO_HPU_ACK, &cx->scb->epu2hpu_irq_ack);
73         cx18_writel(cx, IRQ_PPU_TO_EPU,     &cx->scb->ppu2epu_irq);
74         cx18_writel(cx, IRQ_EPU_TO_PPU_ACK, &cx->scb->epu2ppu_irq_ack);
75
76         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, apu2cpu_mb),
77                         &cx->scb->apu2cpu_mb_offset);
78         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, hpu2cpu_mb),
79                         &cx->scb->hpu2cpu_mb_offset);
80         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, ppu2cpu_mb),
81                         &cx->scb->ppu2cpu_mb_offset);
82         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, epu2cpu_mb),
83                         &cx->scb->epu2cpu_mb_offset);
84         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, cpu2apu_mb),
85                         &cx->scb->cpu2apu_mb_offset);
86         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, hpu2apu_mb),
87                         &cx->scb->hpu2apu_mb_offset);
88         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, ppu2apu_mb),
89                         &cx->scb->ppu2apu_mb_offset);
90         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, epu2apu_mb),
91                         &cx->scb->epu2apu_mb_offset);
92         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, cpu2hpu_mb),
93                         &cx->scb->cpu2hpu_mb_offset);
94         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, apu2hpu_mb),
95                         &cx->scb->apu2hpu_mb_offset);
96         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, ppu2hpu_mb),
97                         &cx->scb->ppu2hpu_mb_offset);
98         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, epu2hpu_mb),
99                         &cx->scb->epu2hpu_mb_offset);
100         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, cpu2ppu_mb),
101                         &cx->scb->cpu2ppu_mb_offset);
102         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, apu2ppu_mb),
103                         &cx->scb->apu2ppu_mb_offset);
104         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, hpu2ppu_mb),
105                         &cx->scb->hpu2ppu_mb_offset);
106         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, epu2ppu_mb),
107                         &cx->scb->epu2ppu_mb_offset);
108         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, cpu2epu_mb),
109                         &cx->scb->cpu2epu_mb_offset);
110         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, apu2epu_mb),
111                         &cx->scb->apu2epu_mb_offset);
112         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, hpu2epu_mb),
113                         &cx->scb->hpu2epu_mb_offset);
114         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, ppu2epu_mb),
115                         &cx->scb->ppu2epu_mb_offset);
116
117         cx18_writel(cx, SCB_OFFSET + offsetof(struct cx18_scb, cpu_state),
118                         &cx->scb->ipc_offset);
119
120         cx18_writel(cx, 1, &cx->scb->hpu_state);
121         cx18_writel(cx, 1, &cx->scb->epu_state);
122 }