SPI omap2_mcspi: Add max_clk_div field to mcspi platform config
Subsystems (4)
PATCH 2/6 SPI omap2_mcspi: Add max_clk_div field to mcspi platform config
The McSPI_CHxCONF.CLKD register field has different limits for the OMAP3 then the OMAP24xx. As per recommendation from the linux-omap list, added a field for max_clk_div to the platform data for use in omap2_mcspi.c.
Used in a subsequent patch.
arch/arm/mach-omap2/devices.c | 16 ++++++++++++++++ arch/arm/plat-omap/include/plat/mcspi.h | 1 + 2 files changed, 17 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/devices.c +16 -0
@@ -302,6 +302,11 @@ static inline void omap_init_sti(void) {}static struct omap2_mcspi_platform_config omap2_mcspi1_config = { .num_cs =4 , +#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) + .max_clk_div =0x0c , +#else + .max_clk_div =0x0f , +#endif };static struct resource omap2_mcspi1_resources[] = {
@@ -324,6 +329,11 @@ static struct platform_device omap2_mcspi1 = {static struct omap2_mcspi_platform_config omap2_mcspi2_config = { .num_cs =2 , +#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) + .max_clk_div =0x0c , +#else + .max_clk_div =0x0f , +#endif };static struct resource omap2_mcspi2_resources[] = {
@@ -348,6 +358,11 @@ static struct platform_device omap2_mcspi2 = {defined (CONFIG_ARCH_OMAP4) static struct omap2_mcspi_platform_config omap2_mcspi3_config = { .num_cs =2 , +#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) + .max_clk_div =0x0c , +#else + .max_clk_div =0x0f , +#endif };static struct resource omap2_mcspi3_resources[] = {
@@ -372,6 +387,7 @@ static struct platform_device omap2_mcspi3 = {#if defined(CONFIG_ARCH_OMAP3 ) || defined(CONFIG_ARCH_OMAP4 )static struct omap2_mcspi_platform_config omap2_mcspi4_config = { .num_cs =1 , + .max_clk_div =0x0c , }; static struct resource omap2_mcspi4_resources[] = {
arch/arm/plat-omap/include/plat/mcspi.h +1 -0
@@ -3,6 +3,7 @@struct omap2_mcspi_platform_config {unsigned short num_cs; +unsigned short max_clk_div; };struct omap2_mcspi_device_config {
Tony Lindgren
maintainerPATCH 2/6 SPI omap2_mcspi: Add max_clk_div field to mcspi platform config
Quoted 18 lines · Scott Ellis
The McSPI_CHxCONF.CLKD register field has different limits for the OMAP3 then the OMAP24xx. As per recommendation from the linux-omap list, added a field for
max_clk_divto the platform data for use inomap2_mcspi.c.Used in a subsequent patch.
Signed-off-by Scott Ellis <[email protected]>arch/arm/mach-omap2/devices.c | 16 ++++++++++++++++ arch/arm/plat-omap/include/plat/mcspi.h | 1 + 2 files changed, 17 insertions(+), 0 deletions(-)arch/arm/mach-omap2/devices.c +0
-0
arch/arm/mach-omap2/devices.c static inline void omap_init_sti(void) {} · line 311
Quoted 10 lines
arch/arm/mach-omap2/devices.c +5
-0@@ -302,6 +302,11 @@ static inline void omap_init_sti(void) {}static struct omap2_mcspi_platform_config omap2_mcspi1_config = { .num_cs =4 , +#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) + .max_clk_div =0x0c , +#else + .max_clk_div =0x0f , +#endif };
Can't do ifdef else like this. It will break multi-omap booting on omap2 + 3 + 4. In the platform init just set the values once with cpu_is_omapXXXX() instead.
Regards,
Tony
PATCH 2/6 SPI omap2_mcspi: Add max_clk_div field to mcspi platform config
The McSPI_CHxCONF.CLKD register field has different limits for the OMAP3 then the OMAP24xx. New max_clk_div field added to mcspi platform config structure to keep track of this.
Revised patch to not break multi-omap booting.
arch/arm/mach-omap2/devices.c | 14 ++++++++++++++ arch/arm/plat-omap/include/plat/mcspi.h | 1 + 2 files changed, 15 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/devices.c +14 -0
@@ -415,6 +415,11 @@ static inline void omap4_mcspi_fixup(void)defined (CONFIG_ARCH_OMAP4) static inline void omap2_mcspi3_init(void) { +if (cpu_is_omap343x () ||cpu_is_omap44xx ()) + omap2_mcspi3_config.max_clk_div =0x0c ; +else + omap2_mcspi3_config.max_clk_div =0x0f ; +platform_device_register (&omap2_mcspi3); }#else
@@ -426,6 +431,7 @@ static inline void omap2_mcspi3_init(void)#if defined(CONFIG_ARCH_OMAP3 ) || defined(CONFIG_ARCH_OMAP4 )static inline void omap2_mcspi4_init (void ) { + omap2_mcspi4_config.max_clk_div =0x0c ;platform_device_register (&omap2_mcspi4); }#else
@@ -439,6 +445,14 @@ static void omap_init_mcspi(void)if (cpu_is_omap44xx ())omap4_mcspi_fixup (); +if (cpu_is_omap343x () ||cpu_is_omap44xx ()) { + omap2_mcspi1_config.max_clk_div =0x0c ; + omap2_mcspi2_config.max_clk_div =0x0c ; + }else { + omap2_mcspi1_config.max_clk_div =0x0f ; + omap2_mcspi2_config.max_clk_div =0x0f ; + } +platform_device_register (&omap2_mcspi1);platform_device_register (&omap2_mcspi2);
arch/arm/plat-omap/include/plat/mcspi.h +1 -0
@@ -3,6 +3,7 @@struct omap2_mcspi_platform_config {unsigned short num_cs; +unsigned short max_clk_div; };struct omap2_mcspi_device_config {
Quoted 18 lines · Scott Ellis
The McSPI_CHxCONF.CLKD register field has different limits for the OMAP3 then the OMAP24xx. New
max_clk_divfield added to mcspi platform config structure to keep track of this.Revised patch to not break multi-omap booting.
Signed-off-by Scott Ellis <scott-oZqG5KApg2M/[email protected]>arch/arm/mach-omap2/devices.c | 14 ++++++++++++++ arch/arm/plat-omap/include/plat/mcspi.h | 1 + 2 files changed, 15 insertions(+), 0 deletions(-)arch/arm/mach-omap2/devices.c +0
-0@@ -415,6 +415,11 @@ static inline void omap4_mcspi_fixup(void)defined (CONFIG_ARCH_OMAP4 )
arch/arm/mach-omap2/devices.c static inline void omap4_mcspi_fixup(void) · line 425
Quoted 10 lines
arch/arm/mach-omap2/devices.c +5
-0static inline void omap2_mcspi3_init (void ) { +if (cpu_is_omap343x () ||cpu_is_omap44xx ()) + omap2_mcspi3_config.max_clk_div =0x0c ; +else + omap2_mcspi3_config.max_clk_div =0x0f ; +platform_device_register (&omap2_mcspi3); }#else
Hmm now it looks like you're missing 3630 handling?
If the max_clk_div is 0x0f for 2420 and 2430, then you can just check for cpu_is_omap24xx(). If it's only different for 2420, then you can check for cpu_is_omap2420().
That way it should be more future proof, and you don't need to change it for new processors.
Regards,
Tony
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Hi,
Quoted 1 line · Tony Lindgren
Hmm now it looks like you're missing 3630 handling?
a bit unrelated but Tony, would you mind looking at patches splitting devices.c into something like dev34xx.c dev24xx.c and dev44xx.c ??
personally I think we should have mach-omap3 and mach-omap4 directories but that would be too intrusive IMO.
Signature · 1 line
balbi
Tony Lindgren
maintainerQuoted 7 lines · Felipe Balbi
Hi,
Quoted 1 line · Tony Lindgren
Hmm now it looks like you're missing 3630 handling?
a bit unrelated but Tony, would you mind looking at patches splitting
devices.cinto something likedev34xx.cdev24xx.canddev44xx.c??
Yeah I've been thinking about that too earlier. We could have common devices.c with the init code, then dev24xx.c and dev34xx.c et al would just call the common init functions with something like this:
static int __init dev34xx_init(void)
{
if (!cpu_is_omap34xx())
return -ENODEV;
omap_init_mbox(omap34xx_mbox_resources, omap34xx_mbox_nr_resources);
omap_init_sti(omap34xx_sti_resources, omap34xx_sti_nr_resources);
...
return 0;
}subsys_initcall(emu_init);
Of course that needs to be coordinated with the pending hwmod patches.
Quoted 2 lines
personally I think we should have mach-omap3 and mach-omap4 directories but that would be too intrusive IMO.
I think we can achieve most of that by right naming of the files and with hwmod. Having separate directories typically means multiple copies of almost the same code.
Regards,
Tony
Hi,
Quoted 17 lines · Tony Lindgren
Yeah I've been thinking about that too earlier. We could have common
devices.cwith the init code, thendev24xx.canddev34xx.cet al would just call the common init functions with something like this:static int
__initdev34xx_init(void){ if (!cpu_is_omap34xx()) return -ENODEV; omap_init_mbox(omap34xx_mbox_resources, omap34xx_mbox_nr_resources); omap_init_sti(omap34xx_sti_resources, omap34xx_sti_nr_resources); ... return 0; }
Quoted 3 lines
subsys_initcall(emu_init);Of course that needs to be coordinated with the pending hwmod patches.
sure. Exactly what I was thinking :-p
Quoted 6 lines
Quoted 2 lines
personally I think we should have mach-omap3 and mach-omap4 directories but that would be too intrusive IMO.
I think we can achieve most of that by right naming of the files and with hwmod. Having separate directories typically means multiple copies of almost the same code.
could be, but we already have separated clk, pm, cpuidle, mux and soon to become devices. So pretty much the base support is already splitted, then why not completely avoiding ifdefs also with dma (which today is full of ifdefs and could be converted to a platform_device also).
Signature · 1 line
balbi
Tony Lindgren
maintainerQuoted 29 lines · Felipe Balbi
Hi,
Quoted 17 lines · Tony Lindgren
Yeah I've been thinking about that too earlier. We could have common
devices.cwith the init code, thendev24xx.canddev34xx.cet al would just call the common init functions with something like this:static int
__initdev34xx_init(void){ if (!cpu_is_omap34xx()) return -ENODEV; omap_init_mbox(omap34xx_mbox_resources, omap34xx_mbox_nr_resources); omap_init_sti(omap34xx_sti_resources, omap34xx_sti_nr_resources); ... return 0; }Quoted 3 lines
subsys_initcall(emu_init);Of course that needs to be coordinated with the pending hwmod patches.
sure. Exactly what I was thinking :-p
Quoted 3 lines
Quoted 2 lines
personally I think we should have mach-omap3 and mach-omap4 directories but that would be too intrusive IMO.
Quoted 8 lines
Quoted 3 lines
I think we can achieve most of that by right naming of the files and with hwmod. Having separate directories typically means multiple copies of almost the same code.
could be, but we already have separated clk, pm, cpuidle, mux and soon to become devices. So pretty much the base support is already splitted, then why not completely avoiding ifdefs also with dma (which today is full of ifdefs and could be converted to a
platform_devicealso).
Yeah there are tons of things that should be fixed and split into platform_data and generic code. At least gpio.c, dma.c and i2c-omap.c need some serious work.
Regards,
Tony
Hi,
Quoted 8 lines · Tony Lindgren
Quoted 4 lines
could be, but we already have separated clk, pm, cpuidle, mux and soon to become devices. So pretty much the base support is already splitted, then why not completely avoiding ifdefs also with dma (which today is full of ifdefs and could be converted to a
platform_devicealso).Yeah there are tons of things that should be fixed and split into
platform_dataand generic code. At leastgpio.c,dma.candi2c-omap.cneed some serious work.
problem with those guys is that they're used all over the place so any changes there would always be extremelly intrusive and are prone to cause regressions :-(
I could try to allocate some time to play with dma.c but I can only test on omap3 since my n810 isn't mount root on mmc, maybe I screwed up something and can't remember what :-s if you happen to have tips, I'm all ears. The thing is rebooting with "mbus" bootreason. I'll have to dig up some legacy docs to figure out what's that.
Signature · 1 line
balbi
Tony Lindgren
maintainerQuoted 8 lines · Felipe Balbi
Hi,
Quoted 5 lines · Tony Lindgren
Quoted 4 lines
could be, but we already have separated clk, pm, cpuidle, mux and soon to become devices. So pretty much the base support is already splitted, then why not completely avoiding ifdefs also with dma (which today is full of ifdefs and could be converted to a
platform_devicealso).
Quoted 7 lines
Quoted 3 lines
Yeah there are tons of things that should be fixed and split into
platform_dataand generic code. At leastgpio.c,dma.candi2c-omap.cneed some serious work.problem with those guys is that they're used all over the place so any changes there would always be extremelly intrusive and are prone to cause regressions :-(
Well it's not too hard, just need to be careful and do it in small patches and test carefully between each patch :)
Quoted 5 lines
I could try to allocate some time to play with
dma.cbut I can only test on omap3 since my n810 isn't mount root on mmc, maybe I screwed up something and can't remember what :-s if you happen to have tips, I'm all ears. The thing is rebooting with "mbus" bootreason. I'll have to dig up some legacy docs to figure out what's that.
For some reason only one of the MMC slots works on both n800 and n810, maybe some menelaus slot switching issue. So you need to try mounting root on the external card on n810 for now until somebody figures out the problem.
Tony
Quoted 9 lines
Hmm now it looks like you're missing 3630 handling?
If the
max_clk_divis0x0ffor 2420 and 2430, then you can just check forcpu_is_omap24xx(). If it's only different for 2420, then you can check forcpu_is_omap2420().That way it should be more future proof, and you don't need to change it for new processors.
Anand Gadiyar <gadiyar <at> ti.com> verified 0x0f for the 2430.
I think SWPU177D is the correct TRM for the omap3630 and if so then 0x0c is the correct value.
I did not verify the omap44xx value and just assumed similar to the omap3's. My bad.
Can you or someone point me to links for the omap2420 and the omap44xx TRMs? I'm not having any luck finding them.
Then it can be verified whether a cpu_is_omap24xx() check is sufficient. It probably is.
Or if someone with access to those manuals could do a quick check...
It's the max value of the MCSPI_CHxCONF.CLKD register field.
Quoted 11 lines · Scott Ellis
Quoted 9 lines
Hmm now it looks like you're missing 3630 handling?
If the
max_clk_divis0x0ffor 2420 and 2430, then you can just check forcpu_is_omap24xx(). If it's only different for 2420, then you can check forcpu_is_omap2420().That way it should be more future proof, and you don't need to change it for new processors.
Anand Gadiyar <gadiyar <at> ti.com> verified
0x0ffor the 2430.
Quoted 8 lines
I think SWPU177D is the correct TRM for the omap3630 and if so then
0x0cis the correct value.I did not verify the omap44xx value and just assumed similar to the omap3's. My bad.
Can you or someone point me to links for the omap2420 and the omap44xx TRMs? I'm not having any luck finding them.
I don't think those are publicly available yet for 4430 and still for 2420..
But looks like 2420, 2430 and 4430 TRMs says that 0xf = 32768 max divider for CLKD.
Only 3430 and 3630 TRMs says 0xd, 0xe, 0xf = Division not supported.
But then again, the TRMs can have errors.
Quoted 2 lines
Then it can be verified whether a
cpu_is_omap24xx()check is sufficient. It probably is.
Then the 4430 TRM must have an error.. Can somebody from TI confirm the CLKD max value for 4430 please?
Quoted 3 lines
Or if someone with access to those manuals could do a quick check...
It's the max value of the MCSPI_CHxCONF.CLKD register field.
Regards,
Tony
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Quoted 2 lines
Only 3430 and 3630 TRMs says
0xd,0xe,0xf= Division not supported.
I tested a 3503 with clock divider values of 0x0d, 0x0e and 0x0f. It worked fine.
I collected data off the SPI bus successfully at the expected frequencies of 5859 Hz, 2929 Hz and 1464 Hz.
Quoted 2 lines
But then again, the TRMs can have errors.
Looks like this is a case of that.
My patches #2 and #3 are unnecessary then and #4 makes use of a new field added in #3.
I can resubmit #4, "Use transfer speed_hz if provided". That was the original problem I was working on.
Should I leave the hard-coded 0x0f in the code or would you prefer a named constant?
Tony Lindgren
maintainerQuoted 10 lines · Scott Ellis
Quoted 2 lines
Only 3430 and 3630 TRMs says
0xd,0xe,0xf= Division not supported.I tested a 3503 with clock divider values of
0x0d,0x0eand0x0f. It worked fine.
I collected data off the SPI bus successfully at the expected frequencies of 5859 Hz, 2929 Hz and 1464 Hz.Quoted 2 lines
But then again, the TRMs can have errors.
Looks like this is a case of that.
OK, good thing you checked it :)
Quoted 8 lines
My patches #2 and #3 are unnecessary then and #4 makes use of a new field added in #3.
I can resubmit #4, "Use transfer
speed_hzif provided". That was the original problem I was working on.Should I leave the hard-coded
0x0fin the code or would you prefer a named constant?
Named constant in the long run, but a minimal fix is best for the -rc cycle.
Regards,
Tony
Please disregard this patch.
PaulM from TI responded,
"It appears that this is a documentation error. The module does support all 16 divide values for the CLKD field"
http://e2e.ti.com/support/dsp/omap_applications_processors/f/42/p/38754/142276.aspx#142276