public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Reilly <marc@cpdesign.com.au>
To: Fabio Estevam <festevam@gmail.com>
Cc: "Shawn Guo" <shawn.guo@freescale.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Mark Brown" <broonie@opensource.wolfsonmicro.com>,
	"Samuel Ortiz" <sameo@linux.intel.com>,
	"Sascha Hauer" <kernel@pengutronix.de>,
	"Philippe Rétornaz" <philippe.retornaz@epfl.ch>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: mc13xxx-core: kernel hangs after 'regmap_read'
Date: Thu, 24 May 2012 23:38:41 +1000	[thread overview]
Message-ID: <201205242338.41420.marc@cpdesign.com.au> (raw)
In-Reply-To: <CAOMZO5AYCSVT=s=rB3xPkz5SYEQQZ9q7f=rFbTbJkkVPk7Y7Vw@mail.gmail.com>

Hi,

> Yes, you are right. buf_size should be changed as you suggests so that
> it can be 4 bytes instead of 3.
> 
> This is the patch I am using now:

I just sent something similar before I saw this.

> 
> diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
> index 0bcda48..6beef98 100644
> --- a/drivers/base/regmap/regmap.c
> +++ b/drivers/base/regmap/regmap.c
> @@ -246,11 +246,12 @@ struct regmap *regmap_init(struct device *dev,
>  		map->lock = regmap_lock_mutex;
>  		map->unlock = regmap_unlock_mutex;
>  	}
> -	map->format.buf_size = (config->reg_bits + config->val_bits) / 8;
>  	map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8);
>  	map->format.pad_bytes = config->pad_bits / 8;
>  	map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8);
> -	map->format.buf_size += map->format.pad_bytes;
> +	map->format.buf_size = (config->reg_bits + config->val_bits +
> +						(config->pad_bits % 8)) / 8;
> +

This won't work when pad bits is > 8


>  	map->reg_shift = config->pad_bits % 8;
>  	if (config->reg_stride)
>  		map->reg_stride = config->reg_stride;
> diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
> index 3fcdab3..4c14dfc 100644
> --- a/drivers/mfd/mc13xxx-spi.c
> +++ b/drivers/mfd/mc13xxx-spi.c
> @@ -49,6 +49,8 @@ static struct regmap_config mc13xxx_regmap_spi_config = {
>  	.reg_bits = 7,
>  	.pad_bits = 1,
>  	.val_bits = 24,
> +	.write_flag_mask = 0x80,
> +	.read_flag_mask = 0x00,
> 
>  	.max_register = MC13XXX_NUMREGS,
> 
> @@ -73,7 +75,6 @@ static int mc13xxx_spi_probe(struct spi_device *spi)
> 
>  	dev_set_drvdata(&spi->dev, mc13xxx);
>  	spi->mode = SPI_MODE_0 | SPI_CS_HIGH;
> -	spi->bits_per_word = 32;
> 
>  	mc13xxx->dev = &spi->dev;
>  	mutex_init(&mc13xxx->lock);
> 
> , which is still not allowing me to read the SPI registers correctly.
> 
> Have I missed anything?


If I had something to test with, I'd be looking at the parameters of 
"regmap_spi_read" in drivers/base/regmap/regmap-spi.c . Verify reg_size is 1 
(8bits) and val_size is 3. Check also what the reg address is. The first read 
when the mc13xxx is probed is register 46, so would expect reg to be 0x5C.

> 
> Still reading 0x810 for all registers (0x810000 is the value of
> register 0 , btw).


This could mean that all the registers are being sent as 0 and the value is 
shifted by 12 bits. (which is a bit weird). It's also a strange that Shawn's 
board seems to work.

Do you have any other devices on that SPI that you can verify are working 
correctly? (you said it worked from the bootloader, I'm running out of 
ideas... :| )


Cheers,
Marc

  reply	other threads:[~2012-05-24 13:41 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 16:06 mc13xxx-core: kernel hangs after 'regmap_read' Fabio Estevam
2012-05-22  0:53 ` Marc Reilly
2012-05-22  9:25   ` Mark Brown
2012-05-22 11:40     ` Fabio Estevam
2012-05-22 12:48       ` Philippe Rétornaz
2012-05-22 14:45     ` Fabio Estevam
2012-05-23  1:12   ` Fabio Estevam
2012-05-23  2:05     ` Fabio Estevam
2012-05-23  8:49       ` Mark Brown
2012-05-23 14:18         ` Fabio Estevam
2012-05-23 15:29           ` Fabio Estevam
2012-05-23 17:36           ` Mark Brown
2012-05-23 19:32             ` Fabio Estevam
2012-05-23 16:42         ` Shawn Guo
2012-05-23 16:34           ` Fabio Estevam
2012-05-24  0:48             ` Shawn Guo
2012-05-24  4:07               ` Fabio Estevam
2012-05-24  6:04                 ` Shawn Guo
2012-05-24  6:39                 ` Shawn Guo
2012-05-24  6:46                   ` Uwe Kleine-König
2012-05-24  7:33                     ` Shawn Guo
2012-05-24  9:08                       ` Marc Reilly
2012-05-24 10:37                         ` Mark Brown
2012-05-24 11:22                           ` Marc Reilly
2012-05-24 12:14                             ` Mark Brown
2012-05-24 13:06                               ` Marc Reilly
2012-05-24 16:37                                 ` Mark Brown
2012-05-24 13:01                         ` Fabio Estevam
2012-05-24 13:38                           ` Marc Reilly [this message]
2012-05-24 16:16                             ` Philippe Rétornaz
2012-05-24 16:36                               ` Mark Brown
2012-05-24 16:41                                 ` Uwe Kleine-König
2012-05-24 17:39                                   ` Fabio Estevam
2012-05-24 18:03                                     ` Mark Brown
2012-05-24 19:42                                       ` philippe.retornaz
2012-05-24 22:21                                         ` Mark Brown
2012-05-25  8:56                         ` Shawn Guo

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=201205242338.41420.marc@cpdesign.com.au \
    --to=marc@cpdesign.com.au \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=philippe.retornaz@epfl.ch \
    --cc=sameo@linux.intel.com \
    --cc=shawn.guo@freescale.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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