All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] MIPS: XBurst: add gpio support
@ 2014-06-26 22:49 Antony Pavlov
  2014-06-26 22:49 ` [PATCH 1/4] gpio: add jz4740-gpio driver for Ingenic MIPS SoCs Antony Pavlov
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Antony Pavlov @ 2014-06-26 22:49 UTC (permalink / raw)
  To: barebox

Antony Pavlov (4):
  gpio: add jz4740-gpio driver for Ingenic MIPS SoCs
  MIPS: XBurst: use gpiolib
  MIPS: dts: jz4755.dtsi: add gpio
  MIPS: ritmix-rzx50_defconfig: enable gpio stuff

 arch/mips/Kconfig                        |   1 +
 arch/mips/configs/ritmix-rzx50_defconfig |  28 ++++---
 arch/mips/dts/jz4755.dtsi                |  42 ++++++++++
 drivers/gpio/Kconfig                     |   6 ++
 drivers/gpio/Makefile                    |   1 +
 drivers/gpio/gpio-jz4740.c               | 140 +++++++++++++++++++++++++++++++
 6 files changed, 205 insertions(+), 13 deletions(-)
 create mode 100644 drivers/gpio/gpio-jz4740.c

-- 
1.9.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] gpio: add jz4740-gpio driver for Ingenic MIPS SoCs
  2014-06-26 22:49 [PATCH 0/4] MIPS: XBurst: add gpio support Antony Pavlov
@ 2014-06-26 22:49 ` Antony Pavlov
  2014-06-26 22:49 ` [PATCH 2/4] MIPS: XBurst: use gpiolib Antony Pavlov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2014-06-26 22:49 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 drivers/gpio/Kconfig       |   6 ++
 drivers/gpio/Makefile      |   1 +
 drivers/gpio/gpio-jz4740.c | 140 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 45b8c53..f98a9c0 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -37,6 +37,12 @@ config GPIO_GENERIC_PLATFORM
 config GPIO_IMX
 	def_bool ARCH_IMX
 
+config GPIO_JZ4740
+	bool "GPIO support for Ingenic SoCs"
+	depends on MACH_MIPS_XBURST
+	help
+	  Say yes here to enable the GPIO driver for the Ingenic SoCs.
+
 config GPIO_MALTA_FPGA_I2C
 	bool "Malta CBUS FPGA I2C GPIO"
 	depends on MACH_MIPS_MALTA
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index add6ffc..22d2ac0 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_GPIO_DAVINCI)	+= gpio-davinci.o
 obj-$(CONFIG_GPIO_CLPS711X)	+= gpio-clps711x.o
 obj-$(CONFIG_GPIO_GENERIC)	+= gpio-generic.o
 obj-$(CONFIG_GPIO_IMX)		+= gpio-imx.o
+obj-$(CONFIG_GPIO_JZ4740)	+= gpio-jz4740.o
 obj-$(CONFIG_GPIO_MALTA_FPGA_I2C) += gpio-malta-fpga-i2c.o
 obj-$(CONFIG_GPIO_ORION)	+= gpio-orion.o
 obj-$(CONFIG_GPIO_OMAP)		+= gpio-omap.o
diff --git a/drivers/gpio/gpio-jz4740.c b/drivers/gpio/gpio-jz4740.c
new file mode 100644
index 0000000..3c8efad
--- /dev/null
+++ b/drivers/gpio/gpio-jz4740.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2013, 2014 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * Based on Linux JZ4740 platform GPIO support:
+ * Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <gpio.h>
+#include <malloc.h>
+
+#define JZ_REG_GPIO_PIN			0x00
+#define JZ_REG_GPIO_DATA		0x10
+#define JZ_REG_GPIO_DATA_SET		0x14
+#define JZ_REG_GPIO_DATA_CLEAR		0x18
+#define JZ_REG_GPIO_DIRECTION		0x60
+#define JZ_REG_GPIO_DIRECTION_SET	0x64
+#define JZ_REG_GPIO_DIRECTION_CLEAR	0x68
+
+#define GPIO_TO_BIT(gpio) BIT(gpio & 0x1f)
+#define CHIP_TO_REG(chip, reg) (gpio_chip_to_jz4740_gpio_chip(chip)->base + (reg))
+
+struct jz4740_gpio_chip {
+	void __iomem *base;
+	struct gpio_chip chip;
+};
+
+static inline struct jz4740_gpio_chip *gpio_chip_to_jz4740_gpio_chip(struct gpio_chip *chip)
+{
+	return container_of(chip, struct jz4740_gpio_chip, chip);
+}
+
+static int jz4740_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
+{
+	return !!(readl(CHIP_TO_REG(chip, JZ_REG_GPIO_PIN)) & BIT(gpio));
+}
+
+static void jz4740_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
+{
+	uint32_t __iomem *reg = CHIP_TO_REG(chip, JZ_REG_GPIO_DATA_SET);
+	reg += !value;
+	writel(BIT(gpio), reg);
+}
+
+static int jz4740_gpio_get_direction(struct gpio_chip *chip, unsigned gpio)
+{
+	if (readl(CHIP_TO_REG(chip, JZ_REG_GPIO_DIRECTION)) & BIT(gpio))
+		return GPIOF_DIR_OUT;
+
+	return GPIOF_DIR_IN;
+}
+
+static int jz4740_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
+{
+	writel(BIT(gpio), CHIP_TO_REG(chip, JZ_REG_GPIO_DIRECTION_CLEAR));
+
+	return 0;
+}
+
+static int jz4740_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
+	int value)
+{
+	jz4740_gpio_set_value(chip, gpio, value);
+	writel(BIT(gpio), CHIP_TO_REG(chip, JZ_REG_GPIO_DIRECTION_SET));
+
+	return 0;
+}
+
+static struct gpio_ops jz4740_gpio_ops = {
+	.direction_input = jz4740_gpio_direction_input,
+	.direction_output = jz4740_gpio_direction_output,
+	.get_direction = jz4740_gpio_get_direction,
+	.get = jz4740_gpio_get_value,
+	.set = jz4740_gpio_set_value,
+};
+
+static int jz4740_gpio_probe(struct device_d *dev)
+{
+	void __iomem *base;
+	struct jz4740_gpio_chip *jz4740_gpio;
+	int ret;
+
+	base = dev_request_mem_region(dev, 0);
+	if (!base) {
+		dev_err(dev, "could not get memory region\n");
+		return -ENODEV;
+	}
+
+	jz4740_gpio = xzalloc(sizeof(*jz4740_gpio));
+	jz4740_gpio->base = base;
+	jz4740_gpio->chip.ops = &jz4740_gpio_ops;
+	jz4740_gpio->chip.base = -1; /* dev->id * 32; */
+	jz4740_gpio->chip.ngpio = 32;
+	jz4740_gpio->chip.dev = dev;
+
+	ret = gpiochip_add(&jz4740_gpio->chip);
+	if (ret) {
+		dev_err(dev, "couldn't add gpiochip\n");
+		free(jz4740_gpio);
+		return ret;
+	}
+
+	dev_dbg(dev, "probed gpiochip%d with base %d\n",
+				dev->id, jz4740_gpio->chip.base);
+
+	return 0;
+}
+
+static __maybe_unused struct of_device_id jz4740_gpio_dt_ids[] = {
+	{
+		.compatible = "ingenic,jz4740-gpio",
+	}, {
+		/* sentinel */
+	},
+};
+
+static struct driver_d jz4740_gpio_driver = {
+	.name = "jz4740-gpio",
+	.probe = jz4740_gpio_probe,
+	.of_compatible	= DRV_OF_COMPAT(jz4740_gpio_dt_ids),
+};
+
+static int jz4740_gpio_init(void)
+{
+	return platform_driver_register(&jz4740_gpio_driver);
+}
+coredevice_initcall(jz4740_gpio_init);
-- 
1.9.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] MIPS: XBurst: use gpiolib
  2014-06-26 22:49 [PATCH 0/4] MIPS: XBurst: add gpio support Antony Pavlov
  2014-06-26 22:49 ` [PATCH 1/4] gpio: add jz4740-gpio driver for Ingenic MIPS SoCs Antony Pavlov
@ 2014-06-26 22:49 ` Antony Pavlov
  2014-06-26 22:49 ` [PATCH 3/4] MIPS: dts: jz4755.dtsi: add gpio Antony Pavlov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2014-06-26 22:49 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/mips/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 077586c..d4e9e1c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -89,6 +89,7 @@ config MACH_MIPS_XBURST
 	select HAVE_PBL_IMAGE
 	select HAVE_IMAGE_COMPRESSION
 	select HAS_NMON
+	select GPIOLIB
 endchoice
 
 source arch/mips/mach-malta/Kconfig
-- 
1.9.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] MIPS: dts: jz4755.dtsi: add gpio
  2014-06-26 22:49 [PATCH 0/4] MIPS: XBurst: add gpio support Antony Pavlov
  2014-06-26 22:49 ` [PATCH 1/4] gpio: add jz4740-gpio driver for Ingenic MIPS SoCs Antony Pavlov
  2014-06-26 22:49 ` [PATCH 2/4] MIPS: XBurst: use gpiolib Antony Pavlov
@ 2014-06-26 22:49 ` Antony Pavlov
  2014-06-26 22:49 ` [PATCH 4/4] MIPS: ritmix-rzx50_defconfig: enable gpio stuff Antony Pavlov
  2014-06-27 19:40 ` [PATCH 0/4] MIPS: XBurst: add gpio support Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2014-06-26 22:49 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/mips/dts/jz4755.dtsi | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/arch/mips/dts/jz4755.dtsi b/arch/mips/dts/jz4755.dtsi
index 44ff912..0e655b6 100644
--- a/arch/mips/dts/jz4755.dtsi
+++ b/arch/mips/dts/jz4755.dtsi
@@ -31,5 +31,47 @@
 			clock-frequency = <12000000>;
 			status = "disabled";
 		};
+
+		gpio0: gpio@10010000 {
+			compatible = "ingenic,jz4740-gpio";
+			gpio-controller;
+			reg = <0xb0010000 0x100>;
+			#gpio-cells = <2>;
+		};
+
+		gpio1: gpio@10010100 {
+			compatible = "ingenic,jz4740-gpio";
+			gpio-controller;
+			reg = <0xb0010100 0x100>;
+			#gpio-cells = <2>;
+		};
+
+		gpio2: gpio@10010200 {
+			compatible = "ingenic,jz4740-gpio";
+			gpio-controller;
+			reg = <0xb0010200 0x100>;
+			#gpio-cells = <2>;
+		};
+
+		gpio3: gpio@10010300 {
+			compatible = "ingenic,jz4740-gpio";
+			gpio-controller;
+			reg = <0xb0010300 0x100>;
+			#gpio-cells = <2>;
+		};
+
+		gpio4: gpio@10010400 {
+			compatible = "ingenic,jz4740-gpio";
+			gpio-controller;
+			reg = <0xb0010400 0x100>;
+			#gpio-cells = <2>;
+		};
+
+		gpio5: gpio@10010500 {
+			compatible = "ingenic,jz4740-gpio";
+			gpio-controller;
+			reg = <0xb0010500 0x100>;
+			#gpio-cells = <2>;
+		};
 	};
 };
-- 
1.9.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] MIPS: ritmix-rzx50_defconfig: enable gpio stuff
  2014-06-26 22:49 [PATCH 0/4] MIPS: XBurst: add gpio support Antony Pavlov
                   ` (2 preceding siblings ...)
  2014-06-26 22:49 ` [PATCH 3/4] MIPS: dts: jz4755.dtsi: add gpio Antony Pavlov
@ 2014-06-26 22:49 ` Antony Pavlov
  2014-06-27 19:40 ` [PATCH 0/4] MIPS: XBurst: add gpio support Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2014-06-26 22:49 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/mips/configs/ritmix-rzx50_defconfig | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/arch/mips/configs/ritmix-rzx50_defconfig b/arch/mips/configs/ritmix-rzx50_defconfig
index 62f23b2..e6f10fb 100644
--- a/arch/mips/configs/ritmix-rzx50_defconfig
+++ b/arch/mips/configs/ritmix-rzx50_defconfig
@@ -6,34 +6,36 @@ CONFIG_PBL_IMAGE=y
 CONFIG_BAUDRATE=57600
 CONFIG_GLOB=y
 CONFIG_HUSH_FANCY_PROMPT=y
-CONFIG_CMD_GETOPT=y
 CONFIG_CMDLINE_EDITING=y
 CONFIG_AUTO_COMPLETE=y
 # CONFIG_DEFAULT_ENVIRONMENT is not set
 CONFIG_DEBUG_LL=y
-CONFIG_CMD_EDIT=y
-CONFIG_CMD_SLEEP=y
-CONFIG_CMD_LOADB=y
-CONFIG_CMD_LOADY=y
-CONFIG_CMD_LOADS=y
-CONFIG_CMD_SAVES=y
-CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_IOMEM=y
-CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_BOOTM_SHOW_TYPE=y
 CONFIG_CMD_BOOTM_VERBOSE=y
 CONFIG_CMD_BOOTM_INITRD=y
 CONFIG_CMD_BOOTM_OFTREE=y
 CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y
-CONFIG_CMD_UIMAGE=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_LOADB=y
+CONFIG_CMD_LOADS=y
+CONFIG_CMD_LOADY=y
 CONFIG_CMD_RESET=y
+CONFIG_CMD_SAVES=y
+CONFIG_CMD_UIMAGE=y
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_GETOPT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_GPIO=y
 CONFIG_CMD_POWEROFF=y
-CONFIG_CMD_GO=y
-CONFIG_CMD_OFTREE=y
-CONFIG_CMD_OF_PROPERTY=y
 CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OFTREE=y
 CONFIG_OFDEVICE=y
 # CONFIG_SPI is not set
+CONFIG_GPIO_JZ4740=y
 CONFIG_SHA1=y
 CONFIG_SHA224=y
 CONFIG_SHA256=y
-- 
1.9.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] MIPS: XBurst: add gpio support
  2014-06-26 22:49 [PATCH 0/4] MIPS: XBurst: add gpio support Antony Pavlov
                   ` (3 preceding siblings ...)
  2014-06-26 22:49 ` [PATCH 4/4] MIPS: ritmix-rzx50_defconfig: enable gpio stuff Antony Pavlov
@ 2014-06-27 19:40 ` Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2014-06-27 19:40 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Fri, Jun 27, 2014 at 02:49:29AM +0400, Antony Pavlov wrote:
> Antony Pavlov (4):
>   gpio: add jz4740-gpio driver for Ingenic MIPS SoCs
>   MIPS: XBurst: use gpiolib
>   MIPS: dts: jz4755.dtsi: add gpio
>   MIPS: ritmix-rzx50_defconfig: enable gpio stuff

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-27 19:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-26 22:49 [PATCH 0/4] MIPS: XBurst: add gpio support Antony Pavlov
2014-06-26 22:49 ` [PATCH 1/4] gpio: add jz4740-gpio driver for Ingenic MIPS SoCs Antony Pavlov
2014-06-26 22:49 ` [PATCH 2/4] MIPS: XBurst: use gpiolib Antony Pavlov
2014-06-26 22:49 ` [PATCH 3/4] MIPS: dts: jz4755.dtsi: add gpio Antony Pavlov
2014-06-26 22:49 ` [PATCH 4/4] MIPS: ritmix-rzx50_defconfig: enable gpio stuff Antony Pavlov
2014-06-27 19:40 ` [PATCH 0/4] MIPS: XBurst: add gpio support Sascha Hauer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.