public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Ryan Mallon <ryan-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
Cc: i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
Subject: Re: New style i2c drivers for ALSA SoC
Date: Mon, 12 May 2008 08:20:25 +0200	[thread overview]
Message-ID: <20080512082025.01e5d0c0@hyperion.delvare> (raw)
In-Reply-To: <482795E7.9040007-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>

Hi Ryan,

On Mon, 12 May 2008 12:57:11 +1200, Ryan Mallon wrote:
> I am writing drivers to support ALSA SoC for an ARM based system. The
> system has an i2c codec. I want to use the new style driver for the
> codec driver, but I cannot get it to work properly. In my codec driver
> (sound/soc/codecs/tlv320aic2x.c) I have:
> 
> static struct i2c_driver aic2x_i2c_driver = {
> 	.driver		= {
> 		.name	= "tlv320aic2x",
> 		.owner	= THIS_MODULE,
> 	},
> 	.probe		= aic2x_i2c_probe,
> 	.remove		= aic2x_i2c_remove,
> };
> 
> static int __init aic2x_init(void)
> {
> 	return i2c_add_driver(&aic2x_i2c_driver);
> }
> 
> static void __exit aic2x_exit(void)
> {
> 	i2c_del_driver(&aic2x_i2c_driver);
> }
> 
> module_init(aic2x_init);
> module_exit(aic2x_exit);
> 
> Putting i2c_register_board_info either in my machine file in the
> arch/arm/ directory, or the machine file in the sound/soc/ directory
> does not seem to work. The driver does correctly register, ie I see the
> following in dmesg (although much later than the other i2c drivers):
> 
> i2c-core: driver [tlv320aic2x] registered
> 
> But its probe function is never called. The other i2c codec drivers in
> the sound/soc/codecs directory are all using the legacy i2c driver model.

What data are you passing to i2c_register_board_info?

Since 2.6.26-rc1, you can and should provide a list of devices
supported by your driver. Your driver definition would look like:

static const struct i2c_device_id aic2x_i2c_id[] = {
	{ "tlv320aic2x", 0 },
	{ }
};
MODULE_DEVICE_TABLE(i2c, aic2x_i2c_id);

static struct i2c_driver aic2x_i2c_driver = {
	.driver		= {
		.name	= "tlv320aic2x",
		.owner	= THIS_MODULE,
	},
	.probe		= aic2x_i2c_probe,
	.remove		= aic2x_i2c_remove,
	.id_table	= aic2x_i2c_id,
};

Also note that there's already a driver in the kernel tree
(drivers/media/video/tlv320aic23b.c) for apparently the same hardware,
so maybe there's some code to share.

> I also looked at the i2c_new_device function. I'm not sure if this is
> what I want, but I don't know where to get the adapter structure to pass
> to it. The other drivers I found which use this function are creating
> their own i2c adapter (usually bit-bashed) for talking to the i2c
> device, which is not what I want to do.

i2c_new_device() is meant to instantiate I2C devices at run-time. It is
mostly useful for TV adapters and similar where you don't know in
advance if it will be there and what i2c bus number it will receive.
For embedded designs where you know exactly which devices you have at
build time, i2c_register_board_info() is the way to go.

> Finally, a stylistic question: Should the i2c_board_info (or similar)
> for a codec device be defined in the machine initialisation code
> (arch/arm/ directory), or in the sound/soc machine file?

Machine initialization code.

-- 
Jean Delvare

_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c

  parent reply	other threads:[~2008-05-12  6:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-12  0:57 New style i2c drivers for ALSA SoC Ryan Mallon
     [not found] ` <482795E7.9040007-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
2008-05-12  6:20   ` Jean Delvare [this message]
     [not found]     ` <20080512082025.01e5d0c0-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-05-12 20:52       ` Ryan Mallon
     [not found]         ` <4828AE22.2030705-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
2008-05-12 21:05           ` Jean Delvare
2008-05-12 21:15   ` Ben Dooks

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=20080512082025.01e5d0c0@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
    --cc=ryan-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org \
    /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