blob: dccae26805b0a38c4b09ecd836a12de422bb1a52 [file] [log] [blame]
Robin Getz96f10502009-09-24 14:11:24 +00001/*
Mike Frysingercfbf1672010-02-16 04:03:18 -05002 * Copyright 2004-2010 Analog Devices Inc.
Robin Getz96f10502009-09-24 14:11:24 +00003 *
4 * Licensed under the GPL-2 or later.
5 */
6
Bryan Wu1394f032007-05-06 14:50:22 -07007#ifndef _BFIN_IO_H
8#define _BFIN_IO_H
9
Bryan Wu1394f032007-05-06 14:50:22 -070010#include <linux/compiler.h>
Mike Frysingercfbf1672010-02-16 04:03:18 -050011#include <linux/types.h>
12#include <asm/byteorder.h>
Bryan Wu1394f032007-05-06 14:50:22 -070013
Mike Frysingercfbf1672010-02-16 04:03:18 -050014#define DECLARE_BFIN_RAW_READX(size, type, asm, asm_sign) \
15static inline type __raw_read##size(const volatile void __iomem *addr) \
16{ \
17 unsigned int val; \
18 int tmp; \
19 __asm__ __volatile__ ( \
20 "cli %1;" \
21 "NOP; NOP; SSYNC;" \
22 "%0 = "#asm" [%2] "#asm_sign";" \
23 "sti %1;" \
24 : "=d"(val), "=d"(tmp) \
25 : "a"(addr) \
26 ); \
27 return (type) val; \
Bryan Wu1394f032007-05-06 14:50:22 -070028}
Mike Frysingercfbf1672010-02-16 04:03:18 -050029DECLARE_BFIN_RAW_READX(b, u8, b, (z))
30#define __raw_readb __raw_readb
31DECLARE_BFIN_RAW_READX(w, u16, w, (z))
32#define __raw_readw __raw_readw
33DECLARE_BFIN_RAW_READX(l, u32, , )
34#define __raw_readl __raw_readl
Bryan Wu1394f032007-05-06 14:50:22 -070035
Bryan Wub7b2d3442007-10-09 15:09:49 +080036extern void outsb(unsigned long port, const void *addr, unsigned long count);
37extern void outsw(unsigned long port, const void *addr, unsigned long count);
Michael Hennerich59069672008-05-17 16:38:52 +080038extern void outsw_8(unsigned long port, const void *addr, unsigned long count);
Bryan Wub7b2d3442007-10-09 15:09:49 +080039extern void outsl(unsigned long port, const void *addr, unsigned long count);
Mike Frysingercfbf1672010-02-16 04:03:18 -050040#define outsb outsb
41#define outsw outsw
42#define outsl outsl
Bryan Wu1394f032007-05-06 14:50:22 -070043
Bryan Wub7b2d3442007-10-09 15:09:49 +080044extern void insb(unsigned long port, void *addr, unsigned long count);
45extern void insw(unsigned long port, void *addr, unsigned long count);
Michael Hennerich59069672008-05-17 16:38:52 +080046extern void insw_8(unsigned long port, void *addr, unsigned long count);
Bryan Wub7b2d3442007-10-09 15:09:49 +080047extern void insl(unsigned long port, void *addr, unsigned long count);
Michael Hennerich5c91fb92007-11-17 23:46:58 +080048extern void insl_16(unsigned long port, void *addr, unsigned long count);
Mike Frysingercfbf1672010-02-16 04:03:18 -050049#define insb insb
50#define insw insw
51#define insl insl
Michael Hennerich23ee9682007-05-21 18:09:17 +080052
Bryan Wub7b2d3442007-10-09 15:09:49 +080053extern void dma_outsb(unsigned long port, const void *addr, unsigned short count);
54extern void dma_outsw(unsigned long port, const void *addr, unsigned short count);
55extern void dma_outsl(unsigned long port, const void *addr, unsigned short count);
Michael Hennerich23ee9682007-05-21 18:09:17 +080056
Bryan Wub7b2d3442007-10-09 15:09:49 +080057extern void dma_insb(unsigned long port, void *addr, unsigned short count);
58extern void dma_insw(unsigned long port, void *addr, unsigned short count);
59extern void dma_insl(unsigned long port, void *addr, unsigned short count);
Bryan Wu1394f032007-05-06 14:50:22 -070060
Mike Frysingercfbf1672010-02-16 04:03:18 -050061/**
62 * I/O write barrier
63 *
64 * Ensure ordering of I/O space writes. This will make sure that writes
65 * following the barrier will arrive after all previous writes.
Bryan Wu1394f032007-05-06 14:50:22 -070066 */
Mike Frysingercfbf1672010-02-16 04:03:18 -050067#define mmiowb() do { SSYNC(); wmb(); } while (0)
Bryan Wu1394f032007-05-06 14:50:22 -070068
Mike Frysingercfbf1672010-02-16 04:03:18 -050069#include <asm-generic/io.h>
Bryan Wu1394f032007-05-06 14:50:22 -070070
71#endif