Skip to contentSkip to conversation

OMAP3+: Add DT support for early devices and i2c / twl6030

PATCH Superseded Benoit Cousson 5 participants 26 messages Sep 26, 2011 – Oct 10, 2011

Subsystems (14)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover OMAP3+: Add DT support for early devices and i2c / twl6030

Hi Grant, Tony,

This series is a rework of several series:
[RFC PATCH 00/10] OMAP: Add DT support for early init OMAP4 devices
http://www.spinics.net/lists/linux-omap/msg55977.html
[PATCH 00/13] OMAP4: Add DT support for i2c and twl6030
http://www.spinics.net/lists/linux-omap/msg56524.html
[PATCH 0/7] OMAP3: Add basic DT support + i2c + twl
http://www.spinics.net/lists/linux-omap/msg56538.html

It adds a minimal i2c and twl support to allow the removal of the static i2c init. A couple of basic i2c devices are added for panda, beagle and sdp4430 boards.
Some early devices (gpio, spinlock) are added as well to remove any init previously done before the machine_init.

It fixes several comments:
- Simplify the twl children creation thanks to Arnd proposal
- Add the twl-rtc DT support needed by the usage of regular of_platform_populate method to create twl children.
- Fix hwspinlock driver that was not building correctly as module
- Allow lecacy device initialization mechanism to work in case no dtb is passed by the bootloader.

Patches are based on for_3.2/3_omap_devicetree
and are available here:
git://gitorious.org/omap-pm/linux.git for_3.2/4_omap_dt_i2c_twl

Tested on PandaBoard, sdp4430 and BeagleBoard-xM with and without CONFIG_OF.

Comments are welcome.

Regards,
Benoit

Benoit Cousson (13):
hwspinlock: OMAP4: Add spinlock support in DT gpio/omap: Adapt GPIO driver to DT
arm/dts: OMAP4: Add gpio nodes
irq: Add stub for none DT build in irqdomain.h
i2c: OMAP: Add DT support for i2c controller
mfd: twl-core: Add initial DT support for twl4030/twl6030
rtc: rtc-twl: Add DT support for RTC inside twl4030/twl6030 arm/dts: OMAP4: Add i2c controller nodes
arm/dts: OMAP3: Add i2c controller nodes
arm/dts: omap4-panda: Add twl6030 and i2c EEPROM arm/dts: omap4-sdp: Add twl6030, i2c3 and i2c4 devices arm/dts: omap3-beagle: Add twl4030 and i2c EEPROM OMAP2+: board-generic: Remove i2c static init

 .../devicetree/bindings/gpio/gpio-omap.txt         |   33 ++++++
 .../bindings/hwspinlock/omap-spinlock.txt          |    5 +
 Documentation/devicetree/bindings/i2c/omap-i2c.txt |   30 ++++++
 .../devicetree/bindings/mfd/twl-familly.txt        |   47 +++++++++
 Documentation/devicetree/bindings/rtc/twl-rtc.txt  |   12 ++
 arch/arm/boot/dts/omap3-beagle.dts                 |   38 +++++++
 arch/arm/boot/dts/omap3.dtsi                       |   27 +++++
 arch/arm/boot/dts/omap4-panda.dts                  |   44 ++++++++
 arch/arm/boot/dts/omap4-sdp.dts                    |   62 +++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |  106 +++++++++++++++++++
 arch/arm/mach-omap2/board-generic.c                |   41 +-------
 arch/arm/mach-omap2/gpio.c                         |    8 +-
 arch/arm/mach-omap2/hwspinlock.c                   |    5 +
 drivers/gpio/gpio-omap.c                           |  108 ++++++++++++++++++--
 drivers/hwspinlock/omap_hwspinlock.c               |   11 ++
 drivers/i2c/busses/i2c-omap.c                      |   26 ++++-
 drivers/mfd/twl-core.c                             |   53 +++++++++-
 drivers/rtc/rtc-twl.c                              |   10 ++-
 include/linux/irqdomain.h                          |    2 +
 19 files changed, 609 insertions(+), 59 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-omap.txt
 create mode 100644 Documentation/devicetree/bindings/hwspinlock/omap-spinlock.txt
 create mode 100644 Documentation/devicetree/bindings/i2c/omap-i2c.txt
 create mode 100644 Documentation/devicetree/bindings/mfd/twl-familly.txt
 create mode 100644 Documentation/devicetree/bindings/rtc/twl-rtc.txt
#1 lore raw

PATCH 1/13 hwspinlock: OMAP4: Add spinlock support in DT

Add a device-tree node for the spinlock.
Remove the static device build code if CONFIG_OF is set.
Update the hwspinlock driver to use the of_match method. Add the information in Documentation/devicetree.

Add documentation for the HW spinlock in OMAP4.

Cc Grant Likely <[email protected]>
Cc Ohad Ben-Cohen <[email protected]>
---
 .../bindings/hwspinlock/omap-spinlock.txt          |    5 +++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 +++++
 arch/arm/mach-omap2/hwspinlock.c                   |    5 +++++
 drivers/hwspinlock/omap_hwspinlock.c               |   11 +++++++++++
 4 files changed, 26 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/hwspinlock/omap-spinlock.txt
Documentation/devicetree/bindings/hwspinlock/omap-spinlock.txt new file +5 -0
new file mode 100644
index 0000000..4cea7cf
@@ -0,0 +1,5 @@
+* HW spinlock on OMAP4 platform:
+
+Required properties:
+- compatible : Must be "ti,omap4-spinlock";
+- ti,hwmods : "spinlock"
arch/arm/boot/dts/omap4.dtsi +5 -0
index 4c61c82..7a7f31e 100644
@@ -99,5 +99,10 @@
 			reg = <0x48241000 0x1000>,
 			      <0x48240100 0x0100>;
 		};
+
+		spinlock {
+			compatible = "ti,omap4-spinlock";
+			ti,hwmods = "spinlock";
+		};
 	};
 };
arch/arm/mach-omap2/hwspinlock.c +5 -0
index 36e2109..80fc18f 100644
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/err.h>
+#include <linux/of.h>
 
 #include <plat/omap_hwmod.h>
 #include <plat/omap_device.h>
@@ -31,6 +32,10 @@ int __init hwspinlocks_init(void)
 	const char *oh_name = "spinlock";
 	const char *dev_name = "omap_hwspinlock";
 
+	/* If dtb is there, the devices will be created dynamically */
+	if (of_have_populated_dt())
+		return -ENODEV;
+
 	/*
 	 * Hwmod lookup will fail in case our platform doesn't support the
 	 * hardware spinlock module, so it is safe to run this initcall
drivers/hwspinlock/omap_hwspinlock.c +11 -0
index a8f0273..8dfa730 100644
@@ -203,11 +203,22 @@ static int omap_hwspinlock_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#if defined(CONFIG_OF)
+static const struct of_device_id spinlock_match[] = {
+	{.compatible = "ti,omap4-spinlock", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, spinlock_match);
+#else
+#define spinlock_match NULL
+#endif
+
 static struct platform_driver omap_hwspinlock_driver = {
 	.probe		= omap_hwspinlock_probe,
 	.remove		= omap_hwspinlock_remove,
 	.driver		= {
 		.name	= "omap_hwspinlock",
+		.of_match_table = spinlock_match,
 	},
 };
 
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 1/13 hwspinlock: OMAP4: Add spinlock support in DT

Hi Benoit,

Quoted 12 lines · Benoit Cousson

+++ b/Documentation/devicetree/bindings/hwspinlock/omap-spinlock.txt

Documentation/devicetree/bindings/hwspinlock/omap-spinlock.txt new file +5 -0
@@ -0,0 +1,5 @@
+* HW spinlock on OMAP4 platform:
+
+Required properties:
+- compatible : Must be "ti,omap4-spinlock";
+- ti,hwmods : "spinlock"
arch/arm/boot/dts/omap4.dtsi +0 -0
index 4c61c82..7a7f31e 100644

arch/arm/boot/dts/omap4.dtsi line 106

Quoted 8 lines
arch/arm/boot/dts/omap4.dtsi +5 -0
@@ -99,5 +99,10 @@
 ? ? ? ? ? ? ? ? ? ? ? ?reg = <0x48241000 0x1000>,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?<0x48240100 0x0100>;
 ? ? ? ? ? ? ? ?};
+
+ ? ? ? ? ? ? ? spinlock {
+ ? ? ? ? ? ? ? ? ? ? ? compatible = "ti,omap4-spinlock";
+ ? ? ? ? ? ? ? ? ? ? ? ti,hwmods = "spinlock";
+ ? ? ? ? ? ? ? };

I think it'd be nice to add the 'baseid' property as we discussed for dynamic allocation of hwspinlocks.

The patch that adds the hwspinlock groundwork for this is in linux-next and will hopefully get into 3.2 if everything works out well:

https://lkml.org/lkml/2011/9/12/194

Of course, as we discussed with Arnd, we will use phandles to the hwspinlock controller when we'll get to static allocations of hwspinlock instances.

Thanks,
Ohad.

#3 lore raw

PATCH 2/13 gpio/omap: Adapt GPIO driver to DT

In reply to Benoit Cousson

Adapt the GPIO driver to retrieve information from a DT file. Note that since the driver is currently under cleanup, some hacks will have to be removed after.

Add documentation for GPIO properties specific to OMAP.

Remove an un-needed whitespace.

Cc Grant Likely <[email protected]>
Cc Charulatha V <[email protected]>
Cc Tarun Kanti DebBarma <[email protected]>
---
 .../devicetree/bindings/gpio/gpio-omap.txt         |   33 ++++++
 drivers/gpio/gpio-omap.c                           |  108 ++++++++++++++++++--
 2 files changed, 132 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-omap.txt
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +33 -0
new file mode 100644
index 0000000..bdd63de
@@ -0,0 +1,33 @@
+OMAP GPIO controller
+
+Required properties:
+- compatible:
+  - "ti,omap2-gpio" for OMAP2 and OMAP3 controllers
+  - "ti,omap4-gpio" for OMAP4 controller
+- #gpio-cells : Should be two.
+  - first cell is the pin number
+  - second cell is used to specify optional parameters (unused)
+- gpio-controller : Marks the device node as a GPIO controller.
+
+OMAP specific properties:
+- ti,hwmods: Name of the hwmod associated to the GPIO
+- id: 32 bits to identify the id (1 based index)
+- bank-width: number of pin supported by the controller (16 or 32)
+- debounce: set if the controller support the debouce funtionnality
+- bank-count: number of controller support by the SoC. This is a temporary
+  hack until the bank_count is removed from the driver.
+
+
+Example:
+
+gpio4: gpio4 {
+    compatible = "ti,omap4-gpio", "ti,omap-gpio";
+    ti,hwmods = "gpio4";
+    id = <4>;
+    bank-width = <32>;
+    debounce;
+    no_idle_on_suspend;
+    #gpio-cells = <2>;
+    gpio-controller;
+};
+
drivers/gpio/gpio-omap.c +99 -9

158 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#4 lore raw

PATCH 2/13 gpio/omap: Adapt GPIO driver to DT

Quoted 24 lines · Benoit Cousson

Adapt the GPIO driver to retrieve information from a DT file. Note that since the driver is currently under cleanup, some hacks will have to be removed after.

Add documentation for GPIO properties specific to OMAP.

Remove an un-needed whitespace.

Cc Grant Likely<[email protected]>
Cc Charulatha V<[email protected]>
Cc Tarun Kanti DebBarma<[email protected]>
---
  .../devicetree/bindings/gpio/gpio-omap.txt         |   33 ++++++
  drivers/gpio/gpio-omap.c                           |  108 ++++++++++++++++++--
  2 files changed, 132 insertions(+), 9 deletions(-)

create mode 100644 Documentation/devicetree/bindings/gpio/gpio-omap.txt

Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +0 -0
new file mode 100644
index 0000000..bdd63de

Documentation/devicetree/bindings/gpio/gpio-omap.txt line 5

Quoted 5 lines
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +5 -0
@@ -0,0 +1,33 @@
+OMAP GPIO controller
+
+Required properties:
+- compatible:
+  - "ti,omap2-gpio" for OMAP2 and OMAP3 controllers

Would it be more readable to have
"ti,omap2-gpio" for OMAP2 controllers and
"ti,omap3-gpio" for OMAP3 controllers?

Documentation/devicetree/bindings/gpio/gpio-omap.txt line 18

Quoted 13 lines
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +13 -0
+  - "ti,omap4-gpio" for OMAP4 controller
+- #gpio-cells : Should be two.
+  - first cell is the pin number
+  - second cell is used to specify optional parameters (unused)
+- gpio-controller : Marks the device node as a GPIO controller.
+
+OMAP specific properties:
+- ti,hwmods: Name of the hwmod associated to the GPIO
+- id: 32 bits to identify the id (1 based index)
+- bank-width: number of pin supported by the controller (16 or 32)
+- debounce: set if the controller support the debouce funtionnality
+- bank-count: number of controller support by the SoC. This is a temporary
+  hack until the bank_count is removed from the driver.

Is there a general rule to be followed as to when to use "ti,<prop-name>" and when to use just "<prop-name>". Since all these are OMAP specific properties, shouldn't all of them be "ti,<prop-name>"?

Quoted 29 lines
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +15 -0
+
+
+Example:
+
+gpio4: gpio4 {
+    compatible = "ti,omap4-gpio", "ti,omap-gpio";
+    ti,hwmods = "gpio4";
+    id =<4>;
+    bank-width =<32>;
+    debounce;
+    no_idle_on_suspend;
+    #gpio-cells =<2>;
+    gpio-controller;
+};
+
drivers/gpio/gpio-omap.c +2 -0
index 0599854..f878fa4 100644
@@ -21,6 +21,8 @@
  #include<linux/io.h>
  #include<linux/slab.h>
  #include<linux/pm_runtime.h>
+#include<linux/of.h>
+#include<linux/of_device.h>
 
  #include<mach/hardware.h>
  #include<asm/irq.h>

drivers/gpio/gpio-omap.c static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable) · line 526

Quoted 5 lines
drivers/gpio/gpio-omap.c +1 -1
@@ -521,7 +523,7 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)
  	unsigned long flags;
 
  	if (bank->non_wakeup_gpios&  gpio_bit) {
-		dev_err(bank->dev,
+		dev_err(bank->dev,

Stray change?

Quoted 15 lines
drivers/gpio/gpio-omap.c +2 -0
  			"Unable to modify wakeup on non-wakeup GPIO%d\n", gpio);
  		return -EINVAL;
  	}
@@ -1150,6 +1152,8 @@ static void __devinit omap_gpio_chip_init(struct gpio_bank *bank)
  	irq_set_handler_data(bank->irq, bank);
  }
 
+static const struct of_device_id omap_gpio_match[];
+
  static int __devinit omap_gpio_probe(struct platform_device *pdev)
  {
  	static int gpio_init_done;
@@ -1157,11 +1161,31 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
  	struct resource *res;
  	int id;

drivers/gpio/gpio-omap.c static int __devinit omap_gpio_probe(struct platform_device *pdev) · line 1172

Quoted 10 lines
drivers/gpio/gpio-omap.c +9 -0
  	struct gpio_bank *bank;
+	struct device_node *node = pdev->dev.of_node;
+	const struct of_device_id *match;
+
+	match = of_match_device(omap_gpio_match,&pdev->dev);
+	if (match) {
+		pdata = match->data;
+		/* XXX: big hack until the bank_count is removed */
+		of_property_read_u32(node, "bank-count",&gpio_bank_count);
+		if (of_property_read_u32(node, "id",&id))

id should be u32.

Quoted 33 lines
drivers/gpio/gpio-omap.c +15 -5
+			return -EINVAL;
+		/*
+		 * In an ideal world, the id should not be needed, but since
+		 * the OMAP TRM consider the multiple GPIO controllers as
+		 * multiple banks, the GPIO number is based on the whole set
+		 * of banks. Hence the need to provide an id in order to
+		 * respect the order and the correct GPIO number.
+		 */
+		id -= 1;
+	} else {
+		if (!pdev->dev.platform_data)
+			return -EINVAL;
 
-	if (!pdev->dev.platform_data)
-		return -EINVAL;
-
-	pdata = pdev->dev.platform_data;
+		pdata = pdev->dev.platform_data;
+		id = pdev->id;
+	}
 
  	if (!gpio_init_done) {
  		int ret;
@@ -1171,7 +1195,6 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
  			return ret;
  	}
 
-	id = pdev->id;
  	bank =&gpio_bank[id];
 
  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -1181,12 +1204,19 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
  	}

drivers/gpio/gpio-omap.c static int __devinit omap_gpio_probe(struct platform_device *pdev) · line 1211

Quoted 10 lines
drivers/gpio/gpio-omap.c +2 -3
 
  	bank->irq = res->start;
-	bank->virtual_irq_start = pdata->virtual_irq_start;
  	bank->method = pdata->bank_type;
  	bank->dev =&pdev->dev;
-	bank->dbck_flag = pdata->dbck_flag;
  	bank->stride = pdata->bank_stride;
-	bank->width = pdata->bank_width;
+	if (match) {
+		of_property_read_u32(node, "bank-width",&bank->width);

Bank width should be u32.

drivers/gpio/gpio-omap.c static int __devinit omap_gpio_probe(struct platform_device *pdev) · line 1212

Quoted 1 line
drivers/gpio/gpio-omap.c +1 -0
+		if (of_get_property(node, "debounce", NULL))

of_find_property() should suffice.

regards,
Rajendra

Quoted 81 lines
drivers/gpio/gpio-omap.c +67 -0
+			bank->dbck_flag = true;
+		bank->virtual_irq_start = IH_GPIO_BASE + 32 * id;
+	} else {
+		bank->width = pdata->bank_width;
+		bank->dbck_flag = pdata->dbck_flag;
+		bank->virtual_irq_start = pdata->virtual_irq_start;
+	}
 
  	bank->regs = pdata->regs;
 
@@ -1559,10 +1589,70 @@ void omap_gpio_restore_context(void)
  }
  #endif
 
+#if defined(CONFIG_OF)
+static struct omap_gpio_reg_offs omap2_gpio_regs = {
+	.revision =		OMAP24XX_GPIO_REVISION,
+	.direction =		OMAP24XX_GPIO_OE,
+	.datain =		OMAP24XX_GPIO_DATAIN,
+	.dataout =		OMAP24XX_GPIO_DATAOUT,
+	.set_dataout =		OMAP24XX_GPIO_SETDATAOUT,
+	.clr_dataout =		OMAP24XX_GPIO_CLEARDATAOUT,
+	.irqstatus =		OMAP24XX_GPIO_IRQSTATUS1,
+	.irqstatus2 =		OMAP24XX_GPIO_IRQSTATUS2,
+	.irqenable =		OMAP24XX_GPIO_IRQENABLE1,
+	.set_irqenable =	OMAP24XX_GPIO_SETIRQENABLE1,
+	.clr_irqenable =	OMAP24XX_GPIO_CLEARIRQENABLE1,
+	.debounce =		OMAP24XX_GPIO_DEBOUNCE_VAL,
+	.debounce_en =		OMAP24XX_GPIO_DEBOUNCE_EN,
+};
+
+static struct omap_gpio_platform_data omap2_pdata = {
+	.bank_type = METHOD_GPIO_24XX,
+	.regs =&omap2_gpio_regs,
+};
+
+static struct omap_gpio_reg_offs omap4_gpio_regs = {
+	.revision =		OMAP4_GPIO_REVISION,
+	.direction =		OMAP4_GPIO_OE,
+	.datain =		OMAP4_GPIO_DATAIN,
+	.dataout =		OMAP4_GPIO_DATAOUT,
+	.set_dataout =		OMAP4_GPIO_SETDATAOUT,
+	.clr_dataout =		OMAP4_GPIO_CLEARDATAOUT,
+	.irqstatus =		OMAP4_GPIO_IRQSTATUS1,
+	.irqstatus2 =		OMAP4_GPIO_IRQSTATUS2,
+	.irqenable =		OMAP4_GPIO_IRQENABLE1,
+	.set_irqenable =	OMAP4_GPIO_SETIRQENABLE1,
+	.clr_irqenable =	OMAP4_GPIO_CLEARIRQENABLE1,
+	.debounce =		OMAP4_GPIO_DEBOUNCINGTIME,
+	.debounce_en =		OMAP4_GPIO_DEBOUNCENABLE,
+};
+
+static struct omap_gpio_platform_data omap4_pdata = {
+	.bank_type = METHOD_GPIO_44XX,
+	.regs =&omap4_gpio_regs,
+};
+
+static const struct of_device_id omap_gpio_match[] = {
+	{
+		.compatible = "ti,omap4-gpio",
+		.data =&omap4_pdata,
+	},
+	{
+		.compatible = "ti,omap2-gpio",
+		.data =&omap2_pdata,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, omap_gpio_match);
+#else
+#define omap_gpio_match NULL
+#endif
+
  static struct platform_driver omap_gpio_driver = {
  	.probe		= omap_gpio_probe,
  	.driver		= {
  		.name	= "omap_gpio",
+		.of_match_table = omap_gpio_match,
  	},
  };
 
#5 lore raw

PATCH 2/13 gpio/omap: Adapt GPIO driver to DT

Hi Rajendra,

Quoted 45 lines · Rajendra
Quoted 24 lines · Benoit Cousson

Adapt the GPIO driver to retrieve information from a DT file. Note that since the driver is currently under cleanup, some hacks will have to be removed after.

Add documentation for GPIO properties specific to OMAP.

Remove an un-needed whitespace.

Cc Grant Likely<[email protected]>
Cc Charulatha V<[email protected]>
Cc Tarun Kanti DebBarma<[email protected]>
---
   .../devicetree/bindings/gpio/gpio-omap.txt         |   33 ++++++
   drivers/gpio/gpio-omap.c                           |  108 ++++++++++++++++++--
   2 files changed, 132 insertions(+), 9 deletions(-)

create mode 100644 Documentation/devicetree/bindings/gpio/gpio-omap.txt

Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +0 -0
new file mode 100644
index 0000000..bdd63de

Documentation/devicetree/bindings/gpio/gpio-omap.txt line 5

Quoted 5 lines
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +5 -0
@@ -0,0 +1,33 @@
+OMAP GPIO controller
+
+Required properties:
+- compatible:
+  - "ti,omap2-gpio" for OMAP2 and OMAP3 controllers

Would it be more readable to have
"ti,omap2-gpio" for OMAP2 controllers and
"ti,omap3-gpio" for OMAP3 controllers?

Quoted 10 lines
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +10 -0
+  - "ti,omap4-gpio" for OMAP4 controller
+- #gpio-cells : Should be two.
+  - first cell is the pin number
+  - second cell is used to specify optional parameters (unused)
+- gpio-controller : Marks the device node as a GPIO controller.
+
+OMAP specific properties:
+- ti,hwmods: Name of the hwmod associated to the GPIO
+- id: 32 bits to identify the id (1 based index)
+- bank-width: number of pin supported by the controller (16 or 32)
Quoted 8 lines

Documentation/devicetree/bindings/gpio/gpio-omap.txt line 18

Quoted 3 lines
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +3 -0
+- debounce: set if the controller support the debouce funtionnality
+- bank-count: number of controller support by the SoC. This is a temporary
+  hack until the bank_count is removed from the driver.

Is there a general rule to be followed as to when to use "ti,<prop-name>" and when to use just"<prop-name>". Since all these are OMAP specific properties, shouldn't all of them be "ti,<prop-name>"?

To be honest, I was wondering as well about this rule.
I think that a property that is not purely OMAP specific and that represents some standard HW information does not have to be prefixed by "ti,XXX".
So hwmods must be "ti,hwmods", but bank-witdh and bank-count seems to me quite generic.

Quoted 29 lines
Quoted 29 lines
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +13 -0
+Example:
+
+gpio4: gpio4 {
+    compatible = "ti,omap4-gpio", "ti,omap-gpio";
+    ti,hwmods = "gpio4";
+    id =<4>;
+    bank-width =<32>;
+    debounce;
+    no_idle_on_suspend;
+    #gpio-cells =<2>;
+    gpio-controller;
+};
+
drivers/gpio/gpio-omap.c +2 -0
index 0599854..f878fa4 100644
@@ -21,6 +21,8 @@
   #include<linux/io.h>
   #include<linux/slab.h>
   #include<linux/pm_runtime.h>
+#include<linux/of.h>
+#include<linux/of_device.h>
 
   #include<mach/hardware.h>
   #include<asm/irq.h>
@@ -521,7 +523,7 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)
   	unsigned long flags;
 
Quoted 5 lines

drivers/gpio/gpio-omap.c static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable) · line 526

Quoted 3 lines
drivers/gpio/gpio-omap.c +1 -1
   	if (bank->non_wakeup_gpios&   gpio_bit) {
-		dev_err(bank->dev,
+		dev_err(bank->dev,

Stray change?

Not anymore, it is part of the changelog :-)

Quoted 20 lines
Quoted 20 lines
drivers/gpio/gpio-omap.c +5 -0
   			"Unable to modify wakeup on non-wakeup GPIO%d\n", gpio);
   		return -EINVAL;
   	}
@@ -1150,6 +1152,8 @@ static void __devinit omap_gpio_chip_init(struct gpio_bank *bank)
   	irq_set_handler_data(bank->irq, bank);
   }
 
+static const struct of_device_id omap_gpio_match[];
+
   static int __devinit omap_gpio_probe(struct platform_device *pdev)
   {
   	static int gpio_init_done;
@@ -1157,11 +1161,31 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
   	struct resource *res;
   	int id;
   	struct gpio_bank *bank;
+	struct device_node *node = pdev->dev.of_node;
+	const struct of_device_id *match;
+
Quoted 8 lines

drivers/gpio/gpio-omap.c static int __devinit omap_gpio_probe(struct platform_device *pdev)

Quoted 6 lines
drivers/gpio/gpio-omap.c +6 -0
+	match = of_match_device(omap_gpio_match,&pdev->dev);
+	if (match) {
+		pdata = match->data;
+		/* XXX: big hack until the bank_count is removed */
+		of_property_read_u32(node, "bank-count",&gpio_bank_count);
+		if (of_property_read_u32(node, "id",&id))

id should be u32.

Oops, good point.

Quoted 47 lines
Quoted 34 lines
drivers/gpio/gpio-omap.c +15 -5
+			return -EINVAL;
+		/*
+		 * In an ideal world, the id should not be needed, but since
+		 * the OMAP TRM consider the multiple GPIO controllers as
+		 * multiple banks, the GPIO number is based on the whole set
+		 * of banks. Hence the need to provide an id in order to
+		 * respect the order and the correct GPIO number.
+		 */
+		id -= 1;
+	} else {
+		if (!pdev->dev.platform_data)
+			return -EINVAL;
 
-	if (!pdev->dev.platform_data)
-		return -EINVAL;
-
-	pdata = pdev->dev.platform_data;
+		pdata = pdev->dev.platform_data;
+		id = pdev->id;
+	}
 
   	if (!gpio_init_done) {
   		int ret;
@@ -1171,7 +1195,6 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
   			return ret;
   	}
 
-	id = pdev->id;
   	bank =&gpio_bank[id];
 
   	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -1181,12 +1204,19 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
   	}

drivers/gpio/gpio-omap.c static int __devinit omap_gpio_probe(struct platform_device *pdev) · line 1211

Quoted 10 lines
drivers/gpio/gpio-omap.c +2 -3
 
   	bank->irq = res->start;
-	bank->virtual_irq_start = pdata->virtual_irq_start;
   	bank->method = pdata->bank_type;
   	bank->dev =&pdev->dev;
-	bank->dbck_flag = pdata->dbck_flag;
   	bank->stride = pdata->bank_stride;
-	bank->width = pdata->bank_width;
+	if (match) {
+		of_property_read_u32(node, "bank-width",&bank->width);

Bank width should be u32.

Quoted 3 lines

drivers/gpio/gpio-omap.c static int __devinit omap_gpio_probe(struct platform_device *pdev) · line 1212

Quoted 1 line
drivers/gpio/gpio-omap.c +1 -0
+		if (of_get_property(node, "debounce", NULL))

of_find_property() should suffice.

Yes, indeed.

Thanks,
Benoit

#6 lore raw

PATCH 2/13 gpio/omap: Adapt GPIO driver to DT

Quoted 9 lines · Benoit
Quoted 8 lines · Rajendra

Documentation/devicetree/bindings/gpio/gpio-omap.txt line 5

Quoted 3 lines · Benoit Cousson
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +3 -0
+Required properties:
+- compatible:
+  - "ti,omap2-gpio" for OMAP2 and OMAP3 controllers

Would it be more readable to have
"ti,omap2-gpio" for OMAP2 controllers and
"ti,omap3-gpio" for OMAP3 controllers?

Or have OMAP3 say this if it's fully backwards compatible:

	compatible = "ti,omap3-gpio", "ti,omap2-gpio";
Quoted 9 lines
Quoted 9 lines

Documentation/devicetree/bindings/gpio/gpio-omap.txt line 14

Quoted 9 lines
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +9 -0
+  - "ti,omap4-gpio" for OMAP4 controller
+- #gpio-cells : Should be two.
+  - first cell is the pin number
+  - second cell is used to specify optional parameters (unused)
+- gpio-controller : Marks the device node as a GPIO controller.
+
+OMAP specific properties:
+- ti,hwmods: Name of the hwmod associated to the GPIO
+- id: 32 bits to identify the id (1 based index)

What does "the id" mean, in relation to the actual hardware?

Some existing bindings have such a thing (often called "cell-index"), but it should be well-defined what it refers to. Often aliases would be a better approach, if it just refers to what the manual calls the device.

Quoted 11 lines
Quoted 10 lines
Quoted 5 lines
+- bank-width: number of pin supported by the controller (16 or 32)
+- debounce: set if the controller support the debouce funtionnality
+- bank-count: number of controller support by the SoC. This is a

temporary
+ hack until the bank_count is removed from the driver.

Is there a general rule to be followed as to when to use "ti,<prop-name>" and when to use just"<prop-name>". Since all these are OMAP specific properties, shouldn't all of them be "ti,<prop-name>"?

Quoted 6 lines

To be honest, I was wondering as well about this rule.
I think that a property that is not purely OMAP specific and that represents some standard HW information does not have to be prefixed by "ti,XXX".
So hwmods must be "ti,hwmods", but bank-witdh and bank-count seems to me quite generic.

It's about where the property is documented. Suppose you use an un-prefixed bank-width but define it in the TI-specific binding to mean width in bits. Later, someone wants something similar for another driver, doesn't look at the TI binding, but says, "This is generic, I'll define something in the main gpio binding," but defines it as width in bytes (ignore the (de)merits of defining it that way in this case). If you had a namespace prefix, it would be clear which binding a node is referring to.

As for bank-count, the description "this is a temporary hack until the bank_count is removed from the driver" suggests it shouldn't be there at all, much less be part of the generic binding.

-Scott

#7 lore raw

PATCH 2/13 gpio/omap: Adapt GPIO driver to DT

Quoted 7 lines · Scott Wood
Quoted 6 lines · Benoit
Quoted 5 lines · Rajendra
Quoted 3 lines · Benoit Cousson
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +3 -0
+Required properties:
+- compatible:
+  - "ti,omap2-gpio" for OMAP2 and OMAP3 controllers
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

Would it be more readable to have
"ti,omap2-gpio" for OMAP2 controllers and
"ti,omap3-gpio" for OMAP3 controllers?

Or have OMAP3 say this if it's fully backwards compatible:

	compatible = "ti,omap3-gpio", "ti,omap2-gpio";

I saw that several time for other platform, but was wondering if this was a strong rule or not. In that case, the IP is the same, so should we still identify it with a different compatible value?

Quoted 11 lines
Quoted 9 lines
Quoted 9 lines

Documentation/devicetree/bindings/gpio/gpio-omap.txt line 14

Quoted 9 lines
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +9 -0
+  - "ti,omap4-gpio" for OMAP4 controller
+- #gpio-cells : Should be two.
+  - first cell is the pin number
+  - second cell is used to specify optional parameters (unused)
+- gpio-controller : Marks the device node as a GPIO controller.
+
+OMAP specific properties:
+- ti,hwmods: Name of the hwmod associated to the GPIO
+- id: 32 bits to identify the id (1 based index)

What does "the id" mean, in relation to the actual hardware?

It's true that the description is not super meaningful... This is the HW instance number. We have 6 gpios, named gpio1 to gpio6, but the pin numbering is global, meaning from 1 to 192, sine only the global number is referenced in the pinmuxing control, we have to maintain the order to ensure the right number.

I still do not know how to use that with the way gpio binding is working. Because in theory each gpio controller should be referenced with the local number, not the global one. And converting that global number from HW spec to a gpio instance + local number seems to me very error prone.

Quoted 3 lines

Some existing bindings have such a thing (often called "cell-index"), but it should be well-defined what it refers to. Often aliases would be a better approach, if it just refers to what the manual calls the device.

The issue is that the manual refer to a global gpio controller.

Quoted 18 lines
Quoted 11 lines
Quoted 10 lines
Quoted 5 lines
+- bank-width: number of pin supported by the controller (16 or 32)
+- debounce: set if the controller support the debouce funtionnality
+- bank-count: number of controller support by the SoC. This is a

temporary
+ hack until the bank_count is removed from the driver.

Is there a general rule to be followed as to when to use "ti,<prop-name>" and when to use just"<prop-name>". Since all these are OMAP specific properties, shouldn't all of them be "ti,<prop-name>"?

Quoted 6 lines

To be honest, I was wondering as well about this rule.
I think that a property that is not purely OMAP specific and that represents some standard HW information does not have to be prefixed by "ti,XXX".
So hwmods must be "ti,hwmods", but bank-witdh and bank-count seems to me quite generic.

Quoted 8 lines

It's about where the property is documented. Suppose you use an un-prefixed bank-width but define it in the TI-specific binding to mean width in bits. Later, someone wants something similar for another driver, doesn't look at the TI binding, but says, "This is generic, I'll define something in the main gpio binding," but defines it as width in bytes (ignore the (de)merits of defining it that way in this case). If you had a namespace prefix, it would be clear which binding a node is referring to.

Good to know, and that makes sense. So the recommendation is to add that into the generic gpio as much as possible if this can be reused by someone else.

Quoted 3 lines

As for bank-count, the description "this is a temporary hack until the bank_count is removed from the driver" suggests it shouldn't be there at all, much less be part of the generic binding.

That one sucks and will be removed soon since the driver cleanup was posted and waiting for upstream acceptance.

Thanks for the detailed explanations.
Benoit

#8 lore raw

PATCH 2/13 gpio/omap: Adapt GPIO driver to DT

Quoted 8 lines · Benoit
Quoted 1 line · Scott Wood

What does "the id" mean, in relation to the actual hardware?

It's true that the description is not super meaningful... This is the HW instance number. We have 6 gpios, named gpio1 to gpio6, but the pin numbering is global, meaning from 1 to 192, sine only the global number is referenced in the pinmuxing control, we have to maintain the order to ensure the right number.

I'd either have one node that handles all the banks (with multiple "reg" resources in the order that they should be mapped to the numberspace), or avoid using that global numberspace and reference things by bank/offset (with the bank identified by alias or phandle).

Quoted 5 lines

I still do not know how to use that with the way gpio binding is working. Because in theory each gpio controller should be referenced with the local number, not the global one. And converting that global number from HW spec to a gpio instance + local number seems to me very error prone.

You could say the same thing about a chip whose manual is written assuming a global IRQ numberspace with a certain encoding scheme.

Or in the other direction, Freescale's manuals split up MPIC interrupts into external/internal/MSI, while they really just map to different regions of the openpic (hardware standard that Freescale's MPIC is an instance of) interrupt space. The device trees use the raw openpic interrupt numbers.

There's certainly potential for confusion, but at least the device tree representation is internally consistent and doesn't make assumptions about the overall system.

-Scott

#9 lore raw

PATCH 2/13 gpio/omap: Adapt GPIO driver to DT

In reply to Rajendra Nayak

I missed one comment...

Quoted 1 line · Rajendra

On Monday 26 September 2011 10:20 PM, Benoit Cousson wrote:

[...]

Quoted 7 lines

Documentation/devicetree/bindings/gpio/gpio-omap.txt line 5

Quoted 3 lines
Documentation/devicetree/bindings/gpio/gpio-omap.txt new file +3 -0
+Required properties:
+- compatible:
+  - "ti,omap2-gpio" for OMAP2 and OMAP3 controllers

Would it be more readable to have
"ti,omap2-gpio" for OMAP2 controllers and
"ti,omap3-gpio" for OMAP3 controllers?

The point here is to identify the IP version used in various OMAPs. Since OMAP3 and OMAP2 are using the same IP version, there is no point to differentiate the OMAP3 version.
What is doable is to put both "ti,omap3-gpio", "ti,omap2-gpio" to avoid modifying the driver for no reason and still being able to identify the OMAP3 version.
But I'm not sure we should do that if there is not real difference.

regards,
Benoit

#10 lore raw

PATCH 2/13 gpio/omap: Adapt GPIO driver to DT

In reply to Rajendra Nayak

Second thought... I was too fast to say OK :-)

Quoted 1 line · Rajendra

On Monday 26 September 2011 10:20 PM, Benoit Cousson wrote:

[...]

Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (match) {
+		of_property_read_u32(node, "bank-width",&bank->width);

Bank width should be u32.

I guess you meant bank->width, and it appears that bank->width is already a u32.

Regards,
Benoit

#11 lore raw

PATCH 3/13 arm/dts: OMAP4: Add gpio nodes

In reply to Benoit Cousson

Add the 6 GPIOs controller nodes.
Since the GPIO driver is still under cleanup, a couple of temp hacks are needed. They will be removed as soon as the driver will be cleaned.

Remove gpio static device initialisation if DT is populated.

Remove un-needed LF.

Cc Grant Likely <[email protected]>
Cc Charulatha V <[email protected]>
---
 arch/arm/boot/dts/omap4.dtsi |   69 ++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/gpio.c   |    8 ++++-
 2 files changed, 75 insertions(+), 2 deletions(-)
arch/arm/boot/dts/omap4.dtsi +69 -0
index 7a7f31e..bb19bca 100644
@@ -104,5 +104,74 @@
 			compatible = "ti,omap4-spinlock";
 			ti,hwmods = "spinlock";
 		};
+
+		gpio1: gpio at 1 {
+			compatible = "ti,omap4-gpio";
+			ti,hwmods = "gpio1";
+			/* id should not be needed with a global GPIO parent */
+			id = <1>;
+			bank-width = <32>;
+			debounce;
+			/* XXX: big hack until the bank_count is removed */
+			bank-count = <6>;
+			ti,no-idle-on-suspend;
+			#gpio-cells = <2>;
+			gpio-controller;
+		};
+
+		gpio2: gpio at 2 {
+			compatible = "ti,omap4-gpio";
+			ti,hwmods = "gpio2";
+			id = <2>;
+			bank-width = <32>;
+			debounce;
+			ti,no-idle-on-suspend;
+			#gpio-cells = <2>;
+			gpio-controller;
+		};
+
+		gpio3: gpio at 3 {
+			compatible = "ti,omap4-gpio";
+			ti,hwmods = "gpio3";
+			id = <3>;
+			bank-width = <32>;
+			debounce;
+			ti,no-idle-on-suspend;
+			#gpio-cells = <2>;
+			gpio-controller;
+		};
+
+		gpio4: gpio at 4 {
+			compatible = "ti,omap4-gpio";
+			ti,hwmods = "gpio4";
+			id = <4>;
+			bank-width = <32>;
+			debounce;
+			ti,no-idle-on-suspend;
+			#gpio-cells = <2>;
+			gpio-controller;
+		};
+
+		gpio5: gpio at 5 {
+			compatible = "ti,omap4-gpio";
+			ti,hwmods = "gpio5";
+			id = <5>;
+			bank-width = <32>;
+			debounce;
+			ti,no-idle-on-suspend;
+			#gpio-cells = <2>;
+			gpio-controller;
+		};
+
+		gpio6: gpio at 6 {
+			compatible = "ti,omap4-gpio";
+			ti,hwmods = "gpio6";
+			id = <6>;
+			bank-width = <32>;
+			debounce;
+			ti,no-idle-on-suspend;
+			#gpio-cells = <2>;
+			gpio-controller;
+		};
 	};
 };
arch/arm/mach-omap2/gpio.c +6 -2
index 8cbfbc2..8412746 100644
@@ -20,6 +20,7 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/of.h>
 
 #include <plat/omap_hwmod.h>
 #include <plat/omap_device.h>
@@ -122,7 +123,10 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
  */
 static int __init omap2_gpio_init(void)
 {
-	return omap_hwmod_for_each_by_class("gpio", omap2_gpio_dev_init,
-						NULL);
+	/* If dtb is there, the devices will be created dynamically */
+	if (of_have_populated_dt())
+		return -ENODEV;
+
+	return omap_hwmod_for_each_by_class("gpio", omap2_gpio_dev_init, NULL);
 }
 postcore_initcall(omap2_gpio_init);
Signature · 1 line
1.7.0.4
#12 lore raw

PATCH 4/13 irq: Add stub for none DT build in irqdomain.h

In reply to Benoit Cousson

Add an empty funtion to allow building a file without adding some #ifdef CONFIG_OF around of APIs.

Grant Likely <[email protected]>

---
 include/linux/irqdomain.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/irqdomain.h +2 -0
index e807ad6..6fa08ab 100644
@@ -84,6 +84,8 @@ extern void irq_domain_add_simple(struct device_node *controller, int irq_base);
 extern void irq_domain_generate_simple(const struct of_device_id *match,
 					u64 phys_base, unsigned int irq_start);
 #else /* CONFIG_IRQ_DOMAIN && CONFIG_OF_IRQ */
+static inline void irq_domain_add_simple(struct device_node *controller,
+					 int irq_base) { }
 static inline void irq_domain_generate_simple(const struct of_device_id *match,
 					u64 phys_base, unsigned int irq_start) { }
 #endif /* CONFIG_IRQ_DOMAIN && CONFIG_OF_IRQ */
Signature · 1 line
1.7.0.4
#13 lore raw

PATCH 5/13 i2c: OMAP: Add DT support for i2c controller

In reply to Benoit Cousson

Add initial DT support to retrieve the frequency using a DT attribute instead of the pdata pointer if of_node exist.

Add documentation for omap i2c controller binding.

Based on original patches from Manju and Grant.

Cc Ben Dooks <[email protected]>
Cc G, Manjunath Kondaiah <[email protected]>
---
 Documentation/devicetree/bindings/i2c/omap-i2c.txt |   30 ++++++++++++++++++++
 drivers/i2c/busses/i2c-omap.c                      |   26 +++++++++++++++--
 2 files changed, 53 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/omap-i2c.txt
Documentation/devicetree/bindings/i2c/omap-i2c.txt new file +30 -0
new file mode 100644
index 0000000..d21f4d8
@@ -0,0 +1,30 @@
+I2C for OMAP platforms
+
+Required properties :
+- compatible : Must be "ti,omap3-i2c"
+- ti,hwmods : Must be "i2c<n>", n being the instance number (1-based)
+- #address-cells = <1>;
+- #size-cells = <0>;
+
+Recommended properties :
+- clock-frequency : Desired I2C bus clock frequency in Hz. Otherwise
+  the default 100 kHz frequency will be used.
+
+Optional properties:
+- Child nodes conforming to i2c bus binding
+
+Note: Current implementation will fetch base address, irq and dma
+from omap hwmod data base during device registration.
+Future plan is to migrate hwmod data base contents into device tree
+blob so that, all the required data will be used from device tree dts
+file.
+
+Examples :
+
+i2c1: i2c at 0 {
+    compatible = "ti,omap3-i2c";
+    #address-cells = <1>;
+    #size-cells = <0>;
+    ti,hwmods = "i2c1";
+    clock-frequency = <400000>;
+};
drivers/i2c/busses/i2c-omap.c +23 -3
index 155b32f..aee5bfa 100644
@@ -37,6 +37,8 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/of_i2c.h>
+#include <linux/of_device.h>
 #include <linux/slab.h>
 #include <linux/i2c-omap.h>
 #include <linux/pm_runtime.h>
@@ -969,6 +971,16 @@ static const struct i2c_algorithm omap_i2c_algo = {
 	.functionality	= omap_i2c_func,
 };
 
+#if defined(CONFIG_OF)
+static const struct of_device_id omap_i2c_of_match[] = {
+	{.compatible = "ti,omap3-i2c", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, omap_i2c_of_match);
+#else
+#define omap_i2c_of_match NULL
+#endif
+
 static int __devinit
 omap_i2c_probe(struct platform_device *pdev)
 {
@@ -1005,12 +1017,16 @@ omap_i2c_probe(struct platform_device *pdev)
 		goto err_release_region;
 	}
 
+	speed = 100;	/* Default speed */
 	if (pdata != NULL) {
 		speed = pdata->clkrate;
 		dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
-	} else {
-		speed = 100;	/* Default speed */
-		dev->set_mpu_wkup_lat = NULL;
+	} else if (pdev->dev.of_node) {
+		u32 prop;
+		if (!of_property_read_u32(pdev->dev.of_node, "clock-frequency",
+					  &prop))
+			/* convert DT value in Hz into kHz */
+			speed = prop / 1000;
 	}
 
 	dev->speed = speed;
@@ -1093,6 +1109,7 @@ omap_i2c_probe(struct platform_device *pdev)
 	strlcpy(adap->name, "OMAP I2C adapter", sizeof(adap->name));
 	adap->algo = &omap_i2c_algo;
 	adap->dev.parent = &pdev->dev;
+	adap->dev.of_node = pdev->dev.of_node;
 
 	/* i2c device drivers may be active on return from add_adapter() */
 	adap->nr = pdev->id;
@@ -1102,6 +1119,8 @@ omap_i2c_probe(struct platform_device *pdev)
 		goto err_free_irq;
 	}
 
+	of_i2c_register_devices(adap);
+
 	return 0;
 
 err_free_irq:
@@ -1143,6 +1162,7 @@ static struct platform_driver omap_i2c_driver = {
 	.driver		= {
 		.name	= "omap_i2c",
 		.owner	= THIS_MODULE,
+		.of_match_table = omap_i2c_of_match,
 	},
 };
 
Signature · 1 line
1.7.0.4
#14 lore raw

PATCH 6/13 mfd: twl-core: Add initial DT support for twl4030/twl6030

In reply to Benoit Cousson

Add initial device-tree support for twl familly chips. The current version is missing the regulator entries due to the lack of DT regulator bindings for the moment. Only the simple sub-modules that do not depend on platform_data information can be initialized properly.

Add documentation for the Texas Instruments TWL Integrated Chip.

Cc Balaji T K <[email protected]>
Cc Graeme Gregory <[email protected]>
Cc Samuel Ortiz <[email protected]>
---
 .../devicetree/bindings/mfd/twl-familly.txt        |   47 +++++++++++++++++
 drivers/mfd/twl-core.c                             |   53 ++++++++++++++++++--
 2 files changed, 96 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/twl-familly.txt
Documentation/devicetree/bindings/mfd/twl-familly.txt new file +47 -0
new file mode 100644
index 0000000..ff4cacd
@@ -0,0 +1,47 @@
+Texas Instruments TWL family
+
+The TWLs are Integrated Power Management Chips.
+Some version might contain much more analog function like
+USB transceiver or Audio amplifier.
+These chips are connected to an i2c bus.
+
+
+Required properties:
+- compatible : Must be "ti,twl4030";
+  For Integrated power-management/audio CODEC device used in OMAP3
+  based boards
+- compatible : Must be "ti,twl6030";
+  For Integrated power-management used in OMAP4 based boards
+- interrupts : This i2c device has an IRQ line connected to the main SoC
+- interrupt-controller : Since the twl support several interrupts internally,
+  it is considered as an interrupt controller cascaded to the SoC one.
+- #interrupt-cells = <1>;
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+- Child nodes contain in the twl. The twl family is made of severals variants
+  that support a different number of features.
+  The children nodes will thus depend of the capabilty of the variant.
+
+
+Example:
+/*
+ * Integrated Power Management Chip
+ * http://www.ti.com/lit/ds/symlink/twl6030.pdf
+ */
+twl at 48 {
+    compatible = "ti,twl6030";
+    reg = <0x48>;
+    interrupts = <39>; /* IRQ_SYS_1N cascaded to gic */
+    interrupt-controller;
+    #interrupt-cells = <1>;
+    interrupt-parent = <&gic>;
+    #address-cells = <1>;
+    #size-cells = <0>;
+
+    twl_rtc {
+        compatible = "ti,twl_rtc";
+        interrupts = <11>;
+        reg = <0>;
+    };
+};
drivers/mfd/twl-core.c +49 -4

87 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#15 lore raw

PATCH 6/13 mfd: twl-core: Add initial DT support for twl4030/twl6030

Quoted 1 line · Benoit Cousson

Add initial device-tree support for twl familly chips.

s/familly/family

Quoted 11 lines

The current version is missing the regulator entries due to the lack of DT regulator bindings for the moment. Only the simple sub-modules that do not depend on platform_data information can be initialized properly.

Add documentation for the Texas Instruments TWL Integrated Chip.

Cc Balaji T K<[email protected]>
Cc Graeme Gregory<[email protected]>
Cc Samuel Ortiz<[email protected]>
Quoted 5 lines
---
  .../devicetree/bindings/mfd/twl-familly.txt        |   47 +++++++++++++++++
  drivers/mfd/twl-core.c                             |   53 ++++++++++++++++++--
  2 files changed, 96 insertions(+), 4 deletions(-)

create mode 100644 Documentation/devicetree/bindings/mfd/twl-familly.txt

s/familly.txt/family.txt

Quoted 31 lines
Documentation/devicetree/bindings/mfd/twl-familly.txt new file +24 -0
new file mode 100644
index 0000000..ff4cacd
@@ -0,0 +1,47 @@
+Texas Instruments TWL family
+
+The TWLs are Integrated Power Management Chips.
+Some version might contain much more analog function like
+USB transceiver or Audio amplifier.
+These chips are connected to an i2c bus.
+
+
+Required properties:
+- compatible : Must be "ti,twl4030";
+  For Integrated power-management/audio CODEC device used in OMAP3
+  based boards
+- compatible : Must be "ti,twl6030";
+  For Integrated power-management used in OMAP4 based boards
+- interrupts : This i2c device has an IRQ line connected to the main SoC
+- interrupt-controller : Since the twl support several interrupts internally,
+  it is considered as an interrupt controller cascaded to the SoC one.
+- #interrupt-cells =<1>;
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+- Child nodes contain in the twl. The twl family is made of severals variants
+  that support a different number of features.
+  The children nodes will thus depend of the capabilty of the variant.

Documentation/devicetree/bindings/mfd/twl-familly.txt line 34

Quoted 10 lines
Documentation/devicetree/bindings/mfd/twl-familly.txt new file +10 -0
+
+
+Example:
+/*
+ * Integrated Power Management Chip
+ * http://www.ti.com/lit/ds/symlink/twl6030.pdf
+ */
+twl at 48 {
+    compatible = "ti,twl6030";
+    reg =<0x48>;

What does the 'reg' property signify here for twl?

Documentation/devicetree/bindings/mfd/twl-familly.txt line 45

Quoted 11 lines
Documentation/devicetree/bindings/mfd/twl-familly.txt new file +11 -0
+    interrupts =<39>; /* IRQ_SYS_1N cascaded to gic */
+    interrupt-controller;
+    #interrupt-cells =<1>;
+    interrupt-parent =<&gic>;
+    #address-cells =<1>;
+    #size-cells =<0>;
+
+    twl_rtc {
+        compatible = "ti,twl_rtc";
+        interrupts =<11>;
+        reg =<0>;

Does the 'reg' property need to be faked for
every twl child node, even if it does not have
any?

Quoted 22 lines
Documentation/devicetree/bindings/mfd/twl-familly.txt new file +2 -0
+    };
+};
drivers/mfd/twl-core.c +5 -0
index 01ecfee..3ef0b43 100644
@@ -33,6 +33,10 @@
  #include<linux/platform_device.h>
  #include<linux/clk.h>
  #include<linux/err.h>
+#include<linux/slab.h>
+#include<linux/of_irq.h>
+#include<linux/of_platform.h>
+#include<linux/irqdomain.h>
 
  #include<linux/regulator/machine.h>
 
@@ -1182,22 +1186,53 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
  	int				status;
  	unsigned			i;
  	struct twl4030_platform_data	*pdata = client->dev.platform_data;
+	struct device_node		*node = client->dev.of_node;

drivers/mfd/twl-core.c twl_probe(struct i2c_client *client, const struct i2c_device_id *id) · line 1199

Quoted 10 lines
drivers/mfd/twl-core.c +7 -0
  	u8 temp;
  	int ret = 0;
 
+	if (node&&  !pdata) {
+		/*
+		 * XXX: Temporary fake pdata until the information
+		 * is correctly retrieved by every TWL modules from DT.
+		 */
+		pdata = kzalloc(sizeof(struct twl4030_platform_data),
+				GFP_KERNEL);

devm_kzalloc instead?

Quoted 43 lines
drivers/mfd/twl-core.c +26 -3
+		if (!pdata) {
+			status = -ENOMEM;
+			goto exit;
+		}
+
+		/*
+		 * XXX: For the moment the IRQs for TWL seems to be encoded in
+		 * the global OMAP space. That should be cleaned to allow
+		 * dynamically adding a new IRQ controller.
+		 */
+		if ((id->driver_data)&  TWL6030_CLASS) {
+			pdata->irq_base = TWL6030_IRQ_BASE;
+			pdata->irq_end = pdata->irq_base + TWL6030_BASE_NR_IRQS;
+		} else {
+			pdata->irq_base = TWL4030_IRQ_BASE;
+			pdata->irq_end = pdata->irq_base + TWL4030_BASE_NR_IRQS;
+		}
+		irq_domain_add_simple(node, pdata->irq_base);
+	}
+
  	if (!pdata) {
  		dev_dbg(&client->dev, "no platform data?\n");
-		return -EINVAL;
+		status = -EINVAL;
+		goto fail_free;
  	}
 
  	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) {
  		dev_dbg(&client->dev, "can't talk I2C?\n");
-		return -EIO;
+		status = -EIO;
+		goto fail_free;
  	}
 
  	if (inuse) {
  		dev_dbg(&client->dev, "driver is already in use\n");
-		return -EBUSY;
+		status = -EBUSY;
+		goto fail_free;
  	}
 
  	for (i = 0; i<  TWL_NUM_SLAVES; i++) {

drivers/mfd/twl-core.c twl_probe(struct i2c_client *client, const struct i2c_device_id *id) · line 1307

Quoted 5 lines
drivers/mfd/twl-core.c +1 -1
@@ -1269,10 +1304,20 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
  		twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
  	}
 
-	status = add_children(pdata, id->driver_data);
+#ifdef CONFIG_OF_DEVICE

is the #ifdef really needed?

Quoted 16 lines
drivers/mfd/twl-core.c +10 -0
+	if (node)
+		status = of_platform_populate(node, NULL, NULL,&client->dev);
+	else
+#endif
+		status = add_children(pdata, id->driver_data);
+
  fail:
  	if (status<  0)
  		twl_remove(client);
+fail_free:
+	if (node)
+		kfree(pdata);
+exit:
  	return status;
  }
 
#16 lore raw

PATCH 6/13 mfd: twl-core: Add initial DT support for twl4030/twl6030

Quoted 4 lines · Rajendra
Quoted 1 line · Benoit Cousson

Add initial device-tree support for twl familly chips.

s/familly/family

Oops.

Quoted 17 lines
Quoted 11 lines

The current version is missing the regulator entries due to the lack of DT regulator bindings for the moment. Only the simple sub-modules that do not depend on platform_data information can be initialized properly.

Add documentation for the Texas Instruments TWL Integrated Chip.

Cc Balaji T K<[email protected]>
Cc Graeme Gregory<[email protected]>
Cc Samuel Ortiz<[email protected]>
Quoted 5 lines
---
   .../devicetree/bindings/mfd/twl-familly.txt        |   47 +++++++++++++++++
   drivers/mfd/twl-core.c                             |   53 ++++++++++++++++++--
   2 files changed, 96 insertions(+), 4 deletions(-)

create mode 100644 Documentation/devicetree/bindings/mfd/twl-familly.txt

Quoted 1 line

s/familly.txt/family.txt

At least I am consistent in my typos ;-)

Quoted 34 lines
Quoted 34 lines
Documentation/devicetree/bindings/mfd/twl-familly.txt new file +28 -0
new file mode 100644
index 0000000..ff4cacd
@@ -0,0 +1,47 @@
+Texas Instruments TWL family
+
+The TWLs are Integrated Power Management Chips.
+Some version might contain much more analog function like
+USB transceiver or Audio amplifier.
+These chips are connected to an i2c bus.
+
+
+Required properties:
+- compatible : Must be "ti,twl4030";
+  For Integrated power-management/audio CODEC device used in OMAP3
+  based boards
+- compatible : Must be "ti,twl6030";
+  For Integrated power-management used in OMAP4 based boards
+- interrupts : This i2c device has an IRQ line connected to the main SoC
+- interrupt-controller : Since the twl support several interrupts internally,
+  it is considered as an interrupt controller cascaded to the SoC one.
+- #interrupt-cells =<1>;
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+- Child nodes contain in the twl. The twl family is made of severals variants
+  that support a different number of features.
+  The children nodes will thus depend of the capabilty of the variant.
+
+
+Example:
+/*
Quoted 8 lines

Documentation/devicetree/bindings/mfd/twl-familly.txt

Quoted 6 lines
Documentation/devicetree/bindings/mfd/twl-familly.txt new file +6 -0
+ * Integrated Power Management Chip
+ * http://www.ti.com/lit/ds/symlink/twl6030.pdf
+ */
+twl at 48 {
+    compatible = "ti,twl6030";
+    reg =<0x48>;

What does the 'reg' property signify here for twl?

The i2c slave address.

Quoted 12 lines

Documentation/devicetree/bindings/mfd/twl-familly.txt line 45

Quoted 11 lines
Documentation/devicetree/bindings/mfd/twl-familly.txt new file +11 -0
+    interrupts =<39>; /* IRQ_SYS_1N cascaded to gic */
+    interrupt-controller;
+    #interrupt-cells =<1>;
+    interrupt-parent =<&gic>;
+    #address-cells =<1>;
+    #size-cells =<0>;
+
+    twl_rtc {
+        compatible = "ti,twl_rtc";
+        interrupts =<11>;
+        reg =<0>;
Quoted 3 lines

Does the 'reg' property need to be faked for
every twl child node, even if it does not have
any?

No, it was even removed from the DTS. But I forgot to update the documentation:-(

Quoted 25 lines
Quoted 25 lines
Documentation/devicetree/bindings/mfd/twl-familly.txt new file +2 -0
+    };
+};
drivers/mfd/twl-core.c +5 -0
index 01ecfee..3ef0b43 100644
@@ -33,6 +33,10 @@
   #include<linux/platform_device.h>
   #include<linux/clk.h>
   #include<linux/err.h>
+#include<linux/slab.h>
+#include<linux/of_irq.h>
+#include<linux/of_platform.h>
+#include<linux/irqdomain.h>
 
   #include<linux/regulator/machine.h>
 
@@ -1182,22 +1186,53 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
   	int				status;
   	unsigned			i;
   	struct twl4030_platform_data	*pdata = client->dev.platform_data;
+	struct device_node		*node = client->dev.of_node;
   	u8 temp;
   	int ret = 0;
 
Quoted 9 lines

drivers/mfd/twl-core.c twl_probe(struct i2c_client *client, const struct i2c_device_id *id) · line 1199

Quoted 7 lines
drivers/mfd/twl-core.c +7 -0
+	if (node&&   !pdata) {
+		/*
+		 * XXX: Temporary fake pdata until the information
+		 * is correctly retrieved by every TWL modules from DT.
+		 */
+		pdata = kzalloc(sizeof(struct twl4030_platform_data),
+				GFP_KERNEL);

devm_kzalloc instead?

Good point.

Quoted 46 lines
Quoted 46 lines
drivers/mfd/twl-core.c +26 -3
+		if (!pdata) {
+			status = -ENOMEM;
+			goto exit;
+		}
+
+		/*
+		 * XXX: For the moment the IRQs for TWL seems to be encoded in
+		 * the global OMAP space. That should be cleaned to allow
+		 * dynamically adding a new IRQ controller.
+		 */
+		if ((id->driver_data)&   TWL6030_CLASS) {
+			pdata->irq_base = TWL6030_IRQ_BASE;
+			pdata->irq_end = pdata->irq_base + TWL6030_BASE_NR_IRQS;
+		} else {
+			pdata->irq_base = TWL4030_IRQ_BASE;
+			pdata->irq_end = pdata->irq_base + TWL4030_BASE_NR_IRQS;
+		}
+		irq_domain_add_simple(node, pdata->irq_base);
+	}
+
   	if (!pdata) {
   		dev_dbg(&client->dev, "no platform data?\n");
-		return -EINVAL;
+		status = -EINVAL;
+		goto fail_free;
   	}
 
   	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) {
   		dev_dbg(&client->dev, "can't talk I2C?\n");
-		return -EIO;
+		status = -EIO;
+		goto fail_free;
   	}
 
   	if (inuse) {
   		dev_dbg(&client->dev, "driver is already in use\n");
-		return -EBUSY;
+		status = -EBUSY;
+		goto fail_free;
   	}
 
   	for (i = 0; i<   TWL_NUM_SLAVES; i++) {
@@ -1269,10 +1304,20 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
   		twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
   	}
 
Quoted 4 lines

drivers/mfd/twl-core.c twl_probe(struct i2c_client *client, const struct i2c_device_id *id) · line 1307

Quoted 2 lines
drivers/mfd/twl-core.c +1 -1
-	status = add_children(pdata, id->driver_data);
+#ifdef CONFIG_OF_DEVICE

is the #ifdef really needed?

Yes, because the of_platform_populate does not have a stub in case of none DT build... But I agree, it is ugly and the of_platform.h should maybe be fixed instead.
I was too lazy to fix it :-)

Thanks,
Benoit

#17 lore raw

PATCH 7/13 rtc: rtc-twl: Add DT support for RTC inside twl4030/twl6030

In reply to Benoit Cousson

Add the DT support for the TI rtc-twl present in the twl4030 and twl6030 devices.

Alessandro Zummo <[email protected]>

---
 Documentation/devicetree/bindings/rtc/twl-rtc.txt |   12 ++++++++++++
 drivers/rtc/rtc-twl.c                             |   10 ++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/twl-rtc.txt
Documentation/devicetree/bindings/rtc/twl-rtc.txt new file +12 -0
new file mode 100644
index 0000000..596e0c9
@@ -0,0 +1,12 @@
+* TI twl RTC
+
+The TWL family (twl4030/6030) contains a RTC.
+
+Required properties:
+- compatible : Should be twl4030-rtc
+
+Examples:
+
+rtc at 0 {
+    compatible = "ti,twl4030-rtc";
+};
drivers/rtc/rtc-twl.c +8 -2
index 20687d5..d43b4f6 100644
@@ -550,6 +550,11 @@ static int twl_rtc_resume(struct platform_device *pdev)
 #define twl_rtc_resume  NULL
 #endif
 
+static const struct of_device_id twl_rtc_of_match[] = {
+	{.compatible = "ti,twl4030-rtc", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, twl_rtc_of_match);
 MODULE_ALIAS("platform:twl_rtc");
 
 static struct platform_driver twl4030rtc_driver = {
@@ -559,8 +564,9 @@ static struct platform_driver twl4030rtc_driver = {
 	.suspend	= twl_rtc_suspend,
 	.resume		= twl_rtc_resume,
 	.driver		= {
-		.owner	= THIS_MODULE,
-		.name	= "twl_rtc",
+		.owner		= THIS_MODULE,
+		.name		= "twl_rtc",
+		.of_match_table = twl_rtc_of_match,
 	},
 };
 
Signature · 1 line
1.7.0.4
#18 lore raw

PATCH 8/13 arm/dts: OMAP4: Add i2c controller nodes

In reply to Benoit Cousson

Add i2c controllers nodes into the main ocp bus.

Cc G, Manjunath Kondaiah <[email protected]>
---
 arch/arm/boot/dts/omap4.dtsi |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap4.dtsi +32 -0
index bb19bca..447f482 100644
@@ -21,6 +21,10 @@
 	interrupt-parent = <&gic>;
 
 	aliases {
+		i2c1 = &i2c1;
+		i2c2 = &i2c2;
+		i2c3 = &i2c3;
+		i2c4 = &i2c4;
 	};
 
 	cpus {
@@ -173,5 +177,33 @@
 			#gpio-cells = <2>;
 			gpio-controller;
 		};
+
+		i2c1: i2c at 1 {
+			compatible = "ti,omap3-i2c";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			ti,hwmods = "i2c1";
+		};
+
+		i2c2: i2c at 2 {
+			compatible = "ti,omap3-i2c";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			ti,hwmods = "i2c2";
+		};
+
+		i2c3: i2c at 3 {
+			compatible = "ti,omap3-i2c";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			ti,hwmods = "i2c3";
+		};
+
+		i2c4: i2c at 4 {
+			compatible = "ti,omap3-i2c";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			ti,hwmods = "i2c4";
+		};
 	};
 };
Signature · 1 line
1.7.0.4
#19 lore raw

PATCH 8/13 arm/dts: OMAP4: Add i2c controller nodes

Quoted 24 lines · Benoit Cousson

Add i2c controllers nodes into the main ocp bus.

Cc G, Manjunath Kondaiah<[email protected]>
---
  arch/arm/boot/dts/omap4.dtsi |   32 ++++++++++++++++++++++++++++++++
  1 files changed, 32 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap4.dtsi +4 -0
index bb19bca..447f482 100644
@@ -21,6 +21,10 @@
  	interrupt-parent =<&gic>;
 
  	aliases {
+		i2c1 =&i2c1;
+		i2c2 =&i2c2;
+		i2c3 =&i2c3;
+		i2c4 =&i2c4;
  	};
 
  	cpus {

arch/arm/boot/dts/omap4.dtsi line 182

Quoted 6 lines
arch/arm/boot/dts/omap4.dtsi +3 -0
@@ -173,5 +177,33 @@
  			#gpio-cells =<2>;
  			gpio-controller;
  		};
+
+		i2c1: i2c at 1 {
+			compatible = "ti,omap3-i2c";

This is a little confusing as omap4.dtsi has
compatible "ti,omap3-i2c" nodes in it.

Quoted 27 lines
arch/arm/boot/dts/omap4.dtsi +25 -0
+			#address-cells =<1>;
+			#size-cells =<0>;
+			ti,hwmods = "i2c1";
+		};
+
+		i2c2: i2c at 2 {
+			compatible = "ti,omap3-i2c";
+			#address-cells =<1>;
+			#size-cells =<0>;
+			ti,hwmods = "i2c2";
+		};
+
+		i2c3: i2c at 3 {
+			compatible = "ti,omap3-i2c";
+			#address-cells =<1>;
+			#size-cells =<0>;
+			ti,hwmods = "i2c3";
+		};
+
+		i2c4: i2c at 4 {
+			compatible = "ti,omap3-i2c";
+			#address-cells =<1>;
+			#size-cells =<0>;
+			ti,hwmods = "i2c4";
+		};
  	};
  };
#20 lore raw

PATCH 9/13 arm/dts: OMAP3: Add i2c controller nodes

In reply to Benoit Cousson

Add i2c controllers nodes into the main ocp bus.

Cc G, Manjunath Kondaiah <[email protected]>
---
 arch/arm/boot/dts/omap3.dtsi |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap3.dtsi +27 -0
index d202bb5..8ff794f 100644
@@ -13,6 +13,12 @@
 / {
 	compatible = "ti,omap3430", "ti,omap3";
 
+	aliases {
+		i2c1 = &i2c1;
+		i2c2 = &i2c2;
+		i2c3 = &i2c3;
+	};
+
 	cpus {
 		cpu at 0 {
 			compatible = "arm,cortex-a8";
@@ -59,5 +65,26 @@
 			interrupt-controller;
 			#interrupt-cells = <1>;
 		};
+
+		i2c1: i2c at 1 {
+			compatible = "ti,omap3-i2c";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			ti,hwmods = "i2c1";
+		};
+
+		i2c2: i2c at 2 {
+			compatible = "ti,omap3-i2c";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			ti,hwmods = "i2c2";
+		};
+
+		i2c3: i2c at 3 {
+			compatible = "ti,omap3-i2c";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			ti,hwmods = "i2c3";
+		};
 	};
 };
Signature · 1 line
1.7.0.4
#21 lore raw

PATCH 10/13 arm/dts: omap4-panda: Add twl6030 and i2c EEPROM

In reply to Benoit Cousson

Update pandaboard dts file with required clock frequencies for the i2c client devices existing on pandaboard.

Add the twl6030 node in i2c1 controller.

This is the minimal support needed to boot OMAP4 boards without any crash.
The support for all the features included in this MFD will be added later.

Add a generic i2c EEPROM entry.

---
 arch/arm/boot/dts/omap4-panda.dts |   44 +++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap4-panda.dts +44 -0
index c702657..2c6ce2b 100644
@@ -27,3 +27,47 @@
 		reg = <0x80000000 0x40000000>; /* 1 GB */
 	};
 };
+
+&i2c1 {
+	clock-frequency = <400000>;
+
+	/*
+	 * Integrated Power Management Chip
+	 * http://www.ti.com/lit/ds/symlink/twl6030.pdf
+	 */
+	twl at 48 {
+		compatible = "ti,twl6030";
+		reg = <0x48>;
+		interrupts = <39>; /* IRQ_SYS_1N cascaded to gic */
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		interrupt-parent = <&gic>;
+
+		/* twl is a MFD, so it will contain a bunch of sub-ips */
+		twl_rtc {
+			compatible = "ti,twl4030-rtc";
+			interrupts = <11>;
+		};
+	};
+};
+
+&i2c2 {
+	clock-frequency = <400000>;
+};
+
+&i2c3 {
+	clock-frequency = <100000>;
+
+	/*
+	 * Display monitor features are burnt in their EEPROM as EDID data.
+	 * The EEPROM is connected as I2C slave device.
+	 */
+	eeprom at 50 {
+		compatible = "ti,eeprom";
+		reg = <0x50>;
+	};
+};
+
+&i2c4 {
+	clock-frequency = <400000>;
+};
Signature · 1 line
1.7.0.4
#22 lore raw

PATCH 11/13 arm/dts: omap4-sdp: Add twl6030, i2c3 and i2c4 devices

In reply to Benoit Cousson

Update DTS file with required clock frequencies for the i2c client devices existing on sdp4430.

Add the twl6030 node inside the i2c1 controller node. This is the minimal support needed to boot OMAP4 boards without any crash.
The support for all the features included in this MFD will be added later.

Add the RTC submodule inside the twl node.

Add tmp105 temperature sensor in i2c3
Add bh1780 Ambient Light Sensor in i2c3
Add hmc5843 3-Axis Digital Compass in i2c4

---
 arch/arm/boot/dts/omap4-sdp.dts |   62 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap4-sdp.dts +62 -0
index 066e28c..2990841 100644
@@ -27,3 +27,65 @@
 		reg = <0x80000000 0x40000000>; /* 1 GB */
 	};
 };
+
+&i2c1 {
+	clock-frequency = <400000>;
+
+	/*
+	 * Integrated Power Management Chip
+	 * http://www.ti.com/lit/ds/symlink/twl6030.pdf
+	 */
+	twl at 48 {
+		compatible = "ti,twl6030";
+		reg = <0x48>;
+		interrupts = <39>; /* IRQ_SYS_1N cascaded to gic */
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		interrupt-parent = <&gic>;
+
+		/* twl is a MFD, so it will contain a bunch of sub-ips */
+		twl_rtc {
+			compatible = "ti,twl4030-rtc";
+			interrupts = <11>;
+		};
+	};
+};
+
+&i2c2 {
+	clock-frequency = <400000>;
+};
+
+&i2c3 {
+	clock-frequency = <400000>;
+
+	/*
+	 * Temperature Sensor
+	 * http://www.ti.com/lit/ds/symlink/tmp105.pdf
+	 */
+	tmp105 at 48 {
+		compatible = "ti,tmp105";
+		reg = <0x48>;
+	};
+
+	/*
+	 * Ambient Light Sensor
+	 * http://www.rohm.com/products/databook/sensor/pdf/bh1780gli-e.pdf
+	 */
+	bh1780 at 29 {
+		compatible = "rohm,bh1780";
+		reg = <0x29>;
+	};
+};
+
+&i2c4 {
+	clock-frequency = <400000>;
+
+	/*
+	 * 3-Axis Digital Compass
+	 * http://www.sparkfun.com/datasheets/Sensors/Magneto/HMC5843.pdf
+	 */
+	hmc5843 at 1e {
+		compatible = "honeywell,hmc5843";
+		reg = <0x1e>;
+	};
+};
Signature · 1 line
1.7.0.4
#23 lore raw

PATCH 12/13 arm/dts: omap3-beagle: Add twl4030 and i2c EEPROM

In reply to Benoit Cousson

Add required clock frequencies for the i2c client devices existing on beagle board.

Add the twl4030 basic description with only the twl_rtc module.

Add the EEPROM node.

Based on original patch from Manju:
http://www.spinics.net/lists/linux-omap/msg55831.html

Cc G, Manjunath Kondaiah <[email protected]>
---
 arch/arm/boot/dts/omap3-beagle.dts |   38 ++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap3-beagle.dts +38 -0
index 9486be6..a65f39d 100644
@@ -27,3 +27,41 @@
 		reg = <0x80000000 0x20000000>; /* 512 MB */
 	};
 };
+
+&i2c1 {
+	clock-frequency = <2600000>;
+
+	/*
+	 * Integrated Power Management Chip
+	 */
+	twl at 48 {
+		compatible = "ti,twl4030";
+		reg = <0x48>;
+		interrupts = <7>; /* SYS_NIRQ cascaded to intc */
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		interrupt-parent = <&intc>;
+
+		twl_rtc {
+			compatible = "ti,twl4030-rtc";
+			interrupts = <11>;
+		};
+	};
+};
+
+&i2c2 {
+	clock-frequency = <400000>;
+};
+
+&i2c3 {
+	clock-frequency = <100000>;
+
+	/*
+	 * Display monitor features are burnt in the EEPROM
+	 * as EDID data.
+	 */
+	eeprom at 50 {
+		compatible = "ti,eeprom";
+		reg = <0x50>;
+	};
+};
Signature · 1 line
1.7.0.4
#24 lore raw

PATCH 12/13 arm/dts: omap3-beagle: Add twl4030 and i2c EEPROM

Quoted 30 lines · Benoit Cousson

Add required clock frequencies for the i2c client devices existing on beagle board.

Add the twl4030 basic description with only the twl_rtc module.

Add the EEPROM node.

Based on original patch from Manju:
http://www.spinics.net/lists/linux-omap/msg55831.html

Cc G, Manjunath Kondaiah <[email protected]>
---
 arch/arm/boot/dts/omap3-beagle.dts |   38 ++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap3-beagle.dts +6 -0
index 9486be6..a65f39d 100644
@@ -27,3 +27,41 @@
 		reg = <0x80000000 0x20000000>; /* 512 MB */
 	};
 };
+
+&i2c1 {
+	clock-frequency = <2600000>;
+
+	/*
+	 * Integrated Power Management Chip

arch/arm/boot/dts/omap3-beagle.dts line 45

Quoted 10 lines
arch/arm/boot/dts/omap3-beagle.dts +10 -0
+	 */
+	twl at 48 {
+		compatible = "ti,twl4030";
+		reg = <0x48>;
+		interrupts = <7>; /* SYS_NIRQ cascaded to intc */
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		interrupt-parent = <&intc>;
+
+		twl_rtc {

Nit: use the generic names recommended practise for node names (in this case, simply 'rtc' sounds appropriate, and don't use underscores (it's not forbidden, just doesn't match the style.

Quoted 25 lines
arch/arm/boot/dts/omap3-beagle.dts +22 -0
+			compatible = "ti,twl4030-rtc";
+			interrupts = <11>;
+		};
+	};
+};
+
+&i2c2 {
+	clock-frequency = <400000>;
+};
+
+&i2c3 {
+	clock-frequency = <100000>;
+
+	/*
+	 * Display monitor features are burnt in the EEPROM
+	 * as EDID data.
+	 */
+	eeprom at 50 {
+		compatible = "ti,eeprom";
+		reg = <0x50>;
+	};
+};
Signature · 1 line
1.7.0.4
#25 lore raw

PATCH 13/13 OMAP2+: board-generic: Remove i2c static init

In reply to Benoit Cousson

This mainly reverts the commit that was adding the i2c static init.

Since the i2c and twl nodes are now present, there is no need for the static initialization anymore.

---
 arch/arm/mach-omap2/board-generic.c |   41 +---------------------------------
 1 files changed, 2 insertions(+), 39 deletions(-)
arch/arm/mach-omap2/board-generic.c +2 -39
index 1186a76..dcbd64c 100644
@@ -11,7 +11,6 @@
 #include <linux/io.h>
 #include <linux/of_platform.h>
 #include <linux/irqdomain.h>
-#include <linux/i2c/twl.h>
 
 #include <mach/hardware.h>
 #include <asm/mach/arch.h>
@@ -19,31 +18,7 @@
 #include <plat/board.h>
 #include <plat/common.h>
 #include <mach/omap4-common.h>
-#include "common-board-devices.h"
 
-/*
- * XXX: Still needed to boot until the i2c & twl driver is adapted to
- * device-tree
- */
-static struct twl4030_platform_data sdp4430_twldata = {
-	.irq_base	= TWL6030_IRQ_BASE,
-	.irq_end	= TWL6030_IRQ_END,
-};
-
-static void __init omap4_i2c_init(void)
-{
-	omap4_pmic_init("twl6030", &sdp4430_twldata);
-}
-
-static struct twl4030_platform_data beagle_twldata = {
-	.irq_base	= TWL4030_IRQ_BASE,
-	.irq_end	= TWL4030_IRQ_END,
-};
-
-static void __init omap3_i2c_init(void)
-{
-	omap3_pmic_init("twl4030", &beagle_twldata);
-}
 
 static struct of_device_id omap_dt_match_table[] __initdata = {
 	{ .compatible = "simple-bus", },
@@ -69,18 +44,6 @@ static void __init omap_generic_init(void)
 	of_platform_populate(NULL, omap_dt_match_table, NULL, NULL);
 }
 
-static void __init omap4_init(void)
-{
-	omap4_i2c_init();
-	omap_generic_init();
-}
-
-static void __init omap3_init(void)
-{
-	omap3_i2c_init();
-	omap_generic_init();
-}
-
 #if defined(CONFIG_SOC_OMAP2420)
 static const char *omap242x_boards_compat[] __initdata = {
 	"ti,omap2420",
@@ -126,7 +89,7 @@ DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
 	.map_io		= omap3_map_io,
 	.init_early	= omap3430_init_early,
 	.init_irq	= omap3_init_irq,
-	.init_machine	= omap3_init,
+	.init_machine	= omap_generic_init,
 	.timer		= &omap3_timer,
 	.dt_compat	= omap3_boards_compat,
 MACHINE_END
@@ -143,7 +106,7 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
 	.map_io		= omap4_map_io,
 	.init_early	= omap4430_init_early,
 	.init_irq	= gic_init_irq,
-	.init_machine	= omap4_init,
+	.init_machine	= omap_generic_init,
 	.timer		= &omap4_timer,
 	.dt_compat	= omap4_boards_compat,
 MACHINE_END
Signature · 1 line
1.7.0.4