Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp14410262rwd; Sat, 24 Jun 2023 19:35:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6GisIVvNnPhBF9OhJgJLquWUKtzWZ4eOpBtmkXpz5nNqimItbQjneL0TTmFUMS3IY4we0D X-Received: by 2002:a05:6358:edd:b0:129:c6d6:ce40 with SMTP id 29-20020a0563580edd00b00129c6d6ce40mr13964983rwh.15.1687660507729; Sat, 24 Jun 2023 19:35:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687660507; cv=none; d=google.com; s=arc-20160816; b=TVlii8+HAJfqq6mBRXcZkgvxZOA19zRfyytYE+cDd9Z/WzpUshvbTmhWIBPn30ATd4 DQ5ZBZRZTUt8n2JaW8ULvZV+tPSuMPJD6WW2hyJTEi92BXw82EnOLkg1VuDOfYfpOlwC y5TtJpJ/S43IjLJHl7oPJlEj3Zq0DMiqmthX7qukqeIhlXM0mSuI+Ybv0KheO4NMKw1d EqIpIxfB+pKnaAtNXl4LUcoxiYIEhmixYk2VOP5S/LQeRiSvCoqMPfwH1t9irFcmvFl/ 9xqtPeJSp8PzmSL+15djbebPi32xLOyrIGbMJyimuA816f5gHQ1h2DkH85DU+d2ZcfJq 8dKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=CYc2BN6zK7Zx/+UJuno9VBqziAEZsaCJXec6fpZQwOI=; fh=vYeKXnkvHcMxn4WVunj8oJO9yg7/BE1K28aBbzmi6lc=; b=lpeqafb4djBP6m0hfmOiPk+HPtAIfAipkBFdC/qCg9JJ6q8IzExVxn4lXUcyLXmw3Y jBFBbzk3AM4nBnJ7AMPpPCZFhXgSvuC/IDb5Eyxj7FnRPbnch3xvHM0ZTfA394boKtZt qNtM8oeK0jMppdvJM6BkDoMaMeujZJ5Hpq5aI8b/sGU8fg9INJtace3Twhdm7020ktRR SVAXQBPv0xQm6+672UDP7zrImAnEZdxjlQw2e3+oI57l8o3fNMoTaLsqlKwXVsUp290T 6qXbW+etOEXXNRNDUlkeQ/wPFbqJ31OWyMviQKUPtX+FjbNcdDKSM5q1ZcpMy5kdx0zv EcGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dw6-20020a056a00368600b006436618b22bsi292076pfb.155.2023.06.24.19.34.56; Sat, 24 Jun 2023 19:35:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230307AbjFYCMC (ORCPT + 99 others); Sat, 24 Jun 2023 22:12:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbjFYCMB (ORCPT ); Sat, 24 Jun 2023 22:12:01 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8125510A; Sat, 24 Jun 2023 19:11:59 -0700 (PDT) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id C77AB24DCFA; Sun, 25 Jun 2023 10:11:45 +0800 (CST) Received: from EXMBX062.cuchost.com (172.16.6.62) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sun, 25 Jun 2023 10:11:45 +0800 Received: from [192.168.125.107] (113.72.146.167) by EXMBX062.cuchost.com (172.16.6.62) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sun, 25 Jun 2023 10:11:44 +0800 Message-ID: <6573a50b-e414-9eba-5a70-f1993c7924c2@starfivetech.com> Date: Sun, 25 Jun 2023 10:11:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v5 2/3] phy: starfive: Add mipi dphy rx support To: Vinod Koul CC: Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Jack Zhu , , , , References: <20230529121503.3544-1-changhuang.liang@starfivetech.com> <20230529121503.3544-3-changhuang.liang@starfivetech.com> Content-Language: en-US From: Changhuang Liang In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [113.72.146.167] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX062.cuchost.com (172.16.6.62) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/6/21 20:30, Vinod Koul wrote: > On 29-05-23, 05:15, Changhuang Liang wrote: >> +static int stf_dphy_configure(struct phy *phy, union phy_configure_opts *opts) >> +{ >> + struct stf_dphy *dphy = phy_get_drvdata(phy); >> + const struct stf_dphy_info *info = dphy->info; >> + int i; >> + >> + for (i = 0; i < ARRAY_SIZE(stf_dphy_init_list); i++) >> + writel(stf_dphy_init_list[i].val, >> + dphy->regs + stf_dphy_init_list[i].addr); >> + >> + writel(FIELD_PREP(STF_DPHY_DA_CDPHY_R100_CTRL0_2D1C_EFUSE_EN, 1) | >> + FIELD_PREP(STF_DPHY_DA_CDPHY_R100_CTRL0_2D1C_EFUSE_IN, 0x1b) | >> + FIELD_PREP(STF_DPHY_DA_CDPHY_R100_CTRL1_2D1C_EFUSE_EN, 1) | >> + FIELD_PREP(STF_DPHY_DA_CDPHY_R100_CTRL1_2D1C_EFUSE_IN, 0x1b), >> + dphy->regs + STF_DPHY_APBCFGSAIF_SYSCFG(0)); >> + >> + writel(FIELD_PREP(STF_DPHY_DATA_BUS16_8, 0) | >> + FIELD_PREP(STF_DPHY_DEBUG_MODE_SEL, 0x5a), >> + dphy->regs + STF_DPHY_APBCFGSAIF_SYSCFG(184)); > > bunch of magic numbers here and previous one..? > magic numbers is "1" "0x1b" "0" "0x5a"? If so, I will move this two registers into stf_dphy_init_list[]. And maybe also have some magic numbers below, I will replace them will macro. >> + >> + writel(FIELD_PREP(STF_DPHY_ENABLE_CLK, 1) | >> + FIELD_PREP(STF_DPHY_ENABLE_CLK1, 1) | >> + FIELD_PREP(STF_DPHY_ENABLE_LAN0, 1) | >> + FIELD_PREP(STF_DPHY_ENABLE_LAN1, 1) | >> + FIELD_PREP(STF_DPHY_ENABLE_LAN2, 1) | >> + FIELD_PREP(STF_DPHY_ENABLE_LAN3, 1) | >> + FIELD_PREP(STF_DPHY_GPI_EN, 0) | >> + FIELD_PREP(STF_DPHY_HS_FREQ_CHANGE_CLK, 0) | >> + FIELD_PREP(STF_DPHY_HS_FREQ_CHANGE_CLK1, 0) | >> + FIELD_PREP(STF_DPHY_LANE_SWAP_CLK, info->maps[0]) | >> + FIELD_PREP(STF_DPHY_LANE_SWAP_CLK1, info->maps[5]) | >> + FIELD_PREP(STF_DPHY_LANE_SWAP_LAN0, info->maps[1]) | >> + FIELD_PREP(STF_DPHY_LANE_SWAP_LAN1, info->maps[2]), >> + dphy->regs + STF_DPHY_APBCFGSAIF_SYSCFG(188)); [...] >> + >> + writel(FIELD_PREP(STF_DPHY_PRECOUNTER_IN_LAN3, 7) | >> + FIELD_PREP(STF_DPHY_RX_1C2C_SEL, 0), >> + dphy->regs + STF_DPHY_APBCFGSAIF_SYSCFG(200)); >> + >> + return 0; >> +} >> + >> +static int stf_dphy_power_on(struct phy *phy) >> +{ >> + struct stf_dphy *dphy = phy_get_drvdata(phy); >> + int ret; >> + >> + pm_runtime_get_sync(dphy->dev); > > no error check? > I will replace pm_runtime_get_sync with pm_runtime_resume_and_get to handle error: ret = pm_runtime_resume_and_get(dphy->dev); if (ret < 0) return ret; >> + >> + ret = regulator_enable(dphy->mipi_0p9); >> + if (ret) >> + return ret; > > should you not drop the pm reference on error here? > I will add pm_runtime_put in this error handle. Thanks for your comments.