Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8337160ybn; Tue, 1 Oct 2019 06:47:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiWLfB86X9wsyUIMHea2vLND0RJ9PKGOmUnWQy5nXVRa4Ueu/+1ldRj1BNlcc3LTvTZpTT X-Received: by 2002:a17:906:c79a:: with SMTP id cw26mr23870638ejb.265.1569937673029; Tue, 01 Oct 2019 06:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569937673; cv=none; d=google.com; s=arc-20160816; b=xXl03ZncXv5YZRDsFrX/PQxl8i9AAIHSM1cI9lCEf5FNV3oX9GELJrO2UJJX1HOo37 TxmmuUN/9gmk9NQIEHcMV+KYkNCvukSfkEgym2OqJsbfkLd7Kgf1yJbLu1US3x3psvux PNjOOP4LeEdMRX2CAQSlgrUxdSwdzFoIx3MlF48RZ+0qCLQBGOeRiDapkPvN9qyecmtO 5Jw2M76FvugZjApvn8pQfOoYYtVl8PRHguLUX/zzZGleq7ECXSGfJJeKOJLvfD7aoJw+ Qhy6ITQ1b6/JQLWRy2w/sDEeN93InlrkcVvpTKxVZdvgEt9OJgLGvxfnqzdSEi4JRUqf RjSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=FCRXcxlBOfNZdlMdGggkY99dkVqafYnC8FQDk3CxLno=; b=b7QEJ7XAWd3re4zFYLG+MqdZZHapQZDw6RSapAyXbyZNdYO+06p9mke6tMOVERt2i4 APHuNh4we2TeHm8NpLuW/11sEZHOA4uoYOBWBJKk/Q1zkveADSO0Dl88SmyN7E3HT+r7 JM1BmSe/HKd+Ju9LWLL3CcaM2eswGqlSv2YkRj7CV6StPVrxeOVvqq07o901NlHAMBqw MT92gRjUfkn2sYh1i7Cjkk7LmLeQ9Ox/CX99GxzF8GJ48ktwtZe3gQp4rUR6daTtP2P7 XHkJVykJCcSPeXFhkwBvGcPJywIENCwsQ1kjlg7flEuAhkL36PS3fAv2ineCJnmu81hR Gejg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=EDxAHxLC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y28si9486793edb.162.2019.10.01.06.47.28; Tue, 01 Oct 2019 06:47:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=EDxAHxLC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388697AbfJANqZ (ORCPT + 99 others); Tue, 1 Oct 2019 09:46:25 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:45374 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388170AbfJANqZ (ORCPT ); Tue, 1 Oct 2019 09:46:25 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x91DinhQ023930; Tue, 1 Oct 2019 08:46:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=PODMain02222019; bh=FCRXcxlBOfNZdlMdGggkY99dkVqafYnC8FQDk3CxLno=; b=EDxAHxLCLqE2Tkzyeq7wt0uJepiflurWnxOfZXxypwCYfuQ7rdLDWjJFFznr/WdMpMXx 8ckRU2qNEnMAreSFlu1fsUa1feLIMNU/GRg6VM1E07tJ5GNr42vYxbmLj65Fvp6rSDPm 9olehpNz0fVTRknzYMBKhqwJZ99jYEn+y0nms3KqFCCcqKnKUwVBZqbq+N6uDmZ3CWhr RnIrZU0lkLrkhs9V96rEHNPu8nTKbkvmU3Suqcp3pn8F8BuUOafw1sFSbUSMTWhzZVK1 RaMaTEjCsjpeCHEjs7ZjWAhpyEJbuhXl0Uahu/7dG2N6EHvTNZZYCJTWqGC1cHeCLBgL Sg== Authentication-Results: ppops.net; spf=fail smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 2va4x4ncr9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 01 Oct 2019 08:46:20 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Tue, 1 Oct 2019 14:46:18 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Tue, 1 Oct 2019 14:46:18 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id E88282B3; Tue, 1 Oct 2019 13:46:17 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH v3 3/3] mfd: madera: Add support for requesting the supply clocks Date: Tue, 1 Oct 2019 14:46:17 +0100 Message-ID: <20191001134617.12093-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191001134617.12093-1-ckeepax@opensource.cirrus.com> References: <20191001134617.12093-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-SPF-Result: fail X-Proofpoint-SPF-Record: v=spf1 include:spf-001ae601.pphosted.com include:spf.protection.outlook.com -all X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=939 malwarescore=0 adultscore=0 phishscore=0 impostorscore=0 priorityscore=1501 suspectscore=1 bulkscore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910010125 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the ability to get the clock for each clock input pin of the chip and enable MCLK2 since that is expected to be a permanently enabled 32kHz clock. Signed-off-by: Charles Keepax --- Changes since v2: - Use new devm_clk_bulk_get_optional API Thanks, Charles drivers/mfd/madera-core.c | 27 ++++++++++++++++++++++++++- include/linux/mfd/madera/core.h | 11 +++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c index 29540cbf75934..88d904eb016ea 100644 --- a/drivers/mfd/madera-core.c +++ b/drivers/mfd/madera-core.c @@ -450,6 +450,21 @@ int madera_dev_init(struct madera *madera) sizeof(madera->pdata)); } + madera->mclk[MADERA_MCLK1].id = "mclk1"; + madera->mclk[MADERA_MCLK2].id = "mclk2"; + madera->mclk[MADERA_MCLK3].id = "mclk3"; + + ret = devm_clk_bulk_get_optional(madera->dev, ARRAY_SIZE(madera->mclk), + madera->mclk); + if (ret) { + dev_err(madera->dev, "Failed to get clocks: %d\n", ret); + return ret; + } + + /* Not using devm_clk_get to prevent breakage of existing DTs */ + if (!madera->mclk[MADERA_MCLK2].clk) + dev_warn(madera->dev, "Missing MCLK2, requires 32kHz clock\n"); + ret = madera_get_reset_gpio(madera); if (ret) return ret; @@ -660,13 +675,19 @@ int madera_dev_init(struct madera *madera) } /* Init 32k clock sourced from MCLK2 */ + ret = clk_prepare_enable(madera->mclk[MADERA_MCLK2].clk); + if (ret != 0) { + dev_err(madera->dev, "Failed to enable 32k clock: %d\n", ret); + goto err_reset; + } + ret = regmap_update_bits(madera->regmap, MADERA_CLOCK_32K_1, MADERA_CLK_32K_ENA_MASK | MADERA_CLK_32K_SRC_MASK, MADERA_CLK_32K_ENA | MADERA_32KZ_MCLK2); if (ret) { dev_err(madera->dev, "Failed to init 32k clock: %d\n", ret); - goto err_reset; + goto err_clock; } pm_runtime_set_active(madera->dev); @@ -687,6 +708,8 @@ int madera_dev_init(struct madera *madera) err_pm_runtime: pm_runtime_disable(madera->dev); +err_clock: + clk_disable_unprepare(madera->mclk[MADERA_MCLK2].clk); err_reset: madera_enable_hard_reset(madera); regulator_disable(madera->dcvdd); @@ -713,6 +736,8 @@ int madera_dev_exit(struct madera *madera) */ pm_runtime_disable(madera->dev); + clk_disable_unprepare(madera->mclk[MADERA_MCLK2].clk); + regulator_disable(madera->dcvdd); regulator_put(madera->dcvdd); diff --git a/include/linux/mfd/madera/core.h b/include/linux/mfd/madera/core.h index 7ffa696cce7ca..ad2c138105d4b 100644 --- a/include/linux/mfd/madera/core.h +++ b/include/linux/mfd/madera/core.h @@ -8,6 +8,7 @@ #ifndef MADERA_CORE_H #define MADERA_CORE_H +#include #include #include #include @@ -29,6 +30,13 @@ enum madera_type { CS42L92 = 9, }; +enum { + MADERA_MCLK1, + MADERA_MCLK2, + MADERA_MCLK3, + MADERA_NUM_MCLK +}; + #define MADERA_MAX_CORE_SUPPLIES 2 #define MADERA_MAX_GPIOS 40 @@ -155,6 +163,7 @@ struct snd_soc_dapm_context; * @irq_dev: the irqchip child driver device * @irq_data: pointer to irqchip data for the child irqchip driver * @irq: host irq number from SPI or I2C configuration + * @mclk: Structure holding clock supplies * @out_clamp: indicates output clamp state for each analogue output * @out_shorted: indicates short circuit state for each analogue output * @hp_ena: bitflags of enable state for the headphone outputs @@ -184,6 +193,8 @@ struct madera { struct regmap_irq_chip_data *irq_data; int irq; + struct clk_bulk_data mclk[MADERA_NUM_MCLK]; + unsigned int num_micbias; unsigned int num_childbias[MADERA_MAX_MICBIAS]; -- 2.11.0