From patchwork Thu Aug 4 09:59:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 655719 X-Patchwork-Delegate: daniel.schwierzeck@googlemail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3s4lm71n8bz9stY for ; Thu, 4 Aug 2016 19:59:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3DDB74BA0E; Thu, 4 Aug 2016 11:59:49 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7_rRVqSZqEcS; Thu, 4 Aug 2016 11:59:49 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 891A64B94B; Thu, 4 Aug 2016 11:59:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 21E144B68A for ; Thu, 4 Aug 2016 11:59:46 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hiGCM-Z1eRdp for ; Thu, 4 Aug 2016 11:59:46 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailapp01.imgtec.com (mailapp01.imgtec.com [195.59.15.196]) by theia.denx.de (Postfix) with ESMTP id 93DA64B99D for ; Thu, 4 Aug 2016 11:59:40 +0200 (CEST) Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id E7BFB27F4FAB7; Thu, 4 Aug 2016 10:59:25 +0100 (IST) Received: from [127.0.0.1] (10.100.200.86) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server (TLS) id 14.3.294.0; Thu, 4 Aug 2016 10:59:28 +0100 To: References: <20160801100705.4143-1-paul.burton@imgtec.com> <20160801100705.4143-2-paul.burton@imgtec.com> From: Paul Burton Message-ID: Date: Thu, 4 Aug 2016 10:59:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.100.200.86] Cc: Marek Vasut , u-boot@lists.denx.de, Michal Simek Subject: Re: [U-Boot] [PATCH v4 01/11] serial: ns16550: Support clocks via phandle X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" On 04/08/16 10:50, Michal Simek wrote: >> @@ -352,6 +353,8 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev) >> { >> struct ns16550_platdata *plat = dev->platdata; >> fdt_addr_t addr; >> + struct clk clk; >> + int err; >> >> /* try Processor Local Bus device first */ >> addr = dev_get_addr(dev); >> @@ -397,9 +400,19 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev) >> "reg-offset", 0); >> plat->reg_shift = fdtdec_get_int(gd->fdt_blob, dev->of_offset, >> "reg-shift", 0); >> - plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, >> - "clock-frequency", >> - CONFIG_SYS_NS16550_CLK); >> + >> + err = clk_get_by_index(dev, 0, &clk); >> + if (!err) { >> + plat->clock = clk_get_rate(&clk); >> + } else if (err != -ENODEV) { >> + debug("ns16550 failed to get clock\n"); >> + return err; >> + } >> + >> + if (!plat->clock) >> + plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, >> + "clock-frequency", >> + CONFIG_SYS_NS16550_CLK); >> if (!plat->clock) { >> debug("ns16550 clock not defined\n"); >> return -EINVAL; >> > > > NACK. It is missing dependency on clk uclass which is not enabled by > default on Microblaze. Maybe also on others. You should add some ifs around. > > Thanks, > Michal I'm not sure #ifdef'ing in this code is the nicest solution. How about if we allow -ENOSYS through the error handling above like -ENODEV, and provide the dummy clk_get_by_* implementations when CONFIG_CLK is disabled? As in: *clk); Thanks, Paul diff --git a/include/clk.h b/include/clk.h index 161bc28..328f364 100644 --- a/include/clk.h +++ b/include/clk.h @@ -59,7 +59,7 @@ struct clk { unsigned long id; }; -#if CONFIG_IS_ENABLED(OF_CONTROL) +#if CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(CONFIG_CLK) struct phandle_2_cell; int clk_get_by_index_platdata(struct udevice *dev, int index, struct phandle_2_cell *cells, struct clk