mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 18:56:29 +00:00
os: refactor i.MX53 interactive drivers (ref #3299)
* Remove input driver specific to i.MX53 tablet board from QSB driver pkg * Move GPIO settings for QSB LVDS backlight out of framebuffer driver into GPIO driver config * Move PWM driver functionality out of framebuffer driver * Make framebuffer driver configureable, and less dependent on platform driver i.MX53 specifics
This commit is contained in:
parent
ab8ef5750d
commit
e1333c9421
@ -18,7 +18,7 @@
|
||||
<default-policy> <child name="fb_drv"/> </default-policy> </service>
|
||||
|
||||
<service name="Input">
|
||||
<default-policy> <child name="imx53_input_drv"/> </default-policy> </service>
|
||||
<default-policy> <child name="dummy_input_drv"/> </default-policy> </service>
|
||||
|
||||
<start name="platform_drv" caps="200">
|
||||
<binary name="imx53_platform_drv"/>
|
||||
@ -40,6 +40,10 @@
|
||||
<start name="imx53_gpio_drv" caps="200">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config>
|
||||
<gpio num="1" mode="O" value="1"/>
|
||||
<gpio num="88" mode="O" value="1"/>
|
||||
</config>
|
||||
<route>
|
||||
<service name="Platform"> <child name="platform_drv"/> </service>
|
||||
<service name="IO_MEM"> <parent/> </service>
|
||||
@ -56,10 +60,10 @@
|
||||
<binary name="imx53_fb_drv"/>
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Framebuffer"/></provides>
|
||||
<config width="800" height="480" display="0" buffered="true"/>
|
||||
<route>
|
||||
<service name="ROM" label="config"> <parent label="fb_drv.config"/> </service>
|
||||
<service name="Platform"> <child name="platform_drv"/> </service>
|
||||
<service name="Gpio"> <child name="imx53_gpio_drv"/> </service>
|
||||
<service name="IO_MEM"> <parent/> </service>
|
||||
<service name="ROM"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
@ -69,19 +73,14 @@
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="imx53_input_drv" caps="100">
|
||||
<start name="dummy_input_drv" caps="100">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Input"/> </provides>
|
||||
<route>
|
||||
<service name="IO_MEM"> <parent/> </service>
|
||||
<service name="IRQ"> <parent/> </service>
|
||||
<service name="Gpio"> <child name="imx53_gpio_drv"/> </service>
|
||||
<service name="Platform"> <child name="platform_drv"/> </service>
|
||||
<service name="ROM"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
<service name="CPU"> <parent/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="Timer"> <parent/> </service>
|
||||
</route>
|
||||
</start>
|
||||
</config>
|
||||
|
@ -7,9 +7,9 @@ include/gpio:
|
||||
cp -r $(REP_DIR)/include/gpio $@
|
||||
|
||||
src/drivers:
|
||||
mkdir -p $@/framebuffer/spec $@/input/spec $@/gpio/spec
|
||||
mkdir -p $@/framebuffer/spec $@/input $@/gpio/spec
|
||||
cp -r $(REP_DIR)/src/drivers/gpio/spec/imx $@/gpio/spec/
|
||||
cp -r $(REP_DIR)/src/drivers/gpio/spec/imx53 $@/gpio/spec/
|
||||
cp -r $(REP_DIR)/src/drivers/framebuffer/spec/imx53 $@/framebuffer/spec/
|
||||
cp -r $(REP_DIR)/include/spec/imx53/imx_framebuffer_session $@/framebuffer/spec/imx53/
|
||||
cp -r $(REP_DIR)/src/drivers/input/spec/imx53 $@/input/spec/
|
||||
cp -r $(REP_DIR)/src/drivers/input/dummy $@/input/
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* \brief Frame-buffer driver for Freescale's i.MX53
|
||||
* \author Nikolay Golikov <nik@ksyslabs.org>
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2012-06-21
|
||||
*/
|
||||
|
||||
@ -18,14 +19,11 @@
|
||||
#include <drivers/defs/imx53.h>
|
||||
#include <base/attached_io_mem_dataspace.h>
|
||||
#include <io_mem_session/connection.h>
|
||||
#include <gpio_session/connection.h>
|
||||
#include <platform_session/connection.h>
|
||||
#include <util/mmio.h>
|
||||
|
||||
/* local includes */
|
||||
#include <ipu.h>
|
||||
#include <pwm.h>
|
||||
|
||||
|
||||
namespace Framebuffer {
|
||||
using namespace Genode;
|
||||
@ -39,71 +37,32 @@ class Framebuffer::Driver
|
||||
|
||||
Genode::Env &_env;
|
||||
|
||||
Platform::Connection _platform;
|
||||
Attached_io_mem_dataspace _ipu_mmio;
|
||||
Ipu _ipu;
|
||||
Attached_io_mem_dataspace _pwm_mmio;
|
||||
Pwm _pwm;
|
||||
Platform::Session::Board_revision _board;
|
||||
size_t _width;
|
||||
size_t _height;
|
||||
Platform::Connection _platform;
|
||||
Attached_io_mem_dataspace _ipu_mmio;
|
||||
Ipu _ipu;
|
||||
bool _disp0;
|
||||
size_t _width;
|
||||
size_t _height;
|
||||
|
||||
public:
|
||||
|
||||
enum Resolutions {
|
||||
QSB_WIDTH = 800,
|
||||
QSB_HEIGHT = 480,
|
||||
SMD_WIDTH = 1024,
|
||||
SMD_HEIGHT = 768,
|
||||
BYTES_PER_PIXEL = 2,
|
||||
};
|
||||
enum Resolutions { BYTES_PER_PIXEL = 2 };
|
||||
|
||||
enum Gpio_pins {
|
||||
LCD_BL_GPIO = 88,
|
||||
LCD_CONT_GPIO = 1,
|
||||
};
|
||||
|
||||
Driver(Genode::Env &env)
|
||||
Driver(Genode::Env &env, Genode::Xml_node config)
|
||||
: _env(env),
|
||||
_platform(_env),
|
||||
_ipu_mmio(_env, Imx53::IPU_BASE, Imx53::IPU_SIZE),
|
||||
_ipu((addr_t)_ipu_mmio.local_addr<void>()),
|
||||
_pwm_mmio(_env, Imx53::PWM2_BASE, Imx53::PWM2_SIZE),
|
||||
_pwm((addr_t)_pwm_mmio.local_addr<void>()),
|
||||
_board(_platform.revision()),
|
||||
_width(_board == Platform::Session::QSB ? QSB_WIDTH : SMD_WIDTH),
|
||||
_height(_board == Platform::Session::QSB ? QSB_HEIGHT : SMD_HEIGHT) { }
|
||||
_disp0(config.attribute_value<unsigned>("display", 0) == 0),
|
||||
_width(config.attribute_value<unsigned>("width", 800)),
|
||||
_height(config.attribute_value<unsigned>("height", 480)) { }
|
||||
|
||||
bool init(addr_t phys_base)
|
||||
{
|
||||
/* enable IPU via platform driver */
|
||||
_platform.enable(Platform::Session::IPU);
|
||||
|
||||
switch (_board) {
|
||||
case Platform::Session::QSB:
|
||||
{
|
||||
_ipu.init(_width, _height, _width * BYTES_PER_PIXEL,
|
||||
phys_base, true);
|
||||
|
||||
/* turn display on */
|
||||
Gpio::Connection gpio_bl(_env, LCD_BL_GPIO);
|
||||
gpio_bl.direction(Gpio::Session::OUT);
|
||||
gpio_bl.write(true);
|
||||
Gpio::Connection gpio_ct(_env, LCD_CONT_GPIO);
|
||||
gpio_ct.direction(Gpio::Session::OUT);
|
||||
gpio_ct.write(true);
|
||||
break;
|
||||
}
|
||||
case Platform::Session::SMD:
|
||||
_ipu.init(_width, _height, _width * BYTES_PER_PIXEL,
|
||||
phys_base, false);
|
||||
_platform.enable(Platform::Session::PWM);
|
||||
_pwm.enable_display();
|
||||
break;
|
||||
default:
|
||||
error("unknown board revision!");
|
||||
return false;
|
||||
}
|
||||
_ipu.init(_width, _height, _width * BYTES_PER_PIXEL,
|
||||
phys_base, _disp0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ struct Main
|
||||
|
||||
Genode::Attached_rom_dataspace _config { _env, "config" };
|
||||
|
||||
Framebuffer::Driver _driver { _env };
|
||||
Framebuffer::Driver _driver { _env, _config.xml() };
|
||||
|
||||
Framebuffer::Session_component _fb_session { _env, _driver,
|
||||
config_attribute(_config.xml(), "buffered") };
|
||||
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* \brief Input-driver
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2013-03-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-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 _DRIVERS__INPUT__SPEC__IMX53__DRIVER_H_
|
||||
#define _DRIVERS__INPUT__SPEC__IMX53__DRIVER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
#include <base/signal.h>
|
||||
#include <gpio_session/connection.h>
|
||||
|
||||
/* local includes */
|
||||
#include <egalax_ts.h>
|
||||
#include <mpr121.h>
|
||||
|
||||
namespace Input {
|
||||
class Tablet_driver;
|
||||
}
|
||||
|
||||
|
||||
class Input::Tablet_driver
|
||||
{
|
||||
private:
|
||||
|
||||
enum Gpio_irqs {
|
||||
GPIO_TOUCH = 84,
|
||||
GPIO_BUTTON = 132,
|
||||
};
|
||||
|
||||
Event_queue &_ev_queue;
|
||||
Gpio::Connection _gpio_ts;
|
||||
Gpio::Connection _gpio_bt;
|
||||
Genode::Irq_session_client _irq_ts;
|
||||
Genode::Irq_session_client _irq_bt;
|
||||
Genode::Io_signal_handler<Tablet_driver> _ts_dispatcher;
|
||||
Genode::Io_signal_handler<Tablet_driver> _bt_dispatcher;
|
||||
Touchscreen _touchscreen;
|
||||
Buttons _buttons;
|
||||
|
||||
void _handle_ts()
|
||||
{
|
||||
_touchscreen.event(_ev_queue);
|
||||
_irq_ts.ack_irq();
|
||||
}
|
||||
|
||||
void _handle_bt()
|
||||
{
|
||||
_buttons.event(_ev_queue);
|
||||
_irq_bt.ack_irq();
|
||||
}
|
||||
|
||||
Tablet_driver(Genode::Env &env, Event_queue &ev_queue)
|
||||
:
|
||||
_ev_queue(ev_queue),
|
||||
_gpio_ts(env, GPIO_TOUCH),
|
||||
_gpio_bt(env, GPIO_BUTTON),
|
||||
_irq_ts(_gpio_ts.irq_session(Gpio::Session::LOW_LEVEL)),
|
||||
_irq_bt(_gpio_bt.irq_session(Gpio::Session::FALLING_EDGE)),
|
||||
_ts_dispatcher(env.ep(), *this, &Tablet_driver::_handle_ts),
|
||||
_bt_dispatcher(env.ep(), *this, &Tablet_driver::_handle_bt),
|
||||
_touchscreen(env),
|
||||
_buttons(env)
|
||||
{
|
||||
/* GPIO touchscreen handling */
|
||||
_gpio_ts.direction(Gpio::Session::OUT);
|
||||
_gpio_ts.write(true);
|
||||
_gpio_ts.direction(Gpio::Session::IN);
|
||||
|
||||
_irq_ts.sigh(_ts_dispatcher);
|
||||
_irq_ts.ack_irq();
|
||||
|
||||
/* GPIO button handling */
|
||||
_gpio_bt.direction(Gpio::Session::OUT);
|
||||
_gpio_bt.write(true);
|
||||
_gpio_bt.direction(Gpio::Session::IN);
|
||||
|
||||
_irq_bt.sigh(_bt_dispatcher);
|
||||
_irq_bt.ack_irq();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static Tablet_driver* factory(Genode::Env &env, Event_queue &ev_queue);
|
||||
};
|
||||
|
||||
#endif /* _DRIVERS__INPUT__SPEC__IMX53__DRIVER_H_ */
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* \brief EETI eGalaxy touchscreen driver
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2013-03-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-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 _DRIVERS__INPUT__SPEC__IMX53__EGALAX_TS_H_
|
||||
#define _DRIVERS__INPUT__SPEC__IMX53__EGALAX_TS_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <drivers/defs/imx53.h>
|
||||
#include <base/attached_io_mem_dataspace.h>
|
||||
#include <input/event_queue.h>
|
||||
#include <input/event.h>
|
||||
#include <input/keycodes.h>
|
||||
|
||||
/* local includes */
|
||||
#include <i2c.h>
|
||||
|
||||
namespace Input {
|
||||
class Touchscreen;
|
||||
}
|
||||
|
||||
|
||||
class Input::Touchscreen {
|
||||
|
||||
private:
|
||||
|
||||
enum I2c_addresses { I2C_ADDR = 0x4 };
|
||||
enum Finger_state { PRESSED, RELEASED };
|
||||
|
||||
Irq_handler _irq_handler;
|
||||
Genode::Attached_io_mem_dataspace _i2c_ds;
|
||||
I2c::I2c _i2c;
|
||||
Genode::uint8_t _buf[10];
|
||||
Finger_state _state;
|
||||
|
||||
public:
|
||||
|
||||
Touchscreen(Genode::Env &env)
|
||||
:
|
||||
_irq_handler(env, Imx53::I2C_3_IRQ),
|
||||
_i2c_ds(env, Imx53::I2C_3_BASE, Imx53::I2C_3_SIZE),
|
||||
_i2c((Genode::addr_t)_i2c_ds.local_addr<void>(),
|
||||
_irq_handler),
|
||||
_state(RELEASED)
|
||||
{
|
||||
/* ask for touchscreen firmware version */
|
||||
Genode::uint8_t cmd[10] = { 0x03, 0x03, 0xa, 0x01, 0x41 };
|
||||
_i2c.send(I2C_ADDR, cmd, sizeof(cmd));
|
||||
}
|
||||
|
||||
void event(Event_queue &ev_queue)
|
||||
{
|
||||
_i2c.recv(I2C_ADDR, _buf, sizeof(_buf));
|
||||
|
||||
/* ignore all events except of multitouch*/
|
||||
if (_buf[0] != 4)
|
||||
return;
|
||||
|
||||
int x = (_buf[3] << 8) | _buf[2];
|
||||
int y = (_buf[5] << 8) | _buf[4];
|
||||
|
||||
Genode::uint8_t state = _buf[1];
|
||||
bool valid = state & (1 << 7);
|
||||
int id = (state >> 2) & 0xf;
|
||||
int down = state & 1;
|
||||
|
||||
if (!valid || id > 5)
|
||||
return; /* invalid point */
|
||||
|
||||
x = 102400 / (3276700 / x);
|
||||
y = 76800 / (3276700 / y);
|
||||
|
||||
/* motion event */
|
||||
ev_queue.add(Input::Absolute_motion{x, y});
|
||||
|
||||
/* button event */
|
||||
if ((down && (_state == RELEASED)) || (!down && (_state == PRESSED))) {
|
||||
|
||||
if (down) ev_queue.add(Input::Press {Input::BTN_LEFT});
|
||||
else ev_queue.add(Input::Release{Input::BTN_LEFT});
|
||||
|
||||
_state = down ? PRESSED : RELEASED;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _DRIVERS__INPUT__SPEC__IMX53__EGALAX_TS_H_ */
|
@ -1,181 +0,0 @@
|
||||
/*
|
||||
* \brief Driver for the i.MX53 i2c controller
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2013-03-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-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 _DRIVERS__INPUT__SPEC__IMX53__I2C_H_
|
||||
#define _DRIVERS__INPUT__SPEC__IMX53__I2C_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/mmio.h>
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
/* local includes */
|
||||
#include "irq_handler.h"
|
||||
|
||||
namespace I2c
|
||||
{
|
||||
class I2c;
|
||||
}
|
||||
|
||||
|
||||
class I2c::I2c : Genode::Mmio
|
||||
{
|
||||
private:
|
||||
|
||||
struct Address : public Register<0x0, 8>
|
||||
{
|
||||
struct Addr : Bitfield<1,7> {};
|
||||
};
|
||||
|
||||
struct Freq_divider : public Register<0x4, 8> {};
|
||||
|
||||
struct Control : public Register<0x8, 8>
|
||||
{
|
||||
struct Repeat_start : Bitfield<2,1> {};
|
||||
struct Tx_ack_enable : Bitfield<3,1> {};
|
||||
struct Tx_rx_select : Bitfield<4,1> {};
|
||||
struct Master_slave_select : Bitfield<5,1> {};
|
||||
struct Irq_enable : Bitfield<6,1> {};
|
||||
struct Enable : Bitfield<7,1> {};
|
||||
};
|
||||
|
||||
struct Status : public Register<0xc, 8>
|
||||
{
|
||||
struct Rcv_ack : Bitfield<0,1> {};
|
||||
struct Irq : Bitfield<1,1> {};
|
||||
struct Slave_rw : Bitfield<2,1> {};
|
||||
struct Arbitration_lost : Bitfield<4,1> {};
|
||||
struct Busy : Bitfield<5,1> {};
|
||||
struct Addressed_as_slave : Bitfield<6,1> {};
|
||||
struct Data_transfer : Bitfield<7,1> {};
|
||||
};
|
||||
|
||||
struct Data : public Register<0x10, 8> { };
|
||||
|
||||
|
||||
class No_ack : Genode::Exception {};
|
||||
|
||||
Irq_handler & _irq_handler;
|
||||
|
||||
void _busy() { while (!read<Status::Busy>()); }
|
||||
|
||||
void _start()
|
||||
{
|
||||
/* clock enable */
|
||||
|
||||
write<Freq_divider>(0x2c);
|
||||
write<Status>(0);
|
||||
write<Control>(Control::Enable::bits(1));
|
||||
|
||||
while (!read<Control::Enable>()) { ; }
|
||||
|
||||
write<Control::Master_slave_select>(1);
|
||||
|
||||
_busy();
|
||||
|
||||
write<Control>(Control::Tx_rx_select::bits(1) |
|
||||
Control::Tx_ack_enable::bits(1) |
|
||||
Control::Irq_enable::bits(1) |
|
||||
Control::Master_slave_select::bits(1) |
|
||||
Control::Enable::bits(1));
|
||||
}
|
||||
|
||||
void _stop()
|
||||
{
|
||||
write<Control>(0);
|
||||
|
||||
/* clock disable */
|
||||
}
|
||||
|
||||
void _write(Genode::uint8_t value)
|
||||
{
|
||||
write<Data>(value);
|
||||
|
||||
do { _irq_handler.wait(); }
|
||||
while (!read<Status::Irq>());
|
||||
|
||||
write<Status::Irq>(0);
|
||||
if (read<Status::Rcv_ack>()) throw No_ack();
|
||||
|
||||
_irq_handler.ack();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
I2c(Genode::addr_t const base, Irq_handler &irq_handler)
|
||||
: Mmio(base),
|
||||
_irq_handler(irq_handler)
|
||||
{
|
||||
write<Control>(0);
|
||||
write<Status>(0);
|
||||
}
|
||||
|
||||
void send(Genode::uint8_t addr, const Genode::uint8_t *buf,
|
||||
Genode::size_t num)
|
||||
{
|
||||
while (true) {
|
||||
try {
|
||||
_start();
|
||||
|
||||
_write(addr << 1);
|
||||
for (Genode::size_t i = 0; i < num; i++)
|
||||
_write(buf[i]);
|
||||
|
||||
_stop();
|
||||
return;
|
||||
} catch(No_ack) { }
|
||||
_stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void recv(Genode::uint8_t addr, Genode::uint8_t *buf,
|
||||
Genode::size_t num)
|
||||
{
|
||||
while (true) {
|
||||
try {
|
||||
_start();
|
||||
_write(addr << 1 | 1);
|
||||
write<Control::Tx_rx_select>(0);
|
||||
if (num > 1)
|
||||
write<Control::Tx_ack_enable>(0);
|
||||
read<Data>(); /* dummy read */
|
||||
|
||||
for (Genode::size_t i = 0; i < num; i++) {
|
||||
|
||||
do { _irq_handler.wait(); }
|
||||
while (!read<Status::Irq>());
|
||||
|
||||
write<Status::Irq>(0);
|
||||
|
||||
if (i == num-1) {
|
||||
write<Control::Tx_rx_select>(0);
|
||||
write<Control::Master_slave_select>(0);
|
||||
while (read<Status::Busy>()) ;
|
||||
} else if (i == num-2) {
|
||||
write<Control::Tx_ack_enable>(1);
|
||||
}
|
||||
|
||||
buf[i] = read<Data>();
|
||||
_irq_handler.ack();
|
||||
}
|
||||
|
||||
_stop();
|
||||
return;
|
||||
} catch(No_ack) { }
|
||||
_stop();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /* _DRIVERS__INPUT__SPEC__IMX53__I2C_H_ */
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* \brief Input-interrupt handler
|
||||
* \author Josef Soentgen
|
||||
* \date 2015-04-08
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015-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 _IRQ_HANDLER_H_
|
||||
#define _IRQ_HANDLER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <irq_session/connection.h>
|
||||
|
||||
class Irq_handler
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Env &_env;
|
||||
Genode::Irq_connection _irq;
|
||||
Genode::Io_signal_handler<Irq_handler> _handler;
|
||||
|
||||
unsigned _sem_cnt = 1;
|
||||
|
||||
void _handle() { _sem_cnt = 0; }
|
||||
|
||||
public:
|
||||
|
||||
Irq_handler(Genode::Env &env, int irq_number)
|
||||
:
|
||||
_env(env), _irq(env, irq_number),
|
||||
_handler(env.ep(), *this, &Irq_handler::_handle)
|
||||
{
|
||||
_irq.sigh(_handler);
|
||||
_irq.ack_irq();
|
||||
}
|
||||
|
||||
void wait()
|
||||
{
|
||||
_sem_cnt++;
|
||||
while (_sem_cnt > 0)
|
||||
_env.ep().wait_and_dispatch_one_io_signal();
|
||||
}
|
||||
|
||||
void ack() { _irq.ack_irq(); }
|
||||
};
|
||||
|
||||
#endif /* _IRQ_HANDLER_H_ */
|
@ -1,65 +0,0 @@
|
||||
/**
|
||||
* \brief Input driver front-end
|
||||
* \author Norman Feske
|
||||
* \author Christian Helmuth
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2006-08-30
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-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.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <base/env.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <platform_session/connection.h>
|
||||
#include <input/component.h>
|
||||
#include <input/root.h>
|
||||
|
||||
/* local includes */
|
||||
#include <driver.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
Input::Tablet_driver* Input::Tablet_driver::factory(Genode::Env &env,
|
||||
Event_queue &ev_queue)
|
||||
{
|
||||
static Input::Tablet_driver driver(env, ev_queue);
|
||||
return &driver;
|
||||
}
|
||||
|
||||
|
||||
struct Main
|
||||
{
|
||||
Genode::Env &env;
|
||||
|
||||
Input::Session_component session { env, env.ram() };
|
||||
Input::Root_component root { env.ep().rpc_ep(), session };
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
Platform::Connection plat_drv { env };
|
||||
switch (plat_drv.revision()) {
|
||||
case Platform::Session::SMD:
|
||||
plat_drv.enable(Platform::Session::I2C_2);
|
||||
plat_drv.enable(Platform::Session::I2C_3);
|
||||
plat_drv.enable(Platform::Session::BUTTONS);
|
||||
Input::Tablet_driver::factory(env, session.event_queue());
|
||||
break;
|
||||
default:
|
||||
warning("No input driver available for this board");
|
||||
}
|
||||
|
||||
/* tell parent about the service */
|
||||
env.parent().announce(env.ep().manage(root));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env) { static Main main(env); }
|
@ -1,107 +0,0 @@
|
||||
/*
|
||||
* \brief Freescale MPR121 capacitative button driver
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2013-03-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-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 _DRIVERS__INPUT__SPEC__IMX53__MPR121_H_
|
||||
#define _DRIVERS__INPUT__SPEC__IMX53__MPR121_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <drivers/defs/imx53.h>
|
||||
#include <base/attached_io_mem_dataspace.h>
|
||||
#include <input/event_queue.h>
|
||||
#include <input/event.h>
|
||||
#include <input/keycodes.h>
|
||||
|
||||
/* local includes */
|
||||
#include <i2c.h>
|
||||
|
||||
namespace Input {
|
||||
class Buttons;
|
||||
}
|
||||
|
||||
|
||||
class Input::Buttons {
|
||||
|
||||
private:
|
||||
|
||||
enum {
|
||||
I2C_ADDR = 0x5a,
|
||||
};
|
||||
|
||||
enum Events {
|
||||
RELEASE = 0,
|
||||
BACK = 1,
|
||||
HOME = 2,
|
||||
MENU = 4,
|
||||
POWER = 8,
|
||||
};
|
||||
|
||||
Irq_handler _irq_handler;
|
||||
Genode::Attached_io_mem_dataspace _i2c_ds;
|
||||
I2c::I2c _i2c;
|
||||
Genode::uint8_t _state;
|
||||
|
||||
public:
|
||||
|
||||
Buttons(Genode::Env &env)
|
||||
:
|
||||
_irq_handler(env, Imx53::I2C_2_IRQ),
|
||||
_i2c_ds(env, Imx53::I2C_2_BASE, Imx53::I2C_2_SIZE),
|
||||
_i2c((Genode::addr_t)_i2c_ds.local_addr<void>(),
|
||||
_irq_handler),
|
||||
_state(0)
|
||||
{
|
||||
static Genode::uint8_t init_cmd[][2] = {
|
||||
{0x41, 0x8 }, {0x42, 0x5 }, {0x43, 0x8 },
|
||||
{0x44, 0x5 }, {0x45, 0x8 }, {0x46, 0x5 },
|
||||
{0x47, 0x8 }, {0x48, 0x5 }, {0x49, 0x8 },
|
||||
{0x4a, 0x5 }, {0x4b, 0x8 }, {0x4c, 0x5 },
|
||||
{0x4d, 0x8 }, {0x4e, 0x5 }, {0x4f, 0x8 },
|
||||
{0x50, 0x5 }, {0x51, 0x8 }, {0x52, 0x5 },
|
||||
{0x53, 0x8 }, {0x54, 0x5 }, {0x55, 0x8 },
|
||||
{0x56, 0x5 }, {0x57, 0x8 }, {0x58, 0x5 },
|
||||
{0x59, 0x8 }, {0x5a, 0x5 }, {0x2b, 0x1 },
|
||||
{0x2c, 0x1 }, {0x2d, 0x0 }, {0x2e, 0x0 },
|
||||
{0x2f, 0x1 }, {0x30, 0x1 }, {0x31, 0xff},
|
||||
{0x32, 0x2 }, {0x5d, 0x4 }, {0x5c, 0xb },
|
||||
{0x7b, 0xb }, {0x7d, 0xc9}, {0x7e, 0x82},
|
||||
{0x7f, 0xb4}, {0x5e, 0x84}};
|
||||
|
||||
/* initialize mpr121 touch button device */
|
||||
for (unsigned i = 0; i < sizeof(init_cmd)/2; i++)
|
||||
_i2c.send(I2C_ADDR, init_cmd[i], 2);
|
||||
}
|
||||
|
||||
void event(Event_queue &ev_queue)
|
||||
{
|
||||
int buttons[] = { BACK, HOME, MENU, POWER };
|
||||
int codes[] = { Input::KEY_BACK, Input::KEY_HOME,
|
||||
Input::KEY_MENU, Input::KEY_POWER};
|
||||
|
||||
Genode::uint8_t buf = 0;
|
||||
_i2c.send(I2C_ADDR, &buf, 1);
|
||||
_i2c.recv(I2C_ADDR, &buf, 1);
|
||||
|
||||
for (unsigned i = 0; i < (sizeof(buttons)/sizeof(int)); i++) {
|
||||
if ((_state & buttons[i]) == (buf & buttons[i]))
|
||||
continue;
|
||||
|
||||
Input::Keycode const key = Input::Keycode(codes[i]);
|
||||
|
||||
if (buf & buttons[i]) ev_queue.add(Input::Press {key});
|
||||
else ev_queue.add(Input::Release{key});
|
||||
};
|
||||
_state = buf;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _DRIVERS__INPUT__SPEC__IMX53__MPR121_H_ */
|
@ -1,6 +0,0 @@
|
||||
TARGET = imx53_input_drv
|
||||
REQUIRES = arm_v7
|
||||
SRC_CC = main.cc
|
||||
LIBS = base
|
||||
INC_DIR += $(PRG_DIR)
|
||||
INC_DIR += $(call select_from_repositories,include/spec/imx53)
|
Loading…
Reference in New Issue
Block a user