From patchwork Sat Jul 16 20:07:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: manjugk manjugk X-Patchwork-Id: 982472 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6GK88OY013741 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 16 Jul 2011 20:08:29 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QiB9U-0002ZQ-Ek; Sat, 16 Jul 2011 20:07:52 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QiB9U-0003Se-2m; Sat, 16 Jul 2011 20:07:52 +0000 Received: from na3sys009aog111.obsmtp.com ([74.125.149.205]) by canuck.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1QiB9N-0003SJ-Jv for linux-arm-kernel@lists.infradead.org; Sat, 16 Jul 2011 20:07:50 +0000 Received: from mail-fx0-f48.google.com ([209.85.161.48]) (using TLSv1) by na3sys009aob111.postini.com ([74.125.148.12]) with SMTP ID DSNKTiHvjc6ePuF3ERtKRae/pAHpQefUZ9b7@postini.com; Sat, 16 Jul 2011 13:07:45 PDT Received: by fxg7 with SMTP id 7so3326464fxg.21 for ; Sat, 16 Jul 2011 13:07:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.36.7 with SMTP id r7mr1350157bkd.2.1310846860292; Sat, 16 Jul 2011 13:07:40 -0700 (PDT) Received: by 10.204.53.195 with HTTP; Sat, 16 Jul 2011 13:07:40 -0700 (PDT) In-Reply-To: References: <1310592975-25773-1-git-send-email-manjugk@ti.com> <1310592975-25773-4-git-send-email-manjugk@ti.com> Date: Sun, 17 Jul 2011 01:37:40 +0530 Message-ID: Subject: Re: [PATCH 3/4] dt: omap3: add generic board file for dt support From: "G, Manjunath Kondaiah" To: Grant Likely X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110716_160745_997983_D21E2DDF X-CRM114-Status: GOOD ( 32.18 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.205 listed in list.dnswl.org] Cc: devicetree-discuss@lists.ozlabs.org, linux-omap@vger.kernel.org, ben-linux@fluff.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 16 Jul 2011 20:08:29 +0000 (UTC) X-MIME-Autoconverted: from quoted-printable to 8bit by demeter2.kernel.org id p6GK88OY013741 ps: posting again since my mailer has triggered the mail in html format hence it does not reach some mailing lists. Hi Grant, > On Thu, Jul 14, 2011 at 4:45 AM, Grant Likely wrote: >> >> On Thu, Jul 14, 2011 at 7:06 AM, G, Manjunath Kondaiah wrote: >> > >> > The generic board file is created and derived from beagle board file. >> > The beagle board file is migrated to boot from flattened device tree and >> > the cleanup of generic board file will happen in different stages. >> > >> > The changes here focus on i2c device registration through dt and upcoming >> > patches in the series will adopt i2c driver to use dt registered i2c >> > devices. >> >> Since this is a new board file instead of a modification of an >> existing one, I recommend *not* trying to completely duplicate the >> behaviour of the beagle board. Start small with only the registration >> of the UART and i2c drivers from the device tree and build up >> functionality until it can be used for all the OMAP3 boards. >> Otherwise the patch just adds a lot of code that needs to be removed >> again. > agreed. Started with minimal board file with only serial and i2c. >> >> > >> > Signed-off-by: G, Manjunath Kondaiah >> > --- >> > arch/arm/mach-omap2/Kconfig | 12 + >> > arch/arm/mach-omap2/Makefile | 2 + >> > arch/arm/mach-omap2/board-omap3-dt.c | 623 +++++++++++++++++++++++++++++++ >> > arch/arm/mach-omap2/board-omap3beagle.c | 13 - >> > 4 files changed, 637 insertions(+), 13 deletions(-) >> > create mode 100644 arch/arm/mach-omap2/board-omap3-dt.c >> > >> > diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig >> > index 19d5891..174f6d1 100644 >> > --- a/arch/arm/mach-omap2/Kconfig >> > +++ b/arch/arm/mach-omap2/Kconfig >> > @@ -302,6 +302,18 @@ config MACH_OMAP_3630SDP >> > default y >> > select OMAP_PACKAGE_CBP >> > >> > +config MACH_OMAP3_DT >> > + bool "Generic OMAP3 board(FDT support)" >> > + depends on ARCH_OMAP3 >> > + select OMAP_PACKAGE_CBB >> > + select USE_OF >> > + select PROC_DEVICETREE >> >> Don't select PROC_DEVICETREE > ok >> >> > + >> > + help >> > + Support for generic TI OMAP3 boards using Flattened Device Tree. >> > + Say Y here to enable OMAP3 device tree support >> > + More information at Documentation/devicetree >> > + >> > config MACH_TI8168EVM >> > bool "TI8168 Evaluation Module" >> > depends on SOC_OMAPTI816X >> > diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile >> > index b148077..86e66f7 100644 >> > --- a/arch/arm/mach-omap2/Makefile >> > +++ b/arch/arm/mach-omap2/Makefile >> > @@ -178,6 +178,8 @@ obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o >> > obj-$(CONFIG_MACH_OMAP_2430SDP) += board-2430sdp.o \ >> > hsmmc.o >> > obj-$(CONFIG_MACH_OMAP_APOLLON) += board-apollon.o >> > +obj-$(CONFIG_MACH_OMAP3_DT) += board-omap3-dt.o \ >> > + hsmmc.o >> > obj-$(CONFIG_MACH_OMAP3_BEAGLE) += board-omap3beagle.o \ >> > hsmmc.o >> >> This is an odd construct. Tony, why does each board add hsmmc to the >> oby-y variable instead of it having its own kconfig symbol? >> >> > +static void __init omap3_init(void) >> > +{ >> > + struct device_node *node; >> > + >> > + node = of_find_matching_node_by_address(NULL, omap3_dt_intc_match, >> > + OMAP34XX_IC_BASE); >> > + if (node) >> > + irq_domain_add_simple(node, 0); >> > + >> > + omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); >> > + omap3_beagle_init_rev(); >> > + omap3_beagle_i2c_init(); >> > + platform_add_devices(omap3_beagle_devices, >> > + ARRAY_SIZE(omap3_beagle_devices)); >> > + omap_display_init(&beagle_dss_data); >> > + omap_serial_init(); >> > + >> > + omap_mux_init_gpio(170, OMAP_PIN_INPUT); >> > + /* REVISIT leave DVI powered down until it's needed ... */ >> > + gpio_request_one(170, GPIOF_OUT_INIT_HIGH, "DVI_nPD"); >> > + >> > + usb_musb_init(NULL); >> > + usbhs_init(&usbhs_bdata); >> > + omap_nand_flash_init(NAND_BUSWIDTH_16, omap3beagle_nand_partitions, >> > + ARRAY_SIZE(omap3beagle_nand_partitions)); >> > + >> > + /* Ensure msecure is mux'd to be able to set the RTC. */ >> > + omap_mux_init_signal("sys_drm_msecure", OMAP_PIN_OFF_OUTPUT_HIGH); >> > + >> > + /* Ensure SDRC pins are mux'd for self-refresh */ >> > + omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); >> > + omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT); >> > + >> > + beagle_display_init(); >> > + beagle_opp_init(); >> > + of_platform_populate(NULL, omap_dt_match_table, NULL, NULL); >> >> Hmmm, I don't think this will work for OMAP because it will not create >> the i2c bus as an omap_device. It will only be a plane >> platform_deevice. You'll need to have a hook in >> of_platform_populate() to create devices the way omap3 infrastructure >> expects. >> > This dependency is mentioned in patch series. Since you pointed out this issue, I would like to propose following approach for hooking up omap hwmod· framework with dt. Though, the current approach focus only on i2c driver, it can be extended and generalized as it evolves with other board and driver cleanup activities. The following changes are not tested and also not compiled, it is only proposal I am thinking to implement. Let me know if you see any serious issues with the approach. * of_platform_bus_create() - Create a device for a node and its children. * @bus: device node of the bus to instantiate @@ -593,6 +642,11 @@ static int of_platform_bus_create(struct device_node *bus, return 0; } + if (of_device_is_compatible(bus, "ti,omap3-i2c")) { + of_omap_i2c_device_create(bus, bus_id, platform_data, parent); + return 0; + } + dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent); if (!dev || !of_match_node(matches, bus)) return 0; -M diff --git a/drivers/of/platform.c b/drivers/of/platform.c index c1773456..104ef31 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -457,6 +457,8 @@ void of_platform_prepare(struct device_node *root, } } + + #ifdef CONFIG_ARM_AMBA static struct amba_device *of_amba_device_create(struct device_node *node, const char *bus_id, @@ -537,13 +539,60 @@ static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *l continue; if (res.start != lookup->phys_addr) continue; - pr_debug("%s: devname=%s\n", np->full_name, lookup->name); + printk("%s: devname=%s\n", np->full_name, lookup->name); return lookup; } } return NULL; } +static struct omap_device *of_omap_i2c_device_create(struct device_node *node, + const char *bus_id, + void *platform_data, + struct device *parent) +{ + struct platform_device *pdev; + struct i2c_board_info *i2c_board_info; + u8 id; + + printk("Creating omap i2c device %s\n", node->full_name); + + if (!of_device_is_available(node)) + return NULL; + + id = simple_strtol(bus_id, NULL, 0); + pdev = kzalloc(sizeof(*pdev), GFP_KERNEL); + pdev->dev.of_node = of_node_get(node); + if (!pdev->dev.of_node) { + speed = 100; + } else { + u32 prop; + if (!of_property_read_u32(pdev->dev.of_node, "clock-frequency", + &prop)) + speed = prop/100; + else + speed = 100; + } + printk("%s : speed->%d\n",__func__, speed); + + for_each_child_of_node(bus, child) { + u32 prop; + + printk(" create child: %s\n", child->full_name); + i2c_board_info = kzalloc(sizeof(*i2c_board_info), GFP_KERNEL); + if (!of_property_read_u32(pdev->dev.of_node, "reg", + &prop)) + i2c_board_info->addr = prop; + if (!of_property_read_u32(pdev->dev.of_node, "interrupts", + &prop)) + i2c_board_info->irq = prop; + i2c_board_info->platform_data = platform_data; + strncpy(i2c_board_info->type, child->name, + sizeof(i2c_board_info->type)); + } + omap_register_i2c_bus(id, speed, i2c_board_info, 1); +} + /**