1 /* $NetBSD: shpcic.c,v 1.12 2008/03/27 02:05:43 uwe Exp $ */
4 * Copyright (c) 2005 NONAKA Kimihiro
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: shpcic.c,v 1.12 2008/03/27 02:05:43 uwe Exp $");
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/device.h>
37 #include <sys/extent.h>
38 #include <sys/malloc.h>
40 #include <dev/pci/pcireg.h>
41 #include <dev/pci/pcivar.h>
42 #include <dev/pci/pciconf.h>
43 #include <dev/pci/pcidevs.h>
45 #include <sh3/bscreg.h>
46 #include <sh3/cache.h>
47 #include <sh3/exception.h>
48 #include <sh3/pcicreg.h>
50 #include <machine/bus.h>
51 #include <machine/intr.h>
52 #include <machine/pci_machdep.h>
55 #if defined(DEBUG) && !defined(SHPCIC_DEBUG)
56 #define SHPCIC_DEBUG 0
58 #if defined(SHPCIC_DEBUG)
59 int shpcic_debug
= SHPCIC_DEBUG
+ 0;
60 #define DPRINTF(arg) if (shpcic_debug) printf arg
65 #define PCI_MODE1_ENABLE 0x80000000UL
68 static int shpcic_match(device_t
, cfdata_t
, void *);
69 static void shpcic_attach(device_t
, device_t
, void *);
71 CFATTACH_DECL_NEW(shpcic
, 0,
72 shpcic_match
, shpcic_attach
, NULL
, NULL
);
75 /* There can be only one. */
76 static int shpcic_found
= 0;
78 /* PCIC intr priotiry */
79 static int shpcic_intr_priority
[2] = { IPL_BIO
, IPL_BIO
};
83 shpcic_match(device_t parent
, cfdata_t cf
, void *aux
)
90 switch (cpu_product
) {
91 case CPU_PRODUCT_7751
:
92 case CPU_PRODUCT_7751R
:
100 id
= _reg_read_4(SH4_PCICONF0
);
102 switch (PCI_VENDOR(id
)) {
103 case PCI_VENDOR_HITACHI
:
111 switch (PCI_PRODUCT(id
)) {
112 case PCI_PRODUCT_HITACHI_SH7751
: /* FALLTHROUGH */
113 case PCI_PRODUCT_HITACHI_SH7751R
:
120 if (_reg_read_2(SH4_BCR2
) & BCR2_PORTEN
)
127 shpcic_attach(device_t parent
, device_t self
, void *aux
)
129 struct pcibus_attach_args pba
;
130 #ifdef PCI_NETBSD_CONFIGURE
131 struct extent
*ioext
, *memext
;
140 id
= _reg_read_4(SH4_PCICONF0
);
141 class = _reg_read_4(SH4_PCICONF2
);
142 pci_devinfo(id
, class, 1, devinfo
, sizeof(devinfo
));
143 aprint_normal(": %s\n", devinfo
);
145 /* allow PCIC request */
146 _reg_write_4(SH4_BCR1
, _reg_read_4(SH4_BCR1
) | BCR1_BREQEN
);
148 /* Initialize PCIC */
149 _reg_write_4(SH4_PCICR
, PCICR_BASE
| PCICR_RSTCTL
);
151 _reg_write_4(SH4_PCICR
, PCICR_BASE
);
153 /* Class: Host-Bridge */
154 _reg_write_4(SH4_PCICONF2
,
155 PCI_CLASS_CODE(PCI_CLASS_BRIDGE
, PCI_SUBCLASS_BRIDGE_HOST
, 0x00));
157 #if !defined(DONT_INIT_PCIBSC)
158 #if defined(PCIBCR_BCR1_VAL)
159 _reg_write_4(SH4_PCIBCR1
, PCIBCR_BCR1_VAL
);
161 _reg_write_4(SH4_PCIBCR1
, _reg_read_4(SH4_BCR1
) | BCR1_MASTER
);
163 #if defined(PCIBCR_BCR2_VAL)
164 _reg_write_4(SH4_PCIBCR2
, PCIBCR_BCR2_VAL
);
166 _reg_write_4(SH4_PCIBCR2
, _reg_read_2(SH4_BCR2
));
168 #if defined(SH4) && defined(SH7751R)
169 if (cpu_product
== CPU_PRODUCT_7751R
) {
170 #if defined(PCIBCR_BCR3_VAL)
171 _reg_write_4(SH4_PCIBCR3
, PCIBCR_BCR3_VAL
);
173 _reg_write_4(SH4_PCIBCR3
, _reg_read_2(SH4_BCR3
));
176 #endif /* SH4 && SH7751R && PCIBCR_BCR3_VAL */
177 #if defined(PCIBCR_WCR1_VAL)
178 _reg_write_4(SH4_PCIWCR1
, PCIBCR_WCR1_VAL
);
180 _reg_write_4(SH4_PCIWCR1
, _reg_read_4(SH4_WCR1
));
182 #if defined(PCIBCR_WCR2_VAL)
183 _reg_write_4(SH4_PCIWCR2
, PCIBCR_WCR2_VAL
);
185 _reg_write_4(SH4_PCIWCR2
, _reg_read_4(SH4_WCR2
));
187 #if defined(PCIBCR_WCR3_VAL)
188 _reg_write_4(SH4_PCIWCR3
, PCIBCR_WCR3_VAL
);
190 _reg_write_4(SH4_PCIWCR3
, _reg_read_4(SH4_WCR3
));
192 #if defined(PCIBCR_MCR_VAL)
193 _reg_write_4(SH4_PCIMCR
, PCIBCR_MCR_VAL
);
195 _reg_write_4(SH4_PCIMCR
, _reg_read_4(SH4_MCR
));
197 #endif /* !DONT_INIT_PCIBSC */
199 /* set PCI I/O, memory base address */
200 _reg_write_4(SH4_PCIIOBR
, SH4_PCIC_IO
);
201 _reg_write_4(SH4_PCIMBR
, SH4_PCIC_MEM
);
203 /* set PCI local address 0 */
204 _reg_write_4(SH4_PCILSR0
, (64 - 1) << 20);
205 _reg_write_4(SH4_PCILAR0
, 0xac000000);
206 _reg_write_4(SH4_PCICONF5
, 0xac000000);
208 /* set PCI local address 1 */
209 _reg_write_4(SH4_PCILSR1
, (64 - 1) << 20);
210 _reg_write_4(SH4_PCILAR1
, 0xac000000);
211 _reg_write_4(SH4_PCICONF6
, 0x8c000000);
213 /* Enable I/O, memory, bus-master */
214 _reg_write_4(SH4_PCICONF1
, PCI_COMMAND_IO_ENABLE
215 | PCI_COMMAND_MEM_ENABLE
216 | PCI_COMMAND_MASTER_ENABLE
217 | PCI_COMMAND_STEPPING_ENABLE
218 | PCI_STATUS_DEVSEL_MEDIUM
);
220 /* Initialize done. */
221 _reg_write_4(SH4_PCICR
, PCICR_BASE
| PCICR_CFINIT
);
223 /* set PCI controller interrupt priority */
224 intpri_intr_priority(SH4_INTEVT_PCIERR
, shpcic_intr_priority
[0]);
225 intpri_intr_priority(SH4_INTEVT_PCISERR
, shpcic_intr_priority
[1]);
228 #ifdef PCI_NETBSD_CONFIGURE
229 ioext
= extent_create("pciio",
230 SH4_PCIC_IO
, SH4_PCIC_IO
+ SH4_PCIC_IO_SIZE
- 1,
231 M_DEVBUF
, NULL
, 0, EX_NOWAIT
);
232 memext
= extent_create("pcimem",
233 SH4_PCIC_MEM
, SH4_PCIC_MEM
+ SH4_PCIC_MEM_SIZE
- 1,
234 M_DEVBUF
, NULL
, 0, EX_NOWAIT
);
236 pci_configure_bus(NULL
, ioext
, memext
, NULL
, 0, sh_cache_line_size
);
238 extent_destroy(ioext
);
239 extent_destroy(memext
);
243 memset(&pba
, 0, sizeof(pba
));
244 pba
.pba_iot
= shpcic_get_bus_io_tag();
245 pba
.pba_memt
= shpcic_get_bus_mem_tag();
246 pba
.pba_dmat
= shpcic_get_bus_dma_tag();
247 pba
.pba_dmat64
= NULL
;
250 pba
.pba_bridgetag
= NULL
;
251 pba
.pba_flags
= PCI_FLAGS_IO_ENABLED
| PCI_FLAGS_MEM_ENABLED
;
252 config_found(self
, &pba
, NULL
);
256 shpcic_bus_maxdevs(void *v
, int busno
)
260 * Bus number is irrelevant. Configuration Mechanism 1 is in
261 * use, can have devices 0-32 (i.e. the `normal' range).
267 shpcic_make_tag(void *v
, int bus
, int device
, int function
)
271 if (bus
>= 256 || device
>= 32 || function
>= 8)
272 panic("pci_make_tag: bad request");
274 tag
= PCI_MODE1_ENABLE
|
275 (bus
<< 16) | (device
<< 11) | (function
<< 8);
281 shpcic_decompose_tag(void *v
, pcitag_t tag
, int *bp
, int *dp
, int *fp
)
285 *bp
= (tag
>> 16) & 0xff;
287 *dp
= (tag
>> 11) & 0x1f;
289 *fp
= (tag
>> 8) & 0x7;
293 shpcic_conf_read(void *v
, pcitag_t tag
, int reg
)
299 _reg_write_4(SH4_PCIPAR
, tag
| reg
);
300 data
= _reg_read_4(SH4_PCIPDR
);
301 _reg_write_4(SH4_PCIPAR
, 0);
308 shpcic_conf_write(void *v
, pcitag_t tag
, int reg
, pcireg_t data
)
313 _reg_write_4(SH4_PCIPAR
, tag
| reg
);
314 _reg_write_4(SH4_PCIPDR
, data
);
315 _reg_write_4(SH4_PCIPAR
, 0);
320 shpcic_set_intr_priority(int intr
, int level
)
324 if ((intr
!= 0) && (intr
!= 1)) {
327 if ((level
< IPL_NONE
) || (level
> IPL_HIGH
)) {
332 evtcode
= SH4_INTEVT_PCIERR
;
334 evtcode
= SH4_INTEVT_PCISERR
;
337 intpri_intr_priority(evtcode
, shpcic_intr_priority
[intr
]);
338 shpcic_intr_priority
[intr
] = level
;
344 shpcic_intr_establish(int evtcode
, int (*ih_func
)(void *), void *ih_arg
)
349 case SH4_INTEVT_PCISERR
:
350 level
= shpcic_intr_priority
[1];
353 case SH4_INTEVT_PCIDMA3
:
354 case SH4_INTEVT_PCIDMA2
:
355 case SH4_INTEVT_PCIDMA1
:
356 case SH4_INTEVT_PCIDMA0
:
357 case SH4_INTEVT_PCIPWON
:
358 case SH4_INTEVT_PCIPWDWN
:
359 case SH4_INTEVT_PCIERR
:
360 level
= shpcic_intr_priority
[0];
364 printf("shpcic_intr_establish: unknown evtcode = 0x%08x\n",
369 return intc_intr_establish(evtcode
, IST_LEVEL
, level
, ih_func
, ih_arg
);
373 shpcic_intr_disestablish(void *ih
)
376 intc_intr_disestablish(ih
);
383 shpcic_iomem_map(void *v
, bus_addr_t bpa
, bus_size_t size
,
384 int flags
, bus_space_handle_t
*bshp
)
387 *bshp
= (bus_space_handle_t
)bpa
;
393 shpcic_iomem_unmap(void *v
, bus_space_handle_t bsh
, bus_size_t size
)
400 shpcic_iomem_subregion(void *v
, bus_space_handle_t bsh
,
401 bus_size_t offset
, bus_size_t size
, bus_space_handle_t
*nbshp
)
404 *nbshp
= bsh
+ offset
;
410 shpcic_iomem_alloc(void *v
, bus_addr_t rstart
, bus_addr_t rend
,
411 bus_size_t size
, bus_size_t alignment
, bus_size_t boundary
, int flags
,
412 bus_addr_t
*bpap
, bus_space_handle_t
*bshp
)
415 *bshp
= *bpap
= rstart
;
421 shpcic_iomem_free(void *v
, bus_space_handle_t bsh
, bus_size_t size
)
428 shpcic_iomem_mmap(void *v
, bus_addr_t addr
, off_t off
, int prot
, int flags
)
435 * shpcic bus space io/mem read/write
438 static inline uint8_t __shpcic_io_read_1(bus_space_handle_t bsh
,
440 static inline uint16_t __shpcic_io_read_2(bus_space_handle_t bsh
,
442 static inline uint32_t __shpcic_io_read_4(bus_space_handle_t bsh
,
444 static inline uint8_t __shpcic_mem_read_1(bus_space_handle_t bsh
,
446 static inline uint16_t __shpcic_mem_read_2(bus_space_handle_t bsh
,
448 static inline uint32_t __shpcic_mem_read_4(bus_space_handle_t bsh
,
451 static inline uint8_t
452 __shpcic_io_read_1(bus_space_handle_t bsh
, bus_size_t offset
)
454 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_IO_MASK
;
456 return *(volatile uint8_t *)(SH4_PCIC_IO
+ adr
);
459 static inline uint16_t
460 __shpcic_io_read_2(bus_space_handle_t bsh
, bus_size_t offset
)
462 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_IO_MASK
;
464 return *(volatile uint16_t *)(SH4_PCIC_IO
+ adr
);
467 static inline uint32_t
468 __shpcic_io_read_4(bus_space_handle_t bsh
, bus_size_t offset
)
470 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_IO_MASK
;
472 return *(volatile uint32_t *)(SH4_PCIC_IO
+ adr
);
475 static inline uint8_t
476 __shpcic_mem_read_1(bus_space_handle_t bsh
, bus_size_t offset
)
478 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_MEM_MASK
;
480 return *(volatile uint8_t *)(SH4_PCIC_MEM
+ adr
);
483 static inline uint16_t
484 __shpcic_mem_read_2(bus_space_handle_t bsh
, bus_size_t offset
)
486 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_MEM_MASK
;
488 return *(volatile uint16_t *)(SH4_PCIC_MEM
+ adr
);
491 static inline uint32_t
492 __shpcic_mem_read_4(bus_space_handle_t bsh
, bus_size_t offset
)
494 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_MEM_MASK
;
496 return *(volatile uint32_t *)(SH4_PCIC_MEM
+ adr
);
503 shpcic_io_read_1(void *v
, bus_space_handle_t bsh
, bus_size_t offset
)
507 value
= __shpcic_io_read_1(bsh
, offset
);
513 shpcic_io_read_2(void *v
, bus_space_handle_t bsh
, bus_size_t offset
)
517 value
= __shpcic_io_read_2(bsh
, offset
);
523 shpcic_io_read_4(void *v
, bus_space_handle_t bsh
, bus_size_t offset
)
527 value
= __shpcic_io_read_4(bsh
, offset
);
533 shpcic_mem_read_1(void *v
, bus_space_handle_t bsh
, bus_size_t offset
)
537 value
= __shpcic_mem_read_1(bsh
, offset
);
543 shpcic_mem_read_2(void *v
, bus_space_handle_t bsh
, bus_size_t offset
)
547 value
= __shpcic_mem_read_2(bsh
, offset
);
553 shpcic_mem_read_4(void *v
, bus_space_handle_t bsh
, bus_size_t offset
)
557 value
= __shpcic_mem_read_4(bsh
, offset
);
566 shpcic_io_read_multi_1(void *v
, bus_space_handle_t bsh
,
567 bus_size_t offset
, uint8_t *addr
, bus_size_t count
)
571 *addr
++ = __shpcic_io_read_1(bsh
, offset
);
576 shpcic_io_read_multi_2(void *v
, bus_space_handle_t bsh
,
577 bus_size_t offset
, uint16_t *addr
, bus_size_t count
)
581 *addr
++ = __shpcic_io_read_2(bsh
, offset
);
586 shpcic_io_read_multi_4(void *v
, bus_space_handle_t bsh
,
587 bus_size_t offset
, uint32_t *addr
, bus_size_t count
)
591 *addr
++ = __shpcic_io_read_4(bsh
, offset
);
596 shpcic_mem_read_multi_1(void *v
, bus_space_handle_t bsh
,
597 bus_size_t offset
, uint8_t *addr
, bus_size_t count
)
601 *addr
++ = __shpcic_mem_read_1(bsh
, offset
);
606 shpcic_mem_read_multi_2(void *v
, bus_space_handle_t bsh
,
607 bus_size_t offset
, uint16_t *addr
, bus_size_t count
)
611 *addr
++ = __shpcic_mem_read_2(bsh
, offset
);
616 shpcic_mem_read_multi_4(void *v
, bus_space_handle_t bsh
,
617 bus_size_t offset
, uint32_t *addr
, bus_size_t count
)
621 *addr
++ = __shpcic_mem_read_4(bsh
, offset
);
630 shpcic_io_read_region_1(void *v
, bus_space_handle_t bsh
,
631 bus_size_t offset
, uint8_t *addr
, bus_size_t count
)
635 *addr
++ = __shpcic_io_read_1(bsh
, offset
);
641 shpcic_io_read_region_2(void *v
, bus_space_handle_t bsh
,
642 bus_size_t offset
, uint16_t *addr
, bus_size_t count
)
646 *addr
++ = __shpcic_io_read_2(bsh
, offset
);
652 shpcic_io_read_region_4(void *v
, bus_space_handle_t bsh
,
653 bus_size_t offset
, uint32_t *addr
, bus_size_t count
)
657 *addr
++ = __shpcic_io_read_4(bsh
, offset
);
663 shpcic_mem_read_region_1(void *v
, bus_space_handle_t bsh
,
664 bus_size_t offset
, uint8_t *addr
, bus_size_t count
)
668 *addr
++ = __shpcic_mem_read_1(bsh
, offset
);
674 shpcic_mem_read_region_2(void *v
, bus_space_handle_t bsh
,
675 bus_size_t offset
, uint16_t *addr
, bus_size_t count
)
679 *addr
++ = __shpcic_mem_read_2(bsh
, offset
);
685 shpcic_mem_read_region_4(void *v
, bus_space_handle_t bsh
,
686 bus_size_t offset
, uint32_t *addr
, bus_size_t count
)
690 *addr
++ = __shpcic_mem_read_4(bsh
, offset
);
696 static inline void __shpcic_io_write_1(bus_space_handle_t bsh
,
697 bus_size_t offset
, uint8_t value
);
698 static inline void __shpcic_io_write_2(bus_space_handle_t bsh
,
699 bus_size_t offset
, uint16_t value
);
700 static inline void __shpcic_io_write_4(bus_space_handle_t bsh
,
701 bus_size_t offset
, uint32_t value
);
702 static inline void __shpcic_mem_write_1(bus_space_handle_t bsh
,
703 bus_size_t offset
, uint8_t value
);
704 static inline void __shpcic_mem_write_2(bus_space_handle_t bsh
,
705 bus_size_t offset
, uint16_t value
);
706 static inline void __shpcic_mem_write_4(bus_space_handle_t bsh
,
707 bus_size_t offset
, uint32_t value
);
710 __shpcic_io_write_1(bus_space_handle_t bsh
, bus_size_t offset
,
713 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_IO_MASK
;
715 *(volatile uint8_t *)(SH4_PCIC_IO
+ adr
) = value
;
719 __shpcic_io_write_2(bus_space_handle_t bsh
, bus_size_t offset
,
722 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_IO_MASK
;
724 *(volatile uint16_t *)(SH4_PCIC_IO
+ adr
) = value
;
728 __shpcic_io_write_4(bus_space_handle_t bsh
, bus_size_t offset
,
731 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_IO_MASK
;
733 *(volatile uint32_t *)(SH4_PCIC_IO
+ adr
) = value
;
737 __shpcic_mem_write_1(bus_space_handle_t bsh
, bus_size_t offset
,
740 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_MEM_MASK
;
742 *(volatile uint8_t *)(SH4_PCIC_MEM
+ adr
) = value
;
746 __shpcic_mem_write_2(bus_space_handle_t bsh
, bus_size_t offset
,
749 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_MEM_MASK
;
751 *(volatile uint16_t *)(SH4_PCIC_MEM
+ adr
) = value
;
755 __shpcic_mem_write_4(bus_space_handle_t bsh
, bus_size_t offset
,
758 u_long adr
= (u_long
)(bsh
+ offset
) & SH4_PCIC_MEM_MASK
;
760 *(volatile uint32_t *)(SH4_PCIC_MEM
+ adr
) = value
;
767 shpcic_io_write_1(void *v
, bus_space_handle_t bsh
,
768 bus_size_t offset
, uint8_t value
)
771 __shpcic_io_write_1(bsh
, offset
, value
);
775 shpcic_io_write_2(void *v
, bus_space_handle_t bsh
,
776 bus_size_t offset
, uint16_t value
)
779 __shpcic_io_write_2(bsh
, offset
, value
);
783 shpcic_io_write_4(void *v
, bus_space_handle_t bsh
,
784 bus_size_t offset
, uint32_t value
)
787 __shpcic_io_write_4(bsh
, offset
, value
);
791 shpcic_mem_write_1(void *v
, bus_space_handle_t bsh
,
792 bus_size_t offset
, uint8_t value
)
795 __shpcic_mem_write_1(bsh
, offset
, value
);
799 shpcic_mem_write_2(void *v
, bus_space_handle_t bsh
,
800 bus_size_t offset
, uint16_t value
)
803 __shpcic_mem_write_2(bsh
, offset
, value
);
807 shpcic_mem_write_4(void *v
, bus_space_handle_t bsh
,
808 bus_size_t offset
, uint32_t value
)
811 __shpcic_mem_write_4(bsh
, offset
, value
);
818 shpcic_io_write_multi_1(void *v
, bus_space_handle_t bsh
,
819 bus_size_t offset
, const uint8_t *addr
, bus_size_t count
)
823 __shpcic_io_write_1(bsh
, offset
, *addr
++);
828 shpcic_io_write_multi_2(void *v
, bus_space_handle_t bsh
,
829 bus_size_t offset
, const uint16_t *addr
, bus_size_t count
)
833 __shpcic_io_write_2(bsh
, offset
, *addr
++);
838 shpcic_io_write_multi_4(void *v
, bus_space_handle_t bsh
,
839 bus_size_t offset
, const uint32_t *addr
, bus_size_t count
)
843 __shpcic_io_write_4(bsh
, offset
, *addr
++);
848 shpcic_mem_write_multi_1(void *v
, bus_space_handle_t bsh
,
849 bus_size_t offset
, const uint8_t *addr
, bus_size_t count
)
853 __shpcic_mem_write_1(bsh
, offset
, *addr
++);
858 shpcic_mem_write_multi_2(void *v
, bus_space_handle_t bsh
,
859 bus_size_t offset
, const uint16_t *addr
, bus_size_t count
)
863 __shpcic_mem_write_2(bsh
, offset
, *addr
++);
868 shpcic_mem_write_multi_4(void *v
, bus_space_handle_t bsh
,
869 bus_size_t offset
, const uint32_t *addr
, bus_size_t count
)
873 __shpcic_mem_write_4(bsh
, offset
, *addr
++);
881 shpcic_io_write_region_1(void *v
, bus_space_handle_t bsh
,
882 bus_size_t offset
, const uint8_t *addr
, bus_size_t count
)
886 __shpcic_io_write_1(bsh
, offset
, *addr
++);
892 shpcic_io_write_region_2(void *v
, bus_space_handle_t bsh
,
893 bus_size_t offset
, const uint16_t *addr
, bus_size_t count
)
897 __shpcic_io_write_2(bsh
, offset
, *addr
++);
903 shpcic_io_write_region_4(void *v
, bus_space_handle_t bsh
,
904 bus_size_t offset
, const uint32_t *addr
, bus_size_t count
)
908 __shpcic_io_write_4(bsh
, offset
, *addr
++);
914 shpcic_mem_write_region_1(void *v
, bus_space_handle_t bsh
,
915 bus_size_t offset
, const uint8_t *addr
, bus_size_t count
)
919 __shpcic_mem_write_1(bsh
, offset
, *addr
++);
925 shpcic_mem_write_region_2(void *v
, bus_space_handle_t bsh
,
926 bus_size_t offset
, const uint16_t *addr
, bus_size_t count
)
930 __shpcic_mem_write_2(bsh
, offset
, *addr
++);
936 shpcic_mem_write_region_4(void *v
, bus_space_handle_t bsh
,
937 bus_size_t offset
, const uint32_t *addr
, bus_size_t count
)
941 __shpcic_mem_write_4(bsh
, offset
, *addr
++);
950 shpcic_io_set_multi_1(void *v
, bus_space_handle_t bsh
,
951 bus_size_t offset
, uint8_t value
, bus_size_t count
)
955 __shpcic_io_write_1(bsh
, offset
, value
);
960 shpcic_io_set_multi_2(void *v
, bus_space_handle_t bsh
,
961 bus_size_t offset
, uint16_t value
, bus_size_t count
)
965 __shpcic_io_write_2(bsh
, offset
, value
);
970 shpcic_io_set_multi_4(void *v
, bus_space_handle_t bsh
,
971 bus_size_t offset
, uint32_t value
, bus_size_t count
)
975 __shpcic_io_write_4(bsh
, offset
, value
);
980 shpcic_mem_set_multi_1(void *v
, bus_space_handle_t bsh
,
981 bus_size_t offset
, uint8_t value
, bus_size_t count
)
985 __shpcic_mem_write_1(bsh
, offset
, value
);
990 shpcic_mem_set_multi_2(void *v
, bus_space_handle_t bsh
,
991 bus_size_t offset
, uint16_t value
, bus_size_t count
)
995 __shpcic_mem_write_2(bsh
, offset
, value
);
1000 shpcic_mem_set_multi_4(void *v
, bus_space_handle_t bsh
,
1001 bus_size_t offset
, uint32_t value
, bus_size_t count
)
1005 __shpcic_mem_write_4(bsh
, offset
, value
);
1013 shpcic_io_set_region_1(void *v
, bus_space_handle_t bsh
,
1014 bus_size_t offset
, uint8_t value
, bus_size_t count
)
1018 __shpcic_io_write_1(bsh
, offset
, value
);
1024 shpcic_io_set_region_2(void *v
, bus_space_handle_t bsh
,
1025 bus_size_t offset
, uint16_t value
, bus_size_t count
)
1029 __shpcic_io_write_2(bsh
, offset
, value
);
1035 shpcic_io_set_region_4(void *v
, bus_space_handle_t bsh
,
1036 bus_size_t offset
, uint32_t value
, bus_size_t count
)
1040 __shpcic_io_write_4(bsh
, offset
, value
);
1046 shpcic_mem_set_region_1(void *v
, bus_space_handle_t bsh
,
1047 bus_size_t offset
, uint8_t value
, bus_size_t count
)
1051 __shpcic_mem_write_1(bsh
, offset
, value
);
1057 shpcic_mem_set_region_2(void *v
, bus_space_handle_t bsh
,
1058 bus_size_t offset
, uint16_t value
, bus_size_t count
)
1062 __shpcic_mem_write_2(bsh
, offset
, value
);
1068 shpcic_mem_set_region_4(void *v
, bus_space_handle_t bsh
,
1069 bus_size_t offset
, uint32_t value
, bus_size_t count
)
1073 __shpcic_mem_write_4(bsh
, offset
, value
);
1082 shpcic_io_copy_region_1(void *v
, bus_space_handle_t bsh1
,
1083 bus_size_t off1
, bus_space_handle_t bsh2
, bus_size_t off2
, bus_size_t count
)
1085 u_long addr1
= bsh1
+ off1
;
1086 u_long addr2
= bsh2
+ off2
;
1089 if (addr1
>= addr2
) { /* src after dest: copy forward */
1091 value
= __shpcic_io_read_1(bsh1
, off1
);
1092 __shpcic_io_write_1(bsh2
, off2
, value
);
1096 } else { /* dest after src: copy backwards */
1097 off1
+= (count
- 1) * 1;
1098 off2
+= (count
- 1) * 1;
1100 value
= __shpcic_io_read_1(bsh1
, off1
);
1101 __shpcic_io_write_1(bsh2
, off2
, value
);
1109 shpcic_io_copy_region_2(void *v
, bus_space_handle_t bsh1
,
1110 bus_size_t off1
, bus_space_handle_t bsh2
, bus_size_t off2
, bus_size_t count
)
1112 u_long addr1
= bsh1
+ off1
;
1113 u_long addr2
= bsh2
+ off2
;
1116 if (addr1
>= addr2
) { /* src after dest: copy forward */
1118 value
= __shpcic_io_read_2(bsh1
, off1
);
1119 __shpcic_io_write_2(bsh2
, off2
, value
);
1123 } else { /* dest after src: copy backwards */
1124 off1
+= (count
- 1) * 2;
1125 off2
+= (count
- 1) * 2;
1127 value
= __shpcic_io_read_2(bsh1
, off1
);
1128 __shpcic_io_write_2(bsh2
, off2
, value
);
1136 shpcic_io_copy_region_4(void *v
, bus_space_handle_t bsh1
,
1137 bus_size_t off1
, bus_space_handle_t bsh2
, bus_size_t off2
, bus_size_t count
)
1139 u_long addr1
= bsh1
+ off1
;
1140 u_long addr2
= bsh2
+ off2
;
1143 if (addr1
>= addr2
) { /* src after dest: copy forward */
1145 value
= __shpcic_io_read_4(bsh1
, off1
);
1146 __shpcic_io_write_4(bsh2
, off2
, value
);
1150 } else { /* dest after src: copy backwards */
1151 off1
+= (count
- 1) * 4;
1152 off2
+= (count
- 1) * 4;
1154 value
= __shpcic_io_read_4(bsh1
, off1
);
1155 __shpcic_io_write_4(bsh2
, off2
, value
);
1163 shpcic_mem_copy_region_1(void *v
, bus_space_handle_t bsh1
,
1164 bus_size_t off1
, bus_space_handle_t bsh2
, bus_size_t off2
, bus_size_t count
)
1166 u_long addr1
= bsh1
+ off1
;
1167 u_long addr2
= bsh2
+ off2
;
1170 if (addr1
>= addr2
) { /* src after dest: copy forward */
1172 value
= __shpcic_mem_read_1(bsh1
, off1
);
1173 __shpcic_mem_write_1(bsh2
, off2
, value
);
1177 } else { /* dest after src: copy backwards */
1178 off1
+= (count
- 1) * 1;
1179 off2
+= (count
- 1) * 1;
1181 value
= __shpcic_mem_read_1(bsh1
, off1
);
1182 __shpcic_mem_write_1(bsh2
, off2
, value
);
1190 shpcic_mem_copy_region_2(void *v
, bus_space_handle_t bsh1
,
1191 bus_size_t off1
, bus_space_handle_t bsh2
, bus_size_t off2
, bus_size_t count
)
1193 u_long addr1
= bsh1
+ off1
;
1194 u_long addr2
= bsh2
+ off2
;
1197 if (addr1
>= addr2
) { /* src after dest: copy forward */
1199 value
= __shpcic_mem_read_2(bsh1
, off1
);
1200 __shpcic_mem_write_2(bsh2
, off2
, value
);
1204 } else { /* dest after src: copy backwards */
1205 off1
+= (count
- 1) * 2;
1206 off2
+= (count
- 1) * 2;
1208 value
= __shpcic_mem_read_2(bsh1
, off1
);
1209 __shpcic_mem_write_2(bsh2
, off2
, value
);
1217 shpcic_mem_copy_region_4(void *v
, bus_space_handle_t bsh1
,
1218 bus_size_t off1
, bus_space_handle_t bsh2
, bus_size_t off2
, bus_size_t count
)
1220 u_long addr1
= bsh1
+ off1
;
1221 u_long addr2
= bsh2
+ off2
;
1224 if (addr1
>= addr2
) { /* src after dest: copy forward */
1226 value
= __shpcic_mem_read_4(bsh1
, off1
);
1227 __shpcic_mem_write_4(bsh2
, off2
, value
);
1231 } else { /* dest after src: copy backwards */
1232 off1
+= (count
- 1) * 4;
1233 off2
+= (count
- 1) * 4;
1235 value
= __shpcic_mem_read_4(bsh1
, off1
);
1236 __shpcic_mem_write_4(bsh2
, off2
, value
);