From patchwork Fri Dec 14 16:45:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 1879801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 45AC940079 for ; Fri, 14 Dec 2012 16:50:29 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TjYPQ-0003BD-GX; Fri, 14 Dec 2012 16:46:48 +0000 Received: from moutng.kundenserver.de ([212.227.17.8]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TjYOK-0002VH-13 for linux-arm-kernel@lists.infradead.org; Fri, 14 Dec 2012 16:45:41 +0000 Received: from axis700.grange (dslb-094-220-155-091.pools.arcor-ip.net [94.220.155.91]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0LrXNx-1T0Hsu0DBF-013ky6; Fri, 14 Dec 2012 17:45:33 +0100 Received: from 6a.grange (6a.grange [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id 7E44240BDA; Fri, 14 Dec 2012 17:45:32 +0100 (CET) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1TjYOC-0001uD-1G; Fri, 14 Dec 2012 17:45:32 +0100 From: Guennadi Liakhovetski To: linux-sh@vger.kernel.org Subject: [PATCH 6/7] ARM: mackerel: support booting with or without DT Date: Fri, 14 Dec 2012 17:45:30 +0100 Message-Id: <1355503531-7276-7-git-send-email-g.liakhovetski@gmx.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1355503531-7276-1-git-send-email-g.liakhovetski@gmx.de> References: <1355503531-7276-1-git-send-email-g.liakhovetski@gmx.de> X-Provags-ID: V02:K0:xAvUjHOxIbLdjLvYkZRb03NxpOLAI7P/i//+vgtfKIX loGG2/q0Qn5IA5XJHF3HGGj/4N17dNfmHr0DrHjdfZwmkZ1wh6 1vr8SOSvcp168Sz+2/I8cO3GBP0pXjrPXnZaMxq/ibXPpDbkUg mAJuPGDs+kkRD4bjILPwvg2GAfxrITzHawr8X5YQY0aJJhezjY kx45DHbDTgg4quh+7DpiX8iSZGoruFDDD/H7uRQNLCPaTaI8Ki gfKk7RjE3DTkhDows5CzGKDpJbHBRlWZphJv1BUlZD8EYx9loa tYU2Nfcvew0l7sAByVCJxm7y6t0078gikaxANEKRE++++SM4WE Tg5ZwGXvw2iJrdrm8PPlkJfjdlqE7ldcz62WYSPQVF6/0LB0s9 RVTnzQhwonJ8Q== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121214_114540_452970_04A0F7F6 X-CRM114-Status: GOOD ( 16.51 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.17.8 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (g.liakhovetski[at]gmx.de) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: devicetree-discuss@lists.ozlabs.org, Simon Horman , Magnus Damm , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch adds dynamic switching to booting either with or without DT. So far only a part of the board initialisation can be done via DT. Devices, that still need platform data are kept that way. Devices, that can be initialised from DT will not be supplied from the platform data, if a DT image is detected. Signed-off-by: Guennadi Liakhovetski --- arch/arm/mach-shmobile/board-mackerel.c | 84 ++++++++++++++++++++++++------- 1 files changed, 66 insertions(+), 18 deletions(-) diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c index 39b8f2e..a6358c9 100644 --- a/arch/arm/mach-shmobile/board-mackerel.c +++ b/arch/arm/mach-shmobile/board-mackerel.c @@ -1326,7 +1326,6 @@ static struct platform_device mackerel_camera = { static struct platform_device *mackerel_devices[] __initdata = { &nor_flash_device, - &smc911x_device, &lcdc_device, &usbhs0_device, &usbhs1_device, @@ -1335,17 +1334,21 @@ static struct platform_device *mackerel_devices[] __initdata = { &fsi_ak4643_device, &fsi_hdmi_device, &nand_flash_device, + &ceu_device, + &mackerel_camera, + &hdmi_device, + &hdmi_lcdc_device, + &meram_device, +}; + +static struct platform_device *mackerel_devices_dt[] __initdata = { + &smc911x_device, &sdhi0_device, #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) &sdhi1_device, #endif &sdhi2_device, &sh_mmcif_device, - &ceu_device, - &mackerel_camera, - &hdmi_device, - &hdmi_lcdc_device, - &meram_device, }; /* Keypad Initialization */ @@ -1404,6 +1407,24 @@ static struct i2c_board_info i2c1_devices[] = { }, }; +static int mackerel_i2c_bus_notify(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct device *dev = data; + + if (action != BUS_NOTIFY_ADD_DEVICE || + strcmp(dev_name(dev->parent), "fff20000.i2c")) + return NOTIFY_DONE; + + i2c_new_device(to_i2c_adapter(dev), &i2c0_devices[1]); + + return NOTIFY_OK; +} + +static struct notifier_block mackerel_i2c_notifier = { + .notifier_call = mackerel_i2c_bus_notify, +}; + #define GPIO_PORT9CR IOMEM(0xE6051009) #define GPIO_PORT10CR IOMEM(0xE605100A) #define GPIO_PORT167CR IOMEM(0xE60520A7) @@ -1420,22 +1441,26 @@ static void __init mackerel_init(void) { "A3SP", &usbhs0_device, }, { "A3SP", &usbhs1_device, }, { "A3SP", &nand_flash_device, }, + { "A4R", &ceu_device, }, + }; + struct pm_domain_device domain_devices_dt[] = { { "A3SP", &sh_mmcif_device, }, { "A3SP", &sdhi0_device, }, #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) { "A3SP", &sdhi1_device, }, #endif { "A3SP", &sdhi2_device, }, - { "A4R", &ceu_device, }, }; u32 srcr4; struct clk *clk; - regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers, - ARRAY_SIZE(fixed1v8_power_consumers), 1800000); - regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers, - ARRAY_SIZE(fixed3v3_power_consumers), 3300000); - regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies)); + if (!of_have_populated_dt()) { + regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers, + ARRAY_SIZE(fixed1v8_power_consumers), 1800000); + regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers, + ARRAY_SIZE(fixed3v3_power_consumers), 3300000); + regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies)); + } /* External clock source */ clk_set_rate(&sh7372_dv_clki_clk, 27000000); @@ -1633,22 +1658,35 @@ static void __init mackerel_init(void) udelay(50); __raw_writel(srcr4 & ~(1 << 13), SRCR4); - i2c_register_board_info(0, i2c0_devices, - ARRAY_SIZE(i2c0_devices)); - i2c_register_board_info(1, i2c1_devices, - ARRAY_SIZE(i2c1_devices)); + if (!of_have_populated_dt()) { + i2c_register_board_info(0, i2c0_devices, + ARRAY_SIZE(i2c0_devices)); + i2c_register_board_info(1, i2c1_devices, + ARRAY_SIZE(i2c1_devices)); + } else { + bus_register_notifier(&i2c_bus_type, + &mackerel_i2c_notifier); + } sh7372_add_standard_devices(); platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); + if (!of_have_populated_dt()) + platform_add_devices(mackerel_devices_dt, + ARRAY_SIZE(mackerel_devices_dt)); rmobile_add_devices_to_domains(domain_devices, ARRAY_SIZE(domain_devices)); + if (!of_have_populated_dt()) + rmobile_add_devices_to_domains(domain_devices_dt, + ARRAY_SIZE(domain_devices_dt)); hdmi_init_pm_clock(); sh7372_pm_init(); pm_clk_add(&fsi_device.dev, "spu2"); pm_clk_add(&hdmi_lcdc_device.dev, "hdmi"); + + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); } static const char *mackerel_boards_compat_dt[] __initdata = { @@ -1659,10 +1697,20 @@ static const char *mackerel_boards_compat_dt[] __initdata = { DT_MACHINE_START(MACKEREL_DT, "mackerel") .map_io = sh7372_map_io, .init_early = sh7372_add_early_devices, - .init_irq = sh7372_init_irq, + .init_irq = sh7372_init_irq_of, + .handle_irq = shmobile_handle_irq_intc, + .init_machine = mackerel_init, + .init_late = sh7372_pm_init_late, + .timer = &shmobile_timer, + .dt_compat = mackerel_boards_compat_dt, +MACHINE_END + +MACHINE_START(MACKEREL, "mackerel") + .map_io = sh7372_map_io, + .init_early = sh7372_add_early_devices, + .init_irq = sh7372_init_irq_of, .handle_irq = shmobile_handle_irq_intc, .init_machine = mackerel_init, .init_late = sh7372_pm_init_late, .timer = &shmobile_timer, - .dt_compat = mackerel_boards_compat_dt, MACHINE_END