gpio: remove env deprecated warnings
And while there, remove usage of Server library. Issue #2280.
This commit is contained in:
parent
4f8804c334
commit
0c7200a0fe
|
@ -27,23 +27,24 @@
|
||||||
#ifndef _INCLUDE__GPIO__CONFIG_H_
|
#ifndef _INCLUDE__GPIO__CONFIG_H_
|
||||||
#define _INCLUDE__GPIO__CONFIG_H_
|
#define _INCLUDE__GPIO__CONFIG_H_
|
||||||
|
|
||||||
|
/* Genode includes */
|
||||||
#include <base/exception.h>
|
#include <base/exception.h>
|
||||||
#include <os/config.h>
|
|
||||||
#include <gpio/driver.h>
|
#include <gpio/driver.h>
|
||||||
|
#include <util/xml_node.h>
|
||||||
|
|
||||||
namespace Gpio {
|
namespace Gpio {
|
||||||
|
|
||||||
class Invalid_gpio_number : Genode::Exception {};
|
class Invalid_gpio_number : Genode::Exception {};
|
||||||
class Invalid_mode : Genode::Exception {};
|
class Invalid_mode : Genode::Exception {};
|
||||||
|
|
||||||
static void process_config(Gpio::Driver &driver);
|
static void process_config(Genode::Xml_node const &config, Gpio::Driver &driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Gpio::process_config(Gpio::Driver &driver)
|
void Gpio::process_config(Genode::Xml_node const &config, Gpio::Driver &driver)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Genode::Xml_node gpio_node = Genode::config()->xml_node().sub_node("gpio");
|
Genode::Xml_node gpio_node = config.sub_node("gpio");
|
||||||
|
|
||||||
for (;; gpio_node = gpio_node.next("gpio")) {
|
for (;; gpio_node = gpio_node.next("gpio")) {
|
||||||
unsigned num = 0;
|
unsigned num = 0;
|
||||||
|
|
|
@ -32,18 +32,18 @@ namespace Gpio { class Odroid_x2_driver; }
|
||||||
class Gpio::Odroid_x2_driver : public Driver
|
class Gpio::Odroid_x2_driver : public Driver
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Server::Entrypoint &_ep;
|
|
||||||
Reg _reg1;
|
Reg _reg1;
|
||||||
Reg _reg2;
|
Reg _reg2;
|
||||||
Reg _reg3;
|
Reg _reg3;
|
||||||
Reg _reg4;
|
Reg _reg4;
|
||||||
Genode::Irq_connection _irq;
|
Genode::Irq_connection _irq;
|
||||||
Genode::Signal_rpc_member<Odroid_x2_driver> _dispatcher;
|
Genode::Signal_handler<Odroid_x2_driver> _dispatcher;
|
||||||
Genode::Signal_context_capability _sig_cap[MAX_PINS];
|
Genode::Signal_context_capability _sig_cap[MAX_PINS];
|
||||||
bool _irq_enabled[MAX_PINS];
|
bool _irq_enabled[MAX_PINS];
|
||||||
bool _async;
|
bool _async;
|
||||||
|
|
||||||
void _handle(unsigned)
|
void _handle()
|
||||||
{
|
{
|
||||||
handle_irq();
|
handle_irq();
|
||||||
}
|
}
|
||||||
|
@ -70,14 +70,14 @@ class Gpio::Odroid_x2_driver : public Driver
|
||||||
|
|
||||||
int _gpio_index(int gpio) { return gpio & 0x1f; }
|
int _gpio_index(int gpio) { return gpio & 0x1f; }
|
||||||
|
|
||||||
Odroid_x2_driver(Server::Entrypoint &ep)
|
Odroid_x2_driver(Genode::Env &env)
|
||||||
: _ep(ep),
|
:
|
||||||
_reg1(0x11400000, 1000),
|
_reg1(env, 0x11400000, 1000),
|
||||||
_reg2(0x11000000, 1000),
|
_reg2(env, 0x11000000, 1000),
|
||||||
_reg3(0x03860000, 1000),
|
_reg3(env, 0x03860000, 1000),
|
||||||
_reg4(0x106E0000, 1000),
|
_reg4(env, 0x106E0000, 1000),
|
||||||
_irq(104),
|
_irq(env, 104),
|
||||||
_dispatcher(ep, *this, &Odroid_x2_driver::_handle),
|
_dispatcher(env.ep(), *this, &Odroid_x2_driver::_handle),
|
||||||
_async(false)
|
_async(false)
|
||||||
{
|
{
|
||||||
_irq.sigh(_dispatcher);
|
_irq.sigh(_dispatcher);
|
||||||
|
@ -87,7 +87,7 @@ class Gpio::Odroid_x2_driver : public Driver
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static Odroid_x2_driver& factory(Server::Entrypoint &ep);
|
static Odroid_x2_driver& factory(Genode::Env &env);
|
||||||
|
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
|
@ -218,11 +218,4 @@ class Gpio::Odroid_x2_driver : public Driver
|
||||||
bool gpio_valid(unsigned gpio) { return gpio < (MAX_PINS); }
|
bool gpio_valid(unsigned gpio) { return gpio < (MAX_PINS); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Gpio::Odroid_x2_driver& Gpio::Odroid_x2_driver::factory(Server::Entrypoint &ep)
|
|
||||||
{
|
|
||||||
static Odroid_x2_driver driver(ep);
|
|
||||||
return driver;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _DRIVER_H_ */
|
#endif /* _DRIVER_H_ */
|
||||||
|
|
|
@ -77,8 +77,8 @@ struct Gpio::Reg : Attached_io_mem_dataspace, Mmio
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Reg(addr_t base, size_t size)
|
Reg(Genode::Env &env, addr_t base, size_t size)
|
||||||
: Attached_io_mem_dataspace(base, size),
|
: Attached_io_mem_dataspace(env, base, size),
|
||||||
Mmio((addr_t)local_addr<Reg>()) { }
|
Mmio((addr_t)local_addr<Reg>()) { }
|
||||||
|
|
||||||
void set_direction(int gpio, bool input, Genode::off_t offset)
|
void set_direction(int gpio, bool input, Genode::off_t offset)
|
||||||
|
|
|
@ -14,50 +14,51 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
|
#include <base/attached_rom_dataspace.h>
|
||||||
|
#include <base/component.h>
|
||||||
#include <base/heap.h>
|
#include <base/heap.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <base/sleep.h>
|
|
||||||
#include <cap_session/connection.h>
|
|
||||||
#include <gpio/component.h>
|
#include <gpio/component.h>
|
||||||
#include <gpio/config.h>
|
#include <gpio/config.h>
|
||||||
#include <os/server.h>
|
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include <driver.h>
|
#include <driver.h>
|
||||||
|
|
||||||
|
|
||||||
|
Gpio::Odroid_x2_driver& Gpio::Odroid_x2_driver::factory(Genode::Env &env)
|
||||||
|
{
|
||||||
|
static Odroid_x2_driver driver(env);
|
||||||
|
return driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Main
|
struct Main
|
||||||
{
|
{
|
||||||
Server::Entrypoint &ep;
|
Genode::Env &env;
|
||||||
Genode::Sliced_heap sliced_heap;
|
Genode::Sliced_heap sliced_heap;
|
||||||
Gpio::Odroid_x2_driver &driver;
|
Gpio::Odroid_x2_driver &driver;
|
||||||
Gpio::Root root;
|
Gpio::Root root;
|
||||||
|
|
||||||
Main(Server::Entrypoint &ep)
|
Genode::Attached_rom_dataspace config_rom { env, "config" };
|
||||||
: ep(ep),
|
|
||||||
sliced_heap(Genode::env()->ram_session(), Genode::env()->rm_session()),
|
Main(Genode::Env &env)
|
||||||
driver(Gpio::Odroid_x2_driver::factory(ep)),
|
: env(env),
|
||||||
root(&ep.rpc_ep(), &sliced_heap, driver)
|
sliced_heap(env.ram(), env.rm()),
|
||||||
|
driver(Gpio::Odroid_x2_driver::factory(env)),
|
||||||
|
root(&env.ep().rpc_ep(), &sliced_heap, driver)
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
log("--- Odroid_x2 gpio driver ---");
|
log("--- Odroid_x2 gpio driver ---");
|
||||||
|
|
||||||
Gpio::process_config(driver);
|
Gpio::process_config(config_rom.xml(), driver);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Announce service
|
* Announce service
|
||||||
*/
|
*/
|
||||||
env()->parent()->announce(ep.manage(root));
|
env.parent().announce(env.ep().manage(root));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/************
|
|
||||||
** Server **
|
|
||||||
************/
|
|
||||||
|
|
||||||
namespace Server {
|
void Component::construct(Genode::Env &env) { static Main main(env); }
|
||||||
char const *name() { return "gpio_drv_ep"; }
|
|
||||||
size_t stack_size() { return 16*1024*sizeof(long); }
|
|
||||||
void construct(Entrypoint &ep) { static Main server(ep); }
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
TARGET = gpio_drv
|
TARGET = gpio_drv
|
||||||
REQUIRES = exynos4
|
REQUIRES = exynos4
|
||||||
SRC_CC = main.cc
|
SRC_CC = main.cc
|
||||||
LIBS = base config server
|
LIBS = base
|
||||||
INC_DIR += $(PRG_DIR)
|
INC_DIR += $(PRG_DIR)
|
||||||
|
|
||||||
vpath main.cc $(PRG_DIR)
|
vpath main.cc $(PRG_DIR)
|
||||||
|
|
|
@ -39,15 +39,6 @@ class Imx53_driver : public Gpio::Driver
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Timer_delayer : Timer::Connection, Genode::Mmio::Delayer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Implementation of 'Delayer' interface
|
|
||||||
*/
|
|
||||||
void usleep(unsigned us) { Timer::Connection::usleep(us); }
|
|
||||||
} _delayer;
|
|
||||||
|
|
||||||
|
|
||||||
class Gpio_bank
|
class Gpio_bank
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -70,10 +61,10 @@ class Imx53_driver : public Gpio::Driver
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Genode::Irq_connection _irq;
|
Genode::Irq_connection _irq;
|
||||||
Genode::Signal_rpc_member<Irq_handler> _dispatcher;
|
Genode::Signal_handler<Irq_handler> _dispatcher;
|
||||||
Gpio_bank *_bank;
|
Gpio_bank *_bank;
|
||||||
|
|
||||||
void _handle(unsigned)
|
void _handle()
|
||||||
{
|
{
|
||||||
_bank->handle_irq();
|
_bank->handle_irq();
|
||||||
_irq.ack_irq();
|
_irq.ack_irq();
|
||||||
|
@ -82,9 +73,9 @@ class Imx53_driver : public Gpio::Driver
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Irq_handler(Server::Entrypoint &ep,
|
Irq_handler(Genode::Env &env,
|
||||||
unsigned irq, Gpio_bank *bank)
|
unsigned irq, Gpio_bank *bank)
|
||||||
: _irq(irq), _dispatcher(ep, *this, &Irq_handler::_handle),
|
: _irq(env, irq), _dispatcher(env.ep(), *this, &Irq_handler::_handle),
|
||||||
_bank(bank)
|
_bank(bank)
|
||||||
{
|
{
|
||||||
_irq.sigh(_dispatcher);
|
_irq.sigh(_dispatcher);
|
||||||
|
@ -100,11 +91,11 @@ class Imx53_driver : public Gpio::Driver
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Gpio_bank(Server::Entrypoint &ep, Genode::addr_t base,
|
Gpio_bank(Genode::Env &env, Genode::addr_t base,
|
||||||
Genode::size_t size, unsigned irq_low, unsigned irq_high)
|
Genode::size_t size, unsigned irq_low, unsigned irq_high)
|
||||||
: _reg(base, size),
|
: _reg(env, base, size),
|
||||||
_irqh_low(ep, irq_low, this),
|
_irqh_low(env, irq_low, this),
|
||||||
_irqh_high(ep, irq_high, this) { }
|
_irqh_high(env, irq_high, this) { }
|
||||||
|
|
||||||
Gpio_reg* regs() { return &_reg; }
|
Gpio_reg* regs() { return &_reg; }
|
||||||
|
|
||||||
|
@ -123,8 +114,6 @@ class Imx53_driver : public Gpio::Driver
|
||||||
_sig_cap[pin] = cap; }
|
_sig_cap[pin] = cap; }
|
||||||
};
|
};
|
||||||
|
|
||||||
Server::Entrypoint &_ep;
|
|
||||||
|
|
||||||
Gpio_bank _gpio_bank_0;
|
Gpio_bank _gpio_bank_0;
|
||||||
Gpio_bank _gpio_bank_1;
|
Gpio_bank _gpio_bank_1;
|
||||||
Gpio_bank _gpio_bank_2;
|
Gpio_bank _gpio_bank_2;
|
||||||
|
@ -158,22 +147,21 @@ class Imx53_driver : public Gpio::Driver
|
||||||
|
|
||||||
int _gpio_index(int gpio) { return gpio & 0x1f; }
|
int _gpio_index(int gpio) { return gpio & 0x1f; }
|
||||||
|
|
||||||
Imx53_driver(Server::Entrypoint &ep)
|
Imx53_driver(Genode::Env &env)
|
||||||
:
|
:
|
||||||
_ep(ep),
|
_gpio_bank_0(env, Genode::Board_base::GPIO1_MMIO_BASE, Genode::Board_base::GPIO1_MMIO_SIZE,
|
||||||
_gpio_bank_0(_ep, Genode::Board_base::GPIO1_MMIO_BASE, Genode::Board_base::GPIO1_MMIO_SIZE,
|
|
||||||
Genode::Board_base::GPIO1_IRQL, Genode::Board_base::GPIO1_IRQH),
|
Genode::Board_base::GPIO1_IRQL, Genode::Board_base::GPIO1_IRQH),
|
||||||
_gpio_bank_1(_ep, Genode::Board_base::GPIO2_MMIO_BASE, Genode::Board_base::GPIO2_MMIO_SIZE,
|
_gpio_bank_1(env, Genode::Board_base::GPIO2_MMIO_BASE, Genode::Board_base::GPIO2_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO2_IRQL, Genode::Board_base::GPIO2_IRQH),
|
Genode::Board_base::GPIO2_IRQL, Genode::Board_base::GPIO2_IRQH),
|
||||||
_gpio_bank_2(_ep, Genode::Board_base::GPIO3_MMIO_BASE, Genode::Board_base::GPIO3_MMIO_SIZE,
|
_gpio_bank_2(env, Genode::Board_base::GPIO3_MMIO_BASE, Genode::Board_base::GPIO3_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO3_IRQL, Genode::Board_base::GPIO3_IRQH),
|
Genode::Board_base::GPIO3_IRQL, Genode::Board_base::GPIO3_IRQH),
|
||||||
_gpio_bank_3(_ep, Genode::Board_base::GPIO4_MMIO_BASE, Genode::Board_base::GPIO4_MMIO_SIZE,
|
_gpio_bank_3(env, Genode::Board_base::GPIO4_MMIO_BASE, Genode::Board_base::GPIO4_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO4_IRQL, Genode::Board_base::GPIO4_IRQH),
|
Genode::Board_base::GPIO4_IRQL, Genode::Board_base::GPIO4_IRQH),
|
||||||
_gpio_bank_4(_ep, Genode::Board_base::GPIO5_MMIO_BASE, Genode::Board_base::GPIO5_MMIO_SIZE,
|
_gpio_bank_4(env, Genode::Board_base::GPIO5_MMIO_BASE, Genode::Board_base::GPIO5_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO5_IRQL, Genode::Board_base::GPIO5_IRQH),
|
Genode::Board_base::GPIO5_IRQL, Genode::Board_base::GPIO5_IRQH),
|
||||||
_gpio_bank_5(_ep, Genode::Board_base::GPIO6_MMIO_BASE, Genode::Board_base::GPIO6_MMIO_SIZE,
|
_gpio_bank_5(env, Genode::Board_base::GPIO6_MMIO_BASE, Genode::Board_base::GPIO6_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO6_IRQL, Genode::Board_base::GPIO6_IRQH),
|
Genode::Board_base::GPIO6_IRQL, Genode::Board_base::GPIO6_IRQH),
|
||||||
_gpio_bank_6(_ep, Genode::Board_base::GPIO7_MMIO_BASE, Genode::Board_base::GPIO7_MMIO_SIZE,
|
_gpio_bank_6(env, Genode::Board_base::GPIO7_MMIO_BASE, Genode::Board_base::GPIO7_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO7_IRQL, Genode::Board_base::GPIO7_IRQH)
|
Genode::Board_base::GPIO7_IRQL, Genode::Board_base::GPIO7_IRQH)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < MAX_BANKS; ++i) {
|
for (unsigned i = 0; i < MAX_BANKS; ++i) {
|
||||||
|
@ -189,7 +177,7 @@ class Imx53_driver : public Gpio::Driver
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static Imx53_driver &factory(Server::Entrypoint &ep);
|
static Imx53_driver &factory(Genode::Env &env);
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
** Gpio::Driver interface **
|
** Gpio::Driver interface **
|
||||||
|
@ -278,11 +266,4 @@ class Imx53_driver : public Gpio::Driver
|
||||||
bool gpio_valid(unsigned gpio) { return gpio < (MAX_PINS*MAX_BANKS); }
|
bool gpio_valid(unsigned gpio) { return gpio < (MAX_PINS*MAX_BANKS); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Imx53_driver &Imx53_driver::factory(Server::Entrypoint &ep)
|
|
||||||
{
|
|
||||||
static Imx53_driver driver(ep);
|
|
||||||
return driver;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _DRIVERS__GPIO__SPEC__IMX53__DRIVER_H_ */
|
#endif /* _DRIVERS__GPIO__SPEC__IMX53__DRIVER_H_ */
|
||||||
|
|
|
@ -22,9 +22,10 @@
|
||||||
|
|
||||||
struct Gpio_reg : Genode::Attached_io_mem_dataspace, Genode::Mmio
|
struct Gpio_reg : Genode::Attached_io_mem_dataspace, Genode::Mmio
|
||||||
{
|
{
|
||||||
Gpio_reg(Genode::addr_t const mmio_base,
|
Gpio_reg(Genode::Env &env,
|
||||||
|
Genode::addr_t const mmio_base,
|
||||||
Genode::size_t const mmio_size)
|
Genode::size_t const mmio_size)
|
||||||
: Genode::Attached_io_mem_dataspace(mmio_base, mmio_size),
|
: Genode::Attached_io_mem_dataspace(env, mmio_base, mmio_size),
|
||||||
Genode::Mmio((Genode::addr_t)local_addr<void>()) { }
|
Genode::Mmio((Genode::addr_t)local_addr<void>()) { }
|
||||||
|
|
||||||
struct Data : Register_array<0x0, 32, 32, 1> {};
|
struct Data : Register_array<0x0, 32, 32, 1> {};
|
||||||
|
|
|
@ -15,51 +15,52 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
|
#include <base/attached_rom_dataspace.h>
|
||||||
|
#include <base/component.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <base/heap.h>
|
#include <base/heap.h>
|
||||||
#include <base/sleep.h>
|
|
||||||
#include <gpio/component.h>
|
#include <gpio/component.h>
|
||||||
#include <gpio/config.h>
|
#include <gpio/config.h>
|
||||||
#include <os/server.h>
|
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include <driver.h>
|
#include <driver.h>
|
||||||
|
|
||||||
|
|
||||||
|
Imx53_driver &Imx53_driver::factory(Genode::Env &env)
|
||||||
|
{
|
||||||
|
static Imx53_driver driver(env);
|
||||||
|
return driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Main
|
struct Main
|
||||||
{
|
{
|
||||||
Server::Entrypoint &ep;
|
Genode::Env &env;
|
||||||
Genode::Sliced_heap sliced_heap;
|
Genode::Sliced_heap sliced_heap;
|
||||||
Imx53_driver &driver;
|
Imx53_driver &driver;
|
||||||
Gpio::Root root;
|
Gpio::Root root;
|
||||||
|
|
||||||
Main(Server::Entrypoint &ep)
|
Genode::Attached_rom_dataspace config_rom { env, "config" };
|
||||||
|
|
||||||
|
Main(Genode::Env &env)
|
||||||
:
|
:
|
||||||
ep(ep),
|
env(env),
|
||||||
sliced_heap(Genode::env()->ram_session(), Genode::env()->rm_session()),
|
sliced_heap(env.ram(), env.rm()),
|
||||||
driver(Imx53_driver::factory(ep)),
|
driver(Imx53_driver::factory(env)),
|
||||||
root(&ep.rpc_ep(), &sliced_heap, driver)
|
root(&env.ep().rpc_ep(), &sliced_heap, driver)
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
log("--- i.MX53 gpio driver ---");
|
log("--- i.MX53 gpio driver ---");
|
||||||
|
|
||||||
Gpio::process_config(driver);
|
Gpio::process_config(config_rom.xml(), driver);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Announce service
|
* Announce service
|
||||||
*/
|
*/
|
||||||
env()->parent()->announce(ep.manage(root));
|
env.parent().announce(env.ep().manage(root));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/************
|
void Component::construct(Genode::Env &env) { static Main main(env); }
|
||||||
** Server **
|
|
||||||
************/
|
|
||||||
|
|
||||||
namespace Server {
|
|
||||||
char const *name() { return "gpio_drv_ep"; }
|
|
||||||
size_t stack_size() { return 16*1024*sizeof(long); }
|
|
||||||
void construct(Entrypoint &ep) { static Main server(ep); }
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
TARGET = gpio_drv
|
TARGET = gpio_drv
|
||||||
REQUIRES = imx53
|
REQUIRES = imx53
|
||||||
SRC_CC = main.cc
|
SRC_CC = main.cc
|
||||||
LIBS = base config server
|
LIBS = base
|
||||||
INC_DIR += $(PRG_DIR)
|
INC_DIR += $(PRG_DIR)
|
||||||
|
|
||||||
vpath main.cc $(PRG_DIR)
|
vpath main.cc $(PRG_DIR)
|
||||||
|
|
|
@ -37,26 +37,17 @@ class Omap4_driver : public Gpio::Driver
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Timer_delayer : Timer::Connection, Genode::Mmio::Delayer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Implementation of 'Delayer' interface
|
|
||||||
*/
|
|
||||||
void usleep(unsigned us) { Timer::Connection::usleep(us); }
|
|
||||||
} _delayer;
|
|
||||||
|
|
||||||
|
|
||||||
class Gpio_bank
|
class Gpio_bank
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Gpio_reg _reg;
|
Gpio_reg _reg;
|
||||||
Genode::Irq_connection _irq;
|
Genode::Irq_connection _irq;
|
||||||
Genode::Signal_rpc_member<Gpio_bank> _dispatcher;
|
Genode::Signal_handler<Gpio_bank> _dispatcher;
|
||||||
Genode::Signal_context_capability _sig_cap[MAX_PINS];
|
Genode::Signal_context_capability _sig_cap[MAX_PINS];
|
||||||
bool _irq_enabled[MAX_PINS];
|
bool _irq_enabled[MAX_PINS];
|
||||||
|
|
||||||
void _handle(unsigned)
|
void _handle()
|
||||||
{
|
{
|
||||||
_reg.write<Gpio_reg::Irqstatus_0>(0xffffffff);
|
_reg.write<Gpio_reg::Irqstatus_0>(0xffffffff);
|
||||||
|
|
||||||
|
@ -74,11 +65,11 @@ class Omap4_driver : public Gpio::Driver
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Gpio_bank(Server::Entrypoint &ep,
|
Gpio_bank(Genode::Env &env,
|
||||||
Genode::addr_t base, Genode::size_t size,
|
Genode::addr_t base, Genode::size_t size,
|
||||||
unsigned irq)
|
unsigned irq)
|
||||||
: _reg(base, size), _irq(irq),
|
: _reg(env, base, size), _irq(env, irq),
|
||||||
_dispatcher(ep, *this, &Gpio_bank::_handle)
|
_dispatcher(env.ep(), *this, &Gpio_bank::_handle)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < MAX_PINS; i++)
|
for (unsigned i = 0; i < MAX_PINS; i++)
|
||||||
_irq_enabled[i] = false;
|
_irq_enabled[i] = false;
|
||||||
|
@ -106,8 +97,6 @@ class Omap4_driver : public Gpio::Driver
|
||||||
_sig_cap[pin] = cap; }
|
_sig_cap[pin] = cap; }
|
||||||
};
|
};
|
||||||
|
|
||||||
Server::Entrypoint &_ep;
|
|
||||||
|
|
||||||
Gpio_bank _gpio_bank_0;
|
Gpio_bank _gpio_bank_0;
|
||||||
Gpio_bank _gpio_bank_1;
|
Gpio_bank _gpio_bank_1;
|
||||||
Gpio_bank _gpio_bank_2;
|
Gpio_bank _gpio_bank_2;
|
||||||
|
@ -138,26 +127,25 @@ class Omap4_driver : public Gpio::Driver
|
||||||
|
|
||||||
int _gpio_index(int gpio) { return gpio & 0x1f; }
|
int _gpio_index(int gpio) { return gpio & 0x1f; }
|
||||||
|
|
||||||
Omap4_driver(Server::Entrypoint &ep)
|
Omap4_driver(Genode::Env &env)
|
||||||
:
|
:
|
||||||
_ep(ep),
|
_gpio_bank_0(env, Genode::Board_base::GPIO1_MMIO_BASE, Genode::Board_base::GPIO1_MMIO_SIZE,
|
||||||
_gpio_bank_0(_ep, Genode::Board_base::GPIO1_MMIO_BASE, Genode::Board_base::GPIO1_MMIO_SIZE,
|
|
||||||
Genode::Board_base::GPIO1_IRQ),
|
Genode::Board_base::GPIO1_IRQ),
|
||||||
_gpio_bank_1(_ep, Genode::Board_base::GPIO2_MMIO_BASE, Genode::Board_base::GPIO2_MMIO_SIZE,
|
_gpio_bank_1(env, Genode::Board_base::GPIO2_MMIO_BASE, Genode::Board_base::GPIO2_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO2_IRQ),
|
Genode::Board_base::GPIO2_IRQ),
|
||||||
_gpio_bank_2(_ep, Genode::Board_base::GPIO3_MMIO_BASE, Genode::Board_base::GPIO3_MMIO_SIZE,
|
_gpio_bank_2(env, Genode::Board_base::GPIO3_MMIO_BASE, Genode::Board_base::GPIO3_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO3_IRQ),
|
Genode::Board_base::GPIO3_IRQ),
|
||||||
_gpio_bank_3(_ep, Genode::Board_base::GPIO4_MMIO_BASE, Genode::Board_base::GPIO4_MMIO_SIZE,
|
_gpio_bank_3(env, Genode::Board_base::GPIO4_MMIO_BASE, Genode::Board_base::GPIO4_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO4_IRQ),
|
Genode::Board_base::GPIO4_IRQ),
|
||||||
_gpio_bank_4(_ep, Genode::Board_base::GPIO5_MMIO_BASE, Genode::Board_base::GPIO5_MMIO_SIZE,
|
_gpio_bank_4(env, Genode::Board_base::GPIO5_MMIO_BASE, Genode::Board_base::GPIO5_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO5_IRQ),
|
Genode::Board_base::GPIO5_IRQ),
|
||||||
_gpio_bank_5(_ep, Genode::Board_base::GPIO6_MMIO_BASE, Genode::Board_base::GPIO6_MMIO_SIZE,
|
_gpio_bank_5(env, Genode::Board_base::GPIO6_MMIO_BASE, Genode::Board_base::GPIO6_MMIO_SIZE,
|
||||||
Genode::Board_base::GPIO6_IRQ)
|
Genode::Board_base::GPIO6_IRQ)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static Omap4_driver& factory(Server::Entrypoint &ep);
|
static Omap4_driver& factory(Genode::Env &env);
|
||||||
|
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
|
@ -268,11 +256,4 @@ class Omap4_driver : public Gpio::Driver
|
||||||
bool gpio_valid(unsigned gpio) { return gpio < (MAX_PINS*MAX_BANKS); }
|
bool gpio_valid(unsigned gpio) { return gpio < (MAX_PINS*MAX_BANKS); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Omap4_driver& Omap4_driver::factory(Server::Entrypoint &ep)
|
|
||||||
{
|
|
||||||
static Omap4_driver driver(ep);
|
|
||||||
return driver;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _DRIVERS__GPIO__SPEC__OMAP4__DRIVER_H_ */
|
#endif /* _DRIVERS__GPIO__SPEC__OMAP4__DRIVER_H_ */
|
||||||
|
|
|
@ -22,9 +22,10 @@
|
||||||
|
|
||||||
struct Gpio_reg : Genode::Attached_io_mem_dataspace, Genode::Mmio
|
struct Gpio_reg : Genode::Attached_io_mem_dataspace, Genode::Mmio
|
||||||
{
|
{
|
||||||
Gpio_reg(Genode::addr_t const mmio_base,
|
Gpio_reg(Genode::Env &env,
|
||||||
|
Genode::addr_t const mmio_base,
|
||||||
Genode::size_t const mmio_size)
|
Genode::size_t const mmio_size)
|
||||||
: Genode::Attached_io_mem_dataspace(mmio_base, mmio_size),
|
: Genode::Attached_io_mem_dataspace(env, mmio_base, mmio_size),
|
||||||
Genode::Mmio((Genode::addr_t)local_addr<void>()) { }
|
Genode::Mmio((Genode::addr_t)local_addr<void>()) { }
|
||||||
|
|
||||||
struct Oe : Register_array<0x134, 32, 32, 1> {};
|
struct Oe : Register_array<0x134, 32, 32, 1> {};
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
|
#include <base/attached_rom_dataspace.h>
|
||||||
|
#include <base/component.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <base/heap.h>
|
#include <base/heap.h>
|
||||||
#include <base/sleep.h>
|
|
||||||
#include <cap_session/connection.h>
|
|
||||||
#include <gpio/component.h>
|
#include <gpio/component.h>
|
||||||
#include <gpio/config.h>
|
#include <gpio/config.h>
|
||||||
#include <os/server.h>
|
#include <os/server.h>
|
||||||
|
@ -25,40 +25,41 @@
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include <driver.h>
|
#include <driver.h>
|
||||||
|
|
||||||
|
Omap4_driver& Omap4_driver::factory(Genode::Env &env)
|
||||||
|
{
|
||||||
|
static Omap4_driver driver(env);
|
||||||
|
return driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Main
|
struct Main
|
||||||
{
|
{
|
||||||
Server::Entrypoint &ep;
|
Genode::Env &env;
|
||||||
Genode::Sliced_heap sliced_heap;
|
Genode::Sliced_heap sliced_heap;
|
||||||
Omap4_driver &driver;
|
Omap4_driver &driver;
|
||||||
Gpio::Root root;
|
Gpio::Root root;
|
||||||
|
|
||||||
Main(Server::Entrypoint &ep)
|
Genode::Attached_rom_dataspace config_rom { env, "config" };
|
||||||
|
|
||||||
|
Main(Genode::Env &env)
|
||||||
:
|
:
|
||||||
ep(ep),
|
env(env),
|
||||||
sliced_heap(Genode::env()->ram_session(), Genode::env()->rm_session()),
|
sliced_heap(env.ram(), env.rm()),
|
||||||
driver(Omap4_driver::factory(ep)),
|
driver(Omap4_driver::factory(env)),
|
||||||
root(&ep.rpc_ep(), &sliced_heap, driver)
|
root(&env.ep().rpc_ep(), &sliced_heap, driver)
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
log("--- omap4 gpio driver ---");
|
log("--- omap4 gpio driver ---");
|
||||||
|
|
||||||
Gpio::process_config(driver);
|
Gpio::process_config(config_rom.xml(), driver);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Announce service
|
* Announce service
|
||||||
*/
|
*/
|
||||||
env()->parent()->announce(ep.manage(root));
|
env.parent().announce(env.ep().manage(root));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/************
|
|
||||||
** Server **
|
|
||||||
************/
|
|
||||||
|
|
||||||
namespace Server {
|
void Component::construct(Genode::Env &env) { static Main main(env); }
|
||||||
char const *name() { return "gpio_drv_ep"; }
|
|
||||||
size_t stack_size() { return 16*1024*sizeof(long); }
|
|
||||||
void construct(Entrypoint &ep) { static Main server(ep); }
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
TARGET = gpio_drv
|
TARGET = gpio_drv
|
||||||
REQUIRES = omap4
|
REQUIRES = omap4
|
||||||
SRC_CC = main.cc
|
SRC_CC = main.cc
|
||||||
LIBS = base config server
|
LIBS = base
|
||||||
INC_DIR += $(PRG_DIR)
|
INC_DIR += $(PRG_DIR)
|
||||||
|
|
||||||
vpath main.cc $(PRG_DIR)
|
vpath main.cc $(PRG_DIR)
|
||||||
|
|
|
@ -37,15 +37,14 @@ class Gpio::Rpi_driver : public Driver
|
||||||
|
|
||||||
enum { MAX_PINS = 54 };
|
enum { MAX_PINS = 54 };
|
||||||
|
|
||||||
Server::Entrypoint &_ep;
|
|
||||||
Reg _reg;
|
Reg _reg;
|
||||||
Genode::Irq_connection _irq;
|
Genode::Irq_connection _irq;
|
||||||
Genode::Signal_rpc_member<Rpi_driver> _dispatcher;
|
Genode::Signal_handler<Rpi_driver> _dispatcher;
|
||||||
Genode::Signal_context_capability _sig_cap[MAX_PINS];
|
Genode::Signal_context_capability _sig_cap[MAX_PINS];
|
||||||
bool _irq_enabled[MAX_PINS];
|
bool _irq_enabled[MAX_PINS];
|
||||||
bool _async;
|
bool _async;
|
||||||
|
|
||||||
void _handle(unsigned)
|
void _handle()
|
||||||
{
|
{
|
||||||
_reg.for_each_gpio_status([&] (unsigned i, bool s) {
|
_reg.for_each_gpio_status([&] (unsigned i, bool s) {
|
||||||
if (!s || !_irq_enabled[i] || !_sig_cap[i].valid()) { return; }
|
if (!s || !_irq_enabled[i] || !_sig_cap[i].valid()) { return; }
|
||||||
|
@ -53,13 +52,12 @@ class Gpio::Rpi_driver : public Driver
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Rpi_driver(Server::Entrypoint &ep)
|
Rpi_driver(Genode::Env &env)
|
||||||
:
|
:
|
||||||
_ep(ep),
|
_reg(env, Genode::Board_base::GPIO_CONTROLLER_BASE,
|
||||||
_reg(Genode::Board_base::GPIO_CONTROLLER_BASE,
|
|
||||||
0, Genode::Board_base::GPIO_CONTROLLER_SIZE),
|
0, Genode::Board_base::GPIO_CONTROLLER_SIZE),
|
||||||
_irq(IRQ),
|
_irq(env, IRQ),
|
||||||
_dispatcher(ep,*this,&Rpi_driver::_handle),
|
_dispatcher(env.ep(), *this, &Rpi_driver::_handle),
|
||||||
_async(false)
|
_async(false)
|
||||||
{
|
{
|
||||||
_irq.sigh(_dispatcher);
|
_irq.sigh(_dispatcher);
|
||||||
|
@ -81,7 +79,7 @@ class Gpio::Rpi_driver : public Driver
|
||||||
_reg.set_gpio_function(gpio, function);
|
_reg.set_gpio_function(gpio, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Rpi_driver& factory(Server::Entrypoint &ep);
|
static Rpi_driver& factory(Genode::Env &env);
|
||||||
|
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
|
@ -208,11 +206,4 @@ class Gpio::Rpi_driver : public Driver
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Gpio::Rpi_driver& Gpio::Rpi_driver::factory(Server::Entrypoint &ep)
|
|
||||||
{
|
|
||||||
static Rpi_driver driver(ep);
|
|
||||||
return driver;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _DRIVERS__GPIO__SPEC__RPI__DRIVER_H_ */
|
#endif /* _DRIVERS__GPIO__SPEC__RPI__DRIVER_H_ */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
TARGET = foc_gpio_drv
|
TARGET = foc_gpio_drv
|
||||||
REQUIRES = rpi
|
REQUIRES = rpi
|
||||||
SRC_CC += ../main.cc
|
SRC_CC += ../main.cc
|
||||||
LIBS += base config server
|
LIBS += base
|
||||||
INC_DIR += $(PRG_DIR) $(PRG_DIR)/..
|
INC_DIR += $(PRG_DIR) $(PRG_DIR)/..
|
||||||
|
|
|
@ -113,6 +113,8 @@ class Gpio::Reg : Attached_io_mem_dataspace, Mmio
|
||||||
|
|
||||||
struct Timer_delayer : Timer::Connection, Mmio::Delayer
|
struct Timer_delayer : Timer::Connection, Mmio::Delayer
|
||||||
{
|
{
|
||||||
|
Timer_delayer(Genode::Env &env) : Timer::Connection(env) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of 'Delayer' interface
|
* Implementation of 'Delayer' interface
|
||||||
*/
|
*/
|
||||||
|
@ -134,10 +136,12 @@ class Gpio::Reg : Attached_io_mem_dataspace, Mmio
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Reg(addr_t base, off_t offset, size_t size)
|
Reg(Genode::Env &env,
|
||||||
|
addr_t base, off_t offset, size_t size)
|
||||||
:
|
:
|
||||||
Attached_io_mem_dataspace(base, size),
|
Attached_io_mem_dataspace(env, base, size),
|
||||||
Mmio((addr_t)local_addr<Reg>() + offset)
|
Mmio((addr_t)local_addr<Reg>() + offset),
|
||||||
|
_delayer(env)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
enum Function {
|
enum Function {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
TARGET = hw_gpio_drv
|
TARGET = hw_gpio_drv
|
||||||
REQUIRES = rpi
|
REQUIRES = rpi
|
||||||
SRC_CC += ../main.cc
|
SRC_CC += ../main.cc
|
||||||
LIBS += base config server
|
LIBS = base
|
||||||
INC_DIR += $(PRG_DIR) $(PRG_DIR)/..
|
INC_DIR += $(PRG_DIR) $(PRG_DIR)/..
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
|
#include <base/attached_rom_dataspace.h>
|
||||||
|
#include <base/component.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <base/heap.h>
|
#include <base/heap.h>
|
||||||
#include <base/sleep.h>
|
|
||||||
#include <cap_session/connection.h>
|
|
||||||
#include <gpio/component.h>
|
#include <gpio/component.h>
|
||||||
#include <gpio/config.h>
|
#include <gpio/config.h>
|
||||||
#include <os/server.h>
|
#include <os/server.h>
|
||||||
|
@ -25,19 +25,29 @@
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
|
|
||||||
|
|
||||||
|
Gpio::Rpi_driver& Gpio::Rpi_driver::factory(Genode::Env &env)
|
||||||
|
{
|
||||||
|
static Rpi_driver driver(env);
|
||||||
|
return driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Main
|
struct Main
|
||||||
{
|
{
|
||||||
Server::Entrypoint &ep;
|
Genode::Env &env;
|
||||||
Genode::Sliced_heap sliced_heap;
|
Genode::Sliced_heap sliced_heap;
|
||||||
Gpio::Rpi_driver &driver;
|
Gpio::Rpi_driver &driver;
|
||||||
Gpio::Root root;
|
Gpio::Root root;
|
||||||
|
|
||||||
Main(Server::Entrypoint &ep)
|
Genode::Attached_rom_dataspace config_rom { env, "config" };
|
||||||
|
|
||||||
|
Main(Genode::Env &env)
|
||||||
:
|
:
|
||||||
ep(ep),
|
env(env),
|
||||||
sliced_heap(Genode::env()->ram_session(), Genode::env()->rm_session()),
|
sliced_heap(env.ram(), env.rm()),
|
||||||
driver(Gpio::Rpi_driver::factory(ep)),
|
driver(Gpio::Rpi_driver::factory(env)),
|
||||||
root(&ep.rpc_ep(), &sliced_heap, driver)
|
root(&env.ep().rpc_ep(), &sliced_heap, driver)
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
log("--- Raspberry Pi GPIO driver ---");
|
log("--- Raspberry Pi GPIO driver ---");
|
||||||
|
@ -47,20 +57,20 @@ struct Main
|
||||||
*/
|
*/
|
||||||
unsigned int async = 0;
|
unsigned int async = 0;
|
||||||
try {
|
try {
|
||||||
config()->xml_node().attribute("async_events").value(&async);
|
config_rom.xml().attribute("async_events").value(&async);
|
||||||
} catch (...) { }
|
} catch (...) { }
|
||||||
driver.set_async_events(async>0);
|
driver.set_async_events(async>0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for common GPIO configuration
|
* Check for common GPIO configuration
|
||||||
*/
|
*/
|
||||||
Gpio::process_config(driver);
|
Gpio::process_config(config_rom.xml(), driver);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check configuration for specific function
|
* Check configuration for specific function
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
Xml_node gpio_node = config()->xml_node().sub_node("gpio");
|
Xml_node gpio_node = config_rom.xml().sub_node("gpio");
|
||||||
|
|
||||||
for (;; gpio_node = gpio_node.next("gpio")) {
|
for (;; gpio_node = gpio_node.next("gpio")) {
|
||||||
unsigned num = 0;
|
unsigned num = 0;
|
||||||
|
@ -89,16 +99,9 @@ struct Main
|
||||||
/*
|
/*
|
||||||
* Announce service
|
* Announce service
|
||||||
*/
|
*/
|
||||||
env()->parent()->announce(ep.manage(root));
|
env.parent().announce(env.ep().manage(root));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/************
|
|
||||||
** Server **
|
|
||||||
************/
|
|
||||||
|
|
||||||
namespace Server {
|
void Component::construct(Genode::Env &env) { static Main main(env); }
|
||||||
char const *name() { return "gpio_drv_ep"; }
|
|
||||||
size_t stack_size() { return 16*1024*sizeof(long); }
|
|
||||||
void construct(Entrypoint &ep) { static Main server(ep); }
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user