From patchwork Sat Mar 26 11:19:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommaso Merciai X-Patchwork-Id: 1609682 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=aRoAsz0H; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4KQc2T0W2Kz9sG1 for ; Sat, 26 Mar 2022 22:20:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 53598841E1; Sat, 26 Mar 2022 12:19:48 +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="aRoAsz0H"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6B12184179; Sat, 26 Mar 2022 12:19:28 +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-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 8B93584189 for ; Sat, 26 Mar 2022 12:19:25 +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-x535.google.com with SMTP id a17so11819810edm.9 for ; Sat, 26 Mar 2022 04:19:25 -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=tY2PVU48p21T7k/LVk2qHbO52mH7cugRJkG/lOkkkrs=; b=aRoAsz0HOnO3V7mdNA6dXO6RLV4gQL2S0oeEIJKnUiflebBwmZC171lpNQgwjL0eXq V4zS1q5lyZ5vcYZUzMc1xiuxIf2hrc5FmrMPMVJxtjDz9APdWltvz06QER2QVlZTngzd Hf/SNF1jbYLNECu6eGxFFlY5KIGN/lI5KFfpw= 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=tY2PVU48p21T7k/LVk2qHbO52mH7cugRJkG/lOkkkrs=; b=DmeZFczKZiMv1qjaqI+z2E5nDpiXbzOBKxQxpSzmZSX+EDVLK2knIxRvLU3a1urHKT g+r2senH9QUtc6ogJdKDFhRTjbvDenAMMWfZFcJSWcJbs+u1NlPKW7uvx5c44jJuAlVA YccY4u+rtXFIShr6yMO5gkfsHh5LZMlV1zmUtEsdAo0nXeGvD5cBfmu0NvtBbdJqhrn1 YiFJefWlFWlBCyANL/UKTaG7acXt3GatOAz0/sPwsEJs3A7Ro8tmlYS2Z0jD0QDPc/UE EXSvYao/Uw4NPsy0e0lyMCHmG49UUkYnflrfF5TAl6ekQrM29STIfZIOK3v02/C2sc7M 6qbg== X-Gm-Message-State: AOAM532c+NTSvkQEiDK5+brTCM5RHE//YN9J9a1ylJJIUH120vHNu+r/ iUtEnZJnBBximx5JgVSsAYZMYg== X-Google-Smtp-Source: ABdhPJwOgOpeR8itiAXuG/eKJx53+M5RVFv2BZR80FVitnPg2YToBqbF7uApB3H1q51p6tjXbO1B5g== X-Received: by 2002:a05:6402:23a8:b0:419:31c1:d141 with SMTP id j40-20020a05640223a800b0041931c1d141mr3886095eda.33.1648293565163; Sat, 26 Mar 2022 04:19:25 -0700 (PDT) Received: from tom-ThinkPad-T14s-Gen-2i.station (net-188-217-56-61.cust.vodafonedsl.it. [188.217.56.61]) by smtp.gmail.com with ESMTPSA id c14-20020a170906340e00b006ce98f2581asm3371543ejb.205.2022.03.26.04.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 04:19:24 -0700 (PDT) From: Tommaso Merciai To: Cc: tommaso.merciai@amarulasolutions.com, alb3rto.merciai@gmail.com, Peng Fan , Ye Li , Alice Guo , Andrey Zhizhikin , u-boot@lists.denx.de Subject: [PATCH v5 7/9] driver: pwm: pwm-imx: separe dm from non dm implementation Date: Sat, 26 Mar 2022 12:19:08 +0100 Message-Id: <20220326111911.13720-8-tommaso.merciai@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326111911.13720-1-tommaso.merciai@amarulasolutions.com> References: <20220326111911.13720-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 1d656e726f..9b8a8c189d 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;