Skip to contentSkip to conversation

updates the at91 main_clock calculation

PATCH New Jens Scharsig 3 participants 6 messages Feb 14, 2010 – Feb 17, 2010 Arm/Microchip (AT91) SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 updates the at91 main_clock calculation

* updates the conditional main_clock calculation (if AT91_MAIN_CLOCK defined) to c structure SoC access
* add need register flags

---
 cpu/arm926ejs/at91/clock.c           |    7 ++++---
 include/asm-arm/arch-at91/at91_pmc.h |    3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)
cpu/arm926ejs/at91/clock.c +4 -3
index 7e03907..f3988fc 100644
@@ -157,9 +157,10 @@ int at91_clock_init(unsigned long main_clock)
 	 */
 	if (!main_clock) {
 		do {
-			tmp = at91_sys_read(AT91_CKGR_MCFR);
-		} while (!(tmp & AT91_PMC_MAINRDY));
-		main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16);
+			tmp = readl(&pmc->mcfr);
+		} while (!(tmp & AT91_PMC_MCFR_MAINRDY));
+		tmp &= AT91_PMC_MCFR_MAINF_MASK;
+		main_clock = tmp * (AT91_SLOW_CLOCK / 16);
 	}
 #endif
 	main_clk_rate_hz = main_clock;
include/asm-arm/arch-at91/at91_pmc.h +3 -0
index 369b5d7..680fe33 100644
@@ -71,6 +71,9 @@ typedef struct at91_pmc {
 #define AT91_PMC_PLLBR_USBDIV_2		0x10000000
 #define AT91_PMC_PLLBR_USBDIV_4		0x20000000
 
+#define AT91_PMC_MCFR_MAINRDY		0x00010000
+#define AT91_PMC_MCFR_MAINF_MASK	0x0000FFFF
+
 #define AT91_PMC_MCKR_CSS_SLOW		0x00000000
 #define AT91_PMC_MCKR_CSS_MAIN		0x00000001
 #define AT91_PMC_MCKR_CSS_PLLA		0x00000002
Signature · 1 line
1.6.0.2
#1 lore raw

PATCH 1/1 updates the at91 main_clock calculation

Quoted 10 lines · Jens Scharsig

* updates the conditional main_clock calculation (if AT91_MAIN_CLOCK defined) to c structure SoC access
* add need register flags

---
 cpu/arm926ejs/at91/clock.c           |    7 ++++---
 include/asm-arm/arch-at91/at91_pmc.h |    3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)

...

Thank you, now the updated otc570 builds without errors. I didn't check, whether the board boots, but I guess it does.

Regards,
Daniel Gorsulowski

#2 lore raw

PATCH 1/1 updates the at91 main_clock calculation

Quoted 11 lines · Daniel Gorsulowski
Quoted 10 lines · Jens Scharsig

* updates the conditional main_clock calculation (if AT91_MAIN_CLOCK defined) to c structure SoC access
* add need register flags

---
 cpu/arm926ejs/at91/clock.c           |    7 ++++---
 include/asm-arm/arch-at91/at91_pmc.h |    3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)
Quoted 5 lines

...

Thank you, now the updated otc570 builds without errors. I didn't check, whether the board boots, but I guess it does.

Were you going to check in the next couple of days ? Tom

Quoted 2 lines

Regards,
Daniel Gorsulowski

#3 lore raw

PATCH 1/1 updates the at91 main_clock calculation

Am 16.02.2010 16:23, schrieb Tom:

Quoted 12 lines
Quoted 11 lines · Daniel Gorsulowski
Quoted 10 lines · Jens Scharsig

* updates the conditional main_clock calculation (if AT91_MAIN_CLOCK defined) to c structure SoC access
* add need register flags

---
 cpu/arm926ejs/at91/clock.c           |    7 ++++---
 include/asm-arm/arch-at91/at91_pmc.h |    3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)
Quoted 9 lines
Quoted 5 lines

...

Thank you, now the updated otc570 builds without errors. I didn't check, whether the board boots, but I guess it does.

Were you going to check in the next couple of days ? Tom

Checked... board boots.

Btw. there are some warnings during build:
mkimage.c: In function ?main?:
mkimage.c:204: warning: dereferencing type-punned pointer will break strict-aliasing rules
mkimage.c:222: warning: dereferencing type-punned pointer will break strict-aliasing rules
soft_i2c.c: In function 'send_reset':
soft_i2c.c:103: warning: unused variable 'pio'
soft_i2c.c: In function 'send_start':
soft_i2c.c:130: warning: unused variable 'pio'
soft_i2c.c: In function 'send_stop':
soft_i2c.c:147: warning: unused variable 'pio'
soft_i2c.c: In function 'send_ack':
soft_i2c.c:166: warning: unused variable 'pio'
soft_i2c.c: In function 'write_byte':
soft_i2c.c:185: warning: unused variable 'pio'
soft_i2c.c: In function 'read_byte':
soft_i2c.c:259: warning: unused variable 'pio' atmel_dataflash_spi.c:25:2: warning: #warning Please update to use C structur SoC access !
atmel_usart.c:21:2: warning: #warning Please update to use C structur SoC access ! ohci-at91.c:30:2: warning: #warning Please update to use C structur SoC access !

Regards,
Daniel

#4 lore raw

PATCH 1/1 updates the at91 main_clock calculation

Quoted 3 lines · Daniel Gorsulowski
Quoted 1 line
Quoted 1 line

Jens Scharsig wrote:

soft_i2c.c: In function 'send_reset':
soft_i2c.c:103: warning: unused variable 'pio'

--snip--

Quoted 2 lines

soft_i2c.c: In function 'read_byte':
soft_i2c.c:259: warning: unused variable 'pio'

There are two ways to define I2C_xxxx macros:
gpio or direct SoC access

if you are using gpio to define macros, I think you get this warnings.

If you are using direct SoC access (no gpio driver needed) there are no warnings
e.g.

#define I2C_ACTIVE writel(AT91_PMX_AA_TWD, &pio->pioa.mddr);
#define I2C_TRISTATE writel(AT91_PMX_AA_TWD, &pio->pioa.mder);
and so on

Quoted 4 lines

atmel_dataflash_spi.c:25:2: warning: #warning Please update to use C structur SoC access !
atmel_usart.c:21:2: warning: #warning Please update to use C structur SoC access ! ohci-at91.c:30:2: warning: #warning Please update to use C structur SoC access !

We need some volunteers, which convert the drivers.

Regards Jens

#5 lore raw

PATCH 1/1 updates the at91 main_clock calculation

In reply to Daniel Gorsulowski
Quoted 15 lines · Daniel Gorsulowski

Am 16.02.2010 16:23, schrieb Tom:

Quoted 14 lines
Quoted 13 lines · Daniel Gorsulowski
Quoted 10 lines · Jens Scharsig

* updates the conditional main_clock calculation (if AT91_MAIN_CLOCK defined) to c structure SoC access
* add need register flags

---
 cpu/arm926ejs/at91/clock.c           |    7 ++++---
 include/asm-arm/arch-at91/at91_pmc.h |    3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)

...

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

Thank you, now the updated otc570 builds without errors. I didn't check, whether the board boots, but I guess it does.

Were you going to check in the next couple of days ? Tom

Checked... board boots.

Thanks!

Quoted 5 lines

Btw. there are some warnings during build:
mkimage.c: In function ?main?:
mkimage.c:204: warning: dereferencing type-punned pointer will break strict-aliasing rules
mkimage.c:222: warning: dereferencing type-punned pointer will break

In general I look for new compiler warnings and errors. Any old warnings should be fixed but it is unlikely that this change introduced them.

Of course results will vary depending on toolchain.

Thanks,
Tom

Quoted 3 lines

Regards,
Daniel