mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-23 17:17:38 +00:00
Add OMAP4 GPIO driver
Add Gpio session interface. Add test for Pandaboard. Fixes #427
This commit is contained in:
committed by
Norman Feske
parent
deb465e442
commit
5e66b6d5ed
23
os/include/gpio_session/capability.h
Normal file
23
os/include/gpio_session/capability.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* \brief Gpio session capability type
|
||||
* \author Ivan Loskutov <ivan.loskutov@ksyslabs.org>
|
||||
* \date 2012-06-23
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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__GPIO_SESSION__CAPABILITY_H_
|
||||
#define _INCLUDE__GPIO_SESSION__CAPABILITY_H_
|
||||
|
||||
#include <base/capability.h>
|
||||
#include <gpio_session/gpio_session.h>
|
||||
|
||||
namespace Gpio { typedef Genode::Capability<Session> Session_capability; }
|
||||
|
||||
#endif /* _INCLUDE__GPIO_SESSION__CAPABILITY_H_ */
|
81
os/include/gpio_session/client.h
Normal file
81
os/include/gpio_session/client.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* \brief Client-side Gpio session interface
|
||||
* \author Ivan Loskutov <ivan.loskutov@ksyslabs.org>
|
||||
* \date 2012-06-23
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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__GPIO_SESSION_H__CLIENT_H_
|
||||
#define _INCLUDE__GPIO_SESSION_H__CLIENT_H_
|
||||
|
||||
#include <gpio_session/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) { }
|
||||
|
||||
|
||||
void direction_output(int gpio, bool enable)
|
||||
{
|
||||
call<Rpc_direction_output>(gpio, enable);
|
||||
}
|
||||
|
||||
void direction_input(int gpio)
|
||||
{
|
||||
call<Rpc_direction_input>(gpio);
|
||||
}
|
||||
|
||||
void dataout(int gpio, bool enable)
|
||||
{
|
||||
call<Rpc_dataout>(gpio, enable);
|
||||
}
|
||||
|
||||
int datain(int gpio)
|
||||
{
|
||||
return call<Rpc_datain>(gpio);
|
||||
}
|
||||
|
||||
void debounce_enable(int gpio, bool enable)
|
||||
{
|
||||
call<Rpc_debounce_enable>(gpio, enable);
|
||||
}
|
||||
|
||||
void debouncing_time(int gpio, unsigned int us)
|
||||
{
|
||||
call<Rpc_debouncing_time>(gpio, us);
|
||||
}
|
||||
|
||||
void falling_detect(int gpio, bool enable)
|
||||
{
|
||||
call<Rpc_falling_detect>(gpio, enable);
|
||||
}
|
||||
|
||||
void rising_detect(int gpio, bool enable)
|
||||
{
|
||||
call<Rpc_rising_detect>(gpio, enable);
|
||||
}
|
||||
|
||||
void irq_enable(int gpio, bool enable)
|
||||
{
|
||||
call<Rpc_irq_enable>(gpio, enable);
|
||||
}
|
||||
|
||||
void irq_sigh(Signal_context_capability cap, int gpio)
|
||||
{
|
||||
call<Rpc_irq_sigh>(cap, gpio);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__GPIO_SESSION_H__CLIENT_H_ */
|
33
os/include/gpio_session/connection.h
Normal file
33
os/include/gpio_session/connection.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* \brief Connection to Gpio session
|
||||
* \author Ivan Loskutov <ivan.loskutov@ksyslabs.org>
|
||||
* \date 2012-06-23
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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__GPIO_SESSION__CONNECTION_H_
|
||||
#define _INCLUDE__GPIO_SESSION__CONNECTION_H_
|
||||
|
||||
#include <gpio_session/client.h>
|
||||
#include <base/connection.h>
|
||||
|
||||
namespace Gpio {
|
||||
|
||||
struct Connection : Genode::Connection<Session>, Session_client
|
||||
{
|
||||
Connection()
|
||||
:
|
||||
Genode::Connection<Session>(session("ram_quota=4K")),
|
||||
Session_client(cap())
|
||||
{ }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__GPIO_SESSION__CONNECTION_H_ */
|
147
os/include/gpio_session/gpio_session.h
Normal file
147
os/include/gpio_session/gpio_session.h
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* \brief Gpio session interface
|
||||
* \author Ivan Loskutov <ivan.loskutov@ksyslabs.org>
|
||||
* \date 2012-06-23
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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__GPIO_SESSION__GPIO_SESSION_H_
|
||||
#define _INCLUDE__GPIO_SESSION__GPIO_SESSION_H_
|
||||
|
||||
#include <base/signal.h>
|
||||
#include <dataspace/capability.h>
|
||||
#include <session/session.h>
|
||||
|
||||
namespace Gpio {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
struct Session : Genode::Session
|
||||
{
|
||||
static const char *service_name() { return "Gpio"; }
|
||||
|
||||
virtual ~Session() { }
|
||||
|
||||
/**
|
||||
* Configure direction on a specified GPIO pin as output
|
||||
*
|
||||
* \param gpio number of the pin
|
||||
* \param enable logic level on the pin
|
||||
*/
|
||||
virtual void direction_output(int gpio, bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Configure direction on a specified GPIO pin as input
|
||||
*
|
||||
* \param gpio number of the pin
|
||||
*/
|
||||
virtual void direction_input(int gpio) = 0;
|
||||
|
||||
/**
|
||||
* Set the logic level on a specified GPIO pin
|
||||
*
|
||||
* \param gpio number of the pin
|
||||
* \param enable logic level on the pin
|
||||
*/
|
||||
virtual void dataout(int gpio, bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Read the logic level on a specified GPIO pin
|
||||
*
|
||||
* \param gpio number of the pin
|
||||
*
|
||||
* \return level on specified GPIO pin
|
||||
*/
|
||||
virtual int datain(int gpio) = 0;
|
||||
|
||||
/**
|
||||
* Enable the debounce on a specified input GPIO pin
|
||||
*
|
||||
* \param gpio number of the pin
|
||||
*/
|
||||
virtual void debounce_enable(int gpio, bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Set the debouncing time for all input pins of GPIO bank
|
||||
*
|
||||
* \param gpio number of the pin
|
||||
*/
|
||||
virtual void debouncing_time(int gpio, unsigned int us) = 0;
|
||||
|
||||
/**
|
||||
* Configure the interrupt request on occurence of a falling edge on
|
||||
* a specified input GPIO pin
|
||||
*
|
||||
* \param gpio number of the pin
|
||||
*/
|
||||
virtual void falling_detect(int gpio, bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Configure the interrupt request on occurence of a rising edge on
|
||||
* a specified input GPIO pin
|
||||
*
|
||||
* \param gpio number of the pin
|
||||
*/
|
||||
virtual void rising_detect(int gpio, bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Enable or disable the interrupt on a specified GPIO pin
|
||||
*
|
||||
* \param gpio number of the pin
|
||||
* \param enable interrupt status( true - enable, false - disable)
|
||||
*/
|
||||
virtual void irq_enable(int gpio, bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Register signal handler to be notified on interrupt on a specified
|
||||
* GPIO pin
|
||||
*
|
||||
* \param cap capability of signal-context to handle GPIO
|
||||
* interrupt
|
||||
* \param gpio number of the pin
|
||||
*
|
||||
* This function is used for a set up signal handler for a specified
|
||||
* GPIO interrupt. Signal emited to the client if IRQ on pin configured
|
||||
* when the driver handles this IRQ.
|
||||
*/
|
||||
virtual void irq_sigh(Signal_context_capability cap, int gpio) = 0;
|
||||
|
||||
/*******************
|
||||
** RPC interface **
|
||||
*******************/
|
||||
|
||||
GENODE_RPC(Rpc_direction_output, void, direction_output, int, bool);
|
||||
GENODE_RPC(Rpc_direction_input, void, direction_input, int);
|
||||
GENODE_RPC(Rpc_dataout, void, dataout, int, bool);
|
||||
GENODE_RPC(Rpc_datain, int, datain, int);
|
||||
GENODE_RPC(Rpc_debounce_enable, void, debounce_enable, int, bool);
|
||||
GENODE_RPC(Rpc_debouncing_time, void, debouncing_time, int, unsigned int);
|
||||
GENODE_RPC(Rpc_falling_detect, void, falling_detect, int, bool);
|
||||
GENODE_RPC(Rpc_rising_detect, void, rising_detect, int, bool);
|
||||
GENODE_RPC(Rpc_irq_enable, void, irq_enable, int, bool);
|
||||
GENODE_RPC(Rpc_irq_sigh, void, irq_sigh, Signal_context_capability, int);
|
||||
|
||||
|
||||
typedef Meta::Type_tuple<Rpc_direction_output,
|
||||
Meta::Type_tuple<Rpc_direction_input,
|
||||
Meta::Type_tuple<Rpc_dataout,
|
||||
Meta::Type_tuple<Rpc_datain,
|
||||
Meta::Type_tuple<Rpc_debounce_enable,
|
||||
Meta::Type_tuple<Rpc_debouncing_time,
|
||||
Meta::Type_tuple<Rpc_falling_detect,
|
||||
Meta::Type_tuple<Rpc_rising_detect,
|
||||
Meta::Type_tuple<Rpc_irq_enable,
|
||||
Meta::Type_tuple<Rpc_irq_sigh,
|
||||
Meta::Empty>
|
||||
> > > > > > > > > Rpc_functions;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__GPIO_SESSION__GPIO_SESSION_H_ */
|
Reference in New Issue
Block a user