Hi Grant,<br><br><div class="gmail_quote">On Thu, Jul 14, 2011 at 4:45 AM, Grant Likely <span dir="ltr"><<a href="mailto:grant.likely@secretlab.ca">grant.likely@secretlab.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Thu, Jul 14, 2011 at 7:06 AM, G, Manjunath Kondaiah <<a href="mailto:manjugk@ti.com">manjugk@ti.com</a>> wrote:<br>
><br>
> The generic board file is created and derived from beagle board file.<br>
> The beagle board file is migrated to boot from flattened device tree and<br>
> the cleanup of generic board file will happen in different stages.<br>
><br>
> The changes here focus on i2c device registration through dt and upcoming<br>
> patches in the series will adopt i2c driver to use dt registered i2c<br>
> devices.<br>
<br>
</div>Since this is a new board file instead of a modification of an<br>
existing one, I recommend *not* trying to completely duplicate the<br>
behaviour of the beagle board.  Start small with only the registration<br>
of the UART and i2c drivers from the device tree and build up<br>
functionality until it can be used for all the OMAP3 boards.<br>
Otherwise the patch just adds a lot of code that needs to be removed<br>
again.<br></blockquote><div> </div><div>agreed. Started with minimal board file with only serial and i2c.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div class="im"><br>
><br>
> Signed-off-by: G, Manjunath Kondaiah <<a href="mailto:manjugk@ti.com">manjugk@ti.com</a>><br>
> ---<br>
>  arch/arm/mach-omap2/Kconfig             |   12 +<br>
>  arch/arm/mach-omap2/Makefile            |    2 +<br>
>  arch/arm/mach-omap2/board-omap3-dt.c    |  623 +++++++++++++++++++++++++++++++<br>
>  arch/arm/mach-omap2/board-omap3beagle.c |   13 -<br>
>  4 files changed, 637 insertions(+), 13 deletions(-)<br>
>  create mode 100644 arch/arm/mach-omap2/board-omap3-dt.c<br>
><br>
> diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig<br>
> index 19d5891..174f6d1 100644<br>
> --- a/arch/arm/mach-omap2/Kconfig<br>
> +++ b/arch/arm/mach-omap2/Kconfig<br>
> @@ -302,6 +302,18 @@ config MACH_OMAP_3630SDP<br>
>        default y<br>
>        select OMAP_PACKAGE_CBP<br>
><br>
> +config MACH_OMAP3_DT<br>
> +       bool "Generic OMAP3 board(FDT support)"<br>
> +       depends on ARCH_OMAP3<br>
> +       select OMAP_PACKAGE_CBB<br>
> +       select USE_OF<br>
> +       select PROC_DEVICETREE<br>
<br>
</div>Don't select PROC_DEVICETREE<br></blockquote><div>ok <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
> +<br>
> +       help<br>
> +         Support for generic TI OMAP3 boards using Flattened Device Tree.<br>
> +         Say Y here to enable OMAP3 device tree support<br>
> +         More information at Documentation/devicetree<br>
> +<br>
>  config MACH_TI8168EVM<br>
>        bool "TI8168 Evaluation Module"<br>
>        depends on SOC_OMAPTI816X<br>
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile<br>
> index b148077..86e66f7 100644<br>
> --- a/arch/arm/mach-omap2/Makefile<br>
> +++ b/arch/arm/mach-omap2/Makefile<br>
> @@ -178,6 +178,8 @@ obj-$(CONFIG_MACH_OMAP_H4)          += board-h4.o<br>
>  obj-$(CONFIG_MACH_OMAP_2430SDP)                += board-2430sdp.o \<br>
>                                           hsmmc.o<br>
>  obj-$(CONFIG_MACH_OMAP_APOLLON)                += board-apollon.o<br>
> +obj-$(CONFIG_MACH_OMAP3_DT)            += board-omap3-dt.o \<br>
> +                                          hsmmc.o<br>
>  obj-$(CONFIG_MACH_OMAP3_BEAGLE)                += board-omap3beagle.o \<br>
>                                           hsmmc.o<br>
<br>
</div>This is an odd construct.  Tony, why does each board add hsmmc to the<br>
oby-y variable instead of it having its own kconfig symbol?<br>
<div><div></div><div class="h5"><br>
> +static void __init omap3_init(void)<br>
> +{<br>
> +       struct device_node *node;<br>
> +<br>
> +       node = of_find_matching_node_by_address(NULL, omap3_dt_intc_match,<br>
> +                                               OMAP34XX_IC_BASE);<br>
> +       if (node)<br>
> +               irq_domain_add_simple(node, 0);<br>
> +<br>
> +       omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);<br>
> +       omap3_beagle_init_rev();<br>
> +       omap3_beagle_i2c_init();<br>
> +       platform_add_devices(omap3_beagle_devices,<br>
> +                       ARRAY_SIZE(omap3_beagle_devices));<br>
> +       omap_display_init(&beagle_dss_data);<br>
> +       omap_serial_init();<br>
> +<br>
> +       omap_mux_init_gpio(170, OMAP_PIN_INPUT);<br>
> +       /* REVISIT leave DVI powered down until it's needed ... */<br>
> +       gpio_request_one(170, GPIOF_OUT_INIT_HIGH, "DVI_nPD");<br>
> +<br>
> +       usb_musb_init(NULL);<br>
> +       usbhs_init(&usbhs_bdata);<br>
> +       omap_nand_flash_init(NAND_BUSWIDTH_16, omap3beagle_nand_partitions,<br>
> +                            ARRAY_SIZE(omap3beagle_nand_partitions));<br>
> +<br>
> +       /* Ensure msecure is mux'd to be able to set the RTC. */<br>
> +       omap_mux_init_signal("sys_drm_msecure", OMAP_PIN_OFF_OUTPUT_HIGH);<br>
> +<br>
> +       /* Ensure SDRC pins are mux'd for self-refresh */<br>
> +       omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);<br>
> +       omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);<br>
> +<br>
> +       beagle_display_init();<br>
> +       beagle_opp_init();<br>
> +       of_platform_populate(NULL, omap_dt_match_table, NULL, NULL);<br>
<br>
</div></div>Hmmm, I don't think this will work for OMAP because it will not create<br>
the i2c bus as an omap_device.  It will only be a plane<br>
platform_deevice.  You'll need to have a hook in<br>
of_platform_populate() to create devices the way omap3 infrastructure<br>
expects.<br>
<div class="im"><br></div></blockquote><div><br>This dependency is mentioned in patch series. Since you pointed out this<br>issue, I would like to propose following approach for hooking up omap hwmod·<br>framework with dt. Though, the current approach focus only on i2c driver, it<br>
can be extended and generalized as it evolves with other board and driver cleanup<br>activities. The following changes are not tested and also not compiled,  it is<br>only proposal I am thinking to implement. <br><br>Let me know if you see any serious issues with the approach.<br>

<pre><span class="Type"></span>
<span class="Type">diff --git a/drivers/of/platform.c b/drivers/of/platform.c</span>
index c1773456..104ef31 100644
<span class="Type">--- a/drivers/of/platform.c</span>
<span class="Type">+++ b/drivers/of/platform.c</span>
<span class="Statement">@@ -457,6 +457,8 @@</span><span class="PreProc"> void of_platform_prepare(struct device_node *root,</span>
        }
 }

<span class="Identifier">+</span>
<span class="Identifier">+</span>
 #ifdef CONFIG_ARM_AMBA
 static struct amba_device *of_amba_device_create(struct device_node *node,
                                                 const char *bus_id,
<span class="Statement">@@ -537,13 +539,60 @@</span><span class="PreProc"> static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *l</span>
                                continue;
                        if (res.start != lookup->phys_addr)
                                continue;
<span class="Special">-                       pr_debug("%s: devname=%s\n", np->full_name, lookup->name);</span>
<span class="Identifier">+                       printk("%s: devname=%s\n", np->full_name, lookup->name);</span>
                        return lookup;
                }
        }
        return NULL;
 }

<span class="Identifier">+static struct omap_device *of_omap_i2c_device_create(struct device_node *node,</span>
<span class="Identifier">+                                                const char *bus_id,</span>
<span class="Identifier">+                                                void *platform_data,</span>
<span class="Identifier">+                                                struct device *parent)</span>
<span class="Identifier">+{</span>
<span class="Identifier">+       struct platform_device *pdev;</span>
<span class="Identifier">+       struct i2c_board_info *i2c_board_info;</span>
<span class="Identifier">+       u8 id;</span>
<span class="Identifier">+</span>
<span class="Identifier">+       printk("Creating omap i2c device %s\n", node->full_name);</span>
<span class="Identifier">+</span>
<span class="Identifier">+       if (!of_device_is_available(node))</span>
<span class="Identifier">+               return NULL;</span>
<span class="Identifier">+</span>
<span class="Identifier">+       id = simple_strtol(bus_id, NULL, 0);</span>
<span class="Identifier">+       pdev = kzalloc(sizeof(*pdev), GFP_KERNEL);</span>
<span class="Identifier">+       pdev->dev.of_node = of_node_get(node);</span>
<span class="Identifier">+       if (!pdev->dev.of_node) {</span>
<span class="Identifier">+               speed = 100;</span>
<span class="Identifier">+       } else {</span>
<span class="Identifier">+               u32 prop;</span>
<span class="Identifier">+               if (!of_property_read_u32(pdev->dev.of_node, "clock-frequency",</span>
<span class="Identifier">+                                                                       &prop))</span>
<span class="Identifier">+                       speed = prop/100;</span>
<span class="Identifier">+               else</span>
<span class="Identifier">+                       speed = 100;</span>
<span class="Identifier">+       }</span>
<span class="Identifier">+       printk("%s : speed->%d\n",__func__, speed);</span>
<span class="Identifier">+</span>
<span class="Identifier">+       for_each_child_of_node(bus, child) {</span>
<span class="Identifier">+               u32 prop;</span>
<span class="Identifier">+</span>
<span class="Identifier">+               printk("   create child: %s\n", child->full_name);</span>
<span class="Identifier">+               i2c_board_info = kzalloc(sizeof(*i2c_board_info), GFP_KERNEL);</span>
<span class="Identifier">+               if (!of_property_read_u32(pdev->dev.of_node, "reg",</span>
<span class="Identifier">+                                                               &prop))</span>
<span class="Identifier">+               i2c_board_info->addr = prop;</span>
<span class="Identifier">+               if (!of_property_read_u32(pdev->dev.of_node, "interrupts",</span>
<span class="Identifier">+                                                               &prop))</span>
<span class="Identifier">+               i2c_board_info->irq = prop;</span>
<span class="Identifier">+               i2c_board_info->platform_data = platform_data;</span>
<span class="Identifier">+               strncpy(i2c_board_info->type, child->name,</span>
<span class="Identifier">+                                       sizeof(i2c_board_info->type));</span>
<span class="Identifier">+       }</span>
<span class="Identifier">+       omap_register_i2c_bus(id, speed, i2c_board_info, 1);</span>
<span class="Identifier">+}</span>
<span class="Identifier">+</span>
 /**
  * of_platform_bus_create() - Create a device for a node and its children.
  * @bus: device node of the bus to instantiate
<span class="Statement">@@ -593,6 +642,11 @@</span><span class="PreProc"> static int of_platform_bus_create(struct device_node *bus,</span>
                return 0;
        }

<span class="Identifier">+       if (of_device_is_compatible(bus, "ti,omap3-i2c")) {</span>
<span class="Identifier">+               of_omap_i2c_device_create(bus, bus_id, platform_data, parent);</span>
<span class="Identifier">+               return 0;</span>
<span class="Identifier">+       }</span>
<span class="Identifier">+</span>
        dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent);
        if (!dev || !of_match_node(matches, bus))
                return 0;
</pre><br>
</div></div>-M<br>