public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: micky_ching@realsil.com.cn
Cc: sameo@linux.intel.com, devel@linuxdriverproject.org,
	linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
	rogerable@realtek.com, wei_wang@realsil.com.cn
Subject: Re: [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249
Date: Mon, 6 Oct 2014 22:05:36 +0100	[thread overview]
Message-ID: <20141006210536.GD18035@lee--X1> (raw)
In-Reply-To: <1411023333-1816-1-git-send-email-micky_ching@realsil.com.cn>

On Thu, 18 Sep 2014, micky_ching@realsil.com.cn wrote:

> From: Micky Ching <micky_ching@realsil.com.cn>
> 
> Fix rts5227&5249 failed send buffer cmd after suspend,
> PM_CTRL3 should reset before send any buffer cmd after suspend.
> Otherwise, buffer cmd will failed, this will lead resume fail.
> 
> Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
> ---
>  drivers/mfd/Makefile         |    2 +-
>  drivers/mfd/rts5227.c        |    6 ++++++
>  drivers/mfd/rts5249.c        |    4 ++++
>  drivers/mfd/rtsx_gops.c      |   36 ++++++++++++++++++++++++++++++++++++
>  drivers/mfd/rtsx_pcr.h       |    3 +++
>  include/linux/mfd/rtsx_pci.h |   12 ++++++++++++
>  6 files changed, 62 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/mfd/rtsx_gops.c

[...]

> diff --git a/drivers/mfd/rtsx_gops.c b/drivers/mfd/rtsx_gops.c
> new file mode 100644
> index 0000000..3cf596f
> --- /dev/null
> +++ b/drivers/mfd/rtsx_gops.c
> @@ -0,0 +1,36 @@
> +/* Driver for Realtek PCI-Express card reader
> + *
> + * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the
> + * Free Software Foundation; either version 2, or (at your option) any
> + * later version.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see <http://www.gnu.org/licenses/>.
> + *
> + * Author:
> + *   Micky Ching <micky_ching@realsil.com.cn>
> + */
> +
> +#include <linux/mfd/rtsx_pci.h>
> +#include "rtsx_pcr.h"
> +
> +int rtsx_gops_pm_reset(struct rtsx_pcr *pcr)
> +{
> +	int err;
> +
> +	/* init aspm */
> +	err = rtsx_pci_update_cfg_byte(pcr, LCTLR, 0xFC, 0);

I'm not keen on the magic numbers here.  Can you #define them?

> +	if (err < 0)
> +		return err;
> +
> +	/* reset PM_CTRL3 before send buffer cmd */
> +	return rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x00);

Same.

> +}
> diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
> index 07e4c2e..fe2bbb6 100644
> --- a/drivers/mfd/rtsx_pcr.h
> +++ b/drivers/mfd/rtsx_pcr.h
> @@ -72,4 +72,7 @@ do {									\
>  	pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \
>  } while (0)
>  
> +/* generic operations */
> +int rtsx_gops_pm_reset(struct rtsx_pcr *pcr);
> +
>  #endif
> diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
> index 74346d5..b34fec8 100644
> --- a/include/linux/mfd/rtsx_pci.h
> +++ b/include/linux/mfd/rtsx_pci.h
> @@ -967,4 +967,16 @@ static inline u8 *rtsx_pci_get_cmd_data(struct rtsx_pcr *pcr)
>  	return (u8 *)(pcr->host_cmds_ptr);
>  }
>  
> +static inline int rtsx_pci_update_cfg_byte(struct rtsx_pcr *pcr, int addr,
> +		u8 mask, u8 append)
> +{
> +	int err;
> +	u8 val;
> +
> +	err = pci_read_config_byte(pcr->pci, addr, &val);
> +	if (err < 0)
> +		return err;
> +	return pci_write_config_byte(pcr->pci, addr, (val & mask) | append);
> +}
> +
>  #endif

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2014-10-06 21:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-18  6:55 [PATCH] mfd: rtsx: fix PM suspend for 5227 & 5249 micky_ching
2014-10-06 21:05 ` Lee Jones [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-09-18  1:35 micky_ching
2014-09-18  4:53 ` Lee Jones
2014-09-18  5:49   ` micky
2014-09-19  0:21     ` Lee Jones
2014-09-19  1:24       ` micky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141006210536.GD18035@lee--X1 \
    --to=lee.jones@linaro.org \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=micky_ching@realsil.com.cn \
    --cc=rogerable@realtek.com \
    --cc=sameo@linux.intel.com \
    --cc=wei_wang@realsil.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox