zynq: remove GPIO driver

This commit is contained in:
Johannes Schlatow
2017-03-02 18:48:58 +01:00
committed by Norman Feske
parent 458c013634
commit 300b0ea022
9 changed files with 98 additions and 464 deletions

View File

@@ -1,22 +0,0 @@
/*
* \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

@@ -1,32 +0,0 @@
/*
* \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

@@ -1,30 +0,0 @@
/*
* \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) __attribute__((deprecated))
: Genode::Connection<Session>(session("ram_quota=8K, gpio=%zd", gpio_number)),
Session_client(cap()) { }
};
}
#endif /* _INCLUDE__GPIO_SESSION__CONNECTION_H_ */

View File

@@ -1,54 +0,0 @@
/*
* \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,98 @@
/*
* \brief Gpio Driver for Zynq
* \author Mark Albers
* \date 2015-04-02
*/
/*
* Copyright (C) 2011-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _GPIO_H_
#define _GPIO_H_
#include <base/attached_io_mem_dataspace.h>
#include <util/mmio.h>
namespace Gpio {
using namespace Genode;
class Zynq_Gpio;
}
struct Gpio::Zynq_Gpio : Attached_io_mem_dataspace, Mmio
{
Zynq_Gpio(Genode::Env &env, Genode::addr_t const mmio_base, Genode::size_t const mmio_size) :
Genode::Attached_io_mem_dataspace(env, mmio_base, mmio_size),
Genode::Mmio((Genode::addr_t)local_addr<void>())
{ }
~Zynq_Gpio()
{ }
/*
* Registers
*/
struct GPIO_DATA : Register<0x00, 32> {};
struct GPIO_TRI : Register<0x04, 32> {};
struct GPIO2_DATA : Register<0x08, 32> {};
struct GPIO2_TRI : Register<0x0C, 32> {};
struct GIER : Register<0x011C, 32>
{
struct Global_Interrupt_Enable : Bitfield<31,1> {};
};
struct IP_IER : Register<0x0128, 32>
{
struct Channel_1_Interrupt_Enable : Bitfield<0,1> {};
struct Channel_2_Interrupt_Enable : Bitfield<1,1> {};
};
struct IP_ISR : Register<0x120, 32>
{
struct Channel_1_Interrupt_Status : Bitfield<0,1> {};
struct Channel_2_Interrupt_Status : Bitfield<1,1> {};
};
/*
* Functions
*/
Genode::uint8_t gpio_read(bool isChannel2)
{
if (isChannel2)
{
write<GPIO2_TRI>(0xffffffff);
return read<GPIO2_DATA>();
}
else
{
write<GPIO_TRI>(0xffffffff);
return read<GPIO_DATA>();
}
}
bool gpio_write(Genode::uint8_t data, bool isChannel2)
{
if (isChannel2)
{
write<GPIO2_TRI>(0);
write<GPIO2_DATA>(data);
}
else
{
write<GPIO_TRI>(0);
write<GPIO_DATA>(data);
}
return true;
}
};
#endif // _GPIO_H_

View File

@@ -1,76 +0,0 @@
/*
* \brief Gpio Driver for Zynq
* \author Mark Albers
* \date 2015-03-12
*/
/*
* 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 _DRIVER_H_
#define _DRIVER_H_
#include <io_mem_session/connection.h>
#include <timer_session/connection.h>
#include <util/mmio.h>
#include <vector>
#include <new>
#include <drivers/board_base.h>
#include "gpio.h"
namespace Gpio {
using namespace Genode;
class Driver;
}
class Gpio::Driver
{
private:
std::vector<Zynq_Gpio*> _gpio_bank;
Driver(std::vector<Genode::addr_t> addr)
{
for (unsigned i = 0; i < addr.size(); i++)
{
_gpio_bank.push_back(new Zynq_Gpio(addr[i], Genode::Board_base::GPIO_MMIO_SIZE));
}
}
~Driver()
{
for (std::vector<Zynq_Gpio*>::iterator it = _gpio_bank.begin() ; it != _gpio_bank.end(); ++it)
{
delete (*it);
}
_gpio_bank.clear();
}
public:
static Driver& factory(std::vector<Genode::addr_t> addr);
Genode::uint8_t read(unsigned gpio, bool isChannel2)
{
Zynq_Gpio *gpio_reg = _gpio_bank[gpio];
return gpio_reg->gpio_read(isChannel2);
}
bool write(unsigned gpio, Genode::uint8_t data, bool isChannel2)
{
Zynq_Gpio *gpio_reg = _gpio_bank[gpio];
return gpio_reg->gpio_write(data, isChannel2);
}
};
Gpio::Driver& Gpio::Driver::factory(std::vector<Genode::addr_t> addr)
{
static Gpio::Driver driver(addr);
return driver;
}
#endif /* _DRIVER_H_ */

View File

@@ -1,98 +0,0 @@
/*
* \brief Gpio Driver for Zynq
* \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 _GPIO_H_
#define _GPIO_H_
#include <os/attached_io_mem_dataspace.h>
#include <util/mmio.h>
namespace Gpio {
using namespace Genode;
class Zynq_Gpio;
}
struct Gpio::Zynq_Gpio : Attached_io_mem_dataspace, Mmio
{
Zynq_Gpio(Genode::addr_t const mmio_base, Genode::size_t const mmio_size) :
Genode::Attached_io_mem_dataspace(mmio_base, mmio_size),
Genode::Mmio((Genode::addr_t)local_addr<void>())
{ }
~Zynq_Gpio()
{ }
/*
* Registers
*/
struct GPIO_DATA : Register<0x00, 32> {};
struct GPIO_TRI : Register<0x04, 32> {};
struct GPIO2_DATA : Register<0x08, 32> {};
struct GPIO2_TRI : Register<0x0C, 32> {};
struct GIER : Register<0x011C, 32>
{
struct Global_Interrupt_Enable : Bitfield<31,1> {};
};
struct IP_IER : Register<0x0128, 32>
{
struct Channel_1_Interrupt_Enable : Bitfield<0,1> {};
struct Channel_2_Interrupt_Enable : Bitfield<1,1> {};
};
struct IP_ISR : Register<0x120, 32>
{
struct Channel_1_Interrupt_Status : Bitfield<0,1> {};
struct Channel_2_Interrupt_Status : Bitfield<1,1> {};
};
/*
* Functions
*/
Genode::uint8_t gpio_read(bool isChannel2)
{
if (isChannel2)
{
write<GPIO2_TRI>(0xffffffff);
return read<GPIO2_DATA>();
}
else
{
write<GPIO_TRI>(0xffffffff);
return read<GPIO_DATA>();
}
}
bool gpio_write(Genode::uint8_t data, bool isChannel2)
{
if (isChannel2)
{
write<GPIO2_TRI>(0);
write<GPIO2_DATA>(data);
}
else
{
write<GPIO_TRI>(0);
write<GPIO_DATA>(data);
}
return true;
}
};
#endif // _GPIO_H_

View File

@@ -1,139 +0,0 @@
/*
* \brief Gpio Driver for Zynq
* \author Mark Albers
* \date 2015-03-30
*/
/*
* 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.
*/
#include <gpio_session/zynq/gpio_session.h>
#include <cap_session/connection.h>
#include <dataspace/client.h>
#include <base/log.h>
#include <base/sleep.h>
#include <base/heap.h>
#include <root/component.h>
#include <os/static_root.h>
#include <os/config.h>
#include <vector>
#include "driver.h"
namespace Gpio {
using namespace Genode;
class Session_component;
class Root;
};
class Gpio::Session_component : public Genode::Rpc_object<Gpio::Session>
{
private:
Driver &_driver;
unsigned _number;
public:
Session_component(Driver &driver, unsigned gpio_number)
: _driver(driver), _number(gpio_number) {}
virtual Genode::uint32_t read(bool isChannel2)
{
return _driver.read(_number, isChannel2);
}
virtual bool write(Genode::uint32_t data, bool isChannel2)
{
return _driver.write(_number, data, isChannel2);
}
};
class Gpio::Root : public Genode::Root_component<Gpio::Session_component>
{
private:
Driver &_driver;
protected:
Session_component *_create_session(const char *args)
{
unsigned number = Genode::Arg_string::find_arg(args, "gpio").ulong_value(0);
Genode::size_t ram_quota = Genode::Arg_string::find_arg(args, "ram_quota").ulong_value(0);
if (ram_quota < sizeof(Session_component)) {
Genode::warning("Insufficient dontated ram_quota (", ram_quota, " bytes), "
"require ", sizeof(Session_component), " bytes");
throw Genode::Root::Quota_exceeded();
}
return new (md_alloc()) Session_component(_driver, number);
}
public:
Root(Genode::Rpc_entrypoint *session_ep,
Genode::Allocator *md_alloc, Driver &driver)
:
Genode::Root_component<Gpio::Session_component>(session_ep, md_alloc),
_driver(driver)
{ }
};
int main(int, char **)
{
using namespace Gpio;
Genode::log("Zynq Gpio driver");
/*
* Read config
*/
std::vector<Genode::addr_t> addr;
try {
Genode::Xml_node gpio_node = Genode::config()->xml_node().sub_node("gpio");
for (unsigned i = 0; ;i++, gpio_node = gpio_node.next("gpio"))
{
addr.push_back(0);
gpio_node.attribute("addr").value(&addr[i]);
Genode::log("Gpio with mio address ", Genode::Hex(addr[i]), " added.");
if (gpio_node.is_last("gpio")) break;
}
}
catch (Genode::Xml_node::Nonexistent_sub_node) {
Genode::warning("No Gpio config");
}
/*
* Create Driver
*/
Driver &driver = Driver::factory(addr);
addr.clear();
/*
* Initialize server entry point
*/
enum { STACK_SIZE = 4096 };
static Cap_connection cap;
Sliced_heap sliced_heap(env()->ram_session(), env()->rm_session());
static Rpc_entrypoint ep(&cap, STACK_SIZE, "gpio_ep");
static Gpio::Root gpio_root(&ep, &sliced_heap, driver);
/*
* Announce service
*/
env()->parent()->announce(ep.manage(&gpio_root));
Genode::sleep_forever();
return 0;
}

View File

@@ -1,13 +0,0 @@
# \brief Gpio specific for zynq systems
# \author Mark Albers
# \date 2015-03-30
TARGET = zynq_gpio_drv
SRC_CC = main.cc
LIBS = base config posix stdcxx
INC_DIR += $(PRG_DIR)
REQUIRES += zynq
vpath main.cc $(PRG_DIR)