/***************************************************************************/
/*                             Druckersoftware                             */
/*                    Copyright (C) Carl Valentin GmbH                     */
/***************************************************************************/

/*
 * KM_DmaChan_MappedIo.h
 *
 *  Created on: May 31, 2016
 *      Author: preitinger
 */

#ifndef KM_DMACHAN_MAPPEDIO_H_
#define KM_DMACHAN_MAPPEDIO_H_

/*. IMPORT ================================================================*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/compiler.h>
#include <linux/bug.h>
#include <linux/stddef.h>
#include <linux/platform_data/edma.h>
/*. ENDIMPORT =============================================================*/

/*. EXPORT ================================================================*/

/*-------------------------------- Makros ---------------------------------*/

/*--------------------------- Typdeklarationen ----------------------------*/

typedef struct SDmaChan_MappedIo
{
	// public: see functions beneath type declaration

	// private:
	struct io_mapping* _map;
	void __iomem* _a;
	unsigned long _size;
} DmaChan_MappedIo;

/*------------------------------ Prototypen -------------------------------*/

int
DmaChan_MappedIo_create(DmaChan_MappedIo* this, phys_addr_t physAddr, unsigned long size);

void
DmaChan_MappedIo_delete(DmaChan_MappedIo* this);

void
DmaChan_MappedIo_set32(DmaChan_MappedIo* this, unsigned long off, uint32_t value);

uint32_t
DmaChan_MappedIo_get32(DmaChan_MappedIo* this, unsigned long off);

void
DmaChan_MappedIo_set16(DmaChan_MappedIo* this, unsigned long off, uint16_t value);

uint16_t
DmaChan_MappedIo_get16(DmaChan_MappedIo* this, unsigned long off);

void DmaChan_MappedIo_set(DmaChan_MappedIo* this, unsigned long offTo, const void* from, size_t count);

void DmaChan_MappedIo_get(DmaChan_MappedIo* this, unsigned long offFrom, void* to, size_t count);

/*------------------------ Konstantendeklarationen ------------------------*/

/*. ENDEXPORT =============================================================*/

#endif /* KM_DMACHAN_MAPPEDIO_H_ */
