From patchwork Thu Mar 24 14:10:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommaso Merciai X-Patchwork-Id: 1609057 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=pl481KvW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KPRxV2ZCrz9s1l for ; Fri, 25 Mar 2022 01:12:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CDA33840ED; Thu, 24 Mar 2022 15:11:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="pl481KvW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2995F840C1; Thu, 24 Mar 2022 15:11:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2DCED840CD for ; Thu, 24 Mar 2022 15:11:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tommaso.merciai@amarulasolutions.com Received: by mail-ed1-x530.google.com with SMTP id k10so5789781edj.2 for ; Thu, 24 Mar 2022 07:11:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HsLJ/xouM1iFqlvpcECoroevrrWe/Ei1DuDNGon589U=; b=pl481KvW9QPmTxEWL9W9K8O/IxHT8/P6zj6HAZO11VM/LWkvsRNcYcwPVk00Im5GOk rDHluCKQD+SH5LWyeSlmYsT361NfLgBtpnip1HpQ0ZEnBNPp1TgKeH38RYm1YkOiNO2j faby6fPIHpSrpk7PI6ewMxIXUD39LbfVJ29Ek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HsLJ/xouM1iFqlvpcECoroevrrWe/Ei1DuDNGon589U=; b=tjnKh1bjuXOniOiL3KPh1fXktW7Qb+NJ710yZRQRju/1Ka+1q2zMQR4WNltIE13xyM ewCSoInsW6r3KHB0hsHxjqNy82htWmzXzfARQWsDKDfM1eaL/Svxq6Thmmc0ApHr3vfE AhdXNNmd1qEqGt0zxMIFvkBW9OSIDTgv4r8NHs2hAB1w6VT1tdBL9bS+oZN4c4qbAqCx cIh4F+1B4ciVQSxQOwN+55ermekHnY3uwMZpxX9JtHAdx0sZr0qkssiNqE5V9fSyklpb 6nuIaTceHEi8gja77fDtvaiYMsvRmR5h8vJLT9U/OTG/hQSyKoOPbIgthcq85gyjbBvv MGqg== X-Gm-Message-State: AOAM5328EeAAJ/HkgtWBc+eZJNBLdoaRBM1VTh70r4q4uC2TFZfJPzy3 vaWkmxcHdjh2X85vsv6noq6sng== X-Google-Smtp-Source: ABdhPJyC9A7KbSHzq/tYPrs0ogP1sxkhS8MtRKTBVGpIJmMPFVW6PcKKHAcDbSgNWue9s1rFUM2Wxw== X-Received: by 2002:a05:6402:1e8b:b0:3da:58e6:9a09 with SMTP id f11-20020a0564021e8b00b003da58e69a09mr6837908edf.155.1648131070799; Thu, 24 Mar 2022 07:11:10 -0700 (PDT) Received: from tom-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-0-195-19.business.telecomitalia.it. [79.0.195.19]) by smtp.gmail.com with ESMTPSA id s15-20020a170906778f00b006df84c19995sm1209355ejm.224.2022.03.24.07.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 07:11:10 -0700 (PDT) From: Tommaso Merciai To: Cc: tommaso.merciai@amarulasolutions.com, alb3rto.merciai@gmail.com, Peng Fan , Alice Guo , Ye Li , Andrey Zhizhikin , u-boot@lists.denx.de Subject: [PATCH v3 7/9] driver: pwm: pwm-imx: separe dm from non dm implementation Date: Thu, 24 Mar 2022 15:10:50 +0100 Message-Id: <20220324141052.16378-8-tommaso.merciai@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220324141052.16378-1-tommaso.merciai@amarulasolutions.com> References: <20220324141052.16378-1-tommaso.merciai@amarulasolutions.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Separe dm implementation from non dm implementation of pwm-imx driver using CONFIG_DM_PWM Signed-off-by: Tommaso Merciai --- drivers/pwm/pwm-imx.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c index c683909b2c..52212588ab 100644 --- a/drivers/pwm/pwm-imx.c +++ b/drivers/pwm/pwm-imx.c @@ -13,17 +13,6 @@ #include #include #include - -int pwm_init(int pwm_id, int div, int invert) -{ - struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id); - - if (!pwm) - return -1; - - writel(0, &pwm->ir); - return 0; -} #include int pwm_config_internal(struct pwm_regs *pwm, unsigned long period_cycles, @@ -44,6 +33,7 @@ int pwm_config_internal(struct pwm_regs *pwm, unsigned long period_cycles, return 0; } +#ifndef CONFIG_DM_PWM /* pwm_id from 0..7 */ struct pwm_regs *pwm_id_to_reg(int pwm_id) { @@ -110,6 +100,17 @@ int pwm_imx_get_parms(int period_ns, int duty_ns, unsigned long *period_c, return 0; } +int pwm_init(int pwm_id, int div, int invert) +{ + struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id); + + if (!pwm) + return -1; + + writel(0, &pwm->ir); + return 0; +} + int pwm_config(int pwm_id, int duty_ns, int period_ns) { struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id); @@ -145,7 +146,7 @@ void pwm_disable(int pwm_id) clrbits_le32(&pwm->cr, PWMCR_EN); } -#if defined(CONFIG_DM_PWM) +#else struct imx_pwm_priv { struct pwm_regs *regs; bool invert;