From patchwork Thu Nov 14 09:29:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 21493 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B39AA23FBC for ; Thu, 14 Nov 2013 09:29:39 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id f11sf3654684qae.9 for ; Thu, 14 Nov 2013 01:29:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=c9JSJe0kD7zem6qpjmgQqNHkre2EiDFIoRO2vxUmjjg=; b=O95FiJReT/xhOIs536ag4tAAaYCfeDPx9FURZCnhm641WMxzG9AhyUc0ravFOBu4pf 53VgYwjUPOCD5UfC+zRq36iQjfKVvuTHjhdRB0Idv3wgpvRlDVj6PTHGnK8rVnrr91H/ PEdTqkCeiKv/eXpclOPMLgwyWPIMcxsCRPWzjPTcb3G9HSMYMP7AX8xZCiYtFPqLRwZT 1607Xg+X/S+BMf5ECqdUpS+KOWfR6J6/maEpQRHLVY4WCQiz85ht5RyNtSTj1NTYo/9h RnDRC6NO1PPYpVr1jojIbCYJPcsOt3yeGnnX14z1FuBCYn6Omzv1iXZZ+5b89KUVpLha BS5Q== X-Gm-Message-State: ALoCoQlpiSREv/50rw7z4i5Bowj8A6YsMDvnyU+sROwHMbxS0qsj39PjtbqjICCnuHE9vYbU/RLi X-Received: by 10.59.4.176 with SMTP id cf16mr198209ved.10.1384421379006; Thu, 14 Nov 2013 01:29:39 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.3.106 with SMTP id b10ls881365qeb.40.gmail; Thu, 14 Nov 2013 01:29:38 -0800 (PST) X-Received: by 10.58.241.169 with SMTP id wj9mr140556vec.69.1384421378917; Thu, 14 Nov 2013 01:29:38 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id td8si11465327vdc.79.2013.11.14.01.29.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Nov 2013 01:29:38 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id cz12so1543882veb.2 for ; Thu, 14 Nov 2013 01:29:38 -0800 (PST) X-Received: by 10.52.116.74 with SMTP id ju10mr167610vdb.20.1384421378802; Thu, 14 Nov 2013 01:29:38 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp302025vcz; Thu, 14 Nov 2013 01:29:38 -0800 (PST) X-Received: by 10.182.103.133 with SMTP id fw5mr362811obb.43.1384421378234; Thu, 14 Nov 2013 01:29:38 -0800 (PST) Received: from mail-ob0-f169.google.com (mail-ob0-f169.google.com [209.85.214.169]) by mx.google.com with ESMTPS id w10si29081045obo.121.2013.11.14.01.29.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Nov 2013 01:29:38 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.169 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.214.169; Received: by mail-ob0-f169.google.com with SMTP id wn1so1897522obc.14 for ; Thu, 14 Nov 2013 01:29:38 -0800 (PST) X-Received: by 10.60.130.163 with SMTP id of3mr405513oeb.96.1384421377949; Thu, 14 Nov 2013 01:29:37 -0800 (PST) Received: from localhost.localdomain (cpc15-aztw25-2-0-cust493.aztw.cable.virginm.net. [92.233.57.238]) by mx.google.com with ESMTPSA id rr6sm5545348oeb.0.2013.11.14.01.29.36 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Nov 2013 01:29:37 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sameo@linux.intel.com, micky_ching@realsil.com.cn Cc: linus.walleij@linaro.org, Lee Jones Subject: [PATCH 2/4] mfd: rtsx: Generify the switch voltage routine Date: Thu, 14 Nov 2013 09:29:13 +0000 Message-Id: <1384421355-4434-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1384421355-4434-1-git-send-email-lee.jones@linaro.org> References: <1384421355-4434-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Other, upcoming devices will want to change the shift value when using the switch voltage call-back routine. In this patch we will ensure that unnecessary code duplication shall not occur. Signed-off-by: Lee Jones --- drivers/mfd/rtl8411.c | 12 ++++++++---- drivers/mfd/rtsx_pcr.c | 3 ++- include/linux/mfd/rtsx_pci.h | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c index 92e9bf6..9bba4e2 100644 --- a/drivers/mfd/rtl8411.c +++ b/drivers/mfd/rtl8411.c @@ -191,24 +191,25 @@ static int rtl8411_card_power_off(struct rtsx_pcr *pcr, int card) BPP_LDO_POWB, BPP_LDO_SUSPEND); } -static int rtl8411_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) +static int rtl84xx_switch_output_voltage(struct rtsx_pcr *pcr, + u8 voltage, int shift) { u8 mask, val; int err; - mask = (BPP_REG_TUNED18 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_MASK; + mask = (BPP_REG_TUNED18 << shift) | BPP_PAD_MASK; if (voltage == OUTPUT_3V3) { err = rtsx_pci_write_register(pcr, SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_3v3); if (err < 0) return err; - val = (BPP_ASIC_3V3 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_3V3; + val = (BPP_ASIC_3V3 << shift) | BPP_PAD_3V3; } else if (voltage == OUTPUT_1V8) { err = rtsx_pci_write_register(pcr, SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_1v8); if (err < 0) return err; - val = (BPP_ASIC_1V8 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_1V8; + val = (BPP_ASIC_1V8 << shift) | BPP_PAD_1V8; } else { return -EINVAL; } @@ -426,6 +427,7 @@ static struct pcr_ops rtl84xx_pcr_generic_ops = { .card_power_on = rtl8411_card_power_on, .card_power_off = rtl8411_card_power_off, .switch_output_voltage = rtl84xx_switch_output_voltage, + .voltage_reg_shift = 0, /* Dynamic */ .cd_deglitch = rtl8411_cd_deglitch, .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n, .force_power_down = rtl8411_force_power_down, @@ -455,6 +457,7 @@ void rtl8411_init_params(struct rtsx_pcr *pcr) /* Device Ops variation. */ pcr->ops->fetch_vendor_settings = rtl8411_fetch_vendor_settings; pcr->ops->extra_init_hw = rtl8411_extra_init_hw; + pcr->ops->voltage_reg_shift = BPP_TUNED18_SHIFT_8411; pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10); @@ -469,6 +472,7 @@ void rtl8411b_init_params(struct rtsx_pcr *pcr) /* Device Ops variation. */ pcr->ops->fetch_vendor_settings = rtl8411b_fetch_vendor_settings; pcr->ops->extra_init_hw = rtl8411b_extra_init_hw; + pcr->ops->voltage_reg_shift = BPP_TUNED18_SHIFT_8411; pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14); pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10); diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c index e6ae772..f41ee8f 100644 --- a/drivers/mfd/rtsx_pcr.c +++ b/drivers/mfd/rtsx_pcr.c @@ -734,7 +734,8 @@ EXPORT_SYMBOL_GPL(rtsx_pci_card_exclusive_check); int rtsx_pci_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) { if (pcr->ops->switch_output_voltage) - return pcr->ops->switch_output_voltage(pcr, voltage); + return pcr->ops->switch_output_voltage(pcr, voltage, + pcr->ops->voltage_reg_shift); return 0; } diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h index f5f3ffc..5afc448 100644 --- a/include/linux/mfd/rtsx_pci.h +++ b/include/linux/mfd/rtsx_pci.h @@ -774,11 +774,12 @@ struct pcr_ops { int (*card_power_on)(struct rtsx_pcr *pcr, int card); int (*card_power_off)(struct rtsx_pcr *pcr, int card); int (*switch_output_voltage)(struct rtsx_pcr *pcr, - u8 voltage); + u8 voltage, int shift); unsigned int (*cd_deglitch)(struct rtsx_pcr *pcr); int (*conv_clk_and_div_n)(int clk, int dir); void (*fetch_vendor_settings)(struct rtsx_pcr *pcr); void (*force_power_down)(struct rtsx_pcr *pcr, u8 pm_state); + int voltage_reg_shift; }; enum PDEV_STAT {PDEV_STAT_IDLE, PDEV_STAT_RUN};