zynq: add gpio, i2c and vdma drivers

This commit is contained in:
Mark
2016-03-24 17:03:20 +01:00
committed by Norman Feske
parent 2e7bb650dc
commit 6418f34082
24 changed files with 1734 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
/*
* \brief Zynq Gpio session capability type
* \author Mark Albers
* \date 2015-04-02
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__GPIO_SESSION__CAPABILITY_H_
#define _INCLUDE__GPIO_SESSION__CAPABILITY_H_
#include <base/capability.h>
#include <gpio_session/zynq/gpio_session.h>
namespace Gpio { typedef Genode::Capability<Session> Session_capability; }
#endif /* _INCLUDE__GPIO_SESSION__CAPABILITY_H_ */

View File

@@ -0,0 +1,32 @@
/*
* \brief Client-side Zynq Gpio session interface
* \author Mark Albers
* \date 2015-04-02
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__GPIO_SESSION_H__CLIENT_H_
#define _INCLUDE__GPIO_SESSION_H__CLIENT_H_
#include <gpio_session/zynq/capability.h>
#include <base/rpc_client.h>
namespace Gpio {
struct Session_client : Genode::Rpc_client<Session>
{
explicit Session_client(Session_capability session)
: Genode::Rpc_client<Session>(session) { }
bool write(Genode::uint32_t data, bool isChannel2 = false) { return call<Rpc_write>(data, isChannel2); }
Genode::uint32_t read(bool isChannel2 = false) { return call<Rpc_read>(isChannel2); }
};
}
#endif /* _INCLUDE__GPIO_SESSION_H__CLIENT_H_ */

View File

@@ -0,0 +1,30 @@
/*
* \brief Connection to Zynq Gpio session
* \author Mark Albers
* \date 2015-04-02
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__GPIO_SESSION__CONNECTION_H_
#define _INCLUDE__GPIO_SESSION__CONNECTION_H_
#include <gpio_session/zynq/client.h>
#include <base/connection.h>
namespace Gpio {
struct Connection : Genode::Connection<Session>, Session_client
{
Connection(unsigned gpio_number)
: Genode::Connection<Session>(session("ram_quota=8K, gpio=%zd", gpio_number)),
Session_client(cap()) { }
};
}
#endif /* _INCLUDE__GPIO_SESSION__CONNECTION_H_ */

View File

@@ -0,0 +1,54 @@
/*
* \brief Zynq Gpio session interface
* \author Mark Albers
* \date 2015-04-02
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__GPIO_SESSION__GPIO_SESSION_H_
#define _INCLUDE__GPIO_SESSION__GPIO_SESSION_H_
#include <base/signal.h>
#include <session/session.h>
namespace Gpio {
struct Session : Genode::Session
{
static const char *service_name() { return "Gpio"; }
virtual ~Session() { }
/**
* Write
*
* \param data
*/
virtual bool write(Genode::uint32_t data, bool isChannel2) = 0;
/**
* Read
*
* \return data
*/
virtual Genode::uint32_t read(bool isChannel2) = 0;
/*******************
** RPC interface **
*******************/
GENODE_RPC(Rpc_write, bool, write, Genode::uint32_t, bool);
GENODE_RPC(Rpc_read, Genode::uint32_t, read, bool);
GENODE_RPC_INTERFACE(Rpc_write, Rpc_read);
};
}
#endif /* _INCLUDE__GPIO_SESSION__GPIO_SESSION_H_ */

View File

@@ -0,0 +1,25 @@
/*
* \brief I2C bus driver session capability type
* \author Mark Albers
* \date 2015-04-13
* \author Alexander Tarasikov <alexander.tarasikov@gmail.com>
* \date 2012-09-18
*/
/*
* Copyright (C) 2012 Ksys Labs LLC
* Copyright (C) 2012-2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__I2C_SESSION__CAPABILITY_H_
#define _INCLUDE__I2C_SESSION__CAPABILITY_H_
#include <base/capability.h>
#include <i2c_session/zynq/i2c_session.h>
namespace I2C { typedef Genode::Capability<Session> Session_capability; }
#endif /* _INCLUDE__I2C_SESSION__CAPABILITY_H_ */

View File

@@ -0,0 +1,43 @@
/*
* \brief Client-side i2c interface
* \author Mark Albers
* \date 2015-04-13
* \author Alexander Tarasikov <alexander.tarasikov@gmail.com>
* \date 2012-09-18
*/
/*
* Copyright (C) 2012 Ksys Labs LLC
* Copyright (C) 2012-2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__I2C_SESSION__CLIENT_H_
#define _INCLUDE__I2C_SESSION__CLIENT_H_
#include <i2c_session/zynq/capability.h>
#include <base/rpc_client.h>
namespace I2C {
struct Session_client : Genode::Rpc_client<Session>
{
explicit Session_client(Session_capability session)
: Genode::Rpc_client<Session>(session) { }
bool read_byte_16bit_reg(Genode::uint8_t adr, Genode::uint16_t reg, Genode::uint8_t *data)
{
return call<Rpc_read_byte_16bit_reg>(adr, reg, data);
}
bool write_16bit_reg(Genode::uint8_t adr, Genode::uint16_t reg,
Genode::uint8_t data)
{
return call<Rpc_write_16bit_reg>(adr, reg, data);
}
};
}
#endif /* _INCLUDE__I2C_SESSION__CLIENT_H_ */

View File

@@ -0,0 +1,34 @@
/*
* \brief Connection to i2c service
* \author Mark Albers
* \author Alexander Tarasikov <alexander.tarasikov@gmail.com>
* \date 2012-09-18
*/
/*
* Copyright (C) 2012 Ksys Labs LLC
* Copyright (C) 2012 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__I2C_SESSION__CONNECTION_H_
#define _INCLUDE__I2C_SESSION__CONNECTION_H_
#include <i2c_session/zynq/client.h>
#include <base/connection.h>
namespace I2C {
class Connection : public Genode::Connection<Session>,
public Session_client
{
public:
Connection(unsigned int bus_num) :
Genode::Connection<Session>(session("ram_quota=4K, bus=%zd", bus_num)),
Session_client(cap()) { }
};
}
#endif /* _INCLUDE__I2C_SESSION__CONNECTION_H_ */

View File

@@ -0,0 +1,69 @@
/*
* \brief I2C session interface
* \author Mark Albers
* \date 2015-04-13
* \author Alexander Tarasikov <alexander.tarasikov@gmail.com>
* \date 2012-09-18
*/
/*
* Copyright (C) 2012 Ksys Labs LLC
* Copyright (C) 2012-2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__I2C_SESSION__I2C_SESSION_H_
#define _INCLUDE__I2C_SESSION__I2C_SESSION_H_
#include <base/signal.h>
#include <session/session.h>
namespace I2C {
struct Session : Genode::Session
{
static const char *service_name() { return "I2C"; }
virtual ~Session() { }
/**
* Read a single byte from a 16 bit register of the device
*
* \param adr the address of the device on the bus
* \param reg the register to read
* \param data the read value
*
*/
virtual bool read_byte_16bit_reg(Genode::uint8_t adr, Genode::uint16_t reg, Genode::uint8_t *data) = 0;
/**
* Write a single data byte to a 16 bit register
*
* \param adr the address of the device on the bus
* \param reg the register to write
* \param data the value to write
*
*/
virtual bool write_16bit_reg(Genode::uint8_t adr, Genode::uint16_t reg,
Genode::uint8_t data) = 0;
/*********************
** RPC declaration **
*********************/
GENODE_RPC(Rpc_read_byte_16bit_reg, bool, read_byte_16bit_reg,
Genode::uint8_t, Genode::uint16_t, Genode::uint8_t*);
GENODE_RPC(Rpc_write_16bit_reg, bool, write_16bit_reg,
Genode::uint8_t, Genode::uint16_t, Genode::uint8_t);
GENODE_RPC_INTERFACE(
Rpc_read_byte_16bit_reg,
Rpc_write_16bit_reg
);
};
}
#endif /* _INCLUDE__I2C_SESSION__I2C_SESSION_H_ */

View File

@@ -0,0 +1,22 @@
/*
* \brief Zynq VDMA session capability type
* \author Mark Albers
* \date 2015-04-13
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__VDMA_SESSION__CAPABILITY_H_
#define _INCLUDE__VDMA_SESSION__CAPABILITY_H_
#include <base/capability.h>
#include <vdma_session/zynq/vdma_session.h>
namespace Vdma { typedef Genode::Capability<Session> Session_capability; }
#endif /* _INCLUDE__VDMA_SESSION__CAPABILITY_H_ */

View File

@@ -0,0 +1,42 @@
/*
* \brief Client-side Zynq VDMA session interface
* \author Mark Albers
* \date 2015-04-13
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__VDMA_SESSION_H__CLIENT_H_
#define _INCLUDE__VDMA_SESSION_H__CLIENT_H_
#include <vdma_session/zynq/capability.h>
#include <base/rpc_client.h>
#define S2MM false
#define MM2S true
namespace Vdma {
struct Session_client : Genode::Rpc_client<Session>
{
explicit Session_client(Session_capability session)
: Genode::Rpc_client<Session>(session) { }
bool setConfig(Genode::uint32_t data, bool isMM2S) { return call<Rpc_setConfig>(data, isMM2S); }
bool setStride(Genode::uint16_t data, bool isMM2S) { return call<Rpc_setStride>(data, isMM2S); }
bool setWidth(Genode::uint16_t data, bool isMM2S) { return call<Rpc_setWidth>(data, isMM2S); }
bool setHeight(Genode::uint16_t data, bool isMM2S) { return call<Rpc_setHeight>(data, isMM2S); }
bool setAddr(Genode::uint32_t data, bool isMM2S) { return call<Rpc_setAddr>(data, isMM2S); }
};
}
#endif /* _INCLUDE__VDMA_SESSION_H__CLIENT_H_ */

View File

@@ -0,0 +1,30 @@
/*
* \brief Connection to Zynq VDMA session
* \author Mark Albers
* \date 2015-04-13
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__VDMA_SESSION__CONNECTION_H_
#define _INCLUDE__VDMA_SESSION__CONNECTION_H_
#include <vdma_session/zynq/client.h>
#include <base/connection.h>
namespace Vdma {
struct Connection : Genode::Connection<Session>, Session_client
{
Connection(unsigned vdma_number)
: Genode::Connection<Session>(session("ram_quota=8K, vdma=%zd", vdma_number)),
Session_client(cap()) { }
};
}
#endif /* _INCLUDE__VDMA_SESSION__CONNECTION_H_ */

View File

@@ -0,0 +1,54 @@
/*
* \brief Zynq VDMA session interface
* \author Mark Albers
* \date 2015-04-13
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__VDMA_SESSION__VDMA_SESSION_H_
#define _INCLUDE__VDMA_SESSION__VDMA_SESSION_H_
#include <base/signal.h>
#include <session/session.h>
namespace Vdma {
struct Session : Genode::Session
{
static const char *service_name() { return "Vdma"; }
virtual ~Session() { }
virtual bool setConfig(Genode::uint32_t data, bool isMM2S) = 0;
virtual bool setStride(Genode::uint16_t data, bool isMM2S) = 0;
virtual bool setWidth(Genode::uint16_t data, bool isMM2S) = 0;
virtual bool setHeight(Genode::uint16_t data, bool isMM2S) = 0;
virtual bool setAddr(Genode::uint32_t data, bool isMM2S) = 0;
/*******************
** RPC interface **
*******************/
GENODE_RPC(Rpc_setConfig, bool, setConfig, Genode::uint32_t, bool);
GENODE_RPC(Rpc_setStride, bool, setStride, Genode::uint16_t, bool);
GENODE_RPC(Rpc_setWidth, bool, setWidth, Genode::uint16_t, bool);
GENODE_RPC(Rpc_setHeight, bool, setHeight, Genode::uint16_t, bool);
GENODE_RPC(Rpc_setAddr, bool, setAddr, Genode::uint32_t, bool);
GENODE_RPC_INTERFACE(Rpc_setConfig, Rpc_setStride, Rpc_setWidth,
Rpc_setHeight, Rpc_setAddr);
};
}
#endif /* _INCLUDE__VDMA_SESSION__VDMA_SESSION_H_ */