From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933917AbbCPRBi (ORCPT ); Mon, 16 Mar 2015 13:01:38 -0400 Received: from opensource.wolfsonmicro.com ([80.75.67.52]:55619 "EHLO opensource.wolfsonmicro.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933173AbbCPRB3 (ORCPT ); Mon, 16 Mar 2015 13:01:29 -0400 From: Charles Keepax To: lee.jones@linaro.org, broonie@kernel.org Cc: sameo@linux.intel.com, lgirdwood@gmail.com, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] mfd: arizona: Factor out SYSCLK enable from wm5102 hardware patch Date: Mon, 16 Mar 2015 16:58:40 +0000 Message-Id: <1426525124-12317-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> X-Mailer: git-send-email 1.7.2.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wm5102 applies a custom hardware boot sequence, for this the SYSCLK needs to be enabled. This patch factors out the code that enables SYSCLK for this sequence such that it can be used for other boot time operations that require SYSCLK. Signed-off-by: Charles Keepax --- drivers/mfd/arizona-core.c | 48 ++++++++++++++++++++++++++++--------------- 1 files changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 6ca6dfa..ef1f8aa 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -250,7 +250,8 @@ static int arizona_wait_for_boot(struct arizona *arizona) return ret; } -static int arizona_apply_hardware_patch(struct arizona* arizona) +static int arizona_exec_with_sysclk(struct arizona *arizona, + int (*exec)(struct arizona *)) { unsigned int fll, sysclk; int ret, err; @@ -292,23 +293,8 @@ static int arizona_apply_hardware_patch(struct arizona* arizona) goto err_fll; } - /* Start the write sequencer and wait for it to finish */ - ret = regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0, - ARIZONA_WSEQ_ENA | ARIZONA_WSEQ_START | 160); - if (ret != 0) { - dev_err(arizona->dev, "Failed to start write sequencer: %d\n", - ret); - goto err_sysclk; - } - ret = arizona_poll_reg(arizona, 5, ARIZONA_WRITE_SEQUENCER_CTRL_1, - ARIZONA_WSEQ_BUSY, 0); - if (ret != 0) { - regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0, - ARIZONA_WSEQ_ABORT); - ret = -ETIMEDOUT; - } + ret = exec(arizona); -err_sysclk: err = regmap_write(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, sysclk); if (err != 0) { dev_err(arizona->dev, @@ -330,6 +316,34 @@ err_fll: return err; } +static int arizona_hardware_patch_wseq(struct arizona *arizona) +{ + int ret; + + /* Start the write sequencer and wait for it to finish */ + ret = regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0, + ARIZONA_WSEQ_ENA | ARIZONA_WSEQ_START | 160); + if (ret != 0) { + dev_err(arizona->dev, "Failed to start write sequencer: %d\n", + ret); + return ret; + } + ret = arizona_poll_reg(arizona, 5, ARIZONA_WRITE_SEQUENCER_CTRL_1, + ARIZONA_WSEQ_BUSY, 0); + if (ret != 0) { + regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0, + ARIZONA_WSEQ_ABORT); + ret = -ETIMEDOUT; + } + + return ret; +} + +static inline int arizona_apply_hardware_patch(struct arizona *arizona) +{ + return arizona_exec_with_sysclk(arizona, arizona_hardware_patch_wseq); +} + #ifdef CONFIG_PM static int arizona_runtime_resume(struct device *dev) { -- 1.7.2.5