From f653be1ebce88466e7f5f723d235deef5ea1431a Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Thu, 22 Feb 2018 15:25:14 +0100 Subject: [PATCH] gpio_drv: add support for i.MX6 Fix #2750 --- repos/base/include/drivers/defs/imx6.h | 31 +++++++++++++ repos/base/mk/spec/imx6.mk | 2 +- .../drivers/gpio/spec/{imx53 => imx}/driver.h | 44 +++++++++---------- .../drivers/gpio/spec/{imx53 => imx}/gpio.h | 8 ++-- .../drivers/gpio/spec/{imx53 => imx}/main.cc | 12 ++--- repos/os/src/drivers/gpio/spec/imx53/board.h | 22 ++++++++++ .../os/src/drivers/gpio/spec/imx53/target.mk | 5 +-- repos/os/src/drivers/gpio/spec/imx6/board.h | 22 ++++++++++ repos/os/src/drivers/gpio/spec/imx6/target.mk | 7 +++ 9 files changed, 117 insertions(+), 36 deletions(-) rename repos/os/src/drivers/gpio/spec/{imx53 => imx}/driver.h (84%) rename repos/os/src/drivers/gpio/spec/{imx53 => imx}/gpio.h (87%) rename repos/os/src/drivers/gpio/spec/{imx53 => imx}/main.cc (83%) create mode 100644 repos/os/src/drivers/gpio/spec/imx53/board.h create mode 100644 repos/os/src/drivers/gpio/spec/imx6/board.h create mode 100644 repos/os/src/drivers/gpio/spec/imx6/target.mk diff --git a/repos/base/include/drivers/defs/imx6.h b/repos/base/include/drivers/defs/imx6.h index c4934336d9..3874e4a069 100644 --- a/repos/base/include/drivers/defs/imx6.h +++ b/repos/base/include/drivers/defs/imx6.h @@ -22,6 +22,37 @@ namespace Imx6 { SDHC_IRQ = 54, SDHC_MMIO_BASE = 0x02190000, SDHC_MMIO_SIZE = 0x00004000, + + /* GPIO */ + GPIO1_MMIO_BASE = 0x0209c000, + GPIO1_MMIO_SIZE = 0x4000, + GPIO2_MMIO_BASE = 0x020a0000, + GPIO2_MMIO_SIZE = 0x4000, + GPIO3_MMIO_BASE = 0x020a4000, + GPIO3_MMIO_SIZE = 0x4000, + GPIO4_MMIO_BASE = 0x020a8000, + GPIO4_MMIO_SIZE = 0x4000, + GPIO5_MMIO_BASE = 0x020ac000, + GPIO5_MMIO_SIZE = 0x4000, + GPIO6_MMIO_BASE = 0x020b0000, + GPIO6_MMIO_SIZE = 0x4000, + GPIO7_MMIO_BASE = 0x020b4000, + GPIO7_MMIO_SIZE = 0x4000, + GPIO1_IRQL = 98, + GPIO1_IRQH = 99, + GPIO2_IRQL = 100, + GPIO2_IRQH = 101, + GPIO3_IRQL = 102, + GPIO3_IRQH = 103, + GPIO4_IRQL = 104, + GPIO4_IRQH = 105, + GPIO5_IRQL = 106, + GPIO5_IRQH = 107, + GPIO6_IRQL = 108, + GPIO6_IRQH = 109, + GPIO7_IRQL = 110, + GPIO7_IRQH = 111, + }; }; diff --git a/repos/base/mk/spec/imx6.mk b/repos/base/mk/spec/imx6.mk index 289335d740..a2a7bbf35e 100644 --- a/repos/base/mk/spec/imx6.mk +++ b/repos/base/mk/spec/imx6.mk @@ -1,4 +1,4 @@ -SPECS += cortex_a9 +SPECS += cortex_a9 gpio REP_INC_DIR += include/spec/imx6 diff --git a/repos/os/src/drivers/gpio/spec/imx53/driver.h b/repos/os/src/drivers/gpio/spec/imx/driver.h similarity index 84% rename from repos/os/src/drivers/gpio/spec/imx53/driver.h rename to repos/os/src/drivers/gpio/spec/imx/driver.h index 1b0bb8d948..4843539f12 100644 --- a/repos/os/src/drivers/gpio/spec/imx53/driver.h +++ b/repos/os/src/drivers/gpio/spec/imx/driver.h @@ -1,5 +1,5 @@ /* - * \brief Gpio driver for the i.MX53 + * \brief Gpio driver for Freescale * \author Ivan Loskutov * \author Nikolay Golikov * \author Stefan Kalkowski @@ -14,21 +14,21 @@ * under the terms of the GNU Affero General Public License version 3. */ -#ifndef _DRIVERS__GPIO__SPEC__IMX53__DRIVER_H_ -#define _DRIVERS__GPIO__SPEC__IMX53__DRIVER_H_ +#ifndef _DRIVERS__GPIO__SPEC__IMX__DRIVER_H_ +#define _DRIVERS__GPIO__SPEC__IMX__DRIVER_H_ /* Genode includes */ -#include #include #include #include #include /* local includes */ -#include "gpio.h" +#include +#include -class Imx53_driver : public Gpio::Driver +class Imx_driver : public Gpio::Driver { private: @@ -152,22 +152,22 @@ class Imx53_driver : public Gpio::Driver int _gpio_index(int gpio) { return gpio & 0x1f; } - Imx53_driver(Genode::Env &env) + Imx_driver(Genode::Env &env) : - _gpio_bank_0(env, Imx53::GPIO1_MMIO_BASE, Imx53::GPIO1_MMIO_SIZE, - Imx53::GPIO1_IRQL, Imx53::GPIO1_IRQH), - _gpio_bank_1(env, Imx53::GPIO2_MMIO_BASE, Imx53::GPIO2_MMIO_SIZE, - Imx53::GPIO2_IRQL, Imx53::GPIO2_IRQH), - _gpio_bank_2(env, Imx53::GPIO3_MMIO_BASE, Imx53::GPIO3_MMIO_SIZE, - Imx53::GPIO3_IRQL, Imx53::GPIO3_IRQH), - _gpio_bank_3(env, Imx53::GPIO4_MMIO_BASE, Imx53::GPIO4_MMIO_SIZE, - Imx53::GPIO4_IRQL, Imx53::GPIO4_IRQH), - _gpio_bank_4(env, Imx53::GPIO5_MMIO_BASE, Imx53::GPIO5_MMIO_SIZE, - Imx53::GPIO5_IRQL, Imx53::GPIO5_IRQH), - _gpio_bank_5(env, Imx53::GPIO6_MMIO_BASE, Imx53::GPIO6_MMIO_SIZE, - Imx53::GPIO6_IRQL, Imx53::GPIO6_IRQH), - _gpio_bank_6(env, Imx53::GPIO7_MMIO_BASE, Imx53::GPIO7_MMIO_SIZE, - Imx53::GPIO7_IRQL, Imx53::GPIO7_IRQH) + _gpio_bank_0(env, Board::GPIO1_MMIO_BASE, Board::GPIO1_MMIO_SIZE, + Board::GPIO1_IRQL, Board::GPIO1_IRQH), + _gpio_bank_1(env, Board::GPIO2_MMIO_BASE, Board::GPIO2_MMIO_SIZE, + Board::GPIO2_IRQL, Board::GPIO2_IRQH), + _gpio_bank_2(env, Board::GPIO3_MMIO_BASE, Board::GPIO3_MMIO_SIZE, + Board::GPIO3_IRQL, Board::GPIO3_IRQH), + _gpio_bank_3(env, Board::GPIO4_MMIO_BASE, Board::GPIO4_MMIO_SIZE, + Board::GPIO4_IRQL, Board::GPIO4_IRQH), + _gpio_bank_4(env, Board::GPIO5_MMIO_BASE, Board::GPIO5_MMIO_SIZE, + Board::GPIO5_IRQL, Board::GPIO5_IRQH), + _gpio_bank_5(env, Board::GPIO6_MMIO_BASE, Board::GPIO6_MMIO_SIZE, + Board::GPIO6_IRQL, Board::GPIO6_IRQH), + _gpio_bank_6(env, Board::GPIO7_MMIO_BASE, Board::GPIO7_MMIO_SIZE, + Board::GPIO7_IRQL, Board::GPIO7_IRQH) { for (unsigned i = 0; i < MAX_BANKS; ++i) { Gpio_reg *regs = _gpio_bank(i << PIN_SHIFT)->regs(); @@ -182,7 +182,7 @@ class Imx53_driver : public Gpio::Driver public: - static Imx53_driver &factory(Genode::Env &env); + static Imx_driver &factory(Genode::Env &env); /****************************** ** Gpio::Driver interface ** diff --git a/repos/os/src/drivers/gpio/spec/imx53/gpio.h b/repos/os/src/drivers/gpio/spec/imx/gpio.h similarity index 87% rename from repos/os/src/drivers/gpio/spec/imx53/gpio.h rename to repos/os/src/drivers/gpio/spec/imx/gpio.h index f5eb01c4be..48f655e280 100644 --- a/repos/os/src/drivers/gpio/spec/imx53/gpio.h +++ b/repos/os/src/drivers/gpio/spec/imx/gpio.h @@ -1,5 +1,5 @@ /* - * \brief Gpio driver for the i.MX53 + * \brief Gpio driver for Freescale * \author Nikolay Golikov * \author Stefan Kalkowski * \date 2012-12-06 @@ -13,8 +13,8 @@ * under the terms of the GNU Affero General Public License version 3. */ -#ifndef _DRIVERS__GPIO__SPEC__IMX53__GPIO_H_ -#define _DRIVERS__GPIO__SPEC__IMX53__GPIO_H_ +#ifndef _DRIVERS__GPIO__SPEC__IMX__GPIO_H_ +#define _DRIVERS__GPIO__SPEC__IMX__GPIO_H_ /* Genode includes */ #include @@ -46,4 +46,4 @@ struct Gpio_reg : Genode::Attached_io_mem_dataspace, Genode::Mmio struct Edge_sel : Register_array<0x1c, 32, 32, 1> {}; }; -#endif /* _DRIVERS__GPIO__SPEC__IMX53__GPIO_H_ */ +#endif /* _DRIVERS__GPIO__SPEC__IMX__GPIO_H_ */ diff --git a/repos/os/src/drivers/gpio/spec/imx53/main.cc b/repos/os/src/drivers/gpio/spec/imx/main.cc similarity index 83% rename from repos/os/src/drivers/gpio/spec/imx53/main.cc rename to repos/os/src/drivers/gpio/spec/imx/main.cc index 9eaef43db8..14c71e7339 100644 --- a/repos/os/src/drivers/gpio/spec/imx53/main.cc +++ b/repos/os/src/drivers/gpio/spec/imx/main.cc @@ -1,5 +1,5 @@ /* - * \brief Gpio driver for the i.MX53 + * \brief Gpio driver for Freescale * \author Ivan Loskutov * \author Nikolay Golikov * \author Stefan Kalkowski @@ -26,9 +26,9 @@ #include -Imx53_driver &Imx53_driver::factory(Genode::Env &env) +Imx_driver &Imx_driver::factory(Genode::Env &env) { - static Imx53_driver driver(env); + static Imx_driver driver(env); return driver; } @@ -37,7 +37,7 @@ struct Main { Genode::Env &env; Genode::Sliced_heap sliced_heap; - Imx53_driver &driver; + Imx_driver &driver; Gpio::Root root; Genode::Attached_rom_dataspace config_rom { env, "config" }; @@ -46,12 +46,12 @@ struct Main : env(env), sliced_heap(env.ram(), env.rm()), - driver(Imx53_driver::factory(env)), + driver(Imx_driver::factory(env)), root(&env.ep().rpc_ep(), &sliced_heap, driver) { using namespace Genode; - log("--- i.MX53 gpio driver ---"); + log("--- Freescale gpio driver ---"); Gpio::process_config(config_rom.xml(), driver); diff --git a/repos/os/src/drivers/gpio/spec/imx53/board.h b/repos/os/src/drivers/gpio/spec/imx53/board.h new file mode 100644 index 0000000000..b78ce03af4 --- /dev/null +++ b/repos/os/src/drivers/gpio/spec/imx53/board.h @@ -0,0 +1,22 @@ +/* + * \brief Gpio driver for the i.MX53 + * \author Stefan Kalkowski + * \date 2018-02-22 + */ + +/* + * Copyright (C) 2018 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__GPIO__SPEC__IMX53__BOARD_H_ +#define _DRIVERS__GPIO__SPEC__IMX53__BOARD_H_ + +/* Genode includes */ +#include + +namespace Board { using namespace Imx53; } + +#endif /* _DRIVERS__GPIO__SPEC__IMX53__BOARD_H_ */ diff --git a/repos/os/src/drivers/gpio/spec/imx53/target.mk b/repos/os/src/drivers/gpio/spec/imx53/target.mk index 4d2de30c57..54b51e63f1 100644 --- a/repos/os/src/drivers/gpio/spec/imx53/target.mk +++ b/repos/os/src/drivers/gpio/spec/imx53/target.mk @@ -2,7 +2,6 @@ TARGET = gpio_drv REQUIRES = imx53 SRC_CC = main.cc LIBS = base -INC_DIR += $(PRG_DIR) - -vpath main.cc $(PRG_DIR) +INC_DIR += $(PRG_DIR) $(REP_DIR)/src/drivers/gpio/spec/imx +vpath main.cc $(REP_DIR)/src/drivers/gpio/spec/imx diff --git a/repos/os/src/drivers/gpio/spec/imx6/board.h b/repos/os/src/drivers/gpio/spec/imx6/board.h new file mode 100644 index 0000000000..77c99331b0 --- /dev/null +++ b/repos/os/src/drivers/gpio/spec/imx6/board.h @@ -0,0 +1,22 @@ +/* + * \brief Gpio driver for the i.MX6 SoCs + * \author Stefan Kalkowski + * \date 2018-02-22 + */ + +/* + * Copyright (C) 2018 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__GPIO__SPEC__IMX6__BOARD_H_ +#define _DRIVERS__GPIO__SPEC__IMX6__BOARD_H_ + +/* Genode includes */ +#include + +namespace Board { using namespace Imx6; } + +#endif /* _DRIVERS__GPIO__SPEC__IMX6__BOARD_H_ */ diff --git a/repos/os/src/drivers/gpio/spec/imx6/target.mk b/repos/os/src/drivers/gpio/spec/imx6/target.mk new file mode 100644 index 0000000000..b8c830ac1a --- /dev/null +++ b/repos/os/src/drivers/gpio/spec/imx6/target.mk @@ -0,0 +1,7 @@ +TARGET = gpio_drv +REQUIRES = imx6 +SRC_CC = main.cc +LIBS = base +INC_DIR += $(PRG_DIR) $(REP_DIR)/src/drivers/gpio/spec/imx + +vpath main.cc $(REP_DIR)/src/drivers/gpio/spec/imx