-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Gpio session interface. Add test for Pandaboard. Fixes #427
- Loading branch information
Showing
13 changed files
with
1,311 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# | ||
# Build | ||
# | ||
if {[have_spec omap4] == 0} { | ||
puts "Runs on OMAP4 only" | ||
exit 0 | ||
} | ||
|
||
set build_components { | ||
core init | ||
drivers/timer drivers/gpio | ||
test/gpio_drv | ||
} | ||
|
||
build $build_components | ||
|
||
create_boot_directory | ||
|
||
# | ||
# Generate config | ||
# | ||
|
||
append config { | ||
<config> | ||
<parent-provides> | ||
<service name="ROM"/> | ||
<service name="RAM"/> | ||
<service name="IRQ"/> | ||
<service name="IO_MEM"/> | ||
<service name="IO_PORT"/> | ||
<service name="CAP"/> | ||
<service name="PD"/> | ||
<service name="RM"/> | ||
<service name="CPU"/> | ||
<service name="LOG"/> | ||
<service name="SIGNAL"/> | ||
</parent-provides> | ||
<default-route> | ||
<any-service> <parent/> <any-child/> </any-service> | ||
</default-route> | ||
<start name="timer"> | ||
<resource name="RAM" quantum="1M"/> | ||
<provides><service name="Timer"/></provides> | ||
</start> | ||
<start name="omap4_gpio_drv"> | ||
<resource name="RAM" quantum="1M"/> | ||
<provides><service name="Gpio"/></provides> | ||
<config> | ||
<gpio num="121" mode="I"/> | ||
<gpio num="7" mode="O" value="0"/> | ||
<gpio num="8" mode="O" value="0"/> | ||
</config> | ||
</start> | ||
<start name="omap4_gpio_drv"> | ||
<resource name="RAM" quantum="1M"/> | ||
</start> | ||
</config>} | ||
|
||
install_config $config | ||
|
||
# | ||
# Boot modules | ||
# | ||
|
||
# generic modules | ||
set boot_modules { | ||
core init | ||
timer | ||
omap4_gpio_drv | ||
test-omap4_gpio_drv | ||
} | ||
|
||
build_boot_image $boot_modules | ||
|
Oops, something went wrong.