From: Vitaly Bordug <vitb@kernel.crashing.org>
To: Olof Johansson <olof@lixom.net>
Cc: Jean Delvare <khali@linux-fr.org>,
"linuxppc-dev@ozlabs.org" <linuxppc-dev@ozlabs.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][RFC][POWERPC] i2c: adds support for i2c bus on 8xx
Date: Wed, 25 Apr 2007 21:01:07 +0400 [thread overview]
Message-ID: <462F8953.1020201@kernel.crashing.org> (raw)
In-Reply-To: <20070423025709.GA28805@lixom.net>
[-- Attachment #1: Type: text/plain, Size: 4624 bytes --]
Olof Johansson wrote:
> On Fri, Apr 20, 2007 at 08:27:14AM +0400, Vitaly Bordug wrote:
>
>
>> diff --git a/arch/powerpc/platforms/8xx/mpc885ads_setup.c b/arch/powerpc/platforms/8xx/mpc885ads_setup.c
>> index 9bd81c7..d32e066 100644
>> --- a/arch/powerpc/platforms/8xx/mpc885ads_setup.c
>> +++ b/arch/powerpc/platforms/8xx/mpc885ads_setup.c
>> @@ -51,6 +51,7 @@ static void init_smc1_uart_ioports(struc
>> static void init_smc2_uart_ioports(struct fs_uart_platform_info* fpi);
>> static void init_scc3_ioports(struct fs_platform_info* ptr);
>> static void init_irda_ioports(void);
>> +static void init_i2c_ioports(void);
>>
>> void __init mpc885ads_board_setup(void)
>> {
>> @@ -120,6 +121,10 @@ #endif
>> #ifdef CONFIG_8XX_SIR
>> init_irda_ioports();
>> #endif
>> +
>> +#ifdef CONFIG_I2C_RPXLITE
>> + init_i2c_ioports();
>> +#endif
>>
>
> Does it hurt to always do it, even when the driver is not enabled? THat'd
> do away with an ifdef.
>
>
Well it will hurt - 8xx has conflicting io pin configurations, and
nothing should be set up "just in case".
> Also, if you move the static function up, you don't need a prototype. That
> goes for other stuff in this file too.
>
>
>> }
>>
>>
>> @@ -361,6 +366,15 @@ static void init_irda_ioports()
>> immr_unmap(cp);
>> }
>>
>> +static void init_i2c_ioports()
>> +{
>> + cpm8xx_t *cp = (cpm8xx_t *)immr_map(im_cpm);
>> +
>> + setbits32(&cp->cp_pbpar, 0x00000030);
>> + setbits32(&cp->cp_pbdir, 0x00000030);
>> + setbits16(&cp->cp_pbodr, 0x0030);
>> +}
>>
>
> Looks like you moved this out of the driver and into the platform
> code. What happens to other platforms where it's used?
>
>
i2c && 8xx combo never work with 2.6 at least in mainstream. That's why
related stuff were scheduled to removal by Jean even,
before I came up with this stuff.
>> +
>> int platform_device_skip(const char *model, int id)
>> {
>> #ifdef CONFIG_MPC8xx_SECOND_ETH_SCC3
>> diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
>> index 419b688..7ecd537 100644
>> --- a/arch/powerpc/sysdev/fsl_soc.c
>> +++ b/arch/powerpc/sysdev/fsl_soc.c
>> @@ -331,7 +331,7 @@ static int __init fsl_i2c_of_init(void)
>> for (np = NULL, i = 0;
>> (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
>> i++) {
>> - struct resource r[2];
>> + struct resource r[3];
>>
>
> Why? No code that uses it has been changed. Is it a bugfix?
>
>
maybe something stray...
>> struct fsl_i2c_platform_data i2c_data;
>> const unsigned char *flags = NULL;
>>
>> @@ -1215,4 +1215,63 @@ err:
>>
>> arch_initcall(fs_irda_of_init);
>>
>> +static const char *i2c_regs = "regs";
>> +static const char *i2c_pram = "pram";
>> +static const char *i2c_irq = "interrupt";
>> +
>> +static int __init fsl_i2c_cpm_of_init(void)
>> +{
>> + struct device_node *np;
>> + unsigned int i;
>> + struct platform_device *i2c_dev;
>> + int ret;
>> +
>> + for (np = NULL, i = 0;
>> + (np = of_find_compatible_node(np, "i2c", "fsl-i2c-cpm")) != NULL;
>> + i++) {
>> + struct resource r[3];
>> + struct fsl_i2c_platform_data i2c_data;
>> +
>> + memset(&r, 0, sizeof(r));
>> + memset(&i2c_data, 0, sizeof(i2c_data));
>> +
>> + ret = of_address_to_resource(np, 0, &r[0]);
>> + if (ret)
>> + goto err;
>> + r[0].name = i2c_regs;
>> +
>> + ret = of_address_to_resource(np, 1, &r[1]);
>> + if (ret)
>> + goto err;
>> + r[1].name = i2c_pram;
>> +
>> + r[2].start = r[2].end = irq_of_parse_and_map(np, 0);
>> + r[2].flags = IORESOURCE_IRQ;
>> + r[2].name = i2c_irq;
>> +
>> + i2c_dev = platform_device_register_simple("fsl-i2c-cpm", i, &r[0], 3);
>> + if (IS_ERR(i2c_dev)) {
>> + ret = PTR_ERR(i2c_dev);
>> + goto err;
>> + }
>> +
>> + ret =
>> + platform_device_add_data(i2c_dev, &i2c_data,
>> + sizeof(struct
>> + fsl_i2c_platform_data));
>> + if (ret)
>> + goto unreg;
>> + }
>> +
>> + return 0;
>> +
>> +unreg:
>> + platform_device_unregister(i2c_dev);
>> +err:
>> + return ret;
>> +}
>> +
>> +arch_initcall(fsl_i2c_cpm_of_init);
>>
>
> This could all be done with an of_platform driver instead, and avoid the above.
> (Someone else already suggested that I believe).
>
>
I know i know. But it was decided, while both ppc/ and powerpc/ wander
around, platform devices way is preferrable.
It is apparent why - so far only mpc885 is alive in arch/powerpc, and it
is not going to change soon for 8xx. OTOH,
some stuff from arch/ppc might use it/add BSP configuration etc.
Having some devices on of_device and some on pdev look kinda messy.
Thanks,
Vitaly
[-- Attachment #2: Type: text/html, Size: 5458 bytes --]
next prev parent reply other threads:[~2007-04-25 17:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-20 4:27 [PATCH][RFC][POWERPC] i2c: adds support for i2c bus on 8xx Vitaly Bordug
2007-04-20 4:27 ` Vitaly Bordug
2007-04-20 8:57 ` Segher Boessenkool
2007-04-20 15:15 ` Milton Miller
2007-04-21 7:57 ` [PATCH][RFC] " Jean Delvare
2007-04-21 7:57 ` Jean Delvare
2007-04-22 11:29 ` Vitaly Bordug
2007-04-22 11:29 ` Vitaly Bordug
2007-04-23 9:19 ` Jean Delvare
2007-04-23 9:19 ` Jean Delvare
2007-04-25 17:06 ` Vitaly Bordug
2007-04-26 15:54 ` Jean Delvare
2007-04-26 15:54 ` Jean Delvare
2007-04-26 16:07 ` Vitaly Bordug
2007-04-23 2:57 ` [PATCH][RFC][POWERPC] " Olof Johansson
2007-04-25 17:01 ` Vitaly Bordug [this message]
2007-04-25 18:53 ` Scott Wood
2007-04-25 18:53 ` Scott Wood
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=462F8953.1020201@kernel.crashing.org \
--to=vitb@kernel.crashing.org \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=olof@lixom.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.