Author: cognet
Date: Wed Jul 14 00:48:53 2010
New Revision: 210040
URL: http://svn.freebsd.org/changeset/base/210040

Log:
  Import preliminary support for Atmel AT91SAM9G20 cpu, and the Hot-e HL201.
  This fine work was done by Yohanes Nugroho <yohanes a gmail dot com>
  Many thanks to John Nicholls and Thinlinx for providing sample hardware.

Added:
  head/sys/arm/at91/at91_aicreg.h   (contents, props changed)
  head/sys/arm/at91/at91_pio_sam9.h   (contents, props changed)
  head/sys/arm/at91/at91_pit.c   (contents, props changed)
  head/sys/arm/at91/at91_pitreg.h   (contents, props changed)
  head/sys/arm/at91/at91sam9.c   (contents, props changed)
  head/sys/arm/at91/at91sam9_machdep.c   (contents, props changed)
  head/sys/arm/at91/at91sam9g20reg.h   (contents, props changed)
  head/sys/arm/at91/board_hl201.c   (contents, props changed)
  head/sys/arm/at91/files.at91sam9   (contents, props changed)
  head/sys/arm/at91/if_macb.c   (contents, props changed)
  head/sys/arm/at91/if_macbreg.h   (contents, props changed)
  head/sys/arm/at91/if_macbvar.h   (contents, props changed)
  head/sys/arm/at91/std.at91sam9   (contents, props changed)
  head/sys/arm/at91/std.hl201   (contents, props changed)
  head/sys/arm/conf/HL201   (contents, props changed)
  head/sys/arm/conf/HL201.hints   (contents, props changed)
Modified:
  head/sys/arm/at91/at91_pmc.c
  head/sys/arm/at91/at91_pmcreg.h

Added: head/sys/arm/at91/at91_aicreg.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/at91/at91_aicreg.h     Wed Jul 14 00:48:53 2010        
(r210040)
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2009 Sylvestre Gallon. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* $FreeBSD$ */
+
+#ifndef ARM_AT91_AT91_AICREG_H
+#define ARM_AT91_AT91_AICREG_H
+
+/* Interrupt Controller */
+#define IC_SMR                 (0) /* Source mode register */
+#define IC_SVR                 (128) /* Source vector register */
+#define IC_IVR                 (256) /* IRQ vector register */
+#define IC_FVR                 (260) /* FIQ vector register */
+#define IC_ISR                 (264) /* Interrupt status register */
+#define IC_IPR                 (268) /* Interrupt pending register */
+#define IC_IMR                 (272) /* Interrupt status register */
+#define IC_CISR                        (276) /* Core interrupt status register 
*/
+#define IC_IECR                        (288) /* Interrupt enable command 
register */
+#define IC_IDCR                        (292) /* Interrupt disable command 
register */
+#define IC_ICCR                        (296) /* Interrupt clear command 
register */
+#define IC_ISCR                        (300) /* Interrupt set command register 
*/
+#define IC_EOICR               (304) /* End of interrupt command register */
+#define IC_SPU                 (308) /* Spurious vector register */
+#define IC_DCR                 (312) /* Debug control register */
+#define IC_FFER                        (320) /* Fast forcing enable register */
+#define IC_FFDR                        (324) /* Fast forcing disable register 
*/
+#define IC_FFSR                        (328) /* Fast forcing status register */
+
+#endif /*ARM_AT91_AT91_AICREG_H*/

Added: head/sys/arm/at91/at91_pio_sam9.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/at91/at91_pio_sam9.h   Wed Jul 14 00:48:53 2010        
(r210040)
@@ -0,0 +1,291 @@
+/*
+ * Theses defines come from an atmel file that says specifically that it
+ * has no copyright.
+ */
+
+/* $FreeBSD$ */
+
+// 
*****************************************************************************
+//               PIO DEFINITIONS FOR AT91SAM9261
+// 
*****************************************************************************
+#define AT91C_PIO_PA0        ((unsigned int) 1 <<  0) // Pin Controlled by PA0
+#define AT91C_PA0_MISO0    ((unsigned int) AT91C_PIO_PA0) //  SPI0 Master In 
Slave
+#define AT91C_PA0_MCDA0    ((unsigned int) AT91C_PIO_PA0) //  Multimedia Card 
A Data 0
+#define AT91C_PIO_PA1        ((unsigned int) 1 <<  1) // Pin Controlled by PA1
+#define AT91C_PA1_MOSI0    ((unsigned int) AT91C_PIO_PA1) //  SPI0 Master Out 
Slave
+#define AT91C_PA1_MCCDA    ((unsigned int) AT91C_PIO_PA1) //  Multimedia Card 
A Command
+#define AT91C_PIO_PA10       ((unsigned int) 1 << 10) // Pin Controlled by PA10
+#define AT91C_PA10_DTXD     ((unsigned int) AT91C_PIO_PA10) //  DBGU Debug 
Transmit Data
+#define AT91C_PA10_PCK3     ((unsigned int) AT91C_PIO_PA10) //  PMC 
Programmable clock Output 3
+#define AT91C_PIO_PA11       ((unsigned int) 1 << 11) // Pin Controlled by PA11
+#define AT91C_PA11_TSYNC    ((unsigned int) AT91C_PIO_PA11) //  Trace 
Synchronization Signal
+#define AT91C_PA11_SCK1     ((unsigned int) AT91C_PIO_PA11) //  USART1 Serial 
Clock
+#define AT91C_PIO_PA12       ((unsigned int) 1 << 12) // Pin Controlled by PA12
+#define AT91C_PA12_TCLK     ((unsigned int) AT91C_PIO_PA12) //  Trace Clock
+#define AT91C_PA12_RTS1     ((unsigned int) AT91C_PIO_PA12) //  USART1 Ready 
To Send
+#define AT91C_PIO_PA13       ((unsigned int) 1 << 13) // Pin Controlled by PA13
+#define AT91C_PA13_TPS0     ((unsigned int) AT91C_PIO_PA13) //  Trace ARM 
Pipeline Status 0
+#define AT91C_PA13_CTS1     ((unsigned int) AT91C_PIO_PA13) //  USART1 Clear 
To Send
+#define AT91C_PIO_PA14       ((unsigned int) 1 << 14) // Pin Controlled by PA14
+#define AT91C_PA14_TPS1     ((unsigned int) AT91C_PIO_PA14) //  Trace ARM 
Pipeline Status 1
+#define AT91C_PA14_SCK2     ((unsigned int) AT91C_PIO_PA14) //  USART2 Serial 
Clock
+#define AT91C_PIO_PA15       ((unsigned int) 1 << 15) // Pin Controlled by PA15
+#define AT91C_PA15_TPS2     ((unsigned int) AT91C_PIO_PA15) //  Trace ARM 
Pipeline Status 2
+#define AT91C_PA15_RTS2     ((unsigned int) AT91C_PIO_PA15) //  USART2 Ready 
To Send
+#define AT91C_PIO_PA16       ((unsigned int) 1 << 16) // Pin Controlled by PA16
+#define AT91C_PA16_TPK0     ((unsigned int) AT91C_PIO_PA16) //  Trace Packet 
Port 0
+#define AT91C_PA16_CTS2     ((unsigned int) AT91C_PIO_PA16) //  USART2 Clear 
To Send
+#define AT91C_PIO_PA17       ((unsigned int) 1 << 17) // Pin Controlled by PA17
+#define AT91C_PA17_TPK1     ((unsigned int) AT91C_PIO_PA17) //  Trace Packet 
Port 1
+#define AT91C_PA17_TF1      ((unsigned int) AT91C_PIO_PA17) //  SSC1 Transmit 
Frame Sync
+#define AT91C_PIO_PA18       ((unsigned int) 1 << 18) // Pin Controlled by PA18
+#define AT91C_PA18_TPK2     ((unsigned int) AT91C_PIO_PA18) //  Trace Packet 
Port 2
+#define AT91C_PA18_TK1      ((unsigned int) AT91C_PIO_PA18) //  SSC1 Transmit 
Clock
+#define AT91C_PIO_PA19       ((unsigned int) 1 << 19) // Pin Controlled by PA19
+#define AT91C_PA19_TPK3     ((unsigned int) AT91C_PIO_PA19) //  Trace Packet 
Port 3
+#define AT91C_PA19_TD1      ((unsigned int) AT91C_PIO_PA19) //  SSC1 Transmit 
Data
+#define AT91C_PIO_PA2        ((unsigned int) 1 <<  2) // Pin Controlled by PA2
+#define AT91C_PA2_SPCK0    ((unsigned int) AT91C_PIO_PA2) //  SPI0 Serial Clock
+#define AT91C_PA2_MCCK     ((unsigned int) AT91C_PIO_PA2) //  Multimedia Card 
Clock
+#define AT91C_PIO_PA20       ((unsigned int) 1 << 20) // Pin Controlled by PA20
+#define AT91C_PA20_TPK4     ((unsigned int) AT91C_PIO_PA20) //  Trace Packet 
Port 4
+#define AT91C_PA20_RD1      ((unsigned int) AT91C_PIO_PA20) //  SSC1 Receive 
Data
+#define AT91C_PIO_PA21       ((unsigned int) 1 << 21) // Pin Controlled by PA21
+#define AT91C_PA21_TPK5     ((unsigned int) AT91C_PIO_PA21) //  Trace Packet 
Port 5
+#define AT91C_PA21_RK1      ((unsigned int) AT91C_PIO_PA21) //  SSC1 Receive 
Clock
+#define AT91C_PIO_PA22       ((unsigned int) 1 << 22) // Pin Controlled by PA22
+#define AT91C_PA22_TPK6     ((unsigned int) AT91C_PIO_PA22) //  Trace Packet 
Port 6
+#define AT91C_PA22_RF1      ((unsigned int) AT91C_PIO_PA22) //  SSC1 Receive 
Frame Sync
+#define AT91C_PIO_PA23       ((unsigned int) 1 << 23) // Pin Controlled by PA23
+#define AT91C_PA23_TPK7     ((unsigned int) AT91C_PIO_PA23) //  Trace Packet 
Port 7
+#define AT91C_PA23_RTS0     ((unsigned int) AT91C_PIO_PA23) //  USART0 Ready 
To Send
+#define AT91C_PIO_PA24       ((unsigned int) 1 << 24) // Pin Controlled by PA24
+#define AT91C_PA24_TPK8     ((unsigned int) AT91C_PIO_PA24) //  Trace Packet 
Port 8
+#define AT91C_PA24_NPCS11   ((unsigned int) AT91C_PIO_PA24) //  SPI1 
Peripheral Chip Select 1
+#define AT91C_PIO_PA25       ((unsigned int) 1 << 25) // Pin Controlled by PA25
+#define AT91C_PA25_TPK9     ((unsigned int) AT91C_PIO_PA25) //  Trace Packet 
Port 9
+#define AT91C_PA25_NPCS12   ((unsigned int) AT91C_PIO_PA25) //  SPI1 
Peripheral Chip Select 2
+#define AT91C_PIO_PA26       ((unsigned int) 1 << 26) // Pin Controlled by PA26
+#define AT91C_PA26_TPK10    ((unsigned int) AT91C_PIO_PA26) //  Trace Packet 
Port 10
+#define AT91C_PA26_NPCS13   ((unsigned int) AT91C_PIO_PA26) //  SPI1 
Peripheral Chip Select 3
+#define AT91C_PIO_PA27       ((unsigned int) 1 << 27) // Pin Controlled by PA27
+#define AT91C_PA27_TPK11    ((unsigned int) AT91C_PIO_PA27) //  Trace Packet 
Port 11
+#define AT91C_PA27_NPCS01   ((unsigned int) AT91C_PIO_PA27) //  SPI0 
Peripheral Chip Select 1
+#define AT91C_PIO_PA28       ((unsigned int) 1 << 28) // Pin Controlled by PA28
+#define AT91C_PA28_TPK12    ((unsigned int) AT91C_PIO_PA28) //  Trace Packet 
Port 12
+#define AT91C_PA28_NPCS02   ((unsigned int) AT91C_PIO_PA28) //  SPI0 
Peripheral Chip Select 2
+#define AT91C_PIO_PA29       ((unsigned int) 1 << 29) // Pin Controlled by PA29
+#define AT91C_PA29_TPK13    ((unsigned int) AT91C_PIO_PA29) //  Trace Packet 
Port 13
+#define AT91C_PA29_NPCS03   ((unsigned int) AT91C_PIO_PA29) //  SPI0 
Peripheral Chip Select 3
+#define AT91C_PIO_PA3        ((unsigned int) 1 <<  3) // Pin Controlled by PA3
+#define AT91C_PA3_NPCS00   ((unsigned int) AT91C_PIO_PA3) //  SPI0 Peripheral 
Chip Select 0
+#define AT91C_PIO_PA30       ((unsigned int) 1 << 30) // Pin Controlled by PA30
+#define AT91C_PA30_TPK14    ((unsigned int) AT91C_PIO_PA30) //  Trace Packet 
Port 14
+#define AT91C_PA30_A23      ((unsigned int) AT91C_PIO_PA30) //  Address Bus 
bit 23
+#define AT91C_PIO_PA31       ((unsigned int) 1 << 31) // Pin Controlled by PA31
+#define AT91C_PA31_TPK15    ((unsigned int) AT91C_PIO_PA31) //  Trace Packet 
Port 15
+#define AT91C_PA31_A24      ((unsigned int) AT91C_PIO_PA31) //  Address Bus 
bit 24
+#define AT91C_PIO_PA4        ((unsigned int) 1 <<  4) // Pin Controlled by PA4
+#define AT91C_PA4_NPCS01   ((unsigned int) AT91C_PIO_PA4) //  SPI0 Peripheral 
Chip Select 1
+#define AT91C_PA4_MCDA1    ((unsigned int) AT91C_PIO_PA4) //  Multimedia Card 
A Data 1
+#define AT91C_PIO_PA5        ((unsigned int) 1 <<  5) // Pin Controlled by PA5
+#define AT91C_PA5_NPCS02   ((unsigned int) AT91C_PIO_PA5) //  SPI0 Peripheral 
Chip Select 2
+#define AT91C_PA5_MCDA2    ((unsigned int) AT91C_PIO_PA5) //  Multimedia Card 
A Data 2
+#define AT91C_PIO_PA6        ((unsigned int) 1 <<  6) // Pin Controlled by PA6
+#define AT91C_PA6_NPCS03   ((unsigned int) AT91C_PIO_PA6) //  SPI0 Peripheral 
Chip Select 3
+#define AT91C_PA6_MCDA3    ((unsigned int) AT91C_PIO_PA6) //  Multimedia Card 
A Data 3
+#define AT91C_PIO_PA7        ((unsigned int) 1 <<  7) // Pin Controlled by PA7
+#define AT91C_PA7_TWD      ((unsigned int) AT91C_PIO_PA7) //  TWI Two-wire 
Serial Data
+#define AT91C_PA7_PCK0     ((unsigned int) AT91C_PIO_PA7) //  PMC Programmable 
clock Output 0
+#define AT91C_PIO_PA8        ((unsigned int) 1 <<  8) // Pin Controlled by PA8
+#define AT91C_PA8_TWCK     ((unsigned int) AT91C_PIO_PA8) //  TWI Two-wire 
Serial Clock
+#define AT91C_PA8_PCK1     ((unsigned int) AT91C_PIO_PA8) //  PMC Programmable 
clock Output 1
+#define AT91C_PIO_PA9        ((unsigned int) 1 <<  9) // Pin Controlled by PA9
+#define AT91C_PA9_DRXD     ((unsigned int) AT91C_PIO_PA9) //  DBGU Debug 
Receive Data
+#define AT91C_PA9_PCK2     ((unsigned int) AT91C_PIO_PA9) //  PMC Programmable 
clock Output 2
+#define AT91C_PIO_PB0        ((unsigned int) 1 <<  0) // Pin Controlled by PB0
+#define AT91C_PB0_LCDVSYNC ((unsigned int) AT91C_PIO_PB0) //  LCD Vertical 
Synchronization
+#define AT91C_PIO_PB1        ((unsigned int) 1 <<  1) // Pin Controlled by PB1
+#define AT91C_PB1_LCDHSYNC ((unsigned int) AT91C_PIO_PB1) //  LCD Horizontal 
Synchronization
+#define AT91C_PIO_PB10       ((unsigned int) 1 << 10) // Pin Controlled by PB10
+#define AT91C_PB10_LCDD5    ((unsigned int) AT91C_PIO_PB10) //  LCD Data Bus 
Bit 5
+#define AT91C_PB10_LCDD10   ((unsigned int) AT91C_PIO_PB10) //  LCD Data Bus 
Bit 10
+#define AT91C_PIO_PB11       ((unsigned int) 1 << 11) // Pin Controlled by PB11
+#define AT91C_PB11_LCDD6    ((unsigned int) AT91C_PIO_PB11) //  LCD Data Bus 
Bit 6
+#define AT91C_PB11_LCDD11   ((unsigned int) AT91C_PIO_PB11) //  LCD Data Bus 
Bit 11
+#define AT91C_PIO_PB12       ((unsigned int) 1 << 12) // Pin Controlled by PB12
+#define AT91C_PB12_LCDD7    ((unsigned int) AT91C_PIO_PB12) //  LCD Data Bus 
Bit 7
+#define AT91C_PB12_LCDD12   ((unsigned int) AT91C_PIO_PB12) //  LCD Data Bus 
Bit 12
+#define AT91C_PIO_PB13       ((unsigned int) 1 << 13) // Pin Controlled by PB13
+#define AT91C_PB13_LCDD8    ((unsigned int) AT91C_PIO_PB13) //  LCD Data Bus 
Bit 8
+#define AT91C_PB13_LCDD13   ((unsigned int) AT91C_PIO_PB13) //  LCD Data Bus 
Bit 13
+#define AT91C_PIO_PB14       ((unsigned int) 1 << 14) // Pin Controlled by PB14
+#define AT91C_PB14_LCDD9    ((unsigned int) AT91C_PIO_PB14) //  LCD Data Bus 
Bit 9
+#define AT91C_PB14_LCDD14   ((unsigned int) AT91C_PIO_PB14) //  LCD Data Bus 
Bit 14
+#define AT91C_PIO_PB15       ((unsigned int) 1 << 15) // Pin Controlled by PB15
+#define AT91C_PB15_LCDD10   ((unsigned int) AT91C_PIO_PB15) //  LCD Data Bus 
Bit 10
+#define AT91C_PB15_LCDD15   ((unsigned int) AT91C_PIO_PB15) //  LCD Data Bus 
Bit 15
+#define AT91C_PIO_PB16       ((unsigned int) 1 << 16) // Pin Controlled by PB16
+#define AT91C_PB16_LCDD11   ((unsigned int) AT91C_PIO_PB16) //  LCD Data Bus 
Bit 11
+#define AT91C_PB16_LCDD19   ((unsigned int) AT91C_PIO_PB16) //  LCD Data Bus 
Bit 19
+#define AT91C_PIO_PB17       ((unsigned int) 1 << 17) // Pin Controlled by PB17
+#define AT91C_PB17_LCDD12   ((unsigned int) AT91C_PIO_PB17) //  LCD Data Bus 
Bit 12
+#define AT91C_PB17_LCDD20   ((unsigned int) AT91C_PIO_PB17) //  LCD Data Bus 
Bit 20
+#define AT91C_PIO_PB18       ((unsigned int) 1 << 18) // Pin Controlled by PB18
+#define AT91C_PB18_LCDD13   ((unsigned int) AT91C_PIO_PB18) //  LCD Data Bus 
Bit 13
+#define AT91C_PB18_LCDD21   ((unsigned int) AT91C_PIO_PB18) //  LCD Data Bus 
Bit 21
+#define AT91C_PIO_PB19       ((unsigned int) 1 << 19) // Pin Controlled by PB19
+#define AT91C_PB19_LCDD14   ((unsigned int) AT91C_PIO_PB19) //  LCD Data Bus 
Bit 14
+#define AT91C_PB19_LCDD22   ((unsigned int) AT91C_PIO_PB19) //  LCD Data Bus 
Bit 22
+#define AT91C_PIO_PB2        ((unsigned int) 1 <<  2) // Pin Controlled by PB2
+#define AT91C_PB2_LCDDOTCK ((unsigned int) AT91C_PIO_PB2) //  LCD Dot Clock
+#define AT91C_PB2_PCK0     ((unsigned int) AT91C_PIO_PB2) //  PMC Programmable 
clock Output 0
+#define AT91C_PIO_PB20       ((unsigned int) 1 << 20) // Pin Controlled by PB20
+#define AT91C_PB20_LCDD15   ((unsigned int) AT91C_PIO_PB20) //  LCD Data Bus 
Bit 15
+#define AT91C_PB20_LCDD23   ((unsigned int) AT91C_PIO_PB20) //  LCD Data Bus 
Bit 23
+#define AT91C_PIO_PB21       ((unsigned int) 1 << 21) // Pin Controlled by PB21
+#define AT91C_PB21_TF0      ((unsigned int) AT91C_PIO_PB21) //  SSC0 Transmit 
Frame Sync
+#define AT91C_PB21_LCDD16   ((unsigned int) AT91C_PIO_PB21) //  LCD Data Bus 
Bit 16
+#define AT91C_PIO_PB22       ((unsigned int) 1 << 22) // Pin Controlled by PB22
+#define AT91C_PB22_TK0      ((unsigned int) AT91C_PIO_PB22) //  SSC0 Transmit 
Clock
+#define AT91C_PB22_LCDD17   ((unsigned int) AT91C_PIO_PB22) //  LCD Data Bus 
Bit 17
+#define AT91C_PIO_PB23       ((unsigned int) 1 << 23) // Pin Controlled by PB23
+#define AT91C_PB23_TD0      ((unsigned int) AT91C_PIO_PB23) //  SSC0 Transmit 
Data
+#define AT91C_PB23_LCDD18   ((unsigned int) AT91C_PIO_PB23) //  LCD Data Bus 
Bit 18
+#define AT91C_PIO_PB24       ((unsigned int) 1 << 24) // Pin Controlled by PB24
+#define AT91C_PB24_RD0      ((unsigned int) AT91C_PIO_PB24) //  SSC0 Receive 
Data
+#define AT91C_PB24_LCDD19   ((unsigned int) AT91C_PIO_PB24) //  LCD Data Bus 
Bit 19
+#define AT91C_PIO_PB25       ((unsigned int) 1 << 25) // Pin Controlled by PB25
+#define AT91C_PB25_RK0      ((unsigned int) AT91C_PIO_PB25) //  SSC0 Receive 
Clock
+#define AT91C_PB25_LCDD20   ((unsigned int) AT91C_PIO_PB25) //  LCD Data Bus 
Bit 20
+#define AT91C_PIO_PB26       ((unsigned int) 1 << 26) // Pin Controlled by PB26
+#define AT91C_PB26_RF0      ((unsigned int) AT91C_PIO_PB26) //  SSC0 Receive 
Frame Sync
+#define AT91C_PB26_LCDD21   ((unsigned int) AT91C_PIO_PB26) //  LCD Data Bus 
Bit 21
+#define AT91C_PIO_PB27       ((unsigned int) 1 << 27) // Pin Controlled by PB27
+#define AT91C_PB27_NPCS11   ((unsigned int) AT91C_PIO_PB27) //  SPI1 
Peripheral Chip Select 1
+#define AT91C_PB27_LCDD22   ((unsigned int) AT91C_PIO_PB27) //  LCD Data Bus 
Bit 22
+#define AT91C_PIO_PB28       ((unsigned int) 1 << 28) // Pin Controlled by PB28
+#define AT91C_PB28_NPCS10   ((unsigned int) AT91C_PIO_PB28) //  SPI1 
Peripheral Chip Select 0
+#define AT91C_PB28_LCDD23   ((unsigned int) AT91C_PIO_PB28) //  LCD Data Bus 
Bit 23
+#define AT91C_PIO_PB29       ((unsigned int) 1 << 29) // Pin Controlled by PB29
+#define AT91C_PB29_SPCK1    ((unsigned int) AT91C_PIO_PB29) //  SPI1 Serial 
Clock
+#define AT91C_PB29_IRQ2     ((unsigned int) AT91C_PIO_PB29) //  Interrupt 
input 2
+#define AT91C_PIO_PB3        ((unsigned int) 1 <<  3) // Pin Controlled by PB3
+#define AT91C_PB3_LCDDEN   ((unsigned int) AT91C_PIO_PB3) //  LCD Data Enable
+#define AT91C_PIO_PB30       ((unsigned int) 1 << 30) // Pin Controlled by PB30
+#define AT91C_PB30_MISO1    ((unsigned int) AT91C_PIO_PB30) //  SPI1 Master In 
Slave
+#define AT91C_PB30_IRQ1     ((unsigned int) AT91C_PIO_PB30) //  Interrupt 
input 1
+#define AT91C_PIO_PB31       ((unsigned int) 1 << 31) // Pin Controlled by PB31
+#define AT91C_PB31_MOSI1    ((unsigned int) AT91C_PIO_PB31) //  SPI1 Master 
Out Slave
+#define AT91C_PB31_PCK2     ((unsigned int) AT91C_PIO_PB31) //  PMC 
Programmable clock Output 2
+#define AT91C_PIO_PB4        ((unsigned int) 1 <<  4) // Pin Controlled by PB4
+#define AT91C_PB4_LCDCC    ((unsigned int) AT91C_PIO_PB4) //  LCD Contrast 
Control
+#define AT91C_PB4_LCDD2    ((unsigned int) AT91C_PIO_PB4) //  LCD Data Bus Bit 
2
+#define AT91C_PIO_PB5        ((unsigned int) 1 <<  5) // Pin Controlled by PB5
+#define AT91C_PB5_LCDD0    ((unsigned int) AT91C_PIO_PB5) //  LCD Data Bus Bit 0
+#define AT91C_PB5_LCDD3    ((unsigned int) AT91C_PIO_PB5) //  LCD Data Bus Bit 
3
+#define AT91C_PIO_PB6        ((unsigned int) 1 <<  6) // Pin Controlled by PB6
+#define AT91C_PB6_LCDD1    ((unsigned int) AT91C_PIO_PB6) //  LCD Data Bus Bit 
1
+#define AT91C_PB6_LCDD4    ((unsigned int) AT91C_PIO_PB6) //  LCD Data Bus Bit 
4
+#define AT91C_PIO_PB7        ((unsigned int) 1 <<  7) // Pin Controlled by PB7
+#define AT91C_PB7_LCDD2    ((unsigned int) AT91C_PIO_PB7) //  LCD Data Bus Bit 
2
+#define AT91C_PB7_LCDD5    ((unsigned int) AT91C_PIO_PB7) //  LCD Data Bus Bit 
5
+#define AT91C_PIO_PB8        ((unsigned int) 1 <<  8) // Pin Controlled by PB8
+#define AT91C_PB8_LCDD3    ((unsigned int) AT91C_PIO_PB8) //  LCD Data Bus Bit 
3
+#define AT91C_PB8_LCDD6    ((unsigned int) AT91C_PIO_PB8) //  LCD Data Bus Bit 
6
+#define AT91C_PIO_PB9        ((unsigned int) 1 <<  9) // Pin Controlled by PB9
+#define AT91C_PB9_LCDD4    ((unsigned int) AT91C_PIO_PB9) //  LCD Data Bus Bit 
4
+#define AT91C_PB9_LCDD7    ((unsigned int) AT91C_PIO_PB9) //  LCD Data Bus Bit 
7
+#define AT91C_PIO_PC0        ((unsigned int) 1 <<  0) // Pin Controlled by PC0
+#define AT91C_PC0_SMOE     ((unsigned int) AT91C_PIO_PC0) //  SmartMedia 
Output Enable
+#define AT91C_PC0_NCS6     ((unsigned int) AT91C_PIO_PC0) //  Chip Select 6
+#define AT91C_PIO_PC1        ((unsigned int) 1 <<  1) // Pin Controlled by PC1
+#define AT91C_PC1_SMWE     ((unsigned int) AT91C_PIO_PC1) //  SmartMedia Write 
Enable
+#define AT91C_PC1_NCS7     ((unsigned int) AT91C_PIO_PC1) //  Chip Select 7
+#define AT91C_PIO_PC10       ((unsigned int) 1 << 10) // Pin Controlled by PC10
+#define AT91C_PC10_RTS0     ((unsigned int) AT91C_PIO_PC10) //  USART0 Ready 
To Send
+#define AT91C_PC10_SCK0     ((unsigned int) AT91C_PIO_PC10) //  USART0 Serial 
Clock
+#define AT91C_PIO_PC11       ((unsigned int) 1 << 11) // Pin Controlled by PC11
+#define AT91C_PC11_CTS0     ((unsigned int) AT91C_PIO_PC11) //  USART0 Clear 
To Send
+#define AT91C_PC11_FIQ      ((unsigned int) AT91C_PIO_PC11) //  AIC Fast 
Interrupt Input
+#define AT91C_PIO_PC12       ((unsigned int) 1 << 12) // Pin Controlled by PC12
+#define AT91C_PC12_TXD1     ((unsigned int) AT91C_PIO_PC12) //  USART1 
Transmit Data
+#define AT91C_PC12_NCS6     ((unsigned int) AT91C_PIO_PC12) //  Chip Select 6
+#define AT91C_PIO_PC13       ((unsigned int) 1 << 13) // Pin Controlled by PC13
+#define AT91C_PC13_RXD1     ((unsigned int) AT91C_PIO_PC13) //  USART1 Receive 
Data
+#define AT91C_PC13_NCS7     ((unsigned int) AT91C_PIO_PC13) //  Chip Select 7
+#define AT91C_PIO_PC14       ((unsigned int) 1 << 14) // Pin Controlled by PC14
+#define AT91C_PC14_TXD2     ((unsigned int) AT91C_PIO_PC14) //  USART2 
Transmit Data
+#define AT91C_PC14_NPCS12   ((unsigned int) AT91C_PIO_PC14) //  SPI1 
Peripheral Chip Select 2
+#define AT91C_PIO_PC15       ((unsigned int) 1 << 15) // Pin Controlled by PC15
+#define AT91C_PC15_RXD2     ((unsigned int) AT91C_PIO_PC15) //  USART2 Receive 
Data
+#define AT91C_PC15_NPCS13   ((unsigned int) AT91C_PIO_PC15) //  SPI1 
Peripheral Chip Select 3
+#define AT91C_PIO_PC16       ((unsigned int) 1 << 16) // Pin Controlled by PC16
+#define AT91C_PC16_D16      ((unsigned int) AT91C_PIO_PC16) //  Data Bus [16]
+#define AT91C_PC16_TCLK0    ((unsigned int) AT91C_PIO_PC16) //  Timer Counter 
0 external clock input
+#define AT91C_PIO_PC17       ((unsigned int) 1 << 17) // Pin Controlled by PC17
+#define AT91C_PC17_D17      ((unsigned int) AT91C_PIO_PC17) //  Data Bus [17]
+#define AT91C_PC17_TCLK1    ((unsigned int) AT91C_PIO_PC17) //  Timer Counter 
1 external clock input
+#define AT91C_PIO_PC18       ((unsigned int) 1 << 18) // Pin Controlled by PC18
+#define AT91C_PC18_D18      ((unsigned int) AT91C_PIO_PC18) //  Data Bus [18]
+#define AT91C_PC18_TCLK2    ((unsigned int) AT91C_PIO_PC18) //  Timer Counter 
2 external clock input
+#define AT91C_PIO_PC19       ((unsigned int) 1 << 19) // Pin Controlled by PC19
+#define AT91C_PC19_D19      ((unsigned int) AT91C_PIO_PC19) //  Data Bus [19]
+#define AT91C_PC19_TIOA0    ((unsigned int) AT91C_PIO_PC19) //  Timer Counter 
0 Multipurpose Timer I/O Pin A
+#define AT91C_PIO_PC2        ((unsigned int) 1 <<  2) // Pin Controlled by PC2
+#define AT91C_PC2_NWAIT    ((unsigned int) AT91C_PIO_PC2) //  NWAIT
+#define AT91C_PC2_IRQ0     ((unsigned int) AT91C_PIO_PC2) //  Interrupt input 0
+#define AT91C_PIO_PC20       ((unsigned int) 1 << 20) // Pin Controlled by PC20
+#define AT91C_PC20_D20      ((unsigned int) AT91C_PIO_PC20) //  Data Bus [20]
+#define AT91C_PC20_TIOB0    ((unsigned int) AT91C_PIO_PC20) //  Timer Counter 
0 Multipurpose Timer I/O Pin B
+#define AT91C_PIO_PC21       ((unsigned int) 1 << 21) // Pin Controlled by PC21
+#define AT91C_PC21_D21      ((unsigned int) AT91C_PIO_PC21) //  Data Bus [21]
+#define AT91C_PC21_TIOA1    ((unsigned int) AT91C_PIO_PC21) //  Timer Counter 
1 Multipurpose Timer I/O Pin A
+#define AT91C_PIO_PC22       ((unsigned int) 1 << 22) // Pin Controlled by PC22
+#define AT91C_PC22_D22      ((unsigned int) AT91C_PIO_PC22) //  Data Bus [22]
+#define AT91C_PC22_TIOB1    ((unsigned int) AT91C_PIO_PC22) //  Timer Counter 
1 Multipurpose Timer I/O Pin B
+#define AT91C_PIO_PC23       ((unsigned int) 1 << 23) // Pin Controlled by PC23
+#define AT91C_PC23_D23      ((unsigned int) AT91C_PIO_PC23) //  Data Bus [23]
+#define AT91C_PC23_TIOA2    ((unsigned int) AT91C_PIO_PC23) //  Timer Counter 
2 Multipurpose Timer I/O Pin A
+#define AT91C_PIO_PC24       ((unsigned int) 1 << 24) // Pin Controlled by PC24
+#define AT91C_PC24_D24      ((unsigned int) AT91C_PIO_PC24) //  Data Bus [24]
+#define AT91C_PC24_TIOB2    ((unsigned int) AT91C_PIO_PC24) //  Timer Counter 
2 Multipurpose Timer I/O Pin B
+#define AT91C_PIO_PC25       ((unsigned int) 1 << 25) // Pin Controlled by PC25
+#define AT91C_PC25_D25      ((unsigned int) AT91C_PIO_PC25) //  Data Bus [25]
+#define AT91C_PC25_TF2      ((unsigned int) AT91C_PIO_PC25) //  SSC2 Transmit 
Frame Sync
+#define AT91C_PIO_PC26       ((unsigned int) 1 << 26) // Pin Controlled by PC26
+#define AT91C_PC26_D26      ((unsigned int) AT91C_PIO_PC26) //  Data Bus [26]
+#define AT91C_PC26_TK2      ((unsigned int) AT91C_PIO_PC26) //  SSC2 Transmit 
Clock
+#define AT91C_PIO_PC27       ((unsigned int) 1 << 27) // Pin Controlled by PC27
+#define AT91C_PC27_D27      ((unsigned int) AT91C_PIO_PC27) //  Data Bus [27]
+#define AT91C_PC27_TD2      ((unsigned int) AT91C_PIO_PC27) //  SSC2 Transmit 
Data
+#define AT91C_PIO_PC28       ((unsigned int) 1 << 28) // Pin Controlled by PC28
+#define AT91C_PC28_D28      ((unsigned int) AT91C_PIO_PC28) //  Data Bus [28]
+#define AT91C_PC28_RD2      ((unsigned int) AT91C_PIO_PC28) //  SSC2 Receive 
Data
+#define AT91C_PIO_PC29       ((unsigned int) 1 << 29) // Pin Controlled by PC29
+#define AT91C_PC29_D29      ((unsigned int) AT91C_PIO_PC29) //  Data Bus [29]
+#define AT91C_PC29_RK2      ((unsigned int) AT91C_PIO_PC29) //  SSC2 Receive 
Clock
+#define AT91C_PIO_PC3        ((unsigned int) 1 <<  3) // Pin Controlled by PC3
+#define AT91C_PC3_A25_CFRNW ((unsigned int) AT91C_PIO_PC3) //  Address Bus[25] 
/ Compact Flash Read Not Write
+#define AT91C_PIO_PC30       ((unsigned int) 1 << 30) // Pin Controlled by PC30
+#define AT91C_PC30_D30      ((unsigned int) AT91C_PIO_PC30) //  Data Bus [30]
+#define AT91C_PC30_RF2      ((unsigned int) AT91C_PIO_PC30) //  SSC2 Receive 
Frame Sync
+#define AT91C_PIO_PC31       ((unsigned int) 1 << 31) // Pin Controlled by PC31
+#define AT91C_PC31_D31      ((unsigned int) AT91C_PIO_PC31) //  Data Bus [31]
+#define AT91C_PC31_PCK1     ((unsigned int) AT91C_PIO_PC31) //  PMC 
Programmable clock Output 1
+#define AT91C_PIO_PC4        ((unsigned int) 1 <<  4) // Pin Controlled by PC4
+#define AT91C_PC4_NCS4_CFCS0 ((unsigned int) AT91C_PIO_PC4) //  Chip Select 4 
/ CompactFlash Chip Select 0
+#define AT91C_PIO_PC5        ((unsigned int) 1 <<  5) // Pin Controlled by PC5
+#define AT91C_PC5_NCS5_CFCS1 ((unsigned int) AT91C_PIO_PC5) //  Chip Select 5 
/ CompactFlash Chip Select 1
+#define AT91C_PIO_PC6        ((unsigned int) 1 <<  6) // Pin Controlled by PC6
+#define AT91C_PC6_CFCE1    ((unsigned int) AT91C_PIO_PC6) //  CompactFlash 
Chip Enable 1
+#define AT91C_PIO_PC7        ((unsigned int) 1 <<  7) // Pin Controlled by PC7
+#define AT91C_PC7_CFCE2    ((unsigned int) AT91C_PIO_PC7) //  CompactFlash 
Chip Enable 2
+#define AT91C_PIO_PC8        ((unsigned int) 1 <<  8) // Pin Controlled by PC8
+#define AT91C_PC8_TXD0     ((unsigned int) AT91C_PIO_PC8) //  USART0 Transmit 
Data
+#define AT91C_PC8_PCK2     ((unsigned int) AT91C_PIO_PC8) //  PMC Programmable 
clock Output 2
+#define AT91C_PIO_PC9        ((unsigned int) 1 <<  9) // Pin Controlled by PC9
+#define AT91C_PC9_RXD0     ((unsigned int) AT91C_PIO_PC9) //  USART0 Receive 
Data
+#define AT91C_PC9_PCK3     ((unsigned int) AT91C_PIO_PC9) //  PMC Programmable 
clock Output 3
+
+

Added: head/sys/arm/at91/at91_pit.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/at91/at91_pit.c        Wed Jul 14 00:48:53 2010        
(r210040)
@@ -0,0 +1,233 @@
+/*-
+ * Copyright (c) 2010 Yohanes Nugroho.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/time.h>
+#include <sys/bus.h>
+#include <sys/resource.h>
+#include <sys/timetc.h>
+#include <sys/watchdog.h>
+
+#include <machine/bus.h>
+#include <machine/cpu.h>
+#include <machine/cpufunc.h>
+#include <machine/resource.h>
+#include <machine/frame.h>
+#include <machine/intr.h>
+
+#include <arm/at91/at91var.h>
+#include <arm/at91/at91_pitreg.h>
+#include <arm/at91/at91_pmcvar.h>
+#include <arm/at91/at91sam9g20reg.h>
+
+__FBSDID("$FreeBSD$");
+
+static struct at91pit_softc {
+       bus_space_tag_t         sc_st;
+       bus_space_handle_t      sc_sh;
+       device_t                sc_dev;
+} *pit_softc;
+
+#define RD4(off) \
+       bus_space_read_4(pit_softc->sc_st, pit_softc->sc_sh, (off))
+#define WR4(off, val) \
+       bus_space_write_4(pit_softc->sc_st, pit_softc->sc_sh, (off), (val))
+
+static unsigned at91pit_get_timecount(struct timecounter *tc);
+static int clock_intr(void *arg);
+
+static struct timecounter at91pit_timecounter = {
+       at91pit_get_timecount, /* get_timecount */
+       NULL, /* no poll_pps */
+       0xffffffffu, /* counter mask */
+       0, /* frequency */
+       "AT91SAM9261 timer", /* name */
+       1000 /* quality */
+};
+
+
+uint32_t 
+at91_pit_base(void);
+
+uint32_t
+at91_pit_size(void);
+
+static int
+at91pit_probe(device_t dev)
+{
+       device_set_desc(dev, "PIT");
+       return (0);
+}
+
+uint32_t 
+at91_pit_base(void)
+{
+       return (AT91SAM9G20_PIT_BASE);
+}
+
+uint32_t
+at91_pit_size(void)
+{
+       return (AT91SAM9G20_PIT_SIZE);
+}
+
+static int pit_rate;
+static int pit_cycle;
+static int pit_counter;
+
+static int
+at91pit_attach(device_t dev)
+{
+       struct at91_softc *sc = device_get_softc(device_get_parent(dev));
+       struct resource *irq;
+       int rid = 0;
+       void *ih;
+
+       pit_softc = device_get_softc(dev);
+       pit_softc->sc_st = sc->sc_st;
+       pit_softc->sc_dev = dev;
+       if (bus_space_subregion(sc->sc_st, sc->sc_sh, at91_pit_base(),
+           at91_pit_size(), &pit_softc->sc_sh) != 0)
+              panic("couldn't subregion pit registers");
+
+       irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 1, 1, 1,
+         RF_ACTIVE | RF_SHAREABLE);
+       if (!irq)
+               panic("Unable to allocate IRQ for the system timer");
+       else
+               bus_setup_intr(dev, irq, INTR_TYPE_CLK,
+                       clock_intr, NULL, NULL, &ih);
+       
+
+       device_printf(dev, "AT91SAM9x pit registered\n");
+       return (0);
+}
+
+static device_method_t at91pit_methods[] = {
+       DEVMETHOD(device_probe, at91pit_probe),
+       DEVMETHOD(device_attach, at91pit_attach),
+       {0,0},
+};
+
+static driver_t at91pit_driver = {
+       "at91_pit",
+       at91pit_methods,
+       sizeof(struct at91pit_softc),
+};
+
+static devclass_t at91pit_devclass;
+
+DRIVER_MODULE(at91_pit, atmelarm, at91pit_driver, at91pit_devclass, 0, 0);
+
+static int
+clock_intr(void *arg)
+{
+
+       struct trapframe *fp = arg;
+
+       if (RD4(PIT_SR) & PIT_PITS_DONE) {
+               uint32_t pivr = RD4(PIT_PIVR);
+               if (PIT_CNT(pivr)>1) {
+                       printf("cnt = %d\n", PIT_CNT(pivr));
+               }
+               pit_counter += pit_cycle;
+               hardclock(TRAPF_USERMODE(fp), TRAPF_PC(fp));
+               return (FILTER_HANDLED);
+       }
+       return (FILTER_STRAY);
+}
+
+static unsigned 
+at91pit_get_timecount(struct timecounter *tc)
+{
+       return pit_counter;
+}
+
+/*todo: review this*/
+void
+DELAY(int n)
+{
+       u_int32_t start, end, cur;
+
+       start = RD4(PIT_PIIR);
+       n = (n * 1000) / (at91_master_clock / 12);
+       if (n <= 0)
+               n = 1;
+       end = (start + n);
+       cur = start;
+       if (start > end) {
+               while (cur >= start || cur < end)
+                       cur = RD4(PIT_PIIR);
+       } else {
+               while (cur < end)
+                       cur = RD4(PIT_PIIR);
+       }
+}
+
+/*
+ * The 3 next functions must be implement with the futur PLL code.
+ */
+void
+cpu_startprofclock(void)
+{
+}
+
+void
+cpu_stopprofclock(void)
+{
+}
+
+#define HZ 100
+
+void
+cpu_initclocks(void)
+{
+       struct at91_pmc_clock *master;
+
+       master = at91_pmc_clock_ref("mck");
+       pit_rate =  master->hz / 16;
+       pit_cycle = (pit_rate + HZ/2) / HZ;     
+       at91pit_timecounter.tc_frequency = pit_rate;
+       WR4(PIT_MR, 0);
+
+       while (PIT_PIV(RD4(PIT_PIVR)) != 0);
+               
+       WR4(PIT_MR, (pit_cycle - 1) | PIT_IEN | PIT_EN);
+       tc_init(&at91pit_timecounter);
+}
+
+void
+cpu_reset(void)
+{
+       *(volatile int *)(AT91SAM9G20_BASE + AT91SAM9G20_RSTC_BASE +
+           RSTC_CR) = RSTC_PROCRST | RSTC_PERRST | RSTC_KEY;
+       while (1)
+               continue;
+}

Added: head/sys/arm/at91/at91_pitreg.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/at91/at91_pitreg.h     Wed Jul 14 00:48:53 2010        
(r210040)
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2009 Sylvestre Gallon.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* $FreeBSD$ */
+
+#ifndef ARM_AT91_AT91PITREG_H
+#define ARM_AT91_AT91PITREG_H
+
+#define PIT_MR         0x0 
+#define PIT_SR         0x4
+#define PIT_PIVR       0x8
+#define PIT_PIIR       0xc
+
+/* PIT_MR */
+#define PIT_PIV(x)     (x & 0xfffff) /* periodic interval value */
+#define PIT_CNT(x)     ((x >>20) & 0xfff) /* periodic interval counter */
+#define PIT_EN         (1 << 24) /* pit enable */
+#define PIT_IEN                (1 << 25) /* pit interrupt enable */
+
+/* PIT_SR */
+#define PIT_PITS_DONE  1 /* interrupt done */
+
+#endif /* ARM_AT91_AT91PITREG_H */

Modified: head/sys/arm/at91/at91_pmc.c
==============================================================================
--- head/sys/arm/at91/at91_pmc.c        Wed Jul 14 00:47:37 2010        
(r210039)
+++ head/sys/arm/at91/at91_pmc.c        Wed Jul 14 00:48:53 2010        
(r210040)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/frame.h>
 #include <machine/intr.h>
 #include <arm/at91/at91rm92reg.h>
+#include <arm/at91/at91sam9g20reg.h>
 
 #include <arm/at91/at91_pmcreg.h>
 #include <arm/at91/at91_pmcvar.h>
@@ -119,20 +120,54 @@ static struct at91_pmc_clock mck = {
        .refcnt = 0,
 };
 
+#ifdef AT91SAM9G20
+#define IRQ_UDP AT91SAM9G20_IRQ_UDP
+#define IRQ_UHP        AT91SAM9G20_IRQ_UHP
+#else
+#define IRQ_UDP AT91RM92_IRQ_UDP
+#define IRQ_UHP AT91RM92_IRQ_UHP
+#endif /* AT91SAM9G20 */
+
 static struct at91_pmc_clock udc_clk = {
        .name = "udc_clk",
        .parent = &mck,
-       .pmc_mask = 1 << AT91RM92_IRQ_UDP,
+       .pmc_mask = 1 << IRQ_UDP,
        .set_mode = &at91_pmc_set_periph_mode
 };
 
 static struct at91_pmc_clock ohci_clk = {
        .name = "ohci_clk",
        .parent = &mck,
-       .pmc_mask = 1 << AT91RM92_IRQ_UHP,
+       .pmc_mask = 1 << IRQ_UHP,
+       .set_mode = &at91_pmc_set_periph_mode
+};
+
+#ifdef AT91SAM9G20
+static struct at91_pmc_clock macb_clk = {
+       .name = "macb_clk",
+       .parent = &mck,
+
+       .pmc_mask = 1 << 21,
+       .set_mode = &at91_pmc_set_periph_mode
+};
+
+static struct at91_pmc_clock spi0_clk = {
+       .name = "spi0_clk",
+       .parent = &mck,
+
+       .pmc_mask = 1 << 12,
+       .set_mode = &at91_pmc_set_periph_mode
+};
+
+static struct at91_pmc_clock spi1_clk = {
+       .name = "spi1_clk",
+       .parent = &mck,
+       .pmc_mask = 1 << 13,
        .set_mode = &at91_pmc_set_periph_mode
 };
 
+#endif /* AT91SAM9G20 */
+
 static struct at91_pmc_clock *const clock_list[] = {
        &slck,
        &main_ck,
@@ -142,6 +177,11 @@ static struct at91_pmc_clock *const cloc
        &uhpck,
        &mck,
        &udc_clk,
+#ifdef AT91SAM9G20
+       &macb_clk,
+       &spi0_clk,
+       &spi1_clk,
+#endif /* AT91SAM9G20 */
        &ohci_clk
 };
 
@@ -257,15 +297,24 @@ at91_pmc_pll_rate(int freq, uint32_t reg
        uint32_t mul, div;
 
        div = reg & 0xff;
+#ifdef AT91SAM9G20
+       if (is_pllb)
+               mul = (reg >> 16) & 0x3f;
+       else
+               mul = (reg >> 16) & 0xff;
+#else
        mul = (reg >> 16) & 0x7ff;
+#endif
        if (div != 0 && mul != 0) {
                freq /= div;
                freq *= mul + 1;
        } else {
                freq = 0;
        }
+#ifndef AT91SAM9G20
        if (is_pllb && (reg & (1 << 28)))
                freq >>= 1;
+#endif
        return (freq);
 }
 
@@ -328,10 +377,12 @@ at91_pmc_init_clock(struct at91_pmc_soft
         */
        sc->pllb_init = at91_pmc_pll_calc(main_clock, 48000000 * 2) |0x10000000;
        pllb.hz = at91_pmc_pll_rate(main_clock, sc->pllb_init, 1);
-       WR4(sc, PMC_PCDR, (1 << AT91RM92_IRQ_UHP) | (1 << AT91RM92_IRQ_UDP));
+       WR4(sc, PMC_PCDR, (1 << IRQ_UHP) | (1 << IRQ_UDP));
        WR4(sc, PMC_SCDR, PMC_SCER_UHP | PMC_SCER_UDP);
        WR4(sc, CKGR_PLLBR, 0);
+#ifndef AT91SAM9G20
        WR4(sc, PMC_SCER, PMC_SCER_MCKUDP);
+#endif
 
        /*
         * MCK and PCU derive from one of the primary clocks.  Initialize

Modified: head/sys/arm/at91/at91_pmcreg.h
==============================================================================
--- head/sys/arm/at91/at91_pmcreg.h     Wed Jul 14 00:47:37 2010        
(r210039)
+++ head/sys/arm/at91/at91_pmcreg.h     Wed Jul 14 00:48:53 2010        
(r210040)
@@ -58,6 +58,21 @@
 #define PMC_SR         0x68            /* Status Register */
 #define PMC_IMR                0x6c            /* Interrupt Mask Register */
 
+#ifdef AT91SAM9G20
+/* PMC Specific AT91SAM9G20 */
+
+/* PMC System Clock Enable Register */
+/* PMC System Clock Disable Register */
+/* PMC System Clock StatusRegister */
+#define PMC_SCER_UHP   (1UL << 6)      /* UHP: USB Host Port Clock Enable */
+#define PMC_SCER_UDP   (1UL << 7)      /* UDP: USB Device Port Clock Enable */
+#define PMC_SCER_PCK0  (1UL << 8)      /* PCK0: Programmable Clock out en */
+#define PMC_SCER_PCK1  (1UL << 9)      /* PCK1: Programmable Clock out en */
+#define PMC_SCER_PCK2  (1UL << 10)     /* PCK2: Programmable Clock out en */
+#define PMC_SCER_PCK3  (1UL << 11)     /* PCK3: Programmable Clock out en */
+
+#else
+
 /* PMC System Clock Enable Register */
 /* PMC System Clock Disable Register */
 /* PMC System Clock StatusRegister */
@@ -70,6 +85,7 @@
 #define PMC_SCER_PCK2  (1UL << 11)     /* PCK2: Programmable Clock out en */
 #define PMC_SCER_PCK3  (1UL << 12)     /* PCK3: Programmable Clock out en */
 
+#endif /* AT91SAM9G20 */
 /* PMC Peripheral Clock Enable Register */
 /* PMC Peripheral Clock Disable Register */
 /* PMC Peripheral Clock Status Register */

Added: head/sys/arm/at91/at91sam9.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/at91/at91sam9.c        Wed Jul 14 00:48:53 2010        
(r210040)
@@ -0,0 +1,717 @@
+/*-
+ * Copyright (c) 2005 Olivier Houchard.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+
+#include <vm/vm.h>
+#include <vm/vm_kern.h>
+#include <vm/pmap.h>
+#include <vm/vm_page.h>
+#include <vm/vm_extern.h>
+
+#define        _ARM32_BUS_DMA_PRIVATE
+#include <machine/bus.h>
+#include <machine/intr.h>
+#include <arm/at91/at91_aicreg.h>
+#include <arm/at91/at91sam9g20reg.h>
+#include <arm/at91/at91var.h>
+
+static struct at91_softc *at91_softc;
+
+static void at91_eoi(void *);
+
+uint32_t at91_master_clock = AT91C_MASTER_CLOCK;
+
+static int
+at91_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
+    bus_space_handle_t *bshp)
+{
+       vm_paddr_t pa, endpa;
+
+       pa = trunc_page(bpa);
+       if (pa >= 0xfff00000) {
+               *bshp = pa - 0xf0000000 + 0xd0000000;
+               return (0);
+       }
+       if (pa >= 0xdff00000)
+               return (0);
+       endpa = round_page(bpa + size);
+
+       *bshp = (vm_offset_t)pmap_mapdev(pa, endpa - pa);
+                      
+       return (0);
+}
+
+static void
+at91_bs_unmap(void *t, bus_space_handle_t h, bus_size_t size)
+{
+       vm_offset_t va, endva;
+
+       va = trunc_page((vm_offset_t)t);
+       endva = va + round_page(size);
+
+       /* Free the kernel virtual mapping. */
+       kmem_free(kernel_map, va, endva - va);
+}
+
+static int
+at91_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
+    bus_size_t size, bus_space_handle_t *nbshp)
+{
+
+       *nbshp = bsh + offset;
+       return (0);
+}
+
+static void
+at91_barrier(void *t, bus_space_handle_t bsh, bus_size_t size, bus_size_t b, 
+    int a)
+{
+}
+
+bs_protos(generic);
+bs_protos(generic_armv4);
+
+struct bus_space at91_bs_tag = {
+       /* cookie */
+       (void *) 0,
+
+       /* mapping/unmapping */
+       at91_bs_map,
+       at91_bs_unmap,
+       at91_bs_subregion,
+
+       /* allocation/deallocation */
+       NULL,
+       NULL,
+
+       /* barrier */
+       at91_barrier,
+
+       /* read (single) */
+       generic_bs_r_1,
+       generic_armv4_bs_r_2,
+       generic_bs_r_4,
+       NULL,
+
+       /* read multiple */
+       generic_bs_rm_1,
+       generic_armv4_bs_rm_2,
+       generic_bs_rm_4,
+       NULL,
+
+       /* read region */
+       generic_bs_rr_1,
+       generic_armv4_bs_rr_2,
+       generic_bs_rr_4,
+       NULL,
+
+       /* write (single) */
+       generic_bs_w_1,
+       generic_armv4_bs_w_2,
+       generic_bs_w_4,
+       NULL,
+
+       /* write multiple */
+       generic_bs_wm_1,
+       generic_armv4_bs_wm_2,
+       generic_bs_wm_4,
+       NULL,
+
+       /* write region */
+       NULL,
+       generic_armv4_bs_wr_2,
+       generic_bs_wr_4,
+       NULL,
+
+       /* set multiple */
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+
+       /* set region */
+       NULL,
+       generic_armv4_bs_sr_2,
+       generic_bs_sr_4,
+       NULL,
+
+       /* copy */
+       NULL,
+       generic_armv4_bs_c_2,
+       NULL,
+       NULL,
+
+       /* read (single) stream */
+       generic_bs_r_1,
+       generic_armv4_bs_r_2,
+       generic_bs_r_4,
+       NULL,
+
+       /* read multiple stream */
+       generic_bs_rm_1,
+       generic_armv4_bs_rm_2,
+       generic_bs_rm_4,
+       NULL,
+
+       /* read region stream */
+       generic_bs_rr_1,
+       generic_armv4_bs_rr_2,
+       generic_bs_rr_4,
+       NULL,
+
+       /* write (single) stream */
+       generic_bs_w_1,
+       generic_armv4_bs_w_2,
+       generic_bs_w_4,
+       NULL,
+
+       /* write multiple stream */
+       generic_bs_wm_1,
+       generic_armv4_bs_wm_2,
+       generic_bs_wm_4,
+       NULL,
+
+       /* write region stream */
+       NULL,
+       generic_armv4_bs_wr_2,
+       generic_bs_wr_4,
+       NULL,
+};
+
+static int
+at91_probe(device_t dev)
+{
+       device_set_desc(dev, "AT91 device bus");

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to