diff options
Diffstat (limited to 'arch/arm/mach-at91')
151 files changed, 10122 insertions, 12082 deletions
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index c015b684b4f..45b55e0f0db 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -1,491 +1,230 @@  if ARCH_AT91 -config HAVE_AT91_DATAFLASH_CARD +config HAVE_AT91_UTMI  	bool -config HAVE_NAND_ATMEL_BUSWIDTH_16 +config HAVE_AT91_USB_CLK  	bool -config HAVE_AT91_USART3 +config HAVE_AT91_DBGU0  	bool -config HAVE_AT91_USART4 +config HAVE_AT91_DBGU1  	bool -config HAVE_AT91_USART5 +config AT91_USE_OLD_CLK  	bool -menu "Atmel AT91 System-on-Chip" +config AT91_PMC_UNIT +	bool +	default !ARCH_AT91X40 -choice -	prompt "Atmel AT91 Processor" +config COMMON_CLK_AT91 +	bool +	default AT91_PMC_UNIT && USE_OF && !AT91_USE_OLD_CLK +	select COMMON_CLK -config ARCH_AT91RM9200 -	bool "AT91RM9200" -	select CPU_ARM920T -	select GENERIC_CLOCKEVENTS -	select HAVE_AT91_USART3 +config OLD_CLK_AT91 +	bool +	default AT91_PMC_UNIT && AT91_USE_OLD_CLK -config ARCH_AT91SAM9260 -	bool "AT91SAM9260 or AT91SAM9XE" -	select CPU_ARM926T -	select GENERIC_CLOCKEVENTS -	select HAVE_AT91_USART3 -	select HAVE_AT91_USART4 -	select HAVE_AT91_USART5 -	select HAVE_NET_MACB +config AT91_SAM9_ALT_RESET +	bool +	default !ARCH_AT91X40 -config ARCH_AT91SAM9261 -	bool "AT91SAM9261" -	select CPU_ARM926T -	select GENERIC_CLOCKEVENTS -	select HAVE_FB_ATMEL +config AT91_SAM9G45_RESET +	bool +	default !ARCH_AT91X40 -config ARCH_AT91SAM9G10 -	bool "AT91SAM9G10" -	select CPU_ARM926T -	select GENERIC_CLOCKEVENTS -	select HAVE_FB_ATMEL +config AT91_SAM9_TIME +	bool -config ARCH_AT91SAM9263 -	bool "AT91SAM9263" -	select CPU_ARM926T -	select GENERIC_CLOCKEVENTS -	select HAVE_FB_ATMEL -	select HAVE_NET_MACB +config HAVE_AT91_SMD +	bool -config ARCH_AT91SAM9RL -	bool "AT91SAM9RL" +config SOC_AT91SAM9 +	bool +	select AT91_SAM9_TIME  	select CPU_ARM926T  	select GENERIC_CLOCKEVENTS -	select HAVE_AT91_USART3 -	select HAVE_FB_ATMEL +	select MULTI_IRQ_HANDLER +	select SPARSE_IRQ -config ARCH_AT91SAM9G20 -	bool "AT91SAM9G20" -	select CPU_ARM926T +config SOC_SAMA5 +	bool +	select AT91_SAM9_TIME +	select CPU_V7  	select GENERIC_CLOCKEVENTS -	select HAVE_AT91_USART3 -	select HAVE_AT91_USART4 -	select HAVE_AT91_USART5 -	select HAVE_NET_MACB +	select MULTI_IRQ_HANDLER +	select SPARSE_IRQ +	select USE_OF -config ARCH_AT91SAM9G45 -	bool "AT91SAM9G45" -	select CPU_ARM926T -	select GENERIC_CLOCKEVENTS -	select HAVE_AT91_USART3 -	select HAVE_FB_ATMEL -	select HAVE_NET_MACB +menu "Atmel AT91 System-on-Chip" -config ARCH_AT91CAP9 -	bool "AT91CAP9" -	select CPU_ARM926T -	select GENERIC_CLOCKEVENTS -	select HAVE_FB_ATMEL +choice -config ARCH_AT572D940HF -	bool "AT572D940HF" -	select CPU_ARM926T -	select GENERIC_CLOCKEVENTS +	prompt "Core type"  config ARCH_AT91X40 -	bool "AT91x40" +	bool "ARM7 AT91X40" +	depends on !MMU +	select CPU_ARM7TDMI  	select ARCH_USES_GETTIMEOFFSET +	select MULTI_IRQ_HANDLER +	select SPARSE_IRQ -endchoice - -config AT91_PMC_UNIT -	bool -	default !ARCH_AT91X40 - -# ---------------------------------------------------------- - -if ARCH_AT91RM9200 - -comment "AT91RM9200 Board Type" - -config MACH_ONEARM -	bool "Ajeco 1ARM Single Board Computer" -	help -	  Select this if you are using Ajeco's 1ARM Single Board Computer. -	  <http://www.ajeco.fi/> - -config ARCH_AT91RM9200DK -	bool "Atmel AT91RM9200-DK Development board" -	select HAVE_AT91_DATAFLASH_CARD -	help -	  Select this if you are using Atmel's AT91RM9200-DK Development board. -	  (Discontinued) - -config MACH_AT91RM9200EK -	bool "Atmel AT91RM9200-EK Evaluation Kit" -	select HAVE_AT91_DATAFLASH_CARD -	help -	  Select this if you are using Atmel's AT91RM9200-EK Evaluation Kit. -	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3507> - -config MACH_CSB337 -	bool "Cogent CSB337" -	help -	  Select this if you are using Cogent's CSB337 board. -	  <http://www.cogcomp.com/csb_csb337.htm> - -config MACH_CSB637 -	bool "Cogent CSB637" -	help -	  Select this if you are using Cogent's CSB637 board. -	  <http://www.cogcomp.com/csb_csb637.htm> - -config MACH_CARMEVA -	bool "Conitec ARM&EVA" -	help -	  Select this if you are using Conitec's AT91RM9200-MCU-Module. -	  <http://www.conitec.net/english/linuxboard.php> - -config MACH_ATEB9200 -	bool "Embest ATEB9200" -	help -	  Select this if you are using Embest's ATEB9200 board. -	  <http://www.embedinfo.com/english/product/ATEB9200.asp> - -config MACH_KB9200 -	bool "KwikByte KB920x" -	help -	  Select this if you are using KwikByte's KB920x board. -	  <http://www.kwikbyte.com/KB9202.html> - -config MACH_PICOTUX2XX -	bool "picotux 200" -	help -	  Select this if you are using a picotux 200. -	  <http://www.picotux.com/> - -config MACH_KAFA -	bool "Sperry-Sun KAFA board" -	help -	  Select this if you are using Sperry-Sun's KAFA board. - -config MACH_ECBAT91 -	bool "emQbit ECB_AT91 SBC" -	select HAVE_AT91_DATAFLASH_CARD -	help -	  Select this if you are using emQbit's ECB_AT91 board. -	  <http://wiki.emqbit.com/free-ecb-at91> - -config MACH_YL9200 -	bool "ucDragon YL-9200" -	help -	  Select this if you are using the ucDragon YL-9200 board. - -config MACH_CPUAT91 -	bool "Eukrea CPUAT91" -	help -	  Select this if you are using the Eukrea Electromatique's -	  CPUAT91 board <http://www.eukrea.com/>. - -config MACH_ECO920 -	bool "eco920" -	help -	  Select this if you are using the eco920 board - -endif - -# ---------------------------------------------------------- - -if ARCH_AT91SAM9260 - -comment "AT91SAM9260 Variants" - -config ARCH_AT91SAM9260_SAM9XE -	bool "AT91SAM9XE" -	help -	  Select this if you are using Atmel's AT91SAM9XE System-on-Chip. -	  They are basically AT91SAM9260s with various sizes of embedded Flash. - -comment "AT91SAM9260 / AT91SAM9XE Board Type" - -config MACH_AT91SAM9260EK -	bool "Atmel AT91SAM9260-EK / AT91SAM9XE Evaluation Kit" -	select HAVE_AT91_DATAFLASH_CARD -	select HAVE_NAND_ATMEL_BUSWIDTH_16 -	help -	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit -	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933> - -config MACH_CAM60 -	bool "KwikByte KB9260 (CAM60) board" -	help -	  Select this if you are using KwikByte's KB9260 (CAM60) board based on the Atmel AT91SAM9260. -	  <http://www.kwikbyte.com/KB9260.html> - -config MACH_SAM9_L9260 -	bool "Olimex SAM9-L9260 board" -	select HAVE_AT91_DATAFLASH_CARD -	help -	  Select this if you are using Olimex's SAM9-L9260 board based on the Atmel AT91SAM9260. -	  <http://www.olimex.com/dev/sam9-L9260.html> - -config MACH_AFEB9260 -	bool "Custom afeb9260 board v1" -	help -	  Select this if you are using custom afeb9260 board based on -	  open hardware design. Select this for revision 1 of the board. -	  <svn://194.85.238.22/home/users/george/svn/arm9eb> -	  <http://groups.google.com/group/arm9fpga-evolution-board> - -config MACH_USB_A9260 -	bool "CALAO USB-A9260" -	help -	  Select this if you are using a Calao Systems USB-A9260. -	  <http://www.calao-systems.com> - -config MACH_QIL_A9260 -	bool "CALAO QIL-A9260 board" -	help -	  Select this if you are using a Calao Systems QIL-A9260 Board. -	  <http://www.calao-systems.com> - -config MACH_CPU9260 -	bool "Eukrea CPU9260 board" -	help -	  Select this if you are using a Eukrea Electromatique's -	  CPU9260 Board <http://www.eukrea.com/> - -config MACH_FLEXIBITY -	bool "Flexibity Connect board" -	help -	  Select this if you are using Flexibity Connect board -	  <http://www.flexibity.com> - -endif - -# ---------------------------------------------------------- - -if ARCH_AT91SAM9261 - -comment "AT91SAM9261 Board Type" - -config MACH_AT91SAM9261EK -	bool "Atmel AT91SAM9261-EK Evaluation Kit" -	select HAVE_AT91_DATAFLASH_CARD -	select HAVE_NAND_ATMEL_BUSWIDTH_16 -	help -	  Select this if you are using Atmel's AT91SAM9261-EK Evaluation Kit. -	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3820> - -endif - -# ---------------------------------------------------------- - -if ARCH_AT91SAM9G10 - -comment "AT91SAM9G10 Board Type" - -config MACH_AT91SAM9G10EK -	bool "Atmel AT91SAM9G10-EK Evaluation Kit" -	select HAVE_AT91_DATAFLASH_CARD -	select HAVE_NAND_ATMEL_BUSWIDTH_16 -	help -	  Select this if you are using Atmel's AT91SAM9G10-EK Evaluation Kit. -	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4588> - -endif - -# ---------------------------------------------------------- - -if ARCH_AT91SAM9263 - -comment "AT91SAM9263 Board Type" - -config MACH_AT91SAM9263EK -	bool "Atmel AT91SAM9263-EK Evaluation Kit" -	select HAVE_AT91_DATAFLASH_CARD -	select HAVE_NAND_ATMEL_BUSWIDTH_16  	help -	  Select this if you are using Atmel's AT91SAM9263-EK Evaluation Kit. -	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4057> +	  Select this if you are using one of Atmel's AT91X40 SoC. -config MACH_USB_A9263 -	bool "CALAO USB-A9263" +config SOC_SAM_V4_V5 +	bool "ARM9 AT91SAM9/AT91RM9200"  	help -	  Select this if you are using a Calao Systems USB-A9263. -	  <http://www.calao-systems.com> +	  Select this if you are using one of Atmel's AT91SAM9 or +	  AT91RM9200 SoC. -config MACH_NEOCORE926 -	bool "Adeneo NEOCORE926" -	select HAVE_AT91_DATAFLASH_CARD +config SOC_SAM_V7 +	bool "Cortex A5"  	help -	  Select this if you are using the Adeneo Neocore 926 board. +	  Select this if you are using one of Atmel's SAMA5D3 SoC. -endif - -# ---------------------------------------------------------- - -if ARCH_AT91SAM9RL +endchoice -comment "AT91SAM9RL Board Type" +comment "Atmel AT91 Processor" -config MACH_AT91SAM9RLEK -	bool "Atmel AT91SAM9RL-EK Evaluation Kit" +if SOC_SAM_V7 +config SOC_SAMA5D3 +	bool "SAMA5D3 family" +	select SOC_SAMA5 +	select HAVE_FB_ATMEL +	select HAVE_AT91_DBGU1 +	select HAVE_AT91_UTMI +	select HAVE_AT91_SMD +	select HAVE_AT91_USB_CLK  	help -	  Select this if you are using Atmel's AT91SAM9RL-EK Evaluation Kit. - +	  Select this if you are using one of Atmel's SAMA5D3 family SoC. +	  This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35, SAMA5D36.  endif -# ---------------------------------------------------------- - -if ARCH_AT91SAM9G20 - -comment "AT91SAM9G20 Board Type" - -config MACH_AT91SAM9G20EK -	bool "Atmel AT91SAM9G20-EK Evaluation Kit" -	select HAVE_AT91_DATAFLASH_CARD -	select HAVE_NAND_ATMEL_BUSWIDTH_16 -	help -	  Select this if you are using Atmel's AT91SAM9G20-EK Evaluation Kit -	  that embeds only one SD/MMC slot. - -config MACH_AT91SAM9G20EK_2MMC -	depends on MACH_AT91SAM9G20EK -	bool "Atmel AT91SAM9G20-EK Evaluation Kit with 2 SD/MMC Slots" -	select HAVE_NAND_ATMEL_BUSWIDTH_16 -	help -	  Select this if you are using an Atmel AT91SAM9G20-EK Evaluation Kit -	  with 2 SD/MMC Slots. This is the case for AT91SAM9G20-EK rev. C and -	  onwards. - -config MACH_CPU9G20 -	bool "Eukrea CPU9G20 board" -	help -	  Select this if you are using a Eukrea Electromatique's -	  CPU9G20 Board <http://www.eukrea.com/> - -config MACH_PORTUXG20 -	bool "taskit PortuxG20" -	help -	  Select this if you are using taskit's PortuxG20. -	  <http://www.taskit.de/en/> - -config MACH_STAMP9G20 -	bool "taskit Stamp9G20 CPU module" -	help -	  Select this if you are using taskit's Stamp9G20 CPU module on its -	  evaluation board. -	  <http://www.taskit.de/en/> - -config MACH_PCONTROL_G20 -	bool "PControl G20 CPU module" +if SOC_SAM_V4_V5 +config SOC_AT91RM9200 +	bool "AT91RM9200" +	select CPU_ARM920T +	select GENERIC_CLOCKEVENTS +	select HAVE_AT91_DBGU0 +	select MULTI_IRQ_HANDLER +	select SPARSE_IRQ +	select AT91_USE_OLD_CLK +	select HAVE_AT91_USB_CLK + +config SOC_AT91SAM9260 +	bool "AT91SAM9260, AT91SAM9XE or AT91SAM9G20" +	select HAVE_AT91_DBGU0 +	select SOC_AT91SAM9 +	select AT91_USE_OLD_CLK +	select HAVE_AT91_USB_CLK +	help +	  Select this if you are using one of Atmel's AT91SAM9260, AT91SAM9XE +	  or AT91SAM9G20 SoC. + +config SOC_AT91SAM9261 +	bool "AT91SAM9261 or AT91SAM9G10" +	select HAVE_AT91_DBGU0 +	select HAVE_FB_ATMEL +	select SOC_AT91SAM9 +	select HAVE_AT91_USB_CLK  	help -	  Select this if you are using taskit's Stamp9G20 CPU module on this -	  carrier board, beeing the decentralized unit of a building automation -	  system; featuring nvram, eth-switch, iso-rs485, display, io -endif - -if (ARCH_AT91SAM9260 || ARCH_AT91SAM9G20) -comment "AT91SAM9260/AT91SAM9G20 boards" +	  Select this if you are using one of Atmel's AT91SAM9261 or AT91SAM9G10 SoC. -config MACH_SNAPPER_9260 -        bool "Bluewater Systems Snapper 9260/9G20 module" -        help -          Select this if you are using the Bluewater Systems Snapper 9260 or -          Snapper 9G20 modules. -          <http://www.bluewatersys.com/> -endif - -# ---------------------------------------------------------- - -if ARCH_AT91SAM9G45 +config SOC_AT91SAM9263 +	bool "AT91SAM9263" +	select HAVE_AT91_DBGU1 +	select HAVE_FB_ATMEL +	select SOC_AT91SAM9 +	select AT91_USE_OLD_CLK +	select HAVE_AT91_USB_CLK -comment "AT91SAM9G45 Board Type" +config SOC_AT91SAM9RL +	bool "AT91SAM9RL" +	select HAVE_AT91_DBGU0 +	select HAVE_FB_ATMEL +	select SOC_AT91SAM9 +	select HAVE_AT91_UTMI -config MACH_AT91SAM9M10G45EK -	bool "Atmel AT91SAM9M10G45-EK Evaluation Kits" -	select HAVE_NAND_ATMEL_BUSWIDTH_16 +config SOC_AT91SAM9G45 +	bool "AT91SAM9G45 or AT91SAM9M10 families" +	select HAVE_AT91_DBGU1 +	select HAVE_FB_ATMEL +	select SOC_AT91SAM9 +	select AT91_USE_OLD_CLK +	select HAVE_AT91_UTMI +	select HAVE_AT91_USB_CLK  	help -	  Select this if you are using Atmel's AT91SAM9G45-EKES Evaluation Kit. -	  "ES" at the end of the name means that this board is an -	  Engineering Sample. - -endif - -# ---------------------------------------------------------- +	  Select this if you are using one of Atmel's AT91SAM9G45 family SoC. +	  This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and AT91SAM9M11. -if ARCH_AT91CAP9 - -comment "AT91CAP9 Board Type" - -config MACH_AT91CAP9ADK -	bool "Atmel AT91CAP9A-DK Evaluation Kit" -	select HAVE_AT91_DATAFLASH_CARD -	select HAVE_NAND_ATMEL_BUSWIDTH_16 +config SOC_AT91SAM9X5 +	bool "AT91SAM9x5 family" +	select HAVE_AT91_DBGU0 +	select HAVE_FB_ATMEL +	select SOC_AT91SAM9 +	select HAVE_AT91_UTMI +	select HAVE_AT91_SMD +	select HAVE_AT91_USB_CLK +	help +	  Select this if you are using one of Atmel's AT91SAM9x5 family SoC. +	  This means that your SAM9 name finishes with a '5' (except if it is +	  AT91SAM9G45!). +	  This support covers AT91SAM9G15, AT91SAM9G25, AT91SAM9X25, AT91SAM9G35 +	  and AT91SAM9X35. + +config SOC_AT91SAM9N12 +	bool "AT91SAM9N12 family" +	select HAVE_AT91_DBGU0 +	select HAVE_FB_ATMEL +	select SOC_AT91SAM9 +	select HAVE_AT91_USB_CLK  	help -	  Select this if you are using Atmel's AT91CAP9A-DK Evaluation Kit. -	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4138> - -endif +	  Select this if you are using Atmel's AT91SAM9N12 SoC.  # ---------------------------------------------------------- +endif # SOC_SAM_V4_V5 -if ARCH_AT572D940HF - -comment "AT572D940HF Board Type" - -config MACH_AT572D940HFEB -	bool "AT572D940HF-EK" -	depends on ARCH_AT572D940HF -	select HAVE_AT91_DATAFLASH_CARD -	select HAVE_NAND_ATMEL_BUSWIDTH_16 -	help -	  Select this if you are using Atmel's AT572D940HF-EK evaluation kit. -	  <http://www.atmel.com/products/diopsis/default.asp> +if SOC_SAM_V4_V5 || ARCH_AT91X40 +source arch/arm/mach-at91/Kconfig.non_dt  endif -# ---------------------------------------------------------- - -if ARCH_AT91X40 - -comment "AT91X40 Board Type" +comment "Generic Board Type" -config MACH_AT91EB01 -	bool "Atmel AT91EB01 Evaluation Kit" +config MACH_AT91RM9200_DT +	bool "Atmel AT91RM9200 Evaluation Kits with device-tree support" +	depends on SOC_AT91RM9200 +	select USE_OF  	help -	  Select this if you are using Atmel's AT91EB01 Evaluation Kit. -	  It is also a popular target for simulators such as GDB's -	  ARM simulator (commonly known as the ARMulator) and the -	  Skyeye simulator. +	  Select this if you want to experiment device-tree with +	  an Atmel RM9200 Evaluation Kit. -endif - -# ---------------------------------------------------------- - -comment "AT91 Board Options" - -config MTD_AT91_DATAFLASH_CARD -	bool "Enable DataFlash Card support" -	depends on HAVE_AT91_DATAFLASH_CARD +config MACH_AT91SAM9_DT +	bool "Atmel AT91SAM Evaluation Kits with device-tree support" +	depends on SOC_AT91SAM9 +	select USE_OF  	help -	  Enable support for the DataFlash card. +	  Select this if you want to experiment device-tree with +	  an Atmel Evaluation Kit. -config MTD_NAND_ATMEL_BUSWIDTH_16 -	bool "Enable 16-bit data bus interface to NAND flash" -	depends on HAVE_NAND_ATMEL_BUSWIDTH_16 +config MACH_SAMA5_DT +	bool "Atmel SAMA5 Evaluation Kits with device-tree support" +	depends on SOC_SAMA5 +	select USE_OF +	select PHYLIB if NETDEVICES  	help -	  On AT91SAM926x boards both types of NAND flash can be present -	  (8 and 16 bit data bus width). +	  Select this if you want to experiment device-tree with +	  an Atmel Evaluation Kit.  # ----------------------------------------------------------  comment "AT91 Feature Selections" -config AT91_PROGRAMMABLE_CLOCKS -	bool "Programmable Clocks" -	help -	  Select this if you need to program one or more of the PCK0..PCK3 -	  programmable clock outputs. -  config AT91_SLOW_CLOCK  	bool "Suspend-to-RAM disables main oscillator"  	depends on SUSPEND @@ -515,36 +254,6 @@ config AT91_TIMER_HZ  	  system clock (of at least several MHz), rounding is less of a  	  problem so it can be safer to use a decimal values like 100. -choice -	prompt "Select a UART for early kernel messages" - -config AT91_EARLY_DBGU -	bool "DBGU" - -config AT91_EARLY_USART0 -	bool "USART0" - -config AT91_EARLY_USART1 -	bool "USART1" - -config AT91_EARLY_USART2 -	bool "USART2" -	depends on ! ARCH_AT91X40 - -config AT91_EARLY_USART3 -	bool "USART3" -	depends on HAVE_AT91_USART3 - -config AT91_EARLY_USART4 -	bool "USART4" -	depends on HAVE_AT91_USART4 - -config AT91_EARLY_USART5 -	bool "USART5" -	depends on HAVE_AT91_USART5 - -endchoice -  endmenu  endif diff --git a/arch/arm/mach-at91/Kconfig.non_dt b/arch/arm/mach-at91/Kconfig.non_dt new file mode 100644 index 00000000000..44ace320d2e --- /dev/null +++ b/arch/arm/mach-at91/Kconfig.non_dt @@ -0,0 +1,350 @@ +menu "Atmel Non-DT world" + +config HAVE_AT91_DATAFLASH_CARD +	bool + +choice +	prompt "Atmel AT91 Processor Devices for non DT boards" +	depends on !ARCH_AT91X40 + +config ARCH_AT91_NONE +	bool "None" + +config ARCH_AT91RM9200 +	bool "AT91RM9200" +	select SOC_AT91RM9200 +	select AT91_USE_OLD_CLK + +config ARCH_AT91SAM9260 +	bool "AT91SAM9260 or AT91SAM9XE or AT91SAM9G20" +	select SOC_AT91SAM9260 +	select AT91_USE_OLD_CLK + +config ARCH_AT91SAM9261 +	bool "AT91SAM9261 or AT91SAM9G10" +	select SOC_AT91SAM9261 +	select AT91_USE_OLD_CLK + +config ARCH_AT91SAM9263 +	bool "AT91SAM9263" +	select SOC_AT91SAM9263 +	select AT91_USE_OLD_CLK + +config ARCH_AT91SAM9RL +	bool "AT91SAM9RL" +	select SOC_AT91SAM9RL +	select AT91_USE_OLD_CLK + +config ARCH_AT91SAM9G45 +	bool "AT91SAM9G45" +	select SOC_AT91SAM9G45 +	select AT91_USE_OLD_CLK + +endchoice + +config ARCH_AT91SAM9G20 +	bool +	select ARCH_AT91SAM9260 + +config ARCH_AT91SAM9G10 +	bool +	select ARCH_AT91SAM9261 + +# ---------------------------------------------------------- + +if ARCH_AT91RM9200 + +comment "AT91RM9200 Board Type" + +config MACH_ONEARM +	bool "Ajeco 1ARM Single Board Computer" +	help +	  Select this if you are using Ajeco's 1ARM Single Board Computer. +	  <http://www.ajeco.fi/> + +config MACH_AT91RM9200EK +	bool "Atmel AT91RM9200-EK Evaluation Kit" +	select HAVE_AT91_DATAFLASH_CARD +	help +	  Select this if you are using Atmel's AT91RM9200-EK Evaluation Kit. +	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3507> + +config MACH_CSB337 +	bool "Cogent CSB337" +	help +	  Select this if you are using Cogent's CSB337 board. +	  <http://www.cogcomp.com/csb_csb337.htm> + +config MACH_CSB637 +	bool "Cogent CSB637" +	help +	  Select this if you are using Cogent's CSB637 board. +	  <http://www.cogcomp.com/csb_csb637.htm> + +config MACH_CARMEVA +	bool "Conitec ARM&EVA" +	help +	  Select this if you are using Conitec's AT91RM9200-MCU-Module. +	  <http://www.conitec.net/english/linuxboard.php> + +config MACH_ATEB9200 +	bool "Embest ATEB9200" +	help +	  Select this if you are using Embest's ATEB9200 board. +	  <http://www.embedinfo.com/english/product/ATEB9200.asp> + +config MACH_KB9200 +	bool "KwikByte KB920x" +	help +	  Select this if you are using KwikByte's KB920x board. +	  <http://www.kwikbyte.com/KB9202.html> + +config MACH_PICOTUX2XX +	bool "picotux 200" +	help +	  Select this if you are using a picotux 200. +	  <http://www.picotux.com/> + +config MACH_KAFA +	bool "Sperry-Sun KAFA board" +	help +	  Select this if you are using Sperry-Sun's KAFA board. + +config MACH_ECBAT91 +	bool "emQbit ECB_AT91 SBC" +	select HAVE_AT91_DATAFLASH_CARD +	help +	  Select this if you are using emQbit's ECB_AT91 board. +	  <http://wiki.emqbit.com/free-ecb-at91> + +config MACH_YL9200 +	bool "ucDragon YL-9200" +	help +	  Select this if you are using the ucDragon YL-9200 board. + +config MACH_CPUAT91 +	bool "Eukrea CPUAT91" +	help +	  Select this if you are using the Eukrea Electromatique's +	  CPUAT91 board <http://www.eukrea.com/>. + +config MACH_ECO920 +	bool "eco920" +	help +	  Select this if you are using the eco920 board + +config MACH_RSI_EWS +	bool "RSI Embedded Webserver" +	depends on ARCH_AT91RM9200 +	help +	  Select this if you are using RSIs EWS board. +endif + +# ---------------------------------------------------------- + +if ARCH_AT91SAM9260 + +comment "AT91SAM9260 Variants" + +comment "AT91SAM9260 / AT91SAM9XE Board Type" + +config MACH_AT91SAM9260EK +	bool "Atmel AT91SAM9260-EK / AT91SAM9XE Evaluation Kit" +	select HAVE_AT91_DATAFLASH_CARD +	help +	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit +	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933> + +config MACH_CAM60 +	bool "KwikByte KB9260 (CAM60) board" +	help +	  Select this if you are using KwikByte's KB9260 (CAM60) board based on the Atmel AT91SAM9260. +	  <http://www.kwikbyte.com/KB9260.html> + +config MACH_SAM9_L9260 +	bool "Olimex SAM9-L9260 board" +	select HAVE_AT91_DATAFLASH_CARD +	help +	  Select this if you are using Olimex's SAM9-L9260 board based on the Atmel AT91SAM9260. +	  <http://www.olimex.com/dev/sam9-L9260.html> + +config MACH_AFEB9260 +	bool "Custom afeb9260 board v1" +	help +	  Select this if you are using custom afeb9260 board based on +	  open hardware design. Select this for revision 1 of the board. +	  <svn://194.85.238.22/home/users/george/svn/arm9eb> +	  <http://groups.google.com/group/arm9fpga-evolution-board> + +config MACH_CPU9260 +	bool "Eukrea CPU9260 board" +	help +	  Select this if you are using a Eukrea Electromatique's +	  CPU9260 Board <http://www.eukrea.com/> + +config MACH_FLEXIBITY +	bool "Flexibity Connect board" +	help +	  Select this if you are using Flexibity Connect board +	  <http://www.flexibity.com> + +comment "AT91SAM9G20 Board Type" + +config MACH_AT91SAM9G20EK +	bool "Atmel AT91SAM9G20-EK Evaluation Kit" +	select HAVE_AT91_DATAFLASH_CARD +	help +	  Select this if you are using Atmel's AT91SAM9G20-EK Evaluation Kit +	  that embeds only one SD/MMC slot. + +config MACH_AT91SAM9G20EK_2MMC +	depends on MACH_AT91SAM9G20EK +	bool "Atmel AT91SAM9G20-EK Evaluation Kit with 2 SD/MMC Slots" +	help +	  Select this if you are using an Atmel AT91SAM9G20-EK Evaluation Kit +	  with 2 SD/MMC Slots. This is the case for AT91SAM9G20-EK rev. C and +	  onwards. +	  <http://www.atmel.com/tools/SAM9G20-EK.aspx> + +config MACH_CPU9G20 +	bool "Eukrea CPU9G20 board" +	help +	  Select this if you are using a Eukrea Electromatique's +	  CPU9G20 Board <http://www.eukrea.com/> + +config MACH_ACMENETUSFOXG20 +	bool "Acme Systems srl FOX Board G20" +	help +	  Select this if you are using Acme Systems +	  FOX Board G20 <http://www.acmesystems.it> + +config MACH_PORTUXG20 +	bool "taskit PortuxG20" +	help +	  Select this if you are using taskit's PortuxG20. +	  <http://www.taskit.de/en/> + +config MACH_STAMP9G20 +	bool "taskit Stamp9G20 CPU module" +	help +	  Select this if you are using taskit's Stamp9G20 CPU module on its +	  evaluation board. +	  <http://www.taskit.de/en/> + +config MACH_PCONTROL_G20 +	bool "PControl G20 CPU module" +	help +	  Select this if you are using taskit's Stamp9G20 CPU module on this +	  carrier board, being the decentralized unit of a building automation +	  system; featuring nvram, eth-switch, iso-rs485, display, io + +config MACH_GSIA18S +	bool "GS_IA18_S board" +	help +	  This enables support for the GS_IA18_S board +	  produced by GeoSIG Ltd company. This is an internet accelerograph. +	  <http://www.geosig.com> + +config MACH_SNAPPER_9260 +	bool "Bluewater Systems Snapper 9260/9G20 module" +	help +	  Select this if you are using the Bluewater Systems Snapper 9260 or +	  Snapper 9G20 modules. +	  <http://www.bluewatersys.com/> +endif + +# ---------------------------------------------------------- + +if ARCH_AT91SAM9261 + +comment "AT91SAM9261 Board Type" + +config MACH_AT91SAM9261EK +	bool "Atmel AT91SAM9261-EK Evaluation Kit" +	select HAVE_AT91_DATAFLASH_CARD +	help +	  Select this if you are using Atmel's AT91SAM9261-EK Evaluation Kit. +	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3820> + +comment "AT91SAM9G10 Board Type" + +config MACH_AT91SAM9G10EK +	bool "Atmel AT91SAM9G10-EK Evaluation Kit" +	select HAVE_AT91_DATAFLASH_CARD +	help +	  Select this if you are using Atmel's AT91SAM9G10-EK Evaluation Kit. +	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4588> + +endif + +# ---------------------------------------------------------- + +if ARCH_AT91SAM9263 + +comment "AT91SAM9263 Board Type" + +config MACH_AT91SAM9263EK +	bool "Atmel AT91SAM9263-EK Evaluation Kit" +	select HAVE_AT91_DATAFLASH_CARD +	help +	  Select this if you are using Atmel's AT91SAM9263-EK Evaluation Kit. +	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4057> + +endif + +# ---------------------------------------------------------- + +if ARCH_AT91SAM9RL + +comment "AT91SAM9RL Board Type" + +config MACH_AT91SAM9RLEK +	bool "Atmel AT91SAM9RL-EK Evaluation Kit" +	help +	  Select this if you are using Atmel's AT91SAM9RL-EK Evaluation Kit. + +endif + +# ---------------------------------------------------------- + +if ARCH_AT91SAM9G45 + +comment "AT91SAM9G45 Board Type" + +config MACH_AT91SAM9M10G45EK +	bool "Atmel AT91SAM9M10G45-EK Evaluation Kits" +	help +	  Select this if you are using Atmel's AT91SAM9M10G45-EK Evaluation Kit. +	  Those boards can be populated with any SoC of AT91SAM9G45 or AT91SAM9M10 +	  families: AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and AT91SAM9M11. +	  <http://www.atmel.com/tools/SAM9M10-G45-EK.aspx> + +endif + +# ---------------------------------------------------------- + +if ARCH_AT91X40 + +comment "AT91X40 Board Type" + +config MACH_AT91EB01 +	bool "Atmel AT91EB01 Evaluation Kit" +	help +	  Select this if you are using Atmel's AT91EB01 Evaluation Kit. +	  It is also a popular target for simulators such as GDB's +	  ARM simulator (commonly known as the ARMulator) and the +	  Skyeye simulator. + +endif + +# ---------------------------------------------------------- + +comment "AT91 Board Options" + +config MTD_AT91_DATAFLASH_CARD +	bool "Enable DataFlash Card support" +	depends on HAVE_AT91_DATAFLASH_CARD +	help +	  Enable support for the DataFlash card. + +endmenu diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index 821eb842795..78e9cec282f 100644 --- a/arch/arm/mach-at91/Makefile +++ b/arch/arm/mach-at91/Makefile @@ -2,30 +2,39 @@  # Makefile for the linux kernel.  # -obj-y		:= irq.o gpio.o +obj-y		:= irq.o gpio.o setup.o sysirq_mask.o  obj-m		:=  obj-n		:=  obj-		:= -obj-$(CONFIG_AT91_PMC_UNIT)	+= clock.o +obj-$(CONFIG_OLD_CLK_AT91)	+= clock.o +obj-$(CONFIG_AT91_SAM9_ALT_RESET) += at91sam9_alt_reset.o +obj-$(CONFIG_AT91_SAM9G45_RESET) += at91sam9g45_reset.o +obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o +obj-$(CONFIG_SOC_AT91SAM9)	+= sam9_smc.o  # CPU-specific support -obj-$(CONFIG_ARCH_AT91RM9200)	+= at91rm9200.o at91rm9200_time.o at91rm9200_devices.o -obj-$(CONFIG_ARCH_AT91SAM9260)	+= at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o at91sam9_alt_reset.o -obj-$(CONFIG_ARCH_AT91SAM9261)	+= at91sam9261.o at91sam926x_time.o at91sam9261_devices.o sam9_smc.o at91sam9_alt_reset.o -obj-$(CONFIG_ARCH_AT91SAM9G10)	+= at91sam9261.o at91sam926x_time.o at91sam9261_devices.o sam9_smc.o at91sam9_alt_reset.o -obj-$(CONFIG_ARCH_AT91SAM9263)	+= at91sam9263.o at91sam926x_time.o at91sam9263_devices.o sam9_smc.o at91sam9_alt_reset.o -obj-$(CONFIG_ARCH_AT91SAM9RL)	+= at91sam9rl.o at91sam926x_time.o at91sam9rl_devices.o sam9_smc.o at91sam9_alt_reset.o -obj-$(CONFIG_ARCH_AT91SAM9G20)	+= at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o at91sam9_alt_reset.o -obj-$(CONFIG_ARCH_AT91SAM9G45)	+= at91sam9g45.o at91sam926x_time.o at91sam9g45_devices.o sam9_smc.o -obj-$(CONFIG_ARCH_AT91CAP9)	+= at91cap9.o at91sam926x_time.o at91cap9_devices.o sam9_smc.o -obj-$(CONFIG_ARCH_AT572D940HF)  += at572d940hf.o at91sam926x_time.o at572d940hf_devices.o sam9_smc.o +obj-$(CONFIG_SOC_AT91RM9200)	+= at91rm9200.o at91rm9200_time.o +obj-$(CONFIG_SOC_AT91SAM9260)	+= at91sam9260.o +obj-$(CONFIG_SOC_AT91SAM9261)	+= at91sam9261.o +obj-$(CONFIG_SOC_AT91SAM9263)	+= at91sam9263.o +obj-$(CONFIG_SOC_AT91SAM9G45)	+= at91sam9g45.o +obj-$(CONFIG_SOC_AT91SAM9N12)	+= at91sam9n12.o +obj-$(CONFIG_SOC_AT91SAM9X5)	+= at91sam9x5.o +obj-$(CONFIG_SOC_AT91SAM9RL)	+= at91sam9rl.o +obj-$(CONFIG_SOC_SAMA5D3)	+= sama5d3.o + +obj-$(CONFIG_ARCH_AT91RM9200)	+= at91rm9200_devices.o +obj-$(CONFIG_ARCH_AT91SAM9260)	+= at91sam9260_devices.o +obj-$(CONFIG_ARCH_AT91SAM9261)	+= at91sam9261_devices.o +obj-$(CONFIG_ARCH_AT91SAM9263)	+= at91sam9263_devices.o +obj-$(CONFIG_ARCH_AT91SAM9RL)	+= at91sam9rl_devices.o +obj-$(CONFIG_ARCH_AT91SAM9G45)	+= at91sam9g45_devices.o  obj-$(CONFIG_ARCH_AT91X40)	+= at91x40.o at91x40_time.o  # AT91RM9200 board-specific support  obj-$(CONFIG_MACH_ONEARM)	+= board-1arm.o -obj-$(CONFIG_ARCH_AT91RM9200DK)	+= board-dk.o -obj-$(CONFIG_MACH_AT91RM9200EK)	+= board-ek.o +obj-$(CONFIG_MACH_AT91RM9200EK)	+= board-rm9200ek.o  obj-$(CONFIG_MACH_CSB337)	+= board-csb337.o  obj-$(CONFIG_MACH_CSB637)	+= board-csb637.o  obj-$(CONFIG_MACH_CARMEVA)	+= board-carmeva.o @@ -37,13 +46,12 @@ obj-$(CONFIG_MACH_ECBAT91)	+= board-ecbat91.o  obj-$(CONFIG_MACH_YL9200)	+= board-yl-9200.o  obj-$(CONFIG_MACH_CPUAT91)	+= board-cpuat91.o  obj-$(CONFIG_MACH_ECO920)	+= board-eco920.o +obj-$(CONFIG_MACH_RSI_EWS)	+= board-rsi-ews.o  # AT91SAM9260 board-specific support  obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o  obj-$(CONFIG_MACH_CAM60)	+= board-cam60.o  obj-$(CONFIG_MACH_SAM9_L9260)	+= board-sam9-l9260.o -obj-$(CONFIG_MACH_USB_A9260)	+= board-usb-a9260.o -obj-$(CONFIG_MACH_QIL_A9260)	+= board-qil-a9260.o  obj-$(CONFIG_MACH_AFEB9260)	+= board-afeb-9260v1.o  obj-$(CONFIG_MACH_CPU9260)	+= board-cpu9krea.o  obj-$(CONFIG_MACH_FLEXIBITY)	+= board-flexibity.o @@ -54,8 +62,6 @@ obj-$(CONFIG_MACH_AT91SAM9G10EK) += board-sam9261ek.o  # AT91SAM9263 board-specific support  obj-$(CONFIG_MACH_AT91SAM9263EK) += board-sam9263ek.o -obj-$(CONFIG_MACH_USB_A9263)	+= board-usb-a9263.o -obj-$(CONFIG_MACH_NEOCORE926)	+= board-neocore926.o  # AT91SAM9RL board-specific support  obj-$(CONFIG_MACH_AT91SAM9RLEK)	+= board-sam9rlek.o @@ -63,9 +69,11 @@ obj-$(CONFIG_MACH_AT91SAM9RLEK)	+= board-sam9rlek.o  # AT91SAM9G20 board-specific support  obj-$(CONFIG_MACH_AT91SAM9G20EK) += board-sam9g20ek.o  obj-$(CONFIG_MACH_CPU9G20)	+= board-cpu9krea.o +obj-$(CONFIG_MACH_ACMENETUSFOXG20) += board-foxg20.o  obj-$(CONFIG_MACH_STAMP9G20)	+= board-stamp9g20.o  obj-$(CONFIG_MACH_PORTUXG20)	+= board-stamp9g20.o -obj-$(CONFIG_MACH_PCONTROL_G20)	+= board-pcontrol-g20.o +obj-$(CONFIG_MACH_PCONTROL_G20)	+= board-pcontrol-g20.o board-stamp9g20.o +obj-$(CONFIG_MACH_GSIA18S)	+= board-gsia18s.o board-stamp9g20.o  # AT91SAM9260/AT91SAM9G20 board-specific support  obj-$(CONFIG_MACH_SNAPPER_9260)	+= board-snapper9260.o @@ -73,11 +81,12 @@ obj-$(CONFIG_MACH_SNAPPER_9260)	+= board-snapper9260.o  # AT91SAM9G45 board-specific support  obj-$(CONFIG_MACH_AT91SAM9M10G45EK) += board-sam9m10g45ek.o -# AT91CAP9 board-specific support -obj-$(CONFIG_MACH_AT91CAP9ADK)	+= board-cap9adk.o +# AT91SAM board with device-tree +obj-$(CONFIG_MACH_AT91RM9200_DT) += board-dt-rm9200.o +obj-$(CONFIG_MACH_AT91SAM9_DT) += board-dt-sam9.o -# AT572D940HF board-specific support -obj-$(CONFIG_MACH_AT572D940HFEB) += board-at572d940hf_ek.o +# SAMA5 board with device-tree +obj-$(CONFIG_MACH_SAMA5_DT) += board-dt-sama5.o  # AT91X40 board-specific support  obj-$(CONFIG_MACH_AT91EB01)	+= board-eb01.o @@ -88,7 +97,6 @@ obj-y				+= leds.o  # Power Management  obj-$(CONFIG_PM)		+= pm.o  obj-$(CONFIG_AT91_SLOW_CLOCK)	+= pm_slowclock.o -obj-$(CONFIG_CPU_IDLE)	+= cpuidle.o  ifeq ($(CONFIG_PM_DEBUG),y)  CFLAGS_pm.o += -DDEBUG diff --git a/arch/arm/mach-at91/Makefile.boot b/arch/arm/mach-at91/Makefile.boot index 3462b815054..5309f9b6aab 100644 --- a/arch/arm/mach-at91/Makefile.boot +++ b/arch/arm/mach-at91/Makefile.boot @@ -3,16 +3,12 @@  #   PARAMS_PHYS must be within 4MB of ZRELADDR  #   INITRD_PHYS must be in RAM -ifeq ($(CONFIG_ARCH_AT91CAP9),y) -   zreladdr-y	:= 0x70008000 -params_phys-y	:= 0x70000100 -initrd_phys-y	:= 0x70410000 -else ifeq ($(CONFIG_ARCH_AT91SAM9G45),y) -   zreladdr-y	:= 0x70008000 +ifeq ($(CONFIG_ARCH_AT91SAM9G45),y) +   zreladdr-y	+= 0x70008000  params_phys-y	:= 0x70000100  initrd_phys-y	:= 0x70410000  else -   zreladdr-y	:= 0x20008000 +   zreladdr-y	+= 0x20008000  params_phys-y	:= 0x20000100  initrd_phys-y	:= 0x20410000  endif diff --git a/arch/arm/mach-at91/at572d940hf.c b/arch/arm/mach-at91/at572d940hf.c deleted file mode 100644 index a6b9c68c003..00000000000 --- a/arch/arm/mach-at91/at572d940hf.c +++ /dev/null @@ -1,377 +0,0 @@ -/* - * arch/arm/mach-at91/at572d940hf.c - * - * Antonio R. Costa <costa.antonior@gmail.com> - * Copyright (C) 2008 Atmel - * - * Copyright (C) 2005 SAN People - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - * - */ - -#include <linux/module.h> - -#include <asm/mach/irq.h> -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <mach/at572d940hf.h> -#include <mach/at91_pmc.h> -#include <mach/at91_rstc.h> - -#include "generic.h" -#include "clock.h" - -static struct map_desc at572d940hf_io_desc[] __initdata = { -	{ -		.virtual	= AT91_VA_BASE_SYS, -		.pfn		= __phys_to_pfn(AT91_BASE_SYS), -		.length		= SZ_16K, -		.type		= MT_DEVICE, -	}, { -		.virtual	= AT91_IO_VIRT_BASE - AT572D940HF_SRAM_SIZE, -		.pfn		= __phys_to_pfn(AT572D940HF_SRAM_BASE), -		.length		= AT572D940HF_SRAM_SIZE, -		.type		= MT_DEVICE, -	}, -}; - -/* -------------------------------------------------------------------- - *  Clocks - * -------------------------------------------------------------------- */ - -/* - * The peripheral clocks. - */ -static struct clk pioA_clk = { -	.name		= "pioA_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_PIOA, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk pioB_clk = { -	.name		= "pioB_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_PIOB, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk pioC_clk = { -	.name		= "pioC_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_PIOC, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk macb_clk = { -	.name		= "macb_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_EMAC, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk usart0_clk = { -	.name		= "usart0_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_US0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk usart1_clk = { -	.name		= "usart1_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_US1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk usart2_clk = { -	.name		= "usart2_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_US2, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk mmc_clk = { -	.name		= "mci_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_MCI, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk udc_clk = { -	.name		= "udc_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_UDP, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk twi0_clk = { -	.name		= "twi0_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_TWI0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk spi0_clk = { -	.name		= "spi0_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_SPI0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk spi1_clk = { -	.name		= "spi1_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_SPI1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk ssc0_clk = { -	.name		= "ssc0_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_SSC0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk ssc1_clk = { -	.name		= "ssc1_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_SSC1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk ssc2_clk = { -	.name		= "ssc2_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_SSC2, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk tc0_clk = { -	.name		= "tc0_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_TC0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk tc1_clk = { -	.name		= "tc1_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_TC1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk tc2_clk = { -	.name		= "tc2_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_TC2, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk ohci_clk = { -	.name		= "ohci_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_UHP, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk ssc3_clk = { -	.name		= "ssc3_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_SSC3, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk twi1_clk = { -	.name		= "twi1_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_TWI1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk can0_clk = { -	.name		= "can0_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_CAN0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk can1_clk = { -	.name		= "can1_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_CAN1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk mAgicV_clk = { -	.name		= "mAgicV_clk", -	.pmc_mask	= 1 << AT572D940HF_ID_MSIRQ0, -	.type		= CLK_TYPE_PERIPHERAL, -}; - - -static struct clk *periph_clocks[] __initdata = { -	&pioA_clk, -	&pioB_clk, -	&pioC_clk, -	&macb_clk, -	&usart0_clk, -	&usart1_clk, -	&usart2_clk, -	&mmc_clk, -	&udc_clk, -	&twi0_clk, -	&spi0_clk, -	&spi1_clk, -	&ssc0_clk, -	&ssc1_clk, -	&ssc2_clk, -	&tc0_clk, -	&tc1_clk, -	&tc2_clk, -	&ohci_clk, -	&ssc3_clk, -	&twi1_clk, -	&can0_clk, -	&can1_clk, -	&mAgicV_clk, -	/* irq0 .. irq2 */ -}; - -/* - * The five programmable clocks. - * You must configure pin multiplexing to bring these signals out. - */ -static struct clk pck0 = { -	.name		= "pck0", -	.pmc_mask	= AT91_PMC_PCK0, -	.type		= CLK_TYPE_PROGRAMMABLE, -	.id		= 0, -}; -static struct clk pck1 = { -	.name		= "pck1", -	.pmc_mask	= AT91_PMC_PCK1, -	.type		= CLK_TYPE_PROGRAMMABLE, -	.id		= 1, -}; -static struct clk pck2 = { -	.name		= "pck2", -	.pmc_mask	= AT91_PMC_PCK2, -	.type		= CLK_TYPE_PROGRAMMABLE, -	.id		= 2, -}; -static struct clk pck3 = { -	.name		= "pck3", -	.pmc_mask	= AT91_PMC_PCK3, -	.type		= CLK_TYPE_PROGRAMMABLE, -	.id		= 3, -}; - -static struct clk mAgicV_mem_clk = { -	.name		= "mAgicV_mem_clk", -	.pmc_mask	= AT91_PMC_PCK4, -	.type		= CLK_TYPE_PROGRAMMABLE, -	.id		= 4, -}; - -/* HClocks */ -static struct clk hck0 = { -	.name		= "hck0", -	.pmc_mask	= AT91_PMC_HCK0, -	.type		= CLK_TYPE_SYSTEM, -	.id		= 0, -}; -static struct clk hck1 = { -	.name		= "hck1", -	.pmc_mask	= AT91_PMC_HCK1, -	.type		= CLK_TYPE_SYSTEM, -	.id		= 1, -}; - -static void __init at572d940hf_register_clocks(void) -{ -	int i; - -	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) -		clk_register(periph_clocks[i]); - -	clk_register(&pck0); -	clk_register(&pck1); -	clk_register(&pck2); -	clk_register(&pck3); -	clk_register(&mAgicV_mem_clk); - -	clk_register(&hck0); -	clk_register(&hck1); -} - -/* -------------------------------------------------------------------- - *  GPIO - * -------------------------------------------------------------------- */ - -static struct at91_gpio_bank at572d940hf_gpio[] = { -	{ -		.id		= AT572D940HF_ID_PIOA, -		.offset		= AT91_PIOA, -		.clock		= &pioA_clk, -	}, { -		.id		= AT572D940HF_ID_PIOB, -		.offset		= AT91_PIOB, -		.clock		= &pioB_clk, -	}, { -		.id		= AT572D940HF_ID_PIOC, -		.offset		= AT91_PIOC, -		.clock		= &pioC_clk, -	} -}; - -static void at572d940hf_reset(void) -{ -	at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); -} - - -/* -------------------------------------------------------------------- - *  AT572D940HF processor initialization - * -------------------------------------------------------------------- */ - -void __init at572d940hf_initialize(unsigned long main_clock) -{ -	/* Map peripherals */ -	iotable_init(at572d940hf_io_desc, ARRAY_SIZE(at572d940hf_io_desc)); - -	at91_arch_reset = at572d940hf_reset; -	at91_extern_irq = (1 << AT572D940HF_ID_IRQ0) | (1 << AT572D940HF_ID_IRQ1) -			| (1 << AT572D940HF_ID_IRQ2); - -	/* Init clock subsystem */ -	at91_clock_init(main_clock); - -	/* Register the processor-specific clocks */ -	at572d940hf_register_clocks(); - -	/* Register GPIO subsystem */ -	at91_gpio_init(at572d940hf_gpio, 3); -} - -/* -------------------------------------------------------------------- - *  Interrupt initialization - * -------------------------------------------------------------------- */ - -/* - * The default interrupt priority levels (0 = lowest, 7 = highest). - */ -static unsigned int at572d940hf_default_irq_priority[NR_AIC_IRQS] __initdata = { -	7,	/* Advanced Interrupt Controller */ -	7,	/* System Peripherals */ -	0,	/* Parallel IO Controller A */ -	0,	/* Parallel IO Controller B */ -	0,	/* Parallel IO Controller C */ -	3,	/* Ethernet */ -	6,	/* USART 0 */ -	6,	/* USART 1 */ -	6,	/* USART 2 */ -	0,	/* Multimedia Card Interface */ -	4,	/* USB Device Port */ -	0,	/* Two-Wire Interface 0 */ -	6,	/* Serial Peripheral Interface 0 */ -	6,	/* Serial Peripheral Interface 1 */ -	5,	/* Serial Synchronous Controller 0 */ -	5,	/* Serial Synchronous Controller 1 */ -	5,	/* Serial Synchronous Controller 2 */ -	0,	/* Timer Counter 0 */ -	0,	/* Timer Counter 1 */ -	0,	/* Timer Counter 2 */ -	3,	/* USB Host port */ -	3,	/* Serial Synchronous Controller 3 */ -	0,	/* Two-Wire Interface 1 */ -	0,	/* CAN Controller 0 */ -	0,	/* CAN Controller 1 */ -	0,	/* mAgicV HALT line */ -	0,	/* mAgicV SIRQ0 line */ -	0,	/* mAgicV exception line */ -	0,	/* mAgicV end of DMA line */ -	0,	/* Advanced Interrupt Controller */ -	0,	/* Advanced Interrupt Controller */ -	0,	/* Advanced Interrupt Controller */ -}; - -void __init at572d940hf_init_interrupts(unsigned int priority[NR_AIC_IRQS]) -{ -	if (!priority) -		priority = at572d940hf_default_irq_priority; - -	/* Initialize the AIC interrupt controller */ -	at91_aic_init(priority); - -	/* Enable GPIO interrupts */ -	at91_gpio_irq_setup(); -} - diff --git a/arch/arm/mach-at91/at572d940hf_devices.c b/arch/arm/mach-at91/at572d940hf_devices.c deleted file mode 100644 index 0fc20a24078..00000000000 --- a/arch/arm/mach-at91/at572d940hf_devices.c +++ /dev/null @@ -1,970 +0,0 @@ -/* - * arch/arm/mach-at91/at572d940hf_devices.c - * - * Copyright (C) 2008 Atmel Antonio R. Costa <costa.antonior@gmail.com> - * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org> - * Copyright (C) 2005 David Brownell - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - * - */ - -#include <asm/mach/arch.h> -#include <asm/mach/map.h> - -#include <linux/dma-mapping.h> -#include <linux/platform_device.h> - -#include <mach/board.h> -#include <mach/gpio.h> -#include <mach/at572d940hf.h> -#include <mach/at572d940hf_matrix.h> -#include <mach/at91sam9_smc.h> - -#include "generic.h" -#include "sam9_smc.h" - - -/* -------------------------------------------------------------------- - *  USB Host - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) -static u64 ohci_dmamask = DMA_BIT_MASK(32); -static struct at91_usbh_data usbh_data; - -static struct resource usbh_resources[] = { -	[0] = { -		.start	= AT572D940HF_UHP_BASE, -		.end	= AT572D940HF_UHP_BASE + SZ_1M - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_UHP, -		.end	= AT572D940HF_ID_UHP, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at572d940hf_usbh_device = { -	.name		= "at91_ohci", -	.id		= -1, -	.dev		= { -				.dma_mask		= &ohci_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &usbh_data, -	}, -	.resource	= usbh_resources, -	.num_resources	= ARRAY_SIZE(usbh_resources), -}; - -void __init at91_add_device_usbh(struct at91_usbh_data *data) -{ -	if (!data) -		return; - -	usbh_data = *data; -	platform_device_register(&at572d940hf_usbh_device); - -} -#else -void __init at91_add_device_usbh(struct at91_usbh_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  USB Device (Gadget) - * -------------------------------------------------------------------- */ - -#ifdef CONFIG_USB_GADGET_AT91 -static struct at91_udc_data udc_data; - -static struct resource udc_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_UDP, -		.end	= AT572D940HF_BASE_UDP + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_UDP, -		.end	= AT572D940HF_ID_UDP, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at572d940hf_udc_device = { -	.name		= "at91_udc", -	.id		= -1, -	.dev		= { -				.platform_data		= &udc_data, -	}, -	.resource	= udc_resources, -	.num_resources	= ARRAY_SIZE(udc_resources), -}; - -void __init at91_add_device_udc(struct at91_udc_data *data) -{ -	if (!data) -		return; - -	if (data->vbus_pin) { -		at91_set_gpio_input(data->vbus_pin, 0); -		at91_set_deglitch(data->vbus_pin, 1); -	} - -	/* Pullup pin is handled internally */ - -	udc_data = *data; -	platform_device_register(&at572d940hf_udc_device); -} -#else -void __init at91_add_device_udc(struct at91_udc_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  Ethernet - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE) -static u64 eth_dmamask = DMA_BIT_MASK(32); -static struct at91_eth_data eth_data; - -static struct resource eth_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_EMAC, -		.end	= AT572D940HF_BASE_EMAC + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_EMAC, -		.end	= AT572D940HF_ID_EMAC, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at572d940hf_eth_device = { -	.name		= "macb", -	.id		= -1, -	.dev		= { -			.dma_mask		= ð_dmamask, -			.coherent_dma_mask	= DMA_BIT_MASK(32), -			.platform_data		= ð_data, -	}, -	.resource	= eth_resources, -	.num_resources	= ARRAY_SIZE(eth_resources), -}; - -void __init at91_add_device_eth(struct at91_eth_data *data) -{ -	if (!data) -		return; - -	if (data->phy_irq_pin) { -		at91_set_gpio_input(data->phy_irq_pin, 0); -		at91_set_deglitch(data->phy_irq_pin, 1); -	} - -	/* Only RMII is supported */ -	data->is_rmii = 1; - -	/* Pins used for RMII */ -	at91_set_A_periph(AT91_PIN_PA16, 0);	/* ETXCK_EREFCK */ -	at91_set_A_periph(AT91_PIN_PA17, 0);	/* ERXDV */ -	at91_set_A_periph(AT91_PIN_PA18, 0);	/* ERX0 */ -	at91_set_A_periph(AT91_PIN_PA19, 0);	/* ERX1 */ -	at91_set_A_periph(AT91_PIN_PA20, 0);	/* ERXER */ -	at91_set_A_periph(AT91_PIN_PA23, 0);	/* ETXEN */ -	at91_set_A_periph(AT91_PIN_PA21, 0);	/* ETX0 */ -	at91_set_A_periph(AT91_PIN_PA22, 0);	/* ETX1 */ -	at91_set_A_periph(AT91_PIN_PA13, 0);	/* EMDIO */ -	at91_set_A_periph(AT91_PIN_PA14, 0);	/* EMDC */ - -	eth_data = *data; -	platform_device_register(&at572d940hf_eth_device); -} -#else -void __init at91_add_device_eth(struct at91_eth_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  MMC / SD - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) -static u64 mmc_dmamask = DMA_BIT_MASK(32); -static struct at91_mmc_data mmc_data; - -static struct resource mmc_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_MCI, -		.end	= AT572D940HF_BASE_MCI + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_MCI, -		.end	= AT572D940HF_ID_MCI, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at572d940hf_mmc_device = { -	.name		= "at91_mci", -	.id		= -1, -	.dev		= { -				.dma_mask		= &mmc_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &mmc_data, -	}, -	.resource	= mmc_resources, -	.num_resources	= ARRAY_SIZE(mmc_resources), -}; - -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) -{ -	if (!data) -		return; - -	/* input/irq */ -	if (data->det_pin) { -		at91_set_gpio_input(data->det_pin, 1); -		at91_set_deglitch(data->det_pin, 1); -	} -	if (data->wp_pin) -		at91_set_gpio_input(data->wp_pin, 1); -	if (data->vcc_pin) -		at91_set_gpio_output(data->vcc_pin, 0); - -	/* CLK */ -	at91_set_A_periph(AT91_PIN_PC22, 0); - -	/* CMD */ -	at91_set_A_periph(AT91_PIN_PC23, 1); - -	/* DAT0, maybe DAT1..DAT3 */ -	at91_set_A_periph(AT91_PIN_PC24, 1); -	if (data->wire4) { -		at91_set_A_periph(AT91_PIN_PC25, 1); -		at91_set_A_periph(AT91_PIN_PC26, 1); -		at91_set_A_periph(AT91_PIN_PC27, 1); -	} - -	mmc_data = *data; -	platform_device_register(&at572d940hf_mmc_device); -} -#else -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  NAND / SmartMedia - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE) -static struct atmel_nand_data nand_data; - -#define NAND_BASE	AT91_CHIPSELECT_3 - -static struct resource nand_resources[] = { -	{ -		.start	= NAND_BASE, -		.end	= NAND_BASE + SZ_256M - 1, -		.flags	= IORESOURCE_MEM, -	} -}; - -static struct platform_device at572d940hf_nand_device = { -	.name		= "atmel_nand", -	.id		= -1, -	.dev		= { -				.platform_data	= &nand_data, -	}, -	.resource	= nand_resources, -	.num_resources	= ARRAY_SIZE(nand_resources), -}; - -void __init at91_add_device_nand(struct atmel_nand_data *data) -{ -	unsigned long csa; - -	if (!data) -		return; - -	csa = at91_sys_read(AT91_MATRIX_EBICSA); -	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); - -	/* enable pin */ -	if (data->enable_pin) -		at91_set_gpio_output(data->enable_pin, 1); - -	/* ready/busy pin */ -	if (data->rdy_pin) -		at91_set_gpio_input(data->rdy_pin, 1); - -	/* card detect pin */ -	if (data->det_pin) -		at91_set_gpio_input(data->det_pin, 1); - -	at91_set_A_periph(AT91_PIN_PB28, 0);		/* A[22] */ -	at91_set_B_periph(AT91_PIN_PA28, 0);		/* NANDOE */ -	at91_set_B_periph(AT91_PIN_PA29, 0);		/* NANDWE */ - -	nand_data = *data; -	platform_device_register(&at572d940hf_nand_device); -} - -#else -void __init at91_add_device_nand(struct atmel_nand_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  TWI (i2c) - * -------------------------------------------------------------------- */ - -/* - * Prefer the GPIO code since the TWI controller isn't robust - * (gets overruns and underruns under load) and can only issue - * repeated STARTs in one scenario (the driver doesn't yet handle them). - */ - -#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) - -static struct i2c_gpio_platform_data pdata = { -	.sda_pin		= AT91_PIN_PC7, -	.sda_is_open_drain	= 1, -	.scl_pin		= AT91_PIN_PC8, -	.scl_is_open_drain	= 1, -	.udelay			= 2,		/* ~100 kHz */ -}; - -static struct platform_device at572d940hf_twi_device { -	.name			= "i2c-gpio", -	.id			= -1, -	.dev.platform_data	= &pdata, -}; - -void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) -{ -	at91_set_GPIO_periph(AT91_PIN_PC7, 1);		/* TWD (SDA) */ -	at91_set_multi_drive(AT91_PIN_PC7, 1); - -	at91_set_GPIO_periph(AT91_PIN_PA8, 1);		/* TWCK (SCL) */ -	at91_set_multi_drive(AT91_PIN_PC8, 1); - -	i2c_register_board_info(0, devices, nr_devices); -	platform_device_register(&at572d940hf_twi_device); -} - -#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) - -static struct resource twi0_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_TWI0, -		.end	= AT572D940HF_BASE_TWI0 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_TWI0, -		.end	= AT572D940HF_ID_TWI0, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at572d940hf_twi0_device = { -	.name		= "at91_i2c", -	.id		= 0, -	.resource	= twi0_resources, -	.num_resources	= ARRAY_SIZE(twi0_resources), -}; - -static struct resource twi1_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_TWI1, -		.end	= AT572D940HF_BASE_TWI1 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_TWI1, -		.end	= AT572D940HF_ID_TWI1, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at572d940hf_twi1_device = { -	.name		= "at91_i2c", -	.id		= 1, -	.resource	= twi1_resources, -	.num_resources	= ARRAY_SIZE(twi1_resources), -}; - -void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) -{ -	/* pins used for TWI0 interface */ -	at91_set_A_periph(AT91_PIN_PC7, 0);		/* TWD */ -	at91_set_multi_drive(AT91_PIN_PC7, 1); - -	at91_set_A_periph(AT91_PIN_PC8, 0);		/* TWCK */ -	at91_set_multi_drive(AT91_PIN_PC8, 1); - -	/* pins used for TWI1 interface */ -	at91_set_A_periph(AT91_PIN_PC20, 0);		/* TWD */ -	at91_set_multi_drive(AT91_PIN_PC20, 1); - -	at91_set_A_periph(AT91_PIN_PC21, 0);		/* TWCK */ -	at91_set_multi_drive(AT91_PIN_PC21, 1); - -	i2c_register_board_info(0, devices, nr_devices); -	platform_device_register(&at572d940hf_twi0_device); -	platform_device_register(&at572d940hf_twi1_device); -} -#else -void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {} -#endif - - -/* -------------------------------------------------------------------- - *  SPI - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) -static u64 spi_dmamask = DMA_BIT_MASK(32); - -static struct resource spi0_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_SPI0, -		.end	= AT572D940HF_BASE_SPI0 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_SPI0, -		.end	= AT572D940HF_ID_SPI0, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at572d940hf_spi0_device = { -	.name		= "atmel_spi", -	.id		= 0, -	.dev		= { -				.dma_mask		= &spi_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -	}, -	.resource	= spi0_resources, -	.num_resources	= ARRAY_SIZE(spi0_resources), -}; - -static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 }; - -static struct resource spi1_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_SPI1, -		.end	= AT572D940HF_BASE_SPI1 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_SPI1, -		.end	= AT572D940HF_ID_SPI1, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at572d940hf_spi1_device = { -	.name		= "atmel_spi", -	.id		= 1, -	.dev		= { -				.dma_mask		= &spi_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -	}, -	.resource	= spi1_resources, -	.num_resources	= ARRAY_SIZE(spi1_resources), -}; - -static const unsigned spi1_standard_cs[4] = { AT91_PIN_PC3, AT91_PIN_PC4, AT91_PIN_PC5, AT91_PIN_PC6 }; - -void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) -{ -	int i; -	unsigned long cs_pin; -	short enable_spi0 = 0; -	short enable_spi1 = 0; - -	/* Choose SPI chip-selects */ -	for (i = 0; i < nr_devices; i++) { -		if (devices[i].controller_data) -			cs_pin = (unsigned long) devices[i].controller_data; -		else if (devices[i].bus_num == 0) -			cs_pin = spi0_standard_cs[devices[i].chip_select]; -		else -			cs_pin = spi1_standard_cs[devices[i].chip_select]; - -		if (devices[i].bus_num == 0) -			enable_spi0 = 1; -		else -			enable_spi1 = 1; - -		/* enable chip-select pin */ -		at91_set_gpio_output(cs_pin, 1); - -		/* pass chip-select pin to driver */ -		devices[i].controller_data = (void *) cs_pin; -	} - -	spi_register_board_info(devices, nr_devices); - -	/* Configure SPI bus(es) */ -	if (enable_spi0) { -		at91_set_A_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */ -		at91_set_A_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */ -		at91_set_A_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */ - -		at91_clock_associate("spi0_clk", &at572d940hf_spi0_device.dev, "spi_clk"); -		platform_device_register(&at572d940hf_spi0_device); -	} -	if (enable_spi1) { -		at91_set_A_periph(AT91_PIN_PC0, 0);	/* SPI1_MISO */ -		at91_set_A_periph(AT91_PIN_PC1, 0);	/* SPI1_MOSI */ -		at91_set_A_periph(AT91_PIN_PC2, 0);	/* SPI1_SPCK */ - -		at91_clock_associate("spi1_clk", &at572d940hf_spi1_device.dev, "spi_clk"); -		platform_device_register(&at572d940hf_spi1_device); -	} -} -#else -void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {} -#endif - - -/* -------------------------------------------------------------------- - *  Timer/Counter blocks - * -------------------------------------------------------------------- */ - -#ifdef CONFIG_ATMEL_TCLIB - -static struct resource tcb_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_TCB, -		.end	= AT572D940HF_BASE_TCB + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_TC0, -		.end	= AT572D940HF_ID_TC0, -		.flags	= IORESOURCE_IRQ, -	}, -	[2] = { -		.start	= AT572D940HF_ID_TC1, -		.end	= AT572D940HF_ID_TC1, -		.flags	= IORESOURCE_IRQ, -	}, -	[3] = { -		.start	= AT572D940HF_ID_TC2, -		.end	= AT572D940HF_ID_TC2, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at572d940hf_tcb_device = { -	.name		= "atmel_tcb", -	.id		= 0, -	.resource	= tcb_resources, -	.num_resources	= ARRAY_SIZE(tcb_resources), -}; - -static void __init at91_add_device_tc(void) -{ -	/* this chip has a separate clock and irq for each TC channel */ -	at91_clock_associate("tc0_clk", &at572d940hf_tcb_device.dev, "t0_clk"); -	at91_clock_associate("tc1_clk", &at572d940hf_tcb_device.dev, "t1_clk"); -	at91_clock_associate("tc2_clk", &at572d940hf_tcb_device.dev, "t2_clk"); -	platform_device_register(&at572d940hf_tcb_device); -} -#else -static void __init at91_add_device_tc(void) { } -#endif - - -/* -------------------------------------------------------------------- - *  RTT - * -------------------------------------------------------------------- */ - -static struct resource rtt_resources[] = { -	{ -		.start	= AT91_BASE_SYS + AT91_RTT, -		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1, -		.flags	= IORESOURCE_MEM, -	} -}; - -static struct platform_device at572d940hf_rtt_device = { -	.name		= "at91_rtt", -	.id		= 0, -	.resource	= rtt_resources, -	.num_resources	= ARRAY_SIZE(rtt_resources), -}; - -static void __init at91_add_device_rtt(void) -{ -	platform_device_register(&at572d940hf_rtt_device); -} - - -/* -------------------------------------------------------------------- - *  Watchdog - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) -static struct platform_device at572d940hf_wdt_device = { -	.name		= "at91_wdt", -	.id		= -1, -	.num_resources	= 0, -}; - -static void __init at91_add_device_watchdog(void) -{ -	platform_device_register(&at572d940hf_wdt_device); -} -#else -static void __init at91_add_device_watchdog(void) {} -#endif - - -/* -------------------------------------------------------------------- - *  UART - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_SERIAL_ATMEL) -static struct resource dbgu_resources[] = { -	[0] = { -		.start	= AT91_VA_BASE_SYS + AT91_DBGU, -		.end	= AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91_ID_SYS, -		.end	= AT91_ID_SYS, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct atmel_uart_data dbgu_data = { -	.use_dma_tx	= 0, -	.use_dma_rx	= 0,		/* DBGU not capable of receive DMA */ -	.regs		= (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), -}; - -static u64 dbgu_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at572d940hf_dbgu_device = { -	.name		= "atmel_usart", -	.id		= 0, -	.dev		= { -				.dma_mask		= &dbgu_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &dbgu_data, -	}, -	.resource	= dbgu_resources, -	.num_resources	= ARRAY_SIZE(dbgu_resources), -}; - -static inline void configure_dbgu_pins(void) -{ -	at91_set_A_periph(AT91_PIN_PC31, 1);		/* DTXD */ -	at91_set_A_periph(AT91_PIN_PC30, 0);		/* DRXD */ -} - -static struct resource uart0_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_US0, -		.end	= AT572D940HF_BASE_US0 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_US0, -		.end	= AT572D940HF_ID_US0, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct atmel_uart_data uart0_data = { -	.use_dma_tx	= 1, -	.use_dma_rx	= 1, -}; - -static u64 uart0_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at572d940hf_uart0_device = { -	.name		= "atmel_usart", -	.id		= 1, -	.dev		= { -				.dma_mask		= &uart0_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &uart0_data, -	}, -	.resource	= uart0_resources, -	.num_resources	= ARRAY_SIZE(uart0_resources), -}; - -static inline void configure_usart0_pins(unsigned pins) -{ -	at91_set_A_periph(AT91_PIN_PA8, 1);		/* TXD0 */ -	at91_set_A_periph(AT91_PIN_PA7, 0);		/* RXD0 */ - -	if (pins & ATMEL_UART_RTS) -		at91_set_A_periph(AT91_PIN_PA10, 0);	/* RTS0 */ -	if (pins & ATMEL_UART_CTS) -		at91_set_A_periph(AT91_PIN_PA9, 0);	/* CTS0 */ -} - -static struct resource uart1_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_US1, -		.end	= AT572D940HF_BASE_US1 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_US1, -		.end	= AT572D940HF_ID_US1, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct atmel_uart_data uart1_data = { -	.use_dma_tx	= 1, -	.use_dma_rx	= 1, -}; - -static u64 uart1_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at572d940hf_uart1_device = { -	.name		= "atmel_usart", -	.id		= 2, -	.dev		= { -				.dma_mask		= &uart1_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &uart1_data, -	}, -	.resource	= uart1_resources, -	.num_resources	= ARRAY_SIZE(uart1_resources), -}; - -static inline void configure_usart1_pins(unsigned pins) -{ -	at91_set_A_periph(AT91_PIN_PC10, 1);		/* TXD1 */ -	at91_set_A_periph(AT91_PIN_PC9 , 0);		/* RXD1 */ - -	if (pins & ATMEL_UART_RTS) -		at91_set_A_periph(AT91_PIN_PC12, 0);	/* RTS1 */ -	if (pins & ATMEL_UART_CTS) -		at91_set_A_periph(AT91_PIN_PC11, 0);	/* CTS1 */ -} - -static struct resource uart2_resources[] = { -	[0] = { -		.start	= AT572D940HF_BASE_US2, -		.end	= AT572D940HF_BASE_US2 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT572D940HF_ID_US2, -		.end	= AT572D940HF_ID_US2, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct atmel_uart_data uart2_data = { -	.use_dma_tx	= 1, -	.use_dma_rx	= 1, -}; - -static u64 uart2_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at572d940hf_uart2_device = { -	.name		= "atmel_usart", -	.id		= 3, -	.dev		= { -				.dma_mask		= &uart2_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &uart2_data, -	}, -	.resource	= uart2_resources, -	.num_resources	= ARRAY_SIZE(uart2_resources), -}; - -static inline void configure_usart2_pins(unsigned pins) -{ -	at91_set_A_periph(AT91_PIN_PC15, 1);		/* TXD2 */ -	at91_set_A_periph(AT91_PIN_PC14, 0);		/* RXD2 */ - -	if (pins & ATMEL_UART_RTS) -		at91_set_A_periph(AT91_PIN_PC17, 0);	/* RTS2 */ -	if (pins & ATMEL_UART_CTS) -		at91_set_A_periph(AT91_PIN_PC16, 0);	/* CTS2 */ -} - -static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */ -struct platform_device *atmel_default_console_device;	/* the serial console device */ - -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) -{ -	struct platform_device *pdev; - -	switch (id) { -		case 0:		/* DBGU */ -			pdev = &at572d940hf_dbgu_device; -			configure_dbgu_pins(); -			at91_clock_associate("mck", &pdev->dev, "usart"); -			break; -		case AT572D940HF_ID_US0: -			pdev = &at572d940hf_uart0_device; -			configure_usart0_pins(pins); -			at91_clock_associate("usart0_clk", &pdev->dev, "usart"); -			break; -		case AT572D940HF_ID_US1: -			pdev = &at572d940hf_uart1_device; -			configure_usart1_pins(pins); -			at91_clock_associate("usart1_clk", &pdev->dev, "usart"); -			break; -		case AT572D940HF_ID_US2: -			pdev = &at572d940hf_uart2_device; -			configure_usart2_pins(pins); -			at91_clock_associate("usart2_clk", &pdev->dev, "usart"); -			break; -		default: -			return; -	} -	pdev->id = portnr;		/* update to mapped ID */ - -	if (portnr < ATMEL_MAX_UART) -		at91_uarts[portnr] = pdev; -} - -void __init at91_set_serial_console(unsigned portnr) -{ -	if (portnr < ATMEL_MAX_UART) -		atmel_default_console_device = at91_uarts[portnr]; -} - -void __init at91_add_device_serial(void) -{ -	int i; - -	for (i = 0; i < ATMEL_MAX_UART; i++) { -		if (at91_uarts[i]) -			platform_device_register(at91_uarts[i]); -	} - -	if (!atmel_default_console_device) -		printk(KERN_INFO "AT91: No default serial console defined.\n"); -} - -#else -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {} -void __init at91_add_device_serial(void) {} -#endif - - -/* -------------------------------------------------------------------- - *  mAgic - * -------------------------------------------------------------------- */ - -#ifdef CONFIG_MAGICV -static struct resource mAgic_resources[] = { -	{ -		.start = AT91_MAGIC_PM_BASE, -		.end   = AT91_MAGIC_PM_BASE + AT91_MAGIC_PM_SIZE - 1, -		.flags = IORESOURCE_MEM, -	}, -	{ -		.start = AT91_MAGIC_DM_I_BASE, -		.end   = AT91_MAGIC_DM_I_BASE + AT91_MAGIC_DM_I_SIZE - 1, -		.flags = IORESOURCE_MEM, -	}, -	{ -		.start = AT91_MAGIC_DM_F_BASE, -		.end   = AT91_MAGIC_DM_F_BASE + AT91_MAGIC_DM_F_SIZE - 1, -		.flags = IORESOURCE_MEM, -	}, -	{ -		.start = AT91_MAGIC_DM_DB_BASE, -		.end   = AT91_MAGIC_DM_DB_BASE + AT91_MAGIC_DM_DB_SIZE - 1, -		.flags = IORESOURCE_MEM, -	}, -	{ -		.start = AT91_MAGIC_REGS_BASE, -		.end   = AT91_MAGIC_REGS_BASE + AT91_MAGIC_REGS_SIZE - 1, -		.flags = IORESOURCE_MEM, -	}, -	{ -		.start = AT91_MAGIC_EXTPAGE_BASE, -		.end   = AT91_MAGIC_EXTPAGE_BASE + AT91_MAGIC_EXTPAGE_SIZE - 1, -		.flags = IORESOURCE_MEM, -	}, -	{ -		.start  = AT572D940HF_ID_MSIRQ0, -		.end    = AT572D940HF_ID_MSIRQ0, -		.flags  = IORESOURCE_IRQ, -	}, -	{ -		.start  = AT572D940HF_ID_MHALT, -		.end    = AT572D940HF_ID_MHALT, -		.flags  = IORESOURCE_IRQ, -	}, -	{ -		.start  = AT572D940HF_ID_MEXC, -		.end    = AT572D940HF_ID_MEXC, -		.flags  = IORESOURCE_IRQ, -	}, -	{ -		.start  = AT572D940HF_ID_MEDMA, -		.end    = AT572D940HF_ID_MEDMA, -		.flags  = IORESOURCE_IRQ, -	}, -}; - -static struct platform_device mAgic_device = { -	.name           = "mAgic", -	.id             = -1, -	.num_resources  = ARRAY_SIZE(mAgic_resources), -	.resource       = mAgic_resources, -}; - -void __init at91_add_device_mAgic(void) -{ -	platform_device_register(&mAgic_device); -} -#else -void __init at91_add_device_mAgic(void) {} -#endif - - -/* -------------------------------------------------------------------- */ - -/* - * These devices are always present and don't need any board-specific - * setup. - */ -static int __init at91_add_standard_devices(void) -{ -	at91_add_device_rtt(); -	at91_add_device_watchdog(); -	at91_add_device_tc(); -	return 0; -} - -arch_initcall(at91_add_standard_devices); diff --git a/arch/arm/mach-at91/at91_aic.h b/arch/arm/mach-at91/at91_aic.h new file mode 100644 index 00000000000..eaea66197fa --- /dev/null +++ b/arch/arm/mach-at91/at91_aic.h @@ -0,0 +1,99 @@ +/* + * arch/arm/mach-at91/include/mach/at91_aic.h + * + * Copyright (C) 2005 Ivan Kokshaysky + * Copyright (C) SAN People + * + * Advanced Interrupt Controller (AIC) - System peripherals registers. + * Based on AT91RM9200 datasheet revision E. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef AT91_AIC_H +#define AT91_AIC_H + +#ifndef __ASSEMBLY__ +extern void __iomem *at91_aic_base; + +#define at91_aic_read(field) \ +	__raw_readl(at91_aic_base + field) + +#define at91_aic_write(field, value) \ +	__raw_writel(value, at91_aic_base + field) +#else +.extern at91_aic_base +#endif + +/* Number of irq lines managed by AIC */ +#define NR_AIC_IRQS	32 +#define NR_AIC5_IRQS	128 + +#define AT91_AIC5_SSR		0x0			/* Source Select Register [AIC5] */ +#define 	AT91_AIC5_INTSEL_MSK	(0x7f << 0)		/* Interrupt Line Selection Mask */ + +#define AT91_AIC_IRQ_MIN_PRIORITY	0 +#define AT91_AIC_IRQ_MAX_PRIORITY	7 + +#define AT91_AIC_SMR(n)		((n) * 4)		/* Source Mode Registers 0-31 */ +#define AT91_AIC5_SMR		0x4			/* Source Mode Register [AIC5] */ +#define		AT91_AIC_PRIOR		(7 << 0)		/* Priority Level */ +#define		AT91_AIC_SRCTYPE	(3 << 5)		/* Interrupt Source Type */ +#define			AT91_AIC_SRCTYPE_LOW		(0 << 5) +#define			AT91_AIC_SRCTYPE_FALLING	(1 << 5) +#define			AT91_AIC_SRCTYPE_HIGH		(2 << 5) +#define			AT91_AIC_SRCTYPE_RISING		(3 << 5) + +#define AT91_AIC_SVR(n)		(0x80 + ((n) * 4))	/* Source Vector Registers 0-31 */ +#define AT91_AIC5_SVR		0x8			/* Source Vector Register [AIC5] */ +#define AT91_AIC_IVR		0x100			/* Interrupt Vector Register */ +#define AT91_AIC5_IVR		0x10			/* Interrupt Vector Register [AIC5] */ +#define AT91_AIC_FVR		0x104			/* Fast Interrupt Vector Register */ +#define AT91_AIC5_FVR		0x14			/* Fast Interrupt Vector Register [AIC5] */ +#define AT91_AIC_ISR		0x108			/* Interrupt Status Register */ +#define AT91_AIC5_ISR		0x18			/* Interrupt Status Register [AIC5] */ +#define		AT91_AIC_IRQID		(0x1f << 0)		/* Current Interrupt Identifier */ + +#define AT91_AIC_IPR		0x10c			/* Interrupt Pending Register */ +#define AT91_AIC5_IPR0		0x20			/* Interrupt Pending Register 0 [AIC5] */ +#define AT91_AIC5_IPR1		0x24			/* Interrupt Pending Register 1 [AIC5] */ +#define AT91_AIC5_IPR2		0x28			/* Interrupt Pending Register 2 [AIC5] */ +#define AT91_AIC5_IPR3		0x2c			/* Interrupt Pending Register 3 [AIC5] */ +#define AT91_AIC_IMR		0x110			/* Interrupt Mask Register */ +#define AT91_AIC5_IMR		0x30			/* Interrupt Mask Register [AIC5] */ +#define AT91_AIC_CISR		0x114			/* Core Interrupt Status Register */ +#define AT91_AIC5_CISR		0x34			/* Core Interrupt Status Register [AIC5] */ +#define		AT91_AIC_NFIQ		(1 << 0)		/* nFIQ Status */ +#define		AT91_AIC_NIRQ		(1 << 1)		/* nIRQ Status */ + +#define AT91_AIC_IECR		0x120			/* Interrupt Enable Command Register */ +#define AT91_AIC5_IECR		0x40			/* Interrupt Enable Command Register [AIC5] */ +#define AT91_AIC_IDCR		0x124			/* Interrupt Disable Command Register */ +#define AT91_AIC5_IDCR		0x44			/* Interrupt Disable Command Register [AIC5] */ +#define AT91_AIC_ICCR		0x128			/* Interrupt Clear Command Register */ +#define AT91_AIC5_ICCR		0x48			/* Interrupt Clear Command Register [AIC5] */ +#define AT91_AIC_ISCR		0x12c			/* Interrupt Set Command Register */ +#define AT91_AIC5_ISCR		0x4c			/* Interrupt Set Command Register [AIC5] */ +#define AT91_AIC_EOICR		0x130			/* End of Interrupt Command Register */ +#define AT91_AIC5_EOICR		0x38			/* End of Interrupt Command Register [AIC5] */ +#define AT91_AIC_SPU		0x134			/* Spurious Interrupt Vector Register */ +#define AT91_AIC5_SPU		0x3c			/* Spurious Interrupt Vector Register [AIC5] */ +#define AT91_AIC_DCR		0x138			/* Debug Control Register */ +#define AT91_AIC5_DCR		0x6c			/* Debug Control Register [AIC5] */ +#define		AT91_AIC_DCR_PROT	(1 << 0)		/* Protection Mode */ +#define		AT91_AIC_DCR_GMSK	(1 << 1)		/* General Mask */ + +#define AT91_AIC_FFER		0x140			/* Fast Forcing Enable Register [SAM9 only] */ +#define AT91_AIC5_FFER		0x50			/* Fast Forcing Enable Register [AIC5] */ +#define AT91_AIC_FFDR		0x144			/* Fast Forcing Disable Register [SAM9 only] */ +#define AT91_AIC5_FFDR		0x54			/* Fast Forcing Disable Register [AIC5] */ +#define AT91_AIC_FFSR		0x148			/* Fast Forcing Status Register [SAM9 only] */ +#define AT91_AIC5_FFSR		0x58			/* Fast Forcing Status Register [AIC5] */ + +void at91_aic_handle_irq(struct pt_regs *regs); +void at91_aic5_handle_irq(struct pt_regs *regs); + +#endif diff --git a/arch/arm/mach-at91/include/mach/at91_rstc.h b/arch/arm/mach-at91/at91_rstc.h index cbd2bf052c1..a600e699292 100644 --- a/arch/arm/mach-at91/include/mach/at91_rstc.h +++ b/arch/arm/mach-at91/at91_rstc.h @@ -16,13 +16,25 @@  #ifndef AT91_RSTC_H  #define AT91_RSTC_H -#define AT91_RSTC_CR		(AT91_RSTC + 0x00)	/* Reset Controller Control Register */ +#ifndef __ASSEMBLY__ +extern void __iomem *at91_rstc_base; + +#define at91_rstc_read(field) \ +	__raw_readl(at91_rstc_base + field) + +#define at91_rstc_write(field, value) \ +	__raw_writel(value, at91_rstc_base + field) +#else +.extern at91_rstc_base +#endif + +#define AT91_RSTC_CR		0x00			/* Reset Controller Control Register */  #define		AT91_RSTC_PROCRST	(1 << 0)		/* Processor Reset */  #define		AT91_RSTC_PERRST	(1 << 2)		/* Peripheral Reset */  #define		AT91_RSTC_EXTRST	(1 << 3)		/* External Reset */  #define		AT91_RSTC_KEY		(0xa5 << 24)		/* KEY Password */ -#define AT91_RSTC_SR		(AT91_RSTC + 0x04)	/* Reset Controller Status Register */ +#define AT91_RSTC_SR		0x04			/* Reset Controller Status Register */  #define		AT91_RSTC_URSTS		(1 << 0)		/* User Reset Status */  #define		AT91_RSTC_RSTTYP	(7 << 8)		/* Reset Type */  #define			AT91_RSTC_RSTTYP_GENERAL	(0 << 8) @@ -33,7 +45,7 @@  #define		AT91_RSTC_NRSTL		(1 << 16)		/* NRST Pin Level */  #define		AT91_RSTC_SRCMP		(1 << 17)		/* Software Reset Command in Progress */ -#define AT91_RSTC_MR		(AT91_RSTC + 0x08)	/* Reset Controller Mode Register */ +#define AT91_RSTC_MR		0x08			/* Reset Controller Mode Register */  #define		AT91_RSTC_URSTEN	(1 << 0)		/* User Reset Enable */  #define		AT91_RSTC_URSTIEN	(1 << 4)		/* User Reset Interrupt Enable */  #define		AT91_RSTC_ERSTL		(0xf << 8)		/* External Reset Length */ diff --git a/arch/arm/mach-at91/include/mach/at91_shdwc.h b/arch/arm/mach-at91/at91_shdwc.h index c4ce07e8a8f..9e29f31ec9a 100644 --- a/arch/arm/mach-at91/include/mach/at91_shdwc.h +++ b/arch/arm/mach-at91/at91_shdwc.h @@ -16,21 +16,33 @@  #ifndef AT91_SHDWC_H  #define AT91_SHDWC_H -#define AT91_SHDW_CR		(AT91_SHDWC + 0x00)	/* Shut Down Control Register */ +#ifndef __ASSEMBLY__ +extern void __iomem *at91_shdwc_base; + +#define at91_shdwc_read(field) \ +	__raw_readl(at91_shdwc_base + field) + +#define at91_shdwc_write(field, value) \ +	__raw_writel(value, at91_shdwc_base + field) +#endif + +#define AT91_SHDW_CR		0x00			/* Shut Down Control Register */  #define		AT91_SHDW_SHDW		(1    << 0)		/* Shut Down command */  #define		AT91_SHDW_KEY		(0xa5 << 24)		/* KEY Password */ -#define AT91_SHDW_MR		(AT91_SHDWC + 0x04)	/* Shut Down Mode Register */ +#define AT91_SHDW_MR		0x04			/* Shut Down Mode Register */  #define		AT91_SHDW_WKMODE0	(3 << 0)		/* Wake-up 0 Mode Selection */  #define			AT91_SHDW_WKMODE0_NONE		0  #define			AT91_SHDW_WKMODE0_HIGH		1  #define			AT91_SHDW_WKMODE0_LOW		2  #define			AT91_SHDW_WKMODE0_ANYLEVEL	3 -#define		AT91_SHDW_CPTWK0	(0xf << 4)		/* Counter On Wake Up 0 */ +#define		AT91_SHDW_CPTWK0_MAX	0xf			/* Maximum Counter On Wake Up 0 */ +#define		AT91_SHDW_CPTWK0	(AT91_SHDW_CPTWK0_MAX << 4) /* Counter On Wake Up 0 */  #define			AT91_SHDW_CPTWK0_(x)	((x) << 4)  #define		AT91_SHDW_RTTWKEN	(1   << 16)		/* Real Time Timer Wake-up Enable */ +#define		AT91_SHDW_RTCWKEN	(1   << 17)		/* Real Time Clock Wake-up Enable */ -#define AT91_SHDW_SR		(AT91_SHDWC + 0x08)	/* Shut Down Status Register */ +#define AT91_SHDW_SR		0x08			/* Shut Down Status Register */  #define		AT91_SHDW_WAKEUP0	(1 <<  0)		/* Wake-up 0 Status */  #define		AT91_SHDW_RTTWK		(1 << 16)		/* Real-time Timer Wake-up */  #define		AT91_SHDW_RTCWK		(1 << 17)		/* Real-time Clock Wake-up [SAM9RL] */ diff --git a/arch/arm/mach-at91/include/mach/at91_tc.h b/arch/arm/mach-at91/at91_tc.h index 46a317fd716..46a317fd716 100644 --- a/arch/arm/mach-at91/include/mach/at91_tc.h +++ b/arch/arm/mach-at91/at91_tc.h diff --git a/arch/arm/mach-at91/at91cap9.c b/arch/arm/mach-at91/at91cap9.c deleted file mode 100644 index 73376170fb9..00000000000 --- a/arch/arm/mach-at91/at91cap9.c +++ /dev/null @@ -1,383 +0,0 @@ -/* - * arch/arm/mach-at91/at91cap9.c - * - *  Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com> - *  Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com> - *  Copyright (C) 2007 Atmel Corporation. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - */ - -#include <linux/module.h> -#include <linux/pm.h> - -#include <asm/irq.h> -#include <asm/mach/arch.h> -#include <asm/mach/map.h> - -#include <mach/cpu.h> -#include <mach/at91cap9.h> -#include <mach/at91_pmc.h> -#include <mach/at91_rstc.h> -#include <mach/at91_shdwc.h> - -#include "generic.h" -#include "clock.h" - -static struct map_desc at91cap9_io_desc[] __initdata = { -	{ -		.virtual	= AT91_VA_BASE_SYS, -		.pfn		= __phys_to_pfn(AT91_BASE_SYS), -		.length		= SZ_16K, -		.type		= MT_DEVICE, -	}, { -		.virtual	= AT91_IO_VIRT_BASE - AT91CAP9_SRAM_SIZE, -		.pfn		= __phys_to_pfn(AT91CAP9_SRAM_BASE), -		.length		= AT91CAP9_SRAM_SIZE, -		.type		= MT_DEVICE, -	}, -}; - -/* -------------------------------------------------------------------- - *  Clocks - * -------------------------------------------------------------------- */ - -/* - * The peripheral clocks. - */ -static struct clk pioABCD_clk = { -	.name		= "pioABCD_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_PIOABCD, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk mpb0_clk = { -	.name		= "mpb0_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_MPB0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk mpb1_clk = { -	.name		= "mpb1_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_MPB1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk mpb2_clk = { -	.name		= "mpb2_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_MPB2, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk mpb3_clk = { -	.name		= "mpb3_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_MPB3, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk mpb4_clk = { -	.name		= "mpb4_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_MPB4, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk usart0_clk = { -	.name		= "usart0_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_US0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk usart1_clk = { -	.name		= "usart1_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_US1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk usart2_clk = { -	.name		= "usart2_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_US2, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk mmc0_clk = { -	.name		= "mci0_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_MCI0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk mmc1_clk = { -	.name		= "mci1_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_MCI1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk can_clk = { -	.name		= "can_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_CAN, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk twi_clk = { -	.name		= "twi_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_TWI, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk spi0_clk = { -	.name		= "spi0_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_SPI0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk spi1_clk = { -	.name		= "spi1_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_SPI1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk ssc0_clk = { -	.name		= "ssc0_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_SSC0, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk ssc1_clk = { -	.name		= "ssc1_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_SSC1, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk ac97_clk = { -	.name		= "ac97_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_AC97C, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk tcb_clk = { -	.name		= "tcb_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_TCB, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk pwm_clk = { -	.name		= "pwm_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_PWMC, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk macb_clk = { -	.name		= "macb_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_EMAC, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk aestdes_clk = { -	.name		= "aestdes_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_AESTDES, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk adc_clk = { -	.name		= "adc_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_ADC, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk isi_clk = { -	.name		= "isi_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_ISI, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk lcdc_clk = { -	.name		= "lcdc_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_LCDC, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk dma_clk = { -	.name		= "dma_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_DMA, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk udphs_clk = { -	.name		= "udphs_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_UDPHS, -	.type		= CLK_TYPE_PERIPHERAL, -}; -static struct clk ohci_clk = { -	.name		= "ohci_clk", -	.pmc_mask	= 1 << AT91CAP9_ID_UHP, -	.type		= CLK_TYPE_PERIPHERAL, -}; - -static struct clk *periph_clocks[] __initdata = { -	&pioABCD_clk, -	&mpb0_clk, -	&mpb1_clk, -	&mpb2_clk, -	&mpb3_clk, -	&mpb4_clk, -	&usart0_clk, -	&usart1_clk, -	&usart2_clk, -	&mmc0_clk, -	&mmc1_clk, -	&can_clk, -	&twi_clk, -	&spi0_clk, -	&spi1_clk, -	&ssc0_clk, -	&ssc1_clk, -	&ac97_clk, -	&tcb_clk, -	&pwm_clk, -	&macb_clk, -	&aestdes_clk, -	&adc_clk, -	&isi_clk, -	&lcdc_clk, -	&dma_clk, -	&udphs_clk, -	&ohci_clk, -	// irq0 .. irq1 -}; - -/* - * The four programmable clocks. - * You must configure pin multiplexing to bring these signals out. - */ -static struct clk pck0 = { -	.name		= "pck0", -	.pmc_mask	= AT91_PMC_PCK0, -	.type		= CLK_TYPE_PROGRAMMABLE, -	.id		= 0, -}; -static struct clk pck1 = { -	.name		= "pck1", -	.pmc_mask	= AT91_PMC_PCK1, -	.type		= CLK_TYPE_PROGRAMMABLE, -	.id		= 1, -}; -static struct clk pck2 = { -	.name		= "pck2", -	.pmc_mask	= AT91_PMC_PCK2, -	.type		= CLK_TYPE_PROGRAMMABLE, -	.id		= 2, -}; -static struct clk pck3 = { -	.name		= "pck3", -	.pmc_mask	= AT91_PMC_PCK3, -	.type		= CLK_TYPE_PROGRAMMABLE, -	.id		= 3, -}; - -static void __init at91cap9_register_clocks(void) -{ -	int i; - -	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) -		clk_register(periph_clocks[i]); - -	clk_register(&pck0); -	clk_register(&pck1); -	clk_register(&pck2); -	clk_register(&pck3); -} - -/* -------------------------------------------------------------------- - *  GPIO - * -------------------------------------------------------------------- */ - -static struct at91_gpio_bank at91cap9_gpio[] = { -	{ -		.id		= AT91CAP9_ID_PIOABCD, -		.offset		= AT91_PIOA, -		.clock		= &pioABCD_clk, -	}, { -		.id		= AT91CAP9_ID_PIOABCD, -		.offset		= AT91_PIOB, -		.clock		= &pioABCD_clk, -	}, { -		.id		= AT91CAP9_ID_PIOABCD, -		.offset		= AT91_PIOC, -		.clock		= &pioABCD_clk, -	}, { -		.id		= AT91CAP9_ID_PIOABCD, -		.offset		= AT91_PIOD, -		.clock		= &pioABCD_clk, -	} -}; - -static void at91cap9_reset(void) -{ -	at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); -} - -static void at91cap9_poweroff(void) -{ -	at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); -} - - -/* -------------------------------------------------------------------- - *  AT91CAP9 processor initialization - * -------------------------------------------------------------------- */ - -void __init at91cap9_initialize(unsigned long main_clock) -{ -	/* Map peripherals */ -	iotable_init(at91cap9_io_desc, ARRAY_SIZE(at91cap9_io_desc)); - -	at91_arch_reset = at91cap9_reset; -	pm_power_off = at91cap9_poweroff; -	at91_extern_irq = (1 << AT91CAP9_ID_IRQ0) | (1 << AT91CAP9_ID_IRQ1); - -	/* Init clock subsystem */ -	at91_clock_init(main_clock); - -	/* Register the processor-specific clocks */ -	at91cap9_register_clocks(); - -	/* Register GPIO subsystem */ -	at91_gpio_init(at91cap9_gpio, 4); - -	/* Remember the silicon revision */ -	if (cpu_is_at91cap9_revB()) -		system_rev = 0xB; -	else if (cpu_is_at91cap9_revC()) -		system_rev = 0xC; -} - -/* -------------------------------------------------------------------- - *  Interrupt initialization - * -------------------------------------------------------------------- */ - -/* - * The default interrupt priority levels (0 = lowest, 7 = highest). - */ -static unsigned int at91cap9_default_irq_priority[NR_AIC_IRQS] __initdata = { -	7,	/* Advanced Interrupt Controller (FIQ) */ -	7,	/* System Peripherals */ -	1,	/* Parallel IO Controller A, B, C and D */ -	0,	/* MP Block Peripheral 0 */ -	0,	/* MP Block Peripheral 1 */ -	0,	/* MP Block Peripheral 2 */ -	0,	/* MP Block Peripheral 3 */ -	0,	/* MP Block Peripheral 4 */ -	5,	/* USART 0 */ -	5,	/* USART 1 */ -	5,	/* USART 2 */ -	0,	/* Multimedia Card Interface 0 */ -	0,	/* Multimedia Card Interface 1 */ -	3,	/* CAN */ -	6,	/* Two-Wire Interface */ -	5,	/* Serial Peripheral Interface 0 */ -	5,	/* Serial Peripheral Interface 1 */ -	4,	/* Serial Synchronous Controller 0 */ -	4,	/* Serial Synchronous Controller 1 */ -	5,	/* AC97 Controller */ -	0,	/* Timer Counter 0, 1 and 2 */ -	0,	/* Pulse Width Modulation Controller */ -	3,	/* Ethernet */ -	0,	/* Advanced Encryption Standard, Triple DES*/ -	0,	/* Analog-to-Digital Converter */ -	0,	/* Image Sensor Interface */ -	3,	/* LCD Controller */ -	0,	/* DMA Controller */ -	2,	/* USB Device Port */ -	2,	/* USB Host port */ -	0,	/* Advanced Interrupt Controller (IRQ0) */ -	0,	/* Advanced Interrupt Controller (IRQ1) */ -}; - -void __init at91cap9_init_interrupts(unsigned int priority[NR_AIC_IRQS]) -{ -	if (!priority) -		priority = at91cap9_default_irq_priority; - -	/* Initialize the AIC interrupt controller */ -	at91_aic_init(priority); - -	/* Enable GPIO interrupts */ -	at91_gpio_irq_setup(); -} diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c deleted file mode 100644 index d1f775e8635..00000000000 --- a/arch/arm/mach-at91/at91cap9_devices.c +++ /dev/null @@ -1,1271 +0,0 @@ -/* - * arch/arm/mach-at91/at91cap9_devices.c - * - *  Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com> - *  Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com> - *  Copyright (C) 2007 Atmel Corporation. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - */ -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/mach/irq.h> - -#include <linux/dma-mapping.h> -#include <linux/platform_device.h> -#include <linux/i2c-gpio.h> - -#include <video/atmel_lcdc.h> - -#include <mach/board.h> -#include <mach/cpu.h> -#include <mach/gpio.h> -#include <mach/at91cap9.h> -#include <mach/at91cap9_matrix.h> -#include <mach/at91sam9_smc.h> - -#include "generic.h" - - -/* -------------------------------------------------------------------- - *  USB Host - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) -static u64 ohci_dmamask = DMA_BIT_MASK(32); -static struct at91_usbh_data usbh_data; - -static struct resource usbh_resources[] = { -	[0] = { -		.start	= AT91CAP9_UHP_BASE, -		.end	= AT91CAP9_UHP_BASE + SZ_1M - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_UHP, -		.end	= AT91CAP9_ID_UHP, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91_usbh_device = { -	.name		= "at91_ohci", -	.id		= -1, -	.dev		= { -				.dma_mask		= &ohci_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &usbh_data, -	}, -	.resource	= usbh_resources, -	.num_resources	= ARRAY_SIZE(usbh_resources), -}; - -void __init at91_add_device_usbh(struct at91_usbh_data *data) -{ -	int i; - -	if (!data) -		return; - -	if (cpu_is_at91cap9_revB()) -		set_irq_type(AT91CAP9_ID_UHP, IRQ_TYPE_LEVEL_HIGH); - -	/* Enable VBus control for UHP ports */ -	for (i = 0; i < data->ports; i++) { -		if (data->vbus_pin[i]) -			at91_set_gpio_output(data->vbus_pin[i], 0); -	} - -	usbh_data = *data; -	platform_device_register(&at91_usbh_device); -} -#else -void __init at91_add_device_usbh(struct at91_usbh_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  USB HS Device (Gadget) - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_USB_GADGET_ATMEL_USBA) || defined(CONFIG_USB_GADGET_ATMEL_USBA_MODULE) - -static struct resource usba_udc_resources[] = { -	[0] = { -		.start	= AT91CAP9_UDPHS_FIFO, -		.end	= AT91CAP9_UDPHS_FIFO + SZ_512K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_BASE_UDPHS, -		.end	= AT91CAP9_BASE_UDPHS + SZ_1K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[2] = { -		.start	= AT91CAP9_ID_UDPHS, -		.end	= AT91CAP9_ID_UDPHS, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -#define EP(nam, idx, maxpkt, maxbk, dma, isoc)			\ -	[idx] = {						\ -		.name		= nam,				\ -		.index		= idx,				\ -		.fifo_size	= maxpkt,			\ -		.nr_banks	= maxbk,			\ -		.can_dma	= dma,				\ -		.can_isoc	= isoc,				\ -	} - -static struct usba_ep_data usba_udc_ep[] = { -	EP("ep0", 0,   64, 1, 0, 0), -	EP("ep1", 1, 1024, 3, 1, 1), -	EP("ep2", 2, 1024, 3, 1, 1), -	EP("ep3", 3, 1024, 2, 1, 1), -	EP("ep4", 4, 1024, 2, 1, 1), -	EP("ep5", 5, 1024, 2, 1, 0), -	EP("ep6", 6, 1024, 2, 1, 0), -	EP("ep7", 7, 1024, 2, 0, 0), -}; - -#undef EP - -/* - * pdata doesn't have room for any endpoints, so we need to - * append room for the ones we need right after it. - */ -static struct { -	struct usba_platform_data pdata; -	struct usba_ep_data ep[8]; -} usba_udc_data; - -static struct platform_device at91_usba_udc_device = { -	.name		= "atmel_usba_udc", -	.id		= -1, -	.dev		= { -				.platform_data	= &usba_udc_data.pdata, -	}, -	.resource	= usba_udc_resources, -	.num_resources	= ARRAY_SIZE(usba_udc_resources), -}; - -void __init at91_add_device_usba(struct usba_platform_data *data) -{ -	if (cpu_is_at91cap9_revB()) { -		set_irq_type(AT91CAP9_ID_UDPHS, IRQ_TYPE_LEVEL_HIGH); -		at91_sys_write(AT91_MATRIX_UDPHS, AT91_MATRIX_SELECT_UDPHS | -						  AT91_MATRIX_UDPHS_BYPASS_LOCK); -	} -	else -		at91_sys_write(AT91_MATRIX_UDPHS, AT91_MATRIX_SELECT_UDPHS); - -	/* -	 * Invalid pins are 0 on AT91, but the usba driver is shared -	 * with AVR32, which use negative values instead. Once/if -	 * gpio_is_valid() is ported to AT91, revisit this code. -	 */ -	usba_udc_data.pdata.vbus_pin = -EINVAL; -	usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep); -	memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));; - -	if (data && data->vbus_pin > 0) { -		at91_set_gpio_input(data->vbus_pin, 0); -		at91_set_deglitch(data->vbus_pin, 1); -		usba_udc_data.pdata.vbus_pin = data->vbus_pin; -	} - -	/* Pullup pin is handled internally by USB device peripheral */ - -	/* Clocks */ -	at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk"); -	at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk"); - -	platform_device_register(&at91_usba_udc_device); -} -#else -void __init at91_add_device_usba(struct usba_platform_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  Ethernet - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE) -static u64 eth_dmamask = DMA_BIT_MASK(32); -static struct at91_eth_data eth_data; - -static struct resource eth_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_EMAC, -		.end	= AT91CAP9_BASE_EMAC + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_EMAC, -		.end	= AT91CAP9_ID_EMAC, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_eth_device = { -	.name		= "macb", -	.id		= -1, -	.dev		= { -				.dma_mask		= ð_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= ð_data, -	}, -	.resource	= eth_resources, -	.num_resources	= ARRAY_SIZE(eth_resources), -}; - -void __init at91_add_device_eth(struct at91_eth_data *data) -{ -	if (!data) -		return; - -	if (data->phy_irq_pin) { -		at91_set_gpio_input(data->phy_irq_pin, 0); -		at91_set_deglitch(data->phy_irq_pin, 1); -	} - -	/* Pins used for MII and RMII */ -	at91_set_A_periph(AT91_PIN_PB21, 0);	/* ETXCK_EREFCK */ -	at91_set_A_periph(AT91_PIN_PB22, 0);	/* ERXDV */ -	at91_set_A_periph(AT91_PIN_PB25, 0);	/* ERX0 */ -	at91_set_A_periph(AT91_PIN_PB26, 0);	/* ERX1 */ -	at91_set_A_periph(AT91_PIN_PB27, 0);	/* ERXER */ -	at91_set_A_periph(AT91_PIN_PB28, 0);	/* ETXEN */ -	at91_set_A_periph(AT91_PIN_PB23, 0);	/* ETX0 */ -	at91_set_A_periph(AT91_PIN_PB24, 0);	/* ETX1 */ -	at91_set_A_periph(AT91_PIN_PB30, 0);	/* EMDIO */ -	at91_set_A_periph(AT91_PIN_PB29, 0);	/* EMDC */ - -	if (!data->is_rmii) { -		at91_set_B_periph(AT91_PIN_PC25, 0);	/* ECRS */ -		at91_set_B_periph(AT91_PIN_PC26, 0);	/* ECOL */ -		at91_set_B_periph(AT91_PIN_PC22, 0);	/* ERX2 */ -		at91_set_B_periph(AT91_PIN_PC23, 0);	/* ERX3 */ -		at91_set_B_periph(AT91_PIN_PC27, 0);	/* ERXCK */ -		at91_set_B_periph(AT91_PIN_PC20, 0);	/* ETX2 */ -		at91_set_B_periph(AT91_PIN_PC21, 0);	/* ETX3 */ -		at91_set_B_periph(AT91_PIN_PC24, 0);	/* ETXER */ -	} - -	eth_data = *data; -	platform_device_register(&at91cap9_eth_device); -} -#else -void __init at91_add_device_eth(struct at91_eth_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  MMC / SD - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) -static u64 mmc_dmamask = DMA_BIT_MASK(32); -static struct at91_mmc_data mmc0_data, mmc1_data; - -static struct resource mmc0_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_MCI0, -		.end	= AT91CAP9_BASE_MCI0 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_MCI0, -		.end	= AT91CAP9_ID_MCI0, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_mmc0_device = { -	.name		= "at91_mci", -	.id		= 0, -	.dev		= { -				.dma_mask		= &mmc_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &mmc0_data, -	}, -	.resource	= mmc0_resources, -	.num_resources	= ARRAY_SIZE(mmc0_resources), -}; - -static struct resource mmc1_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_MCI1, -		.end	= AT91CAP9_BASE_MCI1 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_MCI1, -		.end	= AT91CAP9_ID_MCI1, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_mmc1_device = { -	.name		= "at91_mci", -	.id		= 1, -	.dev		= { -				.dma_mask		= &mmc_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &mmc1_data, -	}, -	.resource	= mmc1_resources, -	.num_resources	= ARRAY_SIZE(mmc1_resources), -}; - -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) -{ -	if (!data) -		return; - -	/* input/irq */ -	if (data->det_pin) { -		at91_set_gpio_input(data->det_pin, 1); -		at91_set_deglitch(data->det_pin, 1); -	} -	if (data->wp_pin) -		at91_set_gpio_input(data->wp_pin, 1); -	if (data->vcc_pin) -		at91_set_gpio_output(data->vcc_pin, 0); - -	if (mmc_id == 0) {		/* MCI0 */ -		/* CLK */ -		at91_set_A_periph(AT91_PIN_PA2, 0); - -		/* CMD */ -		at91_set_A_periph(AT91_PIN_PA1, 1); - -		/* DAT0, maybe DAT1..DAT3 */ -		at91_set_A_periph(AT91_PIN_PA0, 1); -		if (data->wire4) { -			at91_set_A_periph(AT91_PIN_PA3, 1); -			at91_set_A_periph(AT91_PIN_PA4, 1); -			at91_set_A_periph(AT91_PIN_PA5, 1); -		} - -		mmc0_data = *data; -		at91_clock_associate("mci0_clk", &at91cap9_mmc0_device.dev, "mci_clk"); -		platform_device_register(&at91cap9_mmc0_device); -	} else {			/* MCI1 */ -		/* CLK */ -		at91_set_A_periph(AT91_PIN_PA16, 0); - -		/* CMD */ -		at91_set_A_periph(AT91_PIN_PA17, 1); - -		/* DAT0, maybe DAT1..DAT3 */ -		at91_set_A_periph(AT91_PIN_PA18, 1); -		if (data->wire4) { -			at91_set_A_periph(AT91_PIN_PA19, 1); -			at91_set_A_periph(AT91_PIN_PA20, 1); -			at91_set_A_periph(AT91_PIN_PA21, 1); -		} - -		mmc1_data = *data; -		at91_clock_associate("mci1_clk", &at91cap9_mmc1_device.dev, "mci_clk"); -		platform_device_register(&at91cap9_mmc1_device); -	} -} -#else -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  NAND / SmartMedia - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE) -static struct atmel_nand_data nand_data; - -#define NAND_BASE	AT91_CHIPSELECT_3 - -static struct resource nand_resources[] = { -	[0] = { -		.start	= NAND_BASE, -		.end	= NAND_BASE + SZ_256M - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91_BASE_SYS + AT91_ECC, -		.end	= AT91_BASE_SYS + AT91_ECC + SZ_512 - 1, -		.flags	= IORESOURCE_MEM, -	} -}; - -static struct platform_device at91cap9_nand_device = { -	.name		= "atmel_nand", -	.id		= -1, -	.dev		= { -				.platform_data	= &nand_data, -	}, -	.resource	= nand_resources, -	.num_resources	= ARRAY_SIZE(nand_resources), -}; - -void __init at91_add_device_nand(struct atmel_nand_data *data) -{ -	unsigned long csa; - -	if (!data) -		return; - -	csa = at91_sys_read(AT91_MATRIX_EBICSA); -	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA); - -	/* enable pin */ -	if (data->enable_pin) -		at91_set_gpio_output(data->enable_pin, 1); - -	/* ready/busy pin */ -	if (data->rdy_pin) -		at91_set_gpio_input(data->rdy_pin, 1); - -	/* card detect pin */ -	if (data->det_pin) -		at91_set_gpio_input(data->det_pin, 1); - -	nand_data = *data; -	platform_device_register(&at91cap9_nand_device); -} -#else -void __init at91_add_device_nand(struct atmel_nand_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  TWI (i2c) - * -------------------------------------------------------------------- */ - -/* - * Prefer the GPIO code since the TWI controller isn't robust - * (gets overruns and underruns under load) and can only issue - * repeated STARTs in one scenario (the driver doesn't yet handle them). - */ -#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) - -static struct i2c_gpio_platform_data pdata = { -	.sda_pin		= AT91_PIN_PB4, -	.sda_is_open_drain	= 1, -	.scl_pin		= AT91_PIN_PB5, -	.scl_is_open_drain	= 1, -	.udelay			= 2,		/* ~100 kHz */ -}; - -static struct platform_device at91cap9_twi_device = { -	.name			= "i2c-gpio", -	.id			= -1, -	.dev.platform_data	= &pdata, -}; - -void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) -{ -	at91_set_GPIO_periph(AT91_PIN_PB4, 1);		/* TWD (SDA) */ -	at91_set_multi_drive(AT91_PIN_PB4, 1); - -	at91_set_GPIO_periph(AT91_PIN_PB5, 1);		/* TWCK (SCL) */ -	at91_set_multi_drive(AT91_PIN_PB5, 1); - -	i2c_register_board_info(0, devices, nr_devices); -	platform_device_register(&at91cap9_twi_device); -} - -#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) - -static struct resource twi_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_TWI, -		.end	= AT91CAP9_BASE_TWI + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_TWI, -		.end	= AT91CAP9_ID_TWI, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_twi_device = { -	.name		= "at91_i2c", -	.id		= -1, -	.resource	= twi_resources, -	.num_resources	= ARRAY_SIZE(twi_resources), -}; - -void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) -{ -	/* pins used for TWI interface */ -	at91_set_B_periph(AT91_PIN_PB4, 0);		/* TWD */ -	at91_set_multi_drive(AT91_PIN_PB4, 1); - -	at91_set_B_periph(AT91_PIN_PB5, 0);		/* TWCK */ -	at91_set_multi_drive(AT91_PIN_PB5, 1); - -	i2c_register_board_info(0, devices, nr_devices); -	platform_device_register(&at91cap9_twi_device); -} -#else -void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {} -#endif - -/* -------------------------------------------------------------------- - *  SPI - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) -static u64 spi_dmamask = DMA_BIT_MASK(32); - -static struct resource spi0_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_SPI0, -		.end	= AT91CAP9_BASE_SPI0 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_SPI0, -		.end	= AT91CAP9_ID_SPI0, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_spi0_device = { -	.name		= "atmel_spi", -	.id		= 0, -	.dev		= { -				.dma_mask		= &spi_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -	}, -	.resource	= spi0_resources, -	.num_resources	= ARRAY_SIZE(spi0_resources), -}; - -static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA5, AT91_PIN_PA3, AT91_PIN_PD0, AT91_PIN_PD1 }; - -static struct resource spi1_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_SPI1, -		.end	= AT91CAP9_BASE_SPI1 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_SPI1, -		.end	= AT91CAP9_ID_SPI1, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_spi1_device = { -	.name		= "atmel_spi", -	.id		= 1, -	.dev		= { -				.dma_mask		= &spi_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -	}, -	.resource	= spi1_resources, -	.num_resources	= ARRAY_SIZE(spi1_resources), -}; - -static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB15, AT91_PIN_PB16, AT91_PIN_PB17, AT91_PIN_PB18 }; - -void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) -{ -	int i; -	unsigned long cs_pin; -	short enable_spi0 = 0; -	short enable_spi1 = 0; - -	/* Choose SPI chip-selects */ -	for (i = 0; i < nr_devices; i++) { -		if (devices[i].controller_data) -			cs_pin = (unsigned long) devices[i].controller_data; -		else if (devices[i].bus_num == 0) -			cs_pin = spi0_standard_cs[devices[i].chip_select]; -		else -			cs_pin = spi1_standard_cs[devices[i].chip_select]; - -		if (devices[i].bus_num == 0) -			enable_spi0 = 1; -		else -			enable_spi1 = 1; - -		/* enable chip-select pin */ -		at91_set_gpio_output(cs_pin, 1); - -		/* pass chip-select pin to driver */ -		devices[i].controller_data = (void *) cs_pin; -	} - -	spi_register_board_info(devices, nr_devices); - -	/* Configure SPI bus(es) */ -	if (enable_spi0) { -		at91_set_B_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */ -		at91_set_B_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */ -		at91_set_B_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */ - -		at91_clock_associate("spi0_clk", &at91cap9_spi0_device.dev, "spi_clk"); -		platform_device_register(&at91cap9_spi0_device); -	} -	if (enable_spi1) { -		at91_set_A_periph(AT91_PIN_PB12, 0);	/* SPI1_MISO */ -		at91_set_A_periph(AT91_PIN_PB13, 0);	/* SPI1_MOSI */ -		at91_set_A_periph(AT91_PIN_PB14, 0);	/* SPI1_SPCK */ - -		at91_clock_associate("spi1_clk", &at91cap9_spi1_device.dev, "spi_clk"); -		platform_device_register(&at91cap9_spi1_device); -	} -} -#else -void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {} -#endif - - -/* -------------------------------------------------------------------- - *  Timer/Counter block - * -------------------------------------------------------------------- */ - -#ifdef CONFIG_ATMEL_TCLIB - -static struct resource tcb_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_TCB0, -		.end	= AT91CAP9_BASE_TCB0 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_TCB, -		.end	= AT91CAP9_ID_TCB, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_tcb_device = { -	.name		= "atmel_tcb", -	.id		= 0, -	.resource	= tcb_resources, -	.num_resources	= ARRAY_SIZE(tcb_resources), -}; - -static void __init at91_add_device_tc(void) -{ -	/* this chip has one clock and irq for all three TC channels */ -	at91_clock_associate("tcb_clk", &at91cap9_tcb_device.dev, "t0_clk"); -	platform_device_register(&at91cap9_tcb_device); -} -#else -static void __init at91_add_device_tc(void) { } -#endif - - -/* -------------------------------------------------------------------- - *  RTT - * -------------------------------------------------------------------- */ - -static struct resource rtt_resources[] = { -	{ -		.start	= AT91_BASE_SYS + AT91_RTT, -		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1, -		.flags	= IORESOURCE_MEM, -	} -}; - -static struct platform_device at91cap9_rtt_device = { -	.name		= "at91_rtt", -	.id		= 0, -	.resource	= rtt_resources, -	.num_resources	= ARRAY_SIZE(rtt_resources), -}; - -static void __init at91_add_device_rtt(void) -{ -	platform_device_register(&at91cap9_rtt_device); -} - - -/* -------------------------------------------------------------------- - *  Watchdog - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) -static struct platform_device at91cap9_wdt_device = { -	.name		= "at91_wdt", -	.id		= -1, -	.num_resources	= 0, -}; - -static void __init at91_add_device_watchdog(void) -{ -	platform_device_register(&at91cap9_wdt_device); -} -#else -static void __init at91_add_device_watchdog(void) {} -#endif - - -/* -------------------------------------------------------------------- - *  PWM - * --------------------------------------------------------------------*/ - -#if defined(CONFIG_ATMEL_PWM) -static u32 pwm_mask; - -static struct resource pwm_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_PWMC, -		.end	= AT91CAP9_BASE_PWMC + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_PWMC, -		.end	= AT91CAP9_ID_PWMC, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_pwm0_device = { -	.name	= "atmel_pwm", -	.id	= -1, -	.dev	= { -		.platform_data		= &pwm_mask, -	}, -	.resource	= pwm_resources, -	.num_resources	= ARRAY_SIZE(pwm_resources), -}; - -void __init at91_add_device_pwm(u32 mask) -{ -	if (mask & (1 << AT91_PWM0)) -		at91_set_A_periph(AT91_PIN_PB19, 1);	/* enable PWM0 */ - -	if (mask & (1 << AT91_PWM1)) -		at91_set_B_periph(AT91_PIN_PB8, 1);	/* enable PWM1 */ - -	if (mask & (1 << AT91_PWM2)) -		at91_set_B_periph(AT91_PIN_PC29, 1);	/* enable PWM2 */ - -	if (mask & (1 << AT91_PWM3)) -		at91_set_B_periph(AT91_PIN_PA11, 1);	/* enable PWM3 */ - -	pwm_mask = mask; - -	platform_device_register(&at91cap9_pwm0_device); -} -#else -void __init at91_add_device_pwm(u32 mask) {} -#endif - - - -/* -------------------------------------------------------------------- - *  AC97 - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE) -static u64 ac97_dmamask = DMA_BIT_MASK(32); -static struct ac97c_platform_data ac97_data; - -static struct resource ac97_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_AC97C, -		.end	= AT91CAP9_BASE_AC97C + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_AC97C, -		.end	= AT91CAP9_ID_AC97C, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_ac97_device = { -	.name		= "atmel_ac97c", -	.id		= 1, -	.dev		= { -				.dma_mask		= &ac97_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &ac97_data, -	}, -	.resource	= ac97_resources, -	.num_resources	= ARRAY_SIZE(ac97_resources), -}; - -void __init at91_add_device_ac97(struct ac97c_platform_data *data) -{ -	if (!data) -		return; - -	at91_set_A_periph(AT91_PIN_PA6, 0);	/* AC97FS */ -	at91_set_A_periph(AT91_PIN_PA7, 0);	/* AC97CK */ -	at91_set_A_periph(AT91_PIN_PA8, 0);	/* AC97TX */ -	at91_set_A_periph(AT91_PIN_PA9, 0);	/* AC97RX */ - -	/* reset */ -	if (data->reset_pin) -		at91_set_gpio_output(data->reset_pin, 0); - -	ac97_data = *data; -	platform_device_register(&at91cap9_ac97_device); -} -#else -void __init at91_add_device_ac97(struct ac97c_platform_data *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  LCD Controller - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) -static u64 lcdc_dmamask = DMA_BIT_MASK(32); -static struct atmel_lcdfb_info lcdc_data; - -static struct resource lcdc_resources[] = { -	[0] = { -		.start	= AT91CAP9_LCDC_BASE, -		.end	= AT91CAP9_LCDC_BASE + SZ_4K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_LCDC, -		.end	= AT91CAP9_ID_LCDC, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91_lcdc_device = { -	.name		= "atmel_lcdfb", -	.id		= 0, -	.dev		= { -				.dma_mask		= &lcdc_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &lcdc_data, -	}, -	.resource	= lcdc_resources, -	.num_resources	= ARRAY_SIZE(lcdc_resources), -}; - -void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) -{ -	if (!data) -		return; - -	if (cpu_is_at91cap9_revB()) -		set_irq_type(AT91CAP9_ID_LCDC, IRQ_TYPE_LEVEL_HIGH); - -	at91_set_A_periph(AT91_PIN_PC1, 0);	/* LCDHSYNC */ -	at91_set_A_periph(AT91_PIN_PC2, 0);	/* LCDDOTCK */ -	at91_set_A_periph(AT91_PIN_PC3, 0);	/* LCDDEN */ -	at91_set_B_periph(AT91_PIN_PB9, 0);	/* LCDCC */ -	at91_set_A_periph(AT91_PIN_PC6, 0);	/* LCDD2 */ -	at91_set_A_periph(AT91_PIN_PC7, 0);	/* LCDD3 */ -	at91_set_A_periph(AT91_PIN_PC8, 0);	/* LCDD4 */ -	at91_set_A_periph(AT91_PIN_PC9, 0);	/* LCDD5 */ -	at91_set_A_periph(AT91_PIN_PC10, 0);	/* LCDD6 */ -	at91_set_A_periph(AT91_PIN_PC11, 0);	/* LCDD7 */ -	at91_set_A_periph(AT91_PIN_PC14, 0);	/* LCDD10 */ -	at91_set_A_periph(AT91_PIN_PC15, 0);	/* LCDD11 */ -	at91_set_A_periph(AT91_PIN_PC16, 0);	/* LCDD12 */ -	at91_set_A_periph(AT91_PIN_PC17, 0);	/* LCDD13 */ -	at91_set_A_periph(AT91_PIN_PC18, 0);	/* LCDD14 */ -	at91_set_A_periph(AT91_PIN_PC19, 0);	/* LCDD15 */ -	at91_set_A_periph(AT91_PIN_PC22, 0);	/* LCDD18 */ -	at91_set_A_periph(AT91_PIN_PC23, 0);	/* LCDD19 */ -	at91_set_A_periph(AT91_PIN_PC24, 0);	/* LCDD20 */ -	at91_set_A_periph(AT91_PIN_PC25, 0);	/* LCDD21 */ -	at91_set_A_periph(AT91_PIN_PC26, 0);	/* LCDD22 */ -	at91_set_A_periph(AT91_PIN_PC27, 0);	/* LCDD23 */ - -	lcdc_data = *data; -	platform_device_register(&at91_lcdc_device); -} -#else -void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} -#endif - - -/* -------------------------------------------------------------------- - *  SSC -- Synchronous Serial Controller - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE) -static u64 ssc0_dmamask = DMA_BIT_MASK(32); - -static struct resource ssc0_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_SSC0, -		.end	= AT91CAP9_BASE_SSC0 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_SSC0, -		.end	= AT91CAP9_ID_SSC0, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_ssc0_device = { -	.name	= "ssc", -	.id	= 0, -	.dev	= { -		.dma_mask		= &ssc0_dmamask, -		.coherent_dma_mask	= DMA_BIT_MASK(32), -	}, -	.resource	= ssc0_resources, -	.num_resources	= ARRAY_SIZE(ssc0_resources), -}; - -static inline void configure_ssc0_pins(unsigned pins) -{ -	if (pins & ATMEL_SSC_TF) -		at91_set_A_periph(AT91_PIN_PB0, 1); -	if (pins & ATMEL_SSC_TK) -		at91_set_A_periph(AT91_PIN_PB1, 1); -	if (pins & ATMEL_SSC_TD) -		at91_set_A_periph(AT91_PIN_PB2, 1); -	if (pins & ATMEL_SSC_RD) -		at91_set_A_periph(AT91_PIN_PB3, 1); -	if (pins & ATMEL_SSC_RK) -		at91_set_A_periph(AT91_PIN_PB4, 1); -	if (pins & ATMEL_SSC_RF) -		at91_set_A_periph(AT91_PIN_PB5, 1); -} - -static u64 ssc1_dmamask = DMA_BIT_MASK(32); - -static struct resource ssc1_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_SSC1, -		.end	= AT91CAP9_BASE_SSC1 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_SSC1, -		.end	= AT91CAP9_ID_SSC1, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91cap9_ssc1_device = { -	.name	= "ssc", -	.id	= 1, -	.dev	= { -		.dma_mask		= &ssc1_dmamask, -		.coherent_dma_mask	= DMA_BIT_MASK(32), -	}, -	.resource	= ssc1_resources, -	.num_resources	= ARRAY_SIZE(ssc1_resources), -}; - -static inline void configure_ssc1_pins(unsigned pins) -{ -	if (pins & ATMEL_SSC_TF) -		at91_set_A_periph(AT91_PIN_PB6, 1); -	if (pins & ATMEL_SSC_TK) -		at91_set_A_periph(AT91_PIN_PB7, 1); -	if (pins & ATMEL_SSC_TD) -		at91_set_A_periph(AT91_PIN_PB8, 1); -	if (pins & ATMEL_SSC_RD) -		at91_set_A_periph(AT91_PIN_PB9, 1); -	if (pins & ATMEL_SSC_RK) -		at91_set_A_periph(AT91_PIN_PB10, 1); -	if (pins & ATMEL_SSC_RF) -		at91_set_A_periph(AT91_PIN_PB11, 1); -} - -/* - * SSC controllers are accessed through library code, instead of any - * kind of all-singing/all-dancing driver.  For example one could be - * used by a particular I2S audio codec's driver, while another one - * on the same system might be used by a custom data capture driver. - */ -void __init at91_add_device_ssc(unsigned id, unsigned pins) -{ -	struct platform_device *pdev; - -	/* -	 * NOTE: caller is responsible for passing information matching -	 * "pins" to whatever will be using each particular controller. -	 */ -	switch (id) { -	case AT91CAP9_ID_SSC0: -		pdev = &at91cap9_ssc0_device; -		configure_ssc0_pins(pins); -		at91_clock_associate("ssc0_clk", &pdev->dev, "ssc"); -		break; -	case AT91CAP9_ID_SSC1: -		pdev = &at91cap9_ssc1_device; -		configure_ssc1_pins(pins); -		at91_clock_associate("ssc1_clk", &pdev->dev, "ssc"); -		break; -	default: -		return; -	} - -	platform_device_register(pdev); -} - -#else -void __init at91_add_device_ssc(unsigned id, unsigned pins) {} -#endif - - -/* -------------------------------------------------------------------- - *  UART - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_SERIAL_ATMEL) -static struct resource dbgu_resources[] = { -	[0] = { -		.start	= AT91_VA_BASE_SYS + AT91_DBGU, -		.end	= AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91_ID_SYS, -		.end	= AT91_ID_SYS, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct atmel_uart_data dbgu_data = { -	.use_dma_tx	= 0, -	.use_dma_rx	= 0,		/* DBGU not capable of receive DMA */ -	.regs		= (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), -}; - -static u64 dbgu_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91cap9_dbgu_device = { -	.name		= "atmel_usart", -	.id		= 0, -	.dev		= { -				.dma_mask		= &dbgu_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &dbgu_data, -	}, -	.resource	= dbgu_resources, -	.num_resources	= ARRAY_SIZE(dbgu_resources), -}; - -static inline void configure_dbgu_pins(void) -{ -	at91_set_A_periph(AT91_PIN_PC30, 0);		/* DRXD */ -	at91_set_A_periph(AT91_PIN_PC31, 1);		/* DTXD */ -} - -static struct resource uart0_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_US0, -		.end	= AT91CAP9_BASE_US0 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_US0, -		.end	= AT91CAP9_ID_US0, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct atmel_uart_data uart0_data = { -	.use_dma_tx	= 1, -	.use_dma_rx	= 1, -}; - -static u64 uart0_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91cap9_uart0_device = { -	.name		= "atmel_usart", -	.id		= 1, -	.dev		= { -				.dma_mask		= &uart0_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &uart0_data, -	}, -	.resource	= uart0_resources, -	.num_resources	= ARRAY_SIZE(uart0_resources), -}; - -static inline void configure_usart0_pins(unsigned pins) -{ -	at91_set_A_periph(AT91_PIN_PA22, 1);		/* TXD0 */ -	at91_set_A_periph(AT91_PIN_PA23, 0);		/* RXD0 */ - -	if (pins & ATMEL_UART_RTS) -		at91_set_A_periph(AT91_PIN_PA24, 0);	/* RTS0 */ -	if (pins & ATMEL_UART_CTS) -		at91_set_A_periph(AT91_PIN_PA25, 0);	/* CTS0 */ -} - -static struct resource uart1_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_US1, -		.end	= AT91CAP9_BASE_US1 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_US1, -		.end	= AT91CAP9_ID_US1, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct atmel_uart_data uart1_data = { -	.use_dma_tx	= 1, -	.use_dma_rx	= 1, -}; - -static u64 uart1_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91cap9_uart1_device = { -	.name		= "atmel_usart", -	.id		= 2, -	.dev		= { -				.dma_mask		= &uart1_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &uart1_data, -	}, -	.resource	= uart1_resources, -	.num_resources	= ARRAY_SIZE(uart1_resources), -}; - -static inline void configure_usart1_pins(unsigned pins) -{ -	at91_set_A_periph(AT91_PIN_PD0, 1);		/* TXD1 */ -	at91_set_A_periph(AT91_PIN_PD1, 0);		/* RXD1 */ - -	if (pins & ATMEL_UART_RTS) -		at91_set_B_periph(AT91_PIN_PD7, 0);	/* RTS1 */ -	if (pins & ATMEL_UART_CTS) -		at91_set_B_periph(AT91_PIN_PD8, 0);	/* CTS1 */ -} - -static struct resource uart2_resources[] = { -	[0] = { -		.start	= AT91CAP9_BASE_US2, -		.end	= AT91CAP9_BASE_US2 + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91CAP9_ID_US2, -		.end	= AT91CAP9_ID_US2, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct atmel_uart_data uart2_data = { -	.use_dma_tx	= 1, -	.use_dma_rx	= 1, -}; - -static u64 uart2_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91cap9_uart2_device = { -	.name		= "atmel_usart", -	.id		= 3, -	.dev		= { -				.dma_mask		= &uart2_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &uart2_data, -	}, -	.resource	= uart2_resources, -	.num_resources	= ARRAY_SIZE(uart2_resources), -}; - -static inline void configure_usart2_pins(unsigned pins) -{ -	at91_set_A_periph(AT91_PIN_PD2, 1);		/* TXD2 */ -	at91_set_A_periph(AT91_PIN_PD3, 0);		/* RXD2 */ - -	if (pins & ATMEL_UART_RTS) -		at91_set_B_periph(AT91_PIN_PD5, 0);	/* RTS2 */ -	if (pins & ATMEL_UART_CTS) -		at91_set_B_periph(AT91_PIN_PD6, 0);	/* CTS2 */ -} - -static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */ -struct platform_device *atmel_default_console_device;	/* the serial console device */ - -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) -{ -	struct platform_device *pdev; - -	switch (id) { -		case 0:		/* DBGU */ -			pdev = &at91cap9_dbgu_device; -			configure_dbgu_pins(); -			at91_clock_associate("mck", &pdev->dev, "usart"); -			break; -		case AT91CAP9_ID_US0: -			pdev = &at91cap9_uart0_device; -			configure_usart0_pins(pins); -			at91_clock_associate("usart0_clk", &pdev->dev, "usart"); -			break; -		case AT91CAP9_ID_US1: -			pdev = &at91cap9_uart1_device; -			configure_usart1_pins(pins); -			at91_clock_associate("usart1_clk", &pdev->dev, "usart"); -			break; -		case AT91CAP9_ID_US2: -			pdev = &at91cap9_uart2_device; -			configure_usart2_pins(pins); -			at91_clock_associate("usart2_clk", &pdev->dev, "usart"); -			break; -		default: -			return; -	} -	pdev->id = portnr;		/* update to mapped ID */ - -	if (portnr < ATMEL_MAX_UART) -		at91_uarts[portnr] = pdev; -} - -void __init at91_set_serial_console(unsigned portnr) -{ -	if (portnr < ATMEL_MAX_UART) -		atmel_default_console_device = at91_uarts[portnr]; -} - -void __init at91_add_device_serial(void) -{ -	int i; - -	for (i = 0; i < ATMEL_MAX_UART; i++) { -		if (at91_uarts[i]) -			platform_device_register(at91_uarts[i]); -	} - -	if (!atmel_default_console_device) -		printk(KERN_INFO "AT91: No default serial console defined.\n"); -} -#else -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {} -void __init at91_add_device_serial(void) {} -#endif - - -/* -------------------------------------------------------------------- */ -/* - * These devices are always present and don't need any board-specific - * setup. - */ -static int __init at91_add_standard_devices(void) -{ -	at91_add_device_rtt(); -	at91_add_device_watchdog(); -	at91_add_device_tc(); -	return 0; -} - -arch_initcall(at91_add_standard_devices); diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c index 2e9ecad97f3..787bb50a4df 100644 --- a/arch/arm/mach-at91/at91rm9200.c +++ b/arch/arm/mach-at91/at91rm9200.c @@ -11,35 +11,24 @@   */  #include <linux/module.h> +#include <linux/reboot.h> +#include <linux/clk/at91_pmc.h>  #include <asm/irq.h>  #include <asm/mach/arch.h>  #include <asm/mach/map.h> +#include <asm/system_misc.h>  #include <mach/at91rm9200.h> -#include <mach/at91_pmc.h>  #include <mach/at91_st.h> +#include <mach/cpu.h> +#include <mach/hardware.h> +#include "at91_aic.h" +#include "soc.h"  #include "generic.h"  #include "clock.h" - -static struct map_desc at91rm9200_io_desc[] __initdata = { -	{ -		.virtual	= AT91_VA_BASE_SYS, -		.pfn		= __phys_to_pfn(AT91_BASE_SYS), -		.length		= SZ_4K, -		.type		= MT_DEVICE, -	}, { -		.virtual	= AT91_VA_BASE_EMAC, -		.pfn		= __phys_to_pfn(AT91RM9200_BASE_EMAC), -		.length		= SZ_16K, -		.type		= MT_DEVICE, -	}, { -		.virtual	= AT91_IO_VIRT_BASE - AT91RM9200_SRAM_SIZE, -		.pfn		= __phys_to_pfn(AT91RM9200_SRAM_BASE), -		.length		= AT91RM9200_SRAM_SIZE, -		.type		= MT_DEVICE, -	}, -}; +#include "sam9_smc.h" +#include "pm.h"  /* --------------------------------------------------------------------   *  Clocks @@ -191,6 +180,57 @@ static struct clk *periph_clocks[] __initdata = {  	// irq0 .. irq6  }; +static struct clk_lookup periph_clocks_lookups[] = { +	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.2", &ssc2_clk), +	CLKDEV_CON_DEV_ID("pclk", "fffd0000.ssc", &ssc0_clk), +	CLKDEV_CON_DEV_ID("pclk", "fffd4000.ssc", &ssc1_clk), +	CLKDEV_CON_DEV_ID("pclk", "fffd8000.ssc", &ssc2_clk), +	CLKDEV_CON_DEV_ID(NULL, "i2c-at91rm9200.0", &twi_clk), +	/* fake hclk clock */ +	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk), +	CLKDEV_CON_ID("pioA", &pioA_clk), +	CLKDEV_CON_ID("pioB", &pioB_clk), +	CLKDEV_CON_ID("pioC", &pioC_clk), +	CLKDEV_CON_ID("pioD", &pioD_clk), +	/* usart lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck), +	CLKDEV_CON_DEV_ID("usart", "fffc0000.serial", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "fffc4000.serial", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "fffc8000.serial", &usart2_clk), +	CLKDEV_CON_DEV_ID("usart", "fffcc000.serial", &usart3_clk), +	/* tc lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("t0_clk", "fffa0000.timer", &tc0_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "fffa0000.timer", &tc1_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "fffa0000.timer", &tc2_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "fffa4000.timer", &tc3_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "fffa4000.timer", &tc4_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "fffa4000.timer", &tc5_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "fffb4000.mmc", &mmc_clk), +	CLKDEV_CON_DEV_ID("emac_clk", "fffbc000.ethernet", ðer_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffb8000.i2c", &twi_clk), +	CLKDEV_CON_DEV_ID("hclk", "300000.ohci", &ohci_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioA_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioB_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioC_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioD_clk), +}; + +static struct clk_lookup usart_clocks_lookups[] = { +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.4", &usart3_clk), +}; +  /*   * The four programmable clocks.   * You must configure pin multiplexing to bring these signals out. @@ -227,6 +267,11 @@ static void __init at91rm9200_register_clocks(void)  	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)  		clk_register(periph_clocks[i]); +	clkdev_add_table(periph_clocks_lookups, +			 ARRAY_SIZE(periph_clocks_lookups)); +	clkdev_add_table(usart_clocks_lookups, +			 ARRAY_SIZE(usart_clocks_lookups)); +  	clk_register(&pck0);  	clk_register(&pck1);  	clk_register(&pck2); @@ -237,58 +282,64 @@ static void __init at91rm9200_register_clocks(void)   *  GPIO   * -------------------------------------------------------------------- */ -static struct at91_gpio_bank at91rm9200_gpio[] = { +static struct at91_gpio_bank at91rm9200_gpio[] __initdata = {  	{  		.id		= AT91RM9200_ID_PIOA, -		.offset		= AT91_PIOA, -		.clock		= &pioA_clk, +		.regbase	= AT91RM9200_BASE_PIOA,  	}, {  		.id		= AT91RM9200_ID_PIOB, -		.offset		= AT91_PIOB, -		.clock		= &pioB_clk, +		.regbase	= AT91RM9200_BASE_PIOB,  	}, {  		.id		= AT91RM9200_ID_PIOC, -		.offset		= AT91_PIOC, -		.clock		= &pioC_clk, +		.regbase	= AT91RM9200_BASE_PIOC,  	}, {  		.id		= AT91RM9200_ID_PIOD, -		.offset		= AT91_PIOD, -		.clock		= &pioD_clk, +		.regbase	= AT91RM9200_BASE_PIOD,  	}  }; -static void at91rm9200_reset(void) +static void at91rm9200_idle(void)  {  	/* -	 * Perform a hardware reset with the use of the Watchdog timer. +	 * Disable the processor clock.  The processor will be automatically +	 * re-enabled by an interrupt or by a reset.  	 */ -	at91_sys_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1); -	at91_sys_write(AT91_ST_CR, AT91_ST_WDRST); +	at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);  } +static void at91rm9200_restart(enum reboot_mode reboot_mode, const char *cmd) +{ +	/* +	 * Perform a hardware reset with the use of the Watchdog timer. +	 */ +	at91_st_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1); +	at91_st_write(AT91_ST_CR, AT91_ST_WDRST); +}  /* --------------------------------------------------------------------   *  AT91RM9200 processor initialization   * -------------------------------------------------------------------- */ -void __init at91rm9200_initialize(unsigned long main_clock, unsigned short banks) +static void __init at91rm9200_map_io(void)  {  	/* Map peripherals */ -	iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc)); - -	at91_arch_reset = at91rm9200_reset; -	at91_extern_irq = (1 << AT91RM9200_ID_IRQ0) | (1 << AT91RM9200_ID_IRQ1) -			| (1 << AT91RM9200_ID_IRQ2) | (1 << AT91RM9200_ID_IRQ3) -			| (1 << AT91RM9200_ID_IRQ4) | (1 << AT91RM9200_ID_IRQ5) -			| (1 << AT91RM9200_ID_IRQ6); +	at91_init_sram(0, AT91RM9200_SRAM_BASE, AT91RM9200_SRAM_SIZE); +} -	/* Init clock subsystem */ -	at91_clock_init(main_clock); +static void __init at91rm9200_ioremap_registers(void) +{ +	at91rm9200_ioremap_st(AT91RM9200_BASE_ST); +	at91_ioremap_ramc(0, AT91RM9200_BASE_MC, 256); +	at91_pm_set_standby(at91rm9200_standby); +} -	/* Register the processor-specific clocks */ -	at91rm9200_register_clocks(); +static void __init at91rm9200_initialize(void) +{ +	arm_pm_idle = at91rm9200_idle; +	arm_pm_restart = at91rm9200_restart;  	/* Initialize GPIO subsystem */ -	at91_gpio_init(at91rm9200_gpio, banks); +	at91_gpio_init(at91rm9200_gpio, +		cpu_is_at91rm9200_bga() ? AT91RM9200_BGA : AT91RM9200_PQFP);  } @@ -334,14 +385,14 @@ static unsigned int at91rm9200_default_irq_priority[NR_AIC_IRQS] __initdata = {  	0	/* Advanced Interrupt Controller (IRQ6) */  }; -void __init at91rm9200_init_interrupts(unsigned int priority[NR_AIC_IRQS]) -{ -	if (!priority) -		priority = at91rm9200_default_irq_priority; - -	/* Initialize the AIC interrupt controller */ -	at91_aic_init(priority); - -	/* Enable GPIO interrupts */ -	at91_gpio_irq_setup(); -} +AT91_SOC_START(at91rm9200) +	.map_io = at91rm9200_map_io, +	.default_irq_priority = at91rm9200_default_irq_priority, +	.extern_irq = (1 << AT91RM9200_ID_IRQ0) | (1 << AT91RM9200_ID_IRQ1) +		    | (1 << AT91RM9200_ID_IRQ2) | (1 << AT91RM9200_ID_IRQ3) +		    | (1 << AT91RM9200_ID_IRQ4) | (1 << AT91RM9200_ID_IRQ5) +		    | (1 << AT91RM9200_ID_IRQ6), +	.ioremap_registers = at91rm9200_ioremap_registers, +	.register_clocks = at91rm9200_register_clocks, +	.init = at91rm9200_initialize, +AT91_SOC_END diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c index 9338825cfcd..3f4bb58aea5 100644 --- a/arch/arm/mach-at91/at91rm9200_devices.c +++ b/arch/arm/mach-at91/at91rm9200_devices.c @@ -14,15 +14,19 @@  #include <asm/mach/map.h>  #include <linux/dma-mapping.h> +#include <linux/gpio.h> +#include <linux/gpio/driver.h>  #include <linux/platform_device.h>  #include <linux/i2c-gpio.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91rm9200.h>  #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> +#include <mach/hardware.h> +#include "board.h"  #include "generic.h" +#include "gpio.h"  /* -------------------------------------------------------------------- @@ -40,8 +44,8 @@ static struct resource usbh_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_UHP, -		.end	= AT91RM9200_ID_UHP, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_UHP, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_UHP,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -60,9 +64,17 @@ static struct platform_device at91rm9200_usbh_device = {  void __init at91_add_device_usbh(struct at91_usbh_data *data)  { +	int i; +  	if (!data)  		return; +	/* Enable overcurrent notification */ +	for (i = 0; i < data->ports; i++) { +		if (gpio_is_valid(data->overcurrent_pin[i])) +			at91_set_gpio_input(data->overcurrent_pin[i], 1); +	} +  	usbh_data = *data;  	platform_device_register(&at91rm9200_usbh_device);  } @@ -75,7 +87,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}   *  USB Device (Gadget)   * -------------------------------------------------------------------- */ -#ifdef CONFIG_USB_GADGET_AT91 +#if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)  static struct at91_udc_data udc_data;  static struct resource udc_resources[] = { @@ -85,8 +97,8 @@ static struct resource udc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_UDP, -		.end	= AT91RM9200_ID_UDP, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_UDP, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_UDP,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -106,11 +118,11 @@ void __init at91_add_device_udc(struct at91_udc_data *data)  	if (!data)  		return; -	if (data->vbus_pin) { +	if (gpio_is_valid(data->vbus_pin)) {  		at91_set_gpio_input(data->vbus_pin, 0);  		at91_set_deglitch(data->vbus_pin, 1);  	} -	if (data->pullup_pin) +	if (gpio_is_valid(data->pullup_pin))  		at91_set_gpio_output(data->pullup_pin, 0);  	udc_data = *data; @@ -127,17 +139,17 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}  #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE)  static u64 eth_dmamask = DMA_BIT_MASK(32); -static struct at91_eth_data eth_data; +static struct macb_platform_data eth_data;  static struct resource eth_resources[] = {  	[0] = { -		.start	= AT91_VA_BASE_EMAC, -		.end	= AT91_VA_BASE_EMAC + SZ_16K - 1, +		.start	= AT91RM9200_BASE_EMAC, +		.end	= AT91RM9200_BASE_EMAC + SZ_16K - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_EMAC, -		.end	= AT91RM9200_ID_EMAC, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_EMAC, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_EMAC,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -154,12 +166,12 @@ static struct platform_device at91rm9200_eth_device = {  	.num_resources	= ARRAY_SIZE(eth_resources),  }; -void __init at91_add_device_eth(struct at91_eth_data *data) +void __init at91_add_device_eth(struct macb_platform_data *data)  {  	if (!data)  		return; -	if (data->phy_irq_pin) { +	if (gpio_is_valid(data->phy_irq_pin)) {  		at91_set_gpio_input(data->phy_irq_pin, 0);  		at91_set_deglitch(data->phy_irq_pin, 1);  	} @@ -191,7 +203,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data)  	platform_device_register(&at91rm9200_eth_device);  }  #else -void __init at91_add_device_eth(struct at91_eth_data *data) {} +void __init at91_add_device_eth(struct macb_platform_data *data) {}  #endif @@ -233,15 +245,15 @@ void __init at91_add_device_cf(struct at91_cf_data *data)  	data->chipselect = 4;		/* can only use EBI ChipSelect 4 */  	/* CF takes over CS4, CS5, CS6 */ -	csa = at91_sys_read(AT91_EBI_CSA); -	at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH); +	csa = at91_ramc_read(0, AT91_EBI_CSA); +	at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);  	/*  	 * Static memory controller timing adjustments.  	 * REVISIT:  these timings are in terms of MCK cycles, so  	 * when MCK changes (cpufreq etc) so must these values...  	 */ -	at91_sys_write(AT91_SMC_CSR(4), +	at91_ramc_write(0, AT91_SMC_CSR(4),  				  AT91_SMC_ACSS_STD  				| AT91_SMC_DBW_16  				| AT91_SMC_BAT @@ -252,7 +264,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)  	);  	/* input/irq */ -	if (data->irq_pin) { +	if (gpio_is_valid(data->irq_pin)) {  		at91_set_gpio_input(data->irq_pin, 1);  		at91_set_deglitch(data->irq_pin, 1);  	} @@ -260,7 +272,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)  	at91_set_deglitch(data->det_pin, 1);  	/* outputs, initially off */ -	if (data->vcc_pin) +	if (gpio_is_valid(data->vcc_pin))  		at91_set_gpio_output(data->vcc_pin, 0);  	at91_set_gpio_output(data->rst_pin, 0); @@ -285,9 +297,9 @@ void __init at91_add_device_cf(struct at91_cf_data *data) {}   *  MMC / SD   * -------------------------------------------------------------------- */ -#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) +#if IS_ENABLED(CONFIG_MMC_ATMELMCI)  static u64 mmc_dmamask = DMA_BIT_MASK(32); -static struct at91_mmc_data mmc_data; +static struct mci_platform_data mmc_data;  static struct resource mmc_resources[] = {  	[0] = { @@ -296,14 +308,14 @@ static struct resource mmc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_MCI, -		.end	= AT91RM9200_ID_MCI, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_MCI, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_MCI,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91rm9200_mmc_device = { -	.name		= "at91_mci", +	.name		= "atmel_mci",  	.id		= -1,  	.dev		= {  				.dma_mask		= &mmc_dmamask, @@ -314,53 +326,69 @@ static struct platform_device at91rm9200_mmc_device = {  	.num_resources	= ARRAY_SIZE(mmc_resources),  }; -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) +void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)  { +	unsigned int i; +	unsigned int slot_count = 0; +  	if (!data)  		return; -	/* input/irq */ -	if (data->det_pin) { -		at91_set_gpio_input(data->det_pin, 1); -		at91_set_deglitch(data->det_pin, 1); -	} -	if (data->wp_pin) -		at91_set_gpio_input(data->wp_pin, 1); -	if (data->vcc_pin) -		at91_set_gpio_output(data->vcc_pin, 0); +	for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) { -	/* CLK */ -	at91_set_A_periph(AT91_PIN_PA27, 0); +		if (!data->slot[i].bus_width) +			continue; -	if (data->slot_b) { -		/* CMD */ -		at91_set_B_periph(AT91_PIN_PA8, 1); - -		/* DAT0, maybe DAT1..DAT3 */ -		at91_set_B_periph(AT91_PIN_PA9, 1); -		if (data->wire4) { -			at91_set_B_periph(AT91_PIN_PA10, 1); -			at91_set_B_periph(AT91_PIN_PA11, 1); -			at91_set_B_periph(AT91_PIN_PA12, 1); +		/* input/irq */ +		if (gpio_is_valid(data->slot[i].detect_pin)) { +			at91_set_gpio_input(data->slot[i].detect_pin, 1); +			at91_set_deglitch(data->slot[i].detect_pin, 1); +		} +		if (gpio_is_valid(data->slot[i].wp_pin)) +			at91_set_gpio_input(data->slot[i].wp_pin, 1); + +		switch (i) { +		case 0:					/* slot A */ +			/* CMD */ +			at91_set_A_periph(AT91_PIN_PA28, 1); +			/* DAT0, maybe DAT1..DAT3 */ +			at91_set_A_periph(AT91_PIN_PA29, 1); +			if (data->slot[i].bus_width == 4) { +				at91_set_B_periph(AT91_PIN_PB3, 1); +				at91_set_B_periph(AT91_PIN_PB4, 1); +				at91_set_B_periph(AT91_PIN_PB5, 1); +			} +			slot_count++; +			break; +		case 1:					/* slot B */ +			/* CMD */ +			at91_set_B_periph(AT91_PIN_PA8, 1); +			/* DAT0, maybe DAT1..DAT3 */ +			at91_set_B_periph(AT91_PIN_PA9, 1); +			if (data->slot[i].bus_width == 4) { +				at91_set_B_periph(AT91_PIN_PA10, 1); +				at91_set_B_periph(AT91_PIN_PA11, 1); +				at91_set_B_periph(AT91_PIN_PA12, 1); +			} +			slot_count++; +			break; +		default: +			printk(KERN_ERR +			       "AT91: SD/MMC slot %d not available\n", i); +			break;  		} -	} else { -		/* CMD */ -		at91_set_A_periph(AT91_PIN_PA28, 1); - -		/* DAT0, maybe DAT1..DAT3 */ -		at91_set_A_periph(AT91_PIN_PA29, 1); -		if (data->wire4) { -			at91_set_B_periph(AT91_PIN_PB3, 1); -			at91_set_B_periph(AT91_PIN_PB4, 1); -			at91_set_B_periph(AT91_PIN_PB5, 1); +		if (slot_count) { +			/* CLK */ +			at91_set_A_periph(AT91_PIN_PA27, 0); + +			mmc_data = *data; +			platform_device_register(&at91rm9200_mmc_device);  		}  	} -	mmc_data = *data; -	platform_device_register(&at91rm9200_mmc_device);  }  #else -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} +void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}  #endif @@ -399,11 +427,11 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)  		return;  	/* enable the address range of CS3 */ -	csa = at91_sys_read(AT91_EBI_CSA); -	at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA); +	csa = at91_ramc_read(0, AT91_EBI_CSA); +	at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);  	/* set the bus interface characteristics */ -	at91_sys_write(AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN +	at91_ramc_write(0, AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN  		| AT91_SMC_NWS_(5)  		| AT91_SMC_TDF_(1)  		| AT91_SMC_RWSETUP_(0)	/* tDS Data Set up Time 30 - ns */ @@ -411,15 +439,15 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)  	);  	/* enable pin */ -	if (data->enable_pin) +	if (gpio_is_valid(data->enable_pin))  		at91_set_gpio_output(data->enable_pin, 1);  	/* ready/busy pin */ -	if (data->rdy_pin) +	if (gpio_is_valid(data->rdy_pin))  		at91_set_gpio_input(data->rdy_pin, 1);  	/* card detect pin */ -	if (data->det_pin) +	if (gpio_is_valid(data->det_pin))  		at91_set_gpio_input(data->det_pin, 1);  	at91_set_A_periph(AT91_PIN_PC1, 0);		/* SMOE */ @@ -454,7 +482,7 @@ static struct i2c_gpio_platform_data pdata = {  static struct platform_device at91rm9200_twi_device = {  	.name			= "i2c-gpio", -	.id			= -1, +	.id			= 0,  	.dev.platform_data	= &pdata,  }; @@ -479,15 +507,15 @@ static struct resource twi_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_TWI, -		.end	= AT91RM9200_ID_TWI, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_TWI, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_TWI,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91rm9200_twi_device = { -	.name		= "at91_i2c", -	.id		= -1, +	.name		= "i2c-at91rm9200", +	.id		= 0,  	.resource	= twi_resources,  	.num_resources	= ARRAY_SIZE(twi_resources),  }; @@ -523,8 +551,8 @@ static struct resource spi_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_SPI, -		.end	= AT91RM9200_ID_SPI, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_SPI, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_SPI,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -589,18 +617,18 @@ static struct resource tcb0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_TC0, -		.end	= AT91RM9200_ID_TC0, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_TC0, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_TC0,  		.flags	= IORESOURCE_IRQ,  	},  	[2] = { -		.start	= AT91RM9200_ID_TC1, -		.end	= AT91RM9200_ID_TC1, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_TC1, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_TC1,  		.flags	= IORESOURCE_IRQ,  	},  	[3] = { -		.start	= AT91RM9200_ID_TC2, -		.end	= AT91RM9200_ID_TC2, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_TC2, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_TC2,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -619,18 +647,18 @@ static struct resource tcb1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_TC3, -		.end	= AT91RM9200_ID_TC3, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_TC3, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_TC3,  		.flags	= IORESOURCE_IRQ,  	},  	[2] = { -		.start	= AT91RM9200_ID_TC4, -		.end	= AT91RM9200_ID_TC4, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_TC4, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_TC4,  		.flags	= IORESOURCE_IRQ,  	},  	[3] = { -		.start	= AT91RM9200_ID_TC5, -		.end	= AT91RM9200_ID_TC5, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_TC5, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_TC5,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -644,15 +672,7 @@ static struct platform_device at91rm9200_tcb1_device = {  static void __init at91_add_device_tc(void)  { -	/* this chip has a separate clock and irq for each TC channel */ -	at91_clock_associate("tc0_clk", &at91rm9200_tcb0_device.dev, "t0_clk"); -	at91_clock_associate("tc1_clk", &at91rm9200_tcb0_device.dev, "t1_clk"); -	at91_clock_associate("tc2_clk", &at91rm9200_tcb0_device.dev, "t2_clk");  	platform_device_register(&at91rm9200_tcb0_device); - -	at91_clock_associate("tc3_clk", &at91rm9200_tcb1_device.dev, "t0_clk"); -	at91_clock_associate("tc4_clk", &at91rm9200_tcb1_device.dev, "t1_clk"); -	at91_clock_associate("tc5_clk", &at91rm9200_tcb1_device.dev, "t2_clk");  	platform_device_register(&at91rm9200_tcb1_device);  }  #else @@ -665,10 +685,24 @@ static void __init at91_add_device_tc(void) { }   * -------------------------------------------------------------------- */  #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE) +static struct resource rtc_resources[] = { +	[0] = { +		.start	= AT91RM9200_BASE_RTC, +		.end	= AT91RM9200_BASE_RTC + SZ_256 - 1, +		.flags	= IORESOURCE_MEM, +	}, +	[1] = { +		.start	= NR_IRQS_LEGACY + AT91_ID_SYS, +		.end	= NR_IRQS_LEGACY + AT91_ID_SYS, +		.flags	= IORESOURCE_IRQ, +	}, +}; +  static struct platform_device at91rm9200_rtc_device = {  	.name		= "at91_rtc",  	.id		= -1, -	.num_resources	= 0, +	.resource	= rtc_resources, +	.num_resources	= ARRAY_SIZE(rtc_resources),  };  static void __init at91_add_device_rtc(void) @@ -714,14 +748,14 @@ static struct resource ssc0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_SSC0, -		.end	= AT91RM9200_ID_SSC0, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_SSC0, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_SSC0,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91rm9200_ssc0_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 0,  	.dev	= {  		.dma_mask		= &ssc0_dmamask, @@ -756,14 +790,14 @@ static struct resource ssc1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_SSC1, -		.end	= AT91RM9200_ID_SSC1, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_SSC1, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_SSC1,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91rm9200_ssc1_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 1,  	.dev	= {  		.dma_mask		= &ssc1_dmamask, @@ -798,14 +832,14 @@ static struct resource ssc2_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_SSC2, -		.end	= AT91RM9200_ID_SSC2, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_SSC2, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_SSC2,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91rm9200_ssc2_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 2,  	.dev	= {  		.dma_mask		= &ssc2_dmamask, @@ -849,17 +883,14 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)  	case AT91RM9200_ID_SSC0:  		pdev = &at91rm9200_ssc0_device;  		configure_ssc0_pins(pins); -		at91_clock_associate("ssc0_clk", &pdev->dev, "ssc");  		break;  	case AT91RM9200_ID_SSC1:  		pdev = &at91rm9200_ssc1_device;  		configure_ssc1_pins(pins); -		at91_clock_associate("ssc1_clk", &pdev->dev, "ssc");  		break;  	case AT91RM9200_ID_SSC2:  		pdev = &at91rm9200_ssc2_device;  		configure_ssc2_pins(pins); -		at91_clock_associate("ssc2_clk", &pdev->dev, "ssc");  		break;  	default:  		return; @@ -880,13 +911,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}  #if defined(CONFIG_SERIAL_ATMEL)  static struct resource dbgu_resources[] = {  	[0] = { -		.start	= AT91_VA_BASE_SYS + AT91_DBGU, -		.end	= AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, +		.start	= AT91RM9200_BASE_DBGU, +		.end	= AT91RM9200_BASE_DBGU + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91_ID_SYS, -		.end	= AT91_ID_SYS, +		.start	= NR_IRQS_LEGACY + AT91_ID_SYS, +		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -894,7 +925,6 @@ static struct resource dbgu_resources[] = {  static struct atmel_uart_data dbgu_data = {  	.use_dma_tx	= 0,  	.use_dma_rx	= 0,		/* DBGU not capable of receive DMA */ -	.regs		= (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),  };  static u64 dbgu_dmamask = DMA_BIT_MASK(32); @@ -924,8 +954,8 @@ static struct resource uart0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_US0, -		.end	= AT91RM9200_ID_US0, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_US0, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_US0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -935,6 +965,14 @@ static struct atmel_uart_data uart0_data = {  	.use_dma_rx	= 1,  }; +static struct gpiod_lookup_table uart0_gpios_table = { +	.dev_id = "atmel_usart", +	.table = { +		GPIO_LOOKUP("pioA", 21, "rts", GPIO_ACTIVE_LOW), +		{ }, +	}, +}; +  static u64 uart0_dmamask = DMA_BIT_MASK(32);  static struct platform_device at91rm9200_uart0_device = { @@ -960,9 +998,10 @@ static inline void configure_usart0_pins(unsigned pins)  	if (pins & ATMEL_UART_RTS) {  		/*  		 * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21. -		 *  We need to drive the pin manually.  Default is off (RTS is active low). +		 * We need to drive the pin manually. The serial driver will driver +		 * this to high when initializing.  		 */ -		at91_set_gpio_output(AT91_PIN_PA21, 1); +		gpiod_add_lookup_table(&uart0_gpios_table);  	}  } @@ -973,8 +1012,8 @@ static struct resource uart1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_US1, -		.end	= AT91RM9200_ID_US1, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_US1, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_US1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1024,8 +1063,8 @@ static struct resource uart2_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_US2, -		.end	= AT91RM9200_ID_US2, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_US2, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_US2,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1067,8 +1106,8 @@ static struct resource uart3_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91RM9200_ID_US3, -		.end	= AT91RM9200_ID_US3, +		.start	= NR_IRQS_LEGACY + AT91RM9200_ID_US3, +		.end	= NR_IRQS_LEGACY + AT91RM9200_ID_US3,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1104,98 +1143,43 @@ static inline void configure_usart3_pins(unsigned pins)  }  static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */ -struct platform_device *atmel_default_console_device;	/* the serial console device */ - -void __init __deprecated at91_init_serial(struct at91_uart_config *config) -{ -	int i; - -	/* Fill in list of supported UARTs */ -	for (i = 0; i < config->nr_tty; i++) { -		switch (config->tty_map[i]) { -			case 0: -				configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS); -				at91_uarts[i] = &at91rm9200_uart0_device; -				at91_clock_associate("usart0_clk", &at91rm9200_uart0_device.dev, "usart"); -				break; -			case 1: -				configure_usart1_pins(ATMEL_UART_CTS | ATMEL_UART_RTS | ATMEL_UART_DSR | ATMEL_UART_DTR | ATMEL_UART_DCD | ATMEL_UART_RI); -				at91_uarts[i] = &at91rm9200_uart1_device; -				at91_clock_associate("usart1_clk", &at91rm9200_uart1_device.dev, "usart"); -				break; -			case 2: -				configure_usart2_pins(0); -				at91_uarts[i] = &at91rm9200_uart2_device; -				at91_clock_associate("usart2_clk", &at91rm9200_uart2_device.dev, "usart"); -				break; -			case 3: -				configure_usart3_pins(0); -				at91_uarts[i] = &at91rm9200_uart3_device; -				at91_clock_associate("usart3_clk", &at91rm9200_uart3_device.dev, "usart"); -				break; -			case 4: -				configure_dbgu_pins(); -				at91_uarts[i] = &at91rm9200_dbgu_device; -				at91_clock_associate("mck", &at91rm9200_dbgu_device.dev, "usart"); -				break; -			default: -				continue; -		} -		at91_uarts[i]->id = i;		/* update ID number to mapped ID */ -	} - -	/* Set serial console device */ -	if (config->console_tty < ATMEL_MAX_UART) -		atmel_default_console_device = at91_uarts[config->console_tty]; -	if (!atmel_default_console_device) -		printk(KERN_INFO "AT91: No default serial console defined.\n"); -}  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)  {  	struct platform_device *pdev; +	struct atmel_uart_data *pdata;  	switch (id) {  		case 0:		/* DBGU */  			pdev = &at91rm9200_dbgu_device;  			configure_dbgu_pins(); -			at91_clock_associate("mck", &pdev->dev, "usart");  			break;  		case AT91RM9200_ID_US0:  			pdev = &at91rm9200_uart0_device;  			configure_usart0_pins(pins); -			at91_clock_associate("usart0_clk", &pdev->dev, "usart");  			break;  		case AT91RM9200_ID_US1:  			pdev = &at91rm9200_uart1_device;  			configure_usart1_pins(pins); -			at91_clock_associate("usart1_clk", &pdev->dev, "usart");  			break;  		case AT91RM9200_ID_US2:  			pdev = &at91rm9200_uart2_device;  			configure_usart2_pins(pins); -			at91_clock_associate("usart2_clk", &pdev->dev, "usart");  			break;  		case AT91RM9200_ID_US3:  			pdev = &at91rm9200_uart3_device;  			configure_usart3_pins(pins); -			at91_clock_associate("usart3_clk", &pdev->dev, "usart");  			break;  		default:  			return;  	} -	pdev->id = portnr;		/* update to mapped ID */ +	pdata = pdev->dev.platform_data; +	pdata->num = portnr;		/* update to mapped ID */  	if (portnr < ATMEL_MAX_UART)  		at91_uarts[portnr] = pdev;  } -void __init at91_set_serial_console(unsigned portnr) -{ -	if (portnr < ATMEL_MAX_UART) -		atmel_default_console_device = at91_uarts[portnr]; -} -  void __init at91_add_device_serial(void)  {  	int i; @@ -1204,14 +1188,9 @@ void __init at91_add_device_serial(void)  		if (at91_uarts[i])  			platform_device_register(at91_uarts[i]);  	} - -	if (!atmel_default_console_device) -		printk(KERN_INFO "AT91: No default serial console defined.\n");  }  #else -void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {}  void __init at91_add_device_serial(void) {}  #endif diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/arch/arm/mach-at91/at91rm9200_time.c index 2500f41d8d2..7fd13aef982 100644 --- a/arch/arm/mach-at91/at91rm9200_time.c +++ b/arch/arm/mach-at91/at91rm9200_time.c @@ -23,15 +23,22 @@  #include <linux/interrupt.h>  #include <linux/irq.h>  #include <linux/clockchips.h> +#include <linux/export.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h>  #include <asm/mach/time.h>  #include <mach/at91_st.h> +#include <mach/hardware.h>  static unsigned long last_crtr;  static u32 irqmask;  static struct clock_event_device clkevt; +#define RM9200_TIMER_LATCH	((AT91_SLOW_CLOCK + HZ/2) / HZ) +  /*   * The ST_CRTR is updated asynchronously to the master clock ... but   * the updates as seen by the CPU don't seem to be strictly monotonic. @@ -41,9 +48,9 @@ static inline unsigned long read_CRTR(void)  {  	unsigned long x1, x2; -	x1 = at91_sys_read(AT91_ST_CRTR); +	x1 = at91_st_read(AT91_ST_CRTR);  	do { -		x2 = at91_sys_read(AT91_ST_CRTR); +		x2 = at91_st_read(AT91_ST_CRTR);  		if (x1 == x2)  			break;  		x1 = x2; @@ -56,7 +63,7 @@ static inline unsigned long read_CRTR(void)   */  static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)  { -	u32	sr = at91_sys_read(AT91_ST_SR) & irqmask; +	u32	sr = at91_st_read(AT91_ST_SR) & irqmask;  	/*  	 * irqs should be disabled here, but as the irq is shared they are only @@ -74,8 +81,8 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)  	if (sr & AT91_ST_PITS) {  		u32	crtr = read_CRTR(); -		while (((crtr - last_crtr) & AT91_ST_CRTV) >= LATCH) { -			last_crtr += LATCH; +		while (((crtr - last_crtr) & AT91_ST_CRTV) >= RM9200_TIMER_LATCH) { +			last_crtr += RM9200_TIMER_LATCH;  			clkevt.event_handler(&clkevt);  		}  		return IRQ_HANDLED; @@ -87,8 +94,9 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)  static struct irqaction at91rm9200_timer_irq = {  	.name		= "at91_tick", -	.flags		= IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, -	.handler	= at91rm9200_timer_interrupt +	.flags		= IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, +	.handler	= at91rm9200_timer_interrupt, +	.irq		= NR_IRQS_LEGACY + AT91_ID_SYS,  };  static cycle_t read_clk32k(struct clocksource *cs) @@ -101,7 +109,6 @@ static struct clocksource clk32k = {  	.rating		= 150,  	.read		= read_clk32k,  	.mask		= CLOCKSOURCE_MASK(20), -	.shift		= 10,  	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,  }; @@ -109,22 +116,22 @@ static void  clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)  {  	/* Disable and flush pending timer interrupts */ -	at91_sys_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS); -	(void) at91_sys_read(AT91_ST_SR); +	at91_st_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS); +	at91_st_read(AT91_ST_SR);  	last_crtr = read_CRTR();  	switch (mode) {  	case CLOCK_EVT_MODE_PERIODIC:  		/* PIT for periodic irqs; fixed rate of 1/HZ */  		irqmask = AT91_ST_PITS; -		at91_sys_write(AT91_ST_PIMR, LATCH); +		at91_st_write(AT91_ST_PIMR, RM9200_TIMER_LATCH);  		break;  	case CLOCK_EVT_MODE_ONESHOT:  		/* ALM for oneshot irqs, set by next_event()  		 * before 32 seconds have passed  		 */  		irqmask = AT91_ST_ALMS; -		at91_sys_write(AT91_ST_RTAR, last_crtr); +		at91_st_write(AT91_ST_RTAR, last_crtr);  		break;  	case CLOCK_EVT_MODE_SHUTDOWN:  	case CLOCK_EVT_MODE_UNUSED: @@ -132,7 +139,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)  		irqmask = 0;  		break;  	} -	at91_sys_write(AT91_ST_IER, irqmask); +	at91_st_write(AT91_ST_IER, irqmask);  }  static int @@ -155,12 +162,12 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)  	alm = read_CRTR();  	/* Cancel any pending alarm; flush any pending IRQ */ -	at91_sys_write(AT91_ST_RTAR, alm); -	(void) at91_sys_read(AT91_ST_SR); +	at91_st_write(AT91_ST_RTAR, alm); +	at91_st_read(AT91_ST_SR);  	/* Schedule alarm by writing RTAR. */  	alm += delta; -	at91_sys_write(AT91_ST_RTAR, alm); +	at91_st_write(AT91_ST_RTAR, alm);  	return status;  } @@ -168,44 +175,100 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)  static struct clock_event_device clkevt = {  	.name		= "at91_tick",  	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, -	.shift		= 32,  	.rating		= 150,  	.set_next_event	= clkevt32k_next_event,  	.set_mode	= clkevt32k_mode,  }; +void __iomem *at91_st_base; +EXPORT_SYMBOL_GPL(at91_st_base); + +#ifdef CONFIG_OF +static struct of_device_id at91rm9200_st_timer_ids[] = { +	{ .compatible = "atmel,at91rm9200-st" }, +	{ /* sentinel */ } +}; + +static int __init of_at91rm9200_st_init(void) +{ +	struct device_node *np; +	int ret; + +	np = of_find_matching_node(NULL, at91rm9200_st_timer_ids); +	if (!np) +		goto err; + +	at91_st_base = of_iomap(np, 0); +	if (!at91_st_base) +		goto node_err; + +	/* Get the interrupts property */ +	ret = irq_of_parse_and_map(np, 0); +	if (!ret) +		goto ioremap_err; +	at91rm9200_timer_irq.irq = ret; + +	of_node_put(np); + +	return 0; + +ioremap_err: +	iounmap(at91_st_base); +node_err: +	of_node_put(np); +err: +	return -EINVAL; +} +#else +static int __init of_at91rm9200_st_init(void) +{ +	return -EINVAL; +} +#endif + +void __init at91rm9200_ioremap_st(u32 addr) +{ +#ifdef CONFIG_OF +	struct device_node *np; + +	np = of_find_matching_node(NULL, at91rm9200_st_timer_ids); +	if (np) { +		of_node_put(np); +		return; +	} +#endif +	at91_st_base = ioremap(addr, 256); +	if (!at91_st_base) +		panic("Impossible to ioremap ST\n"); +} +  /*   * ST (system timer) module supports both clockevents and clocksource.   */  void __init at91rm9200_timer_init(void)  { +	/* For device tree enabled device: initialize here */ +	of_at91rm9200_st_init(); +  	/* Disable all timer interrupts, and clear any pending ones */ -	at91_sys_write(AT91_ST_IDR, +	at91_st_write(AT91_ST_IDR,  		AT91_ST_PITS | AT91_ST_WDOVF | AT91_ST_RTTINC | AT91_ST_ALMS); -	(void) at91_sys_read(AT91_ST_SR); +	at91_st_read(AT91_ST_SR);  	/* Make IRQs happen for the system timer */ -	setup_irq(AT91_ID_SYS, &at91rm9200_timer_irq); +	setup_irq(at91rm9200_timer_irq.irq, &at91rm9200_timer_irq);  	/* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used  	 * directly for the clocksource and all clockevents, after adjusting  	 * its prescaler from the 1 Hz default.  	 */ -	at91_sys_write(AT91_ST_RTMR, 1); +	at91_st_write(AT91_ST_RTMR, 1);  	/* Setup timer clockevent, with minimum of two ticks (important!!) */ -	clkevt.mult = div_sc(AT91_SLOW_CLOCK, NSEC_PER_SEC, clkevt.shift); -	clkevt.max_delta_ns = clockevent_delta2ns(AT91_ST_ALMV, &clkevt); -	clkevt.min_delta_ns = clockevent_delta2ns(2, &clkevt) + 1;  	clkevt.cpumask = cpumask_of(0); -	clockevents_register_device(&clkevt); +	clockevents_config_and_register(&clkevt, AT91_SLOW_CLOCK, +					2, AT91_ST_ALMV);  	/* register clocksource */ -	clk32k.mult = clocksource_hz2mult(AT91_SLOW_CLOCK, clk32k.shift); -	clocksource_register(&clk32k); +	clocksource_register_hz(&clk32k, AT91_SLOW_CLOCK);  } - -struct sys_timer at91rm9200_timer = { -	.init		= at91rm9200_timer_init, -}; - diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c index 195208b3002..c3d22be73b7 100644 --- a/arch/arm/mach-at91/at91sam9260.c +++ b/arch/arm/mach-at91/at91sam9260.c @@ -11,63 +11,25 @@   */  #include <linux/module.h> -#include <linux/pm.h> +#include <linux/clk/at91_pmc.h> +#include <asm/proc-fns.h>  #include <asm/irq.h>  #include <asm/mach/arch.h>  #include <asm/mach/map.h> +#include <asm/system_misc.h>  #include <mach/cpu.h> +#include <mach/at91_dbgu.h>  #include <mach/at91sam9260.h> -#include <mach/at91_pmc.h> -#include <mach/at91_rstc.h> -#include <mach/at91_shdwc.h> +#include <mach/hardware.h> +#include "at91_aic.h" +#include "at91_rstc.h" +#include "soc.h"  #include "generic.h"  #include "clock.h" - -static struct map_desc at91sam9260_io_desc[] __initdata = { -	{ -		.virtual	= AT91_VA_BASE_SYS, -		.pfn		= __phys_to_pfn(AT91_BASE_SYS), -		.length		= SZ_16K, -		.type		= MT_DEVICE, -	} -}; - -static struct map_desc at91sam9260_sram_desc[] __initdata = { -	{ -		.virtual	= AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE, -		.pfn		= __phys_to_pfn(AT91SAM9260_SRAM0_BASE), -		.length		= AT91SAM9260_SRAM0_SIZE, -		.type		= MT_DEVICE, -	}, { -		.virtual	= AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE - AT91SAM9260_SRAM1_SIZE, -		.pfn		= __phys_to_pfn(AT91SAM9260_SRAM1_BASE), -		.length		= AT91SAM9260_SRAM1_SIZE, -		.type		= MT_DEVICE, -	} -}; - -static struct map_desc at91sam9g20_sram_desc[] __initdata = { -	{ -		.virtual	= AT91_IO_VIRT_BASE - AT91SAM9G20_SRAM0_SIZE, -		.pfn		= __phys_to_pfn(AT91SAM9G20_SRAM0_BASE), -		.length		= AT91SAM9G20_SRAM0_SIZE, -		.type		= MT_DEVICE, -	}, { -		.virtual	= AT91_IO_VIRT_BASE - AT91SAM9G20_SRAM0_SIZE - AT91SAM9G20_SRAM1_SIZE, -		.pfn		= __phys_to_pfn(AT91SAM9G20_SRAM1_BASE), -		.length		= AT91SAM9G20_SRAM1_SIZE, -		.type		= MT_DEVICE, -	} -}; - -static struct map_desc at91sam9xe_sram_desc[] __initdata = { -	{ -		.pfn		= __phys_to_pfn(AT91SAM9XE_SRAM_BASE), -		.type		= MT_DEVICE, -	} -}; +#include "sam9_smc.h" +#include "pm.h"  /* --------------------------------------------------------------------   *  Clocks @@ -96,6 +58,13 @@ static struct clk adc_clk = {  	.pmc_mask	= 1 << AT91SAM9260_ID_ADC,  	.type		= CLK_TYPE_PERIPHERAL,  }; + +static struct clk adc_op_clk = { +	.name		= "adc_op_clk", +	.type		= CLK_TYPE_PERIPHERAL, +	.rate_hz	= 5000000, +}; +  static struct clk usart0_clk = {  	.name		= "usart0_clk",  	.pmc_mask	= 1 << AT91SAM9260_ID_US0, @@ -162,7 +131,7 @@ static struct clk ohci_clk = {  	.type		= CLK_TYPE_PERIPHERAL,  };  static struct clk macb_clk = { -	.name		= "macb_clk", +	.name		= "pclk",  	.pmc_mask	= 1 << AT91SAM9260_ID_EMAC,  	.type		= CLK_TYPE_PERIPHERAL,  }; @@ -207,6 +176,7 @@ static struct clk *periph_clocks[] __initdata = {  	&pioB_clk,  	&pioC_clk,  	&adc_clk, +	&adc_op_clk,  	&usart0_clk,  	&usart1_clk,  	&usart2_clk, @@ -231,6 +201,61 @@ static struct clk *periph_clocks[] __initdata = {  	// irq0 .. irq2  }; +static struct clk_lookup periph_clocks_lookups[] = { +	/* One additional fake clock for macb_hclk */ +	CLKDEV_CON_ID("hclk", &macb_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc_clk), +	CLKDEV_CON_DEV_ID("pclk", "fffbc000.ssc", &ssc_clk), +	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260.0", &twi_clk), +	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi_clk), +	/* more usart lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck), +	CLKDEV_CON_DEV_ID("usart", "fffb0000.serial", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "fffb4000.serial", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "fffb8000.serial", &usart2_clk), +	CLKDEV_CON_DEV_ID("usart", "fffd0000.serial", &usart3_clk), +	CLKDEV_CON_DEV_ID("usart", "fffd4000.serial", &usart4_clk), +	CLKDEV_CON_DEV_ID("usart", "fffd8000.serial", &usart5_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffac000.i2c", &twi_clk), +	/* more tc lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("t0_clk", "fffa0000.timer", &tc0_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "fffa0000.timer", &tc1_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "fffa0000.timer", &tc2_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "fffdc000.timer", &tc3_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk), +	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "fffa8000.mmc", &mmc_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "fffc8000.spi", &spi0_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "fffcc000.spi", &spi1_clk), +	/* fake hclk clock */ +	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk), +	CLKDEV_CON_ID("pioA", &pioA_clk), +	CLKDEV_CON_ID("pioB", &pioB_clk), +	CLKDEV_CON_ID("pioC", &pioC_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioA_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioB_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioC_clk), +}; + +static struct clk_lookup usart_clocks_lookups[] = { +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.4", &usart3_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.5", &usart4_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.6", &usart5_clk), +}; +  /*   * The two programmable clocks.   * You must configure pin multiplexing to bring these signals out. @@ -255,6 +280,11 @@ static void __init at91sam9260_register_clocks(void)  	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)  		clk_register(periph_clocks[i]); +	clkdev_add_table(periph_clocks_lookups, +			 ARRAY_SIZE(periph_clocks_lookups)); +	clkdev_add_table(usart_clocks_lookups, +			 ARRAY_SIZE(usart_clocks_lookups)); +  	clk_register(&pck0);  	clk_register(&pck1);  } @@ -263,39 +293,28 @@ static void __init at91sam9260_register_clocks(void)   *  GPIO   * -------------------------------------------------------------------- */ -static struct at91_gpio_bank at91sam9260_gpio[] = { +static struct at91_gpio_bank at91sam9260_gpio[] __initdata = {  	{  		.id		= AT91SAM9260_ID_PIOA, -		.offset		= AT91_PIOA, -		.clock		= &pioA_clk, +		.regbase	= AT91SAM9260_BASE_PIOA,  	}, {  		.id		= AT91SAM9260_ID_PIOB, -		.offset		= AT91_PIOB, -		.clock		= &pioB_clk, +		.regbase	= AT91SAM9260_BASE_PIOB,  	}, {  		.id		= AT91SAM9260_ID_PIOC, -		.offset		= AT91_PIOC, -		.clock		= &pioC_clk, +		.regbase	= AT91SAM9260_BASE_PIOC,  	}  }; -static void at91sam9260_poweroff(void) -{ -	at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); -} - -  /* --------------------------------------------------------------------   *  AT91SAM9260 processor initialization   * -------------------------------------------------------------------- */ -static void __init at91sam9xe_initialize(void) +static void __init at91sam9xe_map_io(void)  { -	unsigned long cidr, sram_size; - -	cidr = at91_sys_read(AT91_DBGU_CIDR); +	unsigned long sram_size; -	switch (cidr & AT91_CIDR_SRAMSIZ) { +	switch (at91_soc_initdata.cidr & AT91_CIDR_SRAMSIZ) {  		case AT91_CIDR_SRAMSIZ_32K:  			sram_size = 2 * SZ_16K;  			break; @@ -304,34 +323,36 @@ static void __init at91sam9xe_initialize(void)  			sram_size = SZ_16K;  	} -	at91sam9xe_sram_desc->virtual = AT91_IO_VIRT_BASE - sram_size; -	at91sam9xe_sram_desc->length = sram_size; - -	iotable_init(at91sam9xe_sram_desc, ARRAY_SIZE(at91sam9xe_sram_desc)); +	at91_init_sram(0, AT91SAM9XE_SRAM_BASE, sram_size);  } -void __init at91sam9260_initialize(unsigned long main_clock) +static void __init at91sam9260_map_io(void)  { -	/* Map peripherals */ -	iotable_init(at91sam9260_io_desc, ARRAY_SIZE(at91sam9260_io_desc)); -  	if (cpu_is_at91sam9xe()) -		at91sam9xe_initialize(); +		at91sam9xe_map_io();  	else if (cpu_is_at91sam9g20()) -		iotable_init(at91sam9g20_sram_desc, ARRAY_SIZE(at91sam9g20_sram_desc)); +		at91_init_sram(0, AT91SAM9G20_SRAM_BASE, AT91SAM9G20_SRAM_SIZE);  	else -		iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc)); +		at91_init_sram(0, AT91SAM9260_SRAM_BASE, AT91SAM9260_SRAM_SIZE); +} -	at91_arch_reset = at91sam9_alt_reset; -	pm_power_off = at91sam9260_poweroff; -	at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1) -			| (1 << AT91SAM9260_ID_IRQ2); +static void __init at91sam9260_ioremap_registers(void) +{ +	at91_ioremap_shdwc(AT91SAM9260_BASE_SHDWC); +	at91_ioremap_rstc(AT91SAM9260_BASE_RSTC); +	at91_ioremap_ramc(0, AT91SAM9260_BASE_SDRAMC, 512); +	at91sam926x_ioremap_pit(AT91SAM9260_BASE_PIT); +	at91sam9_ioremap_smc(0, AT91SAM9260_BASE_SMC); +	at91_ioremap_matrix(AT91SAM9260_BASE_MATRIX); +	at91_pm_set_standby(at91sam9_sdram_standby); +} -	/* Init clock subsystem */ -	at91_clock_init(main_clock); +static void __init at91sam9260_initialize(void) +{ +	arm_pm_idle = at91sam9_idle; +	arm_pm_restart = at91sam9_alt_restart; -	/* Register the processor-specific clocks */ -	at91sam9260_register_clocks(); +	at91_sysirq_mask_rtt(AT91SAM9260_BASE_RTT);  	/* Register GPIO subsystem */  	at91_gpio_init(at91sam9260_gpio, 3); @@ -379,14 +400,12 @@ static unsigned int at91sam9260_default_irq_priority[NR_AIC_IRQS] __initdata = {  	0,	/* Advanced Interrupt Controller */  }; -void __init at91sam9260_init_interrupts(unsigned int priority[NR_AIC_IRQS]) -{ -	if (!priority) -		priority = at91sam9260_default_irq_priority; - -	/* Initialize the AIC interrupt controller */ -	at91_aic_init(priority); - -	/* Enable GPIO interrupts */ -	at91_gpio_irq_setup(); -} +AT91_SOC_START(at91sam9260) +	.map_io = at91sam9260_map_io, +	.default_irq_priority = at91sam9260_default_irq_priority, +	.extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1) +		    | (1 << AT91SAM9260_ID_IRQ2), +	.ioremap_registers = at91sam9260_ioremap_registers, +	.register_clocks = at91sam9260_register_clocks, +	.init = at91sam9260_initialize, +AT91_SOC_END diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index 07eb7b07e44..ef88e0fe4e8 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c @@ -13,18 +13,22 @@  #include <asm/mach/map.h>  #include <linux/dma-mapping.h> +#include <linux/gpio.h>  #include <linux/platform_device.h>  #include <linux/i2c-gpio.h> -#include <mach/board.h> -#include <mach/gpio.h> +#include <linux/platform_data/at91_adc.h> +  #include <mach/cpu.h>  #include <mach/at91sam9260.h>  #include <mach/at91sam9260_matrix.h> +#include <mach/at91_matrix.h>  #include <mach/at91sam9_smc.h> +#include <mach/hardware.h> +#include "board.h"  #include "generic.h" - +#include "gpio.h"  /* --------------------------------------------------------------------   *  USB Host @@ -41,8 +45,8 @@ static struct resource usbh_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_UHP, -		.end	= AT91SAM9260_ID_UHP, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_UHP, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_UHP,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -61,9 +65,17 @@ static struct platform_device at91_usbh_device = {  void __init at91_add_device_usbh(struct at91_usbh_data *data)  { +	int i; +  	if (!data)  		return; +	/* Enable overcurrent notification */ +	for (i = 0; i < data->ports; i++) { +		if (gpio_is_valid(data->overcurrent_pin[i])) +			at91_set_gpio_input(data->overcurrent_pin[i], 1); +	} +  	usbh_data = *data;  	platform_device_register(&at91_usbh_device);  } @@ -76,7 +88,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}   *  USB Device (Gadget)   * -------------------------------------------------------------------- */ -#ifdef CONFIG_USB_GADGET_AT91 +#if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)  static struct at91_udc_data udc_data;  static struct resource udc_resources[] = { @@ -86,8 +98,8 @@ static struct resource udc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_UDP, -		.end	= AT91SAM9260_ID_UDP, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_UDP, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_UDP,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -107,7 +119,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data)  	if (!data)  		return; -	if (data->vbus_pin) { +	if (gpio_is_valid(data->vbus_pin)) {  		at91_set_gpio_input(data->vbus_pin, 0);  		at91_set_deglitch(data->vbus_pin, 1);  	} @@ -128,7 +140,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}  #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)  static u64 eth_dmamask = DMA_BIT_MASK(32); -static struct at91_eth_data eth_data; +static struct macb_platform_data eth_data;  static struct resource eth_resources[] = {  	[0] = { @@ -137,8 +149,8 @@ static struct resource eth_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_EMAC, -		.end	= AT91SAM9260_ID_EMAC, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_EMAC, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_EMAC,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -155,12 +167,12 @@ static struct platform_device at91sam9260_eth_device = {  	.num_resources	= ARRAY_SIZE(eth_resources),  }; -void __init at91_add_device_eth(struct at91_eth_data *data) +void __init at91_add_device_eth(struct macb_platform_data *data)  {  	if (!data)  		return; -	if (data->phy_irq_pin) { +	if (gpio_is_valid(data->phy_irq_pin)) {  		at91_set_gpio_input(data->phy_irq_pin, 0);  		at91_set_deglitch(data->phy_irq_pin, 1);  	} @@ -192,97 +204,15 @@ void __init at91_add_device_eth(struct at91_eth_data *data)  	platform_device_register(&at91sam9260_eth_device);  }  #else -void __init at91_add_device_eth(struct at91_eth_data *data) {} +void __init at91_add_device_eth(struct macb_platform_data *data) {}  #endif  /* -------------------------------------------------------------------- - *  MMC / SD - * -------------------------------------------------------------------- */ - -#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) -static u64 mmc_dmamask = DMA_BIT_MASK(32); -static struct at91_mmc_data mmc_data; - -static struct resource mmc_resources[] = { -	[0] = { -		.start	= AT91SAM9260_BASE_MCI, -		.end	= AT91SAM9260_BASE_MCI + SZ_16K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	[1] = { -		.start	= AT91SAM9260_ID_MCI, -		.end	= AT91SAM9260_ID_MCI, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device at91sam9260_mmc_device = { -	.name		= "at91_mci", -	.id		= -1, -	.dev		= { -				.dma_mask		= &mmc_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &mmc_data, -	}, -	.resource	= mmc_resources, -	.num_resources	= ARRAY_SIZE(mmc_resources), -}; - -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) -{ -	if (!data) -		return; - -	/* input/irq */ -	if (data->det_pin) { -		at91_set_gpio_input(data->det_pin, 1); -		at91_set_deglitch(data->det_pin, 1); -	} -	if (data->wp_pin) -		at91_set_gpio_input(data->wp_pin, 1); -	if (data->vcc_pin) -		at91_set_gpio_output(data->vcc_pin, 0); - -	/* CLK */ -	at91_set_A_periph(AT91_PIN_PA8, 0); - -	if (data->slot_b) { -		/* CMD */ -		at91_set_B_periph(AT91_PIN_PA1, 1); - -		/* DAT0, maybe DAT1..DAT3 */ -		at91_set_B_periph(AT91_PIN_PA0, 1); -		if (data->wire4) { -			at91_set_B_periph(AT91_PIN_PA5, 1); -			at91_set_B_periph(AT91_PIN_PA4, 1); -			at91_set_B_periph(AT91_PIN_PA3, 1); -		} -	} else { -		/* CMD */ -		at91_set_A_periph(AT91_PIN_PA7, 1); - -		/* DAT0, maybe DAT1..DAT3 */ -		at91_set_A_periph(AT91_PIN_PA6, 1); -		if (data->wire4) { -			at91_set_A_periph(AT91_PIN_PA9, 1); -			at91_set_A_periph(AT91_PIN_PA10, 1); -			at91_set_A_periph(AT91_PIN_PA11, 1); -		} -	} - -	mmc_data = *data; -	platform_device_register(&at91sam9260_mmc_device); -} -#else -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} -#endif - -/* --------------------------------------------------------------------   *  MMC / SD Slot for Atmel MCI Driver   * -------------------------------------------------------------------- */ -#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE) +#if IS_ENABLED(CONFIG_MMC_ATMELMCI)  static u64 mmc_dmamask = DMA_BIT_MASK(32);  static struct mci_platform_data mmc_data; @@ -293,8 +223,8 @@ static struct resource mmc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_MCI, -		.end	= AT91SAM9260_ID_MCI, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_MCI, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_MCI,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -319,14 +249,14 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)  	if (!data)  		return; -	for (i = 0; i < ATMEL_MCI_MAX_NR_SLOTS; i++) { +	for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {  		if (data->slot[i].bus_width) {  			/* input/irq */ -			if (data->slot[i].detect_pin) { +			if (gpio_is_valid(data->slot[i].detect_pin)) {  				at91_set_gpio_input(data->slot[i].detect_pin, 1);  				at91_set_deglitch(data->slot[i].detect_pin, 1);  			} -			if (data->slot[i].wp_pin) +			if (gpio_is_valid(data->slot[i].wp_pin))  				at91_set_gpio_input(data->slot[i].wp_pin, 1);  			switch (i) { @@ -391,8 +321,8 @@ static struct resource nand_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91_BASE_SYS + AT91_ECC, -		.end	= AT91_BASE_SYS + AT91_ECC + SZ_512 - 1, +		.start	= AT91SAM9260_BASE_ECC, +		.end	= AT91SAM9260_BASE_ECC + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	}  }; @@ -414,19 +344,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)  	if (!data)  		return; -	csa = at91_sys_read(AT91_MATRIX_EBICSA); -	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); +	csa = at91_matrix_read(AT91_MATRIX_EBICSA); +	at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);  	/* enable pin */ -	if (data->enable_pin) +	if (gpio_is_valid(data->enable_pin))  		at91_set_gpio_output(data->enable_pin, 1);  	/* ready/busy pin */ -	if (data->rdy_pin) +	if (gpio_is_valid(data->rdy_pin))  		at91_set_gpio_input(data->rdy_pin, 1);  	/* card detect pin */ -	if (data->det_pin) +	if (gpio_is_valid(data->det_pin))  		at91_set_gpio_input(data->det_pin, 1);  	nand_data = *data; @@ -459,7 +389,7 @@ static struct i2c_gpio_platform_data pdata = {  static struct platform_device at91sam9260_twi_device = {  	.name			= "i2c-gpio", -	.id			= -1, +	.id			= 0,  	.dev.platform_data	= &pdata,  }; @@ -484,21 +414,27 @@ static struct resource twi_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_TWI, -		.end	= AT91SAM9260_ID_TWI, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_TWI, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_TWI,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9260_twi_device = { -	.name		= "at91_i2c", -	.id		= -1, +	.id		= 0,  	.resource	= twi_resources,  	.num_resources	= ARRAY_SIZE(twi_resources),  };  void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)  { +	/* IP version is not the same on 9260 and g20 */ +	if (cpu_is_at91sam9g20()) { +		at91sam9260_twi_device.name = "i2c-at91sam9g20"; +	} else { +		at91sam9260_twi_device.name = "i2c-at91sam9260"; +	} +  	/* pins used for TWI interface */  	at91_set_A_periph(AT91_PIN_PA23, 0);		/* TWD */  	at91_set_multi_drive(AT91_PIN_PA23, 1); @@ -528,8 +464,8 @@ static struct resource spi0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_SPI0, -		.end	= AT91SAM9260_ID_SPI0, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_SPI0, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_SPI0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -554,8 +490,8 @@ static struct resource spi1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_SPI1, -		.end	= AT91SAM9260_ID_SPI1, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_SPI1, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_SPI1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -589,6 +525,9 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		else  			cs_pin = spi1_standard_cs[devices[i].chip_select]; +		if (!gpio_is_valid(cs_pin)) +			continue; +  		if (devices[i].bus_num == 0)  			enable_spi0 = 1;  		else @@ -609,7 +548,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		at91_set_A_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */  		at91_set_A_periph(AT91_PIN_PA2, 0);	/* SPI1_SPCK */ -		at91_clock_associate("spi0_clk", &at91sam9260_spi0_device.dev, "spi_clk");  		platform_device_register(&at91sam9260_spi0_device);  	}  	if (enable_spi1) { @@ -617,7 +555,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		at91_set_A_periph(AT91_PIN_PB1, 0);	/* SPI1_MOSI */  		at91_set_A_periph(AT91_PIN_PB2, 0);	/* SPI1_SPCK */ -		at91_clock_associate("spi1_clk", &at91sam9260_spi1_device.dev, "spi_clk");  		platform_device_register(&at91sam9260_spi1_device);  	}  } @@ -635,22 +572,22 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  static struct resource tcb0_resources[] = {  	[0] = {  		.start	= AT91SAM9260_BASE_TCB0, -		.end	= AT91SAM9260_BASE_TCB0 + SZ_16K - 1, +		.end	= AT91SAM9260_BASE_TCB0 + SZ_256 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_TC0, -		.end	= AT91SAM9260_ID_TC0, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC0, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC0,  		.flags	= IORESOURCE_IRQ,  	},  	[2] = { -		.start	= AT91SAM9260_ID_TC1, -		.end	= AT91SAM9260_ID_TC1, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC1, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC1,  		.flags	= IORESOURCE_IRQ,  	},  	[3] = { -		.start	= AT91SAM9260_ID_TC2, -		.end	= AT91SAM9260_ID_TC2, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC2, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC2,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -665,22 +602,22 @@ static struct platform_device at91sam9260_tcb0_device = {  static struct resource tcb1_resources[] = {  	[0] = {  		.start	= AT91SAM9260_BASE_TCB1, -		.end	= AT91SAM9260_BASE_TCB1 + SZ_16K - 1, +		.end	= AT91SAM9260_BASE_TCB1 + SZ_256 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_TC3, -		.end	= AT91SAM9260_ID_TC3, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC3, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC3,  		.flags	= IORESOURCE_IRQ,  	},  	[2] = { -		.start	= AT91SAM9260_ID_TC4, -		.end	= AT91SAM9260_ID_TC4, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC4, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC4,  		.flags	= IORESOURCE_IRQ,  	},  	[3] = { -		.start	= AT91SAM9260_ID_TC5, -		.end	= AT91SAM9260_ID_TC5, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC5, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_TC5,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -694,15 +631,7 @@ static struct platform_device at91sam9260_tcb1_device = {  static void __init at91_add_device_tc(void)  { -	/* this chip has a separate clock and irq for each TC channel */ -	at91_clock_associate("tc0_clk", &at91sam9260_tcb0_device.dev, "t0_clk"); -	at91_clock_associate("tc1_clk", &at91sam9260_tcb0_device.dev, "t1_clk"); -	at91_clock_associate("tc2_clk", &at91sam9260_tcb0_device.dev, "t2_clk");  	platform_device_register(&at91sam9260_tcb0_device); - -	at91_clock_associate("tc3_clk", &at91sam9260_tcb1_device.dev, "t0_clk"); -	at91_clock_associate("tc4_clk", &at91sam9260_tcb1_device.dev, "t1_clk"); -	at91_clock_associate("tc5_clk", &at91sam9260_tcb1_device.dev, "t2_clk");  	platform_device_register(&at91sam9260_tcb1_device);  }  #else @@ -716,21 +645,49 @@ static void __init at91_add_device_tc(void) { }  static struct resource rtt_resources[] = {  	{ -		.start	= AT91_BASE_SYS + AT91_RTT, -		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1, +		.start	= AT91SAM9260_BASE_RTT, +		.end	= AT91SAM9260_BASE_RTT + SZ_16 - 1,  		.flags	= IORESOURCE_MEM, -	} +	}, { +		.flags	= IORESOURCE_MEM, +	}, { +		.flags  = IORESOURCE_IRQ, +	},  };  static struct platform_device at91sam9260_rtt_device = {  	.name		= "at91_rtt",  	.id		= 0,  	.resource	= rtt_resources, -	.num_resources	= ARRAY_SIZE(rtt_resources),  }; + +#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9) +static void __init at91_add_device_rtt_rtc(void) +{ +	at91sam9260_rtt_device.name = "rtc-at91sam9"; +	/* +	 * The second resource is needed: +	 * GPBR will serve as the storage for RTC time offset +	 */ +	at91sam9260_rtt_device.num_resources = 3; +	rtt_resources[1].start = AT91SAM9260_BASE_GPBR + +				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; +	rtt_resources[1].end = rtt_resources[1].start + 3; +	rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS; +	rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS; +} +#else +static void __init at91_add_device_rtt_rtc(void) +{ +	/* Only one resource is needed: RTT not used as RTC */ +	at91sam9260_rtt_device.num_resources = 1; +} +#endif +  static void __init at91_add_device_rtt(void)  { +	at91_add_device_rtt_rtc();  	platform_device_register(&at91sam9260_rtt_device);  } @@ -740,10 +697,19 @@ static void __init at91_add_device_rtt(void)   * -------------------------------------------------------------------- */  #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) +static struct resource wdt_resources[] = { +	{ +		.start	= AT91SAM9260_BASE_WDT, +		.end	= AT91SAM9260_BASE_WDT + SZ_16 - 1, +		.flags	= IORESOURCE_MEM, +	} +}; +  static struct platform_device at91sam9260_wdt_device = {  	.name		= "at91_wdt",  	.id		= -1, -	.num_resources	= 0, +	.resource	= wdt_resources, +	.num_resources	= ARRAY_SIZE(wdt_resources),  };  static void __init at91_add_device_watchdog(void) @@ -769,14 +735,14 @@ static struct resource ssc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_SSC, -		.end	= AT91SAM9260_ID_SSC, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_SSC, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_SSC,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9260_ssc_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 0,  	.dev	= {  		.dma_mask		= &ssc_dmamask, @@ -820,7 +786,6 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)  	case AT91SAM9260_ID_SSC:  		pdev = &at91sam9260_ssc_device;  		configure_ssc_pins(pins); -		at91_clock_associate("ssc_clk", &pdev->dev, "pclk");  		break;  	default:  		return; @@ -840,13 +805,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}  #if defined(CONFIG_SERIAL_ATMEL)  static struct resource dbgu_resources[] = {  	[0] = { -		.start	= AT91_VA_BASE_SYS + AT91_DBGU, -		.end	= AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, +		.start	= AT91SAM9260_BASE_DBGU, +		.end	= AT91SAM9260_BASE_DBGU + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91_ID_SYS, -		.end	= AT91_ID_SYS, +		.start	= NR_IRQS_LEGACY + AT91_ID_SYS, +		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -854,7 +819,6 @@ static struct resource dbgu_resources[] = {  static struct atmel_uart_data dbgu_data = {  	.use_dma_tx	= 0,  	.use_dma_rx	= 0,		/* DBGU not capable of receive DMA */ -	.regs		= (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),  };  static u64 dbgu_dmamask = DMA_BIT_MASK(32); @@ -884,8 +848,8 @@ static struct resource uart0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_US0, -		.end	= AT91SAM9260_ID_US0, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_US0, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_US0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -935,8 +899,8 @@ static struct resource uart1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_US1, -		.end	= AT91SAM9260_ID_US1, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_US1, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_US1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -978,8 +942,8 @@ static struct resource uart2_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_US2, -		.end	= AT91SAM9260_ID_US2, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_US2, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_US2,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1021,8 +985,8 @@ static struct resource uart3_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_US3, -		.end	= AT91SAM9260_ID_US3, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_US3, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_US3,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1064,8 +1028,8 @@ static struct resource uart4_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_US4, -		.end	= AT91SAM9260_ID_US4, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_US4, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_US4,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1102,8 +1066,8 @@ static struct resource uart5_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9260_ID_US5, -		.end	= AT91SAM9260_ID_US5, +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_US5, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_US5,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1134,63 +1098,51 @@ static inline void configure_usart5_pins(void)  }  static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */ -struct platform_device *atmel_default_console_device;	/* the serial console device */  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)  {  	struct platform_device *pdev; +	struct atmel_uart_data *pdata;  	switch (id) {  		case 0:		/* DBGU */  			pdev = &at91sam9260_dbgu_device;  			configure_dbgu_pins(); -			at91_clock_associate("mck", &pdev->dev, "usart");  			break;  		case AT91SAM9260_ID_US0:  			pdev = &at91sam9260_uart0_device;  			configure_usart0_pins(pins); -			at91_clock_associate("usart0_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9260_ID_US1:  			pdev = &at91sam9260_uart1_device;  			configure_usart1_pins(pins); -			at91_clock_associate("usart1_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9260_ID_US2:  			pdev = &at91sam9260_uart2_device;  			configure_usart2_pins(pins); -			at91_clock_associate("usart2_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9260_ID_US3:  			pdev = &at91sam9260_uart3_device;  			configure_usart3_pins(pins); -			at91_clock_associate("usart3_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9260_ID_US4:  			pdev = &at91sam9260_uart4_device;  			configure_usart4_pins(); -			at91_clock_associate("usart4_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9260_ID_US5:  			pdev = &at91sam9260_uart5_device;  			configure_usart5_pins(); -			at91_clock_associate("usart5_clk", &pdev->dev, "usart");  			break;  		default:  			return;  	} -	pdev->id = portnr;		/* update to mapped ID */ +	pdata = pdev->dev.platform_data; +	pdata->num = portnr;		/* update to mapped ID */  	if (portnr < ATMEL_MAX_UART)  		at91_uarts[portnr] = pdev;  } -void __init at91_set_serial_console(unsigned portnr) -{ -	if (portnr < ATMEL_MAX_UART) -		atmel_default_console_device = at91_uarts[portnr]; -} -  void __init at91_add_device_serial(void)  {  	int i; @@ -1199,13 +1151,9 @@ void __init at91_add_device_serial(void)  		if (at91_uarts[i])  			platform_device_register(at91_uarts[i]);  	} - -	if (!atmel_default_console_device) -		printk(KERN_INFO "AT91: No default serial console defined.\n");  }  #else  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {}  void __init at91_add_device_serial(void) {}  #endif @@ -1213,8 +1161,7 @@ void __init at91_add_device_serial(void) {}   *  CF/IDE   * -------------------------------------------------------------------- */ -#if defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE) || \ -	defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \ +#if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \  	defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)  static struct at91_cf_data cf0_data; @@ -1263,7 +1210,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)  	if (!data)  		return; -	csa = at91_sys_read(AT91_MATRIX_EBICSA); +	csa = at91_matrix_read(AT91_MATRIX_EBICSA);  	switch (data->chipselect) {  	case 4: @@ -1286,19 +1233,19 @@ void __init at91_add_device_cf(struct at91_cf_data *data)  		return;  	} -	at91_sys_write(AT91_MATRIX_EBICSA, csa); +	at91_matrix_write(AT91_MATRIX_EBICSA, csa); -	if (data->rst_pin) { +	if (gpio_is_valid(data->rst_pin)) {  		at91_set_multi_drive(data->rst_pin, 0);  		at91_set_gpio_output(data->rst_pin, 1);  	} -	if (data->irq_pin) { +	if (gpio_is_valid(data->irq_pin)) {  		at91_set_gpio_input(data->irq_pin, 0);  		at91_set_deglitch(data->irq_pin, 1);  	} -	if (data->det_pin) { +	if (gpio_is_valid(data->det_pin)) {  		at91_set_gpio_input(data->det_pin, 0);  		at91_set_deglitch(data->det_pin, 1);  	} @@ -1308,14 +1255,8 @@ void __init at91_add_device_cf(struct at91_cf_data *data)  	at91_set_A_periph(AT91_PIN_PC10, 0);    /* CFRNW */  	at91_set_A_periph(AT91_PIN_PC15, 1);    /* NWAIT */ -	if (data->flags & AT91_CF_TRUE_IDE) -#if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) +	if (IS_ENABLED(CONFIG_PATA_AT91) && (data->flags & AT91_CF_TRUE_IDE))  		pdev->name = "pata_at91"; -#elif defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE) -		pdev->name = "at91_ide"; -#else -#warning "board requires AT91_CF_TRUE_IDE: enable either at91_ide or pata_at91" -#endif  	else  		pdev->name = "at91_cf"; @@ -1326,6 +1267,84 @@ void __init at91_add_device_cf(struct at91_cf_data *data)  void __init at91_add_device_cf(struct at91_cf_data * data) {}  #endif +/* -------------------------------------------------------------------- + *  ADCs + * -------------------------------------------------------------------- */ + +#if IS_ENABLED(CONFIG_AT91_ADC) +static struct at91_adc_data adc_data; + +static struct resource adc_resources[] = { +	[0] = { +		.start	= AT91SAM9260_BASE_ADC, +		.end	= AT91SAM9260_BASE_ADC + SZ_16K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	[1] = { +		.start	= NR_IRQS_LEGACY + AT91SAM9260_ID_ADC, +		.end	= NR_IRQS_LEGACY + AT91SAM9260_ID_ADC, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct platform_device at91_adc_device = { +	.name		= "at91sam9260-adc", +	.id		= -1, +	.dev		= { +				.platform_data		= &adc_data, +	}, +	.resource	= adc_resources, +	.num_resources	= ARRAY_SIZE(adc_resources), +}; + +static struct at91_adc_trigger at91_adc_triggers[] = { +	[0] = { +		.name = "timer-counter-0", +		.value = 0x1, +	}, +	[1] = { +		.name = "timer-counter-1", +		.value = 0x3, +	}, +	[2] = { +		.name = "timer-counter-2", +		.value = 0x5, +	}, +	[3] = { +		.name = "external", +		.value = 0xd, +		.is_external = true, +	}, +}; + +void __init at91_add_device_adc(struct at91_adc_data *data) +{ +	if (!data) +		return; + +	if (test_bit(0, &data->channels_used)) +		at91_set_A_periph(AT91_PIN_PC0, 0); +	if (test_bit(1, &data->channels_used)) +		at91_set_A_periph(AT91_PIN_PC1, 0); +	if (test_bit(2, &data->channels_used)) +		at91_set_A_periph(AT91_PIN_PC2, 0); +	if (test_bit(3, &data->channels_used)) +		at91_set_A_periph(AT91_PIN_PC3, 0); + +	if (data->use_external_triggers) +		at91_set_A_periph(AT91_PIN_PA22, 0); + +	data->startup_time = 10; +	data->trigger_number = 4; +	data->trigger_list = at91_adc_triggers; + +	adc_data = *data; +	platform_device_register(&at91_adc_device); +} +#else +void __init at91_add_device_adc(struct at91_adc_data *data) {} +#endif +  /* -------------------------------------------------------------------- */  /*   * These devices are always present and don't need any board-specific @@ -1333,6 +1352,9 @@ void __init at91_add_device_cf(struct at91_cf_data * data) {}   */  static int __init at91_add_standard_devices(void)  { +	if (of_have_populated_dt()) +		return 0; +  	at91_add_device_rtt();  	at91_add_device_watchdog();  	at91_add_device_tc(); diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c index fcad8866850..fb164a5d04a 100644 --- a/arch/arm/mach-at91/at91sam9261.c +++ b/arch/arm/mach-at91/at91sam9261.c @@ -11,46 +11,26 @@   */  #include <linux/module.h> -#include <linux/pm.h> +#include <linux/clk/at91_pmc.h> +#include <asm/proc-fns.h>  #include <asm/irq.h>  #include <asm/mach/arch.h>  #include <asm/mach/map.h> +#include <asm/system_misc.h>  #include <mach/cpu.h>  #include <mach/at91sam9261.h> -#include <mach/at91_pmc.h> -#include <mach/at91_rstc.h> -#include <mach/at91_shdwc.h> +#include <mach/hardware.h> +#include "at91_aic.h" +#include "at91_rstc.h" +#include "soc.h"  #include "generic.h" -#include "clock.h" - -static struct map_desc at91sam9261_io_desc[] __initdata = { -	{ -		.virtual	= AT91_VA_BASE_SYS, -		.pfn		= __phys_to_pfn(AT91_BASE_SYS), -		.length		= SZ_16K, -		.type		= MT_DEVICE, -	}, -}; +#include "sam9_smc.h" +#include "pm.h" -static struct map_desc at91sam9261_sram_desc[] __initdata = { -	{ -		.virtual	= AT91_IO_VIRT_BASE - AT91SAM9261_SRAM_SIZE, -		.pfn		= __phys_to_pfn(AT91SAM9261_SRAM_BASE), -		.length		= AT91SAM9261_SRAM_SIZE, -		.type		= MT_DEVICE, -	}, -}; - -static struct map_desc at91sam9g10_sram_desc[] __initdata = { -	{ -		.virtual	= AT91_IO_VIRT_BASE - AT91SAM9G10_SRAM_SIZE, -		.pfn		= __phys_to_pfn(AT91SAM9G10_SRAM_BASE), -		.length		= AT91SAM9G10_SRAM_SIZE, -		.type		= MT_DEVICE, -	}, -}; +#if defined(CONFIG_OLD_CLK_AT91) +#include "clock.h"  /* --------------------------------------------------------------------   *  Clocks @@ -155,6 +135,20 @@ static struct clk lcdc_clk = {  	.type		= CLK_TYPE_PERIPHERAL,  }; +/* HClocks */ +static struct clk hck0 = { +	.name		= "hck0", +	.pmc_mask	= AT91_PMC_HCK0, +	.type		= CLK_TYPE_SYSTEM, +	.id		= 0, +}; +static struct clk hck1 = { +	.name		= "hck1", +	.pmc_mask	= AT91_PMC_HCK1, +	.type		= CLK_TYPE_SYSTEM, +	.id		= 1, +}; +  static struct clk *periph_clocks[] __initdata = {  	&pioA_clk,  	&pioB_clk, @@ -178,6 +172,52 @@ static struct clk *periph_clocks[] __initdata = {  	// irq0 .. irq2  }; +static struct clk_lookup periph_clocks_lookups[] = { +	CLKDEV_CON_DEV_ID("hclk", "at91sam9261-lcdfb.0", &hck1), +	CLKDEV_CON_DEV_ID("hclk", "at91sam9g10-lcdfb.0", &hck1), +	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.2", &ssc2_clk), +	CLKDEV_CON_DEV_ID("pclk", "fffbc000.ssc", &ssc0_clk), +	CLKDEV_CON_DEV_ID("pclk", "fffc0000.ssc", &ssc1_clk), +	CLKDEV_CON_DEV_ID("pclk", "fffc4000.ssc", &ssc2_clk), +	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &hck0), +	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9261.0", &twi_clk), +	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi_clk), +	CLKDEV_CON_ID("pioA", &pioA_clk), +	CLKDEV_CON_ID("pioB", &pioB_clk), +	CLKDEV_CON_ID("pioC", &pioC_clk), +	/* more lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck), +	CLKDEV_CON_DEV_ID("usart", "fffb0000.serial", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "ffffb400.serial", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "fff94000.serial", &usart2_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "fffa0000.timer", &tc0_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "fffa0000.timer", &tc1_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "fffa0000.timer", &tc2_clk), +	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &hck0), +	CLKDEV_CON_DEV_ID("hclk", "600000.fb", &hck1), +	CLKDEV_CON_DEV_ID("spi_clk", "fffc8000.spi", &spi0_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "fffcc000.spi", &spi1_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "fffa8000.mmc", &mmc_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffac000.i2c", &twi_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioA_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioB_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioC_clk), +}; + +static struct clk_lookup usart_clocks_lookups[] = { +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), +}; +  /*   * The four programmable clocks.   * You must configure pin multiplexing to bring these signals out. @@ -207,20 +247,6 @@ static struct clk pck3 = {  	.id		= 3,  }; -/* HClocks */ -static struct clk hck0 = { -	.name		= "hck0", -	.pmc_mask	= AT91_PMC_HCK0, -	.type		= CLK_TYPE_SYSTEM, -	.id		= 0, -}; -static struct clk hck1 = { -	.name		= "hck1", -	.pmc_mask	= AT91_PMC_HCK1, -	.type		= CLK_TYPE_SYSTEM, -	.id		= 1, -}; -  static void __init at91sam9261_register_clocks(void)  {  	int i; @@ -228,6 +254,11 @@ static void __init at91sam9261_register_clocks(void)  	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)  		clk_register(periph_clocks[i]); +	clkdev_add_table(periph_clocks_lookups, +			 ARRAY_SIZE(periph_clocks_lookups)); +	clkdev_add_table(usart_clocks_lookups, +			 ARRAY_SIZE(usart_clocks_lookups)); +  	clk_register(&pck0);  	clk_register(&pck1);  	clk_register(&pck2); @@ -236,58 +267,55 @@ static void __init at91sam9261_register_clocks(void)  	clk_register(&hck0);  	clk_register(&hck1);  } - +#else +#define at91sam9261_register_clocks NULL +#endif  /* --------------------------------------------------------------------   *  GPIO   * -------------------------------------------------------------------- */ -static struct at91_gpio_bank at91sam9261_gpio[] = { +static struct at91_gpio_bank at91sam9261_gpio[] __initdata = {  	{  		.id		= AT91SAM9261_ID_PIOA, -		.offset		= AT91_PIOA, -		.clock		= &pioA_clk, +		.regbase	= AT91SAM9261_BASE_PIOA,  	}, {  		.id		= AT91SAM9261_ID_PIOB, -		.offset		= AT91_PIOB, -		.clock		= &pioB_clk, +		.regbase	= AT91SAM9261_BASE_PIOB,  	}, {  		.id		= AT91SAM9261_ID_PIOC, -		.offset		= AT91_PIOC, -		.clock		= &pioC_clk, +		.regbase	= AT91SAM9261_BASE_PIOC,  	}  }; -static void at91sam9261_poweroff(void) -{ -	at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); -} - -  /* --------------------------------------------------------------------   *  AT91SAM9261 processor initialization   * -------------------------------------------------------------------- */ -void __init at91sam9261_initialize(unsigned long main_clock) +static void __init at91sam9261_map_io(void)  { -	/* Map peripherals */ -	iotable_init(at91sam9261_io_desc, ARRAY_SIZE(at91sam9261_io_desc)); -  	if (cpu_is_at91sam9g10()) -		iotable_init(at91sam9g10_sram_desc, ARRAY_SIZE(at91sam9g10_sram_desc)); +		at91_init_sram(0, AT91SAM9G10_SRAM_BASE, AT91SAM9G10_SRAM_SIZE);  	else -		iotable_init(at91sam9261_sram_desc, ARRAY_SIZE(at91sam9261_sram_desc)); - +		at91_init_sram(0, AT91SAM9261_SRAM_BASE, AT91SAM9261_SRAM_SIZE); +} -	at91_arch_reset = at91sam9_alt_reset; -	pm_power_off = at91sam9261_poweroff; -	at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1) -			| (1 << AT91SAM9261_ID_IRQ2); +static void __init at91sam9261_ioremap_registers(void) +{ +	at91_ioremap_shdwc(AT91SAM9261_BASE_SHDWC); +	at91_ioremap_rstc(AT91SAM9261_BASE_RSTC); +	at91_ioremap_ramc(0, AT91SAM9261_BASE_SDRAMC, 512); +	at91sam926x_ioremap_pit(AT91SAM9261_BASE_PIT); +	at91sam9_ioremap_smc(0, AT91SAM9261_BASE_SMC); +	at91_ioremap_matrix(AT91SAM9261_BASE_MATRIX); +	at91_pm_set_standby(at91sam9_sdram_standby); +} -	/* Init clock subsystem */ -	at91_clock_init(main_clock); +static void __init at91sam9261_initialize(void) +{ +	arm_pm_idle = at91sam9_idle; +	arm_pm_restart = at91sam9_alt_restart; -	/* Register the processor-specific clocks */ -	at91sam9261_register_clocks(); +	at91_sysirq_mask_rtt(AT91SAM9261_BASE_RTT);  	/* Register GPIO subsystem */  	at91_gpio_init(at91sam9261_gpio, 3); @@ -335,14 +363,12 @@ static unsigned int at91sam9261_default_irq_priority[NR_AIC_IRQS] __initdata = {  	0,	/* Advanced Interrupt Controller */  }; -void __init at91sam9261_init_interrupts(unsigned int priority[NR_AIC_IRQS]) -{ -	if (!priority) -		priority = at91sam9261_default_irq_priority; - -	/* Initialize the AIC interrupt controller */ -	at91_aic_init(priority); - -	/* Enable GPIO interrupts */ -	at91_gpio_irq_setup(); -} +AT91_SOC_START(at91sam9261) +	.map_io = at91sam9261_map_io, +	.default_irq_priority = at91sam9261_default_irq_priority, +	.extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1) +		    | (1 << AT91SAM9261_ID_IRQ2), +	.ioremap_registers = at91sam9261_ioremap_registers, +	.register_clocks = at91sam9261_register_clocks, +	.init = at91sam9261_initialize, +AT91_SOC_END diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c index 59fc48311fb..29baacb5c35 100644 --- a/arch/arm/mach-at91/at91sam9261_devices.c +++ b/arch/arm/mach-at91/at91sam9261_devices.c @@ -14,20 +14,22 @@  #include <asm/mach/map.h>  #include <linux/dma-mapping.h> +#include <linux/gpio.h>  #include <linux/platform_device.h>  #include <linux/i2c-gpio.h>  #include <linux/fb.h>  #include <video/atmel_lcdc.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9261.h>  #include <mach/at91sam9261_matrix.h> +#include <mach/at91_matrix.h>  #include <mach/at91sam9_smc.h> +#include <mach/hardware.h> +#include "board.h"  #include "generic.h" - +#include "gpio.h"  /* --------------------------------------------------------------------   *  USB Host @@ -44,8 +46,8 @@ static struct resource usbh_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_UHP, -		.end	= AT91SAM9261_ID_UHP, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_UHP, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_UHP,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -64,9 +66,17 @@ static struct platform_device at91sam9261_usbh_device = {  void __init at91_add_device_usbh(struct at91_usbh_data *data)  { +	int i; +  	if (!data)  		return; +	/* Enable overcurrent notification */ +	for (i = 0; i < data->ports; i++) { +		if (gpio_is_valid(data->overcurrent_pin[i])) +			at91_set_gpio_input(data->overcurrent_pin[i], 1); +	} +  	usbh_data = *data;  	platform_device_register(&at91sam9261_usbh_device);  } @@ -79,7 +89,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}   *  USB Device (Gadget)   * -------------------------------------------------------------------- */ -#ifdef CONFIG_USB_GADGET_AT91 +#if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)  static struct at91_udc_data udc_data;  static struct resource udc_resources[] = { @@ -89,8 +99,8 @@ static struct resource udc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_UDP, -		.end	= AT91SAM9261_ID_UDP, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_UDP, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_UDP,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -110,7 +120,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data)  	if (!data)  		return; -	if (data->vbus_pin) { +	if (gpio_is_valid(data->vbus_pin)) {  		at91_set_gpio_input(data->vbus_pin, 0);  		at91_set_deglitch(data->vbus_pin, 1);  	} @@ -128,9 +138,9 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}   *  MMC / SD   * -------------------------------------------------------------------- */ -#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) +#if IS_ENABLED(CONFIG_MMC_ATMELMCI)  static u64 mmc_dmamask = DMA_BIT_MASK(32); -static struct at91_mmc_data mmc_data; +static struct mci_platform_data mmc_data;  static struct resource mmc_resources[] = {  	[0] = { @@ -139,14 +149,14 @@ static struct resource mmc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_MCI, -		.end	= AT91SAM9261_ID_MCI, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_MCI, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_MCI,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9261_mmc_device = { -	.name		= "at91_mci", +	.name		= "atmel_mci",  	.id		= -1,  	.dev		= {  				.dma_mask		= &mmc_dmamask, @@ -157,40 +167,40 @@ static struct platform_device at91sam9261_mmc_device = {  	.num_resources	= ARRAY_SIZE(mmc_resources),  }; -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) +void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)  {  	if (!data)  		return; -	/* input/irq */ -	if (data->det_pin) { -		at91_set_gpio_input(data->det_pin, 1); -		at91_set_deglitch(data->det_pin, 1); -	} -	if (data->wp_pin) -		at91_set_gpio_input(data->wp_pin, 1); -	if (data->vcc_pin) -		at91_set_gpio_output(data->vcc_pin, 0); - -	/* CLK */ -	at91_set_B_periph(AT91_PIN_PA2, 0); - -	/* CMD */ -	at91_set_B_periph(AT91_PIN_PA1, 1); - -	/* DAT0, maybe DAT1..DAT3 */ -	at91_set_B_periph(AT91_PIN_PA0, 1); -	if (data->wire4) { -		at91_set_B_periph(AT91_PIN_PA4, 1); -		at91_set_B_periph(AT91_PIN_PA5, 1); -		at91_set_B_periph(AT91_PIN_PA6, 1); -	} +	if (data->slot[0].bus_width) { +		/* input/irq */ +		if (gpio_is_valid(data->slot[0].detect_pin)) { +			at91_set_gpio_input(data->slot[0].detect_pin, 1); +			at91_set_deglitch(data->slot[0].detect_pin, 1); +		} +		if (gpio_is_valid(data->slot[0].wp_pin)) +			at91_set_gpio_input(data->slot[0].wp_pin, 1); + +		/* CLK */ +		at91_set_B_periph(AT91_PIN_PA2, 0); + +		/* CMD */ +		at91_set_B_periph(AT91_PIN_PA1, 1); -	mmc_data = *data; -	platform_device_register(&at91sam9261_mmc_device); +		/* DAT0, maybe DAT1..DAT3 */ +		at91_set_B_periph(AT91_PIN_PA0, 1); +		if (data->slot[0].bus_width == 4) { +			at91_set_B_periph(AT91_PIN_PA4, 1); +			at91_set_B_periph(AT91_PIN_PA5, 1); +			at91_set_B_periph(AT91_PIN_PA6, 1); +		} + +		mmc_data = *data; +		platform_device_register(&at91sam9261_mmc_device); +	}  }  #else -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} +void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}  #endif @@ -228,19 +238,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)  	if (!data)  		return; -	csa = at91_sys_read(AT91_MATRIX_EBICSA); -	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); +	csa = at91_matrix_read(AT91_MATRIX_EBICSA); +	at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);  	/* enable pin */ -	if (data->enable_pin) +	if (gpio_is_valid(data->enable_pin))  		at91_set_gpio_output(data->enable_pin, 1);  	/* ready/busy pin */ -	if (data->rdy_pin) +	if (gpio_is_valid(data->rdy_pin))  		at91_set_gpio_input(data->rdy_pin, 1);  	/* card detect pin */ -	if (data->det_pin) +	if (gpio_is_valid(data->det_pin))  		at91_set_gpio_input(data->det_pin, 1);  	at91_set_A_periph(AT91_PIN_PC0, 0);		/* NANDOE */ @@ -276,7 +286,7 @@ static struct i2c_gpio_platform_data pdata = {  static struct platform_device at91sam9261_twi_device = {  	.name			= "i2c-gpio", -	.id			= -1, +	.id			= 0,  	.dev.platform_data	= &pdata,  }; @@ -301,27 +311,33 @@ static struct resource twi_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_TWI, -		.end	= AT91SAM9261_ID_TWI, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_TWI, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_TWI,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9261_twi_device = { -	.name		= "at91_i2c", -	.id		= -1, +	.id		= 0,  	.resource	= twi_resources,  	.num_resources	= ARRAY_SIZE(twi_resources),  };  void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)  { +	/* IP version is not the same on 9261 and g10 */ +	if (cpu_is_at91sam9g10()) { +		at91sam9261_twi_device.name = "i2c-at91sam9g10"; +		/* I2C PIO must not be configured as open-drain on this chip */ +	} else { +		at91sam9261_twi_device.name = "i2c-at91sam9261"; +		at91_set_multi_drive(AT91_PIN_PA7, 1); +		at91_set_multi_drive(AT91_PIN_PA8, 1); +	} +  	/* pins used for TWI interface */  	at91_set_A_periph(AT91_PIN_PA7, 0);		/* TWD */ -	at91_set_multi_drive(AT91_PIN_PA7, 1); -  	at91_set_A_periph(AT91_PIN_PA8, 0);		/* TWCK */ -	at91_set_multi_drive(AT91_PIN_PA8, 1);  	i2c_register_board_info(0, devices, nr_devices);  	platform_device_register(&at91sam9261_twi_device); @@ -345,8 +361,8 @@ static struct resource spi0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_SPI0, -		.end	= AT91SAM9261_ID_SPI0, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_SPI0, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_SPI0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -371,8 +387,8 @@ static struct resource spi1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_SPI1, -		.end	= AT91SAM9261_ID_SPI1, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_SPI1, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_SPI1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -406,6 +422,9 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		else  			cs_pin = spi1_standard_cs[devices[i].chip_select]; +		if (!gpio_is_valid(cs_pin)) +			continue; +  		if (devices[i].bus_num == 0)  			enable_spi0 = 1;  		else @@ -426,7 +445,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		at91_set_A_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */  		at91_set_A_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */ -		at91_clock_associate("spi0_clk", &at91sam9261_spi0_device.dev, "spi_clk");  		platform_device_register(&at91sam9261_spi0_device);  	}  	if (enable_spi1) { @@ -434,7 +452,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		at91_set_A_periph(AT91_PIN_PB31, 0);	/* SPI1_MOSI */  		at91_set_A_periph(AT91_PIN_PB29, 0);	/* SPI1_SPCK */ -		at91_clock_associate("spi1_clk", &at91sam9261_spi1_device.dev, "spi_clk");  		platform_device_register(&at91sam9261_spi1_device);  	}  } @@ -449,7 +466,7 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)  static u64 lcdc_dmamask = DMA_BIT_MASK(32); -static struct atmel_lcdfb_info lcdc_data; +static struct atmel_lcdfb_pdata lcdc_data;  static struct resource lcdc_resources[] = {  	[0] = { @@ -458,8 +475,8 @@ static struct resource lcdc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_LCDC, -		.end	= AT91SAM9261_ID_LCDC, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_LCDC, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_LCDC,  		.flags	= IORESOURCE_IRQ,  	},  #if defined(CONFIG_FB_INTSRAM) @@ -472,7 +489,6 @@ static struct resource lcdc_resources[] = {  };  static struct platform_device at91_lcdc_device = { -	.name		= "atmel_lcdfb",  	.id		= 0,  	.dev		= {  				.dma_mask		= &lcdc_dmamask, @@ -483,12 +499,17 @@ static struct platform_device at91_lcdc_device = {  	.num_resources	= ARRAY_SIZE(lcdc_resources),  }; -void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) +void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data)  {  	if (!data) {  		return;  	} +	if (cpu_is_at91sam9g10()) +		at91_lcdc_device.name = "at91sam9g10-lcdfb"; +	else +		at91_lcdc_device.name = "at91sam9261-lcdfb"; +  #if defined(CONFIG_FB_ATMEL_STN)  	at91_set_A_periph(AT91_PIN_PB0, 0);     /* LCDVSYNC */  	at91_set_A_periph(AT91_PIN_PB1, 0);     /* LCDHSYNC */ @@ -527,7 +548,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)  	if (ARRAY_SIZE(lcdc_resources) > 2) {  		void __iomem *fb;  		struct resource *fb_res = &lcdc_resources[2]; -		size_t fb_len = fb_res->end - fb_res->start + 1; +		size_t fb_len = resource_size(fb_res);  		fb = ioremap(fb_res->start, fb_len);  		if (fb) { @@ -539,7 +560,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)  	platform_device_register(&at91_lcdc_device);  }  #else -void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} +void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data) {}  #endif @@ -556,18 +577,18 @@ static struct resource tcb_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_TC0, -		.end	= AT91SAM9261_ID_TC0, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_TC0, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_TC0,  		.flags	= IORESOURCE_IRQ,  	},  	[2] = { -		.start	= AT91SAM9261_ID_TC1, -		.end	= AT91SAM9261_ID_TC1, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_TC1, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_TC1,  		.flags	= IORESOURCE_IRQ,  	},  	[3] = { -		.start	= AT91SAM9261_ID_TC2, -		.end	= AT91SAM9261_ID_TC2, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_TC2, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_TC2,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -581,10 +602,6 @@ static struct platform_device at91sam9261_tcb_device = {  static void __init at91_add_device_tc(void)  { -	/* this chip has a separate clock and irq for each TC channel */ -	at91_clock_associate("tc0_clk", &at91sam9261_tcb_device.dev, "t0_clk"); -	at91_clock_associate("tc1_clk", &at91sam9261_tcb_device.dev, "t1_clk"); -	at91_clock_associate("tc2_clk", &at91sam9261_tcb_device.dev, "t2_clk");  	platform_device_register(&at91sam9261_tcb_device);  }  #else @@ -598,9 +615,13 @@ static void __init at91_add_device_tc(void) { }  static struct resource rtt_resources[] = {  	{ -		.start	= AT91_BASE_SYS + AT91_RTT, -		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1, +		.start	= AT91SAM9261_BASE_RTT, +		.end	= AT91SAM9261_BASE_RTT + SZ_16 - 1, +		.flags	= IORESOURCE_MEM, +	}, {  		.flags	= IORESOURCE_MEM, +	}, { +		.flags  = IORESOURCE_IRQ,  	}  }; @@ -608,11 +629,34 @@ static struct platform_device at91sam9261_rtt_device = {  	.name		= "at91_rtt",  	.id		= 0,  	.resource	= rtt_resources, -	.num_resources	= ARRAY_SIZE(rtt_resources),  }; +#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9) +static void __init at91_add_device_rtt_rtc(void) +{ +	at91sam9261_rtt_device.name = "rtc-at91sam9"; +	/* +	 * The second resource is needed: +	 * GPBR will serve as the storage for RTC time offset +	 */ +	at91sam9261_rtt_device.num_resources = 3; +	rtt_resources[1].start = AT91SAM9261_BASE_GPBR + +				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; +	rtt_resources[1].end = rtt_resources[1].start + 3; +	rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS; +	rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS; +} +#else +static void __init at91_add_device_rtt_rtc(void) +{ +	/* Only one resource is needed: RTT not used as RTC */ +	at91sam9261_rtt_device.num_resources = 1; +} +#endif +  static void __init at91_add_device_rtt(void)  { +	at91_add_device_rtt_rtc();  	platform_device_register(&at91sam9261_rtt_device);  } @@ -622,10 +666,19 @@ static void __init at91_add_device_rtt(void)   * -------------------------------------------------------------------- */  #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) +static struct resource wdt_resources[] = { +	{ +		.start	= AT91SAM9261_BASE_WDT, +		.end	= AT91SAM9261_BASE_WDT + SZ_16 - 1, +		.flags	= IORESOURCE_MEM, +	} +}; +  static struct platform_device at91sam9261_wdt_device = {  	.name		= "at91_wdt",  	.id		= -1, -	.num_resources	= 0, +	.resource	= wdt_resources, +	.num_resources	= ARRAY_SIZE(wdt_resources),  };  static void __init at91_add_device_watchdog(void) @@ -651,14 +704,14 @@ static struct resource ssc0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_SSC0, -		.end	= AT91SAM9261_ID_SSC0, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_SSC0, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_SSC0,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9261_ssc0_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 0,  	.dev	= {  		.dma_mask		= &ssc0_dmamask, @@ -693,14 +746,14 @@ static struct resource ssc1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_SSC1, -		.end	= AT91SAM9261_ID_SSC1, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_SSC1, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_SSC1,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9261_ssc1_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 1,  	.dev	= {  		.dma_mask		= &ssc1_dmamask, @@ -735,14 +788,14 @@ static struct resource ssc2_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_SSC2, -		.end	= AT91SAM9261_ID_SSC2, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_SSC2, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_SSC2,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9261_ssc2_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 2,  	.dev	= {  		.dma_mask		= &ssc2_dmamask, @@ -786,17 +839,14 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)  	case AT91SAM9261_ID_SSC0:  		pdev = &at91sam9261_ssc0_device;  		configure_ssc0_pins(pins); -		at91_clock_associate("ssc0_clk", &pdev->dev, "pclk");  		break;  	case AT91SAM9261_ID_SSC1:  		pdev = &at91sam9261_ssc1_device;  		configure_ssc1_pins(pins); -		at91_clock_associate("ssc1_clk", &pdev->dev, "pclk");  		break;  	case AT91SAM9261_ID_SSC2:  		pdev = &at91sam9261_ssc2_device;  		configure_ssc2_pins(pins); -		at91_clock_associate("ssc2_clk", &pdev->dev, "pclk");  		break;  	default:  		return; @@ -817,13 +867,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}  #if defined(CONFIG_SERIAL_ATMEL)  static struct resource dbgu_resources[] = {  	[0] = { -		.start	= AT91_VA_BASE_SYS + AT91_DBGU, -		.end	= AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, +		.start	= AT91SAM9261_BASE_DBGU, +		.end	= AT91SAM9261_BASE_DBGU + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91_ID_SYS, -		.end	= AT91_ID_SYS, +		.start	= NR_IRQS_LEGACY + AT91_ID_SYS, +		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -831,7 +881,6 @@ static struct resource dbgu_resources[] = {  static struct atmel_uart_data dbgu_data = {  	.use_dma_tx	= 0,  	.use_dma_rx	= 0,		/* DBGU not capable of receive DMA */ -	.regs		= (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),  };  static u64 dbgu_dmamask = DMA_BIT_MASK(32); @@ -861,8 +910,8 @@ static struct resource uart0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_US0, -		.end	= AT91SAM9261_ID_US0, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_US0, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_US0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -904,8 +953,8 @@ static struct resource uart1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_US1, -		.end	= AT91SAM9261_ID_US1, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_US1, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_US1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -947,8 +996,8 @@ static struct resource uart2_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9261_ID_US2, -		.end	= AT91SAM9261_ID_US2, +		.start	= NR_IRQS_LEGACY + AT91SAM9261_ID_US2, +		.end	= NR_IRQS_LEGACY + AT91SAM9261_ID_US2,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -984,48 +1033,39 @@ static inline void configure_usart2_pins(unsigned pins)  }  static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */ -struct platform_device *atmel_default_console_device;	/* the serial console device */  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)  {  	struct platform_device *pdev; +	struct atmel_uart_data *pdata;  	switch (id) {  		case 0:		/* DBGU */  			pdev = &at91sam9261_dbgu_device;  			configure_dbgu_pins(); -			at91_clock_associate("mck", &pdev->dev, "usart");  			break;  		case AT91SAM9261_ID_US0:  			pdev = &at91sam9261_uart0_device;  			configure_usart0_pins(pins); -			at91_clock_associate("usart0_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9261_ID_US1:  			pdev = &at91sam9261_uart1_device;  			configure_usart1_pins(pins); -			at91_clock_associate("usart1_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9261_ID_US2:  			pdev = &at91sam9261_uart2_device;  			configure_usart2_pins(pins); -			at91_clock_associate("usart2_clk", &pdev->dev, "usart");  			break;  		default:  			return;  	} -	pdev->id = portnr;		/* update to mapped ID */ +	pdata = pdev->dev.platform_data; +	pdata->num = portnr;		/* update to mapped ID */  	if (portnr < ATMEL_MAX_UART)  		at91_uarts[portnr] = pdev;  } -void __init at91_set_serial_console(unsigned portnr) -{ -	if (portnr < ATMEL_MAX_UART) -		atmel_default_console_device = at91_uarts[portnr]; -} -  void __init at91_add_device_serial(void)  {  	int i; @@ -1034,13 +1074,9 @@ void __init at91_add_device_serial(void)  		if (at91_uarts[i])  			platform_device_register(at91_uarts[i]);  	} - -	if (!atmel_default_console_device) -		printk(KERN_INFO "AT91: No default serial console defined.\n");  }  #else  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {}  void __init at91_add_device_serial(void) {}  #endif diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c index 249f900954d..f3029057229 100644 --- a/arch/arm/mach-at91/at91sam9263.c +++ b/arch/arm/mach-at91/at91sam9263.c @@ -11,37 +11,23 @@   */  #include <linux/module.h> -#include <linux/pm.h> +#include <linux/clk/at91_pmc.h> +#include <asm/proc-fns.h>  #include <asm/irq.h>  #include <asm/mach/arch.h>  #include <asm/mach/map.h> +#include <asm/system_misc.h>  #include <mach/at91sam9263.h> -#include <mach/at91_pmc.h> -#include <mach/at91_rstc.h> -#include <mach/at91_shdwc.h> +#include <mach/hardware.h> +#include "at91_aic.h" +#include "at91_rstc.h" +#include "soc.h"  #include "generic.h"  #include "clock.h" - -static struct map_desc at91sam9263_io_desc[] __initdata = { -	{ -		.virtual	= AT91_VA_BASE_SYS, -		.pfn		= __phys_to_pfn(AT91_BASE_SYS), -		.length		= SZ_16K, -		.type		= MT_DEVICE, -	}, { -		.virtual	= AT91_IO_VIRT_BASE - AT91SAM9263_SRAM0_SIZE, -		.pfn		= __phys_to_pfn(AT91SAM9263_SRAM0_BASE), -		.length		= AT91SAM9263_SRAM0_SIZE, -		.type		= MT_DEVICE, -	}, { -		.virtual	= AT91_IO_VIRT_BASE - AT91SAM9263_SRAM0_SIZE - AT91SAM9263_SRAM1_SIZE, -		.pfn		= __phys_to_pfn(AT91SAM9263_SRAM1_BASE), -		.length		= AT91SAM9263_SRAM1_SIZE, -		.type		= MT_DEVICE, -	}, -}; +#include "sam9_smc.h" +#include "pm.h"  /* --------------------------------------------------------------------   *  Clocks @@ -136,7 +122,7 @@ static struct clk pwm_clk = {  	.type		= CLK_TYPE_PERIPHERAL,  };  static struct clk macb_clk = { -	.name		= "macb_clk", +	.name		= "pclk",  	.pmc_mask	= 1 << AT91SAM9263_ID_EMAC,  	.type		= CLK_TYPE_PERIPHERAL,  }; @@ -199,6 +185,55 @@ static struct clk *periph_clocks[] __initdata = {  	// irq0 .. irq1  }; +static struct clk_lookup periph_clocks_lookups[] = { +	/* One additional fake clock for macb_hclk */ +	CLKDEV_CON_ID("hclk", &macb_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk), +	CLKDEV_CON_DEV_ID("pclk", "fff98000.ssc", &ssc0_clk), +	CLKDEV_CON_DEV_ID("pclk", "fff9c000.ssc", &ssc1_clk), +	CLKDEV_CON_DEV_ID("hclk", "at91sam9263-lcdfb.0", &lcdc_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.0", &mmc0_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.1", &mmc1_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk), +	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260.0", &twi_clk), +	/* fake hclk clock */ +	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk), +	CLKDEV_CON_ID("pioA", &pioA_clk), +	CLKDEV_CON_ID("pioB", &pioB_clk), +	CLKDEV_CON_ID("pioC", &pioCDE_clk), +	CLKDEV_CON_ID("pioD", &pioCDE_clk), +	CLKDEV_CON_ID("pioE", &pioCDE_clk), +	/* more usart lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck), +	CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "fff90000.serial", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "fff94000.serial", &usart2_clk), +	/* more tc lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("t0_clk", "fff7c000.timer", &tcb_clk), +	CLKDEV_CON_DEV_ID("hclk", "a00000.ohci", &ohci_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "fff84000.mmc", &mmc1_clk), +	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff200.gpio", &pioA_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioB_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioCDE_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioCDE_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioCDE_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffb8000.pwm", &pwm_clk), +}; + +static struct clk_lookup usart_clocks_lookups[] = { +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), +}; +  /*   * The four programmable clocks.   * You must configure pin multiplexing to bring these signals out. @@ -235,6 +270,11 @@ static void __init at91sam9263_register_clocks(void)  	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)  		clk_register(periph_clocks[i]); +	clkdev_add_table(periph_clocks_lookups, +			 ARRAY_SIZE(periph_clocks_lookups)); +	clkdev_add_table(usart_clocks_lookups, +			 ARRAY_SIZE(usart_clocks_lookups)); +  	clk_register(&pck0);  	clk_register(&pck1);  	clk_register(&pck2); @@ -245,54 +285,55 @@ static void __init at91sam9263_register_clocks(void)   *  GPIO   * -------------------------------------------------------------------- */ -static struct at91_gpio_bank at91sam9263_gpio[] = { +static struct at91_gpio_bank at91sam9263_gpio[] __initdata = {  	{  		.id		= AT91SAM9263_ID_PIOA, -		.offset		= AT91_PIOA, -		.clock		= &pioA_clk, +		.regbase	= AT91SAM9263_BASE_PIOA,  	}, {  		.id		= AT91SAM9263_ID_PIOB, -		.offset		= AT91_PIOB, -		.clock		= &pioB_clk, +		.regbase	= AT91SAM9263_BASE_PIOB,  	}, {  		.id		= AT91SAM9263_ID_PIOCDE, -		.offset		= AT91_PIOC, -		.clock		= &pioCDE_clk, +		.regbase	= AT91SAM9263_BASE_PIOC,  	}, {  		.id		= AT91SAM9263_ID_PIOCDE, -		.offset		= AT91_PIOD, -		.clock		= &pioCDE_clk, +		.regbase	= AT91SAM9263_BASE_PIOD,  	}, {  		.id		= AT91SAM9263_ID_PIOCDE, -		.offset		= AT91_PIOE, -		.clock		= &pioCDE_clk, +		.regbase	= AT91SAM9263_BASE_PIOE,  	}  }; -static void at91sam9263_poweroff(void) -{ -	at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); -} - -  /* --------------------------------------------------------------------   *  AT91SAM9263 processor initialization   * -------------------------------------------------------------------- */ -void __init at91sam9263_initialize(unsigned long main_clock) +static void __init at91sam9263_map_io(void)  { -	/* Map peripherals */ -	iotable_init(at91sam9263_io_desc, ARRAY_SIZE(at91sam9263_io_desc)); +	at91_init_sram(0, AT91SAM9263_SRAM0_BASE, AT91SAM9263_SRAM0_SIZE); +	at91_init_sram(1, AT91SAM9263_SRAM1_BASE, AT91SAM9263_SRAM1_SIZE); +} -	at91_arch_reset = at91sam9_alt_reset; -	pm_power_off = at91sam9263_poweroff; -	at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1); +static void __init at91sam9263_ioremap_registers(void) +{ +	at91_ioremap_shdwc(AT91SAM9263_BASE_SHDWC); +	at91_ioremap_rstc(AT91SAM9263_BASE_RSTC); +	at91_ioremap_ramc(0, AT91SAM9263_BASE_SDRAMC0, 512); +	at91_ioremap_ramc(1, AT91SAM9263_BASE_SDRAMC1, 512); +	at91sam926x_ioremap_pit(AT91SAM9263_BASE_PIT); +	at91sam9_ioremap_smc(0, AT91SAM9263_BASE_SMC0); +	at91sam9_ioremap_smc(1, AT91SAM9263_BASE_SMC1); +	at91_ioremap_matrix(AT91SAM9263_BASE_MATRIX); +	at91_pm_set_standby(at91sam9_sdram_standby); +} -	/* Init clock subsystem */ -	at91_clock_init(main_clock); +static void __init at91sam9263_initialize(void) +{ +	arm_pm_idle = at91sam9_idle; +	arm_pm_restart = at91sam9_alt_restart; -	/* Register the processor-specific clocks */ -	at91sam9263_register_clocks(); +	at91_sysirq_mask_rtt(AT91SAM9263_BASE_RTT0); +	at91_sysirq_mask_rtt(AT91SAM9263_BASE_RTT1);  	/* Register GPIO subsystem */  	at91_gpio_init(at91sam9263_gpio, 5); @@ -340,14 +381,11 @@ static unsigned int at91sam9263_default_irq_priority[NR_AIC_IRQS] __initdata = {  	0,	/* Advanced Interrupt Controller (IRQ1) */  }; -void __init at91sam9263_init_interrupts(unsigned int priority[NR_AIC_IRQS]) -{ -	if (!priority) -		priority = at91sam9263_default_irq_priority; - -	/* Initialize the AIC interrupt controller */ -	at91_aic_init(priority); - -	/* Enable GPIO interrupts */ -	at91_gpio_irq_setup(); -} +AT91_SOC_START(at91sam9263) +	.map_io = at91sam9263_map_io, +	.default_irq_priority = at91sam9263_default_irq_priority, +	.extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1), +	.ioremap_registers = at91sam9263_ioremap_registers, +	.register_clocks = at91sam9263_register_clocks, +	.init = at91sam9263_initialize, +AT91_SOC_END diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c index fb5c23af101..309390d8e2f 100644 --- a/arch/arm/mach-at91/at91sam9263_devices.c +++ b/arch/arm/mach-at91/at91sam9263_devices.c @@ -13,19 +13,22 @@  #include <asm/mach/map.h>  #include <linux/dma-mapping.h> +#include <linux/gpio.h>  #include <linux/platform_device.h>  #include <linux/i2c-gpio.h>  #include <linux/fb.h>  #include <video/atmel_lcdc.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9263.h>  #include <mach/at91sam9263_matrix.h> +#include <mach/at91_matrix.h>  #include <mach/at91sam9_smc.h> +#include <mach/hardware.h> +#include "board.h"  #include "generic.h" +#include "gpio.h"  /* -------------------------------------------------------------------- @@ -43,8 +46,8 @@ static struct resource usbh_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_UHP, -		.end	= AT91SAM9263_ID_UHP, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_UHP, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_UHP,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -70,8 +73,15 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)  	/* Enable VBus control for UHP ports */  	for (i = 0; i < data->ports; i++) { -		if (data->vbus_pin[i]) -			at91_set_gpio_output(data->vbus_pin[i], 0); +		if (gpio_is_valid(data->vbus_pin[i])) +			at91_set_gpio_output(data->vbus_pin[i], +					     data->vbus_pin_active_low[i]); +	} + +	/* Enable overcurrent notification */ +	for (i = 0; i < data->ports; i++) { +		if (gpio_is_valid(data->overcurrent_pin[i])) +			at91_set_gpio_input(data->overcurrent_pin[i], 1);  	}  	usbh_data = *data; @@ -86,7 +96,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}   *  USB Device (Gadget)   * -------------------------------------------------------------------- */ -#ifdef CONFIG_USB_GADGET_AT91 +#if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)  static struct at91_udc_data udc_data;  static struct resource udc_resources[] = { @@ -96,8 +106,8 @@ static struct resource udc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_UDP, -		.end	= AT91SAM9263_ID_UDP, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_UDP, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_UDP,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -117,7 +127,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data)  	if (!data)  		return; -	if (data->vbus_pin) { +	if (gpio_is_valid(data->vbus_pin)) {  		at91_set_gpio_input(data->vbus_pin, 0);  		at91_set_deglitch(data->vbus_pin, 1);  	} @@ -138,7 +148,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}  #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)  static u64 eth_dmamask = DMA_BIT_MASK(32); -static struct at91_eth_data eth_data; +static struct macb_platform_data eth_data;  static struct resource eth_resources[] = {  	[0] = { @@ -147,8 +157,8 @@ static struct resource eth_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_EMAC, -		.end	= AT91SAM9263_ID_EMAC, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_EMAC, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_EMAC,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -165,12 +175,12 @@ static struct platform_device at91sam9263_eth_device = {  	.num_resources	= ARRAY_SIZE(eth_resources),  }; -void __init at91_add_device_eth(struct at91_eth_data *data) +void __init at91_add_device_eth(struct macb_platform_data *data)  {  	if (!data)  		return; -	if (data->phy_irq_pin) { +	if (gpio_is_valid(data->phy_irq_pin)) {  		at91_set_gpio_input(data->phy_irq_pin, 0);  		at91_set_deglitch(data->phy_irq_pin, 1);  	} @@ -202,7 +212,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data)  	platform_device_register(&at91sam9263_eth_device);  }  #else -void __init at91_add_device_eth(struct at91_eth_data *data) {} +void __init at91_add_device_eth(struct macb_platform_data *data) {}  #endif @@ -210,9 +220,9 @@ void __init at91_add_device_eth(struct at91_eth_data *data) {}   *  MMC / SD   * -------------------------------------------------------------------- */ -#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) +#if IS_ENABLED(CONFIG_MMC_ATMELMCI)  static u64 mmc_dmamask = DMA_BIT_MASK(32); -static struct at91_mmc_data mmc0_data, mmc1_data; +static struct mci_platform_data mmc0_data, mmc1_data;  static struct resource mmc0_resources[] = {  	[0] = { @@ -221,14 +231,14 @@ static struct resource mmc0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_MCI0, -		.end	= AT91SAM9263_ID_MCI0, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_MCI0, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_MCI0,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9263_mmc0_device = { -	.name		= "at91_mci", +	.name		= "atmel_mci",  	.id		= 0,  	.dev		= {  				.dma_mask		= &mmc_dmamask, @@ -246,14 +256,14 @@ static struct resource mmc1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_MCI1, -		.end	= AT91SAM9263_ID_MCI1, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_MCI1, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_MCI1,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9263_mmc1_device = { -	.name		= "at91_mci", +	.name		= "atmel_mci",  	.id		= 1,  	.dev		= {  				.dma_mask		= &mmc_dmamask, @@ -264,95 +274,118 @@ static struct platform_device at91sam9263_mmc1_device = {  	.num_resources	= ARRAY_SIZE(mmc1_resources),  }; -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) +void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)  { +	unsigned int i; +	unsigned int slot_count = 0; +  	if (!data)  		return; -	/* input/irq */ -	if (data->det_pin) { -		at91_set_gpio_input(data->det_pin, 1); -		at91_set_deglitch(data->det_pin, 1); -	} -	if (data->wp_pin) -		at91_set_gpio_input(data->wp_pin, 1); -	if (data->vcc_pin) -		at91_set_gpio_output(data->vcc_pin, 0); +	for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) { -	if (mmc_id == 0) {		/* MCI0 */ -		/* CLK */ -		at91_set_A_periph(AT91_PIN_PA12, 0); +		if (!data->slot[i].bus_width) +			continue; -		if (data->slot_b) { -			/* CMD */ -			at91_set_A_periph(AT91_PIN_PA16, 1); +		/* input/irq */ +		if (gpio_is_valid(data->slot[i].detect_pin)) { +			at91_set_gpio_input(data->slot[i].detect_pin, +					1); +			at91_set_deglitch(data->slot[i].detect_pin, +					1); +		} +		if (gpio_is_valid(data->slot[i].wp_pin)) +			at91_set_gpio_input(data->slot[i].wp_pin, 1); + +		if (mmc_id == 0) {				/* MCI0 */ +			switch (i) { +			case 0:					/* slot A */ +				/* CMD */ +				at91_set_A_periph(AT91_PIN_PA1, 1); +				/* DAT0, maybe DAT1..DAT3 */ +				at91_set_A_periph(AT91_PIN_PA0, 1); +				if (data->slot[i].bus_width == 4) { +					at91_set_A_periph(AT91_PIN_PA3, 1); +					at91_set_A_periph(AT91_PIN_PA4, 1); +					at91_set_A_periph(AT91_PIN_PA5, 1); +				} +				slot_count++; +				break; +			case 1:					/* slot B */ +				/* CMD */ +				at91_set_A_periph(AT91_PIN_PA16, 1); +				/* DAT0, maybe DAT1..DAT3 */ +				at91_set_A_periph(AT91_PIN_PA17, 1); +				if (data->slot[i].bus_width == 4) { +					at91_set_A_periph(AT91_PIN_PA18, 1); +					at91_set_A_periph(AT91_PIN_PA19, 1); +					at91_set_A_periph(AT91_PIN_PA20, 1); +				} +				slot_count++; +				break; +			default: +				printk(KERN_ERR +				       "AT91: SD/MMC slot %d not available\n", i); +				break; +			} +			if (slot_count) { +				/* CLK */ +				at91_set_A_periph(AT91_PIN_PA12, 0); -			/* DAT0, maybe DAT1..DAT3 */ -			at91_set_A_periph(AT91_PIN_PA17, 1); -			if (data->wire4) { -				at91_set_A_periph(AT91_PIN_PA18, 1); -				at91_set_A_periph(AT91_PIN_PA19, 1); -				at91_set_A_periph(AT91_PIN_PA20, 1); +				mmc0_data = *data; +				platform_device_register(&at91sam9263_mmc0_device);  			} -		} else { -			/* CMD */ -			at91_set_A_periph(AT91_PIN_PA1, 1); - -			/* DAT0, maybe DAT1..DAT3 */ -			at91_set_A_periph(AT91_PIN_PA0, 1); -			if (data->wire4) { -				at91_set_A_periph(AT91_PIN_PA3, 1); -				at91_set_A_periph(AT91_PIN_PA4, 1); -				at91_set_A_periph(AT91_PIN_PA5, 1); +		} else if (mmc_id == 1) {			/* MCI1 */ +			switch (i) { +			case 0:					/* slot A */ +				/* CMD */ +				at91_set_A_periph(AT91_PIN_PA7, 1); +				/* DAT0, maybe DAT1..DAT3 */ +				at91_set_A_periph(AT91_PIN_PA8, 1); +				if (data->slot[i].bus_width == 4) { +					at91_set_A_periph(AT91_PIN_PA9, 1); +					at91_set_A_periph(AT91_PIN_PA10, 1); +					at91_set_A_periph(AT91_PIN_PA11, 1); +				} +				slot_count++; +				break; +			case 1:					/* slot B */ +				/* CMD */ +				at91_set_A_periph(AT91_PIN_PA21, 1); +				/* DAT0, maybe DAT1..DAT3 */ +				at91_set_A_periph(AT91_PIN_PA22, 1); +				if (data->slot[i].bus_width == 4) { +					at91_set_A_periph(AT91_PIN_PA23, 1); +					at91_set_A_periph(AT91_PIN_PA24, 1); +					at91_set_A_periph(AT91_PIN_PA25, 1); +				} +				slot_count++; +				break; +			default: +				printk(KERN_ERR +				       "AT91: SD/MMC slot %d not available\n", i); +				break;  			} -		} +			if (slot_count) { +				/* CLK */ +				at91_set_A_periph(AT91_PIN_PA6, 0); -		mmc0_data = *data; -		at91_clock_associate("mci0_clk", &at91sam9263_mmc0_device.dev, "mci_clk"); -		platform_device_register(&at91sam9263_mmc0_device); -	} else {			/* MCI1 */ -		/* CLK */ -		at91_set_A_periph(AT91_PIN_PA6, 0); - -		if (data->slot_b) { -			/* CMD */ -			at91_set_A_periph(AT91_PIN_PA21, 1); - -			/* DAT0, maybe DAT1..DAT3 */ -			at91_set_A_periph(AT91_PIN_PA22, 1); -			if (data->wire4) { -				at91_set_A_periph(AT91_PIN_PA23, 1); -				at91_set_A_periph(AT91_PIN_PA24, 1); -				at91_set_A_periph(AT91_PIN_PA25, 1); -			} -		} else { -			/* CMD */ -			at91_set_A_periph(AT91_PIN_PA7, 1); - -			/* DAT0, maybe DAT1..DAT3 */ -			at91_set_A_periph(AT91_PIN_PA8, 1); -			if (data->wire4) { -				at91_set_A_periph(AT91_PIN_PA9, 1); -				at91_set_A_periph(AT91_PIN_PA10, 1); -				at91_set_A_periph(AT91_PIN_PA11, 1); +				mmc1_data = *data; +				platform_device_register(&at91sam9263_mmc1_device);  			}  		} - -		mmc1_data = *data; -		at91_clock_associate("mci1_clk", &at91sam9263_mmc1_device.dev, "mci_clk"); -		platform_device_register(&at91sam9263_mmc1_device);  	}  }  #else -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} +void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}  #endif  /* --------------------------------------------------------------------   *  Compact Flash (PCMCIA or IDE)   * -------------------------------------------------------------------- */ -#if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) || \ -    defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE) +#if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \ +	defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)  static struct at91_cf_data cf0_data; @@ -405,7 +438,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)  	 * we assume SMC timings are configured by board code,  	 * except True IDE where timings are controlled by driver  	 */ -	ebi0_csa = at91_sys_read(AT91_MATRIX_EBI0CSA); +	ebi0_csa = at91_matrix_read(AT91_MATRIX_EBI0CSA);  	switch (data->chipselect) {  	case 4:  		at91_set_A_periph(AT91_PIN_PD6, 0);  /* EBI0_NCS4/CFCS0 */ @@ -424,19 +457,19 @@ void __init at91_add_device_cf(struct at91_cf_data *data)  		       data->chipselect);  		return;  	} -	at91_sys_write(AT91_MATRIX_EBI0CSA, ebi0_csa); +	at91_matrix_write(AT91_MATRIX_EBI0CSA, ebi0_csa); -	if (data->det_pin) { +	if (gpio_is_valid(data->det_pin)) {  		at91_set_gpio_input(data->det_pin, 1);  		at91_set_deglitch(data->det_pin, 1);  	} -	if (data->irq_pin) { +	if (gpio_is_valid(data->irq_pin)) {  		at91_set_gpio_input(data->irq_pin, 1);  		at91_set_deglitch(data->irq_pin, 1);  	} -	if (data->vcc_pin) +	if (gpio_is_valid(data->vcc_pin))  		/* initially off */  		at91_set_gpio_output(data->vcc_pin, 0); @@ -446,7 +479,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)  	at91_set_A_periph(AT91_PIN_PD9, 0);  /* CFCE2 */  	at91_set_A_periph(AT91_PIN_PD14, 0); /* CFNRW */ -	pdev->name = (data->flags & AT91_CF_TRUE_IDE) ? "at91_ide" : "at91_cf"; +	pdev->name = (data->flags & AT91_CF_TRUE_IDE) ? "pata_at91" : "at91_cf";  	platform_device_register(pdev);  }  #else @@ -469,8 +502,8 @@ static struct resource nand_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91_BASE_SYS + AT91_ECC0, -		.end	= AT91_BASE_SYS + AT91_ECC0 + SZ_512 - 1, +		.start	= AT91SAM9263_BASE_ECC0, +		.end	= AT91SAM9263_BASE_ECC0 + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	}  }; @@ -492,19 +525,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)  	if (!data)  		return; -	csa = at91_sys_read(AT91_MATRIX_EBI0CSA); -	at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA); +	csa = at91_matrix_read(AT91_MATRIX_EBI0CSA); +	at91_matrix_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA);  	/* enable pin */ -	if (data->enable_pin) +	if (gpio_is_valid(data->enable_pin))  		at91_set_gpio_output(data->enable_pin, 1);  	/* ready/busy pin */ -	if (data->rdy_pin) +	if (gpio_is_valid(data->rdy_pin))  		at91_set_gpio_input(data->rdy_pin, 1);  	/* card detect pin */ -	if (data->det_pin) +	if (gpio_is_valid(data->det_pin))  		at91_set_gpio_input(data->det_pin, 1);  	nand_data = *data; @@ -536,7 +569,7 @@ static struct i2c_gpio_platform_data pdata = {  static struct platform_device at91sam9263_twi_device = {  	.name			= "i2c-gpio", -	.id			= -1, +	.id			= 0,  	.dev.platform_data	= &pdata,  }; @@ -561,15 +594,15 @@ static struct resource twi_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_TWI, -		.end	= AT91SAM9263_ID_TWI, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_TWI, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_TWI,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9263_twi_device = { -	.name		= "at91_i2c", -	.id		= -1, +	.name		= "i2c-at91sam9260", +	.id		= 0,  	.resource	= twi_resources,  	.num_resources	= ARRAY_SIZE(twi_resources),  }; @@ -605,8 +638,8 @@ static struct resource spi0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_SPI0, -		.end	= AT91SAM9263_ID_SPI0, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_SPI0, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_SPI0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -631,8 +664,8 @@ static struct resource spi1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_SPI1, -		.end	= AT91SAM9263_ID_SPI1, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_SPI1, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_SPI1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -666,6 +699,9 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		else  			cs_pin = spi1_standard_cs[devices[i].chip_select]; +		if (!gpio_is_valid(cs_pin)) +			continue; +  		if (devices[i].bus_num == 0)  			enable_spi0 = 1;  		else @@ -686,7 +722,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		at91_set_B_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */  		at91_set_B_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */ -		at91_clock_associate("spi0_clk", &at91sam9263_spi0_device.dev, "spi_clk");  		platform_device_register(&at91sam9263_spi0_device);  	}  	if (enable_spi1) { @@ -694,7 +729,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		at91_set_A_periph(AT91_PIN_PB13, 0);	/* SPI1_MOSI */  		at91_set_A_periph(AT91_PIN_PB14, 0);	/* SPI1_SPCK */ -		at91_clock_associate("spi1_clk", &at91sam9263_spi1_device.dev, "spi_clk");  		platform_device_register(&at91sam9263_spi1_device);  	}  } @@ -718,8 +752,8 @@ static struct resource ac97_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_AC97C, -		.end	= AT91SAM9263_ID_AC97C, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_AC97C, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_AC97C,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -747,7 +781,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data)  	at91_set_A_periph(AT91_PIN_PB3, 0);	/* AC97RX */  	/* reset */ -	if (data->reset_pin) +	if (gpio_is_valid(data->reset_pin))  		at91_set_gpio_output(data->reset_pin, 0);  	ac97_data = *data; @@ -769,8 +803,8 @@ static struct resource can_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_CAN, -		.end	= AT91SAM9263_ID_CAN, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_CAN, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_CAN,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -800,7 +834,7 @@ void __init at91_add_device_can(struct at91_can_data *data) {}  #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)  static u64 lcdc_dmamask = DMA_BIT_MASK(32); -static struct atmel_lcdfb_info lcdc_data; +static struct atmel_lcdfb_pdata lcdc_data;  static struct resource lcdc_resources[] = {  	[0] = { @@ -809,14 +843,14 @@ static struct resource lcdc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_LCDC, -		.end	= AT91SAM9263_ID_LCDC, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_LCDC, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_LCDC,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91_lcdc_device = { -	.name		= "atmel_lcdfb", +	.name		= "at91sam9263-lcdfb",  	.id		= 0,  	.dev		= {  				.dma_mask		= &lcdc_dmamask, @@ -827,7 +861,7 @@ static struct platform_device at91_lcdc_device = {  	.num_resources	= ARRAY_SIZE(lcdc_resources),  }; -void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) +void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data)  {  	if (!data)  		return; @@ -859,7 +893,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)  	platform_device_register(&at91_lcdc_device);  }  #else -void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} +void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data) {}  #endif @@ -876,8 +910,8 @@ struct resource isi_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_ISI, -		.end	= AT91SAM9263_ID_ISI, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_ISI, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_ISI,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -889,7 +923,8 @@ static struct platform_device at91sam9263_isi_device = {  	.num_resources	= ARRAY_SIZE(isi_resources),  }; -void __init at91_add_device_isi(void) +void __init at91_add_device_isi(struct isi_platform_data *data, +		bool use_pck_as_mck)  {  	at91_set_A_periph(AT91_PIN_PE0, 0);	/* ISI_D0 */  	at91_set_A_periph(AT91_PIN_PE1, 0);	/* ISI_D1 */ @@ -902,14 +937,20 @@ void __init at91_add_device_isi(void)  	at91_set_A_periph(AT91_PIN_PE8, 0);	/* ISI_PCK */  	at91_set_A_periph(AT91_PIN_PE9, 0);	/* ISI_HSYNC */  	at91_set_A_periph(AT91_PIN_PE10, 0);	/* ISI_VSYNC */ -	at91_set_B_periph(AT91_PIN_PE11, 0);	/* ISI_MCK (PCK3) */  	at91_set_B_periph(AT91_PIN_PE12, 0);	/* ISI_PD8 */  	at91_set_B_periph(AT91_PIN_PE13, 0);	/* ISI_PD9 */  	at91_set_B_periph(AT91_PIN_PE14, 0);	/* ISI_PD10 */  	at91_set_B_periph(AT91_PIN_PE15, 0);	/* ISI_PD11 */ + +	if (use_pck_as_mck) { +		at91_set_B_periph(AT91_PIN_PE11, 0);	/* ISI_MCK (PCK3) */ + +		/* TODO: register the PCK for ISI_MCK and set its parent */ +	}  }  #else -void __init at91_add_device_isi(void) {} +void __init at91_add_device_isi(struct isi_platform_data *data, +		bool use_pck_as_mck) {}  #endif @@ -926,8 +967,8 @@ static struct resource tcb_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_TCB, -		.end	= AT91SAM9263_ID_TCB, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_TCB, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_TCB,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -939,10 +980,25 @@ static struct platform_device at91sam9263_tcb_device = {  	.num_resources	= ARRAY_SIZE(tcb_resources),  }; +#if defined(CONFIG_OF) +static struct of_device_id tcb_ids[] = { +	{ .compatible = "atmel,at91rm9200-tcb" }, +	{ /*sentinel*/ } +}; +#endif +  static void __init at91_add_device_tc(void)  { -	/* this chip has one clock and irq for all three TC channels */ -	at91_clock_associate("tcb_clk", &at91sam9263_tcb_device.dev, "t0_clk"); +#if defined(CONFIG_OF) +	struct device_node *np; + +	np = of_find_matching_node(NULL, tcb_ids); +	if (np) { +		of_node_put(np); +		return; +	} +#endif +  	platform_device_register(&at91sam9263_tcb_device);  }  #else @@ -956,9 +1012,13 @@ static void __init at91_add_device_tc(void) { }  static struct resource rtt0_resources[] = {  	{ -		.start	= AT91_BASE_SYS + AT91_RTT0, -		.end	= AT91_BASE_SYS + AT91_RTT0 + SZ_16 - 1, +		.start	= AT91SAM9263_BASE_RTT0, +		.end	= AT91SAM9263_BASE_RTT0 + SZ_16 - 1,  		.flags	= IORESOURCE_MEM, +	}, { +		.flags	= IORESOURCE_MEM, +	}, { +		.flags  = IORESOURCE_IRQ,  	}  }; @@ -966,14 +1026,17 @@ static struct platform_device at91sam9263_rtt0_device = {  	.name		= "at91_rtt",  	.id		= 0,  	.resource	= rtt0_resources, -	.num_resources	= ARRAY_SIZE(rtt0_resources),  };  static struct resource rtt1_resources[] = {  	{ -		.start	= AT91_BASE_SYS + AT91_RTT1, -		.end	= AT91_BASE_SYS + AT91_RTT1 + SZ_16 - 1, +		.start	= AT91SAM9263_BASE_RTT1, +		.end	= AT91SAM9263_BASE_RTT1 + SZ_16 - 1, +		.flags	= IORESOURCE_MEM, +	}, {  		.flags	= IORESOURCE_MEM, +	}, { +		.flags  = IORESOURCE_IRQ,  	}  }; @@ -981,11 +1044,55 @@ static struct platform_device at91sam9263_rtt1_device = {  	.name		= "at91_rtt",  	.id		= 1,  	.resource	= rtt1_resources, -	.num_resources	= ARRAY_SIZE(rtt1_resources),  }; +#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9) +static void __init at91_add_device_rtt_rtc(void) +{ +	struct platform_device *pdev; +	struct resource *r; + +	switch (CONFIG_RTC_DRV_AT91SAM9_RTT) { +	case 0: +		/* +		 * The second resource is needed only for the chosen RTT: +		 * GPBR will serve as the storage for RTC time offset +		 */ +		at91sam9263_rtt0_device.num_resources = 3; +		at91sam9263_rtt1_device.num_resources = 1; +		pdev = &at91sam9263_rtt0_device; +		r = rtt0_resources; +		break; +	case 1: +		at91sam9263_rtt0_device.num_resources = 1; +		at91sam9263_rtt1_device.num_resources = 3; +		pdev = &at91sam9263_rtt1_device; +		r = rtt1_resources; +		break; +	default: +		pr_err("at91sam9263: only supports 2 RTT (%d)\n", +		       CONFIG_RTC_DRV_AT91SAM9_RTT); +		return; +	} + +	pdev->name = "rtc-at91sam9"; +	r[1].start = AT91SAM9263_BASE_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; +	r[1].end = r[1].start + 3; +	r[2].start = NR_IRQS_LEGACY + AT91_ID_SYS; +	r[2].end = NR_IRQS_LEGACY + AT91_ID_SYS; +} +#else +static void __init at91_add_device_rtt_rtc(void) +{ +	/* Only one resource is needed: RTT not used as RTC */ +	at91sam9263_rtt0_device.num_resources = 1; +	at91sam9263_rtt1_device.num_resources = 1; +} +#endif +  static void __init at91_add_device_rtt(void)  { +	at91_add_device_rtt_rtc();  	platform_device_register(&at91sam9263_rtt0_device);  	platform_device_register(&at91sam9263_rtt1_device);  } @@ -996,10 +1103,19 @@ static void __init at91_add_device_rtt(void)   * -------------------------------------------------------------------- */  #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) +static struct resource wdt_resources[] = { +	{ +		.start	= AT91SAM9263_BASE_WDT, +		.end	= AT91SAM9263_BASE_WDT + SZ_16 - 1, +		.flags	= IORESOURCE_MEM, +	} +}; +  static struct platform_device at91sam9263_wdt_device = {  	.name		= "at91_wdt",  	.id		= -1, -	.num_resources	= 0, +	.resource	= wdt_resources, +	.num_resources	= ARRAY_SIZE(wdt_resources),  };  static void __init at91_add_device_watchdog(void) @@ -1025,8 +1141,8 @@ static struct resource pwm_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_PWMC, -		.end	= AT91SAM9263_ID_PWMC, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_PWMC, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_PWMC,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1078,14 +1194,14 @@ static struct resource ssc0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_SSC0, -		.end	= AT91SAM9263_ID_SSC0, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_SSC0, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_SSC0,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9263_ssc0_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 0,  	.dev	= {  		.dma_mask		= &ssc0_dmamask, @@ -1120,14 +1236,14 @@ static struct resource ssc1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_SSC1, -		.end	= AT91SAM9263_ID_SSC1, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_SSC1, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_SSC1,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9263_ssc1_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 1,  	.dev	= {  		.dma_mask		= &ssc1_dmamask, @@ -1171,12 +1287,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)  	case AT91SAM9263_ID_SSC0:  		pdev = &at91sam9263_ssc0_device;  		configure_ssc0_pins(pins); -		at91_clock_associate("ssc0_clk", &pdev->dev, "pclk");  		break;  	case AT91SAM9263_ID_SSC1:  		pdev = &at91sam9263_ssc1_device;  		configure_ssc1_pins(pins); -		at91_clock_associate("ssc1_clk", &pdev->dev, "pclk");  		break;  	default:  		return; @@ -1198,13 +1312,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}  static struct resource dbgu_resources[] = {  	[0] = { -		.start	= AT91_VA_BASE_SYS + AT91_DBGU, -		.end	= AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, +		.start	= AT91SAM9263_BASE_DBGU, +		.end	= AT91SAM9263_BASE_DBGU + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91_ID_SYS, -		.end	= AT91_ID_SYS, +		.start	= NR_IRQS_LEGACY + AT91_ID_SYS, +		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1212,7 +1326,6 @@ static struct resource dbgu_resources[] = {  static struct atmel_uart_data dbgu_data = {  	.use_dma_tx	= 0,  	.use_dma_rx	= 0,		/* DBGU not capable of receive DMA */ -	.regs		= (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),  };  static u64 dbgu_dmamask = DMA_BIT_MASK(32); @@ -1242,8 +1355,8 @@ static struct resource uart0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_US0, -		.end	= AT91SAM9263_ID_US0, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_US0, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_US0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1285,8 +1398,8 @@ static struct resource uart1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_US1, -		.end	= AT91SAM9263_ID_US1, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_US1, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_US1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1328,8 +1441,8 @@ static struct resource uart2_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9263_ID_US2, -		.end	= AT91SAM9263_ID_US2, +		.start	= NR_IRQS_LEGACY + AT91SAM9263_ID_US2, +		.end	= NR_IRQS_LEGACY + AT91SAM9263_ID_US2,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1365,48 +1478,39 @@ static inline void configure_usart2_pins(unsigned pins)  }  static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */ -struct platform_device *atmel_default_console_device;	/* the serial console device */  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)  {  	struct platform_device *pdev; +	struct atmel_uart_data *pdata;  	switch (id) {  		case 0:		/* DBGU */  			pdev = &at91sam9263_dbgu_device;  			configure_dbgu_pins(); -			at91_clock_associate("mck", &pdev->dev, "usart");  			break;  		case AT91SAM9263_ID_US0:  			pdev = &at91sam9263_uart0_device;  			configure_usart0_pins(pins); -			at91_clock_associate("usart0_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9263_ID_US1:  			pdev = &at91sam9263_uart1_device;  			configure_usart1_pins(pins); -			at91_clock_associate("usart1_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9263_ID_US2:  			pdev = &at91sam9263_uart2_device;  			configure_usart2_pins(pins); -			at91_clock_associate("usart2_clk", &pdev->dev, "usart");  			break;  		default:  			return;  	} -	pdev->id = portnr;		/* update to mapped ID */ +	pdata = pdev->dev.platform_data; +	pdata->num = portnr;		/* update to mapped ID */  	if (portnr < ATMEL_MAX_UART)  		at91_uarts[portnr] = pdev;  } -void __init at91_set_serial_console(unsigned portnr) -{ -	if (portnr < ATMEL_MAX_UART) -		atmel_default_console_device = at91_uarts[portnr]; -} -  void __init at91_add_device_serial(void)  {  	int i; @@ -1415,13 +1519,9 @@ void __init at91_add_device_serial(void)  		if (at91_uarts[i])  			platform_device_register(at91_uarts[i]);  	} - -	if (!atmel_default_console_device) -		printk(KERN_INFO "AT91: No default serial console defined.\n");  }  #else  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {}  void __init at91_add_device_serial(void) {}  #endif @@ -1433,6 +1533,9 @@ void __init at91_add_device_serial(void) {}   */  static int __init at91_add_standard_devices(void)  { +	if (of_have_populated_dt()) +		return 0; +  	at91_add_device_rtt();  	at91_add_device_watchdog();  	at91_add_device_tc(); diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c index 608a63240b6..0a9e2fc8f79 100644 --- a/arch/arm/mach-at91/at91sam926x_time.c +++ b/arch/arm/mach-at91/at91sam926x_time.c @@ -14,18 +14,43 @@  #include <linux/kernel.h>  #include <linux/clk.h>  #include <linux/clockchips.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h>  #include <asm/mach/time.h> +#include <mach/hardware.h> -#include <mach/at91_pit.h> +#define AT91_PIT_MR		0x00			/* Mode Register */ +#define		AT91_PIT_PITIEN		(1 << 25)		/* Timer Interrupt Enable */ +#define		AT91_PIT_PITEN		(1 << 24)		/* Timer Enabled */ +#define		AT91_PIT_PIV		(0xfffff)		/* Periodic Interval Value */ +#define AT91_PIT_SR		0x04			/* Status Register */ +#define		AT91_PIT_PITS		(1 << 0)		/* Timer Status */ + +#define AT91_PIT_PIVR		0x08			/* Periodic Interval Value Register */ +#define AT91_PIT_PIIR		0x0c			/* Periodic Interval Image Register */ +#define		AT91_PIT_PICNT		(0xfff << 20)		/* Interval Counter */ +#define		AT91_PIT_CPIV		(0xfffff)		/* Inverval Value */  #define PIT_CPIV(x)	((x) & AT91_PIT_CPIV)  #define PIT_PICNT(x)	(((x) & AT91_PIT_PICNT) >> 20)  static u32 pit_cycle;		/* write-once */  static u32 pit_cnt;		/* access only w/system irq blocked */ +static void __iomem *pit_base_addr __read_mostly; +static struct clk *mck; +static inline unsigned int pit_read(unsigned int reg_offset) +{ +	return __raw_readl(pit_base_addr + reg_offset); +} + +static inline void pit_write(unsigned int reg_offset, unsigned long value) +{ +	__raw_writel(value, pit_base_addr + reg_offset); +}  /*   * Clocksource:  just a monotonic counter of MCK/16 cycles. @@ -39,7 +64,7 @@ static cycle_t read_pit_clk(struct clocksource *cs)  	raw_local_irq_save(flags);  	elapsed = pit_cnt; -	t = at91_sys_read(AT91_PIT_PIIR); +	t = pit_read(AT91_PIT_PIIR);  	raw_local_irq_restore(flags);  	elapsed += PIT_PICNT(t) * pit_cycle; @@ -51,7 +76,6 @@ static struct clocksource pit_clk = {  	.name		= "pit",  	.rating		= 175,  	.read		= read_pit_clk, -	.shift		= 20,  	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,  }; @@ -65,8 +89,8 @@ pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)  	switch (mode) {  	case CLOCK_EVT_MODE_PERIODIC:  		/* update clocksource counter */ -		pit_cnt += pit_cycle * PIT_PICNT(at91_sys_read(AT91_PIT_PIVR)); -		at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN +		pit_cnt += pit_cycle * PIT_PICNT(pit_read(AT91_PIT_PIVR)); +		pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN  				| AT91_PIT_PITIEN);  		break;  	case CLOCK_EVT_MODE_ONESHOT: @@ -75,19 +99,45 @@ pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)  	case CLOCK_EVT_MODE_SHUTDOWN:  	case CLOCK_EVT_MODE_UNUSED:  		/* disable irq, leaving the clocksource active */ -		at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN); +		pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);  		break;  	case CLOCK_EVT_MODE_RESUME:  		break;  	}  } +static void at91sam926x_pit_suspend(struct clock_event_device *cedev) +{ +	/* Disable timer */ +	pit_write(AT91_PIT_MR, 0); +} + +static void at91sam926x_pit_reset(void) +{ +	/* Disable timer and irqs */ +	pit_write(AT91_PIT_MR, 0); + +	/* Clear any pending interrupts, wait for PIT to stop counting */ +	while (PIT_CPIV(pit_read(AT91_PIT_PIVR)) != 0) +		cpu_relax(); + +	/* Start PIT but don't enable IRQ */ +	pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN); +} + +static void at91sam926x_pit_resume(struct clock_event_device *cedev) +{ +	at91sam926x_pit_reset(); +} +  static struct clock_event_device pit_clkevt = {  	.name		= "pit",  	.features	= CLOCK_EVT_FEAT_PERIODIC,  	.shift		= 32,  	.rating		= 100,  	.set_mode	= pit_clkevt_mode, +	.suspend	= at91sam926x_pit_suspend, +	.resume		= at91sam926x_pit_resume,  }; @@ -104,11 +154,11 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)  	/* The PIT interrupt may be disabled, and is shared */  	if ((pit_clkevt.mode == CLOCK_EVT_MODE_PERIODIC) -			&& (at91_sys_read(AT91_PIT_SR) & AT91_PIT_PITS)) { +			&& (pit_read(AT91_PIT_SR) & AT91_PIT_PITS)) {  		unsigned nr_ticks;  		/* Get number of ticks performed before irq, and ack it */ -		nr_ticks = PIT_PICNT(at91_sys_read(AT91_PIT_PIVR)); +		nr_ticks = PIT_PICNT(pit_read(AT91_PIT_PIVR));  		do {  			pit_cnt += pit_cycle;  			pit_clkevt.event_handler(&pit_clkevt); @@ -123,36 +173,84 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)  static struct irqaction at91sam926x_pit_irq = {  	.name		= "at91_tick", -	.flags		= IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, -	.handler	= at91sam926x_pit_interrupt +	.flags		= IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, +	.handler	= at91sam926x_pit_interrupt, +	.irq		= NR_IRQS_LEGACY + AT91_ID_SYS,  }; -static void at91sam926x_pit_reset(void) +#ifdef CONFIG_OF +static struct of_device_id pit_timer_ids[] = { +	{ .compatible = "atmel,at91sam9260-pit" }, +	{ /* sentinel */ } +}; + +static int __init of_at91sam926x_pit_init(void)  { -	/* Disable timer and irqs */ -	at91_sys_write(AT91_PIT_MR, 0); +	struct device_node	*np; +	int			ret; -	/* Clear any pending interrupts, wait for PIT to stop counting */ -	while (PIT_CPIV(at91_sys_read(AT91_PIT_PIVR)) != 0) -		cpu_relax(); +	np = of_find_matching_node(NULL, pit_timer_ids); +	if (!np) +		goto err; -	/* Start PIT but don't enable IRQ */ -	at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN); +	pit_base_addr = of_iomap(np, 0); +	if (!pit_base_addr) +		goto node_err; + +	mck = of_clk_get(np, 0); + +	/* Get the interrupts property */ +	ret = irq_of_parse_and_map(np, 0); +	if (!ret) { +		pr_crit("AT91: PIT: Unable to get IRQ from DT\n"); +		if (!IS_ERR(mck)) +			clk_put(mck); +		goto ioremap_err; +	} +	at91sam926x_pit_irq.irq = ret; + +	of_node_put(np); + +	return 0; + +ioremap_err: +	iounmap(pit_base_addr); +node_err: +	of_node_put(np); +err: +	return -EINVAL;  } +#else +static int __init of_at91sam926x_pit_init(void) +{ +	return -EINVAL; +} +#endif  /*   * Set up both clocksource and clockevent support.   */ -static void __init at91sam926x_pit_init(void) +void __init at91sam926x_pit_init(void)  {  	unsigned long	pit_rate;  	unsigned	bits; +	int		ret; + +	mck = ERR_PTR(-ENOENT); + +	/* For device tree enabled device: initialize here */ +	of_at91sam926x_pit_init();  	/*  	 * Use our actual MCK to figure out how many MCK/16 ticks per  	 * 1/HZ period (instead of a compile-time constant LATCH).  	 */ -	pit_rate = clk_get_rate(clk_get(NULL, "mck")) / 16; +	if (IS_ERR(mck)) +		mck = clk_get(NULL, "mck"); + +	if (IS_ERR(mck)) +		panic("AT91: PIT: Unable to get mck clk\n"); +	pit_rate = clk_get_rate(mck) / 16;  	pit_cycle = (pit_rate + HZ/2) / HZ;  	WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0); @@ -163,13 +261,14 @@ static void __init at91sam926x_pit_init(void)  	 * Register clocksource.  The high order bits of PIV are unused,  	 * so this isn't a 32-bit counter unless we get clockevent irqs.  	 */ -	pit_clk.mult = clocksource_hz2mult(pit_rate, pit_clk.shift);  	bits = 12 /* PICNT */ + ilog2(pit_cycle) /* PIV */;  	pit_clk.mask = CLOCKSOURCE_MASK(bits); -	clocksource_register(&pit_clk); +	clocksource_register_hz(&pit_clk, pit_rate);  	/* Set up irq handler */ -	setup_irq(AT91_ID_SYS, &at91sam926x_pit_irq); +	ret = setup_irq(at91sam926x_pit_irq.irq, &at91sam926x_pit_irq); +	if (ret) +		pr_crit("AT91: PIT: Unable to setup IRQ\n");  	/* Set up and register clockevents */  	pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift); @@ -177,14 +276,19 @@ static void __init at91sam926x_pit_init(void)  	clockevents_register_device(&pit_clkevt);  } -static void at91sam926x_pit_suspend(void) +void __init at91sam926x_ioremap_pit(u32 addr)  { -	/* Disable timer */ -	at91_sys_write(AT91_PIT_MR, 0); -} +#if defined(CONFIG_OF) +	struct device_node *np = +		of_find_matching_node(NULL, pit_timer_ids); -struct sys_timer at91sam926x_timer = { -	.init		= at91sam926x_pit_init, -	.suspend	= at91sam926x_pit_suspend, -	.resume		= at91sam926x_pit_reset, -}; +	if (np) { +		of_node_put(np); +		return; +	} +#endif +	pit_base_addr = ioremap(addr, 16); + +	if (!pit_base_addr) +		panic("Impossible to ioremap PIT\n"); +} diff --git a/arch/arm/mach-at91/at91sam9_alt_reset.S b/arch/arm/mach-at91/at91sam9_alt_reset.S index e0256deb91f..f039538d3bd 100644 --- a/arch/arm/mach-at91/at91sam9_alt_reset.S +++ b/arch/arm/mach-at91/at91sam9_alt_reset.S @@ -14,21 +14,18 @@   */  #include <linux/linkage.h> -#include <asm/system.h>  #include <mach/hardware.h> -#include <mach/at91sam9_sdramc.h> -#include <mach/at91_rstc.h> +#include <mach/at91_ramc.h> +#include "at91_rstc.h"  			.arm -			.globl	at91sam9_alt_reset +			.globl	at91sam9_alt_restart -at91sam9_alt_reset:	mrc	p15, 0, r0, c1, c0, 0 -			orr	r0, r0, #CR_I -			mcr	p15, 0, r0, c1, c0, 0		@ enable I-cache - -			ldr	r0, .at91_va_base_sdramc	@ preload constants -			ldr	r1, .at91_va_base_rstc_cr +at91sam9_alt_restart:	ldr	r0, =at91_ramc_base		@ preload constants +			ldr	r0, [r0] +			ldr	r4, =at91_rstc_base +			ldr	r1, [r4]  			mov	r2, #1  			mov	r3, #AT91_SDRAMC_LPCB_POWER_DOWN @@ -38,11 +35,6 @@ at91sam9_alt_reset:	mrc	p15, 0, r0, c1, c0, 0  			str	r2, [r0, #AT91_SDRAMC_TR]	@ disable SDRAM access  			str	r3, [r0, #AT91_SDRAMC_LPR]	@ power down SDRAM -			str	r4, [r1]			@ reset processor +			str	r4, [r1, #AT91_RSTC_CR]		@ reset processor  			b	. - -.at91_va_base_sdramc: -	.word AT91_VA_BASE_SYS + AT91_SDRAMC0 -.at91_va_base_rstc_cr: -	.word AT91_VA_BASE_SYS + AT91_RSTC_CR diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c index c67b47f1c0f..9d3d544ac19 100644 --- a/arch/arm/mach-at91/at91sam9g45.c +++ b/arch/arm/mach-at91/at91sam9g45.c @@ -11,33 +11,23 @@   */  #include <linux/module.h> -#include <linux/pm.h> +#include <linux/dma-mapping.h> +#include <linux/clk/at91_pmc.h>  #include <asm/irq.h>  #include <asm/mach/arch.h>  #include <asm/mach/map.h> +#include <asm/system_misc.h>  #include <mach/at91sam9g45.h> -#include <mach/at91_pmc.h> -#include <mach/at91_rstc.h> -#include <mach/at91_shdwc.h>  #include <mach/cpu.h> +#include <mach/hardware.h> +#include "at91_aic.h" +#include "soc.h"  #include "generic.h"  #include "clock.h" - -static struct map_desc at91sam9g45_io_desc[] __initdata = { -	{ -		.virtual	= AT91_VA_BASE_SYS, -		.pfn		= __phys_to_pfn(AT91_BASE_SYS), -		.length		= SZ_16K, -		.type		= MT_DEVICE, -	}, { -		.virtual	= AT91_IO_VIRT_BASE - AT91SAM9G45_SRAM_SIZE, -		.pfn		= __phys_to_pfn(AT91SAM9G45_SRAM_BASE), -		.length		= AT91SAM9G45_SRAM_SIZE, -		.type		= MT_DEVICE, -	} -}; +#include "sam9_smc.h" +#include "pm.h"  /* --------------------------------------------------------------------   *  Clocks @@ -66,6 +56,11 @@ static struct clk pioDE_clk = {  	.pmc_mask	= 1 << AT91SAM9G45_ID_PIODE,  	.type		= CLK_TYPE_PERIPHERAL,  }; +static struct clk trng_clk = { +	.name		= "trng_clk", +	.pmc_mask	= 1 << AT91SAM9G45_ID_TRNG, +	.type		= CLK_TYPE_PERIPHERAL, +};  static struct clk usart0_clk = {  	.name		= "usart0_clk",  	.pmc_mask	= 1 << AT91SAM9G45_ID_US0, @@ -157,7 +152,7 @@ static struct clk ac97_clk = {  	.type		= CLK_TYPE_PERIPHERAL,  };  static struct clk macb_clk = { -	.name		= "macb_clk", +	.name		= "pclk",  	.pmc_mask	= 1 << AT91SAM9G45_ID_EMAC,  	.type		= CLK_TYPE_PERIPHERAL,  }; @@ -184,20 +179,17 @@ static struct clk vdec_clk = {  	.type		= CLK_TYPE_PERIPHERAL,  }; -/* One additional fake clock for ohci */ -static struct clk ohci_clk = { -	.name		= "ohci_clk", -	.pmc_mask	= 0, +static struct clk adc_op_clk = { +	.name		= "adc_op_clk",  	.type		= CLK_TYPE_PERIPHERAL, -	.parent		= &uhphs_clk, +	.rate_hz	= 300000,  }; -/* One additional fake clock for second TC block */ -static struct clk tcb1_clk = { -	.name		= "tcb1_clk", -	.pmc_mask	= 0, +/* AES/TDES/SHA clock - Only for sam9m11/sam9g56 */ +static struct clk aestdessha_clk = { +	.name		= "aestdessha_clk", +	.pmc_mask	= 1 << AT91SAM9G45_ID_AESTDESSHA,  	.type		= CLK_TYPE_PERIPHERAL, -	.parent		= &tcb0_clk,  };  static struct clk *periph_clocks[] __initdata = { @@ -205,6 +197,7 @@ static struct clk *periph_clocks[] __initdata = {  	&pioB_clk,  	&pioC_clk,  	&pioDE_clk, +	&trng_clk,  	&usart0_clk,  	&usart1_clk,  	&usart2_clk, @@ -227,9 +220,80 @@ static struct clk *periph_clocks[] __initdata = {  	&isi_clk,  	&udphs_clk,  	&mmc1_clk, +	&adc_op_clk, +	&aestdessha_clk,  	// irq0 -	&ohci_clk, -	&tcb1_clk, +}; + +static struct clk_lookup periph_clocks_lookups[] = { +	/* One additional fake clock for macb_hclk */ +	CLKDEV_CON_ID("hclk", &macb_clk), +	/* One additional fake clock for ohci */ +	CLKDEV_CON_ID("ohci_clk", &uhphs_clk), +	CLKDEV_CON_DEV_ID("hclk", "at91sam9g45-lcdfb.0", &lcdc_clk), +	CLKDEV_CON_DEV_ID("hclk", "at91sam9g45es-lcdfb.0", &lcdc_clk), +	CLKDEV_CON_DEV_ID("ehci_clk", "atmel-ehci", &uhphs_clk), +	CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc", &utmi_clk), +	CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc", &udphs_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.0", &mmc0_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.1", &mmc1_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb0_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tcb0_clk), +	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi0_clk), +	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.1", &twi1_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91sam9g45_ssc.0", &ssc0_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91sam9g45_ssc.1", &ssc1_clk), +	CLKDEV_CON_DEV_ID("pclk", "fff9c000.ssc", &ssc0_clk), +	CLKDEV_CON_DEV_ID("pclk", "fffa0000.ssc", &ssc1_clk), +	CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk), +	CLKDEV_CON_DEV_ID(NULL, "atmel_sha", &aestdessha_clk), +	CLKDEV_CON_DEV_ID(NULL, "atmel_tdes", &aestdessha_clk), +	CLKDEV_CON_DEV_ID(NULL, "atmel_aes", &aestdessha_clk), +	/* more usart lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck), +	CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "fff90000.serial", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "fff94000.serial", &usart2_clk), +	CLKDEV_CON_DEV_ID("usart", "fff98000.serial", &usart3_clk), +	/* more tc lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("t0_clk", "fff7c000.timer", &tcb0_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk), +	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk), +	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "fffd0000.mmc", &mmc1_clk), +	CLKDEV_CON_DEV_ID(NULL, "fff84000.i2c", &twi0_clk), +	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi1_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk), +	CLKDEV_CON_DEV_ID("hclk", "600000.gadget", &utmi_clk), +	CLKDEV_CON_DEV_ID("pclk", "600000.gadget", &udphs_clk), +	/* fake hclk clock */ +	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff200.gpio", &pioA_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioB_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioC_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioDE_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioDE_clk), + +	CLKDEV_CON_ID("pioA", &pioA_clk), +	CLKDEV_CON_ID("pioB", &pioB_clk), +	CLKDEV_CON_ID("pioC", &pioC_clk), +	CLKDEV_CON_ID("pioD", &pioDE_clk), +	CLKDEV_CON_ID("pioE", &pioDE_clk), +	/* Fake adc clock */ +	CLKDEV_CON_ID("adc_clk", &tsc_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffb8000.pwm", &pwm_clk), +}; + +static struct clk_lookup usart_clocks_lookups[] = { +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.4", &usart3_clk),  };  /* @@ -256,6 +320,11 @@ static void __init at91sam9g45_register_clocks(void)  	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)  		clk_register(periph_clocks[i]); +	clkdev_add_table(periph_clocks_lookups, +			 ARRAY_SIZE(periph_clocks_lookups)); +	clkdev_add_table(usart_clocks_lookups, +			 ARRAY_SIZE(usart_clocks_lookups)); +  	if (cpu_is_at91sam9m10() || cpu_is_at91sam9m11())  		clk_register(&vdec_clk); @@ -267,59 +336,53 @@ static void __init at91sam9g45_register_clocks(void)   *  GPIO   * -------------------------------------------------------------------- */ -static struct at91_gpio_bank at91sam9g45_gpio[] = { +static struct at91_gpio_bank at91sam9g45_gpio[] __initdata = {  	{  		.id		= AT91SAM9G45_ID_PIOA, -		.offset		= AT91_PIOA, -		.clock		= &pioA_clk, +		.regbase	= AT91SAM9G45_BASE_PIOA,  	}, {  		.id		= AT91SAM9G45_ID_PIOB, -		.offset		= AT91_PIOB, -		.clock		= &pioB_clk, +		.regbase	= AT91SAM9G45_BASE_PIOB,  	}, {  		.id		= AT91SAM9G45_ID_PIOC, -		.offset		= AT91_PIOC, -		.clock		= &pioC_clk, +		.regbase	= AT91SAM9G45_BASE_PIOC,  	}, {  		.id		= AT91SAM9G45_ID_PIODE, -		.offset		= AT91_PIOD, -		.clock		= &pioDE_clk, +		.regbase	= AT91SAM9G45_BASE_PIOD,  	}, {  		.id		= AT91SAM9G45_ID_PIODE, -		.offset		= AT91_PIOE, -		.clock		= &pioDE_clk, +		.regbase	= AT91SAM9G45_BASE_PIOE,  	}  }; -static void at91sam9g45_reset(void) -{ -	at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); -} - -static void at91sam9g45_poweroff(void) -{ -	at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); -} - -  /* --------------------------------------------------------------------   *  AT91SAM9G45 processor initialization   * -------------------------------------------------------------------- */ -void __init at91sam9g45_initialize(unsigned long main_clock) +static void __init at91sam9g45_map_io(void)  { -	/* Map peripherals */ -	iotable_init(at91sam9g45_io_desc, ARRAY_SIZE(at91sam9g45_io_desc)); +	at91_init_sram(0, AT91SAM9G45_SRAM_BASE, AT91SAM9G45_SRAM_SIZE); +} -	at91_arch_reset = at91sam9g45_reset; -	pm_power_off = at91sam9g45_poweroff; -	at91_extern_irq = (1 << AT91SAM9G45_ID_IRQ0); +static void __init at91sam9g45_ioremap_registers(void) +{ +	at91_ioremap_shdwc(AT91SAM9G45_BASE_SHDWC); +	at91_ioremap_rstc(AT91SAM9G45_BASE_RSTC); +	at91_ioremap_ramc(0, AT91SAM9G45_BASE_DDRSDRC1, 512); +	at91_ioremap_ramc(1, AT91SAM9G45_BASE_DDRSDRC0, 512); +	at91sam926x_ioremap_pit(AT91SAM9G45_BASE_PIT); +	at91sam9_ioremap_smc(0, AT91SAM9G45_BASE_SMC); +	at91_ioremap_matrix(AT91SAM9G45_BASE_MATRIX); +	at91_pm_set_standby(at91_ddr_standby); +} -	/* Init clock subsystem */ -	at91_clock_init(main_clock); +static void __init at91sam9g45_initialize(void) +{ +	arm_pm_idle = at91sam9_idle; +	arm_pm_restart = at91sam9g45_restart; -	/* Register the processor-specific clocks */ -	at91sam9g45_register_clocks(); +	at91_sysirq_mask_rtc(AT91SAM9G45_BASE_RTC); +	at91_sysirq_mask_rtt(AT91SAM9G45_BASE_RTT);  	/* Register GPIO subsystem */  	at91_gpio_init(at91sam9g45_gpio, 5); @@ -361,20 +424,17 @@ static unsigned int at91sam9g45_default_irq_priority[NR_AIC_IRQS] __initdata = {  	3,	/* Ethernet */  	0,	/* Image Sensor Interface */  	2,	/* USB Device High speed port */ -	0, +	0,	/* AESTDESSHA Crypto HW Accelerators */  	0,	/* Multimedia Card Interface 1 */  	0,  	0,	/* Advanced Interrupt Controller (IRQ0) */  }; -void __init at91sam9g45_init_interrupts(unsigned int priority[NR_AIC_IRQS]) -{ -	if (!priority) -		priority = at91sam9g45_default_irq_priority; - -	/* Initialize the AIC interrupt controller */ -	at91_aic_init(priority); - -	/* Enable GPIO interrupts */ -	at91_gpio_irq_setup(); -} +AT91_SOC_START(at91sam9g45) +	.map_io = at91sam9g45_map_io, +	.default_irq_priority = at91sam9g45_default_irq_priority, +	.extern_irq = (1 << AT91SAM9G45_ID_IRQ0), +	.ioremap_registers = at91sam9g45_ioremap_registers, +	.register_clocks = at91sam9g45_register_clocks, +	.init = at91sam9g45_initialize, +AT91_SOC_END diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c index 1e8f275c17f..391ab6bb536 100644 --- a/arch/arm/mach-at91/at91sam9g45_devices.c +++ b/arch/arm/mach-at91/at91sam9g45_devices.c @@ -13,22 +13,32 @@  #include <asm/mach/map.h>  #include <linux/dma-mapping.h> +#include <linux/gpio.h> +#include <linux/clk.h>  #include <linux/platform_device.h>  #include <linux/i2c-gpio.h>  #include <linux/atmel-mci.h> +#include <linux/platform_data/crypto-atmel.h> + +#include <linux/platform_data/at91_adc.h>  #include <linux/fb.h>  #include <video/atmel_lcdc.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9g45.h>  #include <mach/at91sam9g45_matrix.h> +#include <mach/at91_matrix.h>  #include <mach/at91sam9_smc.h> -#include <mach/at_hdmac.h> +#include <linux/platform_data/dma-atmel.h>  #include <mach/atmel-mci.h> +#include <mach/hardware.h> + +#include <media/atmel-isi.h> +#include "board.h"  #include "generic.h" +#include "clock.h" +#include "gpio.h"  /* -------------------------------------------------------------------- @@ -38,30 +48,25 @@  #if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)  static u64 hdmac_dmamask = DMA_BIT_MASK(32); -static struct at_dma_platform_data atdma_pdata = { -	.nr_channels	= 8, -}; -  static struct resource hdmac_resources[] = {  	[0] = { -		.start	= AT91_BASE_SYS + AT91_DMA, -		.end	= AT91_BASE_SYS + AT91_DMA + SZ_512 - 1, +		.start	= AT91SAM9G45_BASE_DMA, +		.end	= AT91SAM9G45_BASE_DMA + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_DMA, -		.end	= AT91SAM9G45_ID_DMA, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_DMA, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_DMA,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at_hdmac_device = { -	.name		= "at_hdmac", +	.name		= "at91sam9g45_dma",  	.id		= -1,  	.dev		= {  				.dma_mask		= &hdmac_dmamask,  				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &atdma_pdata,  	},  	.resource	= hdmac_resources,  	.num_resources	= ARRAY_SIZE(hdmac_resources), @@ -69,8 +74,6 @@ static struct platform_device at_hdmac_device = {  void __init at91_add_device_hdmac(void)  { -	dma_cap_set(DMA_MEMCPY, atdma_pdata.cap_mask); -	dma_cap_set(DMA_SLAVE, atdma_pdata.cap_mask);  	platform_device_register(&at_hdmac_device);  }  #else @@ -93,8 +96,8 @@ static struct resource usbh_ohci_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_UHPHS, -		.end	= AT91SAM9G45_ID_UHPHS, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -120,8 +123,15 @@ void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data)  	/* Enable VBus control for UHP ports */  	for (i = 0; i < data->ports; i++) { -		if (data->vbus_pin[i]) -			at91_set_gpio_output(data->vbus_pin[i], 0); +		if (gpio_is_valid(data->vbus_pin[i])) +			at91_set_gpio_output(data->vbus_pin[i], +					     data->vbus_pin_active_low[i]); +	} + +	/* Enable overcurrent notification */ +	for (i = 0; i < data->ports; i++) { +		if (gpio_is_valid(data->overcurrent_pin[i])) +			at91_set_gpio_input(data->overcurrent_pin[i], 1);  	}  	usbh_ohci_data = *data; @@ -148,8 +158,8 @@ static struct resource usbh_ehci_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_UHPHS, -		.end	= AT91SAM9G45_ID_UHPHS, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -175,12 +185,12 @@ void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data)  	/* Enable VBus control for UHP ports */  	for (i = 0; i < data->ports; i++) { -		if (data->vbus_pin[i]) -			at91_set_gpio_output(data->vbus_pin[i], 0); +		if (gpio_is_valid(data->vbus_pin[i])) +			at91_set_gpio_output(data->vbus_pin[i], +					     data->vbus_pin_active_low[i]);  	}  	usbh_ehci_data = *data; -	at91_clock_associate("uhphs_clk", &at91_usbh_ehci_device.dev, "ehci_clk");  	platform_device_register(&at91_usbh_ehci_device);  }  #else @@ -192,7 +202,7 @@ void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data) {}   *  USB HS Device (Gadget)   * -------------------------------------------------------------------- */ -#if defined(CONFIG_USB_GADGET_ATMEL_USBA) || defined(CONFIG_USB_GADGET_ATMEL_USBA_MODULE) +#if defined(CONFIG_USB_ATMEL_USBA) || defined(CONFIG_USB_ATMEL_USBA_MODULE)  static struct resource usba_udc_resources[] = {  	[0] = {  		.start	= AT91SAM9G45_UDPHS_FIFO, @@ -205,8 +215,8 @@ static struct resource usba_udc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[2] = { -		.start	= AT91SAM9G45_ID_UDPHS, -		.end	= AT91SAM9G45_ID_UDPHS, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_UDPHS, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_UDPHS,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -256,9 +266,9 @@ void __init at91_add_device_usba(struct usba_platform_data *data)  {  	usba_udc_data.pdata.vbus_pin = -EINVAL;  	usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep); -	memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));; +	memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep)); -	if (data && data->vbus_pin > 0) { +	if (data && gpio_is_valid(data->vbus_pin)) {  		at91_set_gpio_input(data->vbus_pin, 0);  		at91_set_deglitch(data->vbus_pin, 1);  		usba_udc_data.pdata.vbus_pin = data->vbus_pin; @@ -266,10 +276,6 @@ void __init at91_add_device_usba(struct usba_platform_data *data)  	/* Pullup pin is handled internally by USB device peripheral */ -	/* Clocks */ -	at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk"); -	at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk"); -  	platform_device_register(&at91_usba_udc_device);  }  #else @@ -283,7 +289,7 @@ void __init at91_add_device_usba(struct usba_platform_data *data) {}  #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)  static u64 eth_dmamask = DMA_BIT_MASK(32); -static struct at91_eth_data eth_data; +static struct macb_platform_data eth_data;  static struct resource eth_resources[] = {  	[0] = { @@ -292,8 +298,8 @@ static struct resource eth_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_EMAC, -		.end	= AT91SAM9G45_ID_EMAC, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_EMAC, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_EMAC,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -310,12 +316,12 @@ static struct platform_device at91sam9g45_eth_device = {  	.num_resources	= ARRAY_SIZE(eth_resources),  }; -void __init at91_add_device_eth(struct at91_eth_data *data) +void __init at91_add_device_eth(struct macb_platform_data *data)  {  	if (!data)  		return; -	if (data->phy_irq_pin) { +	if (gpio_is_valid(data->phy_irq_pin)) {  		at91_set_gpio_input(data->phy_irq_pin, 0);  		at91_set_deglitch(data->phy_irq_pin, 1);  	} @@ -347,7 +353,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data)  	platform_device_register(&at91sam9g45_eth_device);  }  #else -void __init at91_add_device_eth(struct at91_eth_data *data) {} +void __init at91_add_device_eth(struct macb_platform_data *data) {}  #endif @@ -366,8 +372,8 @@ static struct resource mmc0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_MCI0, -		.end	= AT91SAM9G45_ID_MCI0, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI0, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -391,8 +397,8 @@ static struct resource mmc1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_MCI1, -		.end	= AT91SAM9G45_ID_MCI1, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI1, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -430,10 +436,8 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)  	/* DMA slave channel configuration */  	atslave->dma_dev = &at_hdmac_device.dev; -	atslave->reg_width = AT_DMA_SLAVE_WIDTH_32BIT;  	atslave->cfg = ATC_FIFOCFG_HALFFIFO  			| ATC_SRC_H2SEL_HW | ATC_DST_H2SEL_HW; -	atslave->ctrla = ATC_SCSIZE_16 | ATC_DCSIZE_16;  	if (mmc_id == 0)	/* MCI0 */  		atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI0)  			      | ATC_DST_PER(AT_DMA_ID_MCI0); @@ -448,11 +452,11 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)  	/* input/irq */ -	if (data->slot[0].detect_pin) { +	if (gpio_is_valid(data->slot[0].detect_pin)) {  		at91_set_gpio_input(data->slot[0].detect_pin, 1);  		at91_set_deglitch(data->slot[0].detect_pin, 1);  	} -	if (data->slot[0].wp_pin) +	if (gpio_is_valid(data->slot[0].wp_pin))  		at91_set_gpio_input(data->slot[0].wp_pin, 1);  	if (mmc_id == 0) {		/* MCI0 */ @@ -478,7 +482,6 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)  		}  		mmc0_data = *data; -		at91_clock_associate("mci0_clk", &at91sam9g45_mmc0_device.dev, "mci_clk");  		platform_device_register(&at91sam9g45_mmc0_device);  	} else {			/* MCI1 */ @@ -504,7 +507,6 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)  		}  		mmc1_data = *data; -		at91_clock_associate("mci1_clk", &at91sam9g45_mmc1_device.dev, "mci_clk");  		platform_device_register(&at91sam9g45_mmc1_device);  	} @@ -530,8 +532,8 @@ static struct resource nand_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91_BASE_SYS + AT91_ECC, -		.end	= AT91_BASE_SYS + AT91_ECC + SZ_512 - 1, +		.start	= AT91SAM9G45_BASE_ECC, +		.end	= AT91SAM9G45_BASE_ECC + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	}  }; @@ -553,19 +555,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)  	if (!data)  		return; -	csa = at91_sys_read(AT91_MATRIX_EBICSA); -	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA); +	csa = at91_matrix_read(AT91_MATRIX_EBICSA); +	at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA);  	/* enable pin */ -	if (data->enable_pin) +	if (gpio_is_valid(data->enable_pin))  		at91_set_gpio_output(data->enable_pin, 1);  	/* ready/busy pin */ -	if (data->rdy_pin) +	if (gpio_is_valid(data->rdy_pin))  		at91_set_gpio_input(data->rdy_pin, 1);  	/* card detect pin */ -	if (data->det_pin) +	if (gpio_is_valid(data->det_pin))  		at91_set_gpio_input(data->det_pin, 1);  	nand_data = *data; @@ -645,14 +647,14 @@ static struct resource twi0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_TWI0, -		.end	= AT91SAM9G45_ID_TWI0, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI0, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI0,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9g45_twi0_device = { -	.name		= "at91_i2c", +	.name		= "i2c-at91sam9g10",  	.id		= 0,  	.resource	= twi0_resources,  	.num_resources	= ARRAY_SIZE(twi0_resources), @@ -665,14 +667,14 @@ static struct resource twi1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_TWI1, -		.end	= AT91SAM9G45_ID_TWI1, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI1, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI1,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9g45_twi1_device = { -	.name		= "at91_i2c", +	.name		= "i2c-at91sam9g10",  	.id		= 1,  	.resource	= twi1_resources,  	.num_resources	= ARRAY_SIZE(twi1_resources), @@ -685,18 +687,12 @@ void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, in  	/* pins used for TWI interface */  	if (i2c_id == 0) {  		at91_set_A_periph(AT91_PIN_PA20, 0);		/* TWD */ -		at91_set_multi_drive(AT91_PIN_PA20, 1); -  		at91_set_A_periph(AT91_PIN_PA21, 0);		/* TWCK */ -		at91_set_multi_drive(AT91_PIN_PA21, 1);  		platform_device_register(&at91sam9g45_twi0_device);  	} else {  		at91_set_A_periph(AT91_PIN_PB10, 0);		/* TWD */ -		at91_set_multi_drive(AT91_PIN_PB10, 1); -  		at91_set_A_periph(AT91_PIN_PB11, 0);		/* TWCK */ -		at91_set_multi_drive(AT91_PIN_PB11, 1);  		platform_device_register(&at91sam9g45_twi1_device);  	} @@ -720,8 +716,8 @@ static struct resource spi0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_SPI0, -		.end	= AT91SAM9G45_ID_SPI0, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI0, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -746,8 +742,8 @@ static struct resource spi1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_SPI1, -		.end	= AT91SAM9G45_ID_SPI1, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI1, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -781,6 +777,9 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		else  			cs_pin = spi1_standard_cs[devices[i].chip_select]; +		if (!gpio_is_valid(cs_pin)) +			continue; +  		if (devices[i].bus_num == 0)  			enable_spi0 = 1;  		else @@ -801,7 +800,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		at91_set_A_periph(AT91_PIN_PB1, 0);	/* SPI0_MOSI */  		at91_set_A_periph(AT91_PIN_PB2, 0);	/* SPI0_SPCK */ -		at91_clock_associate("spi0_clk", &at91sam9g45_spi0_device.dev, "spi_clk");  		platform_device_register(&at91sam9g45_spi0_device);  	}  	if (enable_spi1) { @@ -809,7 +807,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		at91_set_A_periph(AT91_PIN_PB15, 0);	/* SPI1_MOSI */  		at91_set_A_periph(AT91_PIN_PB16, 0);	/* SPI1_SPCK */ -		at91_clock_associate("spi1_clk", &at91sam9g45_spi1_device.dev, "spi_clk");  		platform_device_register(&at91sam9g45_spi1_device);  	}  } @@ -833,8 +830,8 @@ static struct resource ac97_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_AC97C, -		.end	= AT91SAM9G45_ID_AC97C, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_AC97C, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_AC97C,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -862,7 +859,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data)  	at91_set_A_periph(AT91_PIN_PD6, 0);	/* AC97RX */  	/* reset */ -	if (data->reset_pin) +	if (gpio_is_valid(data->reset_pin))  		at91_set_gpio_output(data->reset_pin, 0);  	ac97_data = *data; @@ -872,6 +869,96 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data)  void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}  #endif +/* -------------------------------------------------------------------- + *  Image Sensor Interface + * -------------------------------------------------------------------- */ +#if defined(CONFIG_VIDEO_ATMEL_ISI) || defined(CONFIG_VIDEO_ATMEL_ISI_MODULE) +static u64 isi_dmamask = DMA_BIT_MASK(32); +static struct isi_platform_data isi_data; + +struct resource isi_resources[] = { +	[0] = { +		.start	= AT91SAM9G45_BASE_ISI, +		.end	= AT91SAM9G45_BASE_ISI + SZ_16K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	[1] = { +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_ISI, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_ISI, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct platform_device at91sam9g45_isi_device = { +	.name		= "atmel_isi", +	.id		= 0, +	.dev		= { +			.dma_mask		= &isi_dmamask, +			.coherent_dma_mask	= DMA_BIT_MASK(32), +			.platform_data		= &isi_data, +	}, +	.resource	= isi_resources, +	.num_resources	= ARRAY_SIZE(isi_resources), +}; + +static struct clk_lookup isi_mck_lookups[] = { +	CLKDEV_CON_DEV_ID("isi_mck", "atmel_isi.0", NULL), +}; + +void __init at91_add_device_isi(struct isi_platform_data *data, +		bool use_pck_as_mck) +{ +	struct clk *pck; +	struct clk *parent; + +	if (!data) +		return; +	isi_data = *data; + +	at91_set_A_periph(AT91_PIN_PB20, 0);	/* ISI_D0 */ +	at91_set_A_periph(AT91_PIN_PB21, 0);	/* ISI_D1 */ +	at91_set_A_periph(AT91_PIN_PB22, 0);	/* ISI_D2 */ +	at91_set_A_periph(AT91_PIN_PB23, 0);	/* ISI_D3 */ +	at91_set_A_periph(AT91_PIN_PB24, 0);	/* ISI_D4 */ +	at91_set_A_periph(AT91_PIN_PB25, 0);	/* ISI_D5 */ +	at91_set_A_periph(AT91_PIN_PB26, 0);	/* ISI_D6 */ +	at91_set_A_periph(AT91_PIN_PB27, 0);	/* ISI_D7 */ +	at91_set_A_periph(AT91_PIN_PB28, 0);	/* ISI_PCK */ +	at91_set_A_periph(AT91_PIN_PB30, 0);	/* ISI_HSYNC */ +	at91_set_A_periph(AT91_PIN_PB29, 0);	/* ISI_VSYNC */ +	at91_set_B_periph(AT91_PIN_PB8, 0);	/* ISI_PD8 */ +	at91_set_B_periph(AT91_PIN_PB9, 0);	/* ISI_PD9 */ +	at91_set_B_periph(AT91_PIN_PB10, 0);	/* ISI_PD10 */ +	at91_set_B_periph(AT91_PIN_PB11, 0);	/* ISI_PD11 */ + +	platform_device_register(&at91sam9g45_isi_device); + +	if (use_pck_as_mck) { +		at91_set_B_periph(AT91_PIN_PB31, 0);	/* ISI_MCK (PCK1) */ + +		pck = clk_get(NULL, "pck1"); +		parent = clk_get(NULL, "plla"); + +		BUG_ON(IS_ERR(pck) || IS_ERR(parent)); + +		if (clk_set_parent(pck, parent)) { +			pr_err("Failed to set PCK's parent\n"); +		} else { +			/* Register PCK as ISI_MCK */ +			isi_mck_lookups[0].clk = pck; +			clkdev_add_table(isi_mck_lookups, +					ARRAY_SIZE(isi_mck_lookups)); +		} + +		clk_put(pck); +		clk_put(parent); +	} +} +#else +void __init at91_add_device_isi(struct isi_platform_data *data, +		bool use_pck_as_mck) {} +#endif +  /* --------------------------------------------------------------------   *  LCD Controller @@ -879,7 +966,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}  #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)  static u64 lcdc_dmamask = DMA_BIT_MASK(32); -static struct atmel_lcdfb_info lcdc_data; +static struct atmel_lcdfb_pdata lcdc_data;  static struct resource lcdc_resources[] = {  	[0] = { @@ -888,14 +975,13 @@ static struct resource lcdc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_LCDC, -		.end	= AT91SAM9G45_ID_LCDC, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_LCDC, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_LCDC,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91_lcdc_device = { -	.name		= "atmel_lcdfb",  	.id		= 0,  	.dev		= {  				.dma_mask		= &lcdc_dmamask, @@ -906,11 +992,16 @@ static struct platform_device at91_lcdc_device = {  	.num_resources	= ARRAY_SIZE(lcdc_resources),  }; -void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) +void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data)  {  	if (!data)  		return; +	if (cpu_is_at91sam9g45es()) +		at91_lcdc_device.name = "at91sam9g45es-lcdfb"; +	else +		at91_lcdc_device.name = "at91sam9g45-lcdfb"; +  	at91_set_A_periph(AT91_PIN_PE0, 0);	/* LCDDPWR */  	at91_set_A_periph(AT91_PIN_PE2, 0);	/* LCDCC */ @@ -947,7 +1038,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)  	platform_device_register(&at91_lcdc_device);  }  #else -void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} +void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data) {}  #endif @@ -959,12 +1050,12 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}  static struct resource tcb0_resources[] = {  	[0] = {  		.start	= AT91SAM9G45_BASE_TCB0, -		.end	= AT91SAM9G45_BASE_TCB0 + SZ_16K - 1, +		.end	= AT91SAM9G45_BASE_TCB0 + SZ_256 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_TCB, -		.end	= AT91SAM9G45_ID_TCB, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -980,12 +1071,12 @@ static struct platform_device at91sam9g45_tcb0_device = {  static struct resource tcb1_resources[] = {  	[0] = {  		.start	= AT91SAM9G45_BASE_TCB1, -		.end	= AT91SAM9G45_BASE_TCB1 + SZ_16K - 1, +		.end	= AT91SAM9G45_BASE_TCB1 + SZ_256 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_TCB, -		.end	= AT91SAM9G45_ID_TCB, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -999,10 +1090,7 @@ static struct platform_device at91sam9g45_tcb1_device = {  static void __init at91_add_device_tc(void)  { -	/* this chip has one clock and irq for all six TC channels */ -	at91_clock_associate("tcb0_clk", &at91sam9g45_tcb0_device.dev, "t0_clk");  	platform_device_register(&at91sam9g45_tcb0_device); -	at91_clock_associate("tcb1_clk", &at91sam9g45_tcb1_device.dev, "t0_clk");  	platform_device_register(&at91sam9g45_tcb1_device);  }  #else @@ -1015,10 +1103,24 @@ static void __init at91_add_device_tc(void) { }   * -------------------------------------------------------------------- */  #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE) +static struct resource rtc_resources[] = { +	[0] = { +		.start	= AT91SAM9G45_BASE_RTC, +		.end	= AT91SAM9G45_BASE_RTC + SZ_256 - 1, +		.flags	= IORESOURCE_MEM, +	}, +	[1] = { +		.start	= NR_IRQS_LEGACY + AT91_ID_SYS, +		.end	= NR_IRQS_LEGACY + AT91_ID_SYS, +		.flags	= IORESOURCE_IRQ, +	}, +}; +  static struct platform_device at91sam9g45_rtc_device = {  	.name		= "at91_rtc",  	.id		= -1, -	.num_resources	= 0, +	.resource	= rtc_resources, +	.num_resources	= ARRAY_SIZE(rtc_resources),  };  static void __init at91_add_device_rtc(void) @@ -1031,65 +1133,107 @@ static void __init at91_add_device_rtc(void) {}  /* -------------------------------------------------------------------- - *  Touchscreen + *  ADC and touchscreen   * -------------------------------------------------------------------- */ -#if defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) || defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC_MODULE) -static u64 tsadcc_dmamask = DMA_BIT_MASK(32); -static struct at91_tsadcc_data tsadcc_data; +#if IS_ENABLED(CONFIG_AT91_ADC) +static struct at91_adc_data adc_data; -static struct resource tsadcc_resources[] = { +static struct resource adc_resources[] = {  	[0] = {  		.start	= AT91SAM9G45_BASE_TSC,  		.end	= AT91SAM9G45_BASE_TSC + SZ_16K - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_TSC, -		.end	= AT91SAM9G45_ID_TSC, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC,  		.flags	= IORESOURCE_IRQ,  	}  }; -static struct platform_device at91sam9g45_tsadcc_device = { -	.name		= "atmel_tsadcc", +static struct platform_device at91_adc_device = { +	.name		= "at91sam9g45-adc",  	.id		= -1,  	.dev		= { -				.dma_mask		= &tsadcc_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &tsadcc_data, +				.platform_data	= &adc_data, +	}, +	.resource	= adc_resources, +	.num_resources	= ARRAY_SIZE(adc_resources), +}; + +static struct at91_adc_trigger at91_adc_triggers[] = { +	[0] = { +		.name = "external-rising", +		.value = 1, +		.is_external = true, +	}, +	[1] = { +		.name = "external-falling", +		.value = 2, +		.is_external = true, +	}, +	[2] = { +		.name = "external-any", +		.value = 3, +		.is_external = true, +	}, +	[3] = { +		.name = "continuous", +		.value = 6, +		.is_external = false,  	}, -	.resource	= tsadcc_resources, -	.num_resources	= ARRAY_SIZE(tsadcc_resources),  }; -void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) +void __init at91_add_device_adc(struct at91_adc_data *data)  {  	if (!data)  		return; -	at91_set_gpio_input(AT91_PIN_PD20, 0);	/* AD0_XR */ -	at91_set_gpio_input(AT91_PIN_PD21, 0);	/* AD1_XL */ -	at91_set_gpio_input(AT91_PIN_PD22, 0);	/* AD2_YT */ -	at91_set_gpio_input(AT91_PIN_PD23, 0);	/* AD3_TB */ - -	tsadcc_data = *data; -	platform_device_register(&at91sam9g45_tsadcc_device); +	if (test_bit(0, &data->channels_used)) +		at91_set_gpio_input(AT91_PIN_PD20, 0); +	if (test_bit(1, &data->channels_used)) +		at91_set_gpio_input(AT91_PIN_PD21, 0); +	if (test_bit(2, &data->channels_used)) +		at91_set_gpio_input(AT91_PIN_PD22, 0); +	if (test_bit(3, &data->channels_used)) +		at91_set_gpio_input(AT91_PIN_PD23, 0); +	if (test_bit(4, &data->channels_used)) +		at91_set_gpio_input(AT91_PIN_PD24, 0); +	if (test_bit(5, &data->channels_used)) +		at91_set_gpio_input(AT91_PIN_PD25, 0); +	if (test_bit(6, &data->channels_used)) +		at91_set_gpio_input(AT91_PIN_PD26, 0); +	if (test_bit(7, &data->channels_used)) +		at91_set_gpio_input(AT91_PIN_PD27, 0); + +	if (data->use_external_triggers) +		at91_set_A_periph(AT91_PIN_PD28, 0); + +	data->startup_time = 40; +	data->trigger_number = 4; +	data->trigger_list = at91_adc_triggers; + +	adc_data = *data; +	platform_device_register(&at91_adc_device);  }  #else -void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {} +void __init at91_add_device_adc(struct at91_adc_data *data) {}  #endif -  /* --------------------------------------------------------------------   *  RTT   * -------------------------------------------------------------------- */  static struct resource rtt_resources[] = {  	{ -		.start	= AT91_BASE_SYS + AT91_RTT, -		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1, +		.start	= AT91SAM9G45_BASE_RTT, +		.end	= AT91SAM9G45_BASE_RTT + SZ_16 - 1, +		.flags	= IORESOURCE_MEM, +	}, {  		.flags	= IORESOURCE_MEM, +	}, { +		.flags  = IORESOURCE_IRQ,  	}  }; @@ -1097,24 +1241,84 @@ static struct platform_device at91sam9g45_rtt_device = {  	.name		= "at91_rtt",  	.id		= 0,  	.resource	= rtt_resources, -	.num_resources	= ARRAY_SIZE(rtt_resources),  }; +#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9) +static void __init at91_add_device_rtt_rtc(void) +{ +	at91sam9g45_rtt_device.name = "rtc-at91sam9"; +	/* +	 * The second resource is needed: +	 * GPBR will serve as the storage for RTC time offset +	 */ +	at91sam9g45_rtt_device.num_resources = 3; +	rtt_resources[1].start = AT91SAM9G45_BASE_GPBR + +				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; +	rtt_resources[1].end = rtt_resources[1].start + 3; +	rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS; +	rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS; +} +#else +static void __init at91_add_device_rtt_rtc(void) +{ +	/* Only one resource is needed: RTT not used as RTC */ +	at91sam9g45_rtt_device.num_resources = 1; +} +#endif +  static void __init at91_add_device_rtt(void)  { +	at91_add_device_rtt_rtc();  	platform_device_register(&at91sam9g45_rtt_device);  }  /* -------------------------------------------------------------------- + *  TRNG + * -------------------------------------------------------------------- */ + +#if defined(CONFIG_HW_RANDOM_ATMEL) || defined(CONFIG_HW_RANDOM_ATMEL_MODULE) +static struct resource trng_resources[] = { +	{ +		.start	= AT91SAM9G45_BASE_TRNG, +		.end	= AT91SAM9G45_BASE_TRNG + SZ_16K - 1, +		.flags	= IORESOURCE_MEM, +	}, +}; + +static struct platform_device at91sam9g45_trng_device = { +	.name		= "atmel-trng", +	.id		= -1, +	.resource	= trng_resources, +	.num_resources	= ARRAY_SIZE(trng_resources), +}; + +static void __init at91_add_device_trng(void) +{ +	platform_device_register(&at91sam9g45_trng_device); +} +#else +static void __init at91_add_device_trng(void) {} +#endif + +/* --------------------------------------------------------------------   *  Watchdog   * -------------------------------------------------------------------- */  #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) +static struct resource wdt_resources[] = { +	{ +		.start	= AT91SAM9G45_BASE_WDT, +		.end	= AT91SAM9G45_BASE_WDT + SZ_16 - 1, +		.flags	= IORESOURCE_MEM, +	} +}; +  static struct platform_device at91sam9g45_wdt_device = {  	.name		= "at91_wdt",  	.id		= -1, -	.num_resources	= 0, +	.resource	= wdt_resources, +	.num_resources	= ARRAY_SIZE(wdt_resources),  };  static void __init at91_add_device_watchdog(void) @@ -1140,8 +1344,8 @@ static struct resource pwm_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_PWMC, -		.end	= AT91SAM9G45_ID_PWMC, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_PWMC, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_PWMC,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1193,14 +1397,14 @@ static struct resource ssc0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_SSC0, -		.end	= AT91SAM9G45_ID_SSC0, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC0, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC0,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9g45_ssc0_device = { -	.name	= "ssc", +	.name	= "at91sam9g45_ssc",  	.id	= 0,  	.dev	= {  		.dma_mask		= &ssc0_dmamask, @@ -1235,14 +1439,14 @@ static struct resource ssc1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_SSC1, -		.end	= AT91SAM9G45_ID_SSC1, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC1, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC1,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9g45_ssc1_device = { -	.name	= "ssc", +	.name	= "at91sam9g45_ssc",  	.id	= 1,  	.dev	= {  		.dma_mask		= &ssc1_dmamask, @@ -1286,12 +1490,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)  	case AT91SAM9G45_ID_SSC0:  		pdev = &at91sam9g45_ssc0_device;  		configure_ssc0_pins(pins); -		at91_clock_associate("ssc0_clk", &pdev->dev, "pclk");  		break;  	case AT91SAM9G45_ID_SSC1:  		pdev = &at91sam9g45_ssc1_device;  		configure_ssc1_pins(pins); -		at91_clock_associate("ssc1_clk", &pdev->dev, "pclk");  		break;  	default:  		return; @@ -1312,13 +1514,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}  #if defined(CONFIG_SERIAL_ATMEL)  static struct resource dbgu_resources[] = {  	[0] = { -		.start	= AT91_VA_BASE_SYS + AT91_DBGU, -		.end	= AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, +		.start	= AT91SAM9G45_BASE_DBGU, +		.end	= AT91SAM9G45_BASE_DBGU + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91_ID_SYS, -		.end	= AT91_ID_SYS, +		.start	= NR_IRQS_LEGACY + AT91_ID_SYS, +		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1326,7 +1528,6 @@ static struct resource dbgu_resources[] = {  static struct atmel_uart_data dbgu_data = {  	.use_dma_tx	= 0,  	.use_dma_rx	= 0, -	.regs		= (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),  };  static u64 dbgu_dmamask = DMA_BIT_MASK(32); @@ -1356,8 +1557,8 @@ static struct resource uart0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_US0, -		.end	= AT91SAM9G45_ID_US0, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_US0, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_US0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1399,8 +1600,8 @@ static struct resource uart1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_US1, -		.end	= AT91SAM9G45_ID_US1, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_US1, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_US1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1442,8 +1643,8 @@ static struct resource uart2_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_US2, -		.end	= AT91SAM9G45_ID_US2, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_US2, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_US2,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1485,8 +1686,8 @@ static struct resource uart3_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9G45_ID_US3, -		.end	= AT91SAM9G45_ID_US3, +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_US3, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_US3,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1522,53 +1723,43 @@ static inline void configure_usart3_pins(unsigned pins)  }  static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */ -struct platform_device *atmel_default_console_device;	/* the serial console device */  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)  {  	struct platform_device *pdev; +	struct atmel_uart_data *pdata;  	switch (id) {  		case 0:		/* DBGU */  			pdev = &at91sam9g45_dbgu_device;  			configure_dbgu_pins(); -			at91_clock_associate("mck", &pdev->dev, "usart");  			break;  		case AT91SAM9G45_ID_US0:  			pdev = &at91sam9g45_uart0_device;  			configure_usart0_pins(pins); -			at91_clock_associate("usart0_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9G45_ID_US1:  			pdev = &at91sam9g45_uart1_device;  			configure_usart1_pins(pins); -			at91_clock_associate("usart1_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9G45_ID_US2:  			pdev = &at91sam9g45_uart2_device;  			configure_usart2_pins(pins); -			at91_clock_associate("usart2_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9G45_ID_US3:  			pdev = &at91sam9g45_uart3_device;  			configure_usart3_pins(pins); -			at91_clock_associate("usart3_clk", &pdev->dev, "usart");  			break;  		default:  			return;  	} -	pdev->id = portnr;		/* update to mapped ID */ +	pdata = pdev->dev.platform_data; +	pdata->num = portnr;		/* update to mapped ID */  	if (portnr < ATMEL_MAX_UART)  		at91_uarts[portnr] = pdev;  } -void __init at91_set_serial_console(unsigned portnr) -{ -	if (portnr < ATMEL_MAX_UART) -		atmel_default_console_device = at91_uarts[portnr]; -} -  void __init at91_add_device_serial(void)  {  	int i; @@ -1577,16 +1768,134 @@ void __init at91_add_device_serial(void)  		if (at91_uarts[i])  			platform_device_register(at91_uarts[i]);  	} - -	if (!atmel_default_console_device) -		printk(KERN_INFO "AT91: No default serial console defined.\n");  }  #else  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {}  void __init at91_add_device_serial(void) {}  #endif +/* -------------------------------------------------------------------- + *  SHA1/SHA256 + * -------------------------------------------------------------------- */ + +#if defined(CONFIG_CRYPTO_DEV_ATMEL_SHA) || defined(CONFIG_CRYPTO_DEV_ATMEL_SHA_MODULE) +static struct resource sha_resources[] = { +	{ +		.start	= AT91SAM9G45_BASE_SHA, +		.end	= AT91SAM9G45_BASE_SHA + SZ_16K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	[1] = { +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct platform_device at91sam9g45_sha_device = { +	.name	= "atmel_sha", +	.id		= -1, +	.resource	= sha_resources, +	.num_resources	= ARRAY_SIZE(sha_resources), +}; + +static void __init at91_add_device_sha(void) +{ +	platform_device_register(&at91sam9g45_sha_device); +} +#else +static void __init at91_add_device_sha(void) {} +#endif + +/* -------------------------------------------------------------------- + *  DES/TDES + * -------------------------------------------------------------------- */ + +#if defined(CONFIG_CRYPTO_DEV_ATMEL_TDES) || defined(CONFIG_CRYPTO_DEV_ATMEL_TDES_MODULE) +static struct resource tdes_resources[] = { +	[0] = { +		.start	= AT91SAM9G45_BASE_TDES, +		.end	= AT91SAM9G45_BASE_TDES + SZ_16K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	[1] = { +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct platform_device at91sam9g45_tdes_device = { +	.name	= "atmel_tdes", +	.id		= -1, +	.resource	= tdes_resources, +	.num_resources	= ARRAY_SIZE(tdes_resources), +}; + +static void __init at91_add_device_tdes(void) +{ +	platform_device_register(&at91sam9g45_tdes_device); +} +#else +static void __init at91_add_device_tdes(void) {} +#endif + +/* -------------------------------------------------------------------- + *  AES + * -------------------------------------------------------------------- */ + +#if defined(CONFIG_CRYPTO_DEV_ATMEL_AES) || defined(CONFIG_CRYPTO_DEV_ATMEL_AES_MODULE) +static struct crypto_platform_data aes_data; +static struct crypto_dma_data alt_atslave; +static u64 aes_dmamask = DMA_BIT_MASK(32); + +static struct resource aes_resources[] = { +	[0] = { +		.start	= AT91SAM9G45_BASE_AES, +		.end	= AT91SAM9G45_BASE_AES + SZ_16K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	[1] = { +		.start	= NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, +		.end	= NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct platform_device at91sam9g45_aes_device = { +	.name	= "atmel_aes", +	.id		= -1, +	.dev	= { +		.dma_mask		= &aes_dmamask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +		.platform_data		= &aes_data, +	}, +	.resource	= aes_resources, +	.num_resources	= ARRAY_SIZE(aes_resources), +}; + +static void __init at91_add_device_aes(void) +{ +	struct at_dma_slave	*atslave; + +	/* DMA TX slave channel configuration */ +	atslave = &alt_atslave.txdata; +	atslave->dma_dev = &at_hdmac_device.dev; +	atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE	| ATC_SRC_H2SEL_HW | +						ATC_SRC_PER(AT_DMA_ID_AES_RX); + +	/* DMA RX slave channel configuration */ +	atslave = &alt_atslave.rxdata; +	atslave->dma_dev = &at_hdmac_device.dev; +	atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE	| ATC_DST_H2SEL_HW | +						ATC_DST_PER(AT_DMA_ID_AES_TX); + +	aes_data.dma_slave = &alt_atslave; +	platform_device_register(&at91sam9g45_aes_device); +} +#else +static void __init at91_add_device_aes(void) {} +#endif  /* -------------------------------------------------------------------- */  /* @@ -1595,11 +1904,18 @@ void __init at91_add_device_serial(void) {}   */  static int __init at91_add_standard_devices(void)  { +	if (of_have_populated_dt()) +		return 0; +  	at91_add_device_hdmac();  	at91_add_device_rtc();  	at91_add_device_rtt(); +	at91_add_device_trng();  	at91_add_device_watchdog();  	at91_add_device_tc(); +	at91_add_device_sha(); +	at91_add_device_tdes(); +	at91_add_device_aes();  	return 0;  } diff --git a/arch/arm/mach-at91/at91sam9g45_reset.S b/arch/arm/mach-at91/at91sam9g45_reset.S new file mode 100644 index 00000000000..c40c1e2ef80 --- /dev/null +++ b/arch/arm/mach-at91/at91sam9g45_reset.S @@ -0,0 +1,45 @@ +/* + * reset AT91SAM9G45 as per errata + * + * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcosoft.com> + * + * unless the SDRAM is cleanly shutdown before we hit the + * reset register it can be left driving the data bus and + * killing the chance of a subsequent boot from NAND + * + * GPLv2 Only + */ + +#include <linux/linkage.h> +#include <mach/hardware.h> +#include <mach/at91_ramc.h> +#include "at91_rstc.h" +			.arm + +/* + * at91_ramc_base is an array void* + * init at NULL if only one DDR controler is present in or DT + */ +			.globl	at91sam9g45_restart + +at91sam9g45_restart: +			ldr	r5, =at91_ramc_base		@ preload constants +			ldr	r0, [r5] +			ldr	r5, [r5, #4]			@ ddr1 +			cmp	r5, #0 +			ldr	r4, =at91_rstc_base +			ldr	r1, [r4] + +			mov	r2, #1 +			mov	r3, #AT91_DDRSDRC_LPCB_POWER_DOWN +			ldr	r4, =AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST + +			.balign	32				@ align to cache line + +			strne	r2, [r5, #AT91_DDRSDRC_RTR]	@ disable DDR1 access +			strne	r3, [r5, #AT91_DDRSDRC_LPR]	@ power down DDR1 +			str	r2, [r0, #AT91_DDRSDRC_RTR]	@ disable DDR0 access +			str	r3, [r0, #AT91_DDRSDRC_LPR]	@ power down DDR0 +			str	r4, [r1, #AT91_RSTC_CR]		@ reset processor + +			b	. diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c new file mode 100644 index 00000000000..c8988fe5ff7 --- /dev/null +++ b/arch/arm/mach-at91/at91sam9n12.c @@ -0,0 +1,241 @@ +/* + * SoC specific setup code for the AT91SAM9N12 + * + * Copyright (C) 2012 Atmel Corporation. + * + * Licensed under GPLv2 or later. + */ + +#include <linux/module.h> +#include <linux/dma-mapping.h> +#include <linux/clk/at91_pmc.h> + +#include <asm/irq.h> +#include <asm/mach/arch.h> +#include <asm/mach/map.h> +#include <mach/at91sam9n12.h> +#include <mach/cpu.h> + +#include "board.h" +#include "soc.h" +#include "generic.h" +#include "sam9_smc.h" + +#if defined(CONFIG_OLD_CLK_AT91) +#include "clock.h" +/* -------------------------------------------------------------------- + *  Clocks + * -------------------------------------------------------------------- */ + +/* + * The peripheral clocks. + */ +static struct clk pioAB_clk = { +	.name		= "pioAB_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_PIOAB, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk pioCD_clk = { +	.name		= "pioCD_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_PIOCD, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk usart0_clk = { +	.name		= "usart0_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_USART0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk usart1_clk = { +	.name		= "usart1_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_USART1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk usart2_clk = { +	.name		= "usart2_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_USART2, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk usart3_clk = { +	.name		= "usart3_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_USART3, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk twi0_clk = { +	.name		= "twi0_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_TWI0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk twi1_clk = { +	.name		= "twi1_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_TWI1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk mmc_clk = { +	.name		= "mci_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_MCI, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk spi0_clk = { +	.name		= "spi0_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_SPI0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk spi1_clk = { +	.name		= "spi1_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_SPI1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk uart0_clk = { +	.name		= "uart0_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_UART0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk uart1_clk = { +	.name		= "uart1_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_UART1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk tcb_clk = { +	.name		= "tcb_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_TCB, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk pwm_clk = { +	.name		= "pwm_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_PWM, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk adc_clk = { +	.name		= "adc_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_ADC, +	.type	= CLK_TYPE_PERIPHERAL, +}; +static struct clk dma_clk = { +	.name		= "dma_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_DMA, +	.type	= CLK_TYPE_PERIPHERAL, +}; +static struct clk uhp_clk = { +	.name		= "uhp", +	.pmc_mask	= 1 << AT91SAM9N12_ID_UHP, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk udp_clk = { +	.name		= "udp_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_UDP, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk lcdc_clk = { +	.name		= "lcdc_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_LCDC, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk ssc_clk = { +	.name		= "ssc_clk", +	.pmc_mask	= 1 << AT91SAM9N12_ID_SSC, +	.type		= CLK_TYPE_PERIPHERAL, +}; + +static struct clk *periph_clocks[] __initdata = { +	&pioAB_clk, +	&pioCD_clk, +	&usart0_clk, +	&usart1_clk, +	&usart2_clk, +	&usart3_clk, +	&twi0_clk, +	&twi1_clk, +	&mmc_clk, +	&spi0_clk, +	&spi1_clk, +	&lcdc_clk, +	&uart0_clk, +	&uart1_clk, +	&tcb_clk, +	&pwm_clk, +	&adc_clk, +	&dma_clk, +	&uhp_clk, +	&udp_clk, +	&ssc_clk, +}; + +static struct clk_lookup periph_clocks_lookups[] = { +	/* lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck), +	CLKDEV_CON_DEV_ID("usart", "f801c000.serial", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "f8020000.serial", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "f8024000.serial", &usart2_clk), +	CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc_clk), +	CLKDEV_CON_DEV_ID(NULL, "f0010000.ssc", &ssc_clk), +	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma_clk), +	CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk), +	CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "f0000000.spi", &spi0_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "f0004000.spi", &spi1_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioAB_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioAB_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioCD_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioCD_clk), +	/* additional fake clock for macb_hclk */ +	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &uhp_clk), +	CLKDEV_CON_DEV_ID("ohci_clk", "500000.ohci", &uhp_clk), +	CLKDEV_CON_DEV_ID(NULL, "f8034000.pwm", &pwm_clk), +}; + +/* + * The two programmable clocks. + * You must configure pin multiplexing to bring these signals out. + */ +static struct clk pck0 = { +	.name		= "pck0", +	.pmc_mask	= AT91_PMC_PCK0, +	.type		= CLK_TYPE_PROGRAMMABLE, +	.id		= 0, +}; +static struct clk pck1 = { +	.name		= "pck1", +	.pmc_mask	= AT91_PMC_PCK1, +	.type		= CLK_TYPE_PROGRAMMABLE, +	.id		= 1, +}; + +static void __init at91sam9n12_register_clocks(void) +{ +	int i; + +	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) +		clk_register(periph_clocks[i]); +	clk_register(&pck0); +	clk_register(&pck1); + +	clkdev_add_table(periph_clocks_lookups, +			 ARRAY_SIZE(periph_clocks_lookups)); + +} +#else +#define at91sam9n12_register_clocks NULL +#endif + +/* -------------------------------------------------------------------- + *  AT91SAM9N12 processor initialization + * -------------------------------------------------------------------- */ + +static void __init at91sam9n12_map_io(void) +{ +	at91_init_sram(0, AT91SAM9N12_SRAM_BASE, AT91SAM9N12_SRAM_SIZE); +} + +static void __init at91sam9n12_initialize(void) +{ +	at91_sysirq_mask_rtc(AT91SAM9N12_BASE_RTC); +} + +AT91_SOC_START(at91sam9n12) +	.map_io = at91sam9n12_map_io, +	.register_clocks = at91sam9n12_register_clocks, +	.init = at91sam9n12_initialize, +AT91_SOC_END diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c index 6a9d24e5ed8..a79960f57e6 100644 --- a/arch/arm/mach-at91/at91sam9rl.c +++ b/arch/arm/mach-at91/at91sam9rl.c @@ -10,39 +10,30 @@   */  #include <linux/module.h> -#include <linux/pm.h> +#include <linux/clk/at91_pmc.h> +#include <asm/proc-fns.h>  #include <asm/irq.h>  #include <asm/mach/arch.h>  #include <asm/mach/map.h> +#include <asm/system_misc.h>  #include <mach/cpu.h> +#include <mach/at91_dbgu.h>  #include <mach/at91sam9rl.h> -#include <mach/at91_pmc.h> -#include <mach/at91_rstc.h> -#include <mach/at91_shdwc.h> +#include <mach/hardware.h> +#include "at91_aic.h" +#include "at91_rstc.h" +#include "soc.h"  #include "generic.h" -#include "clock.h" - -static struct map_desc at91sam9rl_io_desc[] __initdata = { -	{ -		.virtual	= AT91_VA_BASE_SYS, -		.pfn		= __phys_to_pfn(AT91_BASE_SYS), -		.length		= SZ_16K, -		.type		= MT_DEVICE, -	}, -}; - -static struct map_desc at91sam9rl_sram_desc[] __initdata = { -	{ -		.pfn		= __phys_to_pfn(AT91SAM9RL_SRAM_BASE), -		.type		= MT_DEVICE, -	} -}; +#include "sam9_smc.h" +#include "pm.h"  /* --------------------------------------------------------------------   *  Clocks   * -------------------------------------------------------------------- */ +#if defined(CONFIG_OLD_CLK_AT91) +#include "clock.h"  /*   * The peripheral clocks. @@ -162,6 +153,11 @@ static struct clk ac97_clk = {  	.pmc_mask	= 1 << AT91SAM9RL_ID_AC97C,  	.type		= CLK_TYPE_PERIPHERAL,  }; +static struct clk adc_op_clk = { +	.name		= "adc_op_clk", +	.type		= CLK_TYPE_PERIPHERAL, +	.rate_hz	= 1000000, +};  static struct clk *periph_clocks[] __initdata = {  	&pioA_clk, @@ -187,9 +183,56 @@ static struct clk *periph_clocks[] __initdata = {  	&udphs_clk,  	&lcdc_clk,  	&ac97_clk, +	&adc_op_clk,  	// irq0  }; +static struct clk_lookup periph_clocks_lookups[] = { +	CLKDEV_CON_DEV_ID("hclk", "at91sam9rl-lcdfb.0", &lcdc_clk), +	CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc", &utmi_clk), +	CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc", &udphs_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk), +	CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk), +	CLKDEV_CON_DEV_ID("pclk", "fffc0000.ssc", &ssc0_clk), +	CLKDEV_CON_DEV_ID("pclk", "fffc4000.ssc", &ssc1_clk), +	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi0_clk), +	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.1", &twi1_clk), +	CLKDEV_CON_ID("pioA", &pioA_clk), +	CLKDEV_CON_ID("pioB", &pioB_clk), +	CLKDEV_CON_ID("pioC", &pioC_clk), +	CLKDEV_CON_ID("pioD", &pioD_clk), +	/* more lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck), +	CLKDEV_CON_DEV_ID("usart", "fffb0000.serial", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "ffffb400.serial", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "ffffb800.serial", &usart2_clk), +	CLKDEV_CON_DEV_ID("usart", "ffffbc00.serial", &usart3_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "fffa0000.timer", &tc0_clk), +	CLKDEV_CON_DEV_ID("t1_clk", "fffa0000.timer", &tc1_clk), +	CLKDEV_CON_DEV_ID("t2_clk", "fffa0000.timer", &tc2_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "fffa4000.mmc", &mmc_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffa8000.i2c", &twi0_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffac000.i2c", &twi1_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffc8000.pwm", &pwm_clk), +	CLKDEV_CON_DEV_ID(NULL, "ffffc800.pwm", &pwm_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioA_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioB_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioC_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioD_clk), +	CLKDEV_CON_ID("adc_clk", &tsc_clk), +}; + +static struct clk_lookup usart_clocks_lookups[] = { +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), +	CLKDEV_CON_DEV_ID("usart", "atmel_usart.4", &usart3_clk), +}; +  /*   * The two programmable clocks.   * You must configure pin multiplexing to bring these signals out. @@ -214,54 +257,45 @@ static void __init at91sam9rl_register_clocks(void)  	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)  		clk_register(periph_clocks[i]); +	clkdev_add_table(periph_clocks_lookups, +			 ARRAY_SIZE(periph_clocks_lookups)); +	clkdev_add_table(usart_clocks_lookups, +			 ARRAY_SIZE(usart_clocks_lookups)); +  	clk_register(&pck0);  	clk_register(&pck1);  } +#endif  /* --------------------------------------------------------------------   *  GPIO   * -------------------------------------------------------------------- */ -static struct at91_gpio_bank at91sam9rl_gpio[] = { +static struct at91_gpio_bank at91sam9rl_gpio[] __initdata = {  	{  		.id		= AT91SAM9RL_ID_PIOA, -		.offset		= AT91_PIOA, -		.clock		= &pioA_clk, +		.regbase	= AT91SAM9RL_BASE_PIOA,  	}, {  		.id		= AT91SAM9RL_ID_PIOB, -		.offset		= AT91_PIOB, -		.clock		= &pioB_clk, +		.regbase	= AT91SAM9RL_BASE_PIOB,  	}, {  		.id		= AT91SAM9RL_ID_PIOC, -		.offset		= AT91_PIOC, -		.clock		= &pioC_clk, +		.regbase	= AT91SAM9RL_BASE_PIOC,  	}, {  		.id		= AT91SAM9RL_ID_PIOD, -		.offset		= AT91_PIOD, -		.clock		= &pioD_clk, +		.regbase	= AT91SAM9RL_BASE_PIOD,  	}  }; -static void at91sam9rl_poweroff(void) -{ -	at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); -} - -  /* --------------------------------------------------------------------   *  AT91SAM9RL processor initialization   * -------------------------------------------------------------------- */ -void __init at91sam9rl_initialize(unsigned long main_clock) +static void __init at91sam9rl_map_io(void)  { -	unsigned long cidr, sram_size; +	unsigned long sram_size; -	/* Map peripherals */ -	iotable_init(at91sam9rl_io_desc, ARRAY_SIZE(at91sam9rl_io_desc)); - -	cidr = at91_sys_read(AT91_DBGU_CIDR); - -	switch (cidr & AT91_CIDR_SRAMSIZ) { +	switch (at91_soc_initdata.cidr & AT91_CIDR_SRAMSIZ) {  		case AT91_CIDR_SRAMSIZ_32K:  			sram_size = 2 * SZ_16K;  			break; @@ -270,21 +304,28 @@ void __init at91sam9rl_initialize(unsigned long main_clock)  			sram_size = SZ_16K;  	} -	at91sam9rl_sram_desc->virtual = AT91_IO_VIRT_BASE - sram_size; -	at91sam9rl_sram_desc->length = sram_size; -  	/* Map SRAM */ -	iotable_init(at91sam9rl_sram_desc, ARRAY_SIZE(at91sam9rl_sram_desc)); +	at91_init_sram(0, AT91SAM9RL_SRAM_BASE, sram_size); +} -	at91_arch_reset = at91sam9_alt_reset; -	pm_power_off = at91sam9rl_poweroff; -	at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0); +static void __init at91sam9rl_ioremap_registers(void) +{ +	at91_ioremap_shdwc(AT91SAM9RL_BASE_SHDWC); +	at91_ioremap_rstc(AT91SAM9RL_BASE_RSTC); +	at91_ioremap_ramc(0, AT91SAM9RL_BASE_SDRAMC, 512); +	at91sam926x_ioremap_pit(AT91SAM9RL_BASE_PIT); +	at91sam9_ioremap_smc(0, AT91SAM9RL_BASE_SMC); +	at91_ioremap_matrix(AT91SAM9RL_BASE_MATRIX); +	at91_pm_set_standby(at91sam9_sdram_standby); +} -	/* Init clock subsystem */ -	at91_clock_init(main_clock); +static void __init at91sam9rl_initialize(void) +{ +	arm_pm_idle = at91sam9_idle; +	arm_pm_restart = at91sam9_alt_restart; -	/* Register the processor-specific clocks */ -	at91sam9rl_register_clocks(); +	at91_sysirq_mask_rtc(AT91SAM9RL_BASE_RTC); +	at91_sysirq_mask_rtt(AT91SAM9RL_BASE_RTT);  	/* Register GPIO subsystem */  	at91_gpio_init(at91sam9rl_gpio, 4); @@ -332,14 +373,13 @@ static unsigned int at91sam9rl_default_irq_priority[NR_AIC_IRQS] __initdata = {  	0,	/* Advanced Interrupt Controller */  }; -void __init at91sam9rl_init_interrupts(unsigned int priority[NR_AIC_IRQS]) -{ -	if (!priority) -		priority = at91sam9rl_default_irq_priority; - -	/* Initialize the AIC interrupt controller */ -	at91_aic_init(priority); - -	/* Enable GPIO interrupts */ -	at91_gpio_irq_setup(); -} +AT91_SOC_START(at91sam9rl) +	.map_io = at91sam9rl_map_io, +	.default_irq_priority = at91sam9rl_default_irq_priority, +	.extern_irq = (1 << AT91SAM9RL_ID_IRQ0), +	.ioremap_registers = at91sam9rl_ioremap_registers, +#if defined(CONFIG_OLD_CLK_AT91) +	.register_clocks = at91sam9rl_register_clocks, +#endif +	.init = at91sam9rl_initialize, +AT91_SOC_END diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c index 53aaa94df75..0b1d71a7d9b 100644 --- a/arch/arm/mach-at91/at91sam9rl_devices.c +++ b/arch/arm/mach-at91/at91sam9rl_devices.c @@ -10,20 +10,24 @@  #include <asm/mach/map.h>  #include <linux/dma-mapping.h> +#include <linux/gpio.h>  #include <linux/platform_device.h>  #include <linux/i2c-gpio.h>  #include <linux/fb.h>  #include <video/atmel_lcdc.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9rl.h>  #include <mach/at91sam9rl_matrix.h> +#include <mach/at91_matrix.h>  #include <mach/at91sam9_smc.h> -#include <mach/at_hdmac.h> +#include <mach/hardware.h> +#include <linux/platform_data/dma-atmel.h> +#include <linux/platform_data/at91_adc.h> +#include "board.h"  #include "generic.h" +#include "gpio.h"  /* -------------------------------------------------------------------- @@ -33,30 +37,25 @@  #if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)  static u64 hdmac_dmamask = DMA_BIT_MASK(32); -static struct at_dma_platform_data atdma_pdata = { -	.nr_channels	= 2, -}; -  static struct resource hdmac_resources[] = {  	[0] = { -		.start	= AT91_BASE_SYS + AT91_DMA, -		.end	= AT91_BASE_SYS + AT91_DMA + SZ_512 - 1, +		.start	= AT91SAM9RL_BASE_DMA, +		.end	= AT91SAM9RL_BASE_DMA + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[2] = { -		.start	= AT91SAM9RL_ID_DMA, -		.end	= AT91SAM9RL_ID_DMA, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_DMA, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_DMA,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at_hdmac_device = { -	.name		= "at_hdmac", +	.name		= "at91sam9rl_dma",  	.id		= -1,  	.dev		= {  				.dma_mask		= &hdmac_dmamask,  				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &atdma_pdata,  	},  	.resource	= hdmac_resources,  	.num_resources	= ARRAY_SIZE(hdmac_resources), @@ -64,7 +63,6 @@ static struct platform_device at_hdmac_device = {  void __init at91_add_device_hdmac(void)  { -	dma_cap_set(DMA_MEMCPY, atdma_pdata.cap_mask);  	platform_device_register(&at_hdmac_device);  }  #else @@ -75,7 +73,7 @@ void __init at91_add_device_hdmac(void) {}   *  USB HS Device (Gadget)   * -------------------------------------------------------------------- */ -#if defined(CONFIG_USB_GADGET_ATMEL_USBA) || defined(CONFIG_USB_GADGET_ATMEL_USBA_MODULE) +#if defined(CONFIG_USB_ATMEL_USBA) || defined(CONFIG_USB_ATMEL_USBA_MODULE)  static struct resource usba_udc_resources[] = {  	[0] = { @@ -89,8 +87,8 @@ static struct resource usba_udc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[2] = { -		.start	= AT91SAM9RL_ID_UDPHS, -		.end	= AT91SAM9RL_ID_UDPHS, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_UDPHS, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_UDPHS,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -145,9 +143,9 @@ void __init at91_add_device_usba(struct usba_platform_data *data)  	 */  	usba_udc_data.pdata.vbus_pin = -EINVAL;  	usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep); -	memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));; +	memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep)); -	if (data && data->vbus_pin > 0) { +	if (data && gpio_is_valid(data->vbus_pin)) {  		at91_set_gpio_input(data->vbus_pin, 0);  		at91_set_deglitch(data->vbus_pin, 1);  		usba_udc_data.pdata.vbus_pin = data->vbus_pin; @@ -155,10 +153,6 @@ void __init at91_add_device_usba(struct usba_platform_data *data)  	/* Pullup pin is handled internally by USB device peripheral */ -	/* Clocks */ -	at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk"); -	at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk"); -  	platform_device_register(&at91_usba_udc_device);  }  #else @@ -170,9 +164,9 @@ void __init at91_add_device_usba(struct usba_platform_data *data) {}   *  MMC / SD   * -------------------------------------------------------------------- */ -#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) +#if IS_ENABLED(CONFIG_MMC_ATMELMCI)  static u64 mmc_dmamask = DMA_BIT_MASK(32); -static struct at91_mmc_data mmc_data; +static struct mci_platform_data mmc_data;  static struct resource mmc_resources[] = {  	[0] = { @@ -181,14 +175,14 @@ static struct resource mmc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_MCI, -		.end	= AT91SAM9RL_ID_MCI, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_MCI, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_MCI,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9rl_mmc_device = { -	.name		= "at91_mci", +	.name		= "atmel_mci",  	.id		= -1,  	.dev		= {  				.dma_mask		= &mmc_dmamask, @@ -199,40 +193,40 @@ static struct platform_device at91sam9rl_mmc_device = {  	.num_resources	= ARRAY_SIZE(mmc_resources),  }; -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) +void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)  {  	if (!data)  		return; -	/* input/irq */ -	if (data->det_pin) { -		at91_set_gpio_input(data->det_pin, 1); -		at91_set_deglitch(data->det_pin, 1); -	} -	if (data->wp_pin) -		at91_set_gpio_input(data->wp_pin, 1); -	if (data->vcc_pin) -		at91_set_gpio_output(data->vcc_pin, 0); - -	/* CLK */ -	at91_set_A_periph(AT91_PIN_PA2, 0); - -	/* CMD */ -	at91_set_A_periph(AT91_PIN_PA1, 1); - -	/* DAT0, maybe DAT1..DAT3 */ -	at91_set_A_periph(AT91_PIN_PA0, 1); -	if (data->wire4) { -		at91_set_A_periph(AT91_PIN_PA3, 1); -		at91_set_A_periph(AT91_PIN_PA4, 1); -		at91_set_A_periph(AT91_PIN_PA5, 1); +	if (data->slot[0].bus_width) { +		/* input/irq */ +		if (gpio_is_valid(data->slot[0].detect_pin)) { +			at91_set_gpio_input(data->slot[0].detect_pin, 1); +			at91_set_deglitch(data->slot[0].detect_pin, 1); +		} +		if (gpio_is_valid(data->slot[0].wp_pin)) +			at91_set_gpio_input(data->slot[0].wp_pin, 1); + +		/* CLK */ +		at91_set_A_periph(AT91_PIN_PA2, 0); + +		/* CMD */ +		at91_set_A_periph(AT91_PIN_PA1, 1); + +		/* DAT0, maybe DAT1..DAT3 */ +		at91_set_A_periph(AT91_PIN_PA0, 1); +		if (data->slot[0].bus_width == 4) { +			at91_set_A_periph(AT91_PIN_PA3, 1); +			at91_set_A_periph(AT91_PIN_PA4, 1); +			at91_set_A_periph(AT91_PIN_PA5, 1); +		} + +		mmc_data = *data; +		platform_device_register(&at91sam9rl_mmc_device);  	} - -	mmc_data = *data; -	platform_device_register(&at91sam9rl_mmc_device);  }  #else -void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} +void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}  #endif @@ -252,8 +246,8 @@ static struct resource nand_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91_BASE_SYS + AT91_ECC, -		.end	= AT91_BASE_SYS + AT91_ECC + SZ_512 - 1, +		.start	= AT91SAM9RL_BASE_ECC, +		.end	= AT91SAM9RL_BASE_ECC + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	}  }; @@ -275,19 +269,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)  	if (!data)  		return; -	csa = at91_sys_read(AT91_MATRIX_EBICSA); -	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); +	csa = at91_matrix_read(AT91_MATRIX_EBICSA); +	at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);  	/* enable pin */ -	if (data->enable_pin) +	if (gpio_is_valid(data->enable_pin))  		at91_set_gpio_output(data->enable_pin, 1);  	/* ready/busy pin */ -	if (data->rdy_pin) +	if (gpio_is_valid(data->rdy_pin))  		at91_set_gpio_input(data->rdy_pin, 1);  	/* card detect pin */ -	if (data->det_pin) +	if (gpio_is_valid(data->det_pin))  		at91_set_gpio_input(data->det_pin, 1);  	at91_set_A_periph(AT91_PIN_PB4, 0);		/* NANDOE */ @@ -323,7 +317,7 @@ static struct i2c_gpio_platform_data pdata = {  static struct platform_device at91sam9rl_twi_device = {  	.name			= "i2c-gpio", -	.id			= -1, +	.id			= 0,  	.dev.platform_data	= &pdata,  }; @@ -348,15 +342,15 @@ static struct resource twi_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_TWI0, -		.end	= AT91SAM9RL_ID_TWI0, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_TWI0, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_TWI0,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9rl_twi_device = { -	.name		= "at91_i2c", -	.id		= -1, +	.name		= "i2c-at91sam9g20", +	.id		= 0,  	.resource	= twi_resources,  	.num_resources	= ARRAY_SIZE(twi_resources),  }; @@ -392,8 +386,8 @@ static struct resource spi_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_SPI, -		.end	= AT91SAM9RL_ID_SPI, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_SPI, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_SPI,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -428,6 +422,9 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)  		else  			cs_pin = spi_standard_cs[devices[i].chip_select]; +		if (!gpio_is_valid(cs_pin)) +			continue; +  		/* enable chip-select pin */  		at91_set_gpio_output(cs_pin, 1); @@ -458,8 +455,8 @@ static struct resource ac97_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_AC97C, -		.end	= AT91SAM9RL_ID_AC97C, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_AC97C, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_AC97C,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -487,7 +484,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data)  	at91_set_A_periph(AT91_PIN_PD4, 0);	/* AC97RX */  	/* reset */ -	if (data->reset_pin) +	if (gpio_is_valid(data->reset_pin))  		at91_set_gpio_output(data->reset_pin, 0);  	ac97_data = *data; @@ -504,7 +501,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}  #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)  static u64 lcdc_dmamask = DMA_BIT_MASK(32); -static struct atmel_lcdfb_info lcdc_data; +static struct atmel_lcdfb_pdata lcdc_data;  static struct resource lcdc_resources[] = {  	[0] = { @@ -513,14 +510,14 @@ static struct resource lcdc_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_LCDC, -		.end	= AT91SAM9RL_ID_LCDC, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_LCDC, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_LCDC,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91_lcdc_device = { -	.name		= "atmel_lcdfb", +	.name		= "at91sam9rl-lcdfb",  	.id		= 0,  	.dev		= {  				.dma_mask		= &lcdc_dmamask, @@ -531,7 +528,7 @@ static struct platform_device at91_lcdc_device = {  	.num_resources	= ARRAY_SIZE(lcdc_resources),  }; -void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) +void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data)  {  	if (!data) {  		return; @@ -563,7 +560,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)  	platform_device_register(&at91_lcdc_device);  }  #else -void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} +void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data) {}  #endif @@ -580,18 +577,18 @@ static struct resource tcb_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_TC0, -		.end	= AT91SAM9RL_ID_TC0, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_TC0, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_TC0,  		.flags	= IORESOURCE_IRQ,  	},  	[2] = { -		.start	= AT91SAM9RL_ID_TC1, -		.end	= AT91SAM9RL_ID_TC1, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_TC1, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_TC1,  		.flags	= IORESOURCE_IRQ,  	},  	[3] = { -		.start	= AT91SAM9RL_ID_TC2, -		.end	= AT91SAM9RL_ID_TC2, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_TC2, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_TC2,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -605,10 +602,6 @@ static struct platform_device at91sam9rl_tcb_device = {  static void __init at91_add_device_tc(void)  { -	/* this chip has a separate clock and irq for each TC channel */ -	at91_clock_associate("tc0_clk", &at91sam9rl_tcb_device.dev, "t0_clk"); -	at91_clock_associate("tc1_clk", &at91sam9rl_tcb_device.dev, "t1_clk"); -	at91_clock_associate("tc2_clk", &at91sam9rl_tcb_device.dev, "t2_clk");  	platform_device_register(&at91sam9rl_tcb_device);  }  #else @@ -617,56 +610,90 @@ static void __init at91_add_device_tc(void) { }  /* -------------------------------------------------------------------- - *  Touchscreen + *  ADC and Touchscreen   * -------------------------------------------------------------------- */ -#if defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) || defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC_MODULE) -static u64 tsadcc_dmamask = DMA_BIT_MASK(32); -static struct at91_tsadcc_data tsadcc_data; +#if IS_ENABLED(CONFIG_AT91_ADC) +static struct at91_adc_data adc_data; -static struct resource tsadcc_resources[] = { +static struct resource adc_resources[] = {  	[0] = {  		.start	= AT91SAM9RL_BASE_TSC,  		.end	= AT91SAM9RL_BASE_TSC + SZ_16K - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_TSC, -		.end	= AT91SAM9RL_ID_TSC, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_TSC, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_TSC,  		.flags	= IORESOURCE_IRQ,  	}  }; -static struct platform_device at91sam9rl_tsadcc_device = { -	.name		= "atmel_tsadcc", -	.id		= -1, -	.dev		= { -				.dma_mask		= &tsadcc_dmamask, -				.coherent_dma_mask	= DMA_BIT_MASK(32), -				.platform_data		= &tsadcc_data, +static struct platform_device at91_adc_device = { +	.name           = "at91sam9rl-adc", +	.id             = -1, +	.dev            = { +		.platform_data  = &adc_data,  	}, -	.resource	= tsadcc_resources, -	.num_resources	= ARRAY_SIZE(tsadcc_resources), +	.resource       = adc_resources, +	.num_resources  = ARRAY_SIZE(adc_resources),  }; -void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) +static struct at91_adc_trigger at91_adc_triggers[] = { +	[0] = { +		.name = "external-rising", +		.value = 1, +		.is_external = true, +	}, +	[1] = { +		.name = "external-falling", +		.value = 2, +		.is_external = true, +	}, +	[2] = { +		.name = "external-any", +		.value = 3, +		.is_external = true, +	}, +	[3] = { +		.name = "continuous", +		.value = 6, +		.is_external = false, +	}, +}; + +void __init at91_add_device_adc(struct at91_adc_data *data)  {  	if (!data)  		return; -	at91_set_A_periph(AT91_PIN_PA17, 0);	/* AD0_XR */ -	at91_set_A_periph(AT91_PIN_PA18, 0);	/* AD1_XL */ -	at91_set_A_periph(AT91_PIN_PA19, 0);	/* AD2_YT */ -	at91_set_A_periph(AT91_PIN_PA20, 0);	/* AD3_TB */ - -	tsadcc_data = *data; -	platform_device_register(&at91sam9rl_tsadcc_device); +	if (test_bit(0, &data->channels_used)) +		at91_set_A_periph(AT91_PIN_PA17, 0); +	if (test_bit(1, &data->channels_used)) +		at91_set_A_periph(AT91_PIN_PA18, 0); +	if (test_bit(2, &data->channels_used)) +		at91_set_A_periph(AT91_PIN_PA19, 0); +	if (test_bit(3, &data->channels_used)) +		at91_set_A_periph(AT91_PIN_PA20, 0); +	if (test_bit(4, &data->channels_used)) +		at91_set_A_periph(AT91_PIN_PD6, 0); +	if (test_bit(5, &data->channels_used)) +		at91_set_A_periph(AT91_PIN_PD7, 0); + +	if (data->use_external_triggers) +		at91_set_A_periph(AT91_PIN_PB15, 0); + +	data->startup_time = 40; +	data->trigger_number = 4; +	data->trigger_list = at91_adc_triggers; + +	adc_data = *data; +	platform_device_register(&at91_adc_device);  }  #else -void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {} +void __init at91_add_device_adc(struct at91_adc_data *data) {}  #endif -  /* --------------------------------------------------------------------   *  RTC   * -------------------------------------------------------------------- */ @@ -693,9 +720,13 @@ static void __init at91_add_device_rtc(void) {}  static struct resource rtt_resources[] = {  	{ -		.start	= AT91_BASE_SYS + AT91_RTT, -		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1, +		.start	= AT91SAM9RL_BASE_RTT, +		.end	= AT91SAM9RL_BASE_RTT + SZ_16 - 1, +		.flags	= IORESOURCE_MEM, +	}, {  		.flags	= IORESOURCE_MEM, +	}, { +		.flags  = IORESOURCE_IRQ,  	}  }; @@ -703,11 +734,34 @@ static struct platform_device at91sam9rl_rtt_device = {  	.name		= "at91_rtt",  	.id		= 0,  	.resource	= rtt_resources, -	.num_resources	= ARRAY_SIZE(rtt_resources),  }; +#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9) +static void __init at91_add_device_rtt_rtc(void) +{ +	at91sam9rl_rtt_device.name = "rtc-at91sam9"; +	/* +	 * The second resource is needed: +	 * GPBR will serve as the storage for RTC time offset +	 */ +	at91sam9rl_rtt_device.num_resources = 3; +	rtt_resources[1].start = AT91SAM9RL_BASE_GPBR + +				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; +	rtt_resources[1].end = rtt_resources[1].start + 3; +	rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS; +	rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS; +} +#else +static void __init at91_add_device_rtt_rtc(void) +{ +	/* Only one resource is needed: RTT not used as RTC */ +	at91sam9rl_rtt_device.num_resources = 1; +} +#endif +  static void __init at91_add_device_rtt(void)  { +	at91_add_device_rtt_rtc();  	platform_device_register(&at91sam9rl_rtt_device);  } @@ -717,10 +771,19 @@ static void __init at91_add_device_rtt(void)   * -------------------------------------------------------------------- */  #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) +static struct resource wdt_resources[] = { +	{ +		.start	= AT91SAM9RL_BASE_WDT, +		.end	= AT91SAM9RL_BASE_WDT + SZ_16 - 1, +		.flags	= IORESOURCE_MEM, +	} +}; +  static struct platform_device at91sam9rl_wdt_device = {  	.name		= "at91_wdt",  	.id		= -1, -	.num_resources	= 0, +	.resource	= wdt_resources, +	.num_resources	= ARRAY_SIZE(wdt_resources),  };  static void __init at91_add_device_watchdog(void) @@ -746,8 +809,8 @@ static struct resource pwm_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_PWMC, -		.end	= AT91SAM9RL_ID_PWMC, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_PWMC, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_PWMC,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -799,14 +862,14 @@ static struct resource ssc0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_SSC0, -		.end	= AT91SAM9RL_ID_SSC0, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC0, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC0,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9rl_ssc0_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 0,  	.dev	= {  		.dma_mask		= &ssc0_dmamask, @@ -841,14 +904,14 @@ static struct resource ssc1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_SSC1, -		.end	= AT91SAM9RL_ID_SSC1, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC1, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC1,  		.flags	= IORESOURCE_IRQ,  	},  };  static struct platform_device at91sam9rl_ssc1_device = { -	.name	= "ssc", +	.name	= "at91rm9200_ssc",  	.id	= 1,  	.dev	= {  		.dma_mask		= &ssc1_dmamask, @@ -892,12 +955,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)  	case AT91SAM9RL_ID_SSC0:  		pdev = &at91sam9rl_ssc0_device;  		configure_ssc0_pins(pins); -		at91_clock_associate("ssc0_clk", &pdev->dev, "pclk");  		break;  	case AT91SAM9RL_ID_SSC1:  		pdev = &at91sam9rl_ssc1_device;  		configure_ssc1_pins(pins); -		at91_clock_associate("ssc1_clk", &pdev->dev, "pclk");  		break;  	default:  		return; @@ -918,13 +979,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}  #if defined(CONFIG_SERIAL_ATMEL)  static struct resource dbgu_resources[] = {  	[0] = { -		.start	= AT91_VA_BASE_SYS + AT91_DBGU, -		.end	= AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, +		.start	= AT91SAM9RL_BASE_DBGU, +		.end	= AT91SAM9RL_BASE_DBGU + SZ_512 - 1,  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91_ID_SYS, -		.end	= AT91_ID_SYS, +		.start	= NR_IRQS_LEGACY + AT91_ID_SYS, +		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -932,7 +993,6 @@ static struct resource dbgu_resources[] = {  static struct atmel_uart_data dbgu_data = {  	.use_dma_tx	= 0,  	.use_dma_rx	= 0,		/* DBGU not capable of receive DMA */ -	.regs		= (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),  };  static u64 dbgu_dmamask = DMA_BIT_MASK(32); @@ -962,8 +1022,8 @@ static struct resource uart0_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_US0, -		.end	= AT91SAM9RL_ID_US0, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US0, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US0,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1013,8 +1073,8 @@ static struct resource uart1_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_US1, -		.end	= AT91SAM9RL_ID_US1, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US1, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US1,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1056,8 +1116,8 @@ static struct resource uart2_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_US2, -		.end	= AT91SAM9RL_ID_US2, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US2, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US2,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1099,8 +1159,8 @@ static struct resource uart3_resources[] = {  		.flags	= IORESOURCE_MEM,  	},  	[1] = { -		.start	= AT91SAM9RL_ID_US3, -		.end	= AT91SAM9RL_ID_US3, +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US3, +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US3,  		.flags	= IORESOURCE_IRQ,  	},  }; @@ -1136,53 +1196,43 @@ static inline void configure_usart3_pins(unsigned pins)  }  static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */ -struct platform_device *atmel_default_console_device;	/* the serial console device */  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)  {  	struct platform_device *pdev; +	struct atmel_uart_data *pdata;  	switch (id) {  		case 0:		/* DBGU */  			pdev = &at91sam9rl_dbgu_device;  			configure_dbgu_pins(); -			at91_clock_associate("mck", &pdev->dev, "usart");  			break;  		case AT91SAM9RL_ID_US0:  			pdev = &at91sam9rl_uart0_device;  			configure_usart0_pins(pins); -			at91_clock_associate("usart0_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9RL_ID_US1:  			pdev = &at91sam9rl_uart1_device;  			configure_usart1_pins(pins); -			at91_clock_associate("usart1_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9RL_ID_US2:  			pdev = &at91sam9rl_uart2_device;  			configure_usart2_pins(pins); -			at91_clock_associate("usart2_clk", &pdev->dev, "usart");  			break;  		case AT91SAM9RL_ID_US3:  			pdev = &at91sam9rl_uart3_device;  			configure_usart3_pins(pins); -			at91_clock_associate("usart3_clk", &pdev->dev, "usart");  			break;  		default:  			return;  	} -	pdev->id = portnr;		/* update to mapped ID */ +	pdata = pdev->dev.platform_data; +	pdata->num = portnr;		/* update to mapped ID */  	if (portnr < ATMEL_MAX_UART)  		at91_uarts[portnr] = pdev;  } -void __init at91_set_serial_console(unsigned portnr) -{ -	if (portnr < ATMEL_MAX_UART) -		atmel_default_console_device = at91_uarts[portnr]; -} -  void __init at91_add_device_serial(void)  {  	int i; @@ -1191,13 +1241,9 @@ void __init at91_add_device_serial(void)  		if (at91_uarts[i])  			platform_device_register(at91_uarts[i]);  	} - -	if (!atmel_default_console_device) -		printk(KERN_INFO "AT91: No default serial console defined.\n");  }  #else  void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {}  void __init at91_add_device_serial(void) {}  #endif diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c new file mode 100644 index 00000000000..028268ff372 --- /dev/null +++ b/arch/arm/mach-at91/at91sam9x5.c @@ -0,0 +1,343 @@ +/* + *  Chip-specific setup code for the AT91SAM9x5 family + * + *  Copyright (C) 2010-2012 Atmel Corporation. + * + * Licensed under GPLv2 or later. + */ + +#include <linux/module.h> +#include <linux/dma-mapping.h> +#include <linux/clk/at91_pmc.h> + +#include <asm/irq.h> +#include <asm/mach/arch.h> +#include <asm/mach/map.h> +#include <mach/at91sam9x5.h> +#include <mach/cpu.h> + +#include "board.h" +#include "soc.h" +#include "generic.h" +#include "sam9_smc.h" + +#if defined(CONFIG_OLD_CLK_AT91) +#include "clock.h" +/* -------------------------------------------------------------------- + *  Clocks + * -------------------------------------------------------------------- */ + +/* + * The peripheral clocks. + */ +static struct clk pioAB_clk = { +	.name		= "pioAB_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_PIOAB, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk pioCD_clk = { +	.name		= "pioCD_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_PIOCD, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk smd_clk = { +	.name		= "smd_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_SMD, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk usart0_clk = { +	.name		= "usart0_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_USART0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk usart1_clk = { +	.name		= "usart1_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_USART1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk usart2_clk = { +	.name		= "usart2_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_USART2, +	.type		= CLK_TYPE_PERIPHERAL, +}; +/* USART3 clock - Only for sam9g25/sam9x25 */ +static struct clk usart3_clk = { +	.name		= "usart3_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_USART3, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk twi0_clk = { +	.name		= "twi0_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_TWI0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk twi1_clk = { +	.name		= "twi1_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_TWI1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk twi2_clk = { +	.name		= "twi2_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_TWI2, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk mmc0_clk = { +	.name		= "mci0_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_MCI0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk spi0_clk = { +	.name		= "spi0_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_SPI0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk spi1_clk = { +	.name		= "spi1_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_SPI1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk uart0_clk = { +	.name		= "uart0_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_UART0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk uart1_clk = { +	.name		= "uart1_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_UART1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk tcb0_clk = { +	.name		= "tcb0_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_TCB, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk pwm_clk = { +	.name		= "pwm_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_PWM, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk adc_clk = { +	.name		= "adc_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_ADC, +	.type	= CLK_TYPE_PERIPHERAL, +}; +static struct clk adc_op_clk = { +	.name		= "adc_op_clk", +	.type		= CLK_TYPE_PERIPHERAL, +	.rate_hz	= 5000000, +}; +static struct clk dma0_clk = { +	.name		= "dma0_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_DMA0, +	.type	= CLK_TYPE_PERIPHERAL, +}; +static struct clk dma1_clk = { +	.name		= "dma1_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_DMA1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk uhphs_clk = { +	.name		= "uhphs", +	.pmc_mask	= 1 << AT91SAM9X5_ID_UHPHS, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk udphs_clk = { +	.name		= "udphs_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_UDPHS, +	.type		= CLK_TYPE_PERIPHERAL, +}; +/* emac0 clock - Only for sam9g25/sam9x25/sam9g35/sam9x35 */ +static struct clk macb0_clk = { +	.name		= "pclk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_EMAC0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +/* lcd clock - Only for sam9g15/sam9g35/sam9x35 */ +static struct clk lcdc_clk = { +	.name		= "lcdc_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_LCDC, +	.type		= CLK_TYPE_PERIPHERAL, +}; +/* isi clock - Only for sam9g25 */ +static struct clk isi_clk = { +	.name		= "isi_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_ISI, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk mmc1_clk = { +	.name		= "mci1_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_MCI1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +/* emac1 clock - Only for sam9x25 */ +static struct clk macb1_clk = { +	.name		= "pclk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_EMAC1, +	.type		= CLK_TYPE_PERIPHERAL, +}; +static struct clk ssc_clk = { +	.name		= "ssc_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_SSC, +	.type		= CLK_TYPE_PERIPHERAL, +}; +/* can0 clock - Only for sam9x35 */ +static struct clk can0_clk = { +	.name		= "can0_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_CAN0, +	.type		= CLK_TYPE_PERIPHERAL, +}; +/* can1 clock - Only for sam9x35 */ +static struct clk can1_clk = { +	.name		= "can1_clk", +	.pmc_mask	= 1 << AT91SAM9X5_ID_CAN1, +	.type		= CLK_TYPE_PERIPHERAL, +}; + +static struct clk *periph_clocks[] __initdata = { +	&pioAB_clk, +	&pioCD_clk, +	&smd_clk, +	&usart0_clk, +	&usart1_clk, +	&usart2_clk, +	&twi0_clk, +	&twi1_clk, +	&twi2_clk, +	&mmc0_clk, +	&spi0_clk, +	&spi1_clk, +	&uart0_clk, +	&uart1_clk, +	&tcb0_clk, +	&pwm_clk, +	&adc_clk, +	&adc_op_clk, +	&dma0_clk, +	&dma1_clk, +	&uhphs_clk, +	&udphs_clk, +	&mmc1_clk, +	&ssc_clk, +	// irq0 +}; + +static struct clk_lookup periph_clocks_lookups[] = { +	/* lookup table for DT entries */ +	CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck), +	CLKDEV_CON_DEV_ID("usart", "f801c000.serial", &usart0_clk), +	CLKDEV_CON_DEV_ID("usart", "f8020000.serial", &usart1_clk), +	CLKDEV_CON_DEV_ID("usart", "f8024000.serial", &usart2_clk), +	CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk), +	CLKDEV_CON_DEV_ID("usart", "f8040000.serial", &uart0_clk), +	CLKDEV_CON_DEV_ID("usart", "f8044000.serial", &uart1_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb0_clk), +	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk), +	CLKDEV_CON_DEV_ID("mci_clk", "f000c000.mmc", &mmc1_clk), +	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk), +	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk), +	CLKDEV_CON_DEV_ID("pclk", "f0010000.ssc", &ssc_clk), +	CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk), +	CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk), +	CLKDEV_CON_DEV_ID(NULL, "f8018000.i2c", &twi2_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "f0000000.spi", &spi0_clk), +	CLKDEV_CON_DEV_ID("spi_clk", "f0004000.spi", &spi1_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioAB_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioAB_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioCD_clk), +	CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioCD_clk), +	/* additional fake clock for macb_hclk */ +	CLKDEV_CON_DEV_ID("hclk", "f802c000.ethernet", &macb0_clk), +	CLKDEV_CON_DEV_ID("hclk", "f8030000.ethernet", &macb1_clk), +	CLKDEV_CON_DEV_ID("hclk", "600000.ohci", &uhphs_clk), +	CLKDEV_CON_DEV_ID("ohci_clk", "600000.ohci", &uhphs_clk), +	CLKDEV_CON_DEV_ID("ehci_clk", "700000.ehci", &uhphs_clk), +	CLKDEV_CON_DEV_ID("hclk", "500000.gadget", &utmi_clk), +	CLKDEV_CON_DEV_ID("pclk", "500000.gadget", &udphs_clk), +	CLKDEV_CON_DEV_ID(NULL, "f8034000.pwm", &pwm_clk), +}; + +/* + * The two programmable clocks. + * You must configure pin multiplexing to bring these signals out. + */ +static struct clk pck0 = { +	.name		= "pck0", +	.pmc_mask	= AT91_PMC_PCK0, +	.type		= CLK_TYPE_PROGRAMMABLE, +	.id		= 0, +}; +static struct clk pck1 = { +	.name		= "pck1", +	.pmc_mask	= AT91_PMC_PCK1, +	.type		= CLK_TYPE_PROGRAMMABLE, +	.id		= 1, +}; + +static void __init at91sam9x5_register_clocks(void) +{ +	int i; + +	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) +		clk_register(periph_clocks[i]); + +	clkdev_add_table(periph_clocks_lookups, +			 ARRAY_SIZE(periph_clocks_lookups)); + +	if (cpu_is_at91sam9g25() +	|| cpu_is_at91sam9x25()) +		clk_register(&usart3_clk); + +	if (cpu_is_at91sam9g25() +	|| cpu_is_at91sam9x25() +	|| cpu_is_at91sam9g35() +	|| cpu_is_at91sam9x35()) +		clk_register(&macb0_clk); + +	if (cpu_is_at91sam9g15() +	|| cpu_is_at91sam9g35() +	|| cpu_is_at91sam9x35()) +		clk_register(&lcdc_clk); + +	if (cpu_is_at91sam9g25()) +		clk_register(&isi_clk); + +	if (cpu_is_at91sam9x25()) +		clk_register(&macb1_clk); + +	if (cpu_is_at91sam9x25() +	|| cpu_is_at91sam9x35()) { +		clk_register(&can0_clk); +		clk_register(&can1_clk); +	} + +	clk_register(&pck0); +	clk_register(&pck1); +} +#else +#define at91sam9x5_register_clocks	NULL +#endif + +/* -------------------------------------------------------------------- + *  AT91SAM9x5 processor initialization + * -------------------------------------------------------------------- */ + +static void __init at91sam9x5_map_io(void) +{ +	at91_init_sram(0, AT91SAM9X5_SRAM_BASE, AT91SAM9X5_SRAM_SIZE); +} + +static void __init at91sam9x5_initialize(void) +{ +	at91_sysirq_mask_rtc(AT91SAM9X5_BASE_RTC); +} + +/* -------------------------------------------------------------------- + *  Interrupt initialization + * -------------------------------------------------------------------- */ + +AT91_SOC_START(at91sam9x5) +	.map_io = at91sam9x5_map_io, +	.register_clocks = at91sam9x5_register_clocks, +	.init = at91sam9x5_initialize, +AT91_SOC_END diff --git a/arch/arm/mach-at91/at91x40.c b/arch/arm/mach-at91/at91x40.c index ad3ec85b279..7523f1cdfe1 100644 --- a/arch/arm/mach-at91/at91x40.c +++ b/arch/arm/mach-at91/at91x40.c @@ -13,10 +13,15 @@  #include <linux/kernel.h>  #include <linux/init.h>  #include <linux/irq.h> +#include <linux/io.h> +#include <asm/proc-fns.h> +#include <asm/system_misc.h>  #include <asm/mach/arch.h>  #include <mach/at91x40.h>  #include <mach/at91_st.h> -#include <mach/timex.h> +#include <mach/hardware.h> + +#include "at91_aic.h"  #include "generic.h"  /* @@ -37,15 +42,19 @@ unsigned long clk_get_rate(struct clk *clk)  	return AT91X40_MASTER_CLOCK;  } -struct clk *clk_get(struct device *dev, const char *id) +static void at91x40_idle(void)  { -	return NULL; +	/* +	 * Disable the processor clock.  The processor will be automatically +	 * re-enabled by an interrupt or by a reset. +	 */ +	__raw_writel(AT91_PS_CR_CPU, AT91_IO_P2V(AT91_PS_CR)); +	cpu_do_idle();  }  void __init at91x40_initialize(unsigned long main_clock)  { -	at91_extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1) -			| (1 << AT91X40_ID_IRQ2); +	arm_pm_idle = at91x40_idle;  }  /* @@ -75,9 +84,10 @@ static unsigned int at91x40_default_irq_priority[NR_AIC_IRQS] __initdata = {  void __init at91x40_init_interrupts(unsigned int priority[NR_AIC_IRQS])  { +	u32  extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1) +			| (1 << AT91X40_ID_IRQ2);  	if (!priority)  		priority = at91x40_default_irq_priority; -	at91_aic_init(priority); +	at91_aic_init(priority, extern_irq);  } - diff --git a/arch/arm/mach-at91/at91x40_time.c b/arch/arm/mach-at91/at91x40_time.c index dfff2895f4b..07d0bf2ac2d 100644 --- a/arch/arm/mach-at91/at91x40_time.c +++ b/arch/arm/mach-at91/at91x40_time.c @@ -25,8 +25,16 @@  #include <linux/time.h>  #include <linux/io.h>  #include <mach/hardware.h> +#include <mach/at91x40.h>  #include <asm/mach/time.h> -#include <mach/at91_tc.h> + +#include "at91_tc.h" + +#define at91_tc_read(field) \ +	__raw_readl(AT91_IO_P2V(AT91_TC) + field) + +#define at91_tc_write(field, value) \ +	__raw_writel(value, AT91_IO_P2V(AT91_TC) + field)  /*   *	3 counter/timer units present. @@ -35,21 +43,22 @@  #define	AT91_TC_CLK1BASE	0x40  #define	AT91_TC_CLK2BASE	0x80 -static unsigned long at91x40_gettimeoffset(void) +static u32 at91x40_gettimeoffset(void)  { -	return (at91_sys_read(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CV) * 1000000 / (AT91X40_MASTER_CLOCK / 128)); +	return (at91_tc_read(AT91_TC_CLK1BASE + AT91_TC_CV) * 1000000 / +		(AT91X40_MASTER_CLOCK / 128)) * 1000;  }  static irqreturn_t at91x40_timer_interrupt(int irq, void *dev_id)  { -	at91_sys_read(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_SR); +	at91_tc_read(AT91_TC_CLK1BASE + AT91_TC_SR);  	timer_tick();  	return IRQ_HANDLED;  }  static struct irqaction at91x40_timer_irq = {  	.name		= "at91_tick", -	.flags		= IRQF_DISABLED | IRQF_TIMER, +	.flags		= IRQF_TIMER,  	.handler	= at91x40_timer_interrupt  }; @@ -57,24 +66,20 @@ void __init at91x40_timer_init(void)  {  	unsigned int v; -	at91_sys_write(AT91_TC + AT91_TC_BCR, 0); -	v = at91_sys_read(AT91_TC + AT91_TC_BMR); +	arch_gettimeoffset = at91x40_gettimeoffset; + +	at91_tc_write(AT91_TC_BCR, 0); +	v = at91_tc_read(AT91_TC_BMR);  	v = (v & ~AT91_TC_TC1XC1S) | AT91_TC_TC1XC1S_NONE; -	at91_sys_write(AT91_TC + AT91_TC_BMR, v); +	at91_tc_write(AT91_TC_BMR, v); -	at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CCR, AT91_TC_CLKDIS); -	at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CMR, (AT91_TC_TIMER_CLOCK4 | AT91_TC_CPCTRG)); -	at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_IDR, 0xffffffff); -	at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_RC, (AT91X40_MASTER_CLOCK / 128) / HZ - 1); -	at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_IER, (1<<4)); +	at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_CCR, AT91_TC_CLKDIS); +	at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_CMR, (AT91_TC_TIMER_CLOCK4 | AT91_TC_CPCTRG)); +	at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_IDR, 0xffffffff); +	at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_RC, (AT91X40_MASTER_CLOCK / 128) / HZ - 1); +	at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_IER, (1<<4));  	setup_irq(AT91X40_ID_TC1, &at91x40_timer_irq); -	at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CCR, (AT91_TC_SWTRG | AT91_TC_CLKEN)); +	at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_CCR, (AT91_TC_SWTRG | AT91_TC_CLKEN));  } - -struct sys_timer at91x40_timer = { -	.init	= at91x40_timer_init, -	.offset	= at91x40_gettimeoffset, -}; - diff --git a/arch/arm/mach-at91/board-1arm.c b/arch/arm/mach-at91/board-1arm.c index 46bdc82d3fb..3f6dbcc3402 100644 --- a/arch/arm/mach-at91/board-1arm.c +++ b/arch/arm/mach-at91/board-1arm.c @@ -19,6 +19,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -33,44 +34,31 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h> +#include <mach/cpu.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" - -/* - * Serial port configuration. - *    0 .. 3 = USART0 .. USART3 - *    4      = DBGU - */ -static struct at91_uart_config __initdata onearm_uart_config = { -	.console_tty	= 0,				/* ttyS0 */ -	.nr_tty		= 3, -	.tty_map	= { 4, 0, 1, -1, -1 },		/* ttyS0, ..., ttyS4 */ -}; - -static void __init onearm_map_io(void) +static void __init onearm_init_early(void)  { -	/* Initialize processor: 18.432 MHz crystal */ -	at91rm9200_initialize(18432000, AT91RM9200_PQFP); +	/* Set cpu type: PQFP */ +	at91rm9200_set_type(ARCH_REVISON_9200_PQFP); -	/* Setup the serial ports and console */ -	at91_init_serial(&onearm_uart_config); -} - -static void __init onearm_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); +	/* Initialize processor: 18.432 MHz crystal */ +	at91_initialize(18432000);  } -static struct at91_eth_data __initdata onearm_eth_data = { +static struct macb_platform_data __initdata onearm_eth_data = {  	.phy_irq_pin	= AT91_PIN_PC4,  	.is_rmii	= 1,  };  static struct at91_usbh_data __initdata onearm_usbh_data = {  	.ports		= 1, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata onearm_udc_data = { @@ -81,6 +69,16 @@ static struct at91_udc_data __initdata onearm_udc_data = {  static void __init onearm_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1 (Rx, Tx, CTS, RTS) */ +	at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS); + +	/* USART1 on ttyS2 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD +			   | ATMEL_UART_RI);  	at91_add_device_serial();  	/* Ethernet */  	at91_add_device_eth(&onearm_eth_data); @@ -92,9 +90,10 @@ static void __init onearm_board_init(void)  MACHINE_START(ONEARM, "Ajeco 1ARM single board computer")  	/* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= onearm_map_io, -	.init_irq	= onearm_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= onearm_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= onearm_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-afeb-9260v1.c b/arch/arm/mach-at91/board-afeb-9260v1.c index cba7f7771fe..597c649170a 100644 --- a/arch/arm/mach-at91/board-afeb-9260v1.c +++ b/arch/arm/mach-at91/board-afeb-9260v1.c @@ -25,6 +25,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -42,45 +43,25 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h> - +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -static void __init afeb9260_map_io(void) +static void __init afeb9260_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91sam9260_initialize(18432000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91SAM9260_ID_US0, 1, -			     ATMEL_UART_CTS | ATMEL_UART_RTS -			   | ATMEL_UART_DTR | ATMEL_UART_DSR -			   | ATMEL_UART_DCD | ATMEL_UART_RI); - -	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ -	at91_register_uart(AT91SAM9260_ID_US1, 2, -			ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init afeb9260_init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); +	at91_initialize(18432000);  } -  /*   * USB Host port   */  static struct at91_usbh_data __initdata afeb9260_usbh_data = {  	.ports		= 1, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  /* @@ -88,7 +69,7 @@ static struct at91_usbh_data __initdata afeb9260_usbh_data = {   */  static struct at91_udc_data __initdata afeb9260_udc_data = {  	.vbus_pin	= AT91_PIN_PC5, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */  }; @@ -109,7 +90,7 @@ static struct spi_board_info afeb9260_spi_devices[] = {  /*   * MACB Ethernet device   */ -static struct at91_eth_data __initdata afeb9260_macb_data = { +static struct macb_platform_data __initdata afeb9260_macb_data = {  	.phy_irq_pin	= AT91_PIN_PA9,  	.is_rmii	= 0,  }; @@ -136,30 +117,28 @@ static struct mtd_partition __initdata afeb9260_nand_partition[] = {  	},  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(afeb9260_nand_partition); -	return afeb9260_nand_partition; -} -  static struct atmel_nand_data __initdata afeb9260_nand_data = {  	.ale		= 21,  	.cle		= 22,  	.rdy_pin	= AT91_PIN_PC13,  	.enable_pin	= AT91_PIN_PC14, -	.partition_info	= nand_partitions,  	.bus_width_16	= 0, +	.ecc_mode	= NAND_ECC_SOFT, +	.parts		= afeb9260_nand_partition, +	.num_parts	= ARRAY_SIZE(afeb9260_nand_partition), +	.det_pin	= -EINVAL,  };  /*   * MCI (SD/MMC)   */ -static struct at91_mmc_data __initdata afeb9260_mmc_data = { -	.det_pin 	= AT91_PIN_PC9, -	.wp_pin 	= AT91_PIN_PC4, -	.slot_b		= 1, -	.wire4		= 1, +static struct mci_platform_data __initdata afeb9260_mci0_data = { +	.slot[1] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PC9, +		.wp_pin		= AT91_PIN_PC4, +	},  }; @@ -180,6 +159,8 @@ static struct i2c_board_info __initdata afeb9260_i2c_devices[] = {  static struct at91_cf_data afeb9260_cf_data = {  	.chipselect = 4,  	.irq_pin    = AT91_PIN_PA6, +	.det_pin	= -EINVAL, +	.vcc_pin	= -EINVAL,  	.rst_pin    = AT91_PIN_PA7,  	.flags      = AT91_CF_TRUE_IDE,  }; @@ -187,6 +168,18 @@ static struct at91_cf_data afeb9260_cf_data = {  static void __init afeb9260_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91SAM9260_ID_US0, 1, +			     ATMEL_UART_CTS | ATMEL_UART_RTS +			   | ATMEL_UART_DTR | ATMEL_UART_DSR +			   | ATMEL_UART_DCD | ATMEL_UART_RI); + +	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ +	at91_register_uart(AT91SAM9260_ID_US1, 2, +			ATMEL_UART_CTS | ATMEL_UART_RTS);  	at91_add_device_serial();  	/* USB Host */  	at91_add_device_usbh(&afeb9260_usbh_data); @@ -206,7 +199,7 @@ static void __init afeb9260_board_init(void)  	at91_set_B_periph(AT91_PIN_PA10, 0);	/* ETX2 */  	at91_set_B_periph(AT91_PIN_PA11, 0);	/* ETX3 */  	/* MMC */ -	at91_add_device_mmc(0, &afeb9260_mmc_data); +	at91_add_device_mci(0, &afeb9260_mci0_data);  	/* I2C */  	at91_add_device_i2c(afeb9260_i2c_devices,  			ARRAY_SIZE(afeb9260_i2c_devices)); @@ -218,10 +211,11 @@ static void __init afeb9260_board_init(void)  MACHINE_START(AFEB9260, "Custom afeb9260 board")  	/* Maintainer: Sergey Lapin <slapin@ossfans.org> */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= afeb9260_map_io, -	.init_irq	= afeb9260_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= afeb9260_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= afeb9260_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-at572d940hf_ek.c b/arch/arm/mach-at91/board-at572d940hf_ek.c deleted file mode 100644 index 3929f1c9e4e..00000000000 --- a/arch/arm/mach-at91/board-at572d940hf_ek.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * linux/arch/arm/mach-at91/board-at572d940hf_ek.c - * - * Copyright (C) 2008 Atmel Antonio R. Costa <costa.antonior@gmail.com> - * Copyright (C) 2005 SAN People - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#include <linux/types.h> -#include <linux/init.h> -#include <linux/mm.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/spi/spi.h> -#include <linux/spi/ds1305.h> -#include <linux/irq.h> -#include <linux/mtd/physmap.h> - -#include <mach/hardware.h> -#include <asm/setup.h> -#include <asm/mach-types.h> -#include <asm/irq.h> - -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/mach/irq.h> - -#include <mach/board.h> -#include <mach/gpio.h> -#include <mach/at91sam9_smc.h> - -#include "sam9_smc.h" -#include "generic.h" - - -static void __init eb_map_io(void) -{ -	/* Initialize processor: 12.500 MHz crystal */ -	at572d940hf_initialize(12000000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx & Tx only) */ -	at91_register_uart(AT572D940HF_ID_US0, 1, 0); - -	/* USART1 on ttyS2. (Rx & Tx only) */ -	at91_register_uart(AT572D940HF_ID_US1, 2, 0); - -	/* USART2 on ttyS3. (Tx & Rx only */ -	at91_register_uart(AT572D940HF_ID_US2, 3, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init eb_init_irq(void) -{ -	at572d940hf_init_interrupts(NULL); -} - - -/* - * USB Host Port - */ -static struct at91_usbh_data __initdata eb_usbh_data = { -	.ports		= 2, -}; - - -/* - * USB Device Port - */ -static struct at91_udc_data __initdata eb_udc_data = { -	.vbus_pin	= 0,		/* no VBUS detection,UDC always on */ -	.pullup_pin	= 0,		/* pull-up driven by UDC */ -}; - - -/* - * MCI (SD/MMC) - */ -static struct at91_mmc_data __initdata eb_mmc_data = { -	.wire4		= 1, -/*	.det_pin	= ... not connected */ -/*	.wp_pin		= ... not connected */ -/*	.vcc_pin	= ... not connected */ -}; - - -/* - * MACB Ethernet device - */ -static struct at91_eth_data __initdata eb_eth_data = { -	.phy_irq_pin	= AT91_PIN_PB25, -	.is_rmii	= 1, -}; - -/* - * NOR flash - */ - -static struct mtd_partition eb_nor_partitions[] = { -	{ -		.name		= "Raw Environment", -		.offset		= 0, -		.size		= SZ_4M, -		.mask_flags	= 0, -	}, -	{ -		.name		= "OS FS", -		.offset		= MTDPART_OFS_APPEND, -		.size		= 3 * SZ_1M, -		.mask_flags	= 0, -	}, -	{ -		.name		= "APP FS", -		.offset		= MTDPART_OFS_APPEND, -		.size		= MTDPART_SIZ_FULL, -		.mask_flags	= 0, -	}, -}; - -static void nor_flash_set_vpp(struct map_info* mi, int i) { -}; - -static struct physmap_flash_data nor_flash_data = { -	.width		= 4, -	.parts		= eb_nor_partitions, -	.nr_parts	= ARRAY_SIZE(eb_nor_partitions), -	.set_vpp	= nor_flash_set_vpp, -}; - -static struct resource nor_flash_resources[] = { -	{ -		.start	= AT91_CHIPSELECT_0, -		.end	= AT91_CHIPSELECT_0 + SZ_16M - 1, -		.flags	= IORESOURCE_MEM, -	}, -}; - -static struct platform_device nor_flash = { -	.name		= "physmap-flash", -	.id		= 0, -	.dev		= { -				.platform_data = &nor_flash_data, -			}, -	.resource	= nor_flash_resources, -	.num_resources	= ARRAY_SIZE(nor_flash_resources), -}; - -static struct sam9_smc_config __initdata eb_nor_smc_config = { -	.ncs_read_setup		= 1, -	.nrd_setup		= 1, -	.ncs_write_setup	= 1, -	.nwe_setup		= 1, - -	.ncs_read_pulse		= 7, -	.nrd_pulse		= 7, -	.ncs_write_pulse	= 7, -	.nwe_pulse		= 7, - -	.read_cycle		= 9, -	.write_cycle		= 9, - -	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_32, -	.tdf_cycles		= 1, -}; - -static void __init eb_add_device_nor(void) -{ -	/* configure chip-select 0 (NOR) */ -	sam9_smc_configure(0, &eb_nor_smc_config); -	platform_device_register(&nor_flash); -} - -/* - * NAND flash - */ -static struct mtd_partition __initdata eb_nand_partition[] = { -	{ -		.name	= "Partition 1", -		.offset	= 0, -		.size	= SZ_16M, -	}, -	{ -		.name	= "Partition 2", -		.offset = MTDPART_OFS_NXTBLK, -		.size	= MTDPART_SIZ_FULL, -	} -}; - -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(eb_nand_partition); -	return eb_nand_partition; -} - -static struct atmel_nand_data __initdata eb_nand_data = { -	.ale		= 22, -	.cle		= 21, -/*	.det_pin	= ... not connected */ -/*	.rdy_pin	= AT91_PIN_PC16, */ -	.enable_pin	= AT91_PIN_PA15, -	.partition_info	= nand_partitions, -#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16) -	.bus_width_16	= 1, -#else -	.bus_width_16	= 0, -#endif -}; - -static struct sam9_smc_config __initdata eb_nand_smc_config = { -	.ncs_read_setup		= 0, -	.nrd_setup		= 0, -	.ncs_write_setup	= 1, -	.nwe_setup		= 1, - -	.ncs_read_pulse		= 3, -	.nrd_pulse		= 3, -	.ncs_write_pulse	= 3, -	.nwe_pulse		= 3, - -	.read_cycle		= 5, -	.write_cycle		= 5, - -	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE, -	.tdf_cycles		= 12, -}; - -static void __init eb_add_device_nand(void) -{ -	/* setup bus-width (8 or 16) */ -	if (eb_nand_data.bus_width_16) -		eb_nand_smc_config.mode |= AT91_SMC_DBW_16; -	else -		eb_nand_smc_config.mode |= AT91_SMC_DBW_8; - -	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &eb_nand_smc_config); - -	at91_add_device_nand(&eb_nand_data); -} - - -/* - * SPI devices - */ -static struct resource rtc_resources[] = { -	[0] = { -		.start	= AT572D940HF_ID_IRQ1, -		.end	= AT572D940HF_ID_IRQ1, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct ds1305_platform_data ds1306_data = { -	.is_ds1306	= true, -	.en_1hz		= false, -}; - -static struct spi_board_info eb_spi_devices[] = { -	{	/* RTC Dallas DS1306 */ -		.modalias	= "rtc-ds1305", -		.chip_select	= 3, -		.mode		= SPI_CS_HIGH | SPI_CPOL | SPI_CPHA, -		.max_speed_hz	= 500000, -		.bus_num	= 0, -		.irq		= AT572D940HF_ID_IRQ1, -		.platform_data	= (void *) &ds1306_data, -	}, -#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD) -	{	/* Dataflash card */ -		.modalias	= "mtd_dataflash", -		.chip_select	= 0, -		.max_speed_hz	= 15 * 1000 * 1000, -		.bus_num	= 0, -	}, -#endif -}; - -static void __init eb_board_init(void) -{ -	/* Serial */ -	at91_add_device_serial(); -	/* USB Host */ -	at91_add_device_usbh(&eb_usbh_data); -	/* USB Device */ -	at91_add_device_udc(&eb_udc_data); -	/* I2C */ -	at91_add_device_i2c(NULL, 0); -	/* NOR */ -	eb_add_device_nor(); -	/* NAND */ -	eb_add_device_nand(); -	/* SPI */ -	at91_add_device_spi(eb_spi_devices, ARRAY_SIZE(eb_spi_devices)); -	/* MMC */ -	at91_add_device_mmc(0, &eb_mmc_data); -	/* Ethernet */ -	at91_add_device_eth(&eb_eth_data); -	/* mAgic */ -	at91_add_device_mAgic(); -} - -MACHINE_START(AT572D940HFEB, "Atmel AT91D940HF-EB") -	/* Maintainer: Atmel <costa.antonior@gmail.com> */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= eb_map_io, -	.init_irq	= eb_init_irq, -	.init_machine	= eb_board_init, -MACHINE_END diff --git a/arch/arm/mach-at91/board-cam60.c b/arch/arm/mach-at91/board-cam60.c index b54e3e6fceb..a30502c8d37 100644 --- a/arch/arm/mach-at91/board-cam60.c +++ b/arch/arm/mach-at91/board-cam60.c @@ -21,6 +21,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -37,37 +38,28 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9_smc.h> +#include "at91_aic.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h" -static void __init cam60_map_io(void) +static void __init cam60_init_early(void)  {  	/* Initialize processor: 10 MHz crystal */ -	at91sam9260_initialize(10000000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init cam60_init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); +	at91_initialize(10000000);  } -  /*   * USB Host   */  static struct at91_usbh_data __initdata cam60_usbh_data = {  	.ports		= 1, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  }; @@ -121,7 +113,7 @@ static struct spi_board_info cam60_spi_devices[] __initdata = {  /*   * MACB Ethernet device   */ -static struct __initdata at91_eth_data cam60_macb_data = { +static struct macb_platform_data cam60_macb_data __initdata = {  	.phy_irq_pin	= AT91_PIN_PB5,  	.is_rmii	= 0,  }; @@ -138,19 +130,15 @@ static struct mtd_partition __initdata cam60_nand_partition[] = {  	},  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(cam60_nand_partition); -	return cam60_nand_partition; -} -  static struct atmel_nand_data __initdata cam60_nand_data = {  	.ale		= 21,  	.cle		= 22, -	// .det_pin	= ... not there +	.det_pin	= -EINVAL,  	.rdy_pin	= AT91_PIN_PA9,  	.enable_pin	= AT91_PIN_PA7, -	.partition_info	= nand_partitions, +	.ecc_mode	= NAND_ECC_SOFT, +	.parts		= cam60_nand_partition, +	.num_parts	= ARRAY_SIZE(cam60_nand_partition),  };  static struct sam9_smc_config __initdata cam60_nand_smc_config = { @@ -174,7 +162,7 @@ static struct sam9_smc_config __initdata cam60_nand_smc_config = {  static void __init cam60_add_device_nand(void)  {  	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &cam60_nand_smc_config); +	sam9_smc_configure(0, 3, &cam60_nand_smc_config);  	at91_add_device_nand(&cam60_nand_data);  } @@ -183,6 +171,8 @@ static void __init cam60_add_device_nand(void)  static void __init cam60_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0);  	at91_add_device_serial();  	/* SPI */  	at91_add_device_spi(cam60_spi_devices, ARRAY_SIZE(cam60_spi_devices)); @@ -198,9 +188,10 @@ static void __init cam60_board_init(void)  MACHINE_START(CAM60, "KwikByte CAM60")  	/* Maintainer: KwikByte */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= cam60_map_io, -	.init_irq	= cam60_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= cam60_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= cam60_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-cap9adk.c b/arch/arm/mach-at91/board-cap9adk.c deleted file mode 100644 index e7274440ead..00000000000 --- a/arch/arm/mach-at91/board-cap9adk.c +++ /dev/null @@ -1,407 +0,0 @@ -/* - * linux/arch/arm/mach-at91/board-cap9adk.c - * - *  Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com> - *  Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com> - *  Copyright (C) 2005 SAN People - *  Copyright (C) 2007 Atmel Corporation. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#include <linux/types.h> -#include <linux/init.h> -#include <linux/mm.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/spi/spi.h> -#include <linux/spi/ads7846.h> -#include <linux/fb.h> -#include <linux/mtd/physmap.h> - -#include <video/atmel_lcdc.h> - -#include <mach/hardware.h> -#include <asm/setup.h> -#include <asm/mach-types.h> - -#include <asm/mach/arch.h> -#include <asm/mach/map.h> - -#include <mach/board.h> -#include <mach/gpio.h> -#include <mach/at91cap9_matrix.h> -#include <mach/at91sam9_smc.h> - -#include "sam9_smc.h" -#include "generic.h" - - -static void __init cap9adk_map_io(void) -{ -	/* Initialize processor: 12 MHz crystal */ -	at91cap9_initialize(12000000); - -	/* Setup the LEDs: USER1 and USER2 LED for cpu/timer... */ -	at91_init_leds(AT91_PIN_PA10, AT91_PIN_PA11); -	/* ... POWER LED always on */ -	at91_set_gpio_output(AT91_PIN_PC29, 1); - -	/* Setup the serial ports and console */ -	at91_register_uart(0, 0, 0);		/* DBGU = ttyS0 */ -	at91_set_serial_console(0); -} - -static void __init cap9adk_init_irq(void) -{ -	at91cap9_init_interrupts(NULL); -} - - -/* - * USB Host port - */ -static struct at91_usbh_data __initdata cap9adk_usbh_data = { -	.ports		= 2, -}; - -/* - * USB HS Device port - */ -static struct usba_platform_data __initdata cap9adk_usba_udc_data = { -	.vbus_pin	= AT91_PIN_PB31, -}; - -/* - * ADS7846 Touchscreen - */ -#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) -static int ads7843_pendown_state(void) -{ -	return !at91_get_gpio_value(AT91_PIN_PC4);	/* Touchscreen PENIRQ */ -} - -static struct ads7846_platform_data ads_info = { -	.model			= 7843, -	.x_min			= 150, -	.x_max			= 3830, -	.y_min			= 190, -	.y_max			= 3830, -	.vref_delay_usecs	= 100, -	.x_plate_ohms		= 450, -	.y_plate_ohms		= 250, -	.pressure_max		= 15000, -	.debounce_max		= 1, -	.debounce_rep		= 0, -	.debounce_tol		= (~0), -	.get_pendown_state	= ads7843_pendown_state, -}; - -static void __init cap9adk_add_device_ts(void) -{ -	at91_set_gpio_input(AT91_PIN_PC4, 1);	/* Touchscreen PENIRQ */ -	at91_set_gpio_input(AT91_PIN_PC5, 1);	/* Touchscreen BUSY */ -} -#else -static void __init cap9adk_add_device_ts(void) {} -#endif - - -/* - * SPI devices. - */ -static struct spi_board_info cap9adk_spi_devices[] = { -#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD) -	{	/* DataFlash card */ -		.modalias	= "mtd_dataflash", -		.chip_select	= 0, -		.max_speed_hz	= 15 * 1000 * 1000, -		.bus_num	= 0, -	}, -#endif -#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) -	{ -		.modalias	= "ads7846", -		.chip_select	= 3,		/* can be 2 or 3, depending on J2 jumper */ -		.max_speed_hz	= 125000 * 26,	/* (max sample rate @ 3V) * (cmd + data + overhead) */ -		.bus_num	= 0, -		.platform_data	= &ads_info, -		.irq		= AT91_PIN_PC4, -	}, -#endif -}; - - -/* - * MCI (SD/MMC) - */ -static struct at91_mmc_data __initdata cap9adk_mmc_data = { -	.wire4		= 1, -//	.det_pin	= ... not connected -//	.wp_pin		= ... not connected -//	.vcc_pin	= ... not connected -}; - - -/* - * MACB Ethernet device - */ -static struct at91_eth_data __initdata cap9adk_macb_data = { -	.is_rmii	= 1, -}; - - -/* - * NAND flash - */ -static struct mtd_partition __initdata cap9adk_nand_partitions[] = { -	{ -		.name	= "NAND partition", -		.offset	= 0, -		.size	= MTDPART_SIZ_FULL, -	}, -}; - -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(cap9adk_nand_partitions); -	return cap9adk_nand_partitions; -} - -static struct atmel_nand_data __initdata cap9adk_nand_data = { -	.ale		= 21, -	.cle		= 22, -//	.det_pin	= ... not connected -//	.rdy_pin	= ... not connected -	.enable_pin	= AT91_PIN_PD15, -	.partition_info	= nand_partitions, -#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16) -	.bus_width_16	= 1, -#else -	.bus_width_16	= 0, -#endif -}; - -static struct sam9_smc_config __initdata cap9adk_nand_smc_config = { -	.ncs_read_setup		= 1, -	.nrd_setup		= 2, -	.ncs_write_setup	= 1, -	.nwe_setup		= 2, - -	.ncs_read_pulse		= 6, -	.nrd_pulse		= 4, -	.ncs_write_pulse	= 6, -	.nwe_pulse		= 4, - -	.read_cycle		= 8, -	.write_cycle		= 8, - -	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE, -	.tdf_cycles		= 1, -}; - -static void __init cap9adk_add_device_nand(void) -{ -	unsigned long csa; - -	csa = at91_sys_read(AT91_MATRIX_EBICSA); -	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V); - -	/* setup bus-width (8 or 16) */ -	if (cap9adk_nand_data.bus_width_16) -		cap9adk_nand_smc_config.mode |= AT91_SMC_DBW_16; -	else -		cap9adk_nand_smc_config.mode |= AT91_SMC_DBW_8; - -	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &cap9adk_nand_smc_config); - -	at91_add_device_nand(&cap9adk_nand_data); -} - - -/* - * NOR flash - */ -static struct mtd_partition cap9adk_nor_partitions[] = { -	{ -		.name		= "NOR partition", -		.offset		= 0, -		.size		= MTDPART_SIZ_FULL, -	}, -}; - -static struct physmap_flash_data cap9adk_nor_data = { -	.width		= 2, -	.parts		= cap9adk_nor_partitions, -	.nr_parts	= ARRAY_SIZE(cap9adk_nor_partitions), -}; - -#define NOR_BASE	AT91_CHIPSELECT_0 -#define NOR_SIZE	SZ_8M - -static struct resource nor_flash_resources[] = { -	{ -		.start	= NOR_BASE, -		.end	= NOR_BASE + NOR_SIZE - 1, -		.flags	= IORESOURCE_MEM, -	} -}; - -static struct platform_device cap9adk_nor_flash = { -	.name		= "physmap-flash", -	.id		= 0, -	.dev		= { -				.platform_data	= &cap9adk_nor_data, -	}, -	.resource	= nor_flash_resources, -	.num_resources	= ARRAY_SIZE(nor_flash_resources), -}; - -static struct sam9_smc_config __initdata cap9adk_nor_smc_config = { -	.ncs_read_setup		= 2, -	.nrd_setup		= 4, -	.ncs_write_setup	= 2, -	.nwe_setup		= 4, - -	.ncs_read_pulse		= 10, -	.nrd_pulse		= 8, -	.ncs_write_pulse	= 10, -	.nwe_pulse		= 8, - -	.read_cycle		= 16, -	.write_cycle		= 16, - -	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16, -	.tdf_cycles		= 1, -}; - -static __init void cap9adk_add_device_nor(void) -{ -	unsigned long csa; - -	csa = at91_sys_read(AT91_MATRIX_EBICSA); -	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V); - -	/* configure chip-select 0 (NOR) */ -	sam9_smc_configure(0, &cap9adk_nor_smc_config); - -	platform_device_register(&cap9adk_nor_flash); -} - - -/* - * LCD Controller - */ -#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) -static struct fb_videomode at91_tft_vga_modes[] = { -	{ -	        .name           = "TX09D50VM1CCA @ 60", -		.refresh	= 60, -		.xres		= 240,		.yres		= 320, -		.pixclock	= KHZ2PICOS(4965), - -		.left_margin	= 1,		.right_margin	= 33, -		.upper_margin	= 1,		.lower_margin	= 0, -		.hsync_len	= 5,		.vsync_len	= 1, - -		.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, -		.vmode		= FB_VMODE_NONINTERLACED, -	}, -}; - -static struct fb_monspecs at91fb_default_monspecs = { -	.manufacturer	= "HIT", -	.monitor        = "TX09D70VM1CCA", - -	.modedb		= at91_tft_vga_modes, -	.modedb_len	= ARRAY_SIZE(at91_tft_vga_modes), -	.hfmin		= 15000, -	.hfmax		= 64000, -	.vfmin		= 50, -	.vfmax		= 150, -}; - -#define AT91CAP9_DEFAULT_LCDCON2 	(ATMEL_LCDC_MEMOR_LITTLE \ -					| ATMEL_LCDC_DISTYPE_TFT    \ -					| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE) - -static void at91_lcdc_power_control(int on) -{ -	if (on) -		at91_set_gpio_value(AT91_PIN_PC0, 0);	/* power up */ -	else -		at91_set_gpio_value(AT91_PIN_PC0, 1);	/* power down */ -} - -/* Driver datas */ -static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data = { -	.default_bpp			= 16, -	.default_dmacon			= ATMEL_LCDC_DMAEN, -	.default_lcdcon2		= AT91CAP9_DEFAULT_LCDCON2, -	.default_monspecs		= &at91fb_default_monspecs, -	.atmel_lcdfb_power_control	= at91_lcdc_power_control, -	.guard_time			= 1, -}; - -#else -static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data; -#endif - - -/* - * AC97 - */ -static struct ac97c_platform_data cap9adk_ac97_data = { -//	.reset_pin	= ... not connected -}; - - -static void __init cap9adk_board_init(void) -{ -	/* Serial */ -	at91_add_device_serial(); -	/* USB Host */ -	at91_add_device_usbh(&cap9adk_usbh_data); -	/* USB HS */ -	at91_add_device_usba(&cap9adk_usba_udc_data); -	/* SPI */ -	at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices)); -	/* Touchscreen */ -	cap9adk_add_device_ts(); -	/* MMC */ -	at91_add_device_mmc(1, &cap9adk_mmc_data); -	/* Ethernet */ -	at91_add_device_eth(&cap9adk_macb_data); -	/* NAND */ -	cap9adk_add_device_nand(); -	/* NOR Flash */ -	cap9adk_add_device_nor(); -	/* I2C */ -	at91_add_device_i2c(NULL, 0); -	/* LCD Controller */ -	at91_add_device_lcdc(&cap9adk_lcdc_data); -	/* AC97 */ -	at91_add_device_ac97(&cap9adk_ac97_data); -} - -MACHINE_START(AT91CAP9ADK, "Atmel AT91CAP9A-DK") -	/* Maintainer: Stelian Pop <stelian.pop@leadtechdesign.com> */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= cap9adk_map_io, -	.init_irq	= cap9adk_init_irq, -	.init_machine	= cap9adk_board_init, -MACHINE_END diff --git a/arch/arm/mach-at91/board-carmeva.c b/arch/arm/mach-at91/board-carmeva.c index 2e74a19874d..47313d3ee03 100644 --- a/arch/arm/mach-at91/board-carmeva.c +++ b/arch/arm/mach-at91/board-carmeva.c @@ -20,6 +20,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -34,41 +35,28 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -static void __init carmeva_map_io(void) +static void __init carmeva_init_early(void)  {  	/* Initialize processor: 20.000 MHz crystal */ -	at91rm9200_initialize(20000000, AT91RM9200_BGA); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD -			   | ATMEL_UART_RI); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init carmeva_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); +	at91_initialize(20000000);  } -static struct at91_eth_data __initdata carmeva_eth_data = { +static struct macb_platform_data __initdata carmeva_eth_data = {  	.phy_irq_pin	= AT91_PIN_PC4,  	.is_rmii	= 1,  };  static struct at91_usbh_data __initdata carmeva_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata carmeva_udc_data = { @@ -76,19 +64,20 @@ static struct at91_udc_data __initdata carmeva_udc_data = {  	.pullup_pin	= AT91_PIN_PD9,  }; -/* FIXME: user dependant */ +/* FIXME: user dependent */  // static struct at91_cf_data __initdata carmeva_cf_data = {  //	.det_pin	= AT91_PIN_PB0,  //	.rst_pin	= AT91_PIN_PC5, -	// .irq_pin	= ... not connected -	// .vcc_pin	= ... always powered +	// .irq_pin	= -EINVAL, +	// .vcc_pin	= -EINVAL,  // }; -static struct at91_mmc_data __initdata carmeva_mmc_data = { -	.slot_b		= 0, -	.wire4		= 1, -	.det_pin	= AT91_PIN_PB10, -	.wp_pin		= AT91_PIN_PC14, +static struct mci_platform_data __initdata carmeva_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PB10, +		.wp_pin		= AT91_PIN_PC14, +	},  };  static struct spi_board_info carmeva_spi_devices[] = { @@ -141,6 +130,13 @@ static struct gpio_led carmeva_leds[] = {  static void __init carmeva_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD +			   | ATMEL_UART_RI);  	at91_add_device_serial();  	/* Ethernet */  	at91_add_device_eth(&carmeva_eth_data); @@ -155,16 +151,17 @@ static void __init carmeva_board_init(void)  	/* Compact Flash */  //	at91_add_device_cf(&carmeva_cf_data);  	/* MMC */ -	at91_add_device_mmc(0, &carmeva_mmc_data); +	at91_add_device_mci(0, &carmeva_mci0_data);  	/* LEDs */  	at91_gpio_leds(carmeva_leds, ARRAY_SIZE(carmeva_leds));  }  MACHINE_START(CARMEVA, "Carmeva")  	/* Maintainer: Conitec Datasystems */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= carmeva_map_io, -	.init_irq	= carmeva_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= carmeva_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= carmeva_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-cpu9krea.c b/arch/arm/mach-at91/board-cpu9krea.c index 3838594578f..2037f78c84e 100644 --- a/arch/arm/mach-at91/board-cpu9krea.c +++ b/arch/arm/mach-at91/board-cpu9krea.c @@ -21,6 +21,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -39,51 +40,20 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9_smc.h>  #include <mach/at91sam9260_matrix.h> +#include <mach/at91_matrix.h> +#include "at91_aic.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h" -static void __init cpu9krea_map_io(void) +static void __init cpu9krea_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91sam9260_initialize(18432000); - -	/* DGBU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | -		ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR | -		ATMEL_UART_DCD | ATMEL_UART_RI); - -	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ -	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | -		ATMEL_UART_RTS); - -	/* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */ -	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | -		ATMEL_UART_RTS); - -	/* USART3 on ttyS4. (Rx, Tx) */ -	at91_register_uart(AT91SAM9260_ID_US3, 4, 0); - -	/* USART4 on ttyS5. (Rx, Tx) */ -	at91_register_uart(AT91SAM9260_ID_US4, 5, 0); - -	/* USART5 on ttyS6. (Rx, Tx) */ -	at91_register_uart(AT91SAM9260_ID_US5, 6, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init cpu9krea_init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); +	at91_initialize(18432000);  }  /* @@ -91,6 +61,8 @@ static void __init cpu9krea_init_irq(void)   */  static struct at91_usbh_data __initdata cpu9krea_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  /* @@ -98,13 +70,14 @@ static struct at91_usbh_data __initdata cpu9krea_usbh_data = {   */  static struct at91_udc_data __initdata cpu9krea_udc_data = {  	.vbus_pin	= AT91_PIN_PC8, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */  };  /*   * MACB Ethernet device   */ -static struct at91_eth_data __initdata cpu9krea_macb_data = { +static struct macb_platform_data __initdata cpu9krea_macb_data = { +	.phy_irq_pin	= -EINVAL,  	.is_rmii	= 1,  }; @@ -117,6 +90,8 @@ static struct atmel_nand_data __initdata cpu9krea_nand_data = {  	.rdy_pin	= AT91_PIN_PC13,  	.enable_pin	= AT91_PIN_PC14,  	.bus_width_16	= 0, +	.det_pin	= -EINVAL, +	.ecc_mode	= NAND_ECC_SOFT,  };  #ifdef CONFIG_MACH_CPU9260 @@ -161,7 +136,7 @@ static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {  static void __init cpu9krea_add_device_nand(void)  { -	sam9_smc_configure(3, &cpu9krea_nand_smc_config); +	sam9_smc_configure(0, 3, &cpu9krea_nand_smc_config);  	at91_add_device_nand(&cpu9krea_nand_data);  } @@ -239,11 +214,11 @@ static __init void cpu9krea_add_device_nor(void)  {  	unsigned long csa; -	csa = at91_sys_read(AT91_MATRIX_EBICSA); -	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V); +	csa = at91_matrix_read(AT91_MATRIX_EBICSA); +	at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V);  	/* configure chip-select 0 (NOR) */ -	sam9_smc_configure(0, &cpu9krea_nor_smc_config); +	sam9_smc_configure(0, 0, &cpu9krea_nor_smc_config);  	platform_device_register(&cpu9krea_nor_flash);  } @@ -280,8 +255,7 @@ static struct gpio_led cpu9krea_leds[] = {  static struct i2c_board_info __initdata cpu9krea_i2c_devices[] = {  	{ -		I2C_BOARD_INFO("rtc-ds1307", 0x68), -		.type	= "ds1339", +		I2C_BOARD_INFO("ds1339", 0x68),  	},  }; @@ -338,10 +312,12 @@ static void __init cpu9krea_add_device_buttons(void)  /*   * MCI (SD/MMC)   */ -static struct at91_mmc_data __initdata cpu9krea_mmc_data = { -	.slot_b		= 0, -	.wire4		= 1, -	.det_pin	= AT91_PIN_PA29, +static struct mci_platform_data __initdata cpu9krea_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PA29, +		.wp_pin		= -EINVAL, +	},  };  static void __init cpu9krea_board_init(void) @@ -349,6 +325,30 @@ static void __init cpu9krea_board_init(void)  	/* NOR */  	cpu9krea_add_device_nor();  	/* Serial */ +	/* DGBU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | +		ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR | +		ATMEL_UART_DCD | ATMEL_UART_RI); + +	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | +		ATMEL_UART_RTS); + +	/* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */ +	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | +		ATMEL_UART_RTS); + +	/* USART3 on ttyS4. (Rx, Tx) */ +	at91_register_uart(AT91SAM9260_ID_US3, 4, 0); + +	/* USART4 on ttyS5. (Rx, Tx) */ +	at91_register_uart(AT91SAM9260_ID_US4, 5, 0); + +	/* USART5 on ttyS6. (Rx, Tx) */ +	at91_register_uart(AT91SAM9260_ID_US5, 6, 0);  	at91_add_device_serial();  	/* USB Host */  	at91_add_device_usbh(&cpu9krea_usbh_data); @@ -359,7 +359,7 @@ static void __init cpu9krea_board_init(void)  	/* Ethernet */  	at91_add_device_eth(&cpu9krea_macb_data);  	/* MMC */ -	at91_add_device_mmc(0, &cpu9krea_mmc_data); +	at91_add_device_mci(0, &cpu9krea_mci0_data);  	/* I2C */  	at91_add_device_i2c(cpu9krea_i2c_devices,  		ARRAY_SIZE(cpu9krea_i2c_devices)); @@ -375,9 +375,10 @@ MACHINE_START(CPUAT9260, "Eukrea CPU9260")  MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")  #endif  	/* Maintainer: Eric Benard - EUKREA Electromatique */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= cpu9krea_map_io, -	.init_irq	= cpu9krea_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= cpu9krea_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= cpu9krea_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-cpuat91.c b/arch/arm/mach-at91/board-cpuat91.c index 2f4dd8cdd48..c094350c931 100644 --- a/arch/arm/mach-at91/board-cpuat91.c +++ b/arch/arm/mach-at91/board-cpuat91.c @@ -19,6 +19,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -35,11 +36,15 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> +#include <mach/cpu.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" +  static struct gpio_led cpuat91_leds[] = {  	{ @@ -50,45 +55,24 @@ static struct gpio_led cpuat91_leds[] = {  	},  }; -static void __init cpuat91_map_io(void) +static void __init cpuat91_init_early(void)  { -	/* Initialize processor: 18.432 MHz crystal */ -	at91rm9200_initialize(18432000, AT91RM9200_PQFP); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */ -	at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | -		ATMEL_UART_RTS); - -	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS | -		ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR | -		ATMEL_UART_DCD | ATMEL_UART_RI); - -	/* USART2 on ttyS3 (Rx, Tx) */ -	at91_register_uart(AT91RM9200_ID_US2, 3, 0); - -	/* USART3 on ttyS4 (Rx, Tx, CTS, RTS) */ -	at91_register_uart(AT91RM9200_ID_US3, 4, ATMEL_UART_CTS | -		ATMEL_UART_RTS); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} +	/* Set cpu type: PQFP */ +	at91rm9200_set_type(ARCH_REVISON_9200_PQFP); -static void __init cpuat91_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); +	/* Initialize processor: 18.432 MHz crystal */ +	at91_initialize(18432000);  } -static struct at91_eth_data __initdata cpuat91_eth_data = { +static struct macb_platform_data __initdata cpuat91_eth_data = { +	.phy_irq_pin	= -EINVAL,  	.is_rmii	= 1,  };  static struct at91_usbh_data __initdata cpuat91_usbh_data = {  	.ports		= 1, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata cpuat91_udc_data = { @@ -96,9 +80,12 @@ static struct at91_udc_data __initdata cpuat91_udc_data = {  	.pullup_pin	= AT91_PIN_PC14,  }; -static struct at91_mmc_data __initdata cpuat91_mmc_data = { -	.det_pin	= AT91_PIN_PC2, -	.wire4		= 1, +static struct mci_platform_data __initdata cpuat91_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PC2, +		.wp_pin		= -EINVAL, +	},  };  static struct physmap_flash_data cpuat91_flash_data = { @@ -156,6 +143,24 @@ static struct platform_device *platform_devices[] __initdata = {  static void __init cpuat91_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */ +	at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | +		ATMEL_UART_RTS); + +	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS | +		ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR | +		ATMEL_UART_DCD | ATMEL_UART_RI); + +	/* USART2 on ttyS3 (Rx, Tx) */ +	at91_register_uart(AT91RM9200_ID_US2, 3, 0); + +	/* USART3 on ttyS4 (Rx, Tx, CTS, RTS) */ +	at91_register_uart(AT91RM9200_ID_US3, 4, ATMEL_UART_CTS | +		ATMEL_UART_RTS);  	at91_add_device_serial();  	/* LEDs. */  	at91_gpio_leds(cpuat91_leds, ARRAY_SIZE(cpuat91_leds)); @@ -166,7 +171,7 @@ static void __init cpuat91_board_init(void)  	/* USB Device */  	at91_add_device_udc(&cpuat91_udc_data);  	/* MMC */ -	at91_add_device_mmc(0, &cpuat91_mmc_data); +	at91_add_device_mci(0, &cpuat91_mci0_data);  	/* I2C */  	at91_add_device_i2c(NULL, 0);  	/* Platform devices */ @@ -175,9 +180,10 @@ static void __init cpuat91_board_init(void)  MACHINE_START(CPUAT91, "Eukrea")  	/* Maintainer: Eric Benard - EUKREA Electromatique */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= cpuat91_map_io, -	.init_irq	= cpuat91_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= cpuat91_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= cpuat91_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c index 464839dc39b..0e35a45cf8d 100644 --- a/arch/arm/mach-at91/board-csb337.c +++ b/arch/arm/mach-at91/board-csb337.c @@ -19,6 +19,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -37,44 +38,34 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" - -static void __init csb337_map_io(void) +static void __init csb337_init_early(void)  {  	/* Initialize processor: 3.6864 MHz crystal */ -	at91rm9200_initialize(3686400, AT91RM9200_BGA); - -	/* Setup the LEDs */ -	at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1); - -	/* DBGU on ttyS0 */ -	at91_register_uart(0, 0, 0); - -	/* make console=ttyS0 the default */ -	at91_set_serial_console(0); +	at91_initialize(3686400);  } -static void __init csb337_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); -} - -static struct at91_eth_data __initdata csb337_eth_data = { +static struct macb_platform_data __initdata csb337_eth_data = {  	.phy_irq_pin	= AT91_PIN_PC2,  	.is_rmii	= 0, +	/* The CSB337 bootloader stores the MAC the wrong-way around */ +	.rev_eth_addr	= 1,  };  static struct at91_usbh_data __initdata csb337_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata csb337_udc_data = { -	// this has no VBUS sensing pin  	.pullup_pin	= AT91_PIN_PA24, +	.vbus_pin	= -EINVAL,  };  static struct i2c_board_info __initdata csb337_i2c_devices[] = { @@ -98,11 +89,12 @@ static struct at91_cf_data __initdata csb337_cf_data = {  	.rst_pin	= AT91_PIN_PD2,  }; -static struct at91_mmc_data __initdata csb337_mmc_data = { -	.det_pin	= AT91_PIN_PD5, -	.slot_b		= 0, -	.wire4		= 1, -	.wp_pin		= AT91_PIN_PD6, +static struct mci_platform_data __initdata csb337_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PD5, +		.wp_pin		= AT91_PIN_PD6, +	},  };  static struct spi_board_info csb337_spi_devices[] = { @@ -231,6 +223,8 @@ static struct gpio_led csb_leds[] = {  static void __init csb337_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0 */ +	at91_register_uart(0, 0, 0);  	at91_add_device_serial();  	/* Ethernet */  	at91_add_device_eth(&csb337_eth_data); @@ -246,7 +240,7 @@ static void __init csb337_board_init(void)  	/* SPI */  	at91_add_device_spi(csb337_spi_devices, ARRAY_SIZE(csb337_spi_devices));  	/* MMC */ -	at91_add_device_mmc(0, &csb337_mmc_data); +	at91_add_device_mci(0, &csb337_mci0_data);  	/* NOR flash */  	platform_device_register(&csb_flash);  	/* LEDs */ @@ -257,9 +251,10 @@ static void __init csb337_board_init(void)  MACHINE_START(CSB337, "Cogent CSB337")  	/* Maintainer: Bill Gatliff */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= csb337_map_io, -	.init_irq	= csb337_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= csb337_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= csb337_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-csb637.c b/arch/arm/mach-at91/board-csb637.c index 431688c6141..18d027f529a 100644 --- a/arch/arm/mach-at91/board-csb637.c +++ b/arch/arm/mach-at91/board-csb637.c @@ -20,6 +20,7 @@  #include <linux/types.h>  #include <linux/init.h> +#include <linux/gpio.h>  #include <linux/mm.h>  #include <linux/module.h>  #include <linux/platform_device.h> @@ -34,36 +35,28 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -static void __init csb637_map_io(void) +static void __init csb637_init_early(void)  {  	/* Initialize processor: 3.6864 MHz crystal */ -	at91rm9200_initialize(3686400, AT91RM9200_BGA); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* make console=ttyS0 (ie, DBGU) the default */ -	at91_set_serial_console(0); +	at91_initialize(3686400);  } -static void __init csb637_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); -} - -static struct at91_eth_data __initdata csb637_eth_data = { +static struct macb_platform_data __initdata csb637_eth_data = {  	.phy_irq_pin	= AT91_PIN_PC0,  	.is_rmii	= 0,  };  static struct at91_usbh_data __initdata csb637_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata csb637_udc_data = { @@ -121,6 +114,8 @@ static void __init csb637_board_init(void)  	/* LED(s) */  	at91_gpio_leds(csb_leds, ARRAY_SIZE(csb_leds));  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0);  	at91_add_device_serial();  	/* Ethernet */  	at91_add_device_eth(&csb637_eth_data); @@ -138,9 +133,10 @@ static void __init csb637_board_init(void)  MACHINE_START(CSB637, "Cogent CSB637")  	/* Maintainer: Bill Gatliff */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= csb637_map_io, -	.init_irq	= csb637_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= csb637_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= csb637_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-dk.c b/arch/arm/mach-at91/board-dk.c deleted file mode 100644 index e14f0e16568..00000000000 --- a/arch/arm/mach-at91/board-dk.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * linux/arch/arm/mach-at91/board-dk.c - * - *  Copyright (C) 2005 SAN People - * - *  Epson S1D framebuffer glue code is: - *     Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#include <linux/types.h> -#include <linux/init.h> -#include <linux/mm.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/spi/spi.h> -#include <linux/mtd/physmap.h> - -#include <asm/setup.h> -#include <asm/mach-types.h> -#include <asm/irq.h> - -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/mach/irq.h> - -#include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h> -#include <mach/at91rm9200_mc.h> - -#include "generic.h" - - -static void __init dk_map_io(void) -{ -	/* Initialize processor: 18.432 MHz crystal */ -	at91rm9200_initialize(18432000, AT91RM9200_BGA); - -	/* Setup the LEDs */ -	at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD -			   | ATMEL_UART_RI); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init dk_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); -} - -static struct at91_eth_data __initdata dk_eth_data = { -	.phy_irq_pin	= AT91_PIN_PC4, -	.is_rmii	= 1, -}; - -static struct at91_usbh_data __initdata dk_usbh_data = { -	.ports		= 2, -}; - -static struct at91_udc_data __initdata dk_udc_data = { -	.vbus_pin	= AT91_PIN_PD4, -	.pullup_pin	= AT91_PIN_PD5, -}; - -static struct at91_cf_data __initdata dk_cf_data = { -	.det_pin	= AT91_PIN_PB0, -	.rst_pin	= AT91_PIN_PC5, -	// .irq_pin	= ... not connected -	// .vcc_pin	= ... always powered -}; - -static struct at91_mmc_data __initdata dk_mmc_data = { -	.slot_b		= 0, -	.wire4		= 1, -}; - -static struct spi_board_info dk_spi_devices[] = { -	{	/* DataFlash chip */ -		.modalias	= "mtd_dataflash", -		.chip_select	= 0, -		.max_speed_hz	= 15 * 1000 * 1000, -	}, -	{	/* UR6HCPS2-SP40 PS2-to-SPI adapter */ -		.modalias	= "ur6hcps2", -		.chip_select	= 1, -		.max_speed_hz	= 250 *  1000, -	}, -	{	/* TLV1504 ADC, 4 channels, 10 bits; one is a temp sensor */ -		.modalias	= "tlv1504", -		.chip_select	= 2, -		.max_speed_hz	= 20 * 1000 * 1000, -	}, -#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD -	{	/* DataFlash card */ -		.modalias	= "mtd_dataflash", -		.chip_select	= 3, -		.max_speed_hz	= 15 * 1000 * 1000, -	} -#endif -}; - -static struct i2c_board_info __initdata dk_i2c_devices[] = { -	{ -		I2C_BOARD_INFO("ics1523", 0x26), -	}, -	{ -		I2C_BOARD_INFO("x9429", 0x28), -	}, -	{ -		I2C_BOARD_INFO("24c1024", 0x50), -	} -}; - -static struct mtd_partition __initdata dk_nand_partition[] = { -	{ -		.name	= "NAND Partition 1", -		.offset	= 0, -		.size	= MTDPART_SIZ_FULL, -	}, -}; - -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(dk_nand_partition); -	return dk_nand_partition; -} - -static struct atmel_nand_data __initdata dk_nand_data = { -	.ale		= 22, -	.cle		= 21, -	.det_pin	= AT91_PIN_PB1, -	.rdy_pin	= AT91_PIN_PC2, -	// .enable_pin	= ... not there -	.partition_info	= nand_partitions, -}; - -#define DK_FLASH_BASE	AT91_CHIPSELECT_0 -#define DK_FLASH_SIZE	SZ_2M - -static struct physmap_flash_data dk_flash_data = { -	.width		= 2, -}; - -static struct resource dk_flash_resource = { -	.start		= DK_FLASH_BASE, -	.end		= DK_FLASH_BASE + DK_FLASH_SIZE - 1, -	.flags		= IORESOURCE_MEM, -}; - -static struct platform_device dk_flash = { -	.name		= "physmap-flash", -	.id		= 0, -	.dev		= { -				.platform_data	= &dk_flash_data, -			}, -	.resource	= &dk_flash_resource, -	.num_resources	= 1, -}; - -static struct gpio_led dk_leds[] = { -	{ -		.name			= "led0", -		.gpio			= AT91_PIN_PB2, -		.active_low		= 1, -		.default_trigger	= "heartbeat", -	} -}; - -static void __init dk_board_init(void) -{ -	/* Serial */ -	at91_add_device_serial(); -	/* Ethernet */ -	at91_add_device_eth(&dk_eth_data); -	/* USB Host */ -	at91_add_device_usbh(&dk_usbh_data); -	/* USB Device */ -	at91_add_device_udc(&dk_udc_data); -	at91_set_multi_drive(dk_udc_data.pullup_pin, 1);	/* pullup_pin is connected to reset */ -	/* Compact Flash */ -	at91_add_device_cf(&dk_cf_data); -	/* I2C */ -	at91_add_device_i2c(dk_i2c_devices, ARRAY_SIZE(dk_i2c_devices)); -	/* SPI */ -	at91_add_device_spi(dk_spi_devices, ARRAY_SIZE(dk_spi_devices)); -#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD -	/* DataFlash card */ -	at91_set_gpio_output(AT91_PIN_PB7, 0); -#else -	/* MMC */ -	at91_set_gpio_output(AT91_PIN_PB7, 1);	/* this MMC card slot can optionally use SPI signaling (CS3). */ -	at91_add_device_mmc(0, &dk_mmc_data); -#endif -	/* NAND */ -	at91_add_device_nand(&dk_nand_data); -	/* NOR Flash */ -	platform_device_register(&dk_flash); -	/* LEDs */ -	at91_gpio_leds(dk_leds, ARRAY_SIZE(dk_leds)); -	/* VGA */ -//	dk_add_device_video(); -} - -MACHINE_START(AT91RM9200DK, "Atmel AT91RM9200-DK") -	/* Maintainer: SAN People/Atmel */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= dk_map_io, -	.init_irq	= dk_init_irq, -	.init_machine	= dk_board_init, -MACHINE_END diff --git a/arch/arm/mach-at91/board-dt-rm9200.c b/arch/arm/mach-at91/board-dt-rm9200.c new file mode 100644 index 00000000000..3a185faee79 --- /dev/null +++ b/arch/arm/mach-at91/board-dt-rm9200.c @@ -0,0 +1,50 @@ +/* + *  Setup code for AT91RM9200 Evaluation Kits with Device Tree support + * + *  Copyright (C) 2011 Atmel, + *                2011 Nicolas Ferre <nicolas.ferre@atmel.com> + *                2012 Joachim Eastwood <manabian@gmail.com> + * + * Licensed under GPLv2 or later. + */ + +#include <linux/types.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/gpio.h> +#include <linux/of.h> +#include <linux/of_irq.h> + +#include <asm/setup.h> +#include <asm/irq.h> +#include <asm/mach/arch.h> +#include <asm/mach/map.h> +#include <asm/mach/irq.h> + +#include "at91_aic.h" +#include "generic.h" + + +static const struct of_device_id irq_of_match[] __initconst = { +	{ .compatible = "atmel,at91rm9200-aic", .data = at91_aic_of_init }, +	{ /*sentinel*/ } +}; + +static void __init at91rm9200_dt_init_irq(void) +{ +	of_irq_init(irq_of_match); +} + +static const char *at91rm9200_dt_board_compat[] __initdata = { +	"atmel,at91rm9200", +	NULL +}; + +DT_MACHINE_START(at91rm9200_dt, "Atmel AT91RM9200 (Device Tree)") +	.init_time      = at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= at91rm9200_dt_initialize, +	.init_irq	= at91rm9200_dt_init_irq, +	.dt_compat	= at91rm9200_dt_board_compat, +MACHINE_END diff --git a/arch/arm/mach-at91/board-dt-sam9.c b/arch/arm/mach-at91/board-dt-sam9.c new file mode 100644 index 00000000000..575b0be66ca --- /dev/null +++ b/arch/arm/mach-at91/board-dt-sam9.c @@ -0,0 +1,61 @@ +/* + *  Setup code for AT91SAM Evaluation Kits with Device Tree support + * + *  Copyright (C) 2011 Atmel, + *                2011 Nicolas Ferre <nicolas.ferre@atmel.com> + * + * Licensed under GPLv2 or later. + */ + +#include <linux/types.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/gpio.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/clk-provider.h> + +#include <asm/setup.h> +#include <asm/irq.h> +#include <asm/mach/arch.h> +#include <asm/mach/map.h> +#include <asm/mach/irq.h> + +#include "at91_aic.h" +#include "board.h" +#include "generic.h" + + +static void __init sam9_dt_timer_init(void) +{ +#if defined(CONFIG_COMMON_CLK) +	of_clk_init(NULL); +#endif +	at91sam926x_pit_init(); +} + +static const struct of_device_id irq_of_match[] __initconst = { + +	{ .compatible = "atmel,at91rm9200-aic", .data = at91_aic_of_init }, +	{ /*sentinel*/ } +}; + +static void __init at91_dt_init_irq(void) +{ +	of_irq_init(irq_of_match); +} + +static const char *at91_dt_board_compat[] __initdata = { +	"atmel,at91sam9", +	NULL +}; + +DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM (Device Tree)") +	/* Maintainer: Atmel */ +	.init_time	= sam9_dt_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= at91_dt_initialize, +	.init_irq	= at91_dt_init_irq, +	.dt_compat	= at91_dt_board_compat, +MACHINE_END diff --git a/arch/arm/mach-at91/board-dt-sama5.c b/arch/arm/mach-at91/board-dt-sama5.c new file mode 100644 index 00000000000..075ec0576ad --- /dev/null +++ b/arch/arm/mach-at91/board-dt-sama5.c @@ -0,0 +1,90 @@ +/* + *  Setup code for SAMA5 Evaluation Kits with Device Tree support + * + *  Copyright (C) 2013 Atmel, + *                2013 Ludovic Desroches <ludovic.desroches@atmel.com> + * + * Licensed under GPLv2 or later. + */ + +#include <linux/types.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/gpio.h> +#include <linux/micrel_phy.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/of_platform.h> +#include <linux/phy.h> +#include <linux/clk-provider.h> + +#include <asm/setup.h> +#include <asm/irq.h> +#include <asm/mach/arch.h> +#include <asm/mach/map.h> +#include <asm/mach/irq.h> + +#include "at91_aic.h" +#include "generic.h" + +static void __init sama5_dt_timer_init(void) +{ +#if defined(CONFIG_COMMON_CLK) +	of_clk_init(NULL); +#endif +	at91sam926x_pit_init(); +} + +static const struct of_device_id irq_of_match[] __initconst = { + +	{ .compatible = "atmel,sama5d3-aic", .data = at91_aic5_of_init }, +	{ /*sentinel*/ } +}; + +static void __init at91_dt_init_irq(void) +{ +	of_irq_init(irq_of_match); +} + +static int ksz9021rn_phy_fixup(struct phy_device *phy) +{ +	int value; + +	/* Set delay values */ +	value = MICREL_KSZ9021_RGMII_CLK_CTRL_PAD_SCEW | 0x8000; +	phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value); +	value = 0xF2F4; +	phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value); +	value = MICREL_KSZ9021_RGMII_RX_DATA_PAD_SCEW | 0x8000; +	phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value); +	value = 0x2222; +	phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value); + +	return 0; +} + +static void __init sama5_dt_device_init(void) +{ +	if (of_machine_is_compatible("atmel,sama5d3xcm") && +	    IS_ENABLED(CONFIG_PHYLIB)) +		phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK, +			ksz9021rn_phy_fixup); + +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); +} + +static const char *sama5_dt_board_compat[] __initdata = { +	"atmel,sama5", +	NULL +}; + +DT_MACHINE_START(sama5_dt, "Atmel SAMA5 (Device Tree)") +	/* Maintainer: Atmel */ +	.init_time	= sama5_dt_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic5_handle_irq, +	.init_early	= at91_dt_initialize, +	.init_irq	= at91_dt_init_irq, +	.init_machine	= sama5_dt_device_init, +	.dt_compat	= sama5_dt_board_compat, +MACHINE_END diff --git a/arch/arm/mach-at91/board-eb01.c b/arch/arm/mach-at91/board-eb01.c index 1f9d3cb64c5..becf0a6a289 100644 --- a/arch/arm/mach-at91/board-eb01.c +++ b/arch/arm/mach-at91/board-eb01.c @@ -27,18 +27,26 @@  #include <mach/hardware.h>  #include <asm/mach/arch.h>  #include <asm/mach/map.h> -#include <mach/board.h> + +#include "at91_aic.h" +#include "board.h"  #include "generic.h" -static void __init at91eb01_map_io(void) +static void __init at91eb01_init_irq(void) +{ +	at91x40_init_interrupts(NULL); +} + +static void __init at91eb01_init_early(void)  {  	at91x40_initialize(40000000);  }  MACHINE_START(AT91EB01, "Atmel AT91 EB01")  	/* Maintainer: Greg Ungerer <gerg@snapgear.com> */ -	.timer		= &at91x40_timer, -	.init_irq	= at91x40_init_interrupts, -	.map_io		= at91eb01_map_io, +	.init_time	= at91x40_timer_init, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= at91eb01_init_early, +	.init_irq	= at91eb01_init_irq,  MACHINE_END diff --git a/arch/arm/mach-at91/board-eb9200.c b/arch/arm/mach-at91/board-eb9200.c index 6cf6566ae34..aa457a8b22f 100644 --- a/arch/arm/mach-at91/board-eb9200.c +++ b/arch/arm/mach-at91/board-eb9200.c @@ -20,6 +20,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -34,44 +35,27 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h> - +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -static void __init eb9200_map_io(void) +static void __init eb9200_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91rm9200_initialize(18432000, AT91RM9200_BGA); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -			| ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD -			| ATMEL_UART_RI); - -	/* USART2 on ttyS2. (Rx, Tx) - IRDA */ -	at91_register_uart(AT91RM9200_ID_US2, 2, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); +	at91_initialize(18432000);  } -static void __init eb9200_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); -} - -static struct at91_eth_data __initdata eb9200_eth_data = { +static struct macb_platform_data __initdata eb9200_eth_data = {  	.phy_irq_pin	= AT91_PIN_PC4,  	.is_rmii	= 1,  };  static struct at91_usbh_data __initdata eb9200_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata eb9200_udc_data = { @@ -80,15 +64,18 @@ static struct at91_udc_data __initdata eb9200_udc_data = {  };  static struct at91_cf_data __initdata eb9200_cf_data = { +	.irq_pin	= -EINVAL,  	.det_pin	= AT91_PIN_PB0, +	.vcc_pin	= -EINVAL,  	.rst_pin	= AT91_PIN_PC5, -	// .irq_pin	= ... not connected -	// .vcc_pin	= ... always powered  }; -static struct at91_mmc_data __initdata eb9200_mmc_data = { -	.slot_b		= 0, -	.wire4		= 1, +static struct mci_platform_data __initdata eb9200_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= -EINVAL, +		.wp_pin		= -EINVAL, +	},  };  static struct i2c_board_info __initdata eb9200_i2c_devices[] = { @@ -101,6 +88,16 @@ static struct i2c_board_info __initdata eb9200_i2c_devices[] = {  static void __init eb9200_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS +			| ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD +			| ATMEL_UART_RI); + +	/* USART2 on ttyS2. (Rx, Tx) - IRDA */ +	at91_register_uart(AT91RM9200_ID_US2, 2, 0);  	at91_add_device_serial();  	/* Ethernet */  	at91_add_device_eth(&eb9200_eth_data); @@ -116,13 +113,14 @@ static void __init eb9200_board_init(void)  	at91_add_device_spi(NULL, 0);  	/* MMC */  	/* only supports 1 or 4 bit interface, not wired through to SPI */ -	at91_add_device_mmc(0, &eb9200_mmc_data); +	at91_add_device_mci(0, &eb9200_mci0_data);  }  MACHINE_START(ATEB9200, "Embest ATEB9200") -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= eb9200_map_io, -	.init_irq	= eb9200_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= eb9200_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= eb9200_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-ecbat91.c b/arch/arm/mach-at91/board-ecbat91.c index 7b58c948a95..ede1373ccab 100644 --- a/arch/arm/mach-at91/board-ecbat91.c +++ b/arch/arm/mach-at91/board-ecbat91.c @@ -20,6 +20,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -36,47 +37,40 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h> +#include <mach/cpu.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -static void __init ecb_at91map_io(void) +static void __init ecb_at91init_early(void)  { -	/* Initialize processor: 18.432 MHz crystal */ -	at91rm9200_initialize(18432000, AT91RM9200_PQFP); - -	/* Setup the LEDs */ -	at91_init_leds(AT91_PIN_PC7, AT91_PIN_PC7); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx & Tx only) */ -	at91_register_uart(AT91RM9200_ID_US0, 1, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} +	/* Set cpu type: PQFP */ +	at91rm9200_set_type(ARCH_REVISON_9200_PQFP); -static void __init ecb_at91init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); +	/* Initialize processor: 18.432 MHz crystal */ +	at91_initialize(18432000);  } -static struct at91_eth_data __initdata ecb_at91eth_data = { +static struct macb_platform_data __initdata ecb_at91eth_data = {  	.phy_irq_pin	= AT91_PIN_PC4,  	.is_rmii	= 0,  };  static struct at91_usbh_data __initdata ecb_at91usbh_data = {  	.ports		= 1, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  }; -static struct at91_mmc_data __initdata ecb_at91mmc_data = { -	.slot_b		= 0, -	.wire4		= 1, +static struct mci_platform_data __initdata ecbat91_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= -EINVAL, +		.wp_pin		= -EINVAL, +	},  }; @@ -128,26 +122,43 @@ static struct spi_board_info __initdata ecb_at91spi_devices[] = {  		.platform_data	= &my_flash0_platform,  #endif  	}, -	{	/* User accessable spi - cs1 (250KHz) */ +	{	/* User accessible spi - cs1 (250KHz) */  		.modalias	= "spi-cs1",  		.chip_select	= 1,  		.max_speed_hz	= 250 * 1000,  	}, -	{	/* User accessable spi - cs2 (1MHz) */ +	{	/* User accessible spi - cs2 (1MHz) */  		.modalias	= "spi-cs2",  		.chip_select	= 2,  		.max_speed_hz	= 1 * 1000 * 1000,  	}, -	{	/* User accessable spi - cs3 (10MHz) */ +	{	/* User accessible spi - cs3 (10MHz) */  		.modalias	= "spi-cs3",  		.chip_select	= 3,  		.max_speed_hz	= 10 * 1000 * 1000,  	},  }; +/* + * LEDs + */ +static struct gpio_led ecb_leds[] = { +	{	/* D1 */ +		.name			= "led1", +		.gpio			= AT91_PIN_PC7, +		.active_low		= 1, +		.default_trigger	= "heartbeat", +	} +}; +  static void __init ecb_at91board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1. (Rx & Tx only) */ +	at91_register_uart(AT91RM9200_ID_US0, 1, 0);  	at91_add_device_serial();  	/* Ethernet */ @@ -160,17 +171,21 @@ static void __init ecb_at91board_init(void)  	at91_add_device_i2c(NULL, 0);  	/* MMC */ -	at91_add_device_mmc(0, &ecb_at91mmc_data); +	at91_add_device_mci(0, &ecbat91_mci0_data);  	/* SPI */  	at91_add_device_spi(ecb_at91spi_devices, ARRAY_SIZE(ecb_at91spi_devices)); + +	/* LEDs */ +	at91_gpio_leds(ecb_leds, ARRAY_SIZE(ecb_leds));  }  MACHINE_START(ECBAT91, "emQbit's ECB_AT91")  	/* Maintainer: emQbit.com */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= ecb_at91map_io, -	.init_irq	= ecb_at91init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ecb_at91init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= ecb_at91board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-eco920.c b/arch/arm/mach-at91/board-eco920.c index a158a0ce458..4e75321a8f2 100644 --- a/arch/arm/mach-at91/board-eco920.c +++ b/arch/arm/mach-at91/board-eco920.c @@ -24,36 +24,33 @@  #include <asm/mach/arch.h>  #include <asm/mach/map.h> -#include <mach/board.h>  #include <mach/at91rm9200_mc.h> -#include "generic.h" - -static void __init eco920_map_io(void) -{ -	at91rm9200_initialize(18432000, AT91RM9200_PQFP); +#include <mach/at91_ramc.h> +#include <mach/cpu.h> -	/* Setup the LEDs */ -	at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1); - -	/* DBGU on ttyS0. (Rx & Tx only */ -	at91_register_uart(0, 0, 0); +#include "at91_aic.h" +#include "board.h" +#include "generic.h" +#include "gpio.h" -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} -static void __init eco920_init_irq(void) +static void __init eco920_init_early(void)  { -	at91rm9200_init_interrupts(NULL); +	/* Set cpu type: PQFP */ +	at91rm9200_set_type(ARCH_REVISON_9200_PQFP); + +	at91_initialize(18432000);  } -static struct at91_eth_data __initdata eco920_eth_data = { +static struct macb_platform_data __initdata eco920_eth_data = {  	.phy_irq_pin	= AT91_PIN_PC2,  	.is_rmii	= 1,  };  static struct at91_usbh_data __initdata eco920_usbh_data = {  	.ports		= 1, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata eco920_udc_data = { @@ -61,9 +58,12 @@ static struct at91_udc_data __initdata eco920_udc_data = {  	.pullup_pin	= AT91_PIN_PB13,  }; -static struct at91_mmc_data __initdata eco920_mmc_data = { -	.slot_b		= 0, -	.wire4		= 0, +static struct mci_platform_data __initdata eco920_mci0_data = { +	.slot[0] = { +		.bus_width	= 1, +		.detect_pin	= -EINVAL, +		.wp_pin		= -EINVAL, +	},  };  static struct physmap_flash_data eco920_flash_data = { @@ -86,21 +86,6 @@ static struct platform_device eco920_flash = {  	.num_resources  = 1,  }; -static struct resource at91_beeper_resources[] = { -	[0] = { -		.start          = AT91RM9200_BASE_TC3, -		.end            = AT91RM9200_BASE_TC3 + 0x39, -		.flags          = IORESOURCE_MEM, -	}, -}; - -static struct platform_device at91_beeper = { -	.name           = "at91_beeper", -	.id             = 0, -	.resource       = at91_beeper_resources, -	.num_resources  = ARRAY_SIZE(at91_beeper_resources), -}; -  static struct spi_board_info eco920_spi_devices[] = {  	{	/* CAN controller */  		.modalias	= "tlv5638", @@ -110,17 +95,37 @@ static struct spi_board_info eco920_spi_devices[] = {  	},  }; +/* + * LEDs + */ +static struct gpio_led eco920_leds[] = { +	{       /* D1 */ +		.name                   = "led1", +		.gpio                   = AT91_PIN_PB0, +		.active_low             = 1, +		.default_trigger        = "heartbeat", +	}, +	{       /* D2 */ +		.name                   = "led2", +		.gpio                   = AT91_PIN_PB1, +		.active_low             = 1, +		.default_trigger        = "timer", +	} +}; +  static void __init eco920_board_init(void)  { +	/* DBGU on ttyS0. (Rx & Tx only */ +	at91_register_uart(0, 0, 0);  	at91_add_device_serial();  	at91_add_device_eth(&eco920_eth_data);  	at91_add_device_usbh(&eco920_usbh_data);  	at91_add_device_udc(&eco920_udc_data); -	at91_add_device_mmc(0, &eco920_mmc_data); +	at91_add_device_mci(0, &eco920_mci0_data);  	platform_device_register(&eco920_flash); -	at91_sys_write(AT91_SMC_CSR(7),	AT91_SMC_RWHOLD_(1) +	at91_ramc_write(0, AT91_SMC_CSR(7),	AT91_SMC_RWHOLD_(1)  				| AT91_SMC_RWSETUP_(1)  				| AT91_SMC_DBW_8  				| AT91_SMC_WSEN @@ -132,25 +137,24 @@ static void __init eco920_board_init(void)  	at91_set_deglitch(AT91_PIN_PA23, 1);  /* Initialization of the Static Memory Controller for Chip Select 3 */ -	at91_sys_write(AT91_SMC_CSR(3), +	at91_ramc_write(0, AT91_SMC_CSR(3),  		AT91_SMC_DBW_16  |	/* 16 bit */  		AT91_SMC_WSEN    |  		AT91_SMC_NWS_(5) |	/* wait states */  		AT91_SMC_TDF_(1)	/* float time */  	); -	at91_clock_associate("tc3_clk", &at91_beeper.dev, "at91_beeper"); -	at91_set_B_periph(AT91_PIN_PB6, 0); -	platform_device_register(&at91_beeper); -  	at91_add_device_spi(eco920_spi_devices, ARRAY_SIZE(eco920_spi_devices)); +	/* LEDs */ +	at91_gpio_leds(eco920_leds, ARRAY_SIZE(eco920_leds));  }  MACHINE_START(ECO920, "eco920")  	/* Maintainer: Sascha Hauer */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= eco920_map_io, -	.init_irq	= eco920_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= eco920_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= eco920_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-flexibity.c b/arch/arm/mach-at91/board-flexibity.c index c8a62dc8fa6..68f1ab6bd08 100644 --- a/arch/arm/mach-at91/board-flexibity.c +++ b/arch/arm/mach-at91/board-flexibity.c @@ -1,7 +1,7 @@  /*   * linux/arch/arm/mach-at91/board-flexibity.c   * - *  Copyright (C) 2010 Flexibity + *  Copyright (C) 2010-2011 Flexibity   *  Copyright (C) 2005 SAN People   *  Copyright (C) 2006 Atmel   * @@ -33,36 +33,36 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -static void __init flexibity_map_io(void) +static void __init flexibity_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91sam9260_initialize(18432000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init flexibity_init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); +	at91_initialize(18432000);  }  /* USB Host port */  static struct at91_usbh_data __initdata flexibity_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  /* USB Device port */  static struct at91_udc_data __initdata flexibity_udc_data = {  	.vbus_pin	= AT91_PIN_PC5, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */ +}; + +/* I2C devices */ +static struct i2c_board_info __initdata flexibity_i2c_devices[] = { +	{ +		I2C_BOARD_INFO("ds1307", 0x68), +	},  };  /* SPI devices */ @@ -76,11 +76,12 @@ static struct spi_board_info flexibity_spi_devices[] = {  };  /* MCI (SD/MMC) */ -static struct at91_mmc_data __initdata flexibity_mmc_data = { -	.slot_b		= 0, -	.wire4		= 1, -	.det_pin	= AT91_PIN_PC9, -	.wp_pin		= AT91_PIN_PC4, +static struct mci_platform_data __initdata flexibity_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PC9, +		.wp_pin		= AT91_PIN_PC4, +	},  };  /* LEDs */ @@ -138,25 +139,31 @@ static struct gpio_led flexibity_leds[] = {  static void __init flexibity_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0);  	at91_add_device_serial();  	/* USB Host */  	at91_add_device_usbh(&flexibity_usbh_data);  	/* USB Device */  	at91_add_device_udc(&flexibity_udc_data); +	/* I2C */ +	at91_add_device_i2c(flexibity_i2c_devices, +		ARRAY_SIZE(flexibity_i2c_devices));  	/* SPI */  	at91_add_device_spi(flexibity_spi_devices,  		ARRAY_SIZE(flexibity_spi_devices));  	/* MMC */ -	at91_add_device_mmc(0, &flexibity_mmc_data); +	at91_add_device_mci(0, &flexibity_mci0_data);  	/* LEDs */  	at91_gpio_leds(flexibity_leds, ARRAY_SIZE(flexibity_leds));  }  MACHINE_START(FLEXIBITY, "Flexibity Connect")  	/* Maintainer: Maxim Osipov */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= flexibity_map_io, -	.init_irq	= flexibity_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= flexibity_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= flexibity_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-foxg20.c b/arch/arm/mach-at91/board-foxg20.c new file mode 100644 index 00000000000..8b22c60bb23 --- /dev/null +++ b/arch/arm/mach-at91/board-foxg20.c @@ -0,0 +1,272 @@ +/* + *  Copyright (C) 2005 SAN People + *  Copyright (C) 2008 Atmel + *  Copyright (C) 2010 Lee McLoughlin - lee@lmmrtech.com + *  Copyright (C) 2010 Sergio Tanzilli - tanzilli@acmesystems.it + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + +#include <linux/types.h> +#include <linux/init.h> +#include <linux/mm.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/spi/spi.h> +#include <linux/spi/at73c213.h> +#include <linux/gpio.h> +#include <linux/gpio_keys.h> +#include <linux/input.h> +#include <linux/clk.h> +#include <linux/w1-gpio.h> + +#include <mach/hardware.h> +#include <asm/setup.h> +#include <asm/mach-types.h> +#include <asm/irq.h> + +#include <asm/mach/arch.h> +#include <asm/mach/map.h> +#include <asm/mach/irq.h> + +#include <mach/at91sam9_smc.h> + +#include "at91_aic.h" +#include "board.h" +#include "sam9_smc.h" +#include "generic.h" +#include "gpio.h" + +/* + * The FOX Board G20 hardware comes as the "Netus G20" board with + * just the cpu, ram, dataflash and two header connectors. + * This is plugged into the FOX Board which provides the ethernet, + * usb, rtc, leds, switch, ... + * + * For more info visit: http://www.acmesystems.it/foxg20 + */ + + +static void __init foxg20_init_early(void) +{ +	/* Initialize processor: 18.432 MHz crystal */ +	at91_initialize(18432000); +} + +/* + * USB Host port + */ +static struct at91_usbh_data __initdata foxg20_usbh_data = { +	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL}, +}; + +/* + * USB Device port + */ +static struct at91_udc_data __initdata foxg20_udc_data = { +	.vbus_pin	= AT91_PIN_PC6, +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */ +}; + + +/* + * SPI devices. + */ +static struct spi_board_info foxg20_spi_devices[] = { +#if !IS_ENABLED(CONFIG_MMC_ATMELMCI) +	{ +		.modalias	= "mtd_dataflash", +		.chip_select	= 1, +		.max_speed_hz	= 15 * 1000 * 1000, +		.bus_num	= 0, +	}, +#endif +}; + + +/* + * MACB Ethernet device + */ +static struct macb_platform_data __initdata foxg20_macb_data = { +	.phy_irq_pin	= AT91_PIN_PA7, +	.is_rmii	= 1, +}; + +/* + * MCI (SD/MMC) + * det_pin, wp_pin and vcc_pin are not connected + */ +static struct mci_platform_data __initdata foxg20_mci0_data = { +	.slot[1] = { +		.bus_width	= 4, +		.detect_pin	= -EINVAL, +		.wp_pin		= -EINVAL, +	}, +}; + + +/* + * LEDs + */ +static struct gpio_led foxg20_leds[] = { +	{	/* user led, red */ +		.name			= "user_led", +		.gpio			= AT91_PIN_PC7, +		.active_low		= 0, +		.default_trigger	= "heartbeat", +	}, +}; + + +/* + * GPIO Buttons + */ +#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) +static struct gpio_keys_button foxg20_buttons[] = { +	{ +		.gpio		= AT91_PIN_PC4, +		.code		= BTN_1, +		.desc		= "Button 1", +		.active_low	= 1, +		.wakeup		= 1, +	}, +}; + +static struct gpio_keys_platform_data foxg20_button_data = { +	.buttons	= foxg20_buttons, +	.nbuttons	= ARRAY_SIZE(foxg20_buttons), +}; + +static struct platform_device foxg20_button_device = { +	.name		= "gpio-keys", +	.id		= -1, +	.num_resources	= 0, +	.dev		= { +		.platform_data	= &foxg20_button_data, +	} +}; + +static void __init foxg20_add_device_buttons(void) +{ +	at91_set_gpio_input(AT91_PIN_PC4, 1);	/* btn1 */ +	at91_set_deglitch(AT91_PIN_PC4, 1); + +	platform_device_register(&foxg20_button_device); +} +#else +static void __init foxg20_add_device_buttons(void) {} +#endif + + +#if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE) +static struct w1_gpio_platform_data w1_gpio_pdata = { +	/* If you choose to use a pin other than PB16 it needs to be 3.3V */ +	.pin		= AT91_PIN_PB16, +	.is_open_drain  = 1, +	.ext_pullup_enable_pin	= -EINVAL, +}; + +static struct platform_device w1_device = { +	.name			= "w1-gpio", +	.id			= -1, +	.dev.platform_data	= &w1_gpio_pdata, +}; + +static void __init at91_add_device_w1(void) +{ +	at91_set_GPIO_periph(w1_gpio_pdata.pin, 1); +	at91_set_multi_drive(w1_gpio_pdata.pin, 1); +	platform_device_register(&w1_device); +} + +#endif + + +static struct i2c_board_info __initdata foxg20_i2c_devices[] = { +	{ +		I2C_BOARD_INFO("24c512", 0x50), +	}, +}; + + +static void __init foxg20_board_init(void) +{ +	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91SAM9260_ID_US0, 1, +				ATMEL_UART_CTS +				| ATMEL_UART_RTS +				| ATMEL_UART_DTR +				| ATMEL_UART_DSR +				| ATMEL_UART_DCD +				| ATMEL_UART_RI); + +	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ +	at91_register_uart(AT91SAM9260_ID_US1, 2, +		ATMEL_UART_CTS +		| ATMEL_UART_RTS); + +	/* USART2 on ttyS3. (Rx & Tx only) */ +	at91_register_uart(AT91SAM9260_ID_US2, 3, 0); + +	/* USART3 on ttyS4. (Rx, Tx, RTS, CTS) */ +	at91_register_uart(AT91SAM9260_ID_US3, 4, +		ATMEL_UART_CTS +		| ATMEL_UART_RTS); + +	/* USART4 on ttyS5. (Rx & Tx only) */ +	at91_register_uart(AT91SAM9260_ID_US4, 5, 0); + +	/* USART5 on ttyS6. (Rx & Tx only) */ +	at91_register_uart(AT91SAM9260_ID_US5, 6, 0); + +	/* Set the internal pull-up resistor on DRXD */ +	at91_set_A_periph(AT91_PIN_PB14, 1); +	at91_add_device_serial(); +	/* USB Host */ +	at91_add_device_usbh(&foxg20_usbh_data); +	/* USB Device */ +	at91_add_device_udc(&foxg20_udc_data); +	/* SPI */ +	at91_add_device_spi(foxg20_spi_devices, ARRAY_SIZE(foxg20_spi_devices)); +	/* Ethernet */ +	at91_add_device_eth(&foxg20_macb_data); +	/* MMC */ +	at91_add_device_mci(0, &foxg20_mci0_data); +	/* I2C */ +	at91_add_device_i2c(foxg20_i2c_devices, ARRAY_SIZE(foxg20_i2c_devices)); +	/* LEDs */ +	at91_gpio_leds(foxg20_leds, ARRAY_SIZE(foxg20_leds)); +	/* Push Buttons */ +	foxg20_add_device_buttons(); +#if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE) +	at91_add_device_w1(); +#endif +} + +MACHINE_START(ACMENETUSFOXG20, "Acme Systems srl FOX Board G20") +	/* Maintainer: Sergio Tanzilli */ +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= foxg20_init_early, +	.init_irq	= at91_init_irq_default, +	.init_machine	= foxg20_board_init, +MACHINE_END diff --git a/arch/arm/mach-at91/board-gsia18s.c b/arch/arm/mach-at91/board-gsia18s.c new file mode 100644 index 00000000000..b729dd1271b --- /dev/null +++ b/arch/arm/mach-at91/board-gsia18s.c @@ -0,0 +1,585 @@ +/* + *  Copyright (C) 2010 Christian Glindkamp <christian.glindkamp@taskit.de> + *                     taskit GmbH + *                2010 Igor Plyatov <plyatov@gmail.com> + *                     GeoSIG Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + +#include <linux/platform_device.h> +#include <linux/gpio.h> +#include <linux/w1-gpio.h> +#include <linux/i2c.h> +#include <linux/i2c/pcf857x.h> +#include <linux/gpio_keys.h> +#include <linux/input.h> + +#include <asm/mach-types.h> +#include <asm/mach/arch.h> + +#include <mach/at91sam9_smc.h> +#include <mach/hardware.h> + +#include "at91_aic.h" +#include "board.h" +#include "sam9_smc.h" +#include "generic.h" +#include "gsia18s.h" +#include "stamp9g20.h" +#include "gpio.h" + +static void __init gsia18s_init_early(void) +{ +	stamp9g20_init_early(); +} + +/* + * Two USB Host ports + */ +static struct at91_usbh_data __initdata usbh_data = { +	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL}, +}; + +/* + * USB Device port + */ +static struct at91_udc_data __initdata udc_data = { +	.vbus_pin	= AT91_PIN_PA22, +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */ +}; + +/* + * MACB Ethernet device + */ +static struct macb_platform_data __initdata macb_data = { +	.phy_irq_pin	= AT91_PIN_PA28, +	.is_rmii	= 1, +}; + +/* + * LEDs and GPOs + */ +static struct gpio_led gpio_leds[] = { +	{ +		.name			= "gpo:spi1reset", +		.gpio			= AT91_PIN_PC1, +		.active_low		= 0, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ +		.name			= "gpo:trig_net_out", +		.gpio			= AT91_PIN_PB20, +		.active_low		= 0, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ +		.name			= "gpo:trig_net_dir", +		.gpio			= AT91_PIN_PB19, +		.active_low		= 0, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ +		.name			= "gpo:charge_dis", +		.gpio			= AT91_PIN_PC2, +		.active_low		= 0, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ +		.name			= "led:event", +		.gpio			= AT91_PIN_PB17, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ +		.name			= "led:lan", +		.gpio			= AT91_PIN_PB18, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ +		.name			= "led:error", +		.gpio			= AT91_PIN_PB16, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_ON, +	} +}; + +static struct gpio_led_platform_data gpio_led_info = { +	.leds		= gpio_leds, +	.num_leds	= ARRAY_SIZE(gpio_leds), +}; + +static struct platform_device leds = { +	.name	= "leds-gpio", +	.id	= 0, +	.dev	= { +		.platform_data	= &gpio_led_info, +	} +}; + +static void __init gsia18s_leds_init(void) +{ +	platform_device_register(&leds); +} + +/* PCF8574 0x20 GPIO - U1 on the GS_IA18-CB_V3 board */ +static struct gpio_led pcf_gpio_leds1[] = { +	{ /* bit 0 */ +		.name			= "gpo:hdc_power", +		.gpio			= PCF_GPIO_HDC_POWER, +		.active_low		= 0, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ /* bit 1 */ +		.name			= "gpo:wifi_setup", +		.gpio			= PCF_GPIO_WIFI_SETUP, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ /* bit 2 */ +		.name			= "gpo:wifi_enable", +		.gpio			= PCF_GPIO_WIFI_ENABLE, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ /* bit 3	*/ +		.name			= "gpo:wifi_reset", +		.gpio			= PCF_GPIO_WIFI_RESET, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_ON, +	}, +	/* bit 4 used as GPI	*/ +	{ /* bit 5 */ +		.name			= "gpo:gps_setup", +		.gpio			= PCF_GPIO_GPS_SETUP, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ /* bit 6 */ +		.name			= "gpo:gps_standby", +		.gpio			= PCF_GPIO_GPS_STANDBY, +		.active_low		= 0, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_ON, +	}, +	{ /* bit 7 */ +		.name			= "gpo:gps_power", +		.gpio			= PCF_GPIO_GPS_POWER, +		.active_low		= 0, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	} +}; + +static struct gpio_led_platform_data pcf_gpio_led_info1 = { +	.leds		= pcf_gpio_leds1, +	.num_leds	= ARRAY_SIZE(pcf_gpio_leds1), +}; + +static struct platform_device pcf_leds1 = { +	.name	= "leds-gpio", /* GS_IA18-CB_board */ +	.id	= 1, +	.dev	= { +		.platform_data	= &pcf_gpio_led_info1, +	} +}; + +/* PCF8574 0x22 GPIO - U1 on the GS_2G_OPT1-A_V0 board (Alarm) */ +static struct gpio_led pcf_gpio_leds2[] = { +	{ /* bit 0 */ +		.name			= "gpo:alarm_1", +		.gpio			= PCF_GPIO_ALARM1, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ /* bit 1 */ +		.name			= "gpo:alarm_2", +		.gpio			= PCF_GPIO_ALARM2, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ /* bit 2 */ +		.name			= "gpo:alarm_3", +		.gpio			= PCF_GPIO_ALARM3, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	{ /* bit 3 */ +		.name			= "gpo:alarm_4", +		.gpio			= PCF_GPIO_ALARM4, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +	/* bits 4, 5, 6 not used */ +	{ /* bit 7 */ +		.name			= "gpo:alarm_v_relay_on", +		.gpio			= PCF_GPIO_ALARM_V_RELAY_ON, +		.active_low		= 0, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +}; + +static struct gpio_led_platform_data pcf_gpio_led_info2 = { +	.leds		= pcf_gpio_leds2, +	.num_leds	= ARRAY_SIZE(pcf_gpio_leds2), +}; + +static struct platform_device pcf_leds2 = { +	.name	= "leds-gpio", +	.id	= 2, +	.dev	= { +		.platform_data	= &pcf_gpio_led_info2, +	} +}; + +/* PCF8574 0x24 GPIO U1 on the GS_2G-OPT23-A_V0 board (Modem) */ +static struct gpio_led pcf_gpio_leds3[] = { +	{ /* bit 0 */ +		.name			= "gpo:modem_power", +		.gpio			= PCF_GPIO_MODEM_POWER, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_OFF, +	}, +		/* bits 1 and 2 not used */ +	{ /* bit 3 */ +		.name			= "gpo:modem_reset", +		.gpio			= PCF_GPIO_MODEM_RESET, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_ON, +	}, +		/* bits 4, 5 and 6 not used */ +	{ /* bit 7 */ +		.name			= "gpo:trx_reset", +		.gpio			= PCF_GPIO_TRX_RESET, +		.active_low		= 1, +		.default_trigger	= "none", +		.default_state		= LEDS_GPIO_DEFSTATE_ON, +	} +}; + +static struct gpio_led_platform_data pcf_gpio_led_info3 = { +	.leds		= pcf_gpio_leds3, +	.num_leds	= ARRAY_SIZE(pcf_gpio_leds3), +}; + +static struct platform_device pcf_leds3 = { +	.name	= "leds-gpio", +	.id	= 3, +	.dev	= { +		.platform_data	= &pcf_gpio_led_info3, +	} +}; + +static void __init gsia18s_pcf_leds_init(void) +{ +	platform_device_register(&pcf_leds1); +	platform_device_register(&pcf_leds2); +	platform_device_register(&pcf_leds3); +} + +/* + * SPI busses. + */ +static struct spi_board_info gsia18s_spi_devices[] = { +	{ /* User accessible spi0, cs0 used for communication with MSP RTC */ +		.modalias	= "spidev", +		.bus_num	= 0, +		.chip_select	= 0, +		.max_speed_hz	= 580000, +		.mode		= SPI_MODE_1, +	}, +	{ /* User accessible spi1, cs0 used for communication with int. DSP */ +		.modalias	= "spidev", +		.bus_num	= 1, +		.chip_select	= 0, +		.max_speed_hz	= 5600000, +		.mode		= SPI_MODE_0, +	}, +	{ /* User accessible spi1, cs1 used for communication with ext. DSP */ +		.modalias	= "spidev", +		.bus_num	= 1, +		.chip_select	= 1, +		.max_speed_hz	= 5600000, +		.mode		= SPI_MODE_0, +	}, +	{ /* User accessible spi1, cs2 used for communication with ext. DSP */ +		.modalias	= "spidev", +		.bus_num	= 1, +		.chip_select	= 2, +		.max_speed_hz	= 5600000, +		.mode		= SPI_MODE_0, +	}, +	{ /* User accessible spi1, cs3 used for communication with ext. DSP */ +		.modalias	= "spidev", +		.bus_num	= 1, +		.chip_select	= 3, +		.max_speed_hz	= 5600000, +		.mode		= SPI_MODE_0, +	} +}; + +/* + * GPI Buttons + */ +static struct gpio_keys_button buttons[] = { +	{ +		.gpio		= GPIO_TRIG_NET_IN, +		.code		= BTN_1, +		.desc		= "TRIG_NET_IN", +		.type		= EV_KEY, +		.active_low	= 0, +		.wakeup		= 1, +	}, +	{ /* SW80 on the GS_IA18_S-MN board*/ +		.gpio		= GPIO_CARD_UNMOUNT_0, +		.code		= BTN_2, +		.desc		= "Card umount 0", +		.type		= EV_KEY, +		.active_low	= 1, +		.wakeup		= 1, +	}, +	{ /* SW79 on the GS_IA18_S-MN board*/ +		.gpio		= GPIO_CARD_UNMOUNT_1, +		.code		= BTN_3, +		.desc		= "Card umount 1", +		.type		= EV_KEY, +		.active_low	= 1, +		.wakeup		= 1, +	}, +	{ /* SW280 on the GS_IA18-CB board*/ +		.gpio		= GPIO_KEY_POWER, +		.code		= KEY_POWER, +		.desc		= "Power Off Button", +		.type		= EV_KEY, +		.active_low	= 0, +		.wakeup		= 1, +	} +}; + +static struct gpio_keys_platform_data button_data = { +	.buttons	= buttons, +	.nbuttons	= ARRAY_SIZE(buttons), +}; + +static struct platform_device button_device = { +	.name		= "gpio-keys", +	.id		= -1, +	.num_resources	= 0, +	.dev		= { +		.platform_data	= &button_data, +	} +}; + +static void __init gsia18s_add_device_buttons(void) +{ +	at91_set_gpio_input(GPIO_TRIG_NET_IN, 1); +	at91_set_deglitch(GPIO_TRIG_NET_IN, 1); +	at91_set_gpio_input(GPIO_CARD_UNMOUNT_0, 1); +	at91_set_deglitch(GPIO_CARD_UNMOUNT_0, 1); +	at91_set_gpio_input(GPIO_CARD_UNMOUNT_1, 1); +	at91_set_deglitch(GPIO_CARD_UNMOUNT_1, 1); +	at91_set_gpio_input(GPIO_KEY_POWER, 0); +	at91_set_deglitch(GPIO_KEY_POWER, 1); + +	platform_device_register(&button_device); +} + +/* + * I2C + */ +static int pcf8574x_0x20_setup(struct i2c_client *client, int gpio, +				unsigned int ngpio, void *context) +{ +	int status; + +	status = gpio_request(gpio + PCF_GPIO_ETH_DETECT, "eth_det"); +	if (status < 0) { +		pr_err("error: can't request GPIO%d\n", +			gpio + PCF_GPIO_ETH_DETECT); +		return status; +	} +	status = gpio_direction_input(gpio + PCF_GPIO_ETH_DETECT); +	if (status < 0) { +		pr_err("error: can't setup GPIO%d as input\n", +			gpio + PCF_GPIO_ETH_DETECT); +		return status; +	} +	status = gpio_export(gpio + PCF_GPIO_ETH_DETECT, false); +	if (status < 0) { +		pr_err("error: can't export GPIO%d\n", +			gpio + PCF_GPIO_ETH_DETECT); +		return status; +	} +	status = gpio_sysfs_set_active_low(gpio + PCF_GPIO_ETH_DETECT, 1); +	if (status < 0) { +		pr_err("error: gpio_sysfs_set active_low(GPIO%d, 1)\n", +			gpio + PCF_GPIO_ETH_DETECT); +		return status; +	} + +	return 0; +} + +static int pcf8574x_0x20_teardown(struct i2c_client *client, int gpio, +					unsigned ngpio, void *context) +{ +	gpio_free(gpio + PCF_GPIO_ETH_DETECT); +	return 0; +} + +static struct pcf857x_platform_data pcf20_pdata = { +	.gpio_base	= GS_IA18_S_PCF_GPIO_BASE0, +	.n_latch	= (1 << 4), +	.setup		= pcf8574x_0x20_setup, +	.teardown	= pcf8574x_0x20_teardown, +}; + +static struct pcf857x_platform_data pcf22_pdata = { +	.gpio_base	= GS_IA18_S_PCF_GPIO_BASE1, +}; + +static struct pcf857x_platform_data pcf24_pdata = { +	.gpio_base	= GS_IA18_S_PCF_GPIO_BASE2, +}; + +static struct i2c_board_info __initdata gsia18s_i2c_devices[] = { +	{ /* U1 on the GS_IA18-CB_V3 board */ +		I2C_BOARD_INFO("pcf8574", 0x20), +		.platform_data = &pcf20_pdata, +	}, +	{ /* U1 on the GS_2G_OPT1-A_V0 board (Alarm) */ +		I2C_BOARD_INFO("pcf8574", 0x22), +		.platform_data = &pcf22_pdata, +	}, +	{ /* U1 on the GS_2G-OPT23-A_V0 board (Modem) */ +		I2C_BOARD_INFO("pcf8574", 0x24), +		.platform_data = &pcf24_pdata, +	}, +	{ /* U161 on the GS_IA18_S-MN board */ +		I2C_BOARD_INFO("24c1024", 0x50), +	}, +	{ /* U162 on the GS_IA18_S-MN board */ +		I2C_BOARD_INFO("24c01", 0x53), +	}, +}; + +/* + * Compact Flash + */ +static struct at91_cf_data __initdata gsia18s_cf1_data = { +	.irq_pin	= AT91_PIN_PA27, +	.det_pin	= AT91_PIN_PB30, +	.vcc_pin	= -EINVAL, +	.rst_pin	= AT91_PIN_PB31, +	.chipselect	= 5, +	.flags		= AT91_CF_TRUE_IDE, +}; + +/* Power Off by RTC */ +static void gsia18s_power_off(void) +{ +	pr_notice("Power supply will be switched off automatically now or after 60 seconds without ArmDAS.\n"); +	at91_set_gpio_output(AT91_PIN_PA25, 1); +	/* Spin to death... */ +	while (1) +		; +} + +static int __init gsia18s_power_off_init(void) +{ +	pm_power_off = gsia18s_power_off; +	return 0; +} + +/* ---------------------------------------------------------------------------*/ + +static void __init gsia18s_board_init(void) +{ +	/* +	 * USART0 on ttyS1 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI). +	 * Used for Internal Analog Modem. +	 */ +	at91_register_uart(AT91SAM9260_ID_US0, 1, +				ATMEL_UART_CTS | ATMEL_UART_RTS | +				ATMEL_UART_DTR | ATMEL_UART_DSR | +				ATMEL_UART_DCD | ATMEL_UART_RI); +	/* +	 * USART1 on ttyS2 (Rx, Tx, CTS, RTS). +	 * Used for GPS or WiFi or Data stream. +	 */ +	at91_register_uart(AT91SAM9260_ID_US1, 2, +				ATMEL_UART_CTS | ATMEL_UART_RTS); +	/* +	 * USART2 on ttyS3 (Rx, Tx, CTS, RTS). +	 * Used for External Modem. +	 */ +	at91_register_uart(AT91SAM9260_ID_US2, 3, +				ATMEL_UART_CTS | ATMEL_UART_RTS); +	/* +	 * USART3 on ttyS4 (Rx, Tx, RTS). +	 * Used for RS-485. +	 */ +	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS); + +	/* +	 * USART4 on ttyS5 (Rx, Tx). +	 * Used for TRX433 Radio Module. +	 */ +	at91_register_uart(AT91SAM9260_ID_US4, 5, 0); +	stamp9g20_board_init(); +	at91_add_device_usbh(&usbh_data); +	at91_add_device_udc(&udc_data); +	at91_add_device_eth(&macb_data); +	gsia18s_leds_init(); +	gsia18s_pcf_leds_init(); +	gsia18s_add_device_buttons(); +	at91_add_device_i2c(gsia18s_i2c_devices, +				ARRAY_SIZE(gsia18s_i2c_devices)); +	at91_add_device_cf(&gsia18s_cf1_data); +	at91_add_device_spi(gsia18s_spi_devices, +				ARRAY_SIZE(gsia18s_spi_devices)); +	gsia18s_power_off_init(); +} + +MACHINE_START(GSIA18S, "GS_IA18_S") +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= gsia18s_init_early, +	.init_irq	= at91_init_irq_default, +	.init_machine	= gsia18s_board_init, +MACHINE_END diff --git a/arch/arm/mach-at91/board-kafa.c b/arch/arm/mach-at91/board-kafa.c index c0ce79d431a..93b1df42f63 100644 --- a/arch/arm/mach-at91/board-kafa.c +++ b/arch/arm/mach-at91/board-kafa.c @@ -19,6 +19,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -33,47 +34,32 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h> +#include <mach/cpu.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -/* - * Serial port configuration. - *    0 .. 3 = USART0 .. USART3 - *    4      = DBGU - */ -static struct at91_uart_config __initdata kafa_uart_config = { -	.console_tty	= 0,				/* ttyS0 */ -	.nr_tty		= 2, -	.tty_map	= { 4, 0, -1, -1, -1 }		/* ttyS0, ..., ttyS4 */ -}; - -static void __init kafa_map_io(void) +static void __init kafa_init_early(void)  { -	/* Initialize processor: 18.432 MHz crystal */ -	at91rm9200_initialize(18432000, AT91RM9200_PQFP); - -	/* Set up the LEDs */ -	at91_init_leds(AT91_PIN_PB4, AT91_PIN_PB4); - -	/* Setup the serial ports and console */ -	at91_init_serial(&kafa_uart_config); -} +	/* Set cpu type: PQFP */ +	at91rm9200_set_type(ARCH_REVISON_9200_PQFP); -static void __init kafa_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); +	/* Initialize processor: 18.432 MHz crystal */ +	at91_initialize(18432000);  } -static struct at91_eth_data __initdata kafa_eth_data = { +static struct macb_platform_data __initdata kafa_eth_data = {  	.phy_irq_pin	= AT91_PIN_PC4,  	.is_rmii	= 0,  };  static struct at91_usbh_data __initdata kafa_usbh_data = {  	.ports		= 1, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata kafa_udc_data = { @@ -81,9 +67,26 @@ static struct at91_udc_data __initdata kafa_udc_data = {  	.pullup_pin	= AT91_PIN_PB7,  }; +/* + * LEDs + */ +static struct gpio_led kafa_leds[] = { +	{	/* D1 */ +		.name			= "led1", +		.gpio			= AT91_PIN_PB4, +		.active_low		= 1, +		.default_trigger	= "heartbeat", +	}, +}; +  static void __init kafa_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1 (Rx, Tx, CTS, RTS) */ +	at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);  	at91_add_device_serial();  	/* Ethernet */  	at91_add_device_eth(&kafa_eth_data); @@ -95,13 +98,16 @@ static void __init kafa_board_init(void)  	at91_add_device_i2c(NULL, 0);  	/* SPI */  	at91_add_device_spi(NULL, 0); +	/* LEDs */ +	at91_gpio_leds(kafa_leds, ARRAY_SIZE(kafa_leds));  }  MACHINE_START(KAFA, "Sperry-Sun KAFA")  	/* Maintainer: Sergei Sharonov */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= kafa_map_io, -	.init_irq	= kafa_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= kafa_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= kafa_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c index a13d2063faf..d58d36225e0 100644 --- a/arch/arm/mach-at91/board-kb9202.c +++ b/arch/arm/mach-at91/board-kb9202.c @@ -20,6 +20,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -34,50 +35,34 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h> - +#include <mach/cpu.h>  #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -static void __init kb9202_map_io(void) +static void __init kb9202_init_early(void)  { -	/* Initialize processor: 10 MHz crystal */ -	at91rm9200_initialize(10000000, AT91RM9200_PQFP); - -	/* Set up the LEDs */ -	at91_init_leds(AT91_PIN_PC19, AT91_PIN_PC18); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1 (Rx & Tx only) */ -	at91_register_uart(AT91RM9200_ID_US0, 1, 0); - -	/* USART1 on ttyS2 (Rx & Tx only) - IRDA (optional) */ -	at91_register_uart(AT91RM9200_ID_US1, 2, 0); - -	/* USART3 on ttyS3 (Rx, Tx, CTS, RTS) - RS485 (optional) */ -	at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_CTS | ATMEL_UART_RTS); +	/* Set cpu type: PQFP */ +	at91rm9200_set_type(ARCH_REVISON_9200_PQFP); -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init kb9202_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); +	/* Initialize processor: 10 MHz crystal */ +	at91_initialize(10000000);  } -static struct at91_eth_data __initdata kb9202_eth_data = { +static struct macb_platform_data __initdata kb9202_eth_data = {  	.phy_irq_pin	= AT91_PIN_PB29,  	.is_rmii	= 0,  };  static struct at91_usbh_data __initdata kb9202_usbh_data = {  	.ports		= 1, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata kb9202_udc_data = { @@ -85,10 +70,12 @@ static struct at91_udc_data __initdata kb9202_udc_data = {  	.pullup_pin	= AT91_PIN_PB22,  }; -static struct at91_mmc_data __initdata kb9202_mmc_data = { -	.det_pin	= AT91_PIN_PB2, -	.slot_b		= 0, -	.wire4		= 1, +static struct mci_platform_data __initdata kb9202_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PB2, +		.wp_pin		= -EINVAL, +	},  };  static struct mtd_partition __initdata kb9202_nand_partition[] = { @@ -99,24 +86,49 @@ static struct mtd_partition __initdata kb9202_nand_partition[] = {  	},  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(kb9202_nand_partition); -	return kb9202_nand_partition; -} -  static struct atmel_nand_data __initdata kb9202_nand_data = {  	.ale		= 22,  	.cle		= 21, -	// .det_pin	= ... not there +	.det_pin	= -EINVAL,  	.rdy_pin	= AT91_PIN_PC29,  	.enable_pin	= AT91_PIN_PC28, -	.partition_info	= nand_partitions, +	.ecc_mode	= NAND_ECC_SOFT, +	.parts		= kb9202_nand_partition, +	.num_parts	= ARRAY_SIZE(kb9202_nand_partition), +}; + +/* + * LEDs + */ +static struct gpio_led kb9202_leds[] = { +	{	/* D1 */ +		.name			= "led1", +		.gpio			= AT91_PIN_PC19, +		.active_low		= 1, +		.default_trigger	= "heartbeat", +	}, +	{	/* D2 */ +		.name			= "led2", +		.gpio			= AT91_PIN_PC18, +		.active_low		= 1, +		.default_trigger	= "timer", +	}  };  static void __init kb9202_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1 (Rx & Tx only) */ +	at91_register_uart(AT91RM9200_ID_US0, 1, 0); + +	/* USART1 on ttyS2 (Rx & Tx only) - IRDA (optional) */ +	at91_register_uart(AT91RM9200_ID_US1, 2, 0); + +	/* USART3 on ttyS3 (Rx, Tx, CTS, RTS) - RS485 (optional) */ +	at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);  	at91_add_device_serial();  	/* Ethernet */  	at91_add_device_eth(&kb9202_eth_data); @@ -125,20 +137,23 @@ static void __init kb9202_board_init(void)  	/* USB Device */  	at91_add_device_udc(&kb9202_udc_data);  	/* MMC */ -	at91_add_device_mmc(0, &kb9202_mmc_data); +	at91_add_device_mci(0, &kb9202_mci0_data);  	/* I2C */  	at91_add_device_i2c(NULL, 0);  	/* SPI */  	at91_add_device_spi(NULL, 0);  	/* NAND */  	at91_add_device_nand(&kb9202_nand_data); +	/* LEDs */ +	at91_gpio_leds(kb9202_leds, ARRAY_SIZE(kb9202_leds));  }  MACHINE_START(KB9200, "KB920x")  	/* Maintainer: KwikByte, Inc. */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= kb9202_map_io, -	.init_irq	= kb9202_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= kb9202_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= kb9202_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-neocore926.c b/arch/arm/mach-at91/board-neocore926.c deleted file mode 100644 index fe5f1d47e6e..00000000000 --- a/arch/arm/mach-at91/board-neocore926.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - * linux/arch/arm/mach-at91/board-neocore926.c - * - *  Copyright (C) 2005 SAN People - *  Copyright (C) 2007 Atmel Corporation - *  Copyright (C) 2008 ADENEO. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#include <linux/types.h> -#include <linux/init.h> -#include <linux/mm.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/spi/spi.h> -#include <linux/spi/ads7846.h> -#include <linux/fb.h> -#include <linux/gpio_keys.h> -#include <linux/input.h> - -#include <video/atmel_lcdc.h> - -#include <asm/setup.h> -#include <asm/mach-types.h> -#include <asm/irq.h> -#include <asm/sizes.h> - -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/mach/irq.h> - -#include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h> -#include <mach/at91sam9_smc.h> - -#include "sam9_smc.h" -#include "generic.h" - - -static void __init neocore926_map_io(void) -{ -	/* Initialize processor: 20 MHz crystal */ -	at91sam9263_initialize(20000000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */ -	at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init neocore926_init_irq(void) -{ -	at91sam9263_init_interrupts(NULL); -} - - -/* - * USB Host port - */ -static struct at91_usbh_data __initdata neocore926_usbh_data = { -	.ports		= 2, -	.vbus_pin	= { AT91_PIN_PA24, AT91_PIN_PA21 }, -}; - -/* - * USB Device port - */ -static struct at91_udc_data __initdata neocore926_udc_data = { -	.vbus_pin	= AT91_PIN_PA25, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ -}; - - -/* - * ADS7846 Touchscreen - */ -#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) -static int ads7843_pendown_state(void) -{ -	return !at91_get_gpio_value(AT91_PIN_PA15);	/* Touchscreen PENIRQ */ -} - -static struct ads7846_platform_data ads_info = { -	.model			= 7843, -	.x_min			= 150, -	.x_max			= 3830, -	.y_min			= 190, -	.y_max			= 3830, -	.vref_delay_usecs	= 100, -	.x_plate_ohms		= 450, -	.y_plate_ohms		= 250, -	.pressure_max		= 15000, -	.debounce_max		= 1, -	.debounce_rep		= 0, -	.debounce_tol		= (~0), -	.get_pendown_state	= ads7843_pendown_state, -}; - -static void __init neocore926_add_device_ts(void) -{ -	at91_set_B_periph(AT91_PIN_PA15, 1);	/* External IRQ1, with pullup */ -	at91_set_gpio_input(AT91_PIN_PC13, 1);	/* Touchscreen BUSY signal */ -} -#else -static void __init neocore926_add_device_ts(void) {} -#endif - -/* - * SPI devices. - */ -static struct spi_board_info neocore926_spi_devices[] = { -#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD) -	{	/* DataFlash card */ -		.modalias	= "mtd_dataflash", -		.chip_select	= 0, -		.max_speed_hz	= 15 * 1000 * 1000, -		.bus_num	= 0, -	}, -#endif -#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) -	{ -		.modalias	= "ads7846", -		.chip_select	= 1, -		.max_speed_hz	= 125000 * 16, -		.bus_num	= 0, -		.platform_data	= &ads_info, -		.irq		= AT91SAM9263_ID_IRQ1, -	}, -#endif -}; - - -/* - * MCI (SD/MMC) - */ -static struct at91_mmc_data __initdata neocore926_mmc_data = { -	.wire4		= 1, -	.det_pin	= AT91_PIN_PE18, -	.wp_pin		= AT91_PIN_PE19, -}; - - -/* - * MACB Ethernet device - */ -static struct at91_eth_data __initdata neocore926_macb_data = { -	.phy_irq_pin	= AT91_PIN_PE31, -	.is_rmii	= 1, -}; - - -/* - * NAND flash - */ -static struct mtd_partition __initdata neocore926_nand_partition[] = { -	{ -		.name	= "Linux Kernel",	/* "Partition 1", */ -		.offset	= 0, -		.size	= SZ_8M, -	}, -	{ -		.name	= "Filesystem",		/* "Partition 2", */ -		.offset	= MTDPART_OFS_NXTBLK, -		.size	= SZ_32M, -	}, -	{ -		.name	= "Free",		/* "Partition 3", */ -		.offset	= MTDPART_OFS_NXTBLK, -		.size	= MTDPART_SIZ_FULL, -	}, -}; - -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(neocore926_nand_partition); -	return neocore926_nand_partition; -} - -static struct atmel_nand_data __initdata neocore926_nand_data = { -	.ale			= 21, -	.cle			= 22, -	.rdy_pin		= AT91_PIN_PB19, -	.rdy_pin_active_low	= 1, -	.enable_pin		= AT91_PIN_PD15, -	.partition_info		= nand_partitions, -}; - -static struct sam9_smc_config __initdata neocore926_nand_smc_config = { -	.ncs_read_setup		= 0, -	.nrd_setup		= 1, -	.ncs_write_setup	= 0, -	.nwe_setup		= 1, - -	.ncs_read_pulse		= 4, -	.nrd_pulse		= 4, -	.ncs_write_pulse	= 4, -	.nwe_pulse		= 4, - -	.read_cycle		= 6, -	.write_cycle		= 6, - -	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8, -	.tdf_cycles		= 2, -}; - -static void __init neocore926_add_device_nand(void) -{ -	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &neocore926_nand_smc_config); - -	at91_add_device_nand(&neocore926_nand_data); -} - - -/* - * LCD Controller - */ -#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) -static struct fb_videomode at91_tft_vga_modes[] = { -	{ -		.name		= "TX09D50VM1CCA @ 60", -		.refresh	= 60, -		.xres		= 240,		.yres		= 320, -		.pixclock	= KHZ2PICOS(5000), - -		.left_margin	= 1,		.right_margin	= 33, -		.upper_margin	= 1,		.lower_margin	= 0, -		.hsync_len	= 5,		.vsync_len	= 1, - -		.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, -		.vmode		= FB_VMODE_NONINTERLACED, -	}, -}; - -static struct fb_monspecs at91fb_default_monspecs = { -	.manufacturer	= "HIT", -	.monitor	= "TX09D70VM1CCA", - -	.modedb		= at91_tft_vga_modes, -	.modedb_len	= ARRAY_SIZE(at91_tft_vga_modes), -	.hfmin		= 15000, -	.hfmax		= 64000, -	.vfmin		= 50, -	.vfmax		= 150, -}; - -#define AT91SAM9263_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \ -					| ATMEL_LCDC_DISTYPE_TFT \ -					| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE) - -static void at91_lcdc_power_control(int on) -{ -	at91_set_gpio_value(AT91_PIN_PA30, on); -} - -/* Driver datas */ -static struct atmel_lcdfb_info __initdata neocore926_lcdc_data = { -	.lcdcon_is_backlight		= true, -	.default_bpp			= 16, -	.default_dmacon			= ATMEL_LCDC_DMAEN, -	.default_lcdcon2		= AT91SAM9263_DEFAULT_LCDCON2, -	.default_monspecs		= &at91fb_default_monspecs, -	.atmel_lcdfb_power_control	= at91_lcdc_power_control, -	.guard_time			= 1, -	.lcd_wiring_mode		= ATMEL_LCDC_WIRING_RGB555, -}; - -#else -static struct atmel_lcdfb_info __initdata neocore926_lcdc_data; -#endif - - -/* - * GPIO Buttons - */ -#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) -static struct gpio_keys_button neocore926_buttons[] = { -	{	/* BP1, "leftclic" */ -		.code		= BTN_LEFT, -		.gpio		= AT91_PIN_PC5, -		.active_low	= 1, -		.desc		= "left_click", -		.wakeup		= 1, -	}, -	{	/* BP2, "rightclic" */ -		.code		= BTN_RIGHT, -		.gpio		= AT91_PIN_PC4, -		.active_low	= 1, -		.desc		= "right_click", -		.wakeup		= 1, -	}, -}; - -static struct gpio_keys_platform_data neocore926_button_data = { -	.buttons	= neocore926_buttons, -	.nbuttons	= ARRAY_SIZE(neocore926_buttons), -}; - -static struct platform_device neocore926_button_device = { -	.name		= "gpio-keys", -	.id		= -1, -	.num_resources	= 0, -	.dev		= { -		.platform_data	= &neocore926_button_data, -	} -}; - -static void __init neocore926_add_device_buttons(void) -{ -	at91_set_GPIO_periph(AT91_PIN_PC5, 0);	/* left button */ -	at91_set_deglitch(AT91_PIN_PC5, 1); -	at91_set_GPIO_periph(AT91_PIN_PC4, 0);	/* right button */ -	at91_set_deglitch(AT91_PIN_PC4, 1); - -	platform_device_register(&neocore926_button_device); -} -#else -static void __init neocore926_add_device_buttons(void) {} -#endif - - -/* - * AC97 - */ -static struct ac97c_platform_data neocore926_ac97_data = { -	.reset_pin	= AT91_PIN_PA13, -}; - - -static void __init neocore926_board_init(void) -{ -	/* Serial */ -	at91_add_device_serial(); - -	/* USB Host */ -	at91_add_device_usbh(&neocore926_usbh_data); - -	/* USB Device */ -	at91_add_device_udc(&neocore926_udc_data); - -	/* SPI */ -	at91_set_gpio_output(AT91_PIN_PE20, 1);		/* select spi0 clock */ -	at91_add_device_spi(neocore926_spi_devices, ARRAY_SIZE(neocore926_spi_devices)); - -	/* Touchscreen */ -	neocore926_add_device_ts(); - -	/* MMC */ -	at91_add_device_mmc(1, &neocore926_mmc_data); - -	/* Ethernet */ -	at91_add_device_eth(&neocore926_macb_data); - -	/* NAND */ -	neocore926_add_device_nand(); - -	/* I2C */ -	at91_add_device_i2c(NULL, 0); - -	/* LCD Controller */ -	at91_add_device_lcdc(&neocore926_lcdc_data); - -	/* Push Buttons */ -	neocore926_add_device_buttons(); - -	/* AC97 */ -	at91_add_device_ac97(&neocore926_ac97_data); -} - -MACHINE_START(NEOCORE926, "ADENEO NEOCORE 926") -	/* Maintainer: ADENEO */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= neocore926_map_io, -	.init_irq	= neocore926_init_irq, -	.init_machine	= neocore926_board_init, -MACHINE_END diff --git a/arch/arm/mach-at91/board-pcontrol-g20.c b/arch/arm/mach-at91/board-pcontrol-g20.c index bba5a560e02..b48d95ec515 100644 --- a/arch/arm/mach-at91/board-pcontrol-g20.c +++ b/arch/arm/mach-at91/board-pcontrol-g20.c @@ -29,75 +29,22 @@  #include <asm/mach-types.h>  #include <asm/mach/arch.h> -#include <mach/board.h>  #include <mach/at91sam9_smc.h> +#include <mach/hardware.h> +#include "at91_aic.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "stamp9g20.h" +#include "gpio.h" -static void __init pcontrol_g20_map_io(void) +static void __init pcontrol_g20_init_early(void)  { -	/* Initialize processor: 18.432 MHz crystal */ -	at91sam9260_initialize(18432000); - -	/* DGBU on ttyS0. (Rx, Tx) only TTL -> JTAG connector X7 17,19 ) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS) piggyback  A2 */ -	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS -						| ATMEL_UART_RTS); - -	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS) isolated RS485  X5 */ -	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS -						| ATMEL_UART_RTS); - -	/* USART2 on ttyS3. (Rx, Tx)  9bit-Bus  Multidrop-mode  X4 */ -	at91_register_uart(AT91SAM9260_ID_US4, 3, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - - -static void __init init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); +	stamp9g20_init_early();  } - -/* - * NAND flash 512MiB 1,8V 8-bit, sector size 128 KiB - */ -static struct atmel_nand_data __initdata nand_data = { -	.ale		= 21, -	.cle		= 22, -	.rdy_pin	= AT91_PIN_PC13, -	.enable_pin	= AT91_PIN_PC14, -}; - -/* - * Bus timings; unit = 7.57ns - */ -static struct sam9_smc_config __initdata nand_smc_config = { -	.ncs_read_setup		= 0, -	.nrd_setup		= 2, -	.ncs_write_setup	= 0, -	.nwe_setup		= 2, - -	.ncs_read_pulse		= 4, -	.nrd_pulse		= 4, -	.ncs_write_pulse	= 4, -	.nwe_pulse		= 4, - -	.read_cycle		= 7, -	.write_cycle		= 7, - -	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE -			| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8, -	.tdf_cycles		= 3, -}; -  static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { {  	.ncs_read_setup		= 16,  	.nrd_setup		= 18, @@ -138,45 +85,22 @@ static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { {  	.tdf_cycles		= 1,  } }; -static void __init add_device_nand(void) -{ -	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &nand_smc_config); -	at91_add_device_nand(&nand_data); -} - -  static void __init add_device_pcontrol(void)  {  	/* configure chip-select 4 (IO compatible to 8051  X4 ) */ -	sam9_smc_configure(4, &pcontrol_smc_config[0]); +	sam9_smc_configure(0, 4, &pcontrol_smc_config[0]);  	/* configure chip-select 7 (FerroRAM 256KiBx16bit MR2A16A  D4 ) */ -	sam9_smc_configure(7, &pcontrol_smc_config[1]); +	sam9_smc_configure(0, 7, &pcontrol_smc_config[1]);  }  /* - * MCI (SD/MMC) - * det_pin, wp_pin and vcc_pin are not connected - */ -#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE) -static struct mci_platform_data __initdata mmc_data = { -	.slot[0] = { -		.bus_width	= 4, -	}, -}; -#else -static struct at91_mmc_data __initdata mmc_data = { -	.wire4		= 1, -}; -#endif - - -/*   * USB Host port   */  static struct at91_usbh_data __initdata usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  }; @@ -192,7 +116,7 @@ static struct at91_udc_data __initdata pcontrol_g20_udc_data = {  /*   * MACB Ethernet device   */ -static struct at91_eth_data __initdata macb_data = { +static struct macb_platform_data __initdata macb_data = {  	.phy_irq_pin	= AT91_PIN_PA28,  	.is_rmii	= 1,  }; @@ -265,42 +189,23 @@ static struct spi_board_info pcontrol_g20_spi_devices[] = {  }; -/* - * Dallas 1-Wire  DS2431 - */ -static struct w1_gpio_platform_data w1_gpio_pdata = { -	.pin		= AT91_PIN_PA29, -	.is_open_drain	= 1, -}; - -static struct platform_device w1_device = { -	.name			= "w1-gpio", -	.id			= -1, -	.dev.platform_data	= &w1_gpio_pdata, -}; - -static void add_wire1(void) +static void __init pcontrol_g20_board_init(void)  { -	at91_set_GPIO_periph(w1_gpio_pdata.pin, 1); -	at91_set_multi_drive(w1_gpio_pdata.pin, 1); -	platform_device_register(&w1_device); -} +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS) piggyback  A2 */ +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS +						| ATMEL_UART_RTS); +	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS) isolated RS485  X5 */ +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS +						| ATMEL_UART_RTS); -static void __init pcontrol_g20_board_init(void) -{ -	at91_add_device_serial(); -	add_device_nand(); -#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE) -	at91_add_device_mci(0, &mmc_data); -#else -	at91_add_device_mmc(0, &mmc_data); -#endif +	/* USART2 on ttyS3. (Rx, Tx)  9bit-Bus  Multidrop-mode  X4 */ +	at91_register_uart(AT91SAM9260_ID_US4, 3, 0); +	stamp9g20_board_init();  	at91_add_device_usbh(&usbh_data);  	at91_add_device_eth(&macb_data);  	at91_add_device_i2c(pcontrol_g20_i2c_devices,  		ARRAY_SIZE(pcontrol_g20_i2c_devices)); -	add_wire1();  	add_device_pcontrol();  	at91_add_device_spi(pcontrol_g20_spi_devices,  		ARRAY_SIZE(pcontrol_g20_spi_devices)); @@ -314,9 +219,10 @@ static void __init pcontrol_g20_board_init(void)  MACHINE_START(PCONTROL_G20, "PControl G20")  	/* Maintainer: pgsellmann@portner-elektronik.at */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= pcontrol_g20_map_io, -	.init_irq	= init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= pcontrol_g20_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= pcontrol_g20_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-picotux200.c b/arch/arm/mach-at91/board-picotux200.c index 9d833bbc592..2c0f2d554d8 100644 --- a/arch/arm/mach-at91/board-picotux200.c +++ b/arch/arm/mach-at91/board-picotux200.c @@ -20,6 +20,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -36,74 +37,40 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -/* - * Serial port configuration. - *    0 .. 3 = USART0 .. USART3 - *    4      = DBGU - */ -static struct at91_uart_config __initdata picotux200_uart_config = { -	.console_tty	= 0,				/* ttyS0 */ -	.nr_tty		= 2, -	.tty_map	= { 4, 1, -1, -1, -1 }		/* ttyS0, ..., ttyS4 */ -}; - -static void __init picotux200_map_io(void) +static void __init picotux200_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91rm9200_initialize(18432000, AT91RM9200_BGA); - -	/* Setup the serial ports and console */ -	at91_init_serial(&picotux200_uart_config); +	at91_initialize(18432000);  } -static void __init picotux200_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); -} - -static struct at91_eth_data __initdata picotux200_eth_data = { +static struct macb_platform_data __initdata picotux200_eth_data = {  	.phy_irq_pin	= AT91_PIN_PC4,  	.is_rmii	= 1,  };  static struct at91_usbh_data __initdata picotux200_usbh_data = {  	.ports		= 1, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  }; -// static struct at91_udc_data __initdata picotux200_udc_data = { -// 	.vbus_pin	= AT91_PIN_PD4, -// 	.pullup_pin	= AT91_PIN_PD5, -// }; - -static struct at91_mmc_data __initdata picotux200_mmc_data = { -	.det_pin	= AT91_PIN_PB27, -	.slot_b		= 0, -	.wire4		= 1, -	.wp_pin		= AT91_PIN_PA17, +static struct mci_platform_data __initdata picotux200_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PB27, +		.wp_pin		= AT91_PIN_PA17, +	},  }; -// static struct spi_board_info picotux200_spi_devices[] = { -// 	{	/* DataFlash chip */ -// 		.modalias	= "mtd_dataflash", -// 		.chip_select	= 0, -// 		.max_speed_hz	= 15 * 1000 * 1000, -// 	}, -// #ifdef CONFIG_MTD_AT91_DATAFLASH_CARD -// 	{	/* DataFlash card */ -// 		.modalias	= "mtd_dataflash", -// 		.chip_select	= 3, -// 		.max_speed_hz	= 15 * 1000 * 1000, -// 	}, -// #endif -// }; -  #define PICOTUX200_FLASH_BASE	AT91_CHIPSELECT_0  #define PICOTUX200_FLASH_SIZE	SZ_4M @@ -130,35 +97,33 @@ static struct platform_device picotux200_flash = {  static void __init picotux200_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS +			  | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD +			  | ATMEL_UART_RI);  	at91_add_device_serial();  	/* Ethernet */  	at91_add_device_eth(&picotux200_eth_data);  	/* USB Host */  	at91_add_device_usbh(&picotux200_usbh_data); -	/* USB Device */ -	// at91_add_device_udc(&picotux200_udc_data); -	// at91_set_multi_drive(picotux200_udc_data.pullup_pin, 1);	/* pullup_pin is connected to reset */  	/* I2C */  	at91_add_device_i2c(NULL, 0); -	/* SPI */ -	// at91_add_device_spi(picotux200_spi_devices, ARRAY_SIZE(picotux200_spi_devices)); -#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD -	/* DataFlash card */ -	at91_set_gpio_output(AT91_PIN_PB22, 0); -#else  	/* MMC */  	at91_set_gpio_output(AT91_PIN_PB22, 1);	/* this MMC card slot can optionally use SPI signaling (CS3). */ -	at91_add_device_mmc(0, &picotux200_mmc_data); -#endif +	at91_add_device_mci(0, &picotux200_mci0_data);  	/* NOR Flash */  	platform_device_register(&picotux200_flash);  }  MACHINE_START(PICOTUX2XX, "picotux 200")  	/* Maintainer: Kleinhenz Elektronik GmbH */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= picotux200_map_io, -	.init_irq	= picotux200_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= picotux200_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= picotux200_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-qil-a9260.c b/arch/arm/mach-at91/board-qil-a9260.c deleted file mode 100644 index 69d15a875b6..00000000000 --- a/arch/arm/mach-at91/board-qil-a9260.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * linux/arch/arm/mach-at91/board-qil-a9260.c - * - *  Copyright (C) 2005 SAN People - *  Copyright (C) 2006 Atmel - *  Copyright (C) 2007 Calao-systems - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#include <linux/types.h> -#include <linux/init.h> -#include <linux/mm.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/spi/spi.h> -#include <linux/gpio_keys.h> -#include <linux/input.h> -#include <linux/clk.h> - -#include <asm/setup.h> -#include <asm/mach-types.h> -#include <asm/irq.h> - -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/mach/irq.h> - -#include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h> -#include <mach/at91sam9_smc.h> -#include <mach/at91_shdwc.h> - -#include "sam9_smc.h" -#include "generic.h" - - -static void __init ek_map_io(void) -{ -	/* Initialize processor: 12.000 MHz crystal */ -	at91sam9260_initialize(12000000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD -			   | ATMEL_UART_RI); - -	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */ -	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */ -	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* set serial console to ttyS1 (ie, USART0) */ -	at91_set_serial_console(1); - -} - -static void __init ek_init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); -} - - -/* - * USB Host port - */ -static struct at91_usbh_data __initdata ek_usbh_data = { -	.ports		= 2, -}; - -/* - * USB Device port - */ -static struct at91_udc_data __initdata ek_udc_data = { -	.vbus_pin	= AT91_PIN_PC5, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ -}; - -/* - * SPI devices. - */ -static struct spi_board_info ek_spi_devices[] = { -#if defined(CONFIG_RTC_DRV_M41T94) -	{	/* M41T94 RTC */ -		.modalias	= "m41t94", -		.chip_select	= 0, -		.max_speed_hz	= 1 * 1000 * 1000, -		.bus_num	= 0, -	} -#endif -}; - -/* - * MACB Ethernet device - */ -static struct at91_eth_data __initdata ek_macb_data = { -	.phy_irq_pin	= AT91_PIN_PA31, -	.is_rmii	= 1, -}; - -/* - * NAND flash - */ -static struct mtd_partition __initdata ek_nand_partition[] = { -	{ -		.name	= "Uboot & Kernel", -		.offset	= 0, -		.size	= SZ_16M, -	}, -	{ -		.name	= "Root FS", -		.offset	= MTDPART_OFS_NXTBLK, -		.size	= 120 * SZ_1M, -	}, -	{ -		.name	= "FS", -		.offset	= MTDPART_OFS_NXTBLK, -		.size	= 120 * SZ_1M, -	}, -}; - -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(ek_nand_partition); -	return ek_nand_partition; -} - -static struct atmel_nand_data __initdata ek_nand_data = { -	.ale		= 21, -	.cle		= 22, -//	.det_pin	= ... not connected -	.rdy_pin	= AT91_PIN_PC13, -	.enable_pin	= AT91_PIN_PC14, -	.partition_info	= nand_partitions, -}; - -static struct sam9_smc_config __initdata ek_nand_smc_config = { -	.ncs_read_setup		= 0, -	.nrd_setup		= 1, -	.ncs_write_setup	= 0, -	.nwe_setup		= 1, - -	.ncs_read_pulse		= 3, -	.nrd_pulse		= 3, -	.ncs_write_pulse	= 3, -	.nwe_pulse		= 3, - -	.read_cycle		= 5, -	.write_cycle		= 5, - -	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8, -	.tdf_cycles		= 2, -}; - -static void __init ek_add_device_nand(void) -{ -	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &ek_nand_smc_config); - -	at91_add_device_nand(&ek_nand_data); -} - -/* - * MCI (SD/MMC) - */ -static struct at91_mmc_data __initdata ek_mmc_data = { -	.slot_b		= 0, -	.wire4		= 1, -//	.det_pin	= ... not connected -//	.wp_pin		= ... not connected -//	.vcc_pin	= ... not connected -}; - -/* - * GPIO Buttons - */ -#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) -static struct gpio_keys_button ek_buttons[] = { -	{	/* USER PUSH BUTTON */ -		.code		= KEY_ENTER, -		.gpio		= AT91_PIN_PB10, -		.active_low	= 1, -		.desc		= "user_pb", -		.wakeup		= 1, -	} -}; - -static struct gpio_keys_platform_data ek_button_data = { -	.buttons	= ek_buttons, -	.nbuttons	= ARRAY_SIZE(ek_buttons), -}; - -static struct platform_device ek_button_device = { -	.name		= "gpio-keys", -	.id		= -1, -	.num_resources	= 0, -	.dev		= { -		.platform_data	= &ek_button_data, -	} -}; - -static void __init ek_add_device_buttons(void) -{ -	at91_set_GPIO_periph(AT91_PIN_PB10, 1);	/* user push button, pull up enabled */ -	at91_set_deglitch(AT91_PIN_PB10, 1); - -	platform_device_register(&ek_button_device); -} -#else -static void __init ek_add_device_buttons(void) {} -#endif - -/* - * LEDs - */ -static struct gpio_led ek_leds[] = { -	{	/* user_led (green) */ -		.name			= "user_led", -		.gpio			= AT91_PIN_PB21, -		.active_low		= 0, -		.default_trigger	= "heartbeat", -	} -}; - -static void __init ek_board_init(void) -{ -	/* Serial */ -	at91_add_device_serial(); -	/* USB Host */ -	at91_add_device_usbh(&ek_usbh_data); -	/* USB Device */ -	at91_add_device_udc(&ek_udc_data); -	/* SPI */ -	at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); -	/* NAND */ -	ek_add_device_nand(); -	/* I2C */ -	at91_add_device_i2c(NULL, 0); -	/* Ethernet */ -	at91_add_device_eth(&ek_macb_data); -	/* MMC */ -	at91_add_device_mmc(0, &ek_mmc_data); -	/* Push Buttons */ -	ek_add_device_buttons(); -	/* LEDs */ -	at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); -	/* shutdown controller, wakeup button (5 msec low) */ -	at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW -				| AT91_SHDW_RTTWKEN); -} - -MACHINE_START(QIL_A9260, "CALAO QIL_A9260") -	/* Maintainer: calao-systems */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, -	.init_machine	= ek_board_init, -MACHINE_END diff --git a/arch/arm/mach-at91/board-ek.c b/arch/arm/mach-at91/board-rm9200ek.c index 56e92c4bbc2..953cea41675 100644 --- a/arch/arm/mach-at91/board-ek.c +++ b/arch/arm/mach-at91/board-rm9200ek.c @@ -1,5 +1,5 @@  /* - * linux/arch/arm/mach-at91/board-ek.c + * linux/arch/arm/mach-at91/board-rm9200ek.c   *   *  Copyright (C) 2005 SAN People   * @@ -22,6 +22,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -38,45 +39,30 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -static void __init ek_map_io(void) +static void __init ek_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91rm9200_initialize(18432000, AT91RM9200_BGA); - -	/* Setup the LEDs */ -	at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD -			   | ATMEL_UART_RI); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init ek_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); +	at91_initialize(18432000);  } -static struct at91_eth_data __initdata ek_eth_data = { +static struct macb_platform_data __initdata ek_eth_data = {  	.phy_irq_pin	= AT91_PIN_PC4,  	.is_rmii	= 1,  };  static struct at91_usbh_data __initdata ek_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata ek_udc_data = { @@ -84,12 +70,15 @@ static struct at91_udc_data __initdata ek_udc_data = {  	.pullup_pin	= AT91_PIN_PD5,  }; -static struct at91_mmc_data __initdata ek_mmc_data = { -	.det_pin	= AT91_PIN_PB27, -	.slot_b		= 0, -	.wire4		= 1, -	.wp_pin		= AT91_PIN_PA17, +#ifndef CONFIG_MTD_AT91_DATAFLASH_CARD +static struct mci_platform_data __initdata ek_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PB27, +		.wp_pin		= AT91_PIN_PA17, +	}  }; +#endif  static struct spi_board_info ek_spi_devices[] = {  	{	/* DataFlash chip */ @@ -116,7 +105,7 @@ static struct i2c_board_info __initdata ek_i2c_devices[] = {  };  #define EK_FLASH_BASE	AT91_CHIPSELECT_0 -#define EK_FLASH_SIZE	SZ_2M +#define EK_FLASH_SIZE	SZ_8M  static struct physmap_flash_data ek_flash_data = {  	.width		= 2, @@ -161,6 +150,13 @@ static struct gpio_led ek_leds[] = {  static void __init ek_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD +			   | ATMEL_UART_RI);  	at91_add_device_serial();  	/* Ethernet */  	at91_add_device_eth(&ek_eth_data); @@ -179,7 +175,7 @@ static void __init ek_board_init(void)  #else  	/* MMC */  	at91_set_gpio_output(AT91_PIN_PB22, 1);	/* this MMC card slot can optionally use SPI signaling (CS3). */ -	at91_add_device_mmc(0, &ek_mmc_data); +	at91_add_device_mci(0, &ek_mci0_data);  #endif  	/* NOR Flash */  	platform_device_register(&ek_flash); @@ -191,9 +187,10 @@ static void __init ek_board_init(void)  MACHINE_START(AT91RM9200EK, "Atmel AT91RM9200-EK")  	/* Maintainer: SAN People/Atmel */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ek_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= ek_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-rsi-ews.c b/arch/arm/mach-at91/board-rsi-ews.c new file mode 100644 index 00000000000..f28e8b74df4 --- /dev/null +++ b/arch/arm/mach-at91/board-rsi-ews.c @@ -0,0 +1,232 @@ +/* + * board-rsi-ews.c + * + *  Copyright (C) + *  2005 SAN People, + *  2008-2011 R-S-I Elektrotechnik GmbH & Co. KG + * + * Licensed under GPLv2 or later. + */ + +#include <linux/types.h> +#include <linux/init.h> +#include <linux/mm.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/spi/spi.h> +#include <linux/mtd/physmap.h> + +#include <asm/setup.h> +#include <asm/mach-types.h> +#include <asm/irq.h> + +#include <asm/mach/arch.h> +#include <asm/mach/map.h> +#include <asm/mach/irq.h> + +#include <mach/hardware.h> + +#include <linux/gpio.h> + +#include "at91_aic.h" +#include "board.h" +#include "generic.h" +#include "gpio.h" + +static void __init rsi_ews_init_early(void) +{ +	/* Initialize processor: 18.432 MHz crystal */ +	at91_initialize(18432000); +} + +/* + * Ethernet + */ +static struct macb_platform_data rsi_ews_eth_data __initdata = { +	.phy_irq_pin	= AT91_PIN_PC4, +	.is_rmii	= 1, +}; + +/* + * USB Host + */ +static struct at91_usbh_data rsi_ews_usbh_data __initdata = { +	.ports		= 1, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL}, +}; + +/* + * SD/MC + */ +static struct mci_platform_data __initdata rsi_ews_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PB27, +		.wp_pin		= AT91_PIN_PB29, +	}, +}; + +/* + * I2C + */ +static struct i2c_board_info rsi_ews_i2c_devices[] __initdata = { +	{ +		I2C_BOARD_INFO("ds1337", 0x68), +	}, +	{ +		I2C_BOARD_INFO("24c01", 0x50), +	} +}; + +/* + * LEDs + */ +static struct gpio_led rsi_ews_leds[] = { +	{ +		.name			= "led0", +		.gpio			= AT91_PIN_PB6, +		.active_low		= 0, +	}, +	{ +		.name			= "led1", +		.gpio			= AT91_PIN_PB7, +		.active_low		= 0, +	}, +	{ +		.name			= "led2", +		.gpio			= AT91_PIN_PB8, +		.active_low		= 0, +	}, +	{ +		.name			= "led3", +		.gpio			= AT91_PIN_PB9, +		.active_low		= 0, +	}, +}; + +/* + * DataFlash + */ +static struct spi_board_info rsi_ews_spi_devices[] = { +	{	/* DataFlash chip 1*/ +		.modalias	= "mtd_dataflash", +		.chip_select	= 0, +		.max_speed_hz	= 5 * 1000 * 1000, +	}, +	{	/* DataFlash chip 2*/ +		.modalias	= "mtd_dataflash", +		.chip_select	= 1, +		.max_speed_hz	= 5 * 1000 * 1000, +	}, +}; + +/* + * NOR flash + */ +static struct mtd_partition rsiews_nor_partitions[] = { +	{ +		.name		= "boot", +		.offset		= 0, +		.size		= 3 * SZ_128K, +		.mask_flags	= MTD_WRITEABLE +	}, +	{ +		.name		= "kernel", +		.offset		= MTDPART_OFS_NXTBLK, +		.size		= SZ_2M - (3 * SZ_128K) +	}, +	{ +		.name		= "root", +		.offset		= MTDPART_OFS_NXTBLK, +		.size		= SZ_8M +	}, +	{ +		.name		= "kernelupd", +		.offset		= MTDPART_OFS_NXTBLK, +		.size		= 3 * SZ_512K, +		.mask_flags	= MTD_WRITEABLE +	}, +	{ +		.name		= "rootupd", +		.offset		= MTDPART_OFS_NXTBLK, +		.size		= 9 * SZ_512K, +		.mask_flags	= MTD_WRITEABLE +	}, +}; + +static struct physmap_flash_data rsiews_nor_data = { +	.width		= 2, +	.parts		= rsiews_nor_partitions, +	.nr_parts	= ARRAY_SIZE(rsiews_nor_partitions), +}; + +#define NOR_BASE	AT91_CHIPSELECT_0 +#define NOR_SIZE	SZ_16M + +static struct resource nor_flash_resources[] = { +	{ +		.start	= NOR_BASE, +		.end	= NOR_BASE + NOR_SIZE - 1, +		.flags	= IORESOURCE_MEM, +	} +}; + +static struct platform_device rsiews_nor_flash = { +	.name		= "physmap-flash", +	.id		= 0, +	.dev		= { +				.platform_data	= &rsiews_nor_data, +	}, +	.resource	= nor_flash_resources, +	.num_resources	= ARRAY_SIZE(nor_flash_resources), +}; + +/* + * Init Func + */ +static void __init rsi_ews_board_init(void) +{ +	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	/* This one is for debugging */ +	at91_register_uart(0, 0, 0); + +	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	/* Dialin/-out modem interface */ +	at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD +			   | ATMEL_UART_RI); + +	/* USART3 on ttyS4. (Rx, Tx, RTS) */ +	/* RS485 communication */ +	at91_register_uart(AT91RM9200_ID_US3, 4, ATMEL_UART_RTS); +	at91_add_device_serial(); +	at91_set_gpio_output(AT91_PIN_PA21, 0); +	/* Ethernet */ +	at91_add_device_eth(&rsi_ews_eth_data); +	/* USB Host */ +	at91_add_device_usbh(&rsi_ews_usbh_data); +	/* I2C */ +	at91_add_device_i2c(rsi_ews_i2c_devices, +			ARRAY_SIZE(rsi_ews_i2c_devices)); +	/* SPI */ +	at91_add_device_spi(rsi_ews_spi_devices, +			ARRAY_SIZE(rsi_ews_spi_devices)); +	/* MMC */ +	at91_add_device_mci(0, &rsi_ews_mci0_data); +	/* NOR Flash */ +	platform_device_register(&rsiews_nor_flash); +	/* LEDs */ +	at91_gpio_leds(rsi_ews_leds, ARRAY_SIZE(rsi_ews_leds)); +} + +MACHINE_START(RSI_EWS, "RSI EWS") +	/* Maintainer: Josef Holzmayr <holzmayr@rsi-elektrotechnik.de> */ +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= rsi_ews_init_early, +	.init_irq	= at91_init_irq_default, +	.init_machine	= rsi_ews_board_init, +MACHINE_END diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c index 25a26beaa72..d24dda67e2d 100644 --- a/arch/arm/mach-at91/board-sam9-l9260.c +++ b/arch/arm/mach-at91/board-sam9-l9260.c @@ -21,6 +21,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -36,48 +37,28 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9_smc.h> +#include "at91_aic.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h" -static void __init ek_map_io(void) +static void __init ek_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91sam9260_initialize(18432000); - -	/* Setup the LEDs */ -	at91_init_leds(AT91_PIN_PA9, AT91_PIN_PA6); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD -			   | ATMEL_UART_RI); - -	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */ -	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); +	at91_initialize(18432000);  } -static void __init ek_init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); -} - -  /*   * USB Host port   */  static struct at91_usbh_data __initdata ek_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  /* @@ -85,7 +66,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {   */  static struct at91_udc_data __initdata ek_udc_data = {  	.vbus_pin	= AT91_PIN_PC5, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */  }; @@ -93,7 +74,7 @@ static struct at91_udc_data __initdata ek_udc_data = {   * SPI devices.   */  static struct spi_board_info ek_spi_devices[] = { -#if !defined(CONFIG_MMC_AT91) +#if !IS_ENABLED(CONFIG_MMC_ATMELMCI)  	{	/* DataFlash chip */  		.modalias	= "mtd_dataflash",  		.chip_select	= 1, @@ -115,7 +96,7 @@ static struct spi_board_info ek_spi_devices[] = {  /*   * MACB Ethernet device   */ -static struct at91_eth_data __initdata ek_macb_data = { +static struct macb_platform_data __initdata ek_macb_data = {  	.phy_irq_pin	= AT91_PIN_PA7,  	.is_rmii	= 0,  }; @@ -137,19 +118,15 @@ static struct mtd_partition __initdata ek_nand_partition[] = {  	},  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(ek_nand_partition); -	return ek_nand_partition; -} -  static struct atmel_nand_data __initdata ek_nand_data = {  	.ale		= 21,  	.cle		= 22, -//	.det_pin	= ... not connected +	.det_pin	= -EINVAL,  	.rdy_pin	= AT91_PIN_PC13,  	.enable_pin	= AT91_PIN_PC14, -	.partition_info	= nand_partitions, +	.ecc_mode	= NAND_ECC_SOFT, +	.parts		= ek_nand_partition, +	.num_parts	= ARRAY_SIZE(ek_nand_partition),  };  static struct sam9_smc_config __initdata ek_nand_smc_config = { @@ -173,7 +150,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {  static void __init ek_add_device_nand(void)  {  	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &ek_nand_smc_config); +	sam9_smc_configure(0, 3, &ek_nand_smc_config);  	at91_add_device_nand(&ek_nand_data);  } @@ -182,17 +159,45 @@ static void __init ek_add_device_nand(void)  /*   * MCI (SD/MMC)   */ -static struct at91_mmc_data __initdata ek_mmc_data = { -	.slot_b		= 1, -	.wire4		= 1, -	.det_pin	= AT91_PIN_PC8, -	.wp_pin		= AT91_PIN_PC4, -//	.vcc_pin	= ... not connected +static struct mci_platform_data __initdata ek_mci0_data = { +	.slot[1] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PC8, +		.wp_pin		= AT91_PIN_PC4, +	}, +}; + +/* + * LEDs + */ +static struct gpio_led ek_leds[] = { +	{	/* D1 */ +		.name			= "led1", +		.gpio			= AT91_PIN_PA9, +		.active_low		= 1, +		.default_trigger	= "heartbeat", +	}, +	{	/* D2 */ +		.name			= "led2", +		.gpio			= AT91_PIN_PA6, +		.active_low		= 1, +		.default_trigger	= "timer", +	}  };  static void __init ek_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD +			   | ATMEL_UART_RI); + +	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */ +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);  	at91_add_device_serial();  	/* USB Host */  	at91_add_device_usbh(&ek_usbh_data); @@ -205,16 +210,19 @@ static void __init ek_board_init(void)  	/* Ethernet */  	at91_add_device_eth(&ek_macb_data);  	/* MMC */ -	at91_add_device_mmc(0, &ek_mmc_data); +	at91_add_device_mci(0, &ek_mci0_data);  	/* I2C */  	at91_add_device_i2c(NULL, 0); +	/* LEDs */ +	at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));  }  MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")  	/* Maintainer: Olimex */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ek_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= ek_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c index de1816e0e1d..65dea12d685 100644 --- a/arch/arm/mach-at91/board-sam9260ek.c +++ b/arch/arm/mach-at91/board-sam9260ek.c @@ -20,6 +20,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -27,7 +28,7 @@  #include <linux/spi/spi.h>  #include <linux/spi/at73c213.h>  #include <linux/clk.h> -#include <linux/i2c/at24.h> +#include <linux/platform_data/at24.h>  #include <linux/gpio_keys.h>  #include <linux/input.h> @@ -40,46 +41,30 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9_smc.h> -#include <mach/at91_shdwc.h> +#include <mach/system_rev.h> +#include "at91_aic.h" +#include "at91_shdwc.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h" -static void __init ek_map_io(void) +static void __init ek_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91sam9260_initialize(18432000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD -			   | ATMEL_UART_RI); - -	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ -	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); +	at91_initialize(18432000);  } -static void __init ek_init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); -} - -  /*   * USB Host port   */  static struct at91_usbh_data __initdata ek_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  /* @@ -87,7 +72,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {   */  static struct at91_udc_data __initdata ek_udc_data = {  	.vbus_pin	= AT91_PIN_PC5, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */  }; @@ -124,7 +109,7 @@ static void __init at73c213_set_clk(struct at73c213_board_info *info) {}   * SPI devices.   */  static struct spi_board_info ek_spi_devices[] = { -#if !defined(CONFIG_MMC_AT91) +#if !IS_ENABLED(CONFIG_MMC_ATMELMCI)  	{	/* DataFlash chip */  		.modalias	= "mtd_dataflash",  		.chip_select	= 1, @@ -156,7 +141,7 @@ static struct spi_board_info ek_spi_devices[] = {  /*   * MACB Ethernet device   */ -static struct at91_eth_data __initdata ek_macb_data = { +static struct macb_platform_data __initdata ek_macb_data = {  	.phy_irq_pin	= AT91_PIN_PA7,  	.is_rmii	= 1,  }; @@ -178,24 +163,16 @@ static struct mtd_partition __initdata ek_nand_partition[] = {  	},  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(ek_nand_partition); -	return ek_nand_partition; -} -  static struct atmel_nand_data __initdata ek_nand_data = {  	.ale		= 21,  	.cle		= 22, -//	.det_pin	= ... not connected +	.det_pin	= -EINVAL,  	.rdy_pin	= AT91_PIN_PC13,  	.enable_pin	= AT91_PIN_PC14, -	.partition_info	= nand_partitions, -#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16) -	.bus_width_16	= 1, -#else -	.bus_width_16	= 0, -#endif +	.ecc_mode	= NAND_ECC_SOFT, +	.on_flash_bbt	= 1, +	.parts		= ek_nand_partition, +	.num_parts	= ARRAY_SIZE(ek_nand_partition),  };  static struct sam9_smc_config __initdata ek_nand_smc_config = { @@ -218,6 +195,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {  static void __init ek_add_device_nand(void)  { +	ek_nand_data.bus_width_16 = board_have_nand_16bit();  	/* setup bus-width (8 or 16) */  	if (ek_nand_data.bus_width_16)  		ek_nand_smc_config.mode |= AT91_SMC_DBW_16; @@ -225,7 +203,7 @@ static void __init ek_add_device_nand(void)  		ek_nand_smc_config.mode |= AT91_SMC_DBW_8;  	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &ek_nand_smc_config); +	sam9_smc_configure(0, 3, &ek_nand_smc_config);  	at91_add_device_nand(&ek_nand_data);  } @@ -234,12 +212,12 @@ static void __init ek_add_device_nand(void)  /*   * MCI (SD/MMC)   */ -static struct at91_mmc_data __initdata ek_mmc_data = { -	.slot_b		= 1, -	.wire4		= 1, -//	.det_pin	= ... not connected -//	.wp_pin		= ... not connected -//	.vcc_pin	= ... not connected +static struct mci_platform_data __initdata ek_mci0_data = { +	.slot[1] = { +		.bus_width	= 4, +		.detect_pin	= -EINVAL, +		.wp_pin		= -EINVAL, +	},  }; @@ -330,6 +308,16 @@ static void __init ek_add_device_buttons(void) {}  static void __init ek_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD +			   | ATMEL_UART_RI); + +	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);  	at91_add_device_serial();  	/* USB Host */  	at91_add_device_usbh(&ek_usbh_data); @@ -342,7 +330,7 @@ static void __init ek_board_init(void)  	/* Ethernet */  	at91_add_device_eth(&ek_macb_data);  	/* MMC */ -	at91_add_device_mmc(0, &ek_mmc_data); +	at91_add_device_mci(0, &ek_mci0_data);  	/* I2C */  	at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));  	/* SSC (to AT73C213) */ @@ -356,9 +344,10 @@ static void __init ek_board_init(void)  MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")  	/* Maintainer: Atmel */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ek_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= ek_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c index 14acc901e24..4637432de08 100644 --- a/arch/arm/mach-at91/board-sam9261ek.c +++ b/arch/arm/mach-at91/board-sam9261ek.c @@ -20,6 +20,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -44,36 +45,23 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9_smc.h> -#include <mach/at91_shdwc.h> +#include <mach/system_rev.h> +#include "at91_aic.h" +#include "at91_shdwc.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h" -static void __init ek_map_io(void) +static void __init ek_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91sam9261_initialize(18432000); - -	/* Setup the LEDs */ -	at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init ek_init_irq(void) -{ -	at91sam9261_init_interrupts(NULL); +	at91_initialize(18432000);  } -  /*   * DM9000 ethernet device   */ @@ -90,8 +78,6 @@ static struct resource dm9000_resource[] = {  		.flags	= IORESOURCE_MEM  	},  	[2] = { -		.start	= AT91_PIN_PC11, -		.end	= AT91_PIN_PC11,  		.flags	= IORESOURCE_IRQ  			| IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE,  	} @@ -135,8 +121,10 @@ static struct sam9_smc_config __initdata dm9000_smc_config = {  static void __init ek_add_device_dm9000(void)  { +	struct resource *r = &dm9000_resource[2]; +  	/* Configure chip-select 2 (DM9000) */ -	sam9_smc_configure(2, &dm9000_smc_config); +	sam9_smc_configure(0, 2, &dm9000_smc_config);  	/* Configure Reset signal as output */  	at91_set_gpio_output(AT91_PIN_PC10, 0); @@ -144,6 +132,7 @@ static void __init ek_add_device_dm9000(void)  	/* Configure Interrupt pin as input, no pull-up */  	at91_set_gpio_input(AT91_PIN_PC11, 0); +	r->start = r->end = gpio_to_irq(AT91_PIN_PC11);  	platform_device_register(&dm9000_device);  }  #else @@ -156,6 +145,8 @@ static void __init ek_add_device_dm9000(void) {}   */  static struct at91_usbh_data __initdata ek_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  }; @@ -164,7 +155,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {   */  static struct at91_udc_data __initdata ek_udc_data = {  	.vbus_pin	= AT91_PIN_PB29, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */  }; @@ -184,24 +175,16 @@ static struct mtd_partition __initdata ek_nand_partition[] = {  	},  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(ek_nand_partition); -	return ek_nand_partition; -} -  static struct atmel_nand_data __initdata ek_nand_data = {  	.ale		= 22,  	.cle		= 21, -//	.det_pin	= ... not connected +	.det_pin	= -EINVAL,  	.rdy_pin	= AT91_PIN_PC15,  	.enable_pin	= AT91_PIN_PC14, -	.partition_info	= nand_partitions, -#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16) -	.bus_width_16	= 1, -#else -	.bus_width_16	= 0, -#endif +	.ecc_mode	= NAND_ECC_SOFT, +	.on_flash_bbt	= 1, +	.parts		= ek_nand_partition, +	.num_parts	= ARRAY_SIZE(ek_nand_partition),  };  static struct sam9_smc_config __initdata ek_nand_smc_config = { @@ -224,6 +207,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {  static void __init ek_add_device_nand(void)  { +	ek_nand_data.bus_width_16 = board_have_nand_16bit();  	/* setup bus-width (8 or 16) */  	if (ek_nand_data.bus_width_16)  		ek_nand_smc_config.mode |= AT91_SMC_DBW_16; @@ -231,7 +215,7 @@ static void __init ek_add_device_nand(void)  		ek_nand_smc_config.mode |= AT91_SMC_DBW_8;  	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &ek_nand_smc_config); +	sam9_smc_configure(0, 3, &ek_nand_smc_config);  	at91_add_device_nand(&ek_nand_data);  } @@ -281,11 +265,7 @@ static void __init ek_add_device_ts(void) {}   */  static struct at73c213_board_info at73c213_data = {  	.ssc_id		= 1, -#if defined(CONFIG_MACH_AT91SAM9261EK) -	.shortname	= "AT91SAM9261-EK external DAC", -#else -	.shortname	= "AT91SAM9G10-EK external DAC", -#endif +	.shortname	= "AT91SAM9261/9G10-EK external DAC",  };  #if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE) @@ -326,7 +306,7 @@ static struct spi_board_info ek_spi_devices[] = {  		.max_speed_hz	= 125000 * 26,	/* (max sample rate @ 3V) * (cmd + data + overhead) */  		.bus_num	= 0,  		.platform_data	= &ads_info, -		.irq		= AT91SAM9261_ID_IRQ0, +		.irq		= NR_IRQS_LEGACY + AT91SAM9261_ID_IRQ0,  		.controller_data = (void *) AT91_PIN_PA28,	/* CS pin */  	},  #endif @@ -357,8 +337,12 @@ static struct spi_board_info ek_spi_devices[] = {   * MCI (SD/MMC)   * det_pin, wp_pin and vcc_pin are not connected   */ -static struct at91_mmc_data __initdata ek_mmc_data = { -	.wire4		= 1, +static struct mci_platform_data __initdata mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= -EINVAL, +		.wp_pin		= -EINVAL, +	},  };  #endif /* CONFIG_SPI_ATMEL_* */ @@ -406,7 +390,7 @@ static struct fb_monspecs at91fb_default_stn_monspecs = {  					| ATMEL_LCDC_IFWIDTH_4 \  					| ATMEL_LCDC_SCANMOD_SINGLE) -static void at91_lcdc_stn_power_control(int on) +static void at91_lcdc_stn_power_control(struct atmel_lcdfb_pdata *pdata, int on)  {  	/* backlight */  	if (on) {	/* power up */ @@ -418,16 +402,13 @@ static void at91_lcdc_stn_power_control(int on)  	}  } -static struct atmel_lcdfb_info __initdata ek_lcdc_data = { +static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {  	.default_bpp			= 1,  	.default_dmacon			= ATMEL_LCDC_DMAEN,  	.default_lcdcon2		= AT91SAM9261_DEFAULT_STN_LCDCON2,  	.default_monspecs		= &at91fb_default_stn_monspecs,  	.atmel_lcdfb_power_control	= at91_lcdc_stn_power_control,  	.guard_time			= 1, -#if defined(CONFIG_MACH_AT91SAM9G10EK) -	.lcd_wiring_mode		= ATMEL_LCDC_WIRING_RGB, -#endif  };  #else @@ -465,7 +446,7 @@ static struct fb_monspecs at91fb_default_tft_monspecs = {  					| ATMEL_LCDC_DISTYPE_TFT    \  					| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE) -static void at91_lcdc_tft_power_control(int on) +static void at91_lcdc_tft_power_control(struct atmel_lcdfb_pdata *pdata, int on)  {  	if (on)  		at91_set_gpio_value(AT91_PIN_PA12, 0);	/* power up */ @@ -473,7 +454,7 @@ static void at91_lcdc_tft_power_control(int on)  		at91_set_gpio_value(AT91_PIN_PA12, 1);	/* power down */  } -static struct atmel_lcdfb_info __initdata ek_lcdc_data = { +static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {  	.lcdcon_is_backlight		= true,  	.default_bpp			= 16,  	.default_dmacon			= ATMEL_LCDC_DMAEN, @@ -481,14 +462,11 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data = {  	.default_monspecs		= &at91fb_default_tft_monspecs,  	.atmel_lcdfb_power_control	= at91_lcdc_tft_power_control,  	.guard_time			= 1, -#if defined(CONFIG_MACH_AT91SAM9G10EK) -	.lcd_wiring_mode		= ATMEL_LCDC_WIRING_RGB, -#endif  };  #endif  #else -static struct atmel_lcdfb_info __initdata ek_lcdc_data; +static struct atmel_lcdfb_pdata __initdata ek_lcdc_data;  #endif @@ -584,7 +562,13 @@ static struct gpio_led ek_leds[] = {  static void __init ek_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0);  	at91_add_device_serial(); + +	if (cpu_is_at91sam9g10()) +		ek_lcdc_data.lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB; +  	/* USB Host */  	at91_add_device_usbh(&ek_usbh_data);  	/* USB Device */ @@ -607,7 +591,7 @@ static void __init ek_board_init(void)  	at91_add_device_ssc(AT91SAM9261_ID_SSC1, ATMEL_SSC_TX);  #else  	/* MMC */ -	at91_add_device_mmc(0, &ek_mmc_data); +	at91_add_device_mci(0, &mci0_data);  #endif  	/* LCD Controller */  	at91_add_device_lcdc(&ek_lcdc_data); @@ -617,15 +601,22 @@ static void __init ek_board_init(void)  	at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));  } -#if defined(CONFIG_MACH_AT91SAM9261EK)  MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK") -#else +	/* Maintainer: Atmel */ +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ek_init_early, +	.init_irq	= at91_init_irq_default, +	.init_machine	= ek_board_init, +MACHINE_END +  MACHINE_START(AT91SAM9G10EK, "Atmel AT91SAM9G10-EK") -#endif  	/* Maintainer: Atmel */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ek_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= ek_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c index bfe490df58b..cd2726ee5ad 100644 --- a/arch/arm/mach-at91/board-sam9263ek.c +++ b/arch/arm/mach-at91/board-sam9263ek.c @@ -20,13 +20,14 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h>  #include <linux/platform_device.h>  #include <linux/spi/spi.h>  #include <linux/spi/ads7846.h> -#include <linux/i2c/at24.h> +#include <linux/platform_data/at24.h>  #include <linux/fb.h>  #include <linux/gpio_keys.h>  #include <linux/input.h> @@ -43,42 +44,31 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9_smc.h> -#include <mach/at91_shdwc.h> +#include <mach/system_rev.h> +#include "at91_aic.h" +#include "at91_shdwc.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h" -static void __init ek_map_io(void) +static void __init ek_init_early(void)  {  	/* Initialize processor: 16.367 MHz crystal */ -	at91sam9263_initialize(16367660); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */ -	at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); +	at91_initialize(16367660);  } -static void __init ek_init_irq(void) -{ -	at91sam9263_init_interrupts(NULL); -} - -  /*   * USB Host port   */  static struct at91_usbh_data __initdata ek_usbh_data = {  	.ports		= 2,  	.vbus_pin	= { AT91_PIN_PA24, AT91_PIN_PA21 }, +	.vbus_pin_active_low = {1, 1}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  /* @@ -86,7 +76,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {   */  static struct at91_udc_data __initdata ek_udc_data = {  	.vbus_pin	= AT91_PIN_PA25, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */  }; @@ -143,7 +133,7 @@ static struct spi_board_info ek_spi_devices[] = {  		.max_speed_hz	= 125000 * 26,	/* (max sample rate @ 3V) * (cmd + data + overhead) */  		.bus_num	= 0,  		.platform_data	= &ads_info, -		.irq		= AT91SAM9263_ID_IRQ1, +		.irq		= NR_IRQS_LEGACY + AT91SAM9263_ID_IRQ1,  	},  #endif  }; @@ -152,18 +142,19 @@ static struct spi_board_info ek_spi_devices[] = {  /*   * MCI (SD/MMC)   */ -static struct at91_mmc_data __initdata ek_mmc_data = { -	.wire4		= 1, -	.det_pin	= AT91_PIN_PE18, -	.wp_pin		= AT91_PIN_PE19, -//	.vcc_pin	= ... not connected +static struct mci_platform_data __initdata mci1_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PE18, +		.wp_pin		= AT91_PIN_PE19, +	},  };  /*   * MACB Ethernet device   */ -static struct at91_eth_data __initdata ek_macb_data = { +static struct macb_platform_data __initdata ek_macb_data = {  	.phy_irq_pin	= AT91_PIN_PE31,  	.is_rmii	= 1,  }; @@ -185,24 +176,16 @@ static struct mtd_partition __initdata ek_nand_partition[] = {  	},  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(ek_nand_partition); -	return ek_nand_partition; -} -  static struct atmel_nand_data __initdata ek_nand_data = {  	.ale		= 21,  	.cle		= 22, -//	.det_pin	= ... not connected +	.det_pin	= -EINVAL,  	.rdy_pin	= AT91_PIN_PA22,  	.enable_pin	= AT91_PIN_PD15, -	.partition_info	= nand_partitions, -#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16) -	.bus_width_16	= 1, -#else -	.bus_width_16	= 0, -#endif +	.ecc_mode	= NAND_ECC_SOFT, +	.on_flash_bbt	= 1, +	.parts		= ek_nand_partition, +	.num_parts	= ARRAY_SIZE(ek_nand_partition),  };  static struct sam9_smc_config __initdata ek_nand_smc_config = { @@ -225,6 +208,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {  static void __init ek_add_device_nand(void)  { +	ek_nand_data.bus_width_16 = board_have_nand_16bit();  	/* setup bus-width (8 or 16) */  	if (ek_nand_data.bus_width_16)  		ek_nand_smc_config.mode |= AT91_SMC_DBW_16; @@ -232,7 +216,7 @@ static void __init ek_add_device_nand(void)  		ek_nand_smc_config.mode |= AT91_SMC_DBW_8;  	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &ek_nand_smc_config); +	sam9_smc_configure(0, 3, &ek_nand_smc_config);  	at91_add_device_nand(&ek_nand_data);  } @@ -292,13 +276,13 @@ static struct fb_monspecs at91fb_default_monspecs = {  					| ATMEL_LCDC_DISTYPE_TFT \  					| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE) -static void at91_lcdc_power_control(int on) +static void at91_lcdc_power_control(struct atmel_lcdfb_pdata *pdata, int on)  {  	at91_set_gpio_value(AT91_PIN_PA30, on);  }  /* Driver datas */ -static struct atmel_lcdfb_info __initdata ek_lcdc_data = { +static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {  	.lcdcon_is_backlight		= true,  	.default_bpp			= 16,  	.default_dmacon			= ATMEL_LCDC_DMAEN, @@ -309,7 +293,7 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data = {  };  #else -static struct atmel_lcdfb_info __initdata ek_lcdc_data; +static struct atmel_lcdfb_pdata __initdata ek_lcdc_data;  #endif @@ -367,6 +351,7 @@ static void __init ek_add_device_buttons(void) {}   * reset_pin is not connected: NRST   */  static struct ac97c_platform_data ek_ac97_data = { +	.reset_pin	= -EINVAL,  }; @@ -421,6 +406,11 @@ static struct at91_can_data ek_can_data = {  static void __init ek_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */ +	at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);  	at91_add_device_serial();  	/* USB Host */  	at91_add_device_usbh(&ek_usbh_data); @@ -432,7 +422,7 @@ static void __init ek_board_init(void)  	/* Touchscreen */  	ek_add_device_ts();  	/* MMC */ -	at91_add_device_mmc(1, &ek_mmc_data); +	at91_add_device_mci(1, &mci1_data);  	/* Ethernet */  	at91_add_device_eth(&ek_macb_data);  	/* NAND */ @@ -454,9 +444,10 @@ static void __init ek_board_init(void)  MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")  	/* Maintainer: Atmel */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ek_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= ek_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c index ca8198b3c16..e1be6e25b38 100644 --- a/arch/arm/mach-at91/board-sam9g20ek.c +++ b/arch/arm/mach-at91/board-sam9g20ek.c @@ -18,6 +18,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -31,6 +32,8 @@  #include <linux/regulator/fixed.h>  #include <linux/regulator/consumer.h> +#include <linux/platform_data/at91_adc.h> +  #include <mach/hardware.h>  #include <asm/setup.h>  #include <asm/mach-types.h> @@ -40,12 +43,14 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9_smc.h> +#include <mach/system_rev.h> +#include "at91_aic.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h"  /*   * board revision encoding @@ -60,37 +65,19 @@ static int inline ek_have_2mmc(void)  } -static void __init ek_map_io(void) +static void __init ek_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91sam9260_initialize(18432000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD -			   | ATMEL_UART_RI); - -	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ -	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init ek_init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); +	at91_initialize(18432000);  } -  /*   * USB Host port   */  static struct at91_usbh_data __initdata ek_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  /* @@ -98,7 +85,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {   */  static struct at91_udc_data __initdata ek_udc_data = {  	.vbus_pin	= AT91_PIN_PC5, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */  }; @@ -106,7 +93,7 @@ static struct at91_udc_data __initdata ek_udc_data = {   * SPI devices.   */  static struct spi_board_info ek_spi_devices[] = { -#if !(defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_AT91)) +#if !IS_ENABLED(CONFIG_MMC_ATMELMCI)  	{	/* DataFlash chip */  		.modalias	= "mtd_dataflash",  		.chip_select	= 1, @@ -128,7 +115,7 @@ static struct spi_board_info ek_spi_devices[] = {  /*   * MACB Ethernet device   */ -static struct at91_eth_data __initdata ek_macb_data = { +static struct macb_platform_data __initdata ek_macb_data = {  	.phy_irq_pin	= AT91_PIN_PA7,  	.is_rmii	= 1,  }; @@ -162,24 +149,17 @@ static struct mtd_partition __initdata ek_nand_partition[] = {  	},  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(ek_nand_partition); -	return ek_nand_partition; -} -  /* det_pin is not connected */  static struct atmel_nand_data __initdata ek_nand_data = {  	.ale		= 21,  	.cle		= 22,  	.rdy_pin	= AT91_PIN_PC13,  	.enable_pin	= AT91_PIN_PC14, -	.partition_info	= nand_partitions, -#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16) -	.bus_width_16	= 1, -#else -	.bus_width_16	= 0, -#endif +	.det_pin	= -EINVAL, +	.ecc_mode	= NAND_ECC_SOFT, +	.on_flash_bbt	= 1, +	.parts		= ek_nand_partition, +	.num_parts	= ARRAY_SIZE(ek_nand_partition),  };  static struct sam9_smc_config __initdata ek_nand_smc_config = { @@ -202,6 +182,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {  static void __init ek_add_device_nand(void)  { +	ek_nand_data.bus_width_16 = board_have_nand_16bit();  	/* setup bus-width (8 or 16) */  	if (ek_nand_data.bus_width_16)  		ek_nand_smc_config.mode |= AT91_SMC_DBW_16; @@ -209,7 +190,7 @@ static void __init ek_add_device_nand(void)  		ek_nand_smc_config.mode |= AT91_SMC_DBW_8;  	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &ek_nand_smc_config); +	sam9_smc_configure(0, 3, &ek_nand_smc_config);  	at91_add_device_nand(&ek_nand_data);  } @@ -219,33 +200,23 @@ static void __init ek_add_device_nand(void)   * MCI (SD/MMC)   * wp_pin and vcc_pin are not connected   */ -#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)  static struct mci_platform_data __initdata ek_mmc_data = {  	.slot[1] = {  		.bus_width	= 4,  		.detect_pin	= AT91_PIN_PC9, +		.wp_pin		= -EINVAL,  	},  }; -#else -static struct at91_mmc_data __initdata ek_mmc_data = { -	.slot_b		= 1,	/* Only one slot so use slot B */ -	.wire4		= 1, -	.det_pin	= AT91_PIN_PC9, -}; -#endif  static void __init ek_add_device_mmc(void)  { -#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)  	if (ek_have_2mmc()) {  		ek_mmc_data.slot[0].bus_width = 4;  		ek_mmc_data.slot[0].detect_pin = AT91_PIN_PC2; +		ek_mmc_data.slot[0].wp_pin = -1;  	}  	at91_add_device_mci(0, &ek_mmc_data); -#else -	at91_add_device_mmc(0, &ek_mmc_data); -#endif  }  /* @@ -323,6 +294,16 @@ static void __init ek_add_device_buttons(void)  static void __init ek_add_device_buttons(void) {}  #endif +/* + * ADCs + */ + +static struct at91_adc_data ek_adc_data = { +	.channels_used = BIT(0) | BIT(1) | BIT(2) | BIT(3), +	.use_external_triggers = true, +	.vref = 3300, +}; +  #if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)  static struct regulator_consumer_supply ek_audio_consumer_supplies[] = {  	REGULATOR_SUPPLY("AVDD", "0-001b"), @@ -373,10 +354,30 @@ static struct i2c_board_info __initdata ek_i2c_devices[] = {          },  }; +static struct platform_device sam9g20ek_audio_device = { +	.name   = "at91sam9g20ek-audio", +	.id     = -1, +}; + +static void __init ek_add_device_audio(void) +{ +	platform_device_register(&sam9g20ek_audio_device); +} +  static void __init ek_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD +			   | ATMEL_UART_RI); + +	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);  	at91_add_device_serial();  	/* USB Host */  	at91_add_device_usbh(&ek_usbh_data); @@ -398,26 +399,31 @@ static void __init ek_board_init(void)  	ek_add_device_gpio_leds();  	/* Push Buttons */  	ek_add_device_buttons(); +	/* ADCs */ +	at91_add_device_adc(&ek_adc_data);  	/* PCK0 provides MCLK to the WM8731 */  	at91_set_B_periph(AT91_PIN_PC1, 0);  	/* SSC (for WM8731) */  	at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX); +	ek_add_device_audio();  }  MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK")  	/* Maintainer: Atmel */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ek_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= ek_board_init,  MACHINE_END  MACHINE_START(AT91SAM9G20EK_2MMC, "Atmel AT91SAM9G20-EK 2 MMC Slot Mod")  	/* Maintainer: Atmel */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ek_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= ek_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c index 86ff4b52db3..1ea61328f30 100644 --- a/arch/arm/mach-at91/board-sam9m10g45ek.c +++ b/arch/arm/mach-at91/board-sam9m10g45ek.c @@ -14,6 +14,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -23,11 +24,15 @@  #include <linux/gpio_keys.h>  #include <linux/input.h>  #include <linux/leds.h> -#include <linux/clk.h>  #include <linux/atmel-mci.h> +#include <linux/delay.h> + +#include <linux/platform_data/at91_adc.h>  #include <mach/hardware.h>  #include <video/atmel_lcdc.h> +#include <media/soc_camera.h> +#include <media/atmel-isi.h>  #include <asm/setup.h>  #include <asm/mach-types.h> @@ -37,44 +42,31 @@  #include <asm/mach/map.h>  #include <asm/mach/irq.h> -#include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9_smc.h> -#include <mach/at91_shdwc.h> +#include <mach/system_rev.h> +#include "at91_aic.h" +#include "at91_shdwc.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h" -static void __init ek_map_io(void) +static void __init ek_init_early(void)  {  	/* Initialize processor: 12.000 MHz crystal */ -	at91sam9g45_initialize(12000000); - -	/* DGBU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 not connected on the -EK board */ -	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ -	at91_register_uart(AT91SAM9G45_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); +	at91_initialize(12000000);  } -static void __init ek_init_irq(void) -{ -	at91sam9g45_init_interrupts(NULL); -} - -  /*   * USB HS Host port (common to OHCI & EHCI)   */  static struct at91_usbh_data __initdata ek_usbh_hs_data = {  	.ports		= 2,  	.vbus_pin	= {AT91_PIN_PD1, AT91_PIN_PD3}, +	.vbus_pin_active_low = {1, 1}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  }; @@ -106,6 +98,7 @@ static struct mci_platform_data __initdata mci0_data = {  	.slot[0] = {  		.bus_width	= 4,  		.detect_pin	= AT91_PIN_PD10, +		.wp_pin		= -EINVAL,  	},  }; @@ -121,7 +114,7 @@ static struct mci_platform_data __initdata mci1_data = {  /*   * MACB Ethernet device   */ -static struct at91_eth_data __initdata ek_macb_data = { +static struct macb_platform_data __initdata ek_macb_data = {  	.phy_irq_pin	= AT91_PIN_PD5,  	.is_rmii	= 1,  }; @@ -143,24 +136,17 @@ static struct mtd_partition __initdata ek_nand_partition[] = {  	},  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(ek_nand_partition); -	return ek_nand_partition; -} -  /* det_pin is not connected */  static struct atmel_nand_data __initdata ek_nand_data = {  	.ale		= 21,  	.cle		= 22,  	.rdy_pin	= AT91_PIN_PC8,  	.enable_pin	= AT91_PIN_PC14, -	.partition_info	= nand_partitions, -#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16) -	.bus_width_16	= 1, -#else -	.bus_width_16	= 0, -#endif +	.det_pin	= -EINVAL, +	.ecc_mode	= NAND_ECC_SOFT, +	.on_flash_bbt	= 1, +	.parts		= ek_nand_partition, +	.num_parts	= ARRAY_SIZE(ek_nand_partition),  };  static struct sam9_smc_config __initdata ek_nand_smc_config = { @@ -183,6 +169,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {  static void __init ek_add_device_nand(void)  { +	ek_nand_data.bus_width_16 = board_have_nand_16bit();  	/* setup bus-width (8 or 16) */  	if (ek_nand_data.bus_width_16)  		ek_nand_smc_config.mode |= AT91_SMC_DBW_16; @@ -190,13 +177,78 @@ static void __init ek_add_device_nand(void)  		ek_nand_smc_config.mode |= AT91_SMC_DBW_8;  	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &ek_nand_smc_config); +	sam9_smc_configure(0, 3, &ek_nand_smc_config);  	at91_add_device_nand(&ek_nand_data);  }  /* + *  ISI + */ +static struct isi_platform_data __initdata isi_data = { +	.frate			= ISI_CFG1_FRATE_CAPTURE_ALL, +	/* to use codec and preview path simultaneously */ +	.full_mode		= 1, +	.data_width_flags	= ISI_DATAWIDTH_8 | ISI_DATAWIDTH_10, +	/* ISI_MCK is provided by programmable clock or external clock */ +	.mck_hz			= 25000000, +}; + + +/* + * soc-camera OV2640 + */ +#if defined(CONFIG_SOC_CAMERA_OV2640) || \ +	defined(CONFIG_SOC_CAMERA_OV2640_MODULE) +static unsigned long isi_camera_query_bus_param(struct soc_camera_link *link) +{ +	/* ISI board for ek using default 8-bits connection */ +	return SOCAM_DATAWIDTH_8; +} + +static int i2c_camera_power(struct device *dev, int on) +{ +	/* enable or disable the camera */ +	pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE"); +	at91_set_gpio_output(AT91_PIN_PD13, !on); + +	if (!on) +		goto out; + +	/* If enabled, give a reset impulse */ +	at91_set_gpio_output(AT91_PIN_PD12, 0); +	msleep(20); +	at91_set_gpio_output(AT91_PIN_PD12, 1); +	msleep(100); + +out: +	return 0; +} + +static struct i2c_board_info i2c_camera = { +	I2C_BOARD_INFO("ov2640", 0x30), +}; + +static struct soc_camera_link iclink_ov2640 = { +	.bus_id			= 0, +	.board_info		= &i2c_camera, +	.i2c_adapter_id		= 0, +	.power			= i2c_camera_power, +	.query_bus_param	= isi_camera_query_bus_param, +}; + +static struct platform_device isi_ov2640 = { +	.name	= "soc-camera-pdrv", +	.id	= 0, +	.dev	= { +		.platform_data = &iclink_ov2640, +	}, +}; +#endif + + +/*   * LCD Controller   */  #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) @@ -233,7 +285,7 @@ static struct fb_monspecs at91fb_default_monspecs = {  					| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)  /* Driver datas */ -static struct atmel_lcdfb_info __initdata ek_lcdc_data = { +static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {  	.lcdcon_is_backlight		= true,  	.default_bpp			= 32,  	.default_dmacon			= ATMEL_LCDC_DMAEN, @@ -244,20 +296,20 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data = {  };  #else -static struct atmel_lcdfb_info __initdata ek_lcdc_data; +static struct atmel_lcdfb_pdata __initdata ek_lcdc_data;  #endif  /* - * Touchscreen + * ADCs and touchscreen   */ -static struct at91_tsadcc_data ek_tsadcc_data = { -	.adc_clock		= 300000, -	.pendet_debounce	= 0x0d, -	.ts_sample_hold_time	= 0x0a, +static struct at91_adc_data ek_adc_data = { +	.channels_used = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | BIT(6) | BIT(7), +	.use_external_triggers = true, +	.vref = 3300, +	.touchscreen_type = ATMEL_ADC_TOUCHSCREEN_4WIRE,  }; -  /*   * GPIO Buttons   */ @@ -345,6 +397,7 @@ static void __init ek_add_device_buttons(void) {}   * reset_pin is not connected: NRST   */  static struct ac97c_platform_data ek_ac97_data = { +	.reset_pin	= -EINVAL,  }; @@ -388,11 +441,22 @@ static struct gpio_led ek_pwm_led[] = {  #endif  }; - +static struct platform_device *devices[] __initdata = { +#if defined(CONFIG_SOC_CAMERA_OV2640) || \ +	defined(CONFIG_SOC_CAMERA_OV2640_MODULE) +	&isi_ov2640, +#endif +};  static void __init ek_board_init(void)  {  	/* Serial */ +	/* DGBU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 not connected on the -EK board */ +	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ +	at91_register_uart(AT91SAM9G45_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);  	at91_add_device_serial();  	/* USB HS Host */  	at91_add_device_usbh_ohci(&ek_usbh_hs_data); @@ -410,10 +474,12 @@ static void __init ek_board_init(void)  	ek_add_device_nand();  	/* I2C */  	at91_add_device_i2c(0, NULL, 0); +	/* ISI, using programmable clock as ISI_MCK */ +	at91_add_device_isi(&isi_data, true);  	/* LCD Controller */  	at91_add_device_lcdc(&ek_lcdc_data); -	/* Touch Screen */ -	at91_add_device_tsadcc(&ek_tsadcc_data); +	/* ADC and touchscreen */ +	at91_add_device_adc(&ek_adc_data);  	/* Push Buttons */  	ek_add_device_buttons();  	/* AC97 */ @@ -421,13 +487,16 @@ static void __init ek_board_init(void)  	/* LEDs */  	at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));  	at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led)); +	/* Other platform devices */ +	platform_add_devices(devices, ARRAY_SIZE(devices));  }  MACHINE_START(AT91SAM9M10G45EK, "Atmel AT91SAM9M10G45-EK")  	/* Maintainer: Atmel */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ek_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= ek_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c index 3bf3408e94c..b64648b4a1f 100644 --- a/arch/arm/mach-at91/board-sam9rlek.c +++ b/arch/arm/mach-at91/board-sam9rlek.c @@ -8,6 +8,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -17,6 +18,7 @@  #include <linux/clk.h>  #include <linux/input.h>  #include <linux/gpio_keys.h> +#include <linux/platform_data/at91_adc.h>  #include <video/atmel_lcdc.h> @@ -29,36 +31,23 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91sam9_smc.h> -#include <mach/at91_shdwc.h> + +#include "at91_aic.h" +#include "at91_shdwc.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h" -static void __init ek_map_io(void) +static void __init ek_init_early(void)  {  	/* Initialize processor: 12.000 MHz crystal */ -	at91sam9rl_initialize(12000000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */ -	at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init ek_init_irq(void) -{ -	at91sam9rl_init_interrupts(NULL); +	at91_initialize(12000000);  } -  /*   * USB HS Device port   */ @@ -70,11 +59,12 @@ static struct usba_platform_data __initdata ek_usba_udc_data = {  /*   * MCI (SD/MMC)   */ -static struct at91_mmc_data __initdata ek_mmc_data = { -	.wire4		= 1, -	.det_pin	= AT91_PIN_PA15, -//	.wp_pin		= ... not connected -//	.vcc_pin	= ... not connected +static struct mci_platform_data __initdata mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PA15, +		.wp_pin		= -EINVAL, +	},  }; @@ -94,19 +84,16 @@ static struct mtd_partition __initdata ek_nand_partition[] = {  	},  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(ek_nand_partition); -	return ek_nand_partition; -} -  static struct atmel_nand_data __initdata ek_nand_data = {  	.ale		= 21,  	.cle		= 22, -//	.det_pin	= ... not connected +	.det_pin	= -EINVAL,  	.rdy_pin	= AT91_PIN_PD17,  	.enable_pin	= AT91_PIN_PB6, -	.partition_info	= nand_partitions, +	.ecc_mode	= NAND_ECC_SOFT, +	.on_flash_bbt	= 1, +	.parts		= ek_nand_partition, +	.num_parts	= ARRAY_SIZE(ek_nand_partition),  };  static struct sam9_smc_config __initdata ek_nand_smc_config = { @@ -130,7 +117,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {  static void __init ek_add_device_nand(void)  {  	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &ek_nand_smc_config); +	sam9_smc_configure(0, 3, &ek_nand_smc_config);  	at91_add_device_nand(&ek_nand_data);  } @@ -185,7 +172,7 @@ static struct fb_monspecs at91fb_default_monspecs = {  					| ATMEL_LCDC_DISTYPE_TFT \  					| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE) -static void at91_lcdc_power_control(int on) +static void at91_lcdc_power_control(struct atmel_lcdfb_pdata *pdata, int on)  {  	if (on)  		at91_set_gpio_value(AT91_PIN_PC1, 0);	/* power up */ @@ -194,7 +181,7 @@ static void at91_lcdc_power_control(int on)  }  /* Driver datas */ -static struct atmel_lcdfb_info __initdata ek_lcdc_data = { +static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {  	.lcdcon_is_backlight            = true,  	.default_bpp			= 16,  	.default_dmacon			= ATMEL_LCDC_DMAEN, @@ -206,7 +193,7 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data = {  };  #else -static struct atmel_lcdfb_info __initdata ek_lcdc_data; +static struct atmel_lcdfb_pdata __initdata ek_lcdc_data;  #endif @@ -215,6 +202,7 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data;   * reset_pin is not connected: NRST   */  static struct ac97c_platform_data ek_ac97_data = { +	.reset_pin	= -EINVAL,  }; @@ -243,12 +231,13 @@ static struct gpio_led ek_leds[] = {  /* - * Touchscreen + * ADC + Touchscreen   */ -static struct at91_tsadcc_data ek_tsadcc_data = { -	.adc_clock		= 1000000, -	.pendet_debounce	= 0x0f, -	.ts_sample_hold_time	= 0x03, +static struct at91_adc_data ek_adc_data = { +	.channels_used = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5), +	.use_external_triggers = true, +	.vref = 3300, +	.touchscreen_type = ATMEL_ADC_TOUCHSCREEN_4WIRE,  }; @@ -304,6 +293,11 @@ static void __init ek_add_device_buttons(void) {}  static void __init ek_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */ +	at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);  	at91_add_device_serial();  	/* USB HS */  	at91_add_device_usba(&ek_usba_udc_data); @@ -314,13 +308,13 @@ static void __init ek_board_init(void)  	/* SPI */  	at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));  	/* MMC */ -	at91_add_device_mmc(0, &ek_mmc_data); +	at91_add_device_mci(0, &mci0_data);  	/* LCD Controller */  	at91_add_device_lcdc(&ek_lcdc_data);  	/* AC97 */  	at91_add_device_ac97(&ek_ac97_data); -	/* Touch Screen Controller */ -	at91_add_device_tsadcc(&ek_tsadcc_data); +	/* Touch Screen Controller + ADC */ +	at91_add_device_adc(&ek_adc_data);  	/* LEDs */  	at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));  	/* Push Buttons */ @@ -329,9 +323,10 @@ static void __init ek_board_init(void)  MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")  	/* Maintainer: Atmel */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= ek_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= ek_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-snapper9260.c b/arch/arm/mach-at91/board-snapper9260.c index 0a99b3cedd7..1b870e6def0 100644 --- a/arch/arm/mach-at91/board-snapper9260.c +++ b/arch/arm/mach-at91/board-snapper9260.c @@ -4,7 +4,7 @@   *  Copyright (C) 2010 Bluewater System Ltd   *   * Author: Andre Renaud <andre@bluewatersys.com> - * Author: Ryan Mallon  <ryan@bluewatersys.com> + * Author: Ryan Mallon   *   * This program is free software; you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -26,51 +26,42 @@  #include <linux/gpio.h>  #include <linux/platform_device.h>  #include <linux/spi/spi.h> -#include <linux/i2c/pca953x.h> +#include <linux/platform_data/pca953x.h>  #include <asm/mach-types.h>  #include <asm/mach/arch.h>  #include <mach/hardware.h> -#include <mach/board.h>  #include <mach/at91sam9_smc.h> +#include "at91_aic.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h"  #define SNAPPER9260_IO_EXP_GPIO(x)	(NR_BUILTIN_GPIO + (x)) -static void __init snapper9260_map_io(void) +static void __init snapper9260_init_early(void)  { -	at91sam9260_initialize(18432000); - -	/* Debug on ttyS0 */ -	at91_register_uart(0, 0, 0); -	at91_set_serial_console(0); - -	at91_register_uart(AT91SAM9260_ID_US0, 1, -			   ATMEL_UART_CTS | ATMEL_UART_RTS); -	at91_register_uart(AT91SAM9260_ID_US1, 2, -			   ATMEL_UART_CTS | ATMEL_UART_RTS); -	at91_register_uart(AT91SAM9260_ID_US2, 3, 0); -} - -static void __init snapper9260_init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); +	at91_initialize(18432000);  }  static struct at91_usbh_data __initdata snapper9260_usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  static struct at91_udc_data __initdata snapper9260_udc_data = {  	.vbus_pin		= SNAPPER9260_IO_EXP_GPIO(5),  	.vbus_active_low	= 1,  	.vbus_polled		= 1, +	.pullup_pin		= -EINVAL,  }; -static struct at91_eth_data snapper9260_macb_data = { +static struct macb_platform_data snapper9260_macb_data = { +	.phy_irq_pin	= -EINVAL,  	.is_rmii	= 1,  }; @@ -102,19 +93,16 @@ static struct mtd_partition __initdata snapper9260_nand_partitions[] = {  	},  }; -static struct mtd_partition * __init -snapper9260_nand_partition_info(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(snapper9260_nand_partitions); -	return snapper9260_nand_partitions; -} -  static struct atmel_nand_data __initdata snapper9260_nand_data = {  	.ale		= 21,  	.cle		= 22,  	.rdy_pin	= AT91_PIN_PC13, -	.partition_info	= snapper9260_nand_partition_info, +	.parts		= snapper9260_nand_partitions, +	.num_parts	= ARRAY_SIZE(snapper9260_nand_partitions),  	.bus_width_16	= 0, +	.enable_pin	= -EINVAL, +	.det_pin	= -EINVAL, +	.ecc_mode	= NAND_ECC_SOFT,  };  static struct sam9_smc_config __initdata snapper9260_nand_smc_config = { @@ -150,16 +138,17 @@ static struct i2c_board_info __initdata snapper9260_i2c_devices[] = {  		/* Audio codec */  		I2C_BOARD_INFO("tlv320aic23", 0x1a),  	}, -	{ +}; + +static struct i2c_board_info __initdata snapper9260_i2c_isl1208 = {  		/* RTC */  		I2C_BOARD_INFO("isl1208", 0x6f), -	},  };  static void __init snapper9260_add_device_nand(void)  {  	at91_set_A_periph(AT91_PIN_PC14, 0); -	sam9_smc_configure(3, &snapper9260_nand_smc_config); +	sam9_smc_configure(0, 3, &snapper9260_nand_smc_config);  	at91_add_device_nand(&snapper9260_nand_data);  } @@ -167,6 +156,18 @@ static void __init snapper9260_board_init(void)  {  	at91_add_device_i2c(snapper9260_i2c_devices,  			    ARRAY_SIZE(snapper9260_i2c_devices)); + +	snapper9260_i2c_isl1208.irq = gpio_to_irq(AT91_PIN_PA31); +	i2c_register_board_info(0, &snapper9260_i2c_isl1208, 1); + +	/* Debug on ttyS0 */ +	at91_register_uart(0, 0, 0); + +	at91_register_uart(AT91SAM9260_ID_US0, 1, +			   ATMEL_UART_CTS | ATMEL_UART_RTS); +	at91_register_uart(AT91SAM9260_ID_US1, 2, +			   ATMEL_UART_CTS | ATMEL_UART_RTS); +	at91_register_uart(AT91SAM9260_ID_US2, 3, 0);  	at91_add_device_serial();  	at91_add_device_usbh(&snapper9260_usbh_data);  	at91_add_device_udc(&snapper9260_udc_data); @@ -177,10 +178,11 @@ static void __init snapper9260_board_init(void)  }  MACHINE_START(SNAPPER_9260, "Bluewater Systems Snapper 9260/9G20 module") -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= snapper9260_map_io, -	.init_irq	= snapper9260_init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= snapper9260_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= snapper9260_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-stamp9g20.c b/arch/arm/mach-at91/board-stamp9g20.c index 5206eef4a67..3b575036ff9 100644 --- a/arch/arm/mach-at91/board-stamp9g20.c +++ b/arch/arm/mach-at91/board-stamp9g20.c @@ -25,65 +25,22 @@  #include <asm/mach-types.h>  #include <asm/mach/arch.h> -#include <mach/board.h>  #include <mach/at91sam9_smc.h> +#include <mach/hardware.h> +#include "at91_aic.h" +#include "board.h"  #include "sam9_smc.h"  #include "generic.h" +#include "gpio.h" -static void __init portuxg20_map_io(void) +void __init stamp9g20_init_early(void)  {  	/* Initialize processor: 18.432 MHz crystal */ -	at91sam9260_initialize(18432000); - -	/* DGBU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -						| ATMEL_UART_DTR | ATMEL_UART_DSR -						| ATMEL_UART_DCD | ATMEL_UART_RI); - -	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */ -	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */ -	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS); - -	/* USART4 on ttyS5. (Rx, Tx only) */ -	at91_register_uart(AT91SAM9260_ID_US4, 5, 0); - -	/* USART5 on ttyS6. (Rx, Tx only) */ -	at91_register_uart(AT91SAM9260_ID_US5, 6, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); +	at91_initialize(18432000);  } -static void __init stamp9g20_map_io(void) -{ -	/* Initialize processor: 18.432 MHz crystal */ -	at91sam9260_initialize(18432000); - -	/* DGBU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -						| ATMEL_UART_DTR | ATMEL_UART_DSR -						| ATMEL_UART_DCD | ATMEL_UART_RI); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); -} - -  /*   * NAND flash   */ @@ -93,6 +50,8 @@ static struct atmel_nand_data __initdata nand_data = {  	.rdy_pin	= AT91_PIN_PC13,  	.enable_pin	= AT91_PIN_PC14,  	.bus_width_16	= 0, +	.det_pin	= -EINVAL, +	.ecc_mode	= NAND_ECC_SOFT,  };  static struct sam9_smc_config __initdata nand_smc_config = { @@ -116,7 +75,7 @@ static struct sam9_smc_config __initdata nand_smc_config = {  static void __init add_device_nand(void)  {  	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &nand_smc_config); +	sam9_smc_configure(0, 3, &nand_smc_config);  	at91_add_device_nand(&nand_data);  } @@ -126,18 +85,13 @@ static void __init add_device_nand(void)   * MCI (SD/MMC)   * det_pin, wp_pin and vcc_pin are not connected   */ -#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)  static struct mci_platform_data __initdata mmc_data = {  	.slot[0] = {  		.bus_width	= 4, +		.detect_pin	= -1, +		.wp_pin		= -1,  	},  }; -#else -static struct at91_mmc_data __initdata mmc_data = { -	.slot_b		= 0, -	.wire4		= 1, -}; -#endif  /* @@ -145,6 +99,8 @@ static struct at91_mmc_data __initdata mmc_data = {   */  static struct at91_usbh_data __initdata usbh_data = {  	.ports		= 2, +	.vbus_pin	= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  }; @@ -153,19 +109,19 @@ static struct at91_usbh_data __initdata usbh_data = {   */  static struct at91_udc_data __initdata portuxg20_udc_data = {  	.vbus_pin	= AT91_PIN_PC7, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */  }; -static struct at91_udc_data __initdata stamp9g20_udc_data = { +static struct at91_udc_data __initdata stamp9g20evb_udc_data = {  	.vbus_pin	= AT91_PIN_PA22, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ +	.pullup_pin	= -EINVAL,		/* pull-up driven by UDC */  };  /*   * MACB Ethernet device   */ -static struct at91_eth_data __initdata macb_data = { +static struct macb_platform_data __initdata macb_data = {  	.phy_irq_pin	= AT91_PIN_PA28,  	.is_rmii	= 1,  }; @@ -190,7 +146,7 @@ static struct gpio_led portuxg20_leds[] = {  	}  }; -static struct gpio_led stamp9g20_leds[] = { +static struct gpio_led stamp9g20evb_leds[] = {  	{  		.name			= "D8",  		.gpio			= AT91_PIN_PB18, @@ -234,6 +190,7 @@ static struct spi_board_info portuxg20_spi_devices[] = {  static struct w1_gpio_platform_data w1_gpio_pdata = {  	.pin		= AT91_PIN_PA29,  	.is_open_drain	= 1, +	.ext_pullup_enable_pin	= -EINVAL,  };  static struct platform_device w1_device = { @@ -250,62 +207,88 @@ void add_w1(void)  } -static void __init generic_board_init(void) +void __init stamp9g20_board_init(void)  {  	/* Serial */ +	/* DGBU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0);  	at91_add_device_serial();  	/* NAND */  	add_device_nand();  	/* MMC */ -#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)  	at91_add_device_mci(0, &mmc_data); -#else -	at91_add_device_mmc(0, &mmc_data); -#endif -	/* USB Host */ -	at91_add_device_usbh(&usbh_data); -	/* Ethernet */ -	at91_add_device_eth(&macb_data); -	/* I2C */ -	at91_add_device_i2c(NULL, 0);  	/* W1 */  	add_w1();  }  static void __init portuxg20_board_init(void)  { -	generic_board_init(); -	/* SPI */ -	at91_add_device_spi(portuxg20_spi_devices, ARRAY_SIZE(portuxg20_spi_devices)); +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS +						| ATMEL_UART_DTR | ATMEL_UART_DSR +						| ATMEL_UART_DCD | ATMEL_UART_RI); + +	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */ +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); + +	/* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */ +	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS); + +	/* USART4 on ttyS5. (Rx, Tx only) */ +	at91_register_uart(AT91SAM9260_ID_US4, 5, 0); + +	/* USART5 on ttyS6. (Rx, Tx only) */ +	at91_register_uart(AT91SAM9260_ID_US5, 6, 0); +	stamp9g20_board_init(); +	/* USB Host */ +	at91_add_device_usbh(&usbh_data);  	/* USB Device */  	at91_add_device_udc(&portuxg20_udc_data); +	/* Ethernet */ +	at91_add_device_eth(&macb_data); +	/* I2C */ +	at91_add_device_i2c(NULL, 0); +	/* SPI */ +	at91_add_device_spi(portuxg20_spi_devices, ARRAY_SIZE(portuxg20_spi_devices));  	/* LEDs */  	at91_gpio_leds(portuxg20_leds, ARRAY_SIZE(portuxg20_leds));  } -static void __init stamp9g20_board_init(void) +static void __init stamp9g20evb_board_init(void)  { -	generic_board_init(); +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS +						| ATMEL_UART_DTR | ATMEL_UART_DSR +						| ATMEL_UART_DCD | ATMEL_UART_RI); +	stamp9g20_board_init(); +	/* USB Host */ +	at91_add_device_usbh(&usbh_data);  	/* USB Device */ -	at91_add_device_udc(&stamp9g20_udc_data); +	at91_add_device_udc(&stamp9g20evb_udc_data); +	/* Ethernet */ +	at91_add_device_eth(&macb_data); +	/* I2C */ +	at91_add_device_i2c(NULL, 0);  	/* LEDs */ -	at91_gpio_leds(stamp9g20_leds, ARRAY_SIZE(stamp9g20_leds)); +	at91_gpio_leds(stamp9g20evb_leds, ARRAY_SIZE(stamp9g20evb_leds));  }  MACHINE_START(PORTUXG20, "taskit PortuxG20")  	/* Maintainer: taskit GmbH */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= portuxg20_map_io, -	.init_irq	= init_irq, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= stamp9g20_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= portuxg20_board_init,  MACHINE_END  MACHINE_START(STAMP9G20, "taskit Stamp9G20")  	/* Maintainer: taskit GmbH */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= stamp9g20_map_io, -	.init_irq	= init_irq, -	.init_machine	= stamp9g20_board_init, +	.init_time	= at91sam926x_pit_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= stamp9g20_init_early, +	.init_irq	= at91_init_irq_default, +	.init_machine	= stamp9g20evb_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/board-usb-a9260.c b/arch/arm/mach-at91/board-usb-a9260.c deleted file mode 100644 index 07784baeae8..00000000000 --- a/arch/arm/mach-at91/board-usb-a9260.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * linux/arch/arm/mach-at91/board-usb-a9260.c - * - *  Copyright (C) 2005 SAN People - *  Copyright (C) 2006 Atmel - *  Copyright (C) 2007 Calao-systems - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#include <linux/types.h> -#include <linux/init.h> -#include <linux/mm.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/spi/spi.h> -#include <linux/gpio_keys.h> -#include <linux/input.h> -#include <linux/clk.h> - -#include <asm/setup.h> -#include <asm/mach-types.h> -#include <asm/irq.h> - -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/mach/irq.h> - -#include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h> -#include <mach/at91sam9_smc.h> -#include <mach/at91_shdwc.h> - -#include "sam9_smc.h" -#include "generic.h" - - -static void __init ek_map_io(void) -{ -	/* Initialize processor: 12.000 MHz crystal */ -	at91sam9260_initialize(12000000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init ek_init_irq(void) -{ -	at91sam9260_init_interrupts(NULL); -} - - -/* - * USB Host port - */ -static struct at91_usbh_data __initdata ek_usbh_data = { -	.ports		= 2, -}; - -/* - * USB Device port - */ -static struct at91_udc_data __initdata ek_udc_data = { -	.vbus_pin	= AT91_PIN_PC5, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ -}; - -/* - * MACB Ethernet device - */ -static struct at91_eth_data __initdata ek_macb_data = { -	.phy_irq_pin	= AT91_PIN_PA31, -	.is_rmii	= 1, -}; - -/* - * NAND flash - */ -static struct mtd_partition __initdata ek_nand_partition[] = { -	{ -		.name	= "Uboot & Kernel", -		.offset	= 0, -		.size	= SZ_16M, -	}, -	{ -		.name	= "Root FS", -		.offset	= MTDPART_OFS_NXTBLK, -		.size	= 120 * SZ_1M, -	}, -	{ -		.name	= "FS", -		.offset	= MTDPART_OFS_NXTBLK, -		.size	= 120 * SZ_1M, -	} -}; - -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(ek_nand_partition); -	return ek_nand_partition; -} - -static struct atmel_nand_data __initdata ek_nand_data = { -	.ale		= 21, -	.cle		= 22, -//	.det_pin	= ... not connected -	.rdy_pin	= AT91_PIN_PC13, -	.enable_pin	= AT91_PIN_PC14, -	.partition_info	= nand_partitions, -}; - -static struct sam9_smc_config __initdata ek_nand_smc_config = { -	.ncs_read_setup		= 0, -	.nrd_setup		= 1, -	.ncs_write_setup	= 0, -	.nwe_setup		= 1, - -	.ncs_read_pulse		= 3, -	.nrd_pulse		= 3, -	.ncs_write_pulse	= 3, -	.nwe_pulse		= 3, - -	.read_cycle		= 5, -	.write_cycle		= 5, - -	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8, -	.tdf_cycles		= 2, -}; - -static void __init ek_add_device_nand(void) -{ -	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &ek_nand_smc_config); - -	at91_add_device_nand(&ek_nand_data); -} - -/* - * GPIO Buttons - */ - -#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) -static struct gpio_keys_button ek_buttons[] = { -	{	/* USER PUSH BUTTON */ -		.code		= KEY_ENTER, -		.gpio		= AT91_PIN_PB10, -		.active_low	= 1, -		.desc		= "user_pb", -		.wakeup		= 1, -	} -}; - -static struct gpio_keys_platform_data ek_button_data = { -	.buttons	= ek_buttons, -	.nbuttons	= ARRAY_SIZE(ek_buttons), -}; - -static struct platform_device ek_button_device = { -	.name		= "gpio-keys", -	.id		= -1, -	.num_resources	= 0, -	.dev		= { -		.platform_data	= &ek_button_data, -	} -}; - -static void __init ek_add_device_buttons(void) -{ -	at91_set_GPIO_periph(AT91_PIN_PB10, 1);	/* user push button, pull up enabled */ -	at91_set_deglitch(AT91_PIN_PB10, 1); - -	platform_device_register(&ek_button_device); -} -#else -static void __init ek_add_device_buttons(void) {} -#endif - -/* - * LEDs - */ -static struct gpio_led ek_leds[] = { -	{	/* user_led (green) */ -		.name			= "user_led", -		.gpio			= AT91_PIN_PB21, -		.active_low		= 0, -		.default_trigger	= "heartbeat", -	} -}; - -static void __init ek_board_init(void) -{ -	/* Serial */ -	at91_add_device_serial(); -	/* USB Host */ -	at91_add_device_usbh(&ek_usbh_data); -	/* USB Device */ -	at91_add_device_udc(&ek_udc_data); -	/* NAND */ -	ek_add_device_nand(); -	/* I2C */ -	at91_add_device_i2c(NULL, 0); -	/* Ethernet */ -	at91_add_device_eth(&ek_macb_data); -	/* Push Buttons */ -	ek_add_device_buttons(); -	/* LEDs */ -	at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); -	/* shutdown controller, wakeup button (5 msec low) */ -	at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW -				| AT91_SHDW_RTTWKEN); -} - -MACHINE_START(USB_A9260, "CALAO USB_A9260") -	/* Maintainer: calao-systems */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, -	.init_machine	= ek_board_init, -MACHINE_END diff --git a/arch/arm/mach-at91/board-usb-a9263.c b/arch/arm/mach-at91/board-usb-a9263.c deleted file mode 100644 index b614508931f..00000000000 --- a/arch/arm/mach-at91/board-usb-a9263.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * linux/arch/arm/mach-at91/board-usb-a9263.c - * - *  Copyright (C) 2005 SAN People - *  Copyright (C) 2007 Atmel Corporation. - *  Copyright (C) 2007 Calao-systems - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#include <linux/types.h> -#include <linux/init.h> -#include <linux/mm.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/spi/spi.h> -#include <linux/gpio_keys.h> -#include <linux/input.h> - -#include <asm/setup.h> -#include <asm/mach-types.h> -#include <asm/irq.h> - -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/mach/irq.h> - -#include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h> -#include <mach/at91sam9_smc.h> -#include <mach/at91_shdwc.h> - -#include "sam9_smc.h" -#include "generic.h" - - -static void __init ek_map_io(void) -{ -	/* Initialize processor: 12.00 MHz crystal */ -	at91sam9263_initialize(12000000); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init ek_init_irq(void) -{ -	at91sam9263_init_interrupts(NULL); -} - - -/* - * USB Host port - */ -static struct at91_usbh_data __initdata ek_usbh_data = { -	.ports		= 2, -}; - -/* - * USB Device port - */ -static struct at91_udc_data __initdata ek_udc_data = { -	.vbus_pin	= AT91_PIN_PB11, -	.pullup_pin	= 0,		/* pull-up driven by UDC */ -}; - -/* - * SPI devices. - */ -static struct spi_board_info ek_spi_devices[] = { -#if !defined(CONFIG_MMC_AT91) -	{	/* DataFlash chip */ -		.modalias	= "mtd_dataflash", -		.chip_select	= 0, -		.max_speed_hz	= 15 * 1000 * 1000, -		.bus_num	= 0, -	} -#endif -}; - -/* - * MACB Ethernet device - */ -static struct at91_eth_data __initdata ek_macb_data = { -	.phy_irq_pin	= AT91_PIN_PE31, -	.is_rmii	= 1, -}; - -/* - * NAND flash - */ -static struct mtd_partition __initdata ek_nand_partition[] = { -	{ -		.name	= "Linux Kernel", -		.offset	= 0, -		.size	= SZ_16M, -	}, -	{ -		.name	= "Root FS", -		.offset	= MTDPART_OFS_NXTBLK, -		.size	= 120 * SZ_1M, -	}, -	{ -		.name	= "FS", -		.offset	= MTDPART_OFS_NXTBLK, -		.size	= 120 * SZ_1M, -	} -}; - -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(ek_nand_partition); -	return ek_nand_partition; -} - -static struct atmel_nand_data __initdata ek_nand_data = { -	.ale		= 21, -	.cle		= 22, -//	.det_pin	= ... not connected -	.rdy_pin	= AT91_PIN_PA22, -	.enable_pin	= AT91_PIN_PD15, -	.partition_info	= nand_partitions, -}; - -static struct sam9_smc_config __initdata ek_nand_smc_config = { -	.ncs_read_setup		= 0, -	.nrd_setup		= 1, -	.ncs_write_setup	= 0, -	.nwe_setup		= 1, - -	.ncs_read_pulse		= 3, -	.nrd_pulse		= 3, -	.ncs_write_pulse	= 3, -	.nwe_pulse		= 3, - -	.read_cycle		= 5, -	.write_cycle		= 5, - -	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8, -	.tdf_cycles		= 2, -}; - -static void __init ek_add_device_nand(void) -{ -	/* configure chip-select 3 (NAND) */ -	sam9_smc_configure(3, &ek_nand_smc_config); - -	at91_add_device_nand(&ek_nand_data); -} - - -/* - * GPIO Buttons - */ -#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) -static struct gpio_keys_button ek_buttons[] = { -	{	/* USER PUSH BUTTON */ -		.code		= KEY_ENTER, -		.gpio		= AT91_PIN_PB10, -		.active_low	= 1, -		.desc		= "user_pb", -		.wakeup		= 1, -	} -}; - -static struct gpio_keys_platform_data ek_button_data = { -	.buttons	= ek_buttons, -	.nbuttons	= ARRAY_SIZE(ek_buttons), -}; - -static struct platform_device ek_button_device = { -	.name		= "gpio-keys", -	.id		= -1, -	.num_resources	= 0, -	.dev		= { -		.platform_data	= &ek_button_data, -	} -}; - -static void __init ek_add_device_buttons(void) -{ -	at91_set_GPIO_periph(AT91_PIN_PB10, 1);	/* user push button, pull up enabled */ -	at91_set_deglitch(AT91_PIN_PB10, 1); - -	platform_device_register(&ek_button_device); -} -#else -static void __init ek_add_device_buttons(void) {} -#endif - -/* - * LEDs - */ -static struct gpio_led ek_leds[] = { -	{	/* user_led (green) */ -		.name			= "user_led", -		.gpio			= AT91_PIN_PB21, -		.active_low		= 1, -		.default_trigger	= "heartbeat", -	} -}; - - -static void __init ek_board_init(void) -{ -	/* Serial */ -	at91_add_device_serial(); -	/* USB Host */ -	at91_add_device_usbh(&ek_usbh_data); -	/* USB Device */ -	at91_add_device_udc(&ek_udc_data); -	/* SPI */ -	at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); -	/* Ethernet */ -	at91_add_device_eth(&ek_macb_data); -	/* NAND */ -	ek_add_device_nand(); -	/* I2C */ -	at91_add_device_i2c(NULL, 0); -	/* Push Buttons */ -	ek_add_device_buttons(); -	/* LEDs */ -	at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); -	/* shutdown controller, wakeup button (5 msec low) */ -	at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW -				| AT91_SHDW_RTTWKEN); -} - -MACHINE_START(USB_A9263, "CALAO USB_A9263") -	/* Maintainer: calao-systems */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91sam926x_timer, -	.map_io		= ek_map_io, -	.init_irq	= ek_init_irq, -	.init_machine	= ek_board_init, -MACHINE_END diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c index 89df00a9d2f..46fdb0c68a6 100644 --- a/arch/arm/mach-at91/board-yl-9200.c +++ b/arch/arm/mach-at91/board-yl-9200.c @@ -22,6 +22,7 @@   */  #include <linux/types.h> +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/mm.h>  #include <linux/module.h> @@ -42,45 +43,25 @@  #include <asm/mach/irq.h>  #include <mach/hardware.h> -#include <mach/board.h> -#include <mach/gpio.h>  #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> +#include <mach/cpu.h> +#include "at91_aic.h" +#include "board.h"  #include "generic.h" +#include "gpio.h" -static void __init yl9200_map_io(void) +static void __init yl9200_init_early(void)  { -	/* Initialize processor: 18.432 MHz crystal */ -	at91rm9200_initialize(18432000, AT91RM9200_PQFP); - -	/* Setup the LEDs D2=PB17 (timer), D3=PB16 (cpu) */ -	at91_init_leds(AT91_PIN_PB16, AT91_PIN_PB17); - -	/* DBGU on ttyS0. (Rx & Tx only) */ -	at91_register_uart(0, 0, 0); - -	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ -	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS -			| ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD -			| ATMEL_UART_RI); +	/* Set cpu type: PQFP */ +	at91rm9200_set_type(ARCH_REVISON_9200_PQFP); -	/* USART0 on ttyS2. (Rx & Tx only to JP3) */ -	at91_register_uart(AT91RM9200_ID_US0, 2, 0); - -	/* USART3 on ttyS3. (Rx, Tx, RTS - RS485 interface) */ -	at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_RTS); - -	/* set serial console to ttyS0 (ie, DBGU) */ -	at91_set_serial_console(0); -} - -static void __init yl9200_init_irq(void) -{ -	at91rm9200_init_interrupts(NULL); +	/* Initialize processor: 18.432 MHz crystal */ +	at91_initialize(18432000);  } -  /*   * LEDs   */ @@ -112,7 +93,7 @@ static struct gpio_led yl9200_leds[] = {  /*   * Ethernet   */ -static struct at91_eth_data __initdata yl9200_eth_data = { +static struct macb_platform_data __initdata yl9200_eth_data = {  	.phy_irq_pin		= AT91_PIN_PB28,  	.is_rmii		= 1,  }; @@ -122,6 +103,8 @@ static struct at91_eth_data __initdata yl9200_eth_data = {   */  static struct at91_usbh_data __initdata yl9200_usbh_data = {  	.ports			= 1,	/* PQFP version of AT91RM9200 */ +	.vbus_pin		= {-EINVAL, -EINVAL}, +	.overcurrent_pin= {-EINVAL, -EINVAL},  };  /* @@ -137,10 +120,12 @@ static struct at91_udc_data __initdata yl9200_udc_data = {  /*   * MMC   */ -static struct at91_mmc_data __initdata yl9200_mmc_data = { -	.det_pin	= AT91_PIN_PB9, -	// .wp_pin	= ... not connected -	.wire4		= 1, +static struct mci_platform_data __initdata yl9200_mci0_data = { +	.slot[0] = { +		.bus_width	= 4, +		.detect_pin	= AT91_PIN_PB9, +		.wp_pin		= -EINVAL, +	},  };  /* @@ -174,19 +159,15 @@ static struct mtd_partition __initdata yl9200_nand_partition[] = {  	}  }; -static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) -{ -	*num_partitions = ARRAY_SIZE(yl9200_nand_partition); -	return yl9200_nand_partition; -} -  static struct atmel_nand_data __initdata yl9200_nand_data = {  	.ale		= 6,  	.cle		= 7, -	// .det_pin	= ... not connected +	.det_pin	= -EINVAL,  	.rdy_pin	= AT91_PIN_PC14,	/* R/!B (Sheet10) */  	.enable_pin	= AT91_PIN_PC15,	/* !CE  (Sheet10) */ -	.partition_info	= nand_partitions, +	.ecc_mode	= NAND_ECC_SOFT, +	.parts		= yl9200_nand_partition, +	.num_parts	= ARRAY_SIZE(yl9200_nand_partition),  };  /* @@ -387,17 +368,17 @@ static struct spi_board_info yl9200_spi_devices[] = {   * EPSON S1D13806 FB (discontinued chip)   * EPSON S1D13506 FB   */ -#if defined(CONFIG_FB_S1D135XX) || defined(CONFIG_FB_S1D13XXX_MODULE) +#if defined(CONFIG_FB_S1D13XXX) || defined(CONFIG_FB_S1D13XXX_MODULE)  #include <video/s1d13xxxfb.h> -static void __init yl9200_init_video(void) +static void yl9200_init_video(void)  {  	/* NWAIT Signal */  	at91_set_A_periph(AT91_PIN_PC6, 0);  	/* Initialization of the Static Memory Controller for Chip Select 2 */ -	at91_sys_write(AT91_SMC_CSR(2), AT91_SMC_DBW_16		/* 16 bit */ +	at91_ramc_write(0, AT91_SMC_CSR(2), AT91_SMC_DBW_16		/* 16 bit */  			| AT91_SMC_WSEN | AT91_SMC_NWS_(0x4)	/* wait states */  			| AT91_SMC_TDF_(0x100)			/* float time */  	); @@ -563,6 +544,19 @@ void __init yl9200_add_device_video(void) {}  static void __init yl9200_board_init(void)  {  	/* Serial */ +	/* DBGU on ttyS0. (Rx & Tx only) */ +	at91_register_uart(0, 0, 0); + +	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ +	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS +			| ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD +			| ATMEL_UART_RI); + +	/* USART0 on ttyS2. (Rx & Tx only to JP3) */ +	at91_register_uart(AT91RM9200_ID_US0, 2, 0); + +	/* USART3 on ttyS3. (Rx, Tx, RTS - RS485 interface) */ +	at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_RTS);  	at91_add_device_serial();  	/* Ethernet */  	at91_add_device_eth(&yl9200_eth_data); @@ -573,7 +567,7 @@ static void __init yl9200_board_init(void)  	/* I2C */  	at91_add_device_i2c(yl9200_i2c_devices, ARRAY_SIZE(yl9200_i2c_devices));  	/* MMC */ -	at91_add_device_mmc(0, &yl9200_mmc_data); +	at91_add_device_mci(0, &yl9200_mci0_data);  	/* NAND */  	at91_add_device_nand(&yl9200_nand_data);  	/* NOR Flash */ @@ -594,9 +588,10 @@ static void __init yl9200_board_init(void)  MACHINE_START(YL9200, "uCdragon YL-9200")  	/* Maintainer: S.Birtles */ -	.boot_params	= AT91_SDRAM_BASE + 0x100, -	.timer		= &at91rm9200_timer, -	.map_io		= yl9200_map_io, -	.init_irq	= yl9200_init_irq, +	.init_time	= at91rm9200_timer_init, +	.map_io		= at91_map_io, +	.handle_irq	= at91_aic_handle_irq, +	.init_early	= yl9200_init_early, +	.init_irq	= at91_init_irq_default,  	.init_machine	= yl9200_board_init,  MACHINE_END diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/board.h index 58528aa9c8a..4e773b55bc2 100644 --- a/arch/arm/mach-at91/include/mach/board.h +++ b/arch/arm/mach-at91/board.h @@ -31,89 +31,28 @@  #ifndef __ASM_ARCH_BOARD_H  #define __ASM_ARCH_BOARD_H -#include <linux/mtd/partitions.h> -#include <linux/device.h> -#include <linux/i2c.h> -#include <linux/leds.h> -#include <linux/spi/spi.h> -#include <linux/usb/atmel_usba_udc.h> -#include <linux/atmel-mci.h> -#include <sound/atmel-ac97c.h> -#include <linux/serial.h> +#include <linux/platform_data/atmel.h>   /* USB Device */ -struct at91_udc_data { -	u8	vbus_pin;		/* high == host powering us */ -	u8	vbus_active_low;	/* vbus polarity */ -	u8	vbus_polled;		/* Use polling, not interrupt */ -	u8	pullup_pin;		/* active == D+ pulled up */ -	u8	pullup_active_low;	/* true == pullup_pin is active low */ -};  extern void __init at91_add_device_udc(struct at91_udc_data *data);   /* USB High Speed Device */  extern void __init at91_add_device_usba(struct usba_platform_data *data);   /* Compact Flash */ -struct at91_cf_data { -	u8	irq_pin;		/* I/O IRQ */ -	u8	det_pin;		/* Card detect */ -	u8	vcc_pin;		/* power switching */ -	u8	rst_pin;		/* card reset */ -	u8	chipselect;		/* EBI Chip Select number */ -	u8	flags; -#define AT91_CF_TRUE_IDE	0x01 -#define AT91_IDE_SWAP_A0_A2	0x02 -};  extern void __init at91_add_device_cf(struct at91_cf_data *data);   /* MMC / SD */ -  /* at91_mci platform config */ -struct at91_mmc_data { -	u8		det_pin;	/* card detect IRQ */ -	unsigned	slot_b:1;	/* uses Slot B */ -	unsigned	wire4:1;	/* (SD) supports DAT0..DAT3 */ -	u8		wp_pin;		/* (SD) writeprotect detect */ -	u8		vcc_pin;	/* power switching (high == on) */ -}; -extern void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data); -    /* atmel-mci platform config */  extern void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data); - /* Ethernet (EMAC & MACB) */ -struct at91_eth_data { -	u32		phy_mask; -	u8		phy_irq_pin;	/* PHY IRQ */ -	u8		is_rmii;	/* using RMII interface? */ -}; -extern void __init at91_add_device_eth(struct at91_eth_data *data); - -#if defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9263) || defined(CONFIG_ARCH_AT91SAM9G20) || defined(CONFIG_ARCH_AT91CAP9) \ -	|| defined(CONFIG_ARCH_AT91SAM9G45) || defined(CONFIG_ARCH_AT572D940HF) -#define eth_platform_data	at91_eth_data -#endif +extern void __init at91_add_device_eth(struct macb_platform_data *data);   /* USB Host */ -struct at91_usbh_data { -	u8		ports;		/* number of ports on root hub */ -	u8		vbus_pin[2];	/* port power-control pin */ -};  extern void __init at91_add_device_usbh(struct at91_usbh_data *data);  extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data);  extern void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data); - /* NAND / SmartMedia */ -struct atmel_nand_data { -	u8		enable_pin;	/* chip enable */ -	u8		det_pin;	/* card detect */ -	u8		rdy_pin;	/* ready/busy */ -	u8              rdy_pin_active_low;     /* rdy_pin value is inverted */ -	u8		ale;		/* address line number connected to ALE */ -	u8		cle;		/* address line number connected to CLE */ -	u8		bus_width_16;	/* buswidth is 16 bit */ -	struct mtd_partition* (*partition_info)(int, int*); -};  extern void __init at91_add_device_nand(struct atmel_nand_data *data);   /* I2C*/ @@ -135,22 +74,9 @@ extern void __init at91_add_device_spi(struct spi_board_info *devices, int nr_de  #define ATMEL_UART_RI	0x20  extern void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins); -extern void __init at91_set_serial_console(unsigned portnr); -struct at91_uart_config { -	unsigned short	console_tty;	/* tty number of serial console */ -	unsigned short	nr_tty;		/* number of serial tty's */ -	short		tty_map[];	/* map UART to tty number */ -};  extern struct platform_device *atmel_default_console_device; -extern void __init __deprecated at91_init_serial(struct at91_uart_config *config); - -struct atmel_uart_data { -	short			use_dma_tx;	/* use transmit DMA? */ -	short			use_dma_rx;	/* use receive DMA? */ -	void __iomem		*regs;		/* virt. base address, if any */ -	struct serial_rs485	rs485;		/* rs485 settings */ -}; +  extern void __init at91_add_device_serial(void);  /* @@ -181,38 +107,22 @@ extern void __init at91_add_device_pwm(u32 mask);  extern void __init at91_add_device_ssc(unsigned id, unsigned pins);   /* LCD Controller */ -struct atmel_lcdfb_info; -extern void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data); +struct atmel_lcdfb_pdata; +extern void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data);   /* AC97 */  extern void __init at91_add_device_ac97(struct ac97c_platform_data *data);   /* ISI */ -extern void __init at91_add_device_isi(void); - - /* Touchscreen Controller */ -struct at91_tsadcc_data { -	unsigned int    adc_clock; -	u8		pendet_debounce; -	u8		ts_sample_hold_time; -}; -extern void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data); +struct isi_platform_data; +extern void __init at91_add_device_isi(struct isi_platform_data *data, +		bool use_pck_as_mck);  /* CAN */ -struct at91_can_data { -	void (*transceiver_switch)(int on); -};  extern void __init at91_add_device_can(struct at91_can_data *data);   /* LEDs */ -extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);  extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);  extern void __init at91_pwm_leds(struct gpio_led *leds, int nr); - /* AT572D940HF DSP */ -extern void __init at91_add_device_mAgic(void); - -/* FIXME: this needs a better location, but gets stuff building again */ -extern int at91_suspend_entering_slow_clock(void); -  #endif diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c index 7525cee3983..034529d801b 100644 --- a/arch/arm/mach-at91/clock.c +++ b/arch/arm/mach-at91/clock.c @@ -23,14 +23,19 @@  #include <linux/delay.h>  #include <linux/clk.h>  #include <linux/io.h> +#include <linux/of_address.h> +#include <linux/clk/at91_pmc.h>  #include <mach/hardware.h> -#include <mach/at91_pmc.h>  #include <mach/cpu.h> +#include <asm/proc-fns.h> +  #include "clock.h"  #include "generic.h" +void __iomem *at91_pmc_base; +EXPORT_SYMBOL_GPL(at91_pmc_base);  /*   * There's a lot more which can be done with clocks, including cpufreq @@ -47,26 +52,57 @@  /*   * Chips have some kind of clocks : group them by functionality   */ -#define cpu_has_utmi()		(  cpu_is_at91cap9() \ -				|| cpu_is_at91sam9rl() \ -				|| cpu_is_at91sam9g45()) +#define cpu_has_utmi()		(  cpu_is_at91sam9rl() \ +				|| cpu_is_at91sam9g45() \ +				|| cpu_is_at91sam9x5() \ +				|| cpu_is_sama5d3()) + +#define cpu_has_1056M_plla()	(cpu_is_sama5d3())  #define cpu_has_800M_plla()	(  cpu_is_at91sam9g20() \ -				|| cpu_is_at91sam9g45()) +				|| cpu_is_at91sam9g45() \ +				|| cpu_is_at91sam9x5() \ +				|| cpu_is_at91sam9n12())  #define cpu_has_300M_plla()	(cpu_is_at91sam9g10()) +#define cpu_has_240M_plla()	(cpu_is_at91sam9261() \ +				|| cpu_is_at91sam9263() \ +				|| cpu_is_at91sam9rl()) + +#define cpu_has_210M_plla()	(cpu_is_at91sam9260()) +  #define cpu_has_pllb()		(!(cpu_is_at91sam9rl() \ -				|| cpu_is_at91sam9g45())) +				|| cpu_is_at91sam9g45() \ +				|| cpu_is_at91sam9x5() \ +				|| cpu_is_sama5d3())) -#define cpu_has_upll()		(cpu_is_at91sam9g45()) +#define cpu_has_upll()		(cpu_is_at91sam9g45() \ +				|| cpu_is_at91sam9x5() \ +				|| cpu_is_sama5d3())  /* USB host HS & FS */  #define cpu_has_uhp()		(!cpu_is_at91sam9rl())  /* USB device FS only */  #define cpu_has_udpfs()		(!(cpu_is_at91sam9rl() \ -				|| cpu_is_at91sam9g45())) +				|| cpu_is_at91sam9g45() \ +				|| cpu_is_at91sam9x5() \ +				|| cpu_is_sama5d3())) + +#define cpu_has_plladiv2()	(cpu_is_at91sam9g45() \ +				|| cpu_is_at91sam9x5() \ +				|| cpu_is_at91sam9n12() \ +				|| cpu_is_sama5d3()) + +#define cpu_has_mdiv3()		(cpu_is_at91sam9g45() \ +				|| cpu_is_at91sam9x5() \ +				|| cpu_is_at91sam9n12() \ +				|| cpu_is_sama5d3()) + +#define cpu_has_alt_prescaler()	(cpu_is_at91sam9x5() \ +				|| cpu_is_at91sam9n12() \ +				|| cpu_is_sama5d3())  static LIST_HEAD(clocks);  static DEFINE_SPINLOCK(clk_lock); @@ -111,11 +147,11 @@ static void pllb_mode(struct clk *clk, int is_on)  		value = 0;  	// REVISIT: Add work-around for AT91RM9200 Errata #26 ? -	at91_sys_write(AT91_CKGR_PLLBR, value); +	at91_pmc_write(AT91_CKGR_PLLBR, value);  	do {  		cpu_relax(); -	} while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != is_on); +	} while ((at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != is_on);  }  static struct clk pllb = { @@ -130,31 +166,24 @@ static struct clk pllb = {  static void pmc_sys_mode(struct clk *clk, int is_on)  {  	if (is_on) -		at91_sys_write(AT91_PMC_SCER, clk->pmc_mask); +		at91_pmc_write(AT91_PMC_SCER, clk->pmc_mask);  	else -		at91_sys_write(AT91_PMC_SCDR, clk->pmc_mask); +		at91_pmc_write(AT91_PMC_SCDR, clk->pmc_mask);  }  static void pmc_uckr_mode(struct clk *clk, int is_on)  { -	unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR); - -	if (cpu_is_at91sam9g45()) { -		if (is_on) -			uckr |= AT91_PMC_BIASEN; -		else -			uckr &= ~AT91_PMC_BIASEN; -	} +	unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);  	if (is_on) {  		is_on = AT91_PMC_LOCKU; -		at91_sys_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask); +		at91_pmc_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask);  	} else -		at91_sys_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask)); +		at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask));  	do {  		cpu_relax(); -	} while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on); +	} while ((at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on);  }  /* USB function clocks (PLLB must be 48 MHz) */ @@ -163,7 +192,7 @@ static struct clk udpck = {  	.parent		= &pllb,  	.mode		= pmc_sys_mode,  }; -static struct clk utmi_clk = { +struct clk utmi_clk = {  	.name		= "utmi_clk",  	.parent		= &main_clk,  	.pmc_mask	= AT91_PMC_UPLLEN,	/* in CKGR_UCKR */ @@ -182,17 +211,33 @@ static struct clk uhpck = {   * memory, interfaces to on-chip peripherals, the AIC, and sometimes more   * (e.g baud rate generation).  It's sourced from one of the primary clocks.   */ -static struct clk mck = { +struct clk mck = {  	.name		= "mck",  	.pmc_mask	= AT91_PMC_MCKRDY,	/* in PMC_SR */  };  static void pmc_periph_mode(struct clk *clk, int is_on)  { -	if (is_on) -		at91_sys_write(AT91_PMC_PCER, clk->pmc_mask); -	else -		at91_sys_write(AT91_PMC_PCDR, clk->pmc_mask); +	u32 regval = 0; + +	/* +	 * With sama5d3 devices, we are managing clock division so we have to +	 * use the Peripheral Control Register introduced from at91sam9x5 +	 * devices. +	 */ +	if (cpu_is_sama5d3()) { +		regval |= AT91_PMC_PCR_CMD; /* write command */ +		regval |= clk->pid & AT91_PMC_PCR_PID; /* peripheral selection */ +		regval |= AT91_PMC_PCR_DIV(clk->div); +		if (is_on) +			regval |= AT91_PMC_PCR_EN; /* enable clock */ +		at91_pmc_write(AT91_PMC_PCR, regval); +	} else { +		if (is_on) +			at91_pmc_write(AT91_PMC_PCER, clk->pmc_mask); +		else +			at91_pmc_write(AT91_PMC_PCDR, clk->pmc_mask); +	}  }  static struct clk __init *at91_css_to_clk(unsigned long css) @@ -210,47 +255,23 @@ static struct clk __init *at91_css_to_clk(unsigned long css)  				return &utmi_clk;  			else if (cpu_has_pllb())  				return &pllb; +			break; +		/* alternate PMC: can use master clock */ +		case AT91_PMC_CSS_MASTER: +			return &mck;  	}  	return NULL;  } -/* - * Associate a particular clock with a function (eg, "uart") and device. - * The drivers can then request the same 'function' with several different - * devices and not care about which clock name to use. - */ -void __init at91_clock_associate(const char *id, struct device *dev, const char *func) +static int pmc_prescaler_divider(u32 reg)  { -	struct clk *clk = clk_get(NULL, id); - -	if (!dev || !clk || !IS_ERR(clk_get(dev, func))) -		return; - -	clk->function = func; -	clk->dev = dev; -} - -/* clocks cannot be de-registered no refcounting necessary */ -struct clk *clk_get(struct device *dev, const char *id) -{ -	struct clk *clk; - -	list_for_each_entry(clk, &clocks, node) { -		if (strcmp(id, clk->name) == 0) -			return clk; -		if (clk->function && (dev == clk->dev) && strcmp(id, clk->function) == 0) -			return clk; +	if (cpu_has_alt_prescaler()) { +		return 1 << ((reg & AT91_PMC_ALT_PRES) >> PMC_ALT_PRES_OFFSET); +	} else { +		return 1 << ((reg & AT91_PMC_PRES) >> PMC_PRES_OFFSET);  	} - -	return ERR_PTR(-ENOENT); -} -EXPORT_SYMBOL(clk_get); - -void clk_put(struct clk *clk) -{  } -EXPORT_SYMBOL(clk_put);  static void __clk_enable(struct clk *clk)  { @@ -309,8 +330,6 @@ EXPORT_SYMBOL(clk_get_rate);  /*------------------------------------------------------------------------*/ -#ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS -  /*   * For now, only the programmable clocks support reparenting (MCK could   * do this too, with care) or rate changing (the PLLs could do this too, @@ -353,12 +372,22 @@ int clk_set_rate(struct clk *clk, unsigned long rate)  {  	unsigned long	flags;  	unsigned	prescale; +	unsigned long	prescale_offset, css_mask;  	unsigned long	actual;  	if (!clk_is_programmable(clk))  		return -EINVAL;  	if (clk->users)  		return -EBUSY; + +	if (cpu_has_alt_prescaler()) { +		prescale_offset = PMC_ALT_PRES_OFFSET; +		css_mask = AT91_PMC_ALT_PCKR_CSS; +	} else { +		prescale_offset = PMC_PRES_OFFSET; +		css_mask = AT91_PMC_CSS; +	} +  	spin_lock_irqsave(&clk_lock, flags);  	actual = clk->parent->rate_hz; @@ -366,10 +395,10 @@ int clk_set_rate(struct clk *clk, unsigned long rate)  		if (actual && actual <= rate) {  			u32	pckr; -			pckr = at91_sys_read(AT91_PMC_PCKR(clk->id)); -			pckr &= AT91_PMC_CSS;	/* clock selection */ -			pckr |= prescale << 2; -			at91_sys_write(AT91_PMC_PCKR(clk->id), pckr); +			pckr = at91_pmc_read(AT91_PMC_PCKR(clk->id)); +			pckr &= css_mask;	/* keep clock selection */ +			pckr |= prescale << prescale_offset; +			at91_pmc_write(AT91_PMC_PCKR(clk->id), pckr);  			clk->rate_hz = actual;  			break;  		} @@ -403,7 +432,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)  	clk->rate_hz = parent->rate_hz;  	clk->parent = parent; -	at91_sys_write(AT91_PMC_PCKR(clk->id), parent->id); +	at91_pmc_write(AT91_PMC_PCKR(clk->id), parent->id);  	spin_unlock_irqrestore(&clk_lock, flags);  	return 0; @@ -415,57 +444,80 @@ static void __init init_programmable_clock(struct clk *clk)  {  	struct clk	*parent;  	u32		pckr; +	unsigned int	css_mask; -	pckr = at91_sys_read(AT91_PMC_PCKR(clk->id)); -	parent = at91_css_to_clk(pckr & AT91_PMC_CSS); +	if (cpu_has_alt_prescaler()) +		css_mask = AT91_PMC_ALT_PCKR_CSS; +	else +		css_mask = AT91_PMC_CSS; + +	pckr = at91_pmc_read(AT91_PMC_PCKR(clk->id)); +	parent = at91_css_to_clk(pckr & css_mask);  	clk->parent = parent; -	clk->rate_hz = parent->rate_hz / (1 << ((pckr & AT91_PMC_PRES) >> 2)); +	clk->rate_hz = parent->rate_hz / pmc_prescaler_divider(pckr);  } -#endif	/* CONFIG_AT91_PROGRAMMABLE_CLOCKS */ -  /*------------------------------------------------------------------------*/  #ifdef CONFIG_DEBUG_FS  static int at91_clk_show(struct seq_file *s, void *unused)  { -	u32		scsr, pcsr, uckr = 0, sr; +	u32		scsr, pcsr, pcsr1 = 0, uckr = 0, sr;  	struct clk	*clk; -	seq_printf(s, "SCSR = %8x\n", scsr = at91_sys_read(AT91_PMC_SCSR)); -	seq_printf(s, "PCSR = %8x\n", pcsr = at91_sys_read(AT91_PMC_PCSR)); -	seq_printf(s, "MOR  = %8x\n", at91_sys_read(AT91_CKGR_MOR)); -	seq_printf(s, "MCFR = %8x\n", at91_sys_read(AT91_CKGR_MCFR)); -	seq_printf(s, "PLLA = %8x\n", at91_sys_read(AT91_CKGR_PLLAR)); +	scsr = at91_pmc_read(AT91_PMC_SCSR); +	pcsr = at91_pmc_read(AT91_PMC_PCSR); +	if (cpu_is_sama5d3()) +		pcsr1 = at91_pmc_read(AT91_PMC_PCSR1); +	sr = at91_pmc_read(AT91_PMC_SR); +	seq_printf(s, "SCSR = %8x\n", scsr); +	seq_printf(s, "PCSR = %8x\n", pcsr); +	if (cpu_is_sama5d3()) +		seq_printf(s, "PCSR1 = %8x\n", pcsr1); +	seq_printf(s, "MOR  = %8x\n", at91_pmc_read(AT91_CKGR_MOR)); +	seq_printf(s, "MCFR = %8x\n", at91_pmc_read(AT91_CKGR_MCFR)); +	seq_printf(s, "PLLA = %8x\n", at91_pmc_read(AT91_CKGR_PLLAR));  	if (cpu_has_pllb()) -		seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR)); -	if (cpu_has_utmi()) -		seq_printf(s, "UCKR = %8x\n", uckr = at91_sys_read(AT91_CKGR_UCKR)); -	seq_printf(s, "MCKR = %8x\n", at91_sys_read(AT91_PMC_MCKR)); -	if (cpu_has_upll()) -		seq_printf(s, "USB  = %8x\n", at91_sys_read(AT91_PMC_USB)); -	seq_printf(s, "SR   = %8x\n", sr = at91_sys_read(AT91_PMC_SR)); +		seq_printf(s, "PLLB = %8x\n", at91_pmc_read(AT91_CKGR_PLLBR)); +	if (cpu_has_utmi()) { +		uckr = at91_pmc_read(AT91_CKGR_UCKR); +		seq_printf(s, "UCKR = %8x\n", uckr); +	} +	seq_printf(s, "MCKR = %8x\n", at91_pmc_read(AT91_PMC_MCKR)); +	if (cpu_has_upll() || cpu_is_at91sam9n12()) +		seq_printf(s, "USB  = %8x\n", at91_pmc_read(AT91_PMC_USB)); +	seq_printf(s, "SR   = %8x\n", sr);  	seq_printf(s, "\n");  	list_for_each_entry(clk, &clocks, node) {  		char	*state; -		if (clk->mode == pmc_sys_mode) +		if (clk->mode == pmc_sys_mode) {  			state = (scsr & clk->pmc_mask) ? "on" : "off"; -		else if (clk->mode == pmc_periph_mode) -			state = (pcsr & clk->pmc_mask) ? "on" : "off"; -		else if (clk->mode == pmc_uckr_mode) +		} else if (clk->mode == pmc_periph_mode) { +			if (cpu_is_sama5d3()) { +				u32 pmc_mask = 1 << (clk->pid % 32); + +				if (clk->pid > 31) +					state = (pcsr1 & pmc_mask) ? "on" : "off"; +				else +					state = (pcsr & pmc_mask) ? "on" : "off"; +			} else { +				state = (pcsr & clk->pmc_mask) ? "on" : "off"; +			} +		} else if (clk->mode == pmc_uckr_mode) {  			state = (uckr & clk->pmc_mask) ? "on" : "off"; -		else if (clk->pmc_mask) +		} else if (clk->pmc_mask) {  			state = (sr & clk->pmc_mask) ? "on" : "off"; -		else if (clk == &clk32k || clk == &main_clk) +		} else if (clk == &clk32k || clk == &main_clk) {  			state = "on"; -		else +		} else {  			state = ""; +		} -		seq_printf(s, "%-10s users=%2d %-3s %9ld Hz %s\n", +		seq_printf(s, "%-10s users=%2d %-3s %9lu Hz %s\n",  			clk->name, clk->users, state, clk_get_rate(clk),  			clk->parent ? clk->parent->name : "");  	} @@ -498,32 +550,39 @@ postcore_initcall(at91_clk_debugfs_init);  /*------------------------------------------------------------------------*/  /* Register a new clock */ +static void __init at91_clk_add(struct clk *clk) +{ +	list_add_tail(&clk->node, &clocks); + +	clk->cl.con_id = clk->name; +	clk->cl.clk = clk; +	clkdev_add(&clk->cl); +} +  int __init clk_register(struct clk *clk)  {  	if (clk_is_peripheral(clk)) {  		if (!clk->parent)  			clk->parent = &mck; +		if (cpu_is_sama5d3()) +			clk->rate_hz = DIV_ROUND_UP(clk->parent->rate_hz, +						    1 << clk->div);  		clk->mode = pmc_periph_mode; -		list_add_tail(&clk->node, &clocks);  	}  	else if (clk_is_sys(clk)) {  		clk->parent = &mck;  		clk->mode = pmc_sys_mode; - -		list_add_tail(&clk->node, &clocks);  	} -#ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS  	else if (clk_is_programmable(clk)) {  		clk->mode = pmc_sys_mode;  		init_programmable_clock(clk); -		list_add_tail(&clk->node, &clocks);  	} -#endif + +	at91_clk_add(clk);  	return 0;  } -  /*------------------------------------------------------------------------*/  static u32 __init at91_pll_rate(struct clk *pll, u32 freq, u32 reg) @@ -531,7 +590,11 @@ static u32 __init at91_pll_rate(struct clk *pll, u32 freq, u32 reg)  	unsigned mul, div;  	div = reg & 0xff; -	mul = (reg >> 16) & 0x7ff; +	if (cpu_is_sama5d3()) +		mul = AT91_PMC3_MUL_GET(reg); +	else +		mul = AT91_PMC_MUL_GET(reg); +  	if (div && mul) {  		freq /= div;  		freq *= mul + 1; @@ -545,6 +608,8 @@ static u32 __init at91_usb_rate(struct clk *pll, u32 freq, u32 reg)  {  	if (pll == &pllb && (reg & AT91_PMC_USB96M))  		return freq / 2; +	else if (pll == &utmi_clk || cpu_is_at91sam9n12()) +		return freq / (1 + ((reg & AT91_PMC_OHCIUSBDIV) >> 8));  	else  		return freq;  } @@ -601,7 +666,7 @@ fail:  	return 0;  } -static struct clk *const standard_pmc_clocks[] __initdata = { +static struct clk *const standard_pmc_clocks[] __initconst = {  	/* four primary clocks */  	&clk32k,  	&main_clk, @@ -614,6 +679,8 @@ static struct clk *const standard_pmc_clocks[] __initdata = {  /* PLLB generated USB full speed clock init */  static void __init at91_pllb_usbfs_clock_init(unsigned long main_clock)  { +	unsigned int reg; +  	/*  	 * USB clock init:  choose 48 MHz PLLB value,  	 * disable 48MHz clock during usb peripheral suspend. @@ -622,24 +689,35 @@ static void __init at91_pllb_usbfs_clock_init(unsigned long main_clock)  	 */  	uhpck.parent = &pllb; -	at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2) | AT91_PMC_USB96M; +	reg = at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2);  	pllb.rate_hz = at91_pll_rate(&pllb, main_clock, at91_pllb_usb_init);  	if (cpu_is_at91rm9200()) { +		reg = at91_pllb_usb_init |= AT91_PMC_USB96M;  		uhpck.pmc_mask = AT91RM9200_PMC_UHP;  		udpck.pmc_mask = AT91RM9200_PMC_UDP; -		at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP); +		at91_pmc_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP);  	} else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() ||  		   cpu_is_at91sam9263() || cpu_is_at91sam9g20() || -		   cpu_is_at91sam9g10() || cpu_is_at572d940hf()) { +		   cpu_is_at91sam9g10()) { +		reg = at91_pllb_usb_init |= AT91_PMC_USB96M; +		uhpck.pmc_mask = AT91SAM926x_PMC_UHP; +		udpck.pmc_mask = AT91SAM926x_PMC_UDP; +	} else if (cpu_is_at91sam9n12()) { +		/* Divider for USB clock is in USB clock register for 9n12 */ +		reg = AT91_PMC_USBS_PLLB; + +		/* For PLLB output 96M, set usb divider 2 (USBDIV + 1) */ +		reg |= AT91_PMC_OHCIUSBDIV_2; +		at91_pmc_write(AT91_PMC_USB, reg); + +		/* Still setup masks */  		uhpck.pmc_mask = AT91SAM926x_PMC_UHP;  		udpck.pmc_mask = AT91SAM926x_PMC_UDP; -	} else if (cpu_is_at91cap9()) { -		uhpck.pmc_mask = AT91CAP9_PMC_UHP;  	} -	at91_sys_write(AT91_CKGR_PLLBR, 0); +	at91_pmc_write(AT91_CKGR_PLLBR, 0); -	udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init); -	uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init); +	udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, reg); +	uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, reg);  }  /* UPLL generated USB full speed clock init */ @@ -653,16 +731,15 @@ static void __init at91_upll_usbfs_clock_init(unsigned long main_clock)  	/* Setup divider by 10 to reach 48 MHz */  	usbr |= ((10 - 1) << 8) & AT91_PMC_OHCIUSBDIV; -	at91_sys_write(AT91_PMC_USB, usbr); +	at91_pmc_write(AT91_PMC_USB, usbr);  	/* Now set uhpck values */  	uhpck.parent = &utmi_clk;  	uhpck.pmc_mask = AT91SAM926x_PMC_UHP; -	uhpck.rate_hz = utmi_clk.parent->rate_hz; -	uhpck.rate_hz /= 1 + ((at91_sys_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8); +	uhpck.rate_hz = at91_usb_rate(&utmi_clk, utmi_clk.rate_hz, usbr);  } -int __init at91_clock_init(unsigned long main_clock) +static int __init at91_pmc_init(unsigned long main_clock)  {  	unsigned tmp, freq, mckr;  	int i; @@ -676,20 +753,29 @@ int __init at91_clock_init(unsigned long main_clock)  	 */  	if (!main_clock) {  		do { -			tmp = at91_sys_read(AT91_CKGR_MCFR); +			tmp = at91_pmc_read(AT91_CKGR_MCFR);  		} while (!(tmp & AT91_PMC_MAINRDY));  		main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16);  	}  	main_clk.rate_hz = main_clock;  	/* report if PLLA is more than mildly overclocked */ -	plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_sys_read(AT91_CKGR_PLLAR)); -	if (cpu_has_300M_plla()) { -		if (plla.rate_hz > 300000000) +	plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_pmc_read(AT91_CKGR_PLLAR)); +	if (cpu_has_1056M_plla()) { +		if (plla.rate_hz > 1056000000)  			pll_overclock = true;  	} else if (cpu_has_800M_plla()) {  		if (plla.rate_hz > 800000000)  			pll_overclock = true; +	} else if (cpu_has_300M_plla()) { +		if (plla.rate_hz > 300000000) +			pll_overclock = true; +	} else if (cpu_has_240M_plla()) { +		if (plla.rate_hz > 240000000) +			pll_overclock = true; +	} else if (cpu_has_210M_plla()) { +		if (plla.rate_hz > 210000000) +			pll_overclock = true;  	} else {  		if (plla.rate_hz > 209000000)  			pll_overclock = true; @@ -697,8 +783,8 @@ int __init at91_clock_init(unsigned long main_clock)  	if (pll_overclock)  		pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000); -	if (cpu_is_at91sam9g45()) { -		mckr = at91_sys_read(AT91_PMC_MCKR); +	if (cpu_has_plladiv2()) { +		mckr = at91_pmc_read(AT91_PMC_MCKR);  		plla.rate_hz /= (1 << ((mckr & AT91_PMC_PLLADIV2) >> 12));	/* plla divisor by 2 */  	} @@ -719,6 +805,10 @@ int __init at91_clock_init(unsigned long main_clock)  		 * (obtain the USB High Speed 480 MHz when input is 12 MHz)  		 */  		utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz; + +		/* UTMI bias and PLL are managed at the same time */ +		if (cpu_has_upll()) +			utmi_clk.pmc_mask |= AT91_PMC_BIASEN;  	}  	/* @@ -734,10 +824,10 @@ int __init at91_clock_init(unsigned long main_clock)  	 * MCK and CPU derive from one of those primary clocks.  	 * For now, assume this parentage won't change.  	 */ -	mckr = at91_sys_read(AT91_PMC_MCKR); +	mckr = at91_pmc_read(AT91_PMC_MCKR);  	mck.parent = at91_css_to_clk(mckr & AT91_PMC_CSS);  	freq = mck.parent->rate_hz; -	freq /= (1 << ((mckr & AT91_PMC_PRES) >> 2));				/* prescale */ +	freq /= pmc_prescaler_divider(mckr);					/* prescale */  	if (cpu_is_at91rm9200()) {  		mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8));	/* mdiv */  	} else if (cpu_is_at91sam9g20()) { @@ -745,28 +835,34 @@ int __init at91_clock_init(unsigned long main_clock)  			freq / ((mckr & AT91_PMC_MDIV) >> 7) : freq;	/* mdiv ; (x >> 7) = ((x >> 8) * 2) */  		if (mckr & AT91_PMC_PDIV)  			freq /= 2;		/* processor clock division */ -	} else if (cpu_is_at91sam9g45()) { +	} else if (cpu_has_mdiv3()) {  		mck.rate_hz = (mckr & AT91_PMC_MDIV) == AT91SAM9_PMC_MDIV_3 ?  			freq / 3 : freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8));	/* mdiv */  	} else {  		mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8));		/* mdiv */  	} +	if (cpu_has_alt_prescaler()) { +		/* Programmable clocks can use MCK */ +		mck.type |= CLK_TYPE_PRIMARY; +		mck.id = 4; +	} +  	/* Register the PMC's standard clocks */  	for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++) -		list_add_tail(&standard_pmc_clocks[i]->node, &clocks); +		at91_clk_add(standard_pmc_clocks[i]);  	if (cpu_has_pllb()) -		list_add_tail(&pllb.node, &clocks); +		at91_clk_add(&pllb);  	if (cpu_has_uhp()) -		list_add_tail(&uhpck.node, &clocks); +		at91_clk_add(&uhpck);  	if (cpu_has_udpfs()) -		list_add_tail(&udpck.node, &clocks); +		at91_clk_add(&udpck);  	if (cpu_has_utmi()) -		list_add_tail(&utmi_clk.node, &clocks); +		at91_clk_add(&utmi_clk);  	/* MCK and CPU clock are "always on" */  	clk_enable(&mck); @@ -779,12 +875,67 @@ int __init at91_clock_init(unsigned long main_clock)  	return 0;  } +#if defined(CONFIG_OF) +static struct of_device_id pmc_ids[] = { +	{ .compatible = "atmel,at91rm9200-pmc" }, +	{ .compatible = "atmel,at91sam9260-pmc" }, +	{ .compatible = "atmel,at91sam9g45-pmc" }, +	{ .compatible = "atmel,at91sam9n12-pmc" }, +	{ .compatible = "atmel,at91sam9x5-pmc" }, +	{ .compatible = "atmel,sama5d3-pmc" }, +	{ /*sentinel*/ } +}; + +static struct of_device_id osc_ids[] = { +	{ .compatible = "atmel,osc" }, +	{ /*sentinel*/ } +}; + +int __init at91_dt_clock_init(void) +{ +	struct device_node *np; +	u32 main_clock = 0; + +	np = of_find_matching_node(NULL, pmc_ids); +	if (!np) +		panic("unable to find compatible pmc node in dtb\n"); + +	at91_pmc_base = of_iomap(np, 0); +	if (!at91_pmc_base) +		panic("unable to map pmc cpu registers\n"); + +	of_node_put(np); + +	/* retrieve the freqency of fixed clocks from device tree */ +	np = of_find_matching_node(NULL, osc_ids); +	if (np) { +		u32 rate; +		if (!of_property_read_u32(np, "clock-frequency", &rate)) +			main_clock = rate; +	} + +	of_node_put(np); + +	return at91_pmc_init(main_clock); +} +#endif + +int __init at91_clock_init(unsigned long main_clock) +{ +	at91_pmc_base = ioremap(AT91_PMC, 256); +	if (!at91_pmc_base) +		panic("Impossible to ioremap AT91_PMC 0x%x\n", AT91_PMC); + +	return at91_pmc_init(main_clock); +} +  /*   * Several unused clocks may be active.  Turn them off.   */  static int __init at91_clock_reset(void)  {  	unsigned long pcdr = 0; +	unsigned long pcdr1 = 0;  	unsigned long scdr = 0;  	struct clk *clk; @@ -792,8 +943,17 @@ static int __init at91_clock_reset(void)  		if (clk->users > 0)  			continue; -		if (clk->mode == pmc_periph_mode) -			pcdr |= clk->pmc_mask; +		if (clk->mode == pmc_periph_mode) { +			if (cpu_is_sama5d3()) { +				u32 pmc_mask = 1 << (clk->pid % 32); + +				if (clk->pid > 31) +					pcdr1 |= pmc_mask; +				else +					pcdr |= pmc_mask; +			} else +				pcdr |= clk->pmc_mask; +		}  		if (clk->mode == pmc_sys_mode)  			scdr |= clk->pmc_mask; @@ -801,9 +961,16 @@ static int __init at91_clock_reset(void)  		pr_debug("Clocks: disable unused %s\n", clk->name);  	} -	at91_sys_write(AT91_PMC_PCDR, pcdr); -	at91_sys_write(AT91_PMC_SCDR, scdr); +	at91_pmc_write(AT91_PMC_SCDR, scdr); +	if (cpu_is_sama5d3()) +		at91_pmc_write(AT91_PMC_PCDR1, pcdr1);  	return 0;  }  late_initcall(at91_clock_reset); + +void at91sam9_idle(void) +{ +	at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK); +	cpu_do_idle(); +} diff --git a/arch/arm/mach-at91/clock.h b/arch/arm/mach-at91/clock.h index 6cf4b78e175..a98a39bbd88 100644 --- a/arch/arm/mach-at91/clock.h +++ b/arch/arm/mach-at91/clock.h @@ -6,6 +6,8 @@   * published by the Free Software Foundation.   */ +#include <linux/clkdev.h> +  #define CLK_TYPE_PRIMARY	0x1  #define CLK_TYPE_PLL		0x2  #define CLK_TYPE_PROGRAMMABLE	0x4 @@ -16,10 +18,11 @@  struct clk {  	struct list_head node;  	const char	*name;		/* unique clock name */ -	const char	*function;	/* function of the clock */ -	struct device	*dev;		/* device associated with function */ +	struct clk_lookup cl;  	unsigned long	rate_hz; +	unsigned	div;		/* parent clock divider */  	struct clk	*parent; +	unsigned	pid;		/* peripheral ID */  	u32		pmc_mask;  	void		(*mode)(struct clk *, int);  	unsigned	id:3;		/* PCK0..4, or 32k/main/a/b */ @@ -29,3 +32,18 @@ struct clk {  extern int __init clk_register(struct clk *clk); +extern struct clk mck; +extern struct clk utmi_clk; + +#define CLKDEV_CON_ID(_id, _clk)			\ +	{						\ +		.con_id = _id,				\ +		.clk = _clk,				\ +	} + +#define CLKDEV_CON_DEV_ID(_con_id, _dev_id, _clk)	\ +	{						\ +		.con_id = _con_id,			\ +		.dev_id = _dev_id,			\ +		.clk = _clk,				\ +	} diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c deleted file mode 100644 index 1cfeac1483d..00000000000 --- a/arch/arm/mach-at91/cpuidle.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * based on arch/arm/mach-kirkwood/cpuidle.c - * - * CPU idle support for AT91 SoC - * - * This file is licensed under the terms of the GNU General Public - * License version 2.  This program is licensed "as is" without any - * warranty of any kind, whether express or implied. - * - * The cpu idle uses wait-for-interrupt and RAM self refresh in order - * to implement two idle states - - * #1 wait-for-interrupt - * #2 wait-for-interrupt and RAM self refresh - */ - -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/platform_device.h> -#include <linux/cpuidle.h> -#include <asm/proc-fns.h> -#include <linux/io.h> - -#include "pm.h" - -#define AT91_MAX_STATES	2 - -static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device); - -static struct cpuidle_driver at91_idle_driver = { -	.name =         "at91_idle", -	.owner =        THIS_MODULE, -}; - -/* Actual code that puts the SoC in different idle states */ -static int at91_enter_idle(struct cpuidle_device *dev, -			       struct cpuidle_state *state) -{ -	struct timeval before, after; -	int idle_time; -	u32 saved_lpr; - -	local_irq_disable(); -	do_gettimeofday(&before); -	if (state == &dev->states[0]) -		/* Wait for interrupt state */ -		cpu_do_idle(); -	else if (state == &dev->states[1]) { -		asm("b 1f; .align 5; 1:"); -		asm("mcr p15, 0, r0, c7, c10, 4");	/* drain write buffer */ -		saved_lpr = sdram_selfrefresh_enable(); -		cpu_do_idle(); -		sdram_selfrefresh_disable(saved_lpr); -	} -	do_gettimeofday(&after); -	local_irq_enable(); -	idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + -			(after.tv_usec - before.tv_usec); -	return idle_time; -} - -/* Initialize CPU idle by registering the idle states */ -static int at91_init_cpuidle(void) -{ -	struct cpuidle_device *device; - -	cpuidle_register_driver(&at91_idle_driver); - -	device = &per_cpu(at91_cpuidle_device, smp_processor_id()); -	device->state_count = AT91_MAX_STATES; - -	/* Wait for interrupt state */ -	device->states[0].enter = at91_enter_idle; -	device->states[0].exit_latency = 1; -	device->states[0].target_residency = 10000; -	device->states[0].flags = CPUIDLE_FLAG_TIME_VALID; -	strcpy(device->states[0].name, "WFI"); -	strcpy(device->states[0].desc, "Wait for interrupt"); - -	/* Wait for interrupt and RAM self refresh state */ -	device->states[1].enter = at91_enter_idle; -	device->states[1].exit_latency = 10; -	device->states[1].target_residency = 10000; -	device->states[1].flags = CPUIDLE_FLAG_TIME_VALID; -	strcpy(device->states[1].name, "RAM_SR"); -	strcpy(device->states[1].desc, "WFI and RAM Self Refresh"); - -	if (cpuidle_register_device(device)) { -		printk(KERN_ERR "at91_init_cpuidle: Failed registering\n"); -		return -EIO; -	} -	return 0; -} - -device_initcall(at91_init_cpuidle); diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index 0c66deb2db3..631fa3b8c16 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h @@ -8,46 +8,73 @@   * published by the Free Software Foundation.   */ +#include <linux/clkdev.h> +#include <linux/of.h> +#include <linux/reboot.h> + + /* Map io */ +extern void __init at91_map_io(void); +extern void __init at91_init_sram(int bank, unsigned long base, +				  unsigned int length); +   /* Processors */ -extern void __init at91rm9200_initialize(unsigned long main_clock, unsigned short banks); -extern void __init at91sam9260_initialize(unsigned long main_clock); -extern void __init at91sam9261_initialize(unsigned long main_clock); -extern void __init at91sam9263_initialize(unsigned long main_clock); -extern void __init at91sam9rl_initialize(unsigned long main_clock); -extern void __init at91sam9g45_initialize(unsigned long main_clock); +extern void __init at91rm9200_set_type(int type); +extern void __init at91_initialize(unsigned long main_clock);  extern void __init at91x40_initialize(unsigned long main_clock); -extern void __init at91cap9_initialize(unsigned long main_clock); -extern void __init at572d940hf_initialize(unsigned long main_clock); +extern void __init at91rm9200_dt_initialize(void); +extern void __init at91_dt_initialize(void);   /* Interrupts */ -extern void __init at91rm9200_init_interrupts(unsigned int priority[]); -extern void __init at91sam9260_init_interrupts(unsigned int priority[]); -extern void __init at91sam9261_init_interrupts(unsigned int priority[]); -extern void __init at91sam9263_init_interrupts(unsigned int priority[]); -extern void __init at91sam9rl_init_interrupts(unsigned int priority[]); -extern void __init at91sam9g45_init_interrupts(unsigned int priority[]); +extern void __init at91_init_irq_default(void); +extern void __init at91_init_interrupts(unsigned int priority[]);  extern void __init at91x40_init_interrupts(unsigned int priority[]); -extern void __init at91cap9_init_interrupts(unsigned int priority[]); -extern void __init at572d940hf_init_interrupts(unsigned int priority[]); -extern void __init at91_aic_init(unsigned int priority[]); +extern void __init at91_aic_init(unsigned int priority[], +				 unsigned int ext_irq_mask); +extern int  __init at91_aic_of_init(struct device_node *node, +				    struct device_node *parent); +extern int  __init at91_aic5_of_init(struct device_node *node, +				    struct device_node *parent); +extern void __init at91_sysirq_mask_rtc(u32 rtc_base); +extern void __init at91_sysirq_mask_rtt(u32 rtt_base); +   /* Timer */ -struct sys_timer; -extern struct sys_timer at91rm9200_timer; -extern struct sys_timer at91sam926x_timer; -extern struct sys_timer at91x40_timer; +extern void at91rm9200_ioremap_st(u32 addr); +extern void at91rm9200_timer_init(void); +extern void at91sam926x_ioremap_pit(u32 addr); +extern void at91sam926x_pit_init(void); +extern void at91x40_timer_init(void);   /* Clocks */ +#ifdef CONFIG_OLD_CLK_AT91  extern int __init at91_clock_init(unsigned long main_clock); +extern int __init at91_dt_clock_init(void); +#else +static int inline at91_clock_init(unsigned long main_clock) { return 0; } +static int inline at91_dt_clock_init(void) { return 0; } +#endif  struct device; -extern void __init at91_clock_associate(const char *id, struct device *dev, const char *func);   /* Power Management */  extern void at91_irq_suspend(void);  extern void at91_irq_resume(void); +/* idle */ +extern void at91sam9_idle(void); +  /* reset */ -extern void at91sam9_alt_reset(void); +extern void at91_ioremap_rstc(u32 base_addr); +extern void at91sam9_alt_restart(enum reboot_mode, const char *); +extern void at91sam9g45_restart(enum reboot_mode, const char *); + +/* shutdown */ +extern void at91_ioremap_shdwc(u32 base_addr); + +/* Matrix */ +extern void at91_ioremap_matrix(u32 base_addr); + +/* Ram Controler */ +extern void at91_ioremap_ramc(int id, u32 addr, u32 size);   /* GPIO */  #define AT91RM9200_PQFP		3	/* AT91RM9200 PQFP package has 3 banks */ @@ -55,11 +82,11 @@ extern void at91sam9_alt_reset(void);  struct at91_gpio_bank {  	unsigned short id;		/* peripheral ID */ -	unsigned long offset;		/* offset from system peripheral base */ -	struct clk *clock;		/* associated clock */ +	unsigned long regbase;		/* offset from system peripheral base */  };  extern void __init at91_gpio_init(struct at91_gpio_bank *, int nr_banks);  extern void __init at91_gpio_irq_setup(void); +extern int  __init at91_gpio_of_irq_setup(struct device_node *node, +					  struct device_node *parent); -extern void (*at91_arch_reset)(void); -extern int at91_extern_irq; +extern u32 at91_get_extern_irq(void); diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c index ae4772e744a..d3f05aaad8b 100644 --- a/arch/arm/mach-at91/gpio.c +++ b/arch/arm/mach-at91/gpio.c @@ -11,6 +11,8 @@  #include <linux/clk.h>  #include <linux/errno.h> +#include <linux/device.h> +#include <linux/gpio.h>  #include <linux/interrupt.h>  #include <linux/irq.h>  #include <linux/debugfs.h> @@ -19,60 +21,79 @@  #include <linux/list.h>  #include <linux/module.h>  #include <linux/io.h> +#include <linux/irqdomain.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/of_address.h>  #include <mach/hardware.h>  #include <mach/at91_pio.h> -#include <mach/gpio.h> - -#include <asm/gpio.h>  #include "generic.h" +#include "gpio.h" + +#define MAX_NB_GPIO_PER_BANK	32  struct at91_gpio_chip {  	struct gpio_chip	chip;  	struct at91_gpio_chip	*next;		/* Bank sharing same clock */ -	struct at91_gpio_bank	*bank;		/* Bank definition */ -	void __iomem		*regbase;	/* Base of register bank */ +	int			pioc_hwirq;	/* PIO bank interrupt identifier on AIC */ +	int			pioc_virq;	/* PIO bank Linux virtual interrupt */ +	int			pioc_idx;	/* PIO bank index */ +	void __iomem		*regbase;	/* PIO bank virtual address */ +	struct clk		*clock;		/* associated clock */ +	struct irq_domain	*domain;	/* associated irq domain */  };  #define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) +static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset);  static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip);  static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val);  static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset); +static int at91_gpiolib_get_direction(struct gpio_chip *chip, unsigned offset);  static int at91_gpiolib_direction_output(struct gpio_chip *chip,  					 unsigned offset, int val);  static int at91_gpiolib_direction_input(struct gpio_chip *chip,  					unsigned offset); +static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset); -#define AT91_GPIO_CHIP(name, base_gpio, nr_gpio)			\ +#define AT91_GPIO_CHIP(name)						\  	{								\  		.chip = {						\  			.label		  = name,			\ +			.request	  = at91_gpiolib_request,	\ +			.get_direction    = at91_gpiolib_get_direction, \  			.direction_input  = at91_gpiolib_direction_input, \  			.direction_output = at91_gpiolib_direction_output, \  			.get		  = at91_gpiolib_get,		\  			.set		  = at91_gpiolib_set,		\  			.dbg_show	  = at91_gpiolib_dbg_show,	\ -			.base		  = base_gpio,			\ -			.ngpio		  = nr_gpio,			\ +			.to_irq		  = at91_gpiolib_to_irq,	\ +			.ngpio		  = MAX_NB_GPIO_PER_BANK,	\  		},							\  	}  static struct at91_gpio_chip gpio_chip[] = { -	AT91_GPIO_CHIP("A", 0x00 + PIN_BASE, 32), -	AT91_GPIO_CHIP("B", 0x20 + PIN_BASE, 32), -	AT91_GPIO_CHIP("C", 0x40 + PIN_BASE, 32), -	AT91_GPIO_CHIP("D", 0x60 + PIN_BASE, 32), -	AT91_GPIO_CHIP("E", 0x80 + PIN_BASE, 32), +	AT91_GPIO_CHIP("pioA"), +	AT91_GPIO_CHIP("pioB"), +	AT91_GPIO_CHIP("pioC"), +	AT91_GPIO_CHIP("pioD"), +	AT91_GPIO_CHIP("pioE"),  };  static int gpio_banks; +static unsigned long at91_gpio_caps; + +/* All PIO controllers support PIO3 features */ +#define AT91_GPIO_CAP_PIO3	(1 <<  0) + +#define has_pio3()	(at91_gpio_caps & AT91_GPIO_CAP_PIO3) + +/*--------------------------------------------------------------------------*/  static inline void __iomem *pin_to_controller(unsigned pin)  { -	pin -= PIN_BASE; -	pin /= 32; +	pin /= MAX_NB_GPIO_PER_BANK;  	if (likely(pin < gpio_banks))  		return gpio_chip[pin].regbase; @@ -81,11 +102,29 @@ static inline void __iomem *pin_to_controller(unsigned pin)  static inline unsigned pin_to_mask(unsigned pin)  { -	pin -= PIN_BASE; -	return 1 << (pin % 32); +	return 1 << (pin % MAX_NB_GPIO_PER_BANK);  } +static char peripheral_function(void __iomem *pio, unsigned mask) +{ +	char	ret = 'X'; +	u8	select; + +	if (pio) { +		if (has_pio3()) { +			select = !!(__raw_readl(pio + PIO_ABCDSR1) & mask); +			select |= (!!(__raw_readl(pio + PIO_ABCDSR2) & mask) << 1); +			ret = 'A' + select; +		} else { +			ret = __raw_readl(pio + PIO_ABSR) & mask ? +							'B' : 'A'; +		} +	} + +	return ret; +} +  /*--------------------------------------------------------------------------*/  /* Not all hardware capabilities are exposed through these calls; they @@ -133,7 +172,14 @@ int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup)  	__raw_writel(mask, pio + PIO_IDR);  	__raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); -	__raw_writel(mask, pio + PIO_ASR); +	if (has_pio3()) { +		__raw_writel(__raw_readl(pio + PIO_ABCDSR1) & ~mask, +							pio + PIO_ABCDSR1); +		__raw_writel(__raw_readl(pio + PIO_ABCDSR2) & ~mask, +							pio + PIO_ABCDSR2); +	} else { +		__raw_writel(mask, pio + PIO_ASR); +	}  	__raw_writel(mask, pio + PIO_PDR);  	return 0;  } @@ -153,7 +199,14 @@ int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup)  	__raw_writel(mask, pio + PIO_IDR);  	__raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); -	__raw_writel(mask, pio + PIO_BSR); +	if (has_pio3()) { +		__raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask, +							pio + PIO_ABCDSR1); +		__raw_writel(__raw_readl(pio + PIO_ABCDSR2) & ~mask, +							pio + PIO_ABCDSR2); +	} else { +		__raw_writel(mask, pio + PIO_BSR); +	}  	__raw_writel(mask, pio + PIO_PDR);  	return 0;  } @@ -161,8 +214,50 @@ EXPORT_SYMBOL(at91_set_B_periph);  /* - * mux the pin to the gpio controller (instead of "A" or "B" peripheral), and - * configure it for an input. + * mux the pin to the "C" internal peripheral role. + */ +int __init_or_module at91_set_C_periph(unsigned pin, int use_pullup) +{ +	void __iomem	*pio = pin_to_controller(pin); +	unsigned	mask = pin_to_mask(pin); + +	if (!pio || !has_pio3()) +		return -EINVAL; + +	__raw_writel(mask, pio + PIO_IDR); +	__raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); +	__raw_writel(__raw_readl(pio + PIO_ABCDSR1) & ~mask, pio + PIO_ABCDSR1); +	__raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2); +	__raw_writel(mask, pio + PIO_PDR); +	return 0; +} +EXPORT_SYMBOL(at91_set_C_periph); + + +/* + * mux the pin to the "D" internal peripheral role. + */ +int __init_or_module at91_set_D_periph(unsigned pin, int use_pullup) +{ +	void __iomem	*pio = pin_to_controller(pin); +	unsigned	mask = pin_to_mask(pin); + +	if (!pio || !has_pio3()) +		return -EINVAL; + +	__raw_writel(mask, pio + PIO_IDR); +	__raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); +	__raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask, pio + PIO_ABCDSR1); +	__raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2); +	__raw_writel(mask, pio + PIO_PDR); +	return 0; +} +EXPORT_SYMBOL(at91_set_D_periph); + + +/* + * mux the pin to the gpio controller (instead of "A", "B", "C" + * or "D" peripheral), and configure it for an input.   */  int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup)  { @@ -182,8 +277,8 @@ EXPORT_SYMBOL(at91_set_gpio_input);  /* - * mux the pin to the gpio controller (instead of "A" or "B" peripheral), - * and configure it for an output. + * mux the pin to the gpio controller (instead of "A", "B", "C" + * or "D" peripheral), and configure it for an output.   */  int __init_or_module at91_set_gpio_output(unsigned pin, int value)  { @@ -213,12 +308,37 @@ int __init_or_module at91_set_deglitch(unsigned pin, int is_on)  	if (!pio)  		return -EINVAL; + +	if (has_pio3() && is_on) +		__raw_writel(mask, pio + PIO_IFSCDR);  	__raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR));  	return 0;  }  EXPORT_SYMBOL(at91_set_deglitch);  /* + * enable/disable the debounce filter; + */ +int __init_or_module at91_set_debounce(unsigned pin, int is_on, int div) +{ +	void __iomem	*pio = pin_to_controller(pin); +	unsigned	mask = pin_to_mask(pin); + +	if (!pio || !has_pio3()) +		return -EINVAL; + +	if (is_on) { +		__raw_writel(mask, pio + PIO_IFSCER); +		__raw_writel(div & PIO_SCDR_DIV, pio + PIO_SCDR); +		__raw_writel(mask, pio + PIO_IFER); +	} else { +		__raw_writel(mask, pio + PIO_IFDR); +	} +	return 0; +} +EXPORT_SYMBOL(at91_set_debounce); + +/*   * enable/disable the multi-driver; This is only valid for output and   * allows the output pin to run as an open collector output.   */ @@ -236,6 +356,41 @@ int __init_or_module at91_set_multi_drive(unsigned pin, int is_on)  EXPORT_SYMBOL(at91_set_multi_drive);  /* + * enable/disable the pull-down. + * If pull-up already enabled while calling the function, we disable it. + */ +int __init_or_module at91_set_pulldown(unsigned pin, int is_on) +{ +	void __iomem	*pio = pin_to_controller(pin); +	unsigned	mask = pin_to_mask(pin); + +	if (!pio || !has_pio3()) +		return -EINVAL; + +	/* Disable pull-up anyway */ +	__raw_writel(mask, pio + PIO_PUDR); +	__raw_writel(mask, pio + (is_on ? PIO_PPDER : PIO_PPDDR)); +	return 0; +} +EXPORT_SYMBOL(at91_set_pulldown); + +/* + * disable Schmitt trigger + */ +int __init_or_module at91_disable_schmitt_trig(unsigned pin) +{ +	void __iomem	*pio = pin_to_controller(pin); +	unsigned	mask = pin_to_mask(pin); + +	if (!pio || !has_pio3()) +		return -EINVAL; + +	__raw_writel(__raw_readl(pio + PIO_SCHMITT) | mask, pio + PIO_SCHMITT); +	return 0; +} +EXPORT_SYMBOL(at91_disable_schmitt_trig); + +/*   * assuming the pin is muxed as a gpio output, set its value.   */  int at91_set_gpio_value(unsigned pin, int value) @@ -274,10 +429,11 @@ EXPORT_SYMBOL(at91_get_gpio_value);  static u32 wakeups[MAX_GPIO_BANKS];  static u32 backups[MAX_GPIO_BANKS]; -static int gpio_irq_set_wake(unsigned pin, unsigned state) +static int gpio_irq_set_wake(struct irq_data *d, unsigned state)  { -	unsigned	mask = pin_to_mask(pin); -	unsigned	bank = (pin - PIN_BASE) / 32; +	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); +	unsigned	mask = 1 << d->hwirq; +	unsigned	bank = at91_gpio->pioc_idx;  	if (unlikely(bank >= MAX_GPIO_BANKS))  		return -EINVAL; @@ -287,7 +443,7 @@ static int gpio_irq_set_wake(unsigned pin, unsigned state)  	else  		wakeups[bank] &= ~mask; -	set_irq_wake(gpio_chip[bank].bank->id, state); +	irq_set_irq_wake(at91_gpio->pioc_virq, state);  	return 0;  } @@ -303,9 +459,10 @@ void at91_gpio_suspend(void)  		__raw_writel(backups[i], pio + PIO_IDR);  		__raw_writel(wakeups[i], pio + PIO_IER); -		if (!wakeups[i]) -			clk_disable(gpio_chip[i].bank->clock); -		else { +		if (!wakeups[i]) { +			clk_unprepare(gpio_chip[i].clock); +			clk_disable(gpio_chip[i].clock); +		} else {  #ifdef CONFIG_PM_DEBUG  			printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", 'A'+i, wakeups[i]);  #endif @@ -320,8 +477,10 @@ void at91_gpio_resume(void)  	for (i = 0; i < gpio_banks; i++) {  		void __iomem	*pio = gpio_chip[i].regbase; -		if (!wakeups[i]) -			clk_enable(gpio_chip[i].bank->clock); +		if (!wakeups[i]) { +			if (clk_prepare(gpio_chip[i].clock) == 0) +				clk_enable(gpio_chip[i].clock); +		}  		__raw_writel(wakeups[i], pio + PIO_IDR);  		__raw_writel(backups[i], pio + PIO_IER); @@ -337,32 +496,37 @@ void at91_gpio_resume(void)   * To use any AT91_PIN_* as an externally triggered IRQ, first call   * at91_set_gpio_input() then maybe enable its glitch filter.   * Then just request_irq() with the pin ID; it works like any ARM IRQ - * handler, though it always triggers on rising and falling edges. + * handler. + * First implementation always triggers on rising and falling edges + * whereas the newer PIO3 can be additionally configured to trigger on + * level, edge with any polarity.   *   * Alternatively, certain pins may be used directly as IRQ0..IRQ6 after   * configuring them with at91_set_a_periph() or at91_set_b_periph().   * IRQ0..IRQ6 should be configurable, e.g. level vs edge triggering.   */ -static void gpio_irq_mask(unsigned pin) +static void gpio_irq_mask(struct irq_data *d)  { -	void __iomem	*pio = pin_to_controller(pin); -	unsigned	mask = pin_to_mask(pin); +	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); +	void __iomem	*pio = at91_gpio->regbase; +	unsigned	mask = 1 << d->hwirq;  	if (pio)  		__raw_writel(mask, pio + PIO_IDR);  } -static void gpio_irq_unmask(unsigned pin) +static void gpio_irq_unmask(struct irq_data *d)  { -	void __iomem	*pio = pin_to_controller(pin); -	unsigned	mask = pin_to_mask(pin); +	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); +	void __iomem	*pio = at91_gpio->regbase; +	unsigned	mask = 1 << d->hwirq;  	if (pio)  		__raw_writel(mask, pio + PIO_IER);  } -static int gpio_irq_type(unsigned pin, unsigned type) +static int gpio_irq_type(struct irq_data *d, unsigned type)  {  	switch (type) {  	case IRQ_TYPE_NONE: @@ -373,27 +537,68 @@ static int gpio_irq_type(unsigned pin, unsigned type)  	}  } +/* Alternate irq type for PIO3 support */ +static int alt_gpio_irq_type(struct irq_data *d, unsigned type) +{ +	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); +	void __iomem	*pio = at91_gpio->regbase; +	unsigned	mask = 1 << d->hwirq; + +	switch (type) { +	case IRQ_TYPE_EDGE_RISING: +		__raw_writel(mask, pio + PIO_ESR); +		__raw_writel(mask, pio + PIO_REHLSR); +		break; +	case IRQ_TYPE_EDGE_FALLING: +		__raw_writel(mask, pio + PIO_ESR); +		__raw_writel(mask, pio + PIO_FELLSR); +		break; +	case IRQ_TYPE_LEVEL_LOW: +		__raw_writel(mask, pio + PIO_LSR); +		__raw_writel(mask, pio + PIO_FELLSR); +		break; +	case IRQ_TYPE_LEVEL_HIGH: +		__raw_writel(mask, pio + PIO_LSR); +		__raw_writel(mask, pio + PIO_REHLSR); +		break; +	case IRQ_TYPE_EDGE_BOTH: +		/* +		 * disable additional interrupt modes: +		 * fall back to default behavior +		 */ +		__raw_writel(mask, pio + PIO_AIMDR); +		return 0; +	case IRQ_TYPE_NONE: +	default: +		pr_warn("AT91: No type for irq %d\n", gpio_to_irq(d->irq)); +		return -EINVAL; +	} + +	/* enable additional interrupt modes */ +	__raw_writel(mask, pio + PIO_AIMER); + +	return 0; +} +  static struct irq_chip gpio_irqchip = {  	.name		= "GPIO", -	.mask		= gpio_irq_mask, -	.unmask		= gpio_irq_unmask, -	.set_type	= gpio_irq_type, -	.set_wake	= gpio_irq_set_wake, +	.irq_disable	= gpio_irq_mask, +	.irq_mask	= gpio_irq_mask, +	.irq_unmask	= gpio_irq_unmask, +	/* .irq_set_type is set dynamically */ +	.irq_set_wake	= gpio_irq_set_wake,  };  static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)  { -	unsigned	pin; -	struct irq_desc	*gpio; -	struct at91_gpio_chip *at91_gpio; -	void __iomem	*pio; -	u32		isr; - -	at91_gpio = get_irq_chip_data(irq); -	pio = at91_gpio->regbase; - -	/* temporarily mask (level sensitive) parent IRQ */ -	desc->chip->ack(irq); +	struct irq_chip *chip = irq_desc_get_chip(desc); +	struct irq_data *idata = irq_desc_get_irq_data(desc); +	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata); +	void __iomem	*pio = at91_gpio->regbase; +	unsigned long	isr; +	int		n; + +	chained_irq_enter(chip, desc);  	for (;;) {  		/* Reading ISR acks pending (edge triggered) GPIO interrupts.  		 * When there none are pending, we're finished unless we need @@ -408,28 +613,13 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)  			continue;  		} -		pin = at91_gpio->chip.base; -		gpio = &irq_desc[pin]; - -		while (isr) { -			if (isr & 1) { -				if (unlikely(gpio->depth)) { -					/* -					 * The core ARM interrupt handler lazily disables IRQs so -					 * another IRQ must be generated before it actually gets -					 * here to be disabled on the GPIO controller. -					 */ -					gpio_irq_mask(pin); -				} -				else -					generic_handle_irq(pin); -			} -			pin++; -			gpio++; -			isr >>= 1; +		n = find_first_bit(&isr, BITS_PER_LONG); +		while (n < BITS_PER_LONG) { +			generic_handle_irq(irq_find_mapping(at91_gpio->domain, n)); +			n = find_next_bit(&isr, BITS_PER_LONG, n + 1);  		}  	} -	desc->chip->unmask(irq); +	chained_irq_exit(chip, desc);  	/* now it may re-trigger */  } @@ -437,6 +627,33 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)  #ifdef CONFIG_DEBUG_FS +static void gpio_printf(struct seq_file *s, void __iomem *pio, unsigned mask) +{ +	char	*trigger = NULL; +	char	*polarity = NULL; + +	if (__raw_readl(pio + PIO_IMR) & mask) { +		if (!has_pio3() || !(__raw_readl(pio + PIO_AIMMR) & mask )) { +			trigger = "edge"; +			polarity = "both"; +		} else { +			if (__raw_readl(pio + PIO_ELSR) & mask) { +				trigger = "level"; +				polarity = __raw_readl(pio + PIO_FRLHSR) & mask ? +					"high" : "low"; +			} else { +				trigger = "edge"; +				polarity = __raw_readl(pio + PIO_FRLHSR) & mask ? +						"rising" : "falling"; +			} +		} +		seq_printf(s, "IRQ:%s-%s\t", trigger, polarity); +	} else { +		seq_printf(s, "GPIO:%s\t\t", +				__raw_readl(pio + PIO_PDSR) & mask ? "1" : "0"); +	} +} +  static int at91_gpio_show(struct seq_file *s, void *unused)  {  	int bank, j; @@ -444,7 +661,7 @@ static int at91_gpio_show(struct seq_file *s, void *unused)  	/* print heading */  	seq_printf(s, "Pin\t");  	for (bank = 0; bank < gpio_banks; bank++) { -		seq_printf(s, "PIO%c\t", 'A' + bank); +		seq_printf(s, "PIO%c\t\t", 'A' + bank);  	};  	seq_printf(s, "\n\n"); @@ -453,16 +670,15 @@ static int at91_gpio_show(struct seq_file *s, void *unused)  		seq_printf(s, "%i:\t", j);  		for (bank = 0; bank < gpio_banks; bank++) { -			unsigned	pin  = PIN_BASE + (32 * bank) + j; +			unsigned	pin  = (32 * bank) + j;  			void __iomem	*pio = pin_to_controller(pin);  			unsigned	mask = pin_to_mask(pin);  			if (__raw_readl(pio + PIO_PSR) & mask) -				seq_printf(s, "GPIO:%s", __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0"); +				gpio_printf(s, pio, mask);  			else -				seq_printf(s, "%s", __raw_readl(pio + PIO_ABSR) & mask ? "B" : "A"); - -			seq_printf(s, "\t"); +				seq_printf(s, "%c\t\t", +						peripheral_function(pio, mask));  		}  		seq_printf(s, "\n"); @@ -502,47 +718,101 @@ postcore_initcall(at91_gpio_debugfs_init);  static struct lock_class_key gpio_lock_class;  /* + * irqdomain initialization: pile up irqdomains on top of AIC range + */ +static void __init at91_gpio_irqdomain(struct at91_gpio_chip *at91_gpio) +{ +	int irq_base; + +	irq_base = irq_alloc_descs(-1, 0, at91_gpio->chip.ngpio, 0); +	if (irq_base < 0) +		panic("at91_gpio.%d: error %d: couldn't allocate IRQ numbers.\n", +			at91_gpio->pioc_idx, irq_base); +	at91_gpio->domain = irq_domain_add_legacy(NULL, at91_gpio->chip.ngpio, +						  irq_base, 0, +						  &irq_domain_simple_ops, NULL); +	if (!at91_gpio->domain) +		panic("at91_gpio.%d: couldn't allocate irq domain.\n", +			at91_gpio->pioc_idx); +} + +/*   * Called from the processor-specific init to enable GPIO interrupt support.   */  void __init at91_gpio_irq_setup(void)  { -	unsigned		pioc, pin; +	unsigned		pioc; +	int			gpio_irqnbr = 0;  	struct at91_gpio_chip	*this, *prev; -	for (pioc = 0, pin = PIN_BASE, this = gpio_chip, prev = NULL; +	/* Setup proper .irq_set_type function */ +	if (has_pio3()) +		gpio_irqchip.irq_set_type = alt_gpio_irq_type; +	else +		gpio_irqchip.irq_set_type = gpio_irq_type; + +	for (pioc = 0, this = gpio_chip, prev = NULL;  			pioc++ < gpio_banks;  			prev = this, this++) { -		unsigned	id = this->bank->id; -		unsigned	i; +		int offset;  		__raw_writel(~0, this->regbase + PIO_IDR); -		for (i = 0, pin = this->chip.base; i < 32; i++, pin++) { -			lockdep_set_class(&irq_desc[pin].lock, &gpio_lock_class); +		/* setup irq domain for this GPIO controller */ +		at91_gpio_irqdomain(this); + +		for (offset = 0; offset < this->chip.ngpio; offset++) { +			unsigned int virq = irq_find_mapping(this->domain, offset); +			irq_set_lockdep_class(virq, &gpio_lock_class);  			/*  			 * Can use the "simple" and not "edge" handler since it's  			 * shorter, and the AIC handles interrupts sanely.  			 */ -			set_irq_chip(pin, &gpio_irqchip); -			set_irq_handler(pin, handle_simple_irq); -			set_irq_flags(pin, IRQF_VALID); +			irq_set_chip_and_handler(virq, &gpio_irqchip, +						 handle_simple_irq); +			set_irq_flags(virq, IRQF_VALID); +			irq_set_chip_data(virq, this); + +			gpio_irqnbr++;  		}  		/* The toplevel handler handles one bank of GPIOs, except -		 * AT91SAM9263_ID_PIOCDE handles three... PIOC is first in -		 * the list, so we only set up that handler. +		 * on some SoC it can handles up to three... +		 * We only set up the handler for the first of the list.  		 */  		if (prev && prev->next == this)  			continue; -		set_irq_chip_data(id, this); -		set_irq_chained_handler(id, gpio_irq_handler); +		this->pioc_virq = irq_create_mapping(NULL, this->pioc_hwirq); +		irq_set_chip_data(this->pioc_virq, this); +		irq_set_chained_handler(this->pioc_virq, gpio_irq_handler);  	} -	pr_info("AT91: %d gpio irqs in %d banks\n", pin - PIN_BASE, gpio_banks); +	pr_info("AT91: %d gpio irqs in %d banks\n", gpio_irqnbr, gpio_banks);  }  /* gpiolib support */ +static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset) +{ +	struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); +	void __iomem *pio = at91_gpio->regbase; +	unsigned mask = 1 << offset; + +	__raw_writel(mask, pio + PIO_PER); +	return 0; +} + +static int at91_gpiolib_get_direction(struct gpio_chip *chip, unsigned offset) +{ +	struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); +	void __iomem *pio = at91_gpio->regbase; +	unsigned mask = 1 << offset; +	u32 osr; + +	osr = __raw_readl(pio + PIO_OSR); +	return !(osr & mask); +} +  static int at91_gpiolib_direction_input(struct gpio_chip *chip,  					unsigned offset)  { @@ -605,38 +875,105 @@ static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)  					   at91_get_gpio_value(pin) ?  					   "set" : "clear");  			else -				seq_printf(s, "[periph %s]\n", -					   __raw_readl(pio + PIO_ABSR) & -					   mask ? "B" : "A"); +				seq_printf(s, "[periph %c]\n", +					   peripheral_function(pio, mask));  		}  	}  } +static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset) +{ +	struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); +	int virq; + +	if (offset < chip->ngpio) +		virq = irq_create_mapping(at91_gpio->domain, offset); +	else +		virq = -ENXIO; + +	dev_dbg(chip->dev, "%s: request IRQ for GPIO %d, return %d\n", +				chip->label, offset + chip->base, virq); +	return virq; +} + +static int __init at91_gpio_setup_clk(int idx) +{ +	struct at91_gpio_chip *at91_gpio = &gpio_chip[idx]; + +	/* retreive PIO controller's clock */ +	at91_gpio->clock = clk_get_sys(NULL, at91_gpio->chip.label); +	if (IS_ERR(at91_gpio->clock)) { +		pr_err("at91_gpio.%d, failed to get clock, ignoring.\n", idx); +		goto err; +	} + +	if (clk_prepare(at91_gpio->clock)) +		goto clk_prep_err; + +	/* enable PIO controller's clock */ +	if (clk_enable(at91_gpio->clock)) { +		pr_err("at91_gpio.%d, failed to enable clock, ignoring.\n", idx); +		goto clk_err; +	} + +	return 0; + +clk_err: +	clk_unprepare(at91_gpio->clock); +clk_prep_err: +	clk_put(at91_gpio->clock); +err: +	return -EINVAL; +} + +static void __init at91_gpio_init_one(int idx, u32 regbase, int pioc_hwirq) +{ +	struct at91_gpio_chip *at91_gpio = &gpio_chip[idx]; + +	at91_gpio->chip.base = idx * MAX_NB_GPIO_PER_BANK; +	at91_gpio->pioc_hwirq = pioc_hwirq; +	at91_gpio->pioc_idx = idx; + +	at91_gpio->regbase = ioremap(regbase, 512); +	if (!at91_gpio->regbase) { +		pr_err("at91_gpio.%d, failed to map registers, ignoring.\n", idx); +		return; +	} + +	if (at91_gpio_setup_clk(idx)) +		goto ioremap_err; + +	gpio_banks = max(gpio_banks, idx + 1); +	return; + +ioremap_err: +	iounmap(at91_gpio->regbase); +} +  /*   * Called from the processor-specific init to enable GPIO pin support.   */  void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks)  { -	unsigned		i; +	unsigned i;  	struct at91_gpio_chip *at91_gpio, *last = NULL;  	BUG_ON(nr_banks > MAX_GPIO_BANKS); -	gpio_banks = nr_banks; +	if (of_have_populated_dt()) +		return; -	for (i = 0; i < nr_banks; i++) { -		at91_gpio = &gpio_chip[i]; - -		at91_gpio->bank = &data[i]; -		at91_gpio->chip.base = PIN_BASE + i * 32; -		at91_gpio->regbase = at91_gpio->bank->offset + -			(void __iomem *)AT91_VA_BASE_SYS; +	for (i = 0; i < nr_banks; i++) +		at91_gpio_init_one(i, data[i].regbase, data[i].id); -		/* enable PIO controller's clock */ -		clk_enable(at91_gpio->bank->clock); +	for (i = 0; i < gpio_banks; i++) { +		at91_gpio = &gpio_chip[i]; -		/* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */ -		if (last && last->bank->id == at91_gpio->bank->id) +		/* +		 * GPIO controller are grouped on some SoC: +		 * PIOC, PIOD and PIOE can share the same IRQ line +		 */ +		if (last && last->pioc_hwirq == at91_gpio->pioc_hwirq)  			last->next = at91_gpio;  		last = at91_gpio; diff --git a/arch/arm/mach-at91/gpio.h b/arch/arm/mach-at91/gpio.h new file mode 100644 index 00000000000..eed465ab0dd --- /dev/null +++ b/arch/arm/mach-at91/gpio.h @@ -0,0 +1,214 @@ +/* + * arch/arm/mach-at91/include/mach/gpio.h + * + *  Copyright (C) 2005 HP Labs + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#ifndef __ASM_ARCH_AT91RM9200_GPIO_H +#define __ASM_ARCH_AT91RM9200_GPIO_H + +#include <linux/kernel.h> +#include <asm/irq.h> + +#define MAX_GPIO_BANKS		5 +#define NR_BUILTIN_GPIO		(MAX_GPIO_BANKS * 32) + +/* these pin numbers double as IRQ numbers, like AT91xxx_ID_* values */ + +#define	AT91_PIN_PA0	(0x00 + 0) +#define	AT91_PIN_PA1	(0x00 + 1) +#define	AT91_PIN_PA2	(0x00 + 2) +#define	AT91_PIN_PA3	(0x00 + 3) +#define	AT91_PIN_PA4	(0x00 + 4) +#define	AT91_PIN_PA5	(0x00 + 5) +#define	AT91_PIN_PA6	(0x00 + 6) +#define	AT91_PIN_PA7	(0x00 + 7) +#define	AT91_PIN_PA8	(0x00 + 8) +#define	AT91_PIN_PA9	(0x00 + 9) +#define	AT91_PIN_PA10	(0x00 + 10) +#define	AT91_PIN_PA11	(0x00 + 11) +#define	AT91_PIN_PA12	(0x00 + 12) +#define	AT91_PIN_PA13	(0x00 + 13) +#define	AT91_PIN_PA14	(0x00 + 14) +#define	AT91_PIN_PA15	(0x00 + 15) +#define	AT91_PIN_PA16	(0x00 + 16) +#define	AT91_PIN_PA17	(0x00 + 17) +#define	AT91_PIN_PA18	(0x00 + 18) +#define	AT91_PIN_PA19	(0x00 + 19) +#define	AT91_PIN_PA20	(0x00 + 20) +#define	AT91_PIN_PA21	(0x00 + 21) +#define	AT91_PIN_PA22	(0x00 + 22) +#define	AT91_PIN_PA23	(0x00 + 23) +#define	AT91_PIN_PA24	(0x00 + 24) +#define	AT91_PIN_PA25	(0x00 + 25) +#define	AT91_PIN_PA26	(0x00 + 26) +#define	AT91_PIN_PA27	(0x00 + 27) +#define	AT91_PIN_PA28	(0x00 + 28) +#define	AT91_PIN_PA29	(0x00 + 29) +#define	AT91_PIN_PA30	(0x00 + 30) +#define	AT91_PIN_PA31	(0x00 + 31) + +#define	AT91_PIN_PB0	(0x20 + 0) +#define	AT91_PIN_PB1	(0x20 + 1) +#define	AT91_PIN_PB2	(0x20 + 2) +#define	AT91_PIN_PB3	(0x20 + 3) +#define	AT91_PIN_PB4	(0x20 + 4) +#define	AT91_PIN_PB5	(0x20 + 5) +#define	AT91_PIN_PB6	(0x20 + 6) +#define	AT91_PIN_PB7	(0x20 + 7) +#define	AT91_PIN_PB8	(0x20 + 8) +#define	AT91_PIN_PB9	(0x20 + 9) +#define	AT91_PIN_PB10	(0x20 + 10) +#define	AT91_PIN_PB11	(0x20 + 11) +#define	AT91_PIN_PB12	(0x20 + 12) +#define	AT91_PIN_PB13	(0x20 + 13) +#define	AT91_PIN_PB14	(0x20 + 14) +#define	AT91_PIN_PB15	(0x20 + 15) +#define	AT91_PIN_PB16	(0x20 + 16) +#define	AT91_PIN_PB17	(0x20 + 17) +#define	AT91_PIN_PB18	(0x20 + 18) +#define	AT91_PIN_PB19	(0x20 + 19) +#define	AT91_PIN_PB20	(0x20 + 20) +#define	AT91_PIN_PB21	(0x20 + 21) +#define	AT91_PIN_PB22	(0x20 + 22) +#define	AT91_PIN_PB23	(0x20 + 23) +#define	AT91_PIN_PB24	(0x20 + 24) +#define	AT91_PIN_PB25	(0x20 + 25) +#define	AT91_PIN_PB26	(0x20 + 26) +#define	AT91_PIN_PB27	(0x20 + 27) +#define	AT91_PIN_PB28	(0x20 + 28) +#define	AT91_PIN_PB29	(0x20 + 29) +#define	AT91_PIN_PB30	(0x20 + 30) +#define	AT91_PIN_PB31	(0x20 + 31) + +#define	AT91_PIN_PC0	(0x40 + 0) +#define	AT91_PIN_PC1	(0x40 + 1) +#define	AT91_PIN_PC2	(0x40 + 2) +#define	AT91_PIN_PC3	(0x40 + 3) +#define	AT91_PIN_PC4	(0x40 + 4) +#define	AT91_PIN_PC5	(0x40 + 5) +#define	AT91_PIN_PC6	(0x40 + 6) +#define	AT91_PIN_PC7	(0x40 + 7) +#define	AT91_PIN_PC8	(0x40 + 8) +#define	AT91_PIN_PC9	(0x40 + 9) +#define	AT91_PIN_PC10	(0x40 + 10) +#define	AT91_PIN_PC11	(0x40 + 11) +#define	AT91_PIN_PC12	(0x40 + 12) +#define	AT91_PIN_PC13	(0x40 + 13) +#define	AT91_PIN_PC14	(0x40 + 14) +#define	AT91_PIN_PC15	(0x40 + 15) +#define	AT91_PIN_PC16	(0x40 + 16) +#define	AT91_PIN_PC17	(0x40 + 17) +#define	AT91_PIN_PC18	(0x40 + 18) +#define	AT91_PIN_PC19	(0x40 + 19) +#define	AT91_PIN_PC20	(0x40 + 20) +#define	AT91_PIN_PC21	(0x40 + 21) +#define	AT91_PIN_PC22	(0x40 + 22) +#define	AT91_PIN_PC23	(0x40 + 23) +#define	AT91_PIN_PC24	(0x40 + 24) +#define	AT91_PIN_PC25	(0x40 + 25) +#define	AT91_PIN_PC26	(0x40 + 26) +#define	AT91_PIN_PC27	(0x40 + 27) +#define	AT91_PIN_PC28	(0x40 + 28) +#define	AT91_PIN_PC29	(0x40 + 29) +#define	AT91_PIN_PC30	(0x40 + 30) +#define	AT91_PIN_PC31	(0x40 + 31) + +#define	AT91_PIN_PD0	(0x60 + 0) +#define	AT91_PIN_PD1	(0x60 + 1) +#define	AT91_PIN_PD2	(0x60 + 2) +#define	AT91_PIN_PD3	(0x60 + 3) +#define	AT91_PIN_PD4	(0x60 + 4) +#define	AT91_PIN_PD5	(0x60 + 5) +#define	AT91_PIN_PD6	(0x60 + 6) +#define	AT91_PIN_PD7	(0x60 + 7) +#define	AT91_PIN_PD8	(0x60 + 8) +#define	AT91_PIN_PD9	(0x60 + 9) +#define	AT91_PIN_PD10	(0x60 + 10) +#define	AT91_PIN_PD11	(0x60 + 11) +#define	AT91_PIN_PD12	(0x60 + 12) +#define	AT91_PIN_PD13	(0x60 + 13) +#define	AT91_PIN_PD14	(0x60 + 14) +#define	AT91_PIN_PD15	(0x60 + 15) +#define	AT91_PIN_PD16	(0x60 + 16) +#define	AT91_PIN_PD17	(0x60 + 17) +#define	AT91_PIN_PD18	(0x60 + 18) +#define	AT91_PIN_PD19	(0x60 + 19) +#define	AT91_PIN_PD20	(0x60 + 20) +#define	AT91_PIN_PD21	(0x60 + 21) +#define	AT91_PIN_PD22	(0x60 + 22) +#define	AT91_PIN_PD23	(0x60 + 23) +#define	AT91_PIN_PD24	(0x60 + 24) +#define	AT91_PIN_PD25	(0x60 + 25) +#define	AT91_PIN_PD26	(0x60 + 26) +#define	AT91_PIN_PD27	(0x60 + 27) +#define	AT91_PIN_PD28	(0x60 + 28) +#define	AT91_PIN_PD29	(0x60 + 29) +#define	AT91_PIN_PD30	(0x60 + 30) +#define	AT91_PIN_PD31	(0x60 + 31) + +#define	AT91_PIN_PE0	(0x80 + 0) +#define	AT91_PIN_PE1	(0x80 + 1) +#define	AT91_PIN_PE2	(0x80 + 2) +#define	AT91_PIN_PE3	(0x80 + 3) +#define	AT91_PIN_PE4	(0x80 + 4) +#define	AT91_PIN_PE5	(0x80 + 5) +#define	AT91_PIN_PE6	(0x80 + 6) +#define	AT91_PIN_PE7	(0x80 + 7) +#define	AT91_PIN_PE8	(0x80 + 8) +#define	AT91_PIN_PE9	(0x80 + 9) +#define	AT91_PIN_PE10	(0x80 + 10) +#define	AT91_PIN_PE11	(0x80 + 11) +#define	AT91_PIN_PE12	(0x80 + 12) +#define	AT91_PIN_PE13	(0x80 + 13) +#define	AT91_PIN_PE14	(0x80 + 14) +#define	AT91_PIN_PE15	(0x80 + 15) +#define	AT91_PIN_PE16	(0x80 + 16) +#define	AT91_PIN_PE17	(0x80 + 17) +#define	AT91_PIN_PE18	(0x80 + 18) +#define	AT91_PIN_PE19	(0x80 + 19) +#define	AT91_PIN_PE20	(0x80 + 20) +#define	AT91_PIN_PE21	(0x80 + 21) +#define	AT91_PIN_PE22	(0x80 + 22) +#define	AT91_PIN_PE23	(0x80 + 23) +#define	AT91_PIN_PE24	(0x80 + 24) +#define	AT91_PIN_PE25	(0x80 + 25) +#define	AT91_PIN_PE26	(0x80 + 26) +#define	AT91_PIN_PE27	(0x80 + 27) +#define	AT91_PIN_PE28	(0x80 + 28) +#define	AT91_PIN_PE29	(0x80 + 29) +#define	AT91_PIN_PE30	(0x80 + 30) +#define	AT91_PIN_PE31	(0x80 + 31) + +#ifndef __ASSEMBLY__ +/* setup setup routines, called from board init or driver probe() */ +extern int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup); +extern int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup); +extern int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup); +extern int __init_or_module at91_set_C_periph(unsigned pin, int use_pullup); +extern int __init_or_module at91_set_D_periph(unsigned pin, int use_pullup); +extern int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup); +extern int __init_or_module at91_set_gpio_output(unsigned pin, int value); +extern int __init_or_module at91_set_deglitch(unsigned pin, int is_on); +extern int __init_or_module at91_set_debounce(unsigned pin, int is_on, int div); +extern int __init_or_module at91_set_multi_drive(unsigned pin, int is_on); +extern int __init_or_module at91_set_pulldown(unsigned pin, int is_on); +extern int __init_or_module at91_disable_schmitt_trig(unsigned pin); + +/* callable at any time */ +extern int at91_set_gpio_value(unsigned pin, int value); +extern int at91_get_gpio_value(unsigned pin); + +/* callable only from core power-management code */ +extern void at91_gpio_suspend(void); +extern void at91_gpio_resume(void); + +#endif	/* __ASSEMBLY__ */ + +#endif diff --git a/arch/arm/mach-at91/gsia18s.h b/arch/arm/mach-at91/gsia18s.h new file mode 100644 index 00000000000..307c194926f --- /dev/null +++ b/arch/arm/mach-at91/gsia18s.h @@ -0,0 +1,33 @@ +/* Buttons */ +#define GPIO_TRIG_NET_IN		AT91_PIN_PB21 +#define GPIO_CARD_UNMOUNT_0		AT91_PIN_PB13 +#define GPIO_CARD_UNMOUNT_1		AT91_PIN_PB12 +#define GPIO_KEY_POWER			AT91_PIN_PA25 + +/* PCF8574 0x20 GPIO - U1 on the GS_IA18-CB_V3 board */ +#define GS_IA18_S_PCF_GPIO_BASE0	NR_BUILTIN_GPIO +#define PCF_GPIO_HDC_POWER		(GS_IA18_S_PCF_GPIO_BASE0 + 0) +#define PCF_GPIO_WIFI_SETUP		(GS_IA18_S_PCF_GPIO_BASE0 + 1) +#define PCF_GPIO_WIFI_ENABLE		(GS_IA18_S_PCF_GPIO_BASE0 + 2) +#define PCF_GPIO_WIFI_RESET		(GS_IA18_S_PCF_GPIO_BASE0 + 3) +#define PCF_GPIO_ETH_DETECT		4 /* this is a GPI */ +#define PCF_GPIO_GPS_SETUP		(GS_IA18_S_PCF_GPIO_BASE0 + 5) +#define PCF_GPIO_GPS_STANDBY		(GS_IA18_S_PCF_GPIO_BASE0 + 6) +#define PCF_GPIO_GPS_POWER		(GS_IA18_S_PCF_GPIO_BASE0 + 7) + +/* PCF8574 0x22 GPIO - U1 on the GS_2G_OPT1-A_V0 board (Alarm) */ +#define GS_IA18_S_PCF_GPIO_BASE1	(GS_IA18_S_PCF_GPIO_BASE0 + 8) +#define PCF_GPIO_ALARM1			(GS_IA18_S_PCF_GPIO_BASE1 + 0) +#define PCF_GPIO_ALARM2			(GS_IA18_S_PCF_GPIO_BASE1 + 1) +#define PCF_GPIO_ALARM3			(GS_IA18_S_PCF_GPIO_BASE1 + 2) +#define PCF_GPIO_ALARM4			(GS_IA18_S_PCF_GPIO_BASE1 + 3) +/* bits 4, 5, 6 not used */ +#define PCF_GPIO_ALARM_V_RELAY_ON	(GS_IA18_S_PCF_GPIO_BASE1 + 7) + +/* PCF8574 0x24 GPIO U1 on the GS_2G-OPT23-A_V0 board (Modem) */ +#define GS_IA18_S_PCF_GPIO_BASE2	(GS_IA18_S_PCF_GPIO_BASE1 + 8) +#define PCF_GPIO_MODEM_POWER		(GS_IA18_S_PCF_GPIO_BASE2 + 0) +#define PCF_GPIO_MODEM_RESET		(GS_IA18_S_PCF_GPIO_BASE2 + 3) +/* bits 1, 2, 4, 5 not used */ +#define PCF_GPIO_TRX_RESET		(GS_IA18_S_PCF_GPIO_BASE2 + 6) +/* bit 7 not used */ diff --git a/arch/arm/mach-at91/include/mach/at572d940hf.h b/arch/arm/mach-at91/include/mach/at572d940hf.h deleted file mode 100644 index 2d9b0af9c4d..00000000000 --- a/arch/arm/mach-at91/include/mach/at572d940hf.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * include/mach/at572d940hf.h - * - * Antonio R. Costa <costa.antonior@gmail.com> - * Copyright (C) 2008 Atmel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - * - */ - -#ifndef AT572D940HF_H -#define AT572D940HF_H - -/* - * Peripheral identifiers/interrupts. - */ -#define AT91_ID_FIQ		0	/* Advanced Interrupt Controller (FIQ) */ -#define AT91_ID_SYS		1	/* System Peripherals */ -#define AT572D940HF_ID_PIOA	2	/* Parallel IO Controller A */ -#define AT572D940HF_ID_PIOB	3	/* Parallel IO Controller B */ -#define AT572D940HF_ID_PIOC	4	/* Parallel IO Controller C */ -#define AT572D940HF_ID_EMAC	5	/* MACB ethernet controller */ -#define AT572D940HF_ID_US0	6	/* USART 0 */ -#define AT572D940HF_ID_US1	7	/* USART 1 */ -#define AT572D940HF_ID_US2	8	/* USART 2 */ -#define AT572D940HF_ID_MCI	9	/* Multimedia Card Interface */ -#define AT572D940HF_ID_UDP	10	/* USB Device Port */ -#define AT572D940HF_ID_TWI0	11	/* Two-Wire Interface 0 */ -#define AT572D940HF_ID_SPI0	12	/* Serial Peripheral Interface 0 */ -#define AT572D940HF_ID_SPI1	13	/* Serial Peripheral Interface 1 */ -#define AT572D940HF_ID_SSC0	14	/* Serial Synchronous Controller 0 */ -#define AT572D940HF_ID_SSC1	15	/* Serial Synchronous Controller 1 */ -#define AT572D940HF_ID_SSC2	16	/* Serial Synchronous Controller 2 */ -#define AT572D940HF_ID_TC0	17	/* Timer Counter 0 */ -#define AT572D940HF_ID_TC1	18	/* Timer Counter 1 */ -#define AT572D940HF_ID_TC2	19	/* Timer Counter 2 */ -#define AT572D940HF_ID_UHP	20	/* USB Host port */ -#define AT572D940HF_ID_SSC3	21	/* Serial Synchronous Controller 3 */ -#define AT572D940HF_ID_TWI1	22	/* Two-Wire Interface 1 */ -#define AT572D940HF_ID_CAN0	23	/* CAN Controller 0 */ -#define AT572D940HF_ID_CAN1	24	/* CAN Controller 1 */ -#define AT572D940HF_ID_MHALT	25	/* mAgicV HALT line */ -#define AT572D940HF_ID_MSIRQ0	26	/* mAgicV SIRQ0 line */ -#define AT572D940HF_ID_MEXC	27	/* mAgicV exception line */ -#define AT572D940HF_ID_MEDMA	28	/* mAgicV end of DMA line */ -#define AT572D940HF_ID_IRQ0	29	/* External Interrupt Source (IRQ0) */ -#define AT572D940HF_ID_IRQ1	30	/* External Interrupt Source (IRQ1) */ -#define AT572D940HF_ID_IRQ2	31	/* External Interrupt Source (IRQ2) */ - - -/* - * User Peripheral physical base addresses. - */ -#define AT572D940HF_BASE_TCB	0xfffa0000 -#define AT572D940HF_BASE_TC0	0xfffa0000 -#define AT572D940HF_BASE_TC1	0xfffa0040 -#define AT572D940HF_BASE_TC2	0xfffa0080 -#define AT572D940HF_BASE_UDP	0xfffa4000 -#define AT572D940HF_BASE_MCI	0xfffa8000 -#define AT572D940HF_BASE_TWI0	0xfffac000 -#define AT572D940HF_BASE_US0	0xfffb0000 -#define AT572D940HF_BASE_US1	0xfffb4000 -#define AT572D940HF_BASE_US2	0xfffb8000 -#define AT572D940HF_BASE_SSC0	0xfffbc000 -#define AT572D940HF_BASE_SSC1	0xfffc0000 -#define AT572D940HF_BASE_SSC2	0xfffc4000 -#define AT572D940HF_BASE_SPI0	0xfffc8000 -#define AT572D940HF_BASE_SPI1	0xfffcc000 -#define AT572D940HF_BASE_SSC3	0xfffd0000 -#define AT572D940HF_BASE_TWI1	0xfffd4000 -#define AT572D940HF_BASE_EMAC	0xfffd8000 -#define AT572D940HF_BASE_CAN0	0xfffdc000 -#define AT572D940HF_BASE_CAN1	0xfffe0000 -#define AT91_BASE_SYS		0xffffea00 - - -/* - * System Peripherals (offset from AT91_BASE_SYS) - */ -#define AT91_SDRAMC	(0xffffea00 - AT91_BASE_SYS) -#define AT91_SMC	(0xffffec00 - AT91_BASE_SYS) -#define AT91_MATRIX	(0xffffee00 - AT91_BASE_SYS) -#define AT91_AIC	(0xfffff000 - AT91_BASE_SYS) -#define AT91_DBGU	(0xfffff200 - AT91_BASE_SYS) -#define AT91_PIOA	(0xfffff400 - AT91_BASE_SYS) -#define AT91_PIOB	(0xfffff600 - AT91_BASE_SYS) -#define AT91_PIOC	(0xfffff800 - AT91_BASE_SYS) -#define AT91_PMC	(0xfffffc00 - AT91_BASE_SYS) -#define AT91_RSTC	(0xfffffd00 - AT91_BASE_SYS) -#define AT91_RTT	(0xfffffd20 - AT91_BASE_SYS) -#define AT91_PIT	(0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT	(0xfffffd40 - AT91_BASE_SYS) - -#define AT91_USART0	AT572D940HF_ID_US0 -#define AT91_USART1	AT572D940HF_ID_US1 -#define AT91_USART2	AT572D940HF_ID_US2 - - -/* - * Internal Memory. - */ -#define AT572D940HF_SRAM_BASE	0x00300000	/* Internal SRAM base address */ -#define AT572D940HF_SRAM_SIZE	(48 * SZ_1K)	/* Internal SRAM size (48Kb) */ - -#define AT572D940HF_ROM_BASE	0x00400000	/* Internal ROM base address */ -#define AT572D940HF_ROM_SIZE	SZ_32K		/* Internal ROM size (32Kb) */ - -#define AT572D940HF_UHP_BASE	0x00500000	/* USB Host controller */ - - -#endif diff --git a/arch/arm/mach-at91/include/mach/at572d940hf_matrix.h b/arch/arm/mach-at91/include/mach/at572d940hf_matrix.h deleted file mode 100644 index b6751df0948..00000000000 --- a/arch/arm/mach-at91/include/mach/at572d940hf_matrix.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * include/mach//at572d940hf_matrix.h - * - * Antonio R. Costa <costa.antonior@gmail.com> - * Copyright (C) 2008 Atmel - * - * Copyright (C) 2005 SAN People - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#ifndef AT572D940HF_MATRIX_H -#define AT572D940HF_MATRIX_H - -#define AT91_MATRIX_MCFG0	(AT91_MATRIX + 0x00)	/* Master Configuration Register 0 */ -#define AT91_MATRIX_MCFG1	(AT91_MATRIX + 0x04)	/* Master Configuration Register 1 */ -#define AT91_MATRIX_MCFG2	(AT91_MATRIX + 0x08)	/* Master Configuration Register 2 */ -#define AT91_MATRIX_MCFG3	(AT91_MATRIX + 0x0C)	/* Master Configuration Register 3 */ -#define AT91_MATRIX_MCFG4	(AT91_MATRIX + 0x10)	/* Master Configuration Register 4 */ -#define AT91_MATRIX_MCFG5	(AT91_MATRIX + 0x14)	/* Master Configuration Register 5 */ - -#define		AT91_MATRIX_ULBT	(7 << 0)	/* Undefined Length Burst Type */ -#define			AT91_MATRIX_ULBT_INFINITE	(0 << 0) -#define			AT91_MATRIX_ULBT_SINGLE		(1 << 0) -#define			AT91_MATRIX_ULBT_FOUR		(2 << 0) -#define			AT91_MATRIX_ULBT_EIGHT		(3 << 0) -#define			AT91_MATRIX_ULBT_SIXTEEN	(4 << 0) - -#define AT91_MATRIX_SCFG0	(AT91_MATRIX + 0x40)	/* Slave Configuration Register 0 */ -#define AT91_MATRIX_SCFG1	(AT91_MATRIX + 0x44)	/* Slave Configuration Register 1 */ -#define AT91_MATRIX_SCFG2	(AT91_MATRIX + 0x48)	/* Slave Configuration Register 2 */ -#define AT91_MATRIX_SCFG3	(AT91_MATRIX + 0x4C)	/* Slave Configuration Register 3 */ -#define AT91_MATRIX_SCFG4	(AT91_MATRIX + 0x50)	/* Slave Configuration Register 4 */ -#define		AT91_MATRIX_SLOT_CYCLE		(0xff << 0)	/* Maximum Number of Allowed Cycles for a Burst */ -#define		AT91_MATRIX_DEFMSTR_TYPE	(3    << 16)	/* Default Master Type */ -#define			AT91_MATRIX_DEFMSTR_TYPE_NONE	(0 << 16) -#define			AT91_MATRIX_DEFMSTR_TYPE_LAST	(1 << 16) -#define			AT91_MATRIX_DEFMSTR_TYPE_FIXED	(2 << 16) -#define		AT91_MATRIX_FIXED_DEFMSTR	(0x7  << 18)	/* Fixed Index of Default Master */ -#define		AT91_MATRIX_ARBT		(3    << 24)	/* Arbitration Type */ -#define			AT91_MATRIX_ARBT_ROUND_ROBIN	(0 << 24) -#define			AT91_MATRIX_ARBT_FIXED_PRIORITY	(1 << 24) - -#define AT91_MATRIX_PRAS0	(AT91_MATRIX + 0x80)	/* Priority Register A for Slave 0 */ -#define AT91_MATRIX_PRAS1	(AT91_MATRIX + 0x88)	/* Priority Register A for Slave 1 */ -#define AT91_MATRIX_PRAS2	(AT91_MATRIX + 0x90)	/* Priority Register A for Slave 2 */ -#define AT91_MATRIX_PRAS3	(AT91_MATRIX + 0x98)	/* Priority Register A for Slave 3 */ -#define AT91_MATRIX_PRAS4	(AT91_MATRIX + 0xA0)	/* Priority Register A for Slave 4 */ - -#define		AT91_MATRIX_M0PR		(3 << 0)	/* Master 0 Priority */ -#define		AT91_MATRIX_M1PR		(3 << 4)	/* Master 1 Priority */ -#define		AT91_MATRIX_M2PR		(3 << 8)	/* Master 2 Priority */ -#define		AT91_MATRIX_M3PR		(3 << 12)	/* Master 3 Priority */ -#define		AT91_MATRIX_M4PR		(3 << 16)	/* Master 4 Priority */ -#define		AT91_MATRIX_M5PR		(3 << 20)	/* Master 5 Priority */ -#define		AT91_MATRIX_M6PR		(3 << 24)	/* Master 6 Priority */ - -#define AT91_MATRIX_MRCR	(AT91_MATRIX + 0x100)	/* Master Remap Control Register */ -#define		AT91_MATRIX_RCB0		(1 << 0)	/* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ -#define		AT91_MATRIX_RCB1		(1 << 1)	/* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ - -#define AT91_MATRIX_SFR0	(AT91_MATRIX + 0x110)	/* Special Function Register 0 */ -#define AT91_MATRIX_SFR1	(AT91_MATRIX + 0x114)	/* Special Function Register 1 */ -#define AT91_MATRIX_SFR2	(AT91_MATRIX + 0x118)	/* Special Function Register 2 */ -#define AT91_MATRIX_SFR3	(AT91_MATRIX + 0x11C)	/* Special Function Register 3 */ -#define AT91_MATRIX_SFR4	(AT91_MATRIX + 0x120)	/* Special Function Register 4 */ -#define AT91_MATRIX_SFR5	(AT91_MATRIX + 0x124)	/* Special Function Register 5 */ -#define AT91_MATRIX_SFR6	(AT91_MATRIX + 0x128)	/* Special Function Register 6 */ -#define AT91_MATRIX_SFR7	(AT91_MATRIX + 0x12C)	/* Special Function Register 7 */ -#define AT91_MATRIX_SFR8	(AT91_MATRIX + 0x130)	/* Special Function Register 8 */ -#define AT91_MATRIX_SFR9	(AT91_MATRIX + 0x134)	/* Special Function Register 9 */ -#define AT91_MATRIX_SFR10	(AT91_MATRIX + 0x138)	/* Special Function Register 10 */ -#define AT91_MATRIX_SFR11	(AT91_MATRIX + 0x13C)	/* Special Function Register 11 */ -#define AT91_MATRIX_SFR12	(AT91_MATRIX + 0x140)	/* Special Function Register 12 */ -#define AT91_MATRIX_SFR13	(AT91_MATRIX + 0x144)	/* Special Function Register 13 */ -#define AT91_MATRIX_SFR14	(AT91_MATRIX + 0x148)	/* Special Function Register 14 */ -#define AT91_MATRIX_SFR15	(AT91_MATRIX + 0x14C)	/* Special Function Register 15 */ - - -/* - * The following registers / bits are not defined in the Datasheet (Revision A) - */ - -#define AT91_MATRIX_TCR		(AT91_MATRIX + 0x100)	/* TCM Configuration Register */ -#define		AT91_MATRIX_ITCM_SIZE		(0xf << 0)	/* Size of ITCM enabled memory block */ -#define			AT91_MATRIX_ITCM_0		(0 << 0) -#define			AT91_MATRIX_ITCM_16		(5 << 0) -#define			AT91_MATRIX_ITCM_32		(6 << 0) -#define			AT91_MATRIX_ITCM_64		(7 << 0) -#define		AT91_MATRIX_DTCM_SIZE		(0xf << 4)	/* Size of DTCM enabled memory block */ -#define			AT91_MATRIX_DTCM_0		(0 << 4) -#define			AT91_MATRIX_DTCM_16		(5 << 4) -#define			AT91_MATRIX_DTCM_32		(6 << 4) -#define			AT91_MATRIX_DTCM_64		(7 << 4) - -#define AT91_MATRIX_EBICSA	(AT91_MATRIX + 0x11C)	/* EBI Chip Select Assignment Register */ -#define		AT91_MATRIX_CS1A		(1 << 1)	/* Chip Select 1 Assignment */ -#define			AT91_MATRIX_CS1A_SMC		(0 << 1) -#define			AT91_MATRIX_CS1A_SDRAMC		(1 << 1) -#define		AT91_MATRIX_CS3A		(1 << 3)	/* Chip Select 3 Assignment */ -#define			AT91_MATRIX_CS3A_SMC		(0 << 3) -#define			AT91_MATRIX_CS3A_SMC_SMARTMEDIA	(1 << 3) -#define		AT91_MATRIX_CS4A		(1 << 4)	/* Chip Select 4 Assignment */ -#define			AT91_MATRIX_CS4A_SMC		(0 << 4) -#define			AT91_MATRIX_CS4A_SMC_CF1	(1 << 4) -#define		AT91_MATRIX_CS5A		(1 << 5)	/* Chip Select 5 Assignment */ -#define			AT91_MATRIX_CS5A_SMC		(0 << 5) -#define			AT91_MATRIX_CS5A_SMC_CF2	(1 << 5) -#define		AT91_MATRIX_DBPUC		(1 << 8)	/* Data Bus Pull-up Configuration */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91_adc.h b/arch/arm/mach-at91/include/mach/at91_adc.h deleted file mode 100644 index 8e7ed5c9081..00000000000 --- a/arch/arm/mach-at91/include/mach/at91_adc.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_adc.h - * - * Copyright (C) SAN People - * - * Analog-to-Digital Converter (ADC) registers. - * Based on AT91SAM9260 datasheet revision D. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91_ADC_H -#define AT91_ADC_H - -#define AT91_ADC_CR		0x00		/* Control Register */ -#define		AT91_ADC_SWRST		(1 << 0)	/* Software Reset */ -#define		AT91_ADC_START		(1 << 1)	/* Start Conversion */ - -#define AT91_ADC_MR		0x04		/* Mode Register */ -#define		AT91_ADC_TRGEN		(1 << 0)	/* Trigger Enable */ -#define		AT91_ADC_TRGSEL		(7 << 1)	/* Trigger Selection */ -#define			AT91_ADC_TRGSEL_TC0		(0 << 1) -#define			AT91_ADC_TRGSEL_TC1		(1 << 1) -#define			AT91_ADC_TRGSEL_TC2		(2 << 1) -#define			AT91_ADC_TRGSEL_EXTERNAL	(6 << 1) -#define		AT91_ADC_LOWRES		(1 << 4)	/* Low Resolution */ -#define		AT91_ADC_SLEEP		(1 << 5)	/* Sleep Mode */ -#define		AT91_ADC_PRESCAL	(0x3f << 8)	/* Prescalar Rate Selection */ -#define			AT91_ADC_PRESCAL_(x)	((x) << 8) -#define		AT91_ADC_STARTUP	(0x1f << 16)	/* Startup Up Time */ -#define			AT91_ADC_STARTUP_(x)	((x) << 16) -#define		AT91_ADC_SHTIM		(0xf  << 24)	/* Sample & Hold Time */ -#define			AT91_ADC_SHTIM_(x)	((x) << 24) - -#define AT91_ADC_CHER		0x10		/* Channel Enable Register */ -#define AT91_ADC_CHDR		0x14		/* Channel Disable Register */ -#define AT91_ADC_CHSR		0x18		/* Channel Status Register */ -#define		AT91_ADC_CH(n)		(1 << (n))	/* Channel Number */ - -#define AT91_ADC_SR		0x1C		/* Status Register */ -#define		AT91_ADC_EOC(n)		(1 << (n))	/* End of Conversion on Channel N */ -#define		AT91_ADC_OVRE(n)	(1 << ((n) + 8))/* Overrun Error on Channel N */ -#define		AT91_ADC_DRDY		(1 << 16)	/* Data Ready */ -#define		AT91_ADC_GOVRE		(1 << 17)	/* General Overrun Error */ -#define		AT91_ADC_ENDRX		(1 << 18)	/* End of RX Buffer */ -#define		AT91_ADC_RXFUFF		(1 << 19)	/* RX Buffer Full */ - -#define AT91_ADC_LCDR		0x20		/* Last Converted Data Register */ -#define		AT91_ADC_LDATA		(0x3ff) - -#define AT91_ADC_IER		0x24		/* Interrupt Enable Register */ -#define AT91_ADC_IDR		0x28		/* Interrupt Disable Register */ -#define AT91_ADC_IMR		0x2C		/* Interrupt Mask Register */ - -#define AT91_ADC_CHR(n)		(0x30 + ((n) * 4))	/* Channel Data Register N */ -#define		AT91_ADC_DATA		(0x3ff) - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91_aic.h b/arch/arm/mach-at91/include/mach/at91_aic.h deleted file mode 100644 index 03566799d3b..00000000000 --- a/arch/arm/mach-at91/include/mach/at91_aic.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_aic.h - * - * Copyright (C) 2005 Ivan Kokshaysky - * Copyright (C) SAN People - * - * Advanced Interrupt Controller (AIC) - System peripherals registers. - * Based on AT91RM9200 datasheet revision E. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91_AIC_H -#define AT91_AIC_H - -#define AT91_AIC_SMR(n)		(AT91_AIC + ((n) * 4))	/* Source Mode Registers 0-31 */ -#define		AT91_AIC_PRIOR		(7 << 0)		/* Priority Level */ -#define		AT91_AIC_SRCTYPE	(3 << 5)		/* Interrupt Source Type */ -#define			AT91_AIC_SRCTYPE_LOW		(0 << 5) -#define			AT91_AIC_SRCTYPE_FALLING	(1 << 5) -#define			AT91_AIC_SRCTYPE_HIGH		(2 << 5) -#define			AT91_AIC_SRCTYPE_RISING		(3 << 5) - -#define AT91_AIC_SVR(n)		(AT91_AIC + 0x80 + ((n) * 4))	/* Source Vector Registers 0-31 */ -#define AT91_AIC_IVR		(AT91_AIC + 0x100)	/* Interrupt Vector Register */ -#define AT91_AIC_FVR		(AT91_AIC + 0x104)	/* Fast Interrupt Vector Register */ -#define AT91_AIC_ISR		(AT91_AIC + 0x108)	/* Interrupt Status Register */ -#define		AT91_AIC_IRQID		(0x1f << 0)		/* Current Interrupt Identifier */ - -#define AT91_AIC_IPR		(AT91_AIC + 0x10c)	/* Interrupt Pending Register */ -#define AT91_AIC_IMR		(AT91_AIC + 0x110)	/* Interrupt Mask Register */ -#define AT91_AIC_CISR		(AT91_AIC + 0x114)	/* Core Interrupt Status Register */ -#define		AT91_AIC_NFIQ		(1 << 0)		/* nFIQ Status */ -#define		AT91_AIC_NIRQ		(1 << 1)		/* nIRQ Status */ - -#define AT91_AIC_IECR		(AT91_AIC + 0x120)	/* Interrupt Enable Command Register */ -#define AT91_AIC_IDCR		(AT91_AIC + 0x124)	/* Interrupt Disable Command Register */ -#define AT91_AIC_ICCR		(AT91_AIC + 0x128)	/* Interrupt Clear Command Register */ -#define AT91_AIC_ISCR		(AT91_AIC + 0x12c)	/* Interrupt Set Command Register */ -#define AT91_AIC_EOICR		(AT91_AIC + 0x130)	/* End of Interrupt Command Register */ -#define AT91_AIC_SPU		(AT91_AIC + 0x134)	/* Spurious Interrupt Vector Register */ -#define AT91_AIC_DCR		(AT91_AIC + 0x138)	/* Debug Control Register */ -#define		AT91_AIC_DCR_PROT	(1 << 0)		/* Protection Mode */ -#define		AT91_AIC_DCR_GMSK	(1 << 1)		/* General Mask */ - -#define AT91_AIC_FFER		(AT91_AIC + 0x140)	/* Fast Forcing Enable Register [SAM9 only] */ -#define AT91_AIC_FFDR		(AT91_AIC + 0x144)	/* Fast Forcing Disable Register [SAM9 only] */ -#define AT91_AIC_FFSR		(AT91_AIC + 0x148)	/* Fast Forcing Status Register [SAM9 only] */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91_dbgu.h b/arch/arm/mach-at91/include/mach/at91_dbgu.h index 6dcaa771687..3b5948566e5 100644 --- a/arch/arm/mach-at91/include/mach/at91_dbgu.h +++ b/arch/arm/mach-at91/include/mach/at91_dbgu.h @@ -16,22 +16,22 @@  #ifndef AT91_DBGU_H  #define AT91_DBGU_H -#ifdef AT91_DBGU -#define AT91_DBGU_CR		(AT91_DBGU + 0x00)	/* Control Register */ -#define AT91_DBGU_MR		(AT91_DBGU + 0x04)	/* Mode Register */ -#define AT91_DBGU_IER		(AT91_DBGU + 0x08)	/* Interrupt Enable Register */ +#if !defined(CONFIG_ARCH_AT91X40) +#define AT91_DBGU_CR		(0x00)	/* Control Register */ +#define AT91_DBGU_MR		(0x04)	/* Mode Register */ +#define AT91_DBGU_IER		(0x08)	/* Interrupt Enable Register */  #define		AT91_DBGU_TXRDY		(1 << 1)		/* Transmitter Ready */  #define		AT91_DBGU_TXEMPTY	(1 << 9)		/* Transmitter Empty */ -#define AT91_DBGU_IDR		(AT91_DBGU + 0x0c)	/* Interrupt Disable Register */ -#define AT91_DBGU_IMR		(AT91_DBGU + 0x10)	/* Interrupt Mask Register */ -#define AT91_DBGU_SR		(AT91_DBGU + 0x14)	/* Status Register */ -#define AT91_DBGU_RHR		(AT91_DBGU + 0x18)	/* Receiver Holding Register */ -#define AT91_DBGU_THR		(AT91_DBGU + 0x1c)	/* Transmitter Holding Register */ -#define AT91_DBGU_BRGR		(AT91_DBGU + 0x20)	/* Baud Rate Generator Register */ +#define AT91_DBGU_IDR		(0x0c)	/* Interrupt Disable Register */ +#define AT91_DBGU_IMR		(0x10)	/* Interrupt Mask Register */ +#define AT91_DBGU_SR		(0x14)	/* Status Register */ +#define AT91_DBGU_RHR		(0x18)	/* Receiver Holding Register */ +#define AT91_DBGU_THR		(0x1c)	/* Transmitter Holding Register */ +#define AT91_DBGU_BRGR		(0x20)	/* Baud Rate Generator Register */ -#define AT91_DBGU_CIDR		(AT91_DBGU + 0x40)	/* Chip ID Register */ -#define AT91_DBGU_EXID		(AT91_DBGU + 0x44)	/* Chip ID Extension Register */ -#define AT91_DBGU_FNR		(AT91_DBGU + 0x48)	/* Force NTRST Register [SAM9 only] */ +#define AT91_DBGU_CIDR		(0x40)	/* Chip ID Register */ +#define AT91_DBGU_EXID		(0x44)	/* Chip ID Extension Register */ +#define AT91_DBGU_FNR		(0x48)	/* Force NTRST Register [SAM9 only] */  #define		AT91_DBGU_FNTRST	(1 << 0)		/* Force NTRST */  #endif /* AT91_DBGU */ diff --git a/arch/arm/mach-at91/include/mach/at91_matrix.h b/arch/arm/mach-at91/include/mach/at91_matrix.h new file mode 100644 index 00000000000..f8996c95413 --- /dev/null +++ b/arch/arm/mach-at91/include/mach/at91_matrix.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> + * + * Under GPLv2 + */ + +#ifndef __MACH_AT91_MATRIX_H__ +#define __MACH_AT91_MATRIX_H__ + +#ifndef __ASSEMBLY__ +extern void __iomem *at91_matrix_base; + +#define at91_matrix_read(field) \ +	__raw_readl(at91_matrix_base + field) + +#define at91_matrix_write(field, value) \ +	__raw_writel(value, at91_matrix_base + field) + +#else +.extern at91_matrix_base +#endif + +#endif /* __MACH_AT91_MATRIX_H__ */ diff --git a/arch/arm/mach-at91/include/mach/at91_mci.h b/arch/arm/mach-at91/include/mach/at91_mci.h deleted file mode 100644 index 57f8ee15494..00000000000 --- a/arch/arm/mach-at91/include/mach/at91_mci.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_mci.h - * - * Copyright (C) 2005 Ivan Kokshaysky - * Copyright (C) SAN People - * - * MultiMedia Card Interface (MCI) registers. - * Based on AT91RM9200 datasheet revision F. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91_MCI_H -#define AT91_MCI_H - -#define AT91_MCI_CR		0x00		/* Control Register */ -#define		AT91_MCI_MCIEN		(1 <<  0)	/* Multi-Media Interface Enable */ -#define		AT91_MCI_MCIDIS		(1 <<  1)	/* Multi-Media Interface Disable */ -#define		AT91_MCI_PWSEN		(1 <<  2)	/* Power Save Mode Enable */ -#define		AT91_MCI_PWSDIS		(1 <<  3)	/* Power Save Mode Disable */ -#define		AT91_MCI_SWRST		(1 <<  7)	/* Software Reset */ - -#define AT91_MCI_MR		0x04		/* Mode Register */ -#define		AT91_MCI_CLKDIV		(0xff  <<  0)	/* Clock Divider */ -#define		AT91_MCI_PWSDIV		(7     <<  8)	/* Power Saving Divider */ -#define		AT91_MCI_RDPROOF	(1     << 11)	/* Read Proof Enable [SAM926[03] only] */ -#define		AT91_MCI_WRPROOF	(1     << 12)	/* Write Proof Enable [SAM926[03] only] */ -#define		AT91_MCI_PDCFBYTE	(1     << 13)	/* PDC Force Byte Transfer [SAM926[03] only] */ -#define		AT91_MCI_PDCPADV	(1     << 14)	/* PDC Padding Value */ -#define		AT91_MCI_PDCMODE	(1     << 15)	/* PDC-orientated Mode */ -#define		AT91_MCI_BLKLEN		(0xfff << 18)	/* Data Block Length */ - -#define AT91_MCI_DTOR		0x08		/* Data Timeout Register */ -#define		AT91_MCI_DTOCYC		(0xf << 0)	/* Data Timeout Cycle Number */ -#define		AT91_MCI_DTOMUL		(7   << 4)	/* Data Timeout Multiplier */ -#define		AT91_MCI_DTOMUL_1		(0 <<  4) -#define		AT91_MCI_DTOMUL_16		(1 <<  4) -#define		AT91_MCI_DTOMUL_128		(2 <<  4) -#define		AT91_MCI_DTOMUL_256		(3 <<  4) -#define		AT91_MCI_DTOMUL_1K		(4 <<  4) -#define		AT91_MCI_DTOMUL_4K		(5 <<  4) -#define		AT91_MCI_DTOMUL_64K		(6 <<  4) -#define		AT91_MCI_DTOMUL_1M		(7 <<  4) - -#define AT91_MCI_SDCR		0x0c		/* SD Card Register */ -#define		AT91_MCI_SDCSEL		(3 << 0)	/* SD Card Selector */ -#define		AT91_MCI_SDCBUS		(1 << 7)	/* 1-bit or 4-bit bus */ - -#define AT91_MCI_ARGR		0x10		/* Argument Register */ - -#define AT91_MCI_CMDR		0x14		/* Command Register */ -#define		AT91_MCI_CMDNB		(0x3f << 0)	/* Command Number */ -#define		AT91_MCI_RSPTYP		(3    << 6)	/* Response Type */ -#define			AT91_MCI_RSPTYP_NONE	(0 <<  6) -#define			AT91_MCI_RSPTYP_48	(1 <<  6) -#define			AT91_MCI_RSPTYP_136	(2 <<  6) -#define		AT91_MCI_SPCMD		(7    << 8)	/* Special Command */ -#define			AT91_MCI_SPCMD_NONE	(0 <<  8) -#define			AT91_MCI_SPCMD_INIT	(1 <<  8) -#define			AT91_MCI_SPCMD_SYNC	(2 <<  8) -#define			AT91_MCI_SPCMD_ICMD	(4 <<  8) -#define			AT91_MCI_SPCMD_IRESP	(5 <<  8) -#define		AT91_MCI_OPDCMD		(1 << 11)	/* Open Drain Command */ -#define		AT91_MCI_MAXLAT		(1 << 12)	/* Max Latency for Command to Response */ -#define		AT91_MCI_TRCMD		(3 << 16)	/* Transfer Command */ -#define			AT91_MCI_TRCMD_NONE	(0 << 16) -#define			AT91_MCI_TRCMD_START	(1 << 16) -#define			AT91_MCI_TRCMD_STOP	(2 << 16) -#define		AT91_MCI_TRDIR		(1 << 18)	/* Transfer Direction */ -#define		AT91_MCI_TRTYP		(3 << 19)	/* Transfer Type */ -#define			AT91_MCI_TRTYP_BLOCK	(0 << 19) -#define			AT91_MCI_TRTYP_MULTIPLE	(1 << 19) -#define			AT91_MCI_TRTYP_STREAM	(2 << 19) - -#define AT91_MCI_BLKR		0x18		/* Block Register */ -#define		AT91_MCI_BLKR_BCNT(n)	((0xffff & (n)) << 0)	/* Block count */ -#define		AT91_MCI_BLKR_BLKLEN(n)	((0xffff & (n)) << 16)	/* Block length */ - -#define AT91_MCI_RSPR(n)	(0x20 + ((n) * 4))	/* Response Registers 0-3 */ -#define AT91_MCR_RDR		0x30		/* Receive Data Register */ -#define AT91_MCR_TDR		0x34		/* Transmit Data Register */ - -#define AT91_MCI_SR		0x40		/* Status Register */ -#define		AT91_MCI_CMDRDY		(1 <<  0)	/* Command Ready */ -#define		AT91_MCI_RXRDY		(1 <<  1)	/* Receiver Ready */ -#define		AT91_MCI_TXRDY		(1 <<  2)	/* Transmit Ready */ -#define		AT91_MCI_BLKE		(1 <<  3)	/* Data Block Ended */ -#define		AT91_MCI_DTIP		(1 <<  4)	/* Data Transfer in Progress */ -#define		AT91_MCI_NOTBUSY	(1 <<  5)	/* Data Not Busy */ -#define		AT91_MCI_ENDRX		(1 <<  6)	/* End of RX Buffer */ -#define		AT91_MCI_ENDTX		(1 <<  7)	/* End fo TX Buffer */ -#define		AT91_MCI_SDIOIRQA	(1 <<  8)	/* SDIO Interrupt for Slot A */ -#define		AT91_MCI_SDIOIRQB	(1 <<  9)	/* SDIO Interrupt for Slot B */ -#define		AT91_MCI_RXBUFF		(1 << 14)	/* RX Buffer Full */ -#define		AT91_MCI_TXBUFE		(1 << 15)	/* TX Buffer Empty */ -#define		AT91_MCI_RINDE		(1 << 16)	/* Response Index Error */ -#define		AT91_MCI_RDIRE		(1 << 17)	/* Response Direction Error */ -#define		AT91_MCI_RCRCE		(1 << 18)	/* Response CRC Error */ -#define		AT91_MCI_RENDE		(1 << 19)	/* Response End Bit Error */ -#define		AT91_MCI_RTOE		(1 << 20)	/* Reponse Time-out Error */ -#define		AT91_MCI_DCRCE		(1 << 21)	/* Data CRC Error */ -#define		AT91_MCI_DTOE		(1 << 22)	/* Data Time-out Error */ -#define		AT91_MCI_OVRE		(1 << 30)	/* Overrun */ -#define		AT91_MCI_UNRE		(1 << 31)	/* Underrun */ - -#define AT91_MCI_IER		0x44		/* Interrupt Enable Register */ -#define AT91_MCI_IDR		0x48		/* Interrupt Disable Register */ -#define AT91_MCI_IMR		0x4c		/* Interrupt Mask Register */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91_pio.h b/arch/arm/mach-at91/include/mach/at91_pio.h index c6a31bf8a5c..732b11c37f1 100644 --- a/arch/arm/mach-at91/include/mach/at91_pio.h +++ b/arch/arm/mach-at91/include/mach/at91_pio.h @@ -40,10 +40,35 @@  #define PIO_PUER	0x64	/* Pull-up Enable Register */  #define PIO_PUSR	0x68	/* Pull-up Status Register */  #define PIO_ASR		0x70	/* Peripheral A Select Register */ +#define PIO_ABCDSR1	0x70	/* Peripheral ABCD Select Register 1 [some sam9 only] */  #define PIO_BSR		0x74	/* Peripheral B Select Register */ +#define PIO_ABCDSR2	0x74	/* Peripheral ABCD Select Register 2 [some sam9 only] */  #define PIO_ABSR	0x78	/* AB Status Register */ +#define PIO_IFSCDR	0x80	/* Input Filter Slow Clock Disable Register */ +#define PIO_IFSCER	0x84	/* Input Filter Slow Clock Enable Register */ +#define PIO_IFSCSR	0x88	/* Input Filter Slow Clock Status Register */ +#define PIO_SCDR	0x8c	/* Slow Clock Divider Debouncing Register */ +#define		PIO_SCDR_DIV	(0x3fff <<  0)		/* Slow Clock Divider Mask */ +#define PIO_PPDDR	0x90	/* Pad Pull-down Disable Register */ +#define PIO_PPDER	0x94	/* Pad Pull-down Enable Register */ +#define PIO_PPDSR	0x98	/* Pad Pull-down Status Register */  #define PIO_OWER	0xa0	/* Output Write Enable Register */  #define PIO_OWDR	0xa4	/* Output Write Disable Register */  #define PIO_OWSR	0xa8	/* Output Write Status Register */ +#define PIO_AIMER	0xb0	/* Additional Interrupt Modes Enable Register */ +#define PIO_AIMDR	0xb4	/* Additional Interrupt Modes Disable Register */ +#define PIO_AIMMR	0xb8	/* Additional Interrupt Modes Mask Register */ +#define PIO_ESR		0xc0	/* Edge Select Register */ +#define PIO_LSR		0xc4	/* Level Select Register */ +#define PIO_ELSR	0xc8	/* Edge/Level Status Register */ +#define PIO_FELLSR	0xd0	/* Falling Edge/Low Level Select Register */ +#define PIO_REHLSR	0xd4	/* Rising Edge/ High Level Select Register */ +#define PIO_FRLHSR	0xd8	/* Fall/Rise - Low/High Status Register */ +#define PIO_SCHMITT	0x100	/* Schmitt Trigger Register */ + +#define ABCDSR_PERIPH_A	0x0 +#define ABCDSR_PERIPH_B	0x1 +#define ABCDSR_PERIPH_C	0x2 +#define ABCDSR_PERIPH_D	0x3  #endif diff --git a/arch/arm/mach-at91/include/mach/at91_pit.h b/arch/arm/mach-at91/include/mach/at91_pit.h deleted file mode 100644 index 974d0bd05b5..00000000000 --- a/arch/arm/mach-at91/include/mach/at91_pit.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_pit.h - * - * Copyright (C) 2007 Andrew Victor - * Copyright (C) 2007 Atmel Corporation. - * - * Periodic Interval Timer (PIT) - System peripherals regsters. - * Based on AT91SAM9261 datasheet revision D. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91_PIT_H -#define AT91_PIT_H - -#define AT91_PIT_MR		(AT91_PIT + 0x00)	/* Mode Register */ -#define		AT91_PIT_PITIEN		(1 << 25)		/* Timer Interrupt Enable */ -#define		AT91_PIT_PITEN		(1 << 24)		/* Timer Enabled */ -#define		AT91_PIT_PIV		(0xfffff)		/* Periodic Interval Value */ - -#define AT91_PIT_SR		(AT91_PIT + 0x04)	/* Status Register */ -#define		AT91_PIT_PITS		(1 << 0)		/* Timer Status */ - -#define AT91_PIT_PIVR		(AT91_PIT + 0x08)	/* Periodic Interval Value Register */ -#define AT91_PIT_PIIR		(AT91_PIT + 0x0c)	/* Periodic Interval Image Register */ -#define		AT91_PIT_PICNT		(0xfff << 20)		/* Interval Counter */ -#define		AT91_PIT_CPIV		(0xfffff)		/* Inverval Value */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h b/arch/arm/mach-at91/include/mach/at91_pmc.h deleted file mode 100644 index e46f93e34aa..00000000000 --- a/arch/arm/mach-at91/include/mach/at91_pmc.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_pmc.h - * - * Copyright (C) 2005 Ivan Kokshaysky - * Copyright (C) SAN People - * - * Power Management Controller (PMC) - System peripherals registers. - * Based on AT91RM9200 datasheet revision E. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91_PMC_H -#define AT91_PMC_H - -#define	AT91_PMC_SCER		(AT91_PMC + 0x00)	/* System Clock Enable Register */ -#define	AT91_PMC_SCDR		(AT91_PMC + 0x04)	/* System Clock Disable Register */ - -#define	AT91_PMC_SCSR		(AT91_PMC + 0x08)	/* System Clock Status Register */ -#define		AT91_PMC_PCK		(1 <<  0)		/* Processor Clock */ -#define		AT91RM9200_PMC_UDP	(1 <<  1)		/* USB Devcice Port Clock [AT91RM9200 only] */ -#define		AT91RM9200_PMC_MCKUDP	(1 <<  2)		/* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */ -#define		AT91CAP9_PMC_DDR	(1 <<  2)		/* DDR Clock [CAP9 revC & some SAM9 only] */ -#define		AT91RM9200_PMC_UHP	(1 <<  4)		/* USB Host Port Clock [AT91RM9200 only] */ -#define		AT91SAM926x_PMC_UHP	(1 <<  6)		/* USB Host Port Clock [AT91SAM926x only] */ -#define		AT91CAP9_PMC_UHP	(1 <<  6)		/* USB Host Port Clock [AT91CAP9 only] */ -#define		AT91SAM926x_PMC_UDP	(1 <<  7)		/* USB Devcice Port Clock [AT91SAM926x only] */ -#define		AT91_PMC_PCK0		(1 <<  8)		/* Programmable Clock 0 */ -#define		AT91_PMC_PCK1		(1 <<  9)		/* Programmable Clock 1 */ -#define		AT91_PMC_PCK2		(1 << 10)		/* Programmable Clock 2 */ -#define		AT91_PMC_PCK3		(1 << 11)		/* Programmable Clock 3 */ -#define		AT91_PMC_PCK4		(1 << 12)		/* Programmable Clock 4 [AT572D940HF only] */ -#define		AT91_PMC_HCK0		(1 << 16)		/* AHB Clock (USB host) [AT91SAM9261 only] */ -#define		AT91_PMC_HCK1		(1 << 17)		/* AHB Clock (LCD) [AT91SAM9261 only] */ - -#define	AT91_PMC_PCER		(AT91_PMC + 0x10)	/* Peripheral Clock Enable Register */ -#define	AT91_PMC_PCDR		(AT91_PMC + 0x14)	/* Peripheral Clock Disable Register */ -#define	AT91_PMC_PCSR		(AT91_PMC + 0x18)	/* Peripheral Clock Status Register */ - -#define	AT91_CKGR_UCKR		(AT91_PMC + 0x1C)	/* UTMI Clock Register [some SAM9, CAP9] */ -#define		AT91_PMC_UPLLEN		(1   << 16)		/* UTMI PLL Enable */ -#define		AT91_PMC_UPLLCOUNT	(0xf << 20)		/* UTMI PLL Start-up Time */ -#define		AT91_PMC_BIASEN		(1   << 24)		/* UTMI BIAS Enable */ -#define		AT91_PMC_BIASCOUNT	(0xf << 28)		/* UTMI BIAS Start-up Time */ - -#define	AT91_CKGR_MOR		(AT91_PMC + 0x20)	/* Main Oscillator Register [not on SAM9RL] */ -#define		AT91_PMC_MOSCEN		(1    << 0)		/* Main Oscillator Enable */ -#define		AT91_PMC_OSCBYPASS	(1    << 1)		/* Oscillator Bypass [SAM9x, CAP9] */ -#define		AT91_PMC_OSCOUNT	(0xff << 8)		/* Main Oscillator Start-up Time */ - -#define	AT91_CKGR_MCFR		(AT91_PMC + 0x24)	/* Main Clock Frequency Register */ -#define		AT91_PMC_MAINF		(0xffff <<  0)		/* Main Clock Frequency */ -#define		AT91_PMC_MAINRDY	(1	<< 16)		/* Main Clock Ready */ - -#define	AT91_CKGR_PLLAR		(AT91_PMC + 0x28)	/* PLL A Register */ -#define	AT91_CKGR_PLLBR		(AT91_PMC + 0x2c)	/* PLL B Register */ -#define		AT91_PMC_DIV		(0xff  <<  0)		/* Divider */ -#define		AT91_PMC_PLLCOUNT	(0x3f  <<  8)		/* PLL Counter */ -#define		AT91_PMC_OUT		(3     << 14)		/* PLL Clock Frequency Range */ -#define		AT91_PMC_MUL		(0x7ff << 16)		/* PLL Multiplier */ -#define		AT91_PMC_USBDIV		(3     << 28)		/* USB Divisor (PLLB only) */ -#define			AT91_PMC_USBDIV_1		(0 << 28) -#define			AT91_PMC_USBDIV_2		(1 << 28) -#define			AT91_PMC_USBDIV_4		(2 << 28) -#define		AT91_PMC_USB96M		(1     << 28)		/* Divider by 2 Enable (PLLB only) */ - -#define	AT91_PMC_MCKR		(AT91_PMC + 0x30)	/* Master Clock Register */ -#define		AT91_PMC_CSS		(3 <<  0)		/* Master Clock Selection */ -#define			AT91_PMC_CSS_SLOW		(0 << 0) -#define			AT91_PMC_CSS_MAIN		(1 << 0) -#define			AT91_PMC_CSS_PLLA		(2 << 0) -#define			AT91_PMC_CSS_PLLB		(3 << 0) -#define			AT91_PMC_CSS_UPLL		(3 << 0)	/* [some SAM9 only] */ -#define		AT91_PMC_PRES		(7 <<  2)		/* Master Clock Prescaler */ -#define			AT91_PMC_PRES_1			(0 << 2) -#define			AT91_PMC_PRES_2			(1 << 2) -#define			AT91_PMC_PRES_4			(2 << 2) -#define			AT91_PMC_PRES_8			(3 << 2) -#define			AT91_PMC_PRES_16		(4 << 2) -#define			AT91_PMC_PRES_32		(5 << 2) -#define			AT91_PMC_PRES_64		(6 << 2) -#define		AT91_PMC_MDIV		(3 <<  8)		/* Master Clock Division */ -#define			AT91RM9200_PMC_MDIV_1		(0 << 8)	/* [AT91RM9200 only] */ -#define			AT91RM9200_PMC_MDIV_2		(1 << 8) -#define			AT91RM9200_PMC_MDIV_3		(2 << 8) -#define			AT91RM9200_PMC_MDIV_4		(3 << 8) -#define			AT91SAM9_PMC_MDIV_1		(0 << 8)	/* [SAM9,CAP9 only] */ -#define			AT91SAM9_PMC_MDIV_2		(1 << 8) -#define			AT91SAM9_PMC_MDIV_4		(2 << 8) -#define			AT91SAM9_PMC_MDIV_6		(3 << 8)	/* [some SAM9 only] */ -#define			AT91SAM9_PMC_MDIV_3		(3 << 8)	/* [some SAM9 only] */ -#define		AT91_PMC_PDIV		(1 << 12)		/* Processor Clock Division [some SAM9 only] */ -#define			AT91_PMC_PDIV_1			(0 << 12) -#define			AT91_PMC_PDIV_2			(1 << 12) -#define		AT91_PMC_PLLADIV2	(1 << 12)		/* PLLA divisor by 2 [some SAM9 only] */ -#define			AT91_PMC_PLLADIV2_OFF		(0 << 12) -#define			AT91_PMC_PLLADIV2_ON		(1 << 12) - -#define	AT91_PMC_USB		(AT91_PMC + 0x38)	/* USB Clock Register [some SAM9 only] */ -#define		AT91_PMC_USBS		(0x1 <<  0)		/* USB OHCI Input clock selection */ -#define			AT91_PMC_USBS_PLLA		(0 << 0) -#define			AT91_PMC_USBS_UPLL		(1 << 0) -#define		AT91_PMC_OHCIUSBDIV	(0xF <<  8)		/* Divider for USB OHCI Clock */ - -#define	AT91_PMC_PCKR(n)	(AT91_PMC + 0x40 + ((n) * 4))	/* Programmable Clock 0-N Registers */ -#define		AT91_PMC_CSSMCK		(0x1 <<  8)		/* CSS or Master Clock Selection */ -#define			AT91_PMC_CSSMCK_CSS		(0 << 8) -#define			AT91_PMC_CSSMCK_MCK		(1 << 8) - -#define	AT91_PMC_IER		(AT91_PMC + 0x60)	/* Interrupt Enable Register */ -#define	AT91_PMC_IDR		(AT91_PMC + 0x64)	/* Interrupt Disable Register */ -#define	AT91_PMC_SR		(AT91_PMC + 0x68)	/* Status Register */ -#define		AT91_PMC_MOSCS		(1 <<  0)		/* MOSCS Flag */ -#define		AT91_PMC_LOCKA		(1 <<  1)		/* PLLA Lock */ -#define		AT91_PMC_LOCKB		(1 <<  2)		/* PLLB Lock */ -#define		AT91_PMC_MCKRDY		(1 <<  3)		/* Master Clock */ -#define		AT91_PMC_LOCKU		(1 <<  6)		/* UPLL Lock [some SAM9, AT91CAP9 only] */ -#define		AT91_PMC_OSCSEL		(1 <<  7)		/* Slow Clock Oscillator [AT91CAP9 revC only] */ -#define		AT91_PMC_PCK0RDY	(1 <<  8)		/* Programmable Clock 0 */ -#define		AT91_PMC_PCK1RDY	(1 <<  9)		/* Programmable Clock 1 */ -#define		AT91_PMC_PCK2RDY	(1 << 10)		/* Programmable Clock 2 */ -#define		AT91_PMC_PCK3RDY	(1 << 11)		/* Programmable Clock 3 */ -#define	AT91_PMC_IMR		(AT91_PMC + 0x6c)	/* Interrupt Mask Register */ - -#define AT91_PMC_PROT		(AT91_PMC + 0xe4)	/* Protect Register [AT91CAP9 revC only] */ -#define		AT91_PMC_PROTKEY	0x504d4301	/* Activation Code */ - -#define AT91_PMC_VER		(AT91_PMC + 0xfc)	/* PMC Module Version [AT91CAP9 only] */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91_ramc.h b/arch/arm/mach-at91/include/mach/at91_ramc.h new file mode 100644 index 00000000000..d8aeb278614 --- /dev/null +++ b/arch/arm/mach-at91/include/mach/at91_ramc.h @@ -0,0 +1,32 @@ +/* + * Header file for the Atmel RAM Controller + * + * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> + * + * Under GPLv2 only + */ + +#ifndef __AT91_RAMC_H__ +#define __AT91_RAMC_H__ + +#ifndef __ASSEMBLY__ +extern void __iomem *at91_ramc_base[]; + +#define at91_ramc_read(id, field) \ +	__raw_readl(at91_ramc_base[id] + field) + +#define at91_ramc_write(id, field, value) \ +	__raw_writel(value, at91_ramc_base[id] + field) +#else +.extern at91_ramc_base +#endif + +#define AT91_MEMCTRL_MC		0 +#define AT91_MEMCTRL_SDRAMC	1 +#define AT91_MEMCTRL_DDRSDR	2 + +#include <mach/at91rm9200_sdramc.h> +#include <mach/at91sam9_ddrsdr.h> +#include <mach/at91sam9_sdramc.h> + +#endif /* __AT91_RAMC_H__ */ diff --git a/arch/arm/mach-at91/include/mach/at91_rtc.h b/arch/arm/mach-at91/include/mach/at91_rtc.h deleted file mode 100644 index e56f4701a3e..00000000000 --- a/arch/arm/mach-at91/include/mach/at91_rtc.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_rtc.h - * - * Copyright (C) 2005 Ivan Kokshaysky - * Copyright (C) SAN People - * - * Real Time Clock (RTC) - System peripheral registers. - * Based on AT91RM9200 datasheet revision E. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91_RTC_H -#define AT91_RTC_H - -#define	AT91_RTC_CR		(AT91_RTC + 0x00)	/* Control Register */ -#define		AT91_RTC_UPDTIM		(1 <<  0)		/* Update Request Time Register */ -#define		AT91_RTC_UPDCAL		(1 <<  1)		/* Update Request Calendar Register */ -#define		AT91_RTC_TIMEVSEL	(3 <<  8)		/* Time Event Selection */ -#define			AT91_RTC_TIMEVSEL_MINUTE	(0 << 8) -#define			AT91_RTC_TIMEVSEL_HOUR		(1 << 8) -#define			AT91_RTC_TIMEVSEL_DAY24		(2 << 8) -#define			AT91_RTC_TIMEVSEL_DAY12		(3 << 8) -#define		AT91_RTC_CALEVSEL	(3 << 16)		/* Calendar Event Selection */ -#define			AT91_RTC_CALEVSEL_WEEK		(0 << 16) -#define			AT91_RTC_CALEVSEL_MONTH		(1 << 16) -#define			AT91_RTC_CALEVSEL_YEAR		(2 << 16) - -#define	AT91_RTC_MR		(AT91_RTC + 0x04)	/* Mode Register */ -#define			AT91_RTC_HRMOD		(1 <<  0)		/* 12/24 Hour Mode */ - -#define	AT91_RTC_TIMR		(AT91_RTC + 0x08)	/* Time Register */ -#define		AT91_RTC_SEC		(0x7f <<  0)		/* Current Second */ -#define		AT91_RTC_MIN		(0x7f <<  8)		/* Current Minute */ -#define		AT91_RTC_HOUR		(0x3f << 16)		/* Current Hour */ -#define		AT91_RTC_AMPM		(1    << 22)		/* Ante Meridiem Post Meridiem Indicator */ - -#define	AT91_RTC_CALR		(AT91_RTC + 0x0c)	/* Calendar Register */ -#define		AT91_RTC_CENT		(0x7f <<  0)		/* Current Century */ -#define		AT91_RTC_YEAR		(0xff <<  8)		/* Current Year */ -#define		AT91_RTC_MONTH		(0x1f << 16)		/* Current Month */ -#define		AT91_RTC_DAY		(7    << 21)		/* Current Day */ -#define		AT91_RTC_DATE		(0x3f << 24)		/* Current Date */ - -#define	AT91_RTC_TIMALR		(AT91_RTC + 0x10)	/* Time Alarm Register */ -#define		AT91_RTC_SECEN		(1 <<  7)		/* Second Alarm Enable */ -#define		AT91_RTC_MINEN		(1 << 15)		/* Minute Alarm Enable */ -#define		AT91_RTC_HOUREN		(1 << 23)		/* Hour Alarm Enable */ - -#define	AT91_RTC_CALALR		(AT91_RTC + 0x14)	/* Calendar Alarm Register */ -#define		AT91_RTC_MTHEN		(1 << 23)		/* Month Alarm Enable */ -#define		AT91_RTC_DATEEN		(1 << 31)		/* Date Alarm Enable */ - -#define	AT91_RTC_SR		(AT91_RTC + 0x18)	/* Status Register */ -#define		AT91_RTC_ACKUPD		(1 <<  0)		/* Acknowledge for Update */ -#define		AT91_RTC_ALARM		(1 <<  1)		/* Alarm Flag */ -#define		AT91_RTC_SECEV		(1 <<  2)		/* Second Event */ -#define		AT91_RTC_TIMEV		(1 <<  3)		/* Time Event */ -#define		AT91_RTC_CALEV		(1 <<  4)		/* Calendar Event */ - -#define	AT91_RTC_SCCR		(AT91_RTC + 0x1c)	/* Status Clear Command Register */ -#define	AT91_RTC_IER		(AT91_RTC + 0x20)	/* Interrupt Enable Register */ -#define	AT91_RTC_IDR		(AT91_RTC + 0x24)	/* Interrupt Disable Register */ -#define	AT91_RTC_IMR		(AT91_RTC + 0x28)	/* Interrupt Mask Register */ - -#define	AT91_RTC_VER		(AT91_RTC + 0x2c)	/* Valid Entry Register */ -#define		AT91_RTC_NVTIM		(1 <<  0)		/* Non valid Time */ -#define		AT91_RTC_NVCAL		(1 <<  1)		/* Non valid Calendar */ -#define		AT91_RTC_NVTIMALR	(1 <<  2)		/* Non valid Time Alarm */ -#define		AT91_RTC_NVCALALR	(1 <<  3)		/* Non valid Calendar Alarm */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91_spi.h b/arch/arm/mach-at91/include/mach/at91_spi.h deleted file mode 100644 index 2f6ba0c5636..00000000000 --- a/arch/arm/mach-at91/include/mach/at91_spi.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_spi.h - * - * Copyright (C) 2005 Ivan Kokshaysky - * Copyright (C) SAN People - * - * Serial Peripheral Interface (SPI) registers. - * Based on AT91RM9200 datasheet revision E. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91_SPI_H -#define AT91_SPI_H - -#define AT91_SPI_CR			0x00		/* Control Register */ -#define		AT91_SPI_SPIEN		(1 <<  0)		/* SPI Enable */ -#define		AT91_SPI_SPIDIS		(1 <<  1)		/* SPI Disable */ -#define		AT91_SPI_SWRST		(1 <<  7)		/* SPI Software Reset */ -#define		AT91_SPI_LASTXFER	(1 << 24)		/* Last Transfer [SAM9261 only] */ - -#define AT91_SPI_MR			0x04		/* Mode Register */ -#define		AT91_SPI_MSTR		(1    <<  0)		/* Master/Slave Mode */ -#define		AT91_SPI_PS		(1    <<  1)		/* Peripheral Select */ -#define			AT91_SPI_PS_FIXED	(0 << 1) -#define			AT91_SPI_PS_VARIABLE	(1 << 1) -#define		AT91_SPI_PCSDEC		(1    <<  2)		/* Chip Select Decode */ -#define		AT91_SPI_DIV32		(1    <<  3)		/* Clock Selection [AT91RM9200 only] */ -#define		AT91_SPI_MODFDIS	(1    <<  4)		/* Mode Fault Detection */ -#define		AT91_SPI_LLB		(1    <<  7)		/* Local Loopback Enable */ -#define		AT91_SPI_PCS		(0xf  << 16)		/* Peripheral Chip Select */ -#define		AT91_SPI_DLYBCS		(0xff << 24)		/* Delay Between Chip Selects */ - -#define AT91_SPI_RDR		0x08			/* Receive Data Register */ -#define		AT91_SPI_RD		(0xffff <<  0)		/* Receive Data */ -#define		AT91_SPI_PCS		(0xf	<< 16)		/* Peripheral Chip Select */ - -#define AT91_SPI_TDR		0x0c			/* Transmit Data Register */ -#define		AT91_SPI_TD		(0xffff <<  0)		/* Transmit Data */ -#define		AT91_SPI_PCS		(0xf	<< 16)		/* Peripheral Chip Select */ -#define		AT91_SPI_LASTXFER	(1	<< 24)		/* Last Transfer [SAM9261 only] */ - -#define AT91_SPI_SR		0x10			/* Status Register */ -#define		AT91_SPI_RDRF		(1 <<  0)		/* Receive Data Register Full */ -#define		AT91_SPI_TDRE		(1 <<  1)		/* Transmit Data Register Full */ -#define		AT91_SPI_MODF		(1 <<  2)		/* Mode Fault Error */ -#define		AT91_SPI_OVRES		(1 <<  3)		/* Overrun Error Status */ -#define		AT91_SPI_ENDRX		(1 <<  4)		/* End of RX buffer */ -#define		AT91_SPI_ENDTX		(1 <<  5)		/* End of TX buffer */ -#define		AT91_SPI_RXBUFF		(1 <<  6)		/* RX Buffer Full */ -#define		AT91_SPI_TXBUFE		(1 <<  7)		/* TX Buffer Empty */ -#define		AT91_SPI_NSSR		(1 <<  8)		/* NSS Rising [SAM9261 only] */ -#define		AT91_SPI_TXEMPTY	(1 <<  9)		/* Transmission Register Empty [SAM9261 only] */ -#define		AT91_SPI_SPIENS		(1 << 16)		/* SPI Enable Status */ - -#define AT91_SPI_IER		0x14			/* Interrupt Enable Register */ -#define AT91_SPI_IDR		0x18			/* Interrupt Disable Register */ -#define AT91_SPI_IMR		0x1c			/* Interrupt Mask Register */ - -#define AT91_SPI_CSR(n)		(0x30 + ((n) * 4))	/* Chip Select Registers 0-3 */ -#define		AT91_SPI_CPOL		(1    <<  0)		/* Clock Polarity */ -#define		AT91_SPI_NCPHA		(1    <<  1)		/* Clock Phase */ -#define		AT91_SPI_CSAAT		(1    <<  3)		/* Chip Select Active After Transfer [SAM9261 only] */ -#define		AT91_SPI_BITS		(0xf  <<  4)		/* Bits Per Transfer */ -#define			AT91_SPI_BITS_8		(0 << 4) -#define			AT91_SPI_BITS_9		(1 << 4) -#define			AT91_SPI_BITS_10	(2 << 4) -#define			AT91_SPI_BITS_11	(3 << 4) -#define			AT91_SPI_BITS_12	(4 << 4) -#define			AT91_SPI_BITS_13	(5 << 4) -#define			AT91_SPI_BITS_14	(6 << 4) -#define			AT91_SPI_BITS_15	(7 << 4) -#define			AT91_SPI_BITS_16	(8 << 4) -#define		AT91_SPI_SCBR		(0xff <<  8)		/* Serial Clock Baud Rate */ -#define		AT91_SPI_DLYBS		(0xff << 16)		/* Delay before SPCK */ -#define		AT91_SPI_DLYBCT		(0xff << 24)		/* Delay between Consecutive Transfers */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91_ssc.h b/arch/arm/mach-at91/include/mach/at91_ssc.h deleted file mode 100644 index a81114c11c7..00000000000 --- a/arch/arm/mach-at91/include/mach/at91_ssc.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_ssc.h - * - * Copyright (C) SAN People - * - * Serial Synchronous Controller (SSC) registers. - * Based on AT91RM9200 datasheet revision E. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91_SSC_H -#define AT91_SSC_H - -#define AT91_SSC_CR		0x00	/* Control Register */ -#define		AT91_SSC_RXEN		(1 <<  0)	/* Receive Enable */ -#define		AT91_SSC_RXDIS		(1 <<  1)	/* Receive Disable */ -#define		AT91_SSC_TXEN		(1 <<  8)	/* Transmit Enable */ -#define		AT91_SSC_TXDIS		(1 <<  9)	/* Transmit Disable */ -#define		AT91_SSC_SWRST		(1 << 15)	/* Software Reset */ - -#define AT91_SSC_CMR		0x04	/* Clock Mode Register */ -#define		AT91_SSC_CMR_DIV	(0xfff << 0)	/* Clock Divider */ - -#define AT91_SSC_RCMR		0x10	/* Receive Clock Mode Register */ -#define		AT91_SSC_CKS		(3    <<  0)	/* Clock Selection */ -#define			AT91_SSC_CKS_DIV		(0 << 0) -#define			AT91_SSC_CKS_CLOCK		(1 << 0) -#define			AT91_SSC_CKS_PIN		(2 << 0) -#define		AT91_SSC_CKO		(7    <<  2)	/* Clock Output Mode Selection */ -#define			AT91_SSC_CKO_NONE		(0 << 2) -#define			AT91_SSC_CKO_CONTINUOUS		(1 << 2) -#define		AT91_SSC_CKI		(1    <<  5)	/* Clock Inversion */ -#define			AT91_SSC_CKI_FALLING		(0 << 5) -#define			AT91_SSC_CK_RISING		(1 << 5) -#define		AT91_SSC_CKG		(1    <<  6)	/* Receive Clock Gating Selection [AT91SAM9261 only] */ -#define			AT91_SSC_CKG_NONE		(0 << 6) -#define			AT91_SSC_CKG_RFLOW		(1 << 6) -#define			AT91_SSC_CKG_RFHIGH		(2 << 6) -#define		AT91_SSC_START		(0xf  <<  8)	/* Start Selection */ -#define			AT91_SSC_START_CONTINUOUS	(0 << 8) -#define			AT91_SSC_START_TX_RX		(1 << 8) -#define			AT91_SSC_START_LOW_RF		(2 << 8) -#define			AT91_SSC_START_HIGH_RF		(3 << 8) -#define			AT91_SSC_START_FALLING_RF	(4 << 8) -#define			AT91_SSC_START_RISING_RF	(5 << 8) -#define			AT91_SSC_START_LEVEL_RF		(6 << 8) -#define			AT91_SSC_START_EDGE_RF		(7 << 8) -#define		AT91_SSC_STOP		(1    << 12)	/* Receive Stop Selection [AT91SAM9261 only] */ -#define		AT91_SSC_STTDLY		(0xff << 16)	/* Start Delay */ -#define		AT91_SSC_PERIOD		(0xff << 24)	/* Period Divider Selection */ - -#define AT91_SSC_RFMR		0x14	/* Receive Frame Mode Register */ -#define		AT91_SSC_DATALEN	(0x1f <<  0)	/* Data Length */ -#define		AT91_SSC_LOOP		(1    <<  5)	/* Loop Mode */ -#define		AT91_SSC_MSBF		(1    <<  7)	/* Most Significant Bit First */ -#define		AT91_SSC_DATNB		(0xf  <<  8)	/* Data Number per Frame */ -#define		AT91_SSC_FSLEN		(0xf  << 16)	/* Frame Sync Length */ -#define		AT91_SSC_FSOS		(7    << 20)	/* Frame Sync Output Selection */ -#define			AT91_SSC_FSOS_NONE		(0 << 20) -#define			AT91_SSC_FSOS_NEGATIVE		(1 << 20) -#define			AT91_SSC_FSOS_POSITIVE		(2 << 20) -#define			AT91_SSC_FSOS_LOW		(3 << 20) -#define			AT91_SSC_FSOS_HIGH		(4 << 20) -#define			AT91_SSC_FSOS_TOGGLE		(5 << 20) -#define		AT91_SSC_FSEDGE		(1    << 24)	/* Frame Sync Edge Detection */ -#define			AT91_SSC_FSEDGE_POSITIVE	(0 << 24) -#define			AT91_SSC_FSEDGE_NEGATIVE	(1 << 24) - -#define AT91_SSC_TCMR		0x18	/* Transmit Clock Mode Register */ -#define AT91_SSC_TFMR		0x1c	/* Transmit Fram Mode Register */ -#define		AT91_SSC_DATDEF		(1 <<  5)	/* Data Default Value */ -#define		AT91_SSC_FSDEN		(1 << 23)	/* Frame Sync Data Enable */ - -#define AT91_SSC_RHR		0x20	/* Receive Holding Register */ -#define AT91_SSC_THR		0x24	/* Transmit Holding Register */ -#define AT91_SSC_RSHR		0x30	/* Receive Sync Holding Register */ -#define AT91_SSC_TSHR		0x34	/* Transmit Sync Holding Register */ - -#define AT91_SSC_RC0R		0x38	/* Receive Compare 0 Register [AT91SAM9261 only] */ -#define AT91_SSC_RC1R		0x3c	/* Receive Compare 1 Register [AT91SAM9261 only] */ - -#define AT91_SSC_SR		0x40	/* Status Register */ -#define		AT91_SSC_TXRDY		(1 <<  0)	/* Transmit Ready */ -#define		AT91_SSC_TXEMPTY	(1 <<  1)	/* Transmit Empty */ -#define		AT91_SSC_ENDTX		(1 <<  2)	/* End of Transmission */ -#define		AT91_SSC_TXBUFE		(1 <<  3)	/* Transmit Buffer Empty */ -#define		AT91_SSC_RXRDY		(1 <<  4)	/* Receive Ready */ -#define		AT91_SSC_OVRUN		(1 <<  5)	/* Receive Overrun */ -#define		AT91_SSC_ENDRX		(1 <<  6)	/* End of Reception */ -#define		AT91_SSC_RXBUFF		(1 <<  7)	/* Receive Buffer Full */ -#define		AT91_SSC_CP0		(1 <<  8)	/* Compare 0 [AT91SAM9261 only] */ -#define		AT91_SSC_CP1		(1 <<  9)	/* Compare 1 [AT91SAM9261 only] */ -#define		AT91_SSC_TXSYN		(1 << 10)	/* Transmit Sync */ -#define		AT91_SSC_RXSYN		(1 << 11)	/* Receive Sync */ -#define		AT91_SSC_TXENA		(1 << 16)	/* Transmit Enable */ -#define		AT91_SSC_RXENA		(1 << 17)	/* Receive Enable */ - -#define AT91_SSC_IER		0x44	/* Interrupt Enable Register */ -#define AT91_SSC_IDR		0x48	/* Interrupt Disable Register */ -#define AT91_SSC_IMR		0x4c	/* Interrupt Mask Register */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91_st.h b/arch/arm/mach-at91/include/mach/at91_st.h index 8847173e410..67fdbd13c3e 100644 --- a/arch/arm/mach-at91/include/mach/at91_st.h +++ b/arch/arm/mach-at91/include/mach/at91_st.h @@ -16,34 +16,46 @@  #ifndef AT91_ST_H  #define AT91_ST_H -#define	AT91_ST_CR		(AT91_ST + 0x00)	/* Control Register */ +#ifndef __ASSEMBLY__ +extern void __iomem *at91_st_base; + +#define at91_st_read(field) \ +	__raw_readl(at91_st_base + field) + +#define at91_st_write(field, value) \ +	__raw_writel(value, at91_st_base + field) +#else +.extern at91_st_base +#endif + +#define	AT91_ST_CR		0x00			/* Control Register */  #define 	AT91_ST_WDRST		(1 << 0)		/* Watchdog Timer Restart */ -#define	AT91_ST_PIMR		(AT91_ST + 0x04)	/* Period Interval Mode Register */ +#define	AT91_ST_PIMR		0x04			/* Period Interval Mode Register */  #define		AT91_ST_PIV		(0xffff <<  0)		/* Period Interval Value */ -#define	AT91_ST_WDMR		(AT91_ST + 0x08)	/* Watchdog Mode Register */ +#define	AT91_ST_WDMR		0x08			/* Watchdog Mode Register */  #define		AT91_ST_WDV		(0xffff <<  0)		/* Watchdog Counter Value */  #define		AT91_ST_RSTEN		(1	<< 16)		/* Reset Enable */  #define		AT91_ST_EXTEN		(1	<< 17)		/* External Signal Assertion Enable */ -#define	AT91_ST_RTMR		(AT91_ST + 0x0c)	/* Real-time Mode Register */ +#define	AT91_ST_RTMR		0x0c			/* Real-time Mode Register */  #define		AT91_ST_RTPRES		(0xffff <<  0)		/* Real-time Prescalar Value */ -#define	AT91_ST_SR		(AT91_ST + 0x10)	/* Status Register */ +#define	AT91_ST_SR		0x10			/* Status Register */  #define		AT91_ST_PITS		(1 << 0)		/* Period Interval Timer Status */  #define		AT91_ST_WDOVF		(1 << 1) 		/* Watchdog Overflow */  #define		AT91_ST_RTTINC		(1 << 2) 		/* Real-time Timer Increment */  #define		AT91_ST_ALMS		(1 << 3) 		/* Alarm Status */ -#define	AT91_ST_IER		(AT91_ST + 0x14)	/* Interrupt Enable Register */ -#define	AT91_ST_IDR		(AT91_ST + 0x18)	/* Interrupt Disable Register */ -#define	AT91_ST_IMR		(AT91_ST + 0x1c)	/* Interrupt Mask Register */ +#define	AT91_ST_IER		0x14			/* Interrupt Enable Register */ +#define	AT91_ST_IDR		0x18			/* Interrupt Disable Register */ +#define	AT91_ST_IMR		0x1c			/* Interrupt Mask Register */ -#define	AT91_ST_RTAR		(AT91_ST + 0x20)	/* Real-time Alarm Register */ +#define	AT91_ST_RTAR		0x20			/* Real-time Alarm Register */  #define		AT91_ST_ALMV		(0xfffff << 0)		/* Alarm Value */ -#define	AT91_ST_CRTR		(AT91_ST + 0x24)	/* Current Real-time Register */ +#define	AT91_ST_CRTR		0x24			/* Current Real-time Register */  #define		AT91_ST_CRTV		(0xfffff << 0)		/* Current Real-Time Value */  #endif diff --git a/arch/arm/mach-at91/include/mach/at91_twi.h b/arch/arm/mach-at91/include/mach/at91_twi.h deleted file mode 100644 index bb2880f6ba3..00000000000 --- a/arch/arm/mach-at91/include/mach/at91_twi.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_twi.h - * - * Copyright (C) 2005 Ivan Kokshaysky - * Copyright (C) SAN People - * - * Two-wire Interface (TWI) registers. - * Based on AT91RM9200 datasheet revision E. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91_TWI_H -#define AT91_TWI_H - -#define	AT91_TWI_CR		0x00		/* Control Register */ -#define		AT91_TWI_START		(1 <<  0)	/* Send a Start Condition */ -#define		AT91_TWI_STOP		(1 <<  1)	/* Send a Stop Condition */ -#define		AT91_TWI_MSEN		(1 <<  2)	/* Master Transfer Enable */ -#define		AT91_TWI_MSDIS		(1 <<  3)	/* Master Transfer Disable */ -#define		AT91_TWI_SVEN		(1 <<  4)	/* Slave Transfer Enable [SAM9260 only] */ -#define		AT91_TWI_SVDIS		(1 <<  5)	/* Slave Transfer Disable [SAM9260 only] */ -#define		AT91_TWI_SWRST		(1 <<  7)	/* Software Reset */ - -#define	AT91_TWI_MMR		0x04		/* Master Mode Register */ -#define		AT91_TWI_IADRSZ		(3    <<  8)	/* Internal Device Address Size */ -#define			AT91_TWI_IADRSZ_NO		(0 << 8) -#define			AT91_TWI_IADRSZ_1		(1 << 8) -#define			AT91_TWI_IADRSZ_2		(2 << 8) -#define			AT91_TWI_IADRSZ_3		(3 << 8) -#define		AT91_TWI_MREAD		(1    << 12)	/* Master Read Direction */ -#define		AT91_TWI_DADR		(0x7f << 16)	/* Device Address */ - -#define	AT91_TWI_SMR		0x08		/* Slave Mode Register [SAM9260 only] */ -#define		AT91_TWI_SADR		(0x7f << 16)	/* Slave Address */ - -#define	AT91_TWI_IADR		0x0c		/* Internal Address Register */ - -#define	AT91_TWI_CWGR		0x10		/* Clock Waveform Generator Register */ -#define		AT91_TWI_CLDIV		(0xff <<  0)	/* Clock Low Divisor */ -#define		AT91_TWI_CHDIV		(0xff <<  8)	/* Clock High Divisor */ -#define		AT91_TWI_CKDIV		(7    << 16)	/* Clock Divider */ - -#define	AT91_TWI_SR		0x20		/* Status Register */ -#define		AT91_TWI_TXCOMP		(1 <<  0)	/* Transmission Complete */ -#define		AT91_TWI_RXRDY		(1 <<  1)	/* Receive Holding Register Ready */ -#define		AT91_TWI_TXRDY		(1 <<  2)	/* Transmit Holding Register Ready */ -#define		AT91_TWI_SVREAD		(1 <<  3)	/* Slave Read [SAM9260 only] */ -#define		AT91_TWI_SVACC		(1 <<  4)	/* Slave Access [SAM9260 only] */ -#define		AT91_TWI_GACC		(1 <<  5)	/* General Call Access [SAM9260 only] */ -#define		AT91_TWI_OVRE		(1 <<  6)	/* Overrun Error [AT91RM9200 only] */ -#define		AT91_TWI_UNRE		(1 <<  7)	/* Underrun Error [AT91RM9200 only] */ -#define		AT91_TWI_NACK		(1 <<  8)	/* Not Acknowledged */ -#define		AT91_TWI_ARBLST		(1 <<  9)	/* Arbitration Lost [SAM9260 only] */ -#define		AT91_TWI_SCLWS		(1 << 10)	/* Clock Wait State [SAM9260 only] */ -#define		AT91_TWI_EOSACC		(1 << 11)	/* End of Slave Address [SAM9260 only] */ - -#define	AT91_TWI_IER		0x24		/* Interrupt Enable Register */ -#define	AT91_TWI_IDR		0x28		/* Interrupt Disable Register */ -#define	AT91_TWI_IMR		0x2c		/* Interrupt Mask Register */ -#define	AT91_TWI_RHR		0x30		/* Receive Holding Register */ -#define	AT91_TWI_THR		0x34		/* Transmit Holding Register */ - -#endif - diff --git a/arch/arm/mach-at91/include/mach/at91_wdt.h b/arch/arm/mach-at91/include/mach/at91_wdt.h deleted file mode 100644 index fecc2e9f0ca..00000000000 --- a/arch/arm/mach-at91/include/mach/at91_wdt.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_wdt.h - * - * Copyright (C) 2007 Andrew Victor - * Copyright (C) 2007 Atmel Corporation. - * - * Watchdog Timer (WDT) - System peripherals regsters. - * Based on AT91SAM9261 datasheet revision D. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91_WDT_H -#define AT91_WDT_H - -#define AT91_WDT_CR		(AT91_WDT + 0x00)	/* Watchdog Control Register */ -#define		AT91_WDT_WDRSTT		(1    << 0)		/* Restart */ -#define		AT91_WDT_KEY		(0xa5 << 24)		/* KEY Password */ - -#define AT91_WDT_MR		(AT91_WDT + 0x04)	/* Watchdog Mode Register */ -#define		AT91_WDT_WDV		(0xfff << 0)		/* Counter Value */ -#define		AT91_WDT_WDFIEN		(1     << 12)		/* Fault Interrupt Enable */ -#define		AT91_WDT_WDRSTEN	(1     << 13)		/* Reset Processor */ -#define		AT91_WDT_WDRPROC	(1     << 14)		/* Timer Restart */ -#define		AT91_WDT_WDDIS		(1     << 15)		/* Watchdog Disable */ -#define		AT91_WDT_WDD		(0xfff << 16)		/* Delta Value */ -#define		AT91_WDT_WDDBGHLT	(1     << 28)		/* Debug Halt */ -#define		AT91_WDT_WDIDLEHLT	(1     << 29)		/* Idle Halt */ - -#define AT91_WDT_SR		(AT91_WDT + 0x08)	/* Watchdog Status Register */ -#define		AT91_WDT_WDUNF		(1 << 0)		/* Watchdog Underflow */ -#define		AT91_WDT_WDERR		(1 << 1)		/* Watchdog Error */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91cap9.h b/arch/arm/mach-at91/include/mach/at91cap9.h deleted file mode 100644 index 9c6af973748..00000000000 --- a/arch/arm/mach-at91/include/mach/at91cap9.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91cap9.h - * - *  Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com> - *  Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com> - *  Copyright (C) 2007 Atmel Corporation. - * - * Common definitions. - * Based on AT91CAP9 datasheet revision B (Preliminary). - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91CAP9_H -#define AT91CAP9_H - -/* - * Peripheral identifiers/interrupts. - */ -#define AT91_ID_FIQ		0	/* Advanced Interrupt Controller (FIQ) */ -#define AT91_ID_SYS		1	/* System Peripherals */ -#define AT91CAP9_ID_PIOABCD	2	/* Parallel IO Controller A, B, C and D */ -#define AT91CAP9_ID_MPB0	3	/* MP Block Peripheral 0 */ -#define AT91CAP9_ID_MPB1	4	/* MP Block Peripheral 1 */ -#define AT91CAP9_ID_MPB2	5	/* MP Block Peripheral 2 */ -#define AT91CAP9_ID_MPB3	6	/* MP Block Peripheral 3 */ -#define AT91CAP9_ID_MPB4	7	/* MP Block Peripheral 4 */ -#define AT91CAP9_ID_US0		8	/* USART 0 */ -#define AT91CAP9_ID_US1		9	/* USART 1 */ -#define AT91CAP9_ID_US2		10	/* USART 2 */ -#define AT91CAP9_ID_MCI0	11	/* Multimedia Card Interface 0 */ -#define AT91CAP9_ID_MCI1	12	/* Multimedia Card Interface 1 */ -#define AT91CAP9_ID_CAN		13	/* CAN */ -#define AT91CAP9_ID_TWI		14	/* Two-Wire Interface */ -#define AT91CAP9_ID_SPI0	15	/* Serial Peripheral Interface 0 */ -#define AT91CAP9_ID_SPI1	16	/* Serial Peripheral Interface 0 */ -#define AT91CAP9_ID_SSC0	17	/* Serial Synchronous Controller 0 */ -#define AT91CAP9_ID_SSC1	18	/* Serial Synchronous Controller 1 */ -#define AT91CAP9_ID_AC97C	19	/* AC97 Controller */ -#define AT91CAP9_ID_TCB		20	/* Timer Counter 0, 1 and 2 */ -#define AT91CAP9_ID_PWMC	21	/* Pulse Width Modulation Controller */ -#define AT91CAP9_ID_EMAC	22	/* Ethernet */ -#define AT91CAP9_ID_AESTDES	23	/* Advanced Encryption Standard, Triple DES */ -#define AT91CAP9_ID_ADC		24	/* Analog-to-Digital Converter */ -#define AT91CAP9_ID_ISI		25	/* Image Sensor Interface */ -#define AT91CAP9_ID_LCDC	26	/* LCD Controller */ -#define AT91CAP9_ID_DMA		27	/* DMA Controller */ -#define AT91CAP9_ID_UDPHS	28	/* USB High Speed Device Port */ -#define AT91CAP9_ID_UHP		29	/* USB Host Port */ -#define AT91CAP9_ID_IRQ0	30	/* Advanced Interrupt Controller (IRQ0) */ -#define AT91CAP9_ID_IRQ1	31	/* Advanced Interrupt Controller (IRQ1) */ - -/* - * User Peripheral physical base addresses. - */ -#define AT91CAP9_BASE_UDPHS		0xfff78000 -#define AT91CAP9_BASE_TCB0		0xfff7c000 -#define AT91CAP9_BASE_TC0		0xfff7c000 -#define AT91CAP9_BASE_TC1		0xfff7c040 -#define AT91CAP9_BASE_TC2		0xfff7c080 -#define AT91CAP9_BASE_MCI0		0xfff80000 -#define AT91CAP9_BASE_MCI1		0xfff84000 -#define AT91CAP9_BASE_TWI		0xfff88000 -#define AT91CAP9_BASE_US0		0xfff8c000 -#define AT91CAP9_BASE_US1		0xfff90000 -#define AT91CAP9_BASE_US2		0xfff94000 -#define AT91CAP9_BASE_SSC0		0xfff98000 -#define AT91CAP9_BASE_SSC1		0xfff9c000 -#define AT91CAP9_BASE_AC97C		0xfffa0000 -#define AT91CAP9_BASE_SPI0		0xfffa4000 -#define AT91CAP9_BASE_SPI1		0xfffa8000 -#define AT91CAP9_BASE_CAN		0xfffac000 -#define AT91CAP9_BASE_PWMC		0xfffb8000 -#define AT91CAP9_BASE_EMAC		0xfffbc000 -#define AT91CAP9_BASE_ADC		0xfffc0000 -#define AT91CAP9_BASE_ISI		0xfffc4000 -#define AT91_BASE_SYS			0xffffe200 - -/* - * System Peripherals (offset from AT91_BASE_SYS) - */ -#define AT91_ECC	(0xffffe200 - AT91_BASE_SYS) -#define AT91_BCRAMC	(0xffffe400 - AT91_BASE_SYS) -#define AT91_DDRSDRC0	(0xffffe600 - AT91_BASE_SYS) -#define AT91_SMC	(0xffffe800 - AT91_BASE_SYS) -#define AT91_MATRIX	(0xffffea00 - AT91_BASE_SYS) -#define AT91_CCFG	(0xffffeb10 - AT91_BASE_SYS) -#define AT91_DMA	(0xffffec00 - AT91_BASE_SYS) -#define AT91_DBGU	(0xffffee00 - AT91_BASE_SYS) -#define AT91_AIC	(0xfffff000 - AT91_BASE_SYS) -#define AT91_PIOA	(0xfffff200 - AT91_BASE_SYS) -#define AT91_PIOB	(0xfffff400 - AT91_BASE_SYS) -#define AT91_PIOC	(0xfffff600 - AT91_BASE_SYS) -#define AT91_PIOD	(0xfffff800 - AT91_BASE_SYS) -#define AT91_PMC	(0xfffffc00 - AT91_BASE_SYS) -#define AT91_RSTC	(0xfffffd00 - AT91_BASE_SYS) -#define AT91_SHDWC	(0xfffffd10 - AT91_BASE_SYS) -#define AT91_RTT	(0xfffffd20 - AT91_BASE_SYS) -#define AT91_PIT	(0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT	(0xfffffd40 - AT91_BASE_SYS) -#define AT91_GPBR	(cpu_is_at91cap9_revB() ?	\ -			(0xfffffd50 - AT91_BASE_SYS) :	\ -			(0xfffffd60 - AT91_BASE_SYS)) - -#define AT91_USART0	AT91CAP9_BASE_US0 -#define AT91_USART1	AT91CAP9_BASE_US1 -#define AT91_USART2	AT91CAP9_BASE_US2 - - -/* - * Internal Memory. - */ -#define AT91CAP9_SRAM_BASE	0x00100000	/* Internal SRAM base address */ -#define AT91CAP9_SRAM_SIZE	(32 * SZ_1K)	/* Internal SRAM size (32Kb) */ - -#define AT91CAP9_ROM_BASE	0x00400000	/* Internal ROM base address */ -#define AT91CAP9_ROM_SIZE	(32 * SZ_1K)	/* Internal ROM size (32Kb) */ - -#define AT91CAP9_LCDC_BASE	0x00500000	/* LCD Controller */ -#define AT91CAP9_UDPHS_FIFO	0x00600000	/* USB High Speed Device Port */ -#define AT91CAP9_UHP_BASE	0x00700000	/* USB Host controller */ - -#define CONFIG_DRAM_BASE	AT91_CHIPSELECT_6 - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h b/arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h deleted file mode 100644 index 976f4a6c335..00000000000 --- a/arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h - * - *  (C) 2008 Andrew Victor - * - * DDR/SDR Controller (DDRSDRC) - System peripherals registers. - * Based on AT91CAP9 datasheet revision B. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91CAP9_DDRSDR_H -#define AT91CAP9_DDRSDR_H - -#define AT91_DDRSDRC_MR		0x00	/* Mode Register */ -#define		AT91_DDRSDRC_MODE	(0xf << 0)		/* Command Mode */ -#define			AT91_DDRSDRC_MODE_NORMAL		0 -#define			AT91_DDRSDRC_MODE_NOP		1 -#define			AT91_DDRSDRC_MODE_PRECHARGE	2 -#define			AT91_DDRSDRC_MODE_LMR		3 -#define			AT91_DDRSDRC_MODE_REFRESH	4 -#define			AT91_DDRSDRC_MODE_EXT_LMR	5 -#define			AT91_DDRSDRC_MODE_DEEP		6 - -#define AT91_DDRSDRC_RTR	0x04	/* Refresh Timer Register */ -#define		AT91_DDRSDRC_COUNT	(0xfff << 0)		/* Refresh Timer Counter */ - -#define AT91_DDRSDRC_CR		0x08	/* Configuration Register */ -#define		AT91_DDRSDRC_NC		(3 << 0)		/* Number of Column Bits */ -#define			AT91_DDRSDRC_NC_SDR8	(0 << 0) -#define			AT91_DDRSDRC_NC_SDR9	(1 << 0) -#define			AT91_DDRSDRC_NC_SDR10	(2 << 0) -#define			AT91_DDRSDRC_NC_SDR11	(3 << 0) -#define			AT91_DDRSDRC_NC_DDR9	(0 << 0) -#define			AT91_DDRSDRC_NC_DDR10	(1 << 0) -#define			AT91_DDRSDRC_NC_DDR11	(2 << 0) -#define			AT91_DDRSDRC_NC_DDR12	(3 << 0) -#define		AT91_DDRSDRC_NR		(3 << 2)		/* Number of Row Bits */ -#define			AT91_DDRSDRC_NR_11	(0 << 2) -#define			AT91_DDRSDRC_NR_12	(1 << 2) -#define			AT91_DDRSDRC_NR_13	(2 << 2) -#define		AT91_DDRSDRC_CAS	(7 << 4)		/* CAS Latency */ -#define			AT91_DDRSDRC_CAS_2	(2 << 4) -#define			AT91_DDRSDRC_CAS_3	(3 << 4) -#define			AT91_DDRSDRC_CAS_25	(6 << 4) -#define		AT91_DDRSDRC_DLL	(1 << 7)		/* Reset DLL */ -#define		AT91_DDRSDRC_DICDS	(1 << 8)		/* Output impedance control */ - -#define AT91_DDRSDRC_T0PR	0x0C	/* Timing 0 Register */ -#define		AT91_DDRSDRC_TRAS	(0xf <<  0)		/* Active to Precharge delay */ -#define		AT91_DDRSDRC_TRCD	(0xf <<  4)		/* Row to Column delay */ -#define		AT91_DDRSDRC_TWR	(0xf <<  8)		/* Write recovery delay */ -#define		AT91_DDRSDRC_TRC	(0xf << 12)		/* Row cycle delay */ -#define		AT91_DDRSDRC_TRP	(0xf << 16)		/* Row precharge delay */ -#define		AT91_DDRSDRC_TRRD	(0xf << 20)		/* Active BankA to BankB */ -#define		AT91_DDRSDRC_TWTR	(1   << 24)		/* Internal Write to Read delay */ -#define		AT91_DDRSDRC_TMRD	(0xf << 28)		/* Load mode to active/refresh delay */ - -#define AT91_DDRSDRC_T1PR	0x10	/* Timing 1 Register */ -#define		AT91_DDRSDRC_TRFC	(0x1f << 0)		/* Row Cycle Delay */ -#define		AT91_DDRSDRC_TXSNR	(0xff << 8)		/* Exit self-refresh to non-read */ -#define		AT91_DDRSDRC_TXSRD	(0xff << 16)		/* Exit self-refresh to read */ -#define		AT91_DDRSDRC_TXP	(0xf  << 24)		/* Exit power-down delay */ - -#define AT91_DDRSDRC_LPR	0x18	/* Low Power Register */ -#define		AT91_DDRSDRC_LPCB		(3 << 0)	/* Low-power Configurations */ -#define			AT91_DDRSDRC_LPCB_DISABLE		0 -#define			AT91_DDRSDRC_LPCB_SELF_REFRESH		1 -#define			AT91_DDRSDRC_LPCB_POWER_DOWN		2 -#define			AT91_DDRSDRC_LPCB_DEEP_POWER_DOWN	3 -#define		AT91_DDRSDRC_CLKFR		(1 << 2)	/* Clock Frozen */ -#define		AT91_DDRSDRC_PASR		(7 << 4)	/* Partial Array Self Refresh */ -#define		AT91_DDRSDRC_TCSR		(3 << 8)	/* Temperature Compensated Self Refresh */ -#define		AT91_DDRSDRC_DS			(3 << 10)	/* Drive Strength */ -#define		AT91_DDRSDRC_TIMEOUT		(3 << 12)	/* Time to define when Low Power Mode is enabled */ -#define			AT91_DDRSDRC_TIMEOUT_0_CLK_CYCLES	(0 << 12) -#define			AT91_DDRSDRC_TIMEOUT_64_CLK_CYCLES	(1 << 12) -#define			AT91_DDRSDRC_TIMEOUT_128_CLK_CYCLES	(2 << 12) - -#define AT91_DDRSDRC_MDR	0x1C	/* Memory Device Register */ -#define		AT91_DDRSDRC_MD		(3 << 0)		/* Memory Device Type */ -#define			AT91_DDRSDRC_MD_SDR		0 -#define			AT91_DDRSDRC_MD_LOW_POWER_SDR	1 -#define			AT91_DDRSDRC_MD_DDR		2 -#define			AT91_DDRSDRC_MD_LOW_POWER_DDR	3 - -#define AT91_DDRSDRC_DLLR	0x20	/* DLL Information Register */ -#define		AT91_DDRSDRC_MDINC	(1 << 0)		/* Master Delay increment */ -#define		AT91_DDRSDRC_MDDEC	(1 << 1)		/* Master Delay decrement */ -#define		AT91_DDRSDRC_MDOVF	(1 << 2)		/* Master Delay Overflow */ -#define		AT91_DDRSDRC_SDCOVF	(1 << 3)		/* Slave Delay Correction Overflow */ -#define		AT91_DDRSDRC_SDCUDF	(1 << 4)		/* Slave Delay Correction Underflow */ -#define		AT91_DDRSDRC_SDERF	(1 << 5)		/* Slave Delay Correction error */ -#define		AT91_DDRSDRC_MDVAL	(0xff <<  8)		/* Master Delay value */ -#define		AT91_DDRSDRC_SDVAL	(0xff << 16)		/* Slave Delay value */ -#define		AT91_DDRSDRC_SDCVAL	(0xff << 24)		/* Slave Delay Correction value */ - -/* Register access macros */ -#define at91_ramc_read(num, reg) \ -	at91_sys_read(AT91_DDRSDRC##num + reg) -#define at91_ramc_write(num, reg, value) \ -	at91_sys_write(AT91_DDRSDRC##num + reg, value) - - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91cap9_matrix.h b/arch/arm/mach-at91/include/mach/at91cap9_matrix.h deleted file mode 100644 index 4b9d4aff4b4..00000000000 --- a/arch/arm/mach-at91/include/mach/at91cap9_matrix.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91cap9_matrix.h - * - *  Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com> - *  Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com> - *  Copyright (C) 2006 Atmel Corporation. - * - * Memory Controllers (MATRIX, EBI) - System peripherals registers. - * Based on AT91CAP9 datasheet revision B (Preliminary). - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91CAP9_MATRIX_H -#define AT91CAP9_MATRIX_H - -#define AT91_MATRIX_MCFG0	(AT91_MATRIX + 0x00)	/* Master Configuration Register 0 */ -#define AT91_MATRIX_MCFG1	(AT91_MATRIX + 0x04)	/* Master Configuration Register 1 */ -#define AT91_MATRIX_MCFG2	(AT91_MATRIX + 0x08)	/* Master Configuration Register 2 */ -#define AT91_MATRIX_MCFG3	(AT91_MATRIX + 0x0C)	/* Master Configuration Register 3 */ -#define AT91_MATRIX_MCFG4	(AT91_MATRIX + 0x10)	/* Master Configuration Register 4 */ -#define AT91_MATRIX_MCFG5	(AT91_MATRIX + 0x14)	/* Master Configuration Register 5 */ -#define AT91_MATRIX_MCFG6	(AT91_MATRIX + 0x18)	/* Master Configuration Register 6 */ -#define AT91_MATRIX_MCFG7	(AT91_MATRIX + 0x1C)	/* Master Configuration Register 7 */ -#define AT91_MATRIX_MCFG8	(AT91_MATRIX + 0x20)	/* Master Configuration Register 8 */ -#define AT91_MATRIX_MCFG9	(AT91_MATRIX + 0x24)	/* Master Configuration Register 9 */ -#define AT91_MATRIX_MCFG10	(AT91_MATRIX + 0x28)	/* Master Configuration Register 10 */ -#define AT91_MATRIX_MCFG11	(AT91_MATRIX + 0x2C)	/* Master Configuration Register 11 */ -#define		AT91_MATRIX_ULBT	(7 << 0)	/* Undefined Length Burst Type */ -#define			AT91_MATRIX_ULBT_INFINITE	(0 << 0) -#define			AT91_MATRIX_ULBT_SINGLE		(1 << 0) -#define			AT91_MATRIX_ULBT_FOUR		(2 << 0) -#define			AT91_MATRIX_ULBT_EIGHT		(3 << 0) -#define			AT91_MATRIX_ULBT_SIXTEEN	(4 << 0) - -#define AT91_MATRIX_SCFG0	(AT91_MATRIX + 0x40)	/* Slave Configuration Register 0 */ -#define AT91_MATRIX_SCFG1	(AT91_MATRIX + 0x44)	/* Slave Configuration Register 1 */ -#define AT91_MATRIX_SCFG2	(AT91_MATRIX + 0x48)	/* Slave Configuration Register 2 */ -#define AT91_MATRIX_SCFG3	(AT91_MATRIX + 0x4C)	/* Slave Configuration Register 3 */ -#define AT91_MATRIX_SCFG4	(AT91_MATRIX + 0x50)	/* Slave Configuration Register 4 */ -#define AT91_MATRIX_SCFG5	(AT91_MATRIX + 0x54)	/* Slave Configuration Register 5 */ -#define AT91_MATRIX_SCFG6	(AT91_MATRIX + 0x58)	/* Slave Configuration Register 6 */ -#define AT91_MATRIX_SCFG7	(AT91_MATRIX + 0x5C)	/* Slave Configuration Register 7 */ -#define AT91_MATRIX_SCFG8	(AT91_MATRIX + 0x60)	/* Slave Configuration Register 8 */ -#define AT91_MATRIX_SCFG9	(AT91_MATRIX + 0x64)	/* Slave Configuration Register 9 */ -#define		AT91_MATRIX_SLOT_CYCLE		(0xff << 0)	/* Maximum Number of Allowed Cycles for a Burst */ -#define		AT91_MATRIX_DEFMSTR_TYPE	(3    << 16)	/* Default Master Type */ -#define			AT91_MATRIX_DEFMSTR_TYPE_NONE	(0 << 16) -#define			AT91_MATRIX_DEFMSTR_TYPE_LAST	(1 << 16) -#define			AT91_MATRIX_DEFMSTR_TYPE_FIXED	(2 << 16) -#define		AT91_MATRIX_FIXED_DEFMSTR	(0xf  << 18)	/* Fixed Index of Default Master */ -#define		AT91_MATRIX_ARBT		(3    << 24)	/* Arbitration Type */ -#define			AT91_MATRIX_ARBT_ROUND_ROBIN	(0 << 24) -#define			AT91_MATRIX_ARBT_FIXED_PRIORITY	(1 << 24) - -#define AT91_MATRIX_PRAS0	(AT91_MATRIX + 0x80)	/* Priority Register A for Slave 0 */ -#define AT91_MATRIX_PRBS0	(AT91_MATRIX + 0x84)	/* Priority Register B for Slave 0 */ -#define AT91_MATRIX_PRAS1	(AT91_MATRIX + 0x88)	/* Priority Register A for Slave 1 */ -#define AT91_MATRIX_PRBS1	(AT91_MATRIX + 0x8C)	/* Priority Register B for Slave 1 */ -#define AT91_MATRIX_PRAS2	(AT91_MATRIX + 0x90)	/* Priority Register A for Slave 2 */ -#define AT91_MATRIX_PRBS2	(AT91_MATRIX + 0x94)	/* Priority Register B for Slave 2 */ -#define AT91_MATRIX_PRAS3	(AT91_MATRIX + 0x98)	/* Priority Register A for Slave 3 */ -#define AT91_MATRIX_PRBS3	(AT91_MATRIX + 0x9C)	/* Priority Register B for Slave 3 */ -#define AT91_MATRIX_PRAS4	(AT91_MATRIX + 0xA0)	/* Priority Register A for Slave 4 */ -#define AT91_MATRIX_PRBS4	(AT91_MATRIX + 0xA4)	/* Priority Register B for Slave 4 */ -#define AT91_MATRIX_PRAS5	(AT91_MATRIX + 0xA8)	/* Priority Register A for Slave 5 */ -#define AT91_MATRIX_PRBS5	(AT91_MATRIX + 0xAC)	/* Priority Register B for Slave 5 */ -#define AT91_MATRIX_PRAS6	(AT91_MATRIX + 0xB0)	/* Priority Register A for Slave 6 */ -#define AT91_MATRIX_PRBS6	(AT91_MATRIX + 0xB4)	/* Priority Register B for Slave 6 */ -#define AT91_MATRIX_PRAS7	(AT91_MATRIX + 0xB8)	/* Priority Register A for Slave 7 */ -#define AT91_MATRIX_PRBS7	(AT91_MATRIX + 0xBC)	/* Priority Register B for Slave 7 */ -#define AT91_MATRIX_PRAS8	(AT91_MATRIX + 0xC0)	/* Priority Register A for Slave 8 */ -#define AT91_MATRIX_PRBS8	(AT91_MATRIX + 0xC4)	/* Priority Register B for Slave 8 */ -#define AT91_MATRIX_PRAS9	(AT91_MATRIX + 0xC8)	/* Priority Register A for Slave 9 */ -#define AT91_MATRIX_PRBS9	(AT91_MATRIX + 0xCC)	/* Priority Register B for Slave 9 */ -#define		AT91_MATRIX_M0PR		(3 << 0)	/* Master 0 Priority */ -#define		AT91_MATRIX_M1PR		(3 << 4)	/* Master 1 Priority */ -#define		AT91_MATRIX_M2PR		(3 << 8)	/* Master 2 Priority */ -#define		AT91_MATRIX_M3PR		(3 << 12)	/* Master 3 Priority */ -#define		AT91_MATRIX_M4PR		(3 << 16)	/* Master 4 Priority */ -#define		AT91_MATRIX_M5PR		(3 << 20)	/* Master 5 Priority */ -#define		AT91_MATRIX_M6PR		(3 << 24)	/* Master 6 Priority */ -#define		AT91_MATRIX_M7PR		(3 << 28)	/* Master 7 Priority */ -#define		AT91_MATRIX_M8PR		(3 << 0)	/* Master 8 Priority (in Register B) */ -#define		AT91_MATRIX_M9PR		(3 << 4)	/* Master 9 Priority (in Register B) */ -#define		AT91_MATRIX_M10PR		(3 << 8)	/* Master 10 Priority (in Register B) */ -#define		AT91_MATRIX_M11PR		(3 << 12)	/* Master 11 Priority (in Register B) */ - -#define AT91_MATRIX_MRCR	(AT91_MATRIX + 0x100)	/* Master Remap Control Register */ -#define		AT91_MATRIX_RCB0		(1 << 0)	/* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ -#define		AT91_MATRIX_RCB1		(1 << 1)	/* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ -#define		AT91_MATRIX_RCB2		(1 << 2) -#define		AT91_MATRIX_RCB3		(1 << 3) -#define		AT91_MATRIX_RCB4		(1 << 4) -#define		AT91_MATRIX_RCB5		(1 << 5) -#define		AT91_MATRIX_RCB6		(1 << 6) -#define		AT91_MATRIX_RCB7		(1 << 7) -#define		AT91_MATRIX_RCB8		(1 << 8) -#define		AT91_MATRIX_RCB9		(1 << 9) -#define		AT91_MATRIX_RCB10		(1 << 10) -#define		AT91_MATRIX_RCB11		(1 << 11) - -#define AT91_MPBS0_SFR		(AT91_MATRIX + 0x114)	/* MPBlock Slave 0 Special Function Register */ -#define AT91_MPBS1_SFR		(AT91_MATRIX + 0x11C)	/* MPBlock Slave 1 Special Function Register */ - -#define AT91_MATRIX_UDPHS	(AT91_MATRIX + 0x118)	/* USBHS Special Function Register [AT91CAP9 only] */ -#define		AT91_MATRIX_SELECT_UDPHS	(0 << 31)	/* select High Speed UDP */ -#define		AT91_MATRIX_SELECT_UDP		(1 << 31)	/* select standard UDP */ -#define		AT91_MATRIX_UDPHS_BYPASS_LOCK	(1 << 30)	/* bypass lock bit */ - -#define AT91_MATRIX_EBICSA	(AT91_MATRIX + 0x120)	/* EBI Chip Select Assignment Register */ -#define		AT91_MATRIX_EBI_CS1A		(1 << 1)	/* Chip Select 1 Assignment */ -#define			AT91_MATRIX_EBI_CS1A_SMC		(0 << 1) -#define			AT91_MATRIX_EBI_CS1A_BCRAMC		(1 << 1) -#define		AT91_MATRIX_EBI_CS3A		(1 << 3)	/* Chip Select 3 Assignment */ -#define			AT91_MATRIX_EBI_CS3A_SMC		(0 << 3) -#define			AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA	(1 << 3) -#define		AT91_MATRIX_EBI_CS4A		(1 << 4)	/* Chip Select 4 Assignment */ -#define			AT91_MATRIX_EBI_CS4A_SMC		(0 << 4) -#define			AT91_MATRIX_EBI_CS4A_SMC_CF1		(1 << 4) -#define		AT91_MATRIX_EBI_CS5A		(1 << 5)	/* Chip Select 5 Assignment */ -#define			AT91_MATRIX_EBI_CS5A_SMC		(0 << 5) -#define			AT91_MATRIX_EBI_CS5A_SMC_CF2		(1 << 5) -#define		AT91_MATRIX_EBI_DBPUC		(1 << 8)	/* Data Bus Pull-up Configuration */ -#define		AT91_MATRIX_EBI_DQSPDC		(1 << 9)	/* Data Qualifier Strobe Pull-Down Configuration */ -#define		AT91_MATRIX_EBI_VDDIOMSEL	(1 << 16)	/* Memory voltage selection */ -#define			AT91_MATRIX_EBI_VDDIOMSEL_1_8V		(0 << 16) -#define			AT91_MATRIX_EBI_VDDIOMSEL_3_3V		(1 << 16) - -#define AT91_MPBS2_SFR		(AT91_MATRIX + 0x12C)	/* MPBlock Slave 2 Special Function Register */ -#define AT91_MPBS3_SFR		(AT91_MATRIX + 0x130)	/* MPBlock Slave 3 Special Function Register */ -#define AT91_APB_SFR		(AT91_MATRIX + 0x134)	/* APB Bridge Special Function Register */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91rm9200.h b/arch/arm/mach-at91/include/mach/at91rm9200.h index 78983155a07..e67317c6776 100644 --- a/arch/arm/mach-at91/include/mach/at91rm9200.h +++ b/arch/arm/mach-at91/include/mach/at91rm9200.h @@ -19,8 +19,6 @@  /*   * Peripheral identifiers/interrupts.   */ -#define AT91_ID_FIQ		0	/* Advanced Interrupt Controller (FIQ) */ -#define AT91_ID_SYS		1	/* System Peripheral */  #define AT91RM9200_ID_PIOA	2	/* Parallel IO Controller A */  #define AT91RM9200_ID_PIOB	3	/* Parallel IO Controller B */  #define AT91RM9200_ID_PIOC	4	/* Parallel IO Controller C */ @@ -76,29 +74,19 @@  #define AT91RM9200_BASE_SSC1	0xfffd4000  #define AT91RM9200_BASE_SSC2	0xfffd8000  #define AT91RM9200_BASE_SPI	0xfffe0000 -#define AT91_BASE_SYS		0xfffff000  /* - * System Peripherals (offset from AT91_BASE_SYS) + * System Peripherals   */ -#define AT91_AIC	(0xfffff000 - AT91_BASE_SYS)	/* Advanced Interrupt Controller */ -#define AT91_DBGU	(0xfffff200 - AT91_BASE_SYS)	/* Debug Unit */ -#define AT91_PIOA	(0xfffff400 - AT91_BASE_SYS)	/* PIO Controller A */ -#define AT91_PIOB	(0xfffff600 - AT91_BASE_SYS)	/* PIO Controller B */ -#define AT91_PIOC	(0xfffff800 - AT91_BASE_SYS)	/* PIO Controller C */ -#define AT91_PIOD	(0xfffffa00 - AT91_BASE_SYS)	/* PIO Controller D */ -#define AT91_PMC	(0xfffffc00 - AT91_BASE_SYS)	/* Power Management Controller */ -#define AT91_ST		(0xfffffd00 - AT91_BASE_SYS)	/* System Timer */ -#define AT91_RTC	(0xfffffe00 - AT91_BASE_SYS)	/* Real-Time Clock */ -#define AT91_MC		(0xffffff00 - AT91_BASE_SYS)	/* Memory Controllers */ - -#define AT91_USART0	AT91RM9200_BASE_US0 -#define AT91_USART1	AT91RM9200_BASE_US1 -#define AT91_USART2	AT91RM9200_BASE_US2 -#define AT91_USART3	AT91RM9200_BASE_US3 - -#define AT91_MATRIX	0	/* not supported */ +#define AT91RM9200_BASE_DBGU	AT91_BASE_DBGU0	/* Debug Unit */ +#define AT91RM9200_BASE_PIOA	0xfffff400	/* PIO Controller A */ +#define AT91RM9200_BASE_PIOB	0xfffff600	/* PIO Controller B */ +#define AT91RM9200_BASE_PIOC	0xfffff800	/* PIO Controller C */ +#define AT91RM9200_BASE_PIOD	0xfffffa00	/* PIO Controller D */ +#define AT91RM9200_BASE_ST	0xfffffd00	/* System Timer */ +#define AT91RM9200_BASE_RTC	0xfffffe00	/* Real-Time Clock */ +#define AT91RM9200_BASE_MC	0xffffff00	/* Memory Controllers */  /*   * Internal Memory. diff --git a/arch/arm/mach-at91/include/mach/at91rm9200_emac.h b/arch/arm/mach-at91/include/mach/at91rm9200_emac.h deleted file mode 100644 index b8260cd8041..00000000000 --- a/arch/arm/mach-at91/include/mach/at91rm9200_emac.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91rm9200_emac.h - * - * Copyright (C) 2005 Ivan Kokshaysky - * Copyright (C) SAN People - * - * Ethernet MAC registers. - * Based on AT91RM9200 datasheet revision E. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef AT91RM9200_EMAC_H -#define AT91RM9200_EMAC_H - -#define	AT91_EMAC_CTL		0x00	/* Control Register */ -#define		AT91_EMAC_LB		(1 <<  0)	/* Loopback */ -#define		AT91_EMAC_LBL		(1 <<  1)	/* Loopback Local */ -#define		AT91_EMAC_RE		(1 <<  2)	/* Receive Enable */ -#define		AT91_EMAC_TE		(1 <<  3)	/* Transmit Enable */ -#define		AT91_EMAC_MPE		(1 <<  4)	/* Management Port Enable */ -#define		AT91_EMAC_CSR		(1 <<  5)	/* Clear Statistics Registers */ -#define		AT91_EMAC_INCSTAT	(1 <<  6)	/* Increment Statistics Registers */ -#define		AT91_EMAC_WES		(1 <<  7)	/* Write Enable for Statistics Registers */ -#define		AT91_EMAC_BP		(1 <<  8)	/* Back Pressure */ - -#define	AT91_EMAC_CFG		0x04	/* Configuration Register */ -#define		AT91_EMAC_SPD		(1 <<  0)	/* Speed */ -#define		AT91_EMAC_FD		(1 <<  1)	/* Full Duplex */ -#define		AT91_EMAC_BR		(1 <<  2)	/* Bit Rate */ -#define		AT91_EMAC_CAF		(1 <<  4)	/* Copy All Frames */ -#define		AT91_EMAC_NBC		(1 <<  5)	/* No Broadcast */ -#define		AT91_EMAC_MTI		(1 <<  6)	/* Multicast Hash Enable */ -#define		AT91_EMAC_UNI		(1 <<  7)	/* Unicast Hash Enable */ -#define		AT91_EMAC_BIG		(1 <<  8)	/* Receive 1522 Bytes */ -#define		AT91_EMAC_EAE		(1 <<  9)	/* External Address Match Enable */ -#define		AT91_EMAC_CLK		(3 << 10)	/* MDC Clock Divisor */ -#define		AT91_EMAC_CLK_DIV8		(0 << 10) -#define		AT91_EMAC_CLK_DIV16		(1 << 10) -#define		AT91_EMAC_CLK_DIV32		(2 << 10) -#define		AT91_EMAC_CLK_DIV64		(3 << 10) -#define		AT91_EMAC_RTY		(1 << 12)	/* Retry Test */ -#define		AT91_EMAC_RMII		(1 << 13)	/* Reduce MII (RMII) */ - -#define	AT91_EMAC_SR		0x08	/* Status Register */ -#define		AT91_EMAC_SR_LINK	(1 <<  0)	/* Link */ -#define		AT91_EMAC_SR_MDIO	(1 <<  1)	/* MDIO pin */ -#define		AT91_EMAC_SR_IDLE	(1 <<  2)	/* PHY idle */ - -#define	AT91_EMAC_TAR		0x0c	/* Transmit Address Register */ - -#define	AT91_EMAC_TCR		0x10	/* Transmit Control Register */ -#define		AT91_EMAC_LEN		(0x7ff << 0)	/* Transmit Frame Length */ -#define		AT91_EMAC_NCRC		(1     << 15)	/* No CRC */ - -#define	AT91_EMAC_TSR		0x14	/* Transmit Status Register */ -#define		AT91_EMAC_TSR_OVR	(1 <<  0)	/* Transmit Buffer Overrun */ -#define		AT91_EMAC_TSR_COL	(1 <<  1)	/* Collision Occurred */ -#define		AT91_EMAC_TSR_RLE	(1 <<  2)	/* Retry Limit Exceeded */ -#define		AT91_EMAC_TSR_IDLE	(1 <<  3)	/* Transmitter Idle */ -#define		AT91_EMAC_TSR_BNQ	(1 <<  4)	/* Transmit Buffer not Queued */ -#define		AT91_EMAC_TSR_COMP	(1 <<  5)	/* Transmit Complete */ -#define		AT91_EMAC_TSR_UND	(1 <<  6)	/* Transmit Underrun */ - -#define	AT91_EMAC_RBQP		0x18	/* Receive Buffer Queue Pointer */ - -#define	AT91_EMAC_RSR		0x20	/* Receive Status Register */ -#define		AT91_EMAC_RSR_BNA	(1 <<  0)	/* Buffer Not Available */ -#define		AT91_EMAC_RSR_REC	(1 <<  1)	/* Frame Received */ -#define		AT91_EMAC_RSR_OVR	(1 <<  2)	/* RX Overrun */ - -#define	AT91_EMAC_ISR		0x24	/* Interrupt Status Register */ -#define		AT91_EMAC_DONE		(1 <<  0)	/* Management Done */ -#define		AT91_EMAC_RCOM		(1 <<  1)	/* Receive Complete */ -#define		AT91_EMAC_RBNA		(1 <<  2)	/* Receive Buffer Not Available */ -#define		AT91_EMAC_TOVR		(1 <<  3)	/* Transmit Buffer Overrun */ -#define		AT91_EMAC_TUND		(1 <<  4)	/* Transmit Buffer Underrun */ -#define		AT91_EMAC_RTRY		(1 <<  5)	/* Retry Limit */ -#define		AT91_EMAC_TBRE		(1 <<  6)	/* Transmit Buffer Register Empty */ -#define		AT91_EMAC_TCOM		(1 <<  7)	/* Transmit Complete */ -#define		AT91_EMAC_TIDLE		(1 <<  8)	/* Transmit Idle */ -#define		AT91_EMAC_LINK		(1 <<  9)	/* Link */ -#define		AT91_EMAC_ROVR		(1 << 10)	/* RX Overrun */ -#define		AT91_EMAC_ABT		(1 << 11)	/* Abort */ - -#define	AT91_EMAC_IER		0x28	/* Interrupt Enable Register */ -#define	AT91_EMAC_IDR		0x2c	/* Interrupt Disable Register */ -#define	AT91_EMAC_IMR		0x30	/* Interrupt Mask Register */ - -#define	AT91_EMAC_MAN		0x34	/* PHY Maintenance Register */ -#define		AT91_EMAC_DATA		(0xffff << 0)	/* MDIO Data */ -#define		AT91_EMAC_REGA		(0x1f	<< 18)	/* MDIO Register */ -#define		AT91_EMAC_PHYA		(0x1f	<< 23)	/* MDIO PHY Address */ -#define		AT91_EMAC_RW		(3	<< 28)	/* Read/Write operation */ -#define			AT91_EMAC_RW_W		(1 << 28) -#define			AT91_EMAC_RW_R		(2 << 28) -#define		AT91_EMAC_MAN_802_3	0x40020000	/* IEEE 802.3 value */ - -/* - * Statistics Registers. - */ -#define AT91_EMAC_FRA		0x40	/* Frames Transmitted OK */ -#define AT91_EMAC_SCOL		0x44	/* Single Collision Frame */ -#define AT91_EMAC_MCOL		0x48	/* Multiple Collision Frame */ -#define AT91_EMAC_OK		0x4c	/* Frames Received OK */ -#define AT91_EMAC_SEQE		0x50	/* Frame Check Sequence Error */ -#define AT91_EMAC_ALE		0x54	/* Alignmemt Error */ -#define AT91_EMAC_DTE		0x58	/* Deffered Transmission Frame */ -#define AT91_EMAC_LCOL		0x5c	/* Late Collision */ -#define AT91_EMAC_ECOL		0x60	/* Excessive Collision */ -#define AT91_EMAC_TUE		0x64	/* Transmit Underrun Error */ -#define AT91_EMAC_CSE		0x68	/* Carrier Sense Error */ -#define AT91_EMAC_DRFC		0x6c	/* Discard RX Frame */ -#define AT91_EMAC_ROV		0x70	/* Receive Overrun */ -#define AT91_EMAC_CDE		0x74	/* Code Error */ -#define AT91_EMAC_ELR		0x78	/* Excessive Length Error */ -#define AT91_EMAC_RJB		0x7c	/* Receive Jabber */ -#define AT91_EMAC_USF		0x80	/* Undersize Frame */ -#define AT91_EMAC_SQEE		0x84	/* SQE Test Error */ - -/* - * Address Registers. - */ -#define AT91_EMAC_HSL		0x90	/* Hash Address Low [31:0] */ -#define AT91_EMAC_HSH		0x94	/* Hash Address High [63:32] */ -#define AT91_EMAC_SA1L		0x98	/* Specific Address 1 Low, bytes 0-3 */ -#define AT91_EMAC_SA1H		0x9c	/* Specific Address 1 High, bytes 4-5 */ -#define AT91_EMAC_SA2L		0xa0	/* Specific Address 2 Low, bytes 0-3 */ -#define AT91_EMAC_SA2H		0xa4	/* Specific Address 2 High, bytes 4-5 */ -#define AT91_EMAC_SA3L		0xa8	/* Specific Address 3 Low, bytes 0-3 */ -#define AT91_EMAC_SA3H		0xac	/* Specific Address 3 High, bytes 4-5 */ -#define AT91_EMAC_SA4L		0xb0	/* Specific Address 4 Low, bytes 0-3 */ -#define AT91_EMAC_SA4H		0xb4	/* Specific Address 4 High, bytes 4-5 */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/at91rm9200_mc.h b/arch/arm/mach-at91/include/mach/at91rm9200_mc.h index d34e4ed8934..aeaadfb452a 100644 --- a/arch/arm/mach-at91/include/mach/at91rm9200_mc.h +++ b/arch/arm/mach-at91/include/mach/at91rm9200_mc.h @@ -17,10 +17,10 @@  #define AT91RM9200_MC_H  /* Memory Controller */ -#define AT91_MC_RCR		(AT91_MC + 0x00)	/* MC Remap Control Register */ +#define AT91_MC_RCR		0x00			/* MC Remap Control Register */  #define		AT91_MC_RCB		(1 <<  0)		/* Remap Command Bit */ -#define AT91_MC_ASR		(AT91_MC + 0x04)	/* MC Abort Status Register */ +#define AT91_MC_ASR		0x04			/* MC Abort Status Register */  #define		AT91_MC_UNADD		(1 <<  0)		/* Undefined Address Abort Status */  #define		AT91_MC_MISADD		(1 <<  1)		/* Misaligned Address Abort Status */  #define		AT91_MC_ABTSZ		(3 <<  8)		/* Abort Size Status */ @@ -40,16 +40,16 @@  #define		AT91_MC_SVMST2		(1 << 26)		/* Saved UHP Abort Source */  #define		AT91_MC_SVMST3		(1 << 27)		/* Saved EMAC Abort Source */ -#define AT91_MC_AASR		(AT91_MC + 0x08)	/* MC Abort Address Status Register */ +#define AT91_MC_AASR		0x08			/* MC Abort Address Status Register */ -#define AT91_MC_MPR		(AT91_MC + 0x0c)	/* MC Master Priority Register */ +#define AT91_MC_MPR		0x0c			/* MC Master Priority Register */  #define		AT91_MPR_MSTP0		(7 <<  0)		/* ARM920T Priority */  #define		AT91_MPR_MSTP1		(7 <<  4)		/* PDC Priority */  #define		AT91_MPR_MSTP2		(7 <<  8)		/* UHP Priority */  #define		AT91_MPR_MSTP3		(7 << 12)		/* EMAC Priority */  /* External Bus Interface (EBI) registers */ -#define AT91_EBI_CSA		(AT91_MC + 0x60)	/* Chip Select Assignment Register */ +#define AT91_EBI_CSA		0x60			/* Chip Select Assignment Register */  #define		AT91_EBI_CS0A		(1 << 0)		/* Chip Select 0 Assignment */  #define			AT91_EBI_CS0A_SMC		(0 << 0)  #define			AT91_EBI_CS0A_BFC		(1 << 0) @@ -66,7 +66,7 @@  #define		AT91_EBI_DBPUC		(1 << 0)		/* Data Bus Pull-Up Configuration */  /* Static Memory Controller (SMC) registers */ -#define	AT91_SMC_CSR(n)		(AT91_MC + 0x70 + ((n) * 4))/* SMC Chip Select Register */ +#define	AT91_SMC_CSR(n)		(0x70 + ((n) * 4))	/* SMC Chip Select Register */  #define		AT91_SMC_NWS		(0x7f <<  0)		/* Number of Wait States */  #define			AT91_SMC_NWS_(x)	((x) << 0)  #define		AT91_SMC_WSEN		(1    <<  7)		/* Wait State Enable */ @@ -87,52 +87,8 @@  #define		AT91_SMC_RWHOLD		(7 << 28)		/* Read & Write Signal Hold Time */  #define			AT91_SMC_RWHOLD_(x)	((x) << 28) -/* SDRAM Controller registers */ -#define AT91_SDRAMC_MR		(AT91_MC + 0x90)	/* Mode Register */ -#define		AT91_SDRAMC_MODE	(0xf << 0)		/* Command Mode */ -#define			AT91_SDRAMC_MODE_NORMAL		(0 << 0) -#define			AT91_SDRAMC_MODE_NOP		(1 << 0) -#define			AT91_SDRAMC_MODE_PRECHARGE	(2 << 0) -#define			AT91_SDRAMC_MODE_LMR		(3 << 0) -#define			AT91_SDRAMC_MODE_REFRESH	(4 << 0) -#define		AT91_SDRAMC_DBW		(1   << 4)		/* Data Bus Width */ -#define			AT91_SDRAMC_DBW_32	(0 << 4) -#define			AT91_SDRAMC_DBW_16	(1 << 4) - -#define AT91_SDRAMC_TR		(AT91_MC + 0x94)	/* Refresh Timer Register */ -#define		AT91_SDRAMC_COUNT	(0xfff << 0)		/* Refresh Timer Count */ - -#define AT91_SDRAMC_CR		(AT91_MC + 0x98)	/* Configuration Register */ -#define		AT91_SDRAMC_NC		(3   <<  0)		/* Number of Column Bits */ -#define			AT91_SDRAMC_NC_8	(0 << 0) -#define			AT91_SDRAMC_NC_9	(1 << 0) -#define			AT91_SDRAMC_NC_10	(2 << 0) -#define			AT91_SDRAMC_NC_11	(3 << 0) -#define		AT91_SDRAMC_NR		(3   <<  2)		/* Number of Row Bits */ -#define			AT91_SDRAMC_NR_11	(0 << 2) -#define			AT91_SDRAMC_NR_12	(1 << 2) -#define			AT91_SDRAMC_NR_13	(2 << 2) -#define		AT91_SDRAMC_NB		(1   <<  4)		/* Number of Banks */ -#define			AT91_SDRAMC_NB_2	(0 << 4) -#define			AT91_SDRAMC_NB_4	(1 << 4) -#define		AT91_SDRAMC_CAS		(3   <<  5)		/* CAS Latency */ -#define			AT91_SDRAMC_CAS_2	(2 << 5) -#define		AT91_SDRAMC_TWR		(0xf <<  7)		/* Write Recovery Delay */ -#define		AT91_SDRAMC_TRC		(0xf << 11)		/* Row Cycle Delay */ -#define		AT91_SDRAMC_TRP		(0xf << 15)		/* Row Precharge Delay */ -#define		AT91_SDRAMC_TRCD	(0xf << 19)		/* Row to Column Delay */ -#define		AT91_SDRAMC_TRAS	(0xf << 23)		/* Active to Precharge Delay */ -#define		AT91_SDRAMC_TXSR	(0xf << 27)		/* Exit Self Refresh to Active Delay */ - -#define AT91_SDRAMC_SRR		(AT91_MC + 0x9c)	/* Self Refresh Register */ -#define AT91_SDRAMC_LPR		(AT91_MC + 0xa0)	/* Low Power Register */ -#define AT91_SDRAMC_IER		(AT91_MC + 0xa4)	/* Interrupt Enable Register */ -#define AT91_SDRAMC_IDR		(AT91_MC + 0xa8)	/* Interrupt Disable Register */ -#define AT91_SDRAMC_IMR		(AT91_MC + 0xac)	/* Interrupt Mask Register */ -#define AT91_SDRAMC_ISR		(AT91_MC + 0xb0)	/* Interrupt Status Register */ -  /* Burst Flash Controller register */ -#define AT91_BFC_MR		(AT91_MC + 0xc0)	/* Mode Register */ +#define AT91_BFC_MR		0xc0			/* Mode Register */  #define		AT91_BFC_BFCOM		(3   <<  0)		/* Burst Flash Controller Operating Mode */  #define			AT91_BFC_BFCOM_DISABLED	(0 << 0)  #define			AT91_BFC_BFCOM_ASYNC	(1 << 0) diff --git a/arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h b/arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h new file mode 100644 index 00000000000..aa047f458f1 --- /dev/null +++ b/arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h @@ -0,0 +1,63 @@ +/* + * arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h + * + * Copyright (C) 2005 Ivan Kokshaysky + * Copyright (C) SAN People + * + * Memory Controllers (SDRAMC only) - System peripherals registers. + * Based on AT91RM9200 datasheet revision E. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef AT91RM9200_SDRAMC_H +#define AT91RM9200_SDRAMC_H + +/* SDRAM Controller registers */ +#define AT91RM9200_SDRAMC_MR		0x90			/* Mode Register */ +#define		AT91RM9200_SDRAMC_MODE	(0xf << 0)		/* Command Mode */ +#define			AT91RM9200_SDRAMC_MODE_NORMAL		(0 << 0) +#define			AT91RM9200_SDRAMC_MODE_NOP		(1 << 0) +#define			AT91RM9200_SDRAMC_MODE_PRECHARGE	(2 << 0) +#define			AT91RM9200_SDRAMC_MODE_LMR		(3 << 0) +#define			AT91RM9200_SDRAMC_MODE_REFRESH	(4 << 0) +#define		AT91RM9200_SDRAMC_DBW		(1   << 4)		/* Data Bus Width */ +#define			AT91RM9200_SDRAMC_DBW_32	(0 << 4) +#define			AT91RM9200_SDRAMC_DBW_16	(1 << 4) + +#define AT91RM9200_SDRAMC_TR		0x94			/* Refresh Timer Register */ +#define		AT91RM9200_SDRAMC_COUNT	(0xfff << 0)		/* Refresh Timer Count */ + +#define AT91RM9200_SDRAMC_CR		0x98			/* Configuration Register */ +#define		AT91RM9200_SDRAMC_NC		(3   <<  0)		/* Number of Column Bits */ +#define			AT91RM9200_SDRAMC_NC_8	(0 << 0) +#define			AT91RM9200_SDRAMC_NC_9	(1 << 0) +#define			AT91RM9200_SDRAMC_NC_10	(2 << 0) +#define			AT91RM9200_SDRAMC_NC_11	(3 << 0) +#define		AT91RM9200_SDRAMC_NR		(3   <<  2)		/* Number of Row Bits */ +#define			AT91RM9200_SDRAMC_NR_11	(0 << 2) +#define			AT91RM9200_SDRAMC_NR_12	(1 << 2) +#define			AT91RM9200_SDRAMC_NR_13	(2 << 2) +#define		AT91RM9200_SDRAMC_NB		(1   <<  4)		/* Number of Banks */ +#define			AT91RM9200_SDRAMC_NB_2	(0 << 4) +#define			AT91RM9200_SDRAMC_NB_4	(1 << 4) +#define		AT91RM9200_SDRAMC_CAS		(3   <<  5)		/* CAS Latency */ +#define			AT91RM9200_SDRAMC_CAS_2	(2 << 5) +#define		AT91RM9200_SDRAMC_TWR		(0xf <<  7)		/* Write Recovery Delay */ +#define		AT91RM9200_SDRAMC_TRC		(0xf << 11)		/* Row Cycle Delay */ +#define		AT91RM9200_SDRAMC_TRP		(0xf << 15)		/* Row Precharge Delay */ +#define		AT91RM9200_SDRAMC_TRCD	(0xf << 19)		/* Row to Column Delay */ +#define		AT91RM9200_SDRAMC_TRAS	(0xf << 23)		/* Active to Precharge Delay */ +#define		AT91RM9200_SDRAMC_TXSR	(0xf << 27)		/* Exit Self Refresh to Active Delay */ + +#define AT91RM9200_SDRAMC_SRR		0x9c			/* Self Refresh Register */ +#define AT91RM9200_SDRAMC_LPR		0xa0			/* Low Power Register */ +#define AT91RM9200_SDRAMC_IER		0xa4			/* Interrupt Enable Register */ +#define AT91RM9200_SDRAMC_IDR		0xa8			/* Interrupt Disable Register */ +#define AT91RM9200_SDRAMC_IMR		0xac			/* Interrupt Mask Register */ +#define AT91RM9200_SDRAMC_ISR		0xb0			/* Interrupt Status Register */ + +#endif diff --git a/arch/arm/mach-at91/include/mach/at91sam9260.h b/arch/arm/mach-at91/include/mach/at91sam9260.h index 4e79036d3b8..416c7b6c56d 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9260.h +++ b/arch/arm/mach-at91/include/mach/at91sam9260.h @@ -20,8 +20,6 @@  /*   * Peripheral identifiers/interrupts.   */ -#define AT91_ID_FIQ		0	/* Advanced Interrupt Controller (FIQ) */ -#define AT91_ID_SYS		1	/* System Peripherals */  #define AT91SAM9260_ID_PIOA	2	/* Parallel IO Controller A */  #define AT91SAM9260_ID_PIOB	3	/* Parallel IO Controller B */  #define AT91SAM9260_ID_PIOC	4	/* Parallel IO Controller C */ @@ -78,35 +76,24 @@  #define AT91SAM9260_BASE_TC4		0xfffdc040  #define AT91SAM9260_BASE_TC5		0xfffdc080  #define AT91SAM9260_BASE_ADC		0xfffe0000 -#define AT91_BASE_SYS			0xffffe800  /* - * System Peripherals (offset from AT91_BASE_SYS) + * System Peripherals   */ -#define AT91_ECC	(0xffffe800 - AT91_BASE_SYS) -#define AT91_SDRAMC0	(0xffffea00 - AT91_BASE_SYS) -#define AT91_SMC	(0xffffec00 - AT91_BASE_SYS) -#define AT91_MATRIX	(0xffffee00 - AT91_BASE_SYS) -#define AT91_CCFG	(0xffffef10 - AT91_BASE_SYS) -#define AT91_AIC	(0xfffff000 - AT91_BASE_SYS) -#define AT91_DBGU	(0xfffff200 - AT91_BASE_SYS) -#define AT91_PIOA	(0xfffff400 - AT91_BASE_SYS) -#define AT91_PIOB	(0xfffff600 - AT91_BASE_SYS) -#define AT91_PIOC	(0xfffff800 - AT91_BASE_SYS) -#define AT91_PMC	(0xfffffc00 - AT91_BASE_SYS) -#define AT91_RSTC	(0xfffffd00 - AT91_BASE_SYS) -#define AT91_SHDWC	(0xfffffd10 - AT91_BASE_SYS) -#define AT91_RTT	(0xfffffd20 - AT91_BASE_SYS) -#define AT91_PIT	(0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT	(0xfffffd40 - AT91_BASE_SYS) -#define AT91_GPBR	(0xfffffd50 - AT91_BASE_SYS) - -#define AT91_USART0	AT91SAM9260_BASE_US0 -#define AT91_USART1	AT91SAM9260_BASE_US1 -#define AT91_USART2	AT91SAM9260_BASE_US2 -#define AT91_USART3	AT91SAM9260_BASE_US3 -#define AT91_USART4	AT91SAM9260_BASE_US4 -#define AT91_USART5	AT91SAM9260_BASE_US5 +#define AT91SAM9260_BASE_ECC	0xffffe800 +#define AT91SAM9260_BASE_SDRAMC	0xffffea00 +#define AT91SAM9260_BASE_SMC	0xffffec00 +#define AT91SAM9260_BASE_MATRIX	0xffffee00 +#define AT91SAM9260_BASE_DBGU	AT91_BASE_DBGU0 +#define AT91SAM9260_BASE_PIOA	0xfffff400 +#define AT91SAM9260_BASE_PIOB	0xfffff600 +#define AT91SAM9260_BASE_PIOC	0xfffff800 +#define AT91SAM9260_BASE_RSTC	0xfffffd00 +#define AT91SAM9260_BASE_SHDWC	0xfffffd10 +#define AT91SAM9260_BASE_RTT	0xfffffd20 +#define AT91SAM9260_BASE_PIT	0xfffffd30 +#define AT91SAM9260_BASE_WDT	0xfffffd40 +#define AT91SAM9260_BASE_GPBR	0xfffffd50  /* @@ -119,6 +106,8 @@  #define AT91SAM9260_SRAM0_SIZE	SZ_4K		/* Internal SRAM 0 size (4Kb) */  #define AT91SAM9260_SRAM1_BASE	0x00300000	/* Internal SRAM 1 base address */  #define AT91SAM9260_SRAM1_SIZE	SZ_4K		/* Internal SRAM 1 size (4Kb) */ +#define AT91SAM9260_SRAM_BASE	0x002FF000	/* Internal SRAM base address */ +#define AT91SAM9260_SRAM_SIZE	SZ_8K		/* Internal SRAM size (8Kb) */  #define AT91SAM9260_UHP_BASE	0x00500000	/* USB Host controller */ @@ -132,6 +121,8 @@  #define AT91SAM9G20_SRAM0_SIZE	SZ_16K		/* Internal SRAM 0 size (16Kb) */  #define AT91SAM9G20_SRAM1_BASE	0x00300000	/* Internal SRAM 1 base address */  #define AT91SAM9G20_SRAM1_SIZE	SZ_16K		/* Internal SRAM 1 size (16Kb) */ +#define AT91SAM9G20_SRAM_BASE	0x002FC000	/* Internal SRAM base address */ +#define AT91SAM9G20_SRAM_SIZE	SZ_32K		/* Internal SRAM size (32Kb) */  #define AT91SAM9G20_UHP_BASE	0x00500000	/* USB Host controller */ diff --git a/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h index 020f02ed921..f459df42062 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h +++ b/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h @@ -15,12 +15,12 @@  #ifndef AT91SAM9260_MATRIX_H  #define AT91SAM9260_MATRIX_H -#define AT91_MATRIX_MCFG0	(AT91_MATRIX + 0x00)	/* Master Configuration Register 0 */ -#define AT91_MATRIX_MCFG1	(AT91_MATRIX + 0x04)	/* Master Configuration Register 1 */ -#define AT91_MATRIX_MCFG2	(AT91_MATRIX + 0x08)	/* Master Configuration Register 2 */ -#define AT91_MATRIX_MCFG3	(AT91_MATRIX + 0x0C)	/* Master Configuration Register 3 */ -#define AT91_MATRIX_MCFG4	(AT91_MATRIX + 0x10)	/* Master Configuration Register 4 */ -#define AT91_MATRIX_MCFG5	(AT91_MATRIX + 0x14)	/* Master Configuration Register 5 */ +#define AT91_MATRIX_MCFG0	0x00			/* Master Configuration Register 0 */ +#define AT91_MATRIX_MCFG1	0x04			/* Master Configuration Register 1 */ +#define AT91_MATRIX_MCFG2	0x08			/* Master Configuration Register 2 */ +#define AT91_MATRIX_MCFG3	0x0C			/* Master Configuration Register 3 */ +#define AT91_MATRIX_MCFG4	0x10			/* Master Configuration Register 4 */ +#define AT91_MATRIX_MCFG5	0x14			/* Master Configuration Register 5 */  #define		AT91_MATRIX_ULBT		(7 << 0)	/* Undefined Length Burst Type */  #define			AT91_MATRIX_ULBT_INFINITE	(0 << 0)  #define			AT91_MATRIX_ULBT_SINGLE		(1 << 0) @@ -28,11 +28,11 @@  #define			AT91_MATRIX_ULBT_EIGHT		(3 << 0)  #define			AT91_MATRIX_ULBT_SIXTEEN	(4 << 0) -#define AT91_MATRIX_SCFG0	(AT91_MATRIX + 0x40)	/* Slave Configuration Register 0 */ -#define AT91_MATRIX_SCFG1	(AT91_MATRIX + 0x44)	/* Slave Configuration Register 1 */ -#define AT91_MATRIX_SCFG2	(AT91_MATRIX + 0x48)	/* Slave Configuration Register 2 */ -#define AT91_MATRIX_SCFG3	(AT91_MATRIX + 0x4C)	/* Slave Configuration Register 3 */ -#define AT91_MATRIX_SCFG4	(AT91_MATRIX + 0x50)	/* Slave Configuration Register 4 */ +#define AT91_MATRIX_SCFG0	0x40			/* Slave Configuration Register 0 */ +#define AT91_MATRIX_SCFG1	0x44			/* Slave Configuration Register 1 */ +#define AT91_MATRIX_SCFG2	0x48			/* Slave Configuration Register 2 */ +#define AT91_MATRIX_SCFG3	0x4C			/* Slave Configuration Register 3 */ +#define AT91_MATRIX_SCFG4	0x50			/* Slave Configuration Register 4 */  #define		AT91_MATRIX_SLOT_CYCLE		(0xff <<  0)	/* Maximum Number of Allowed Cycles for a Burst */  #define		AT91_MATRIX_DEFMSTR_TYPE	(3    << 16)	/* Default Master Type */  #define			AT91_MATRIX_DEFMSTR_TYPE_NONE	(0 << 16) @@ -43,11 +43,11 @@  #define			AT91_MATRIX_ARBT_ROUND_ROBIN	(0 << 24)  #define			AT91_MATRIX_ARBT_FIXED_PRIORITY	(1 << 24) -#define AT91_MATRIX_PRAS0	(AT91_MATRIX + 0x80)	/* Priority Register A for Slave 0 */ -#define AT91_MATRIX_PRAS1	(AT91_MATRIX + 0x88)	/* Priority Register A for Slave 1 */ -#define AT91_MATRIX_PRAS2	(AT91_MATRIX + 0x90)	/* Priority Register A for Slave 2 */ -#define AT91_MATRIX_PRAS3	(AT91_MATRIX + 0x98)	/* Priority Register A for Slave 3 */ -#define AT91_MATRIX_PRAS4	(AT91_MATRIX + 0xA0)	/* Priority Register A for Slave 4 */ +#define AT91_MATRIX_PRAS0	0x80			/* Priority Register A for Slave 0 */ +#define AT91_MATRIX_PRAS1	0x88			/* Priority Register A for Slave 1 */ +#define AT91_MATRIX_PRAS2	0x90			/* Priority Register A for Slave 2 */ +#define AT91_MATRIX_PRAS3	0x98			/* Priority Register A for Slave 3 */ +#define AT91_MATRIX_PRAS4	0xA0			/* Priority Register A for Slave 4 */  #define		AT91_MATRIX_M0PR		(3 << 0)	/* Master 0 Priority */  #define		AT91_MATRIX_M1PR		(3 << 4)	/* Master 1 Priority */  #define		AT91_MATRIX_M2PR		(3 << 8)	/* Master 2 Priority */ @@ -55,11 +55,11 @@  #define		AT91_MATRIX_M4PR		(3 << 16)	/* Master 4 Priority */  #define		AT91_MATRIX_M5PR		(3 << 20)	/* Master 5 Priority */ -#define AT91_MATRIX_MRCR	(AT91_MATRIX + 0x100)	/* Master Remap Control Register */ +#define AT91_MATRIX_MRCR	0x100			/* Master Remap Control Register */  #define		AT91_MATRIX_RCB0		(1 << 0)	/* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */  #define		AT91_MATRIX_RCB1		(1 << 1)	/* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ -#define AT91_MATRIX_EBICSA	(AT91_MATRIX + 0x11C)	/* EBI Chip Select Assignment Register */ +#define AT91_MATRIX_EBICSA	0x11C			/* EBI Chip Select Assignment Register */  #define		AT91_MATRIX_CS1A		(1 << 1)	/* Chip Select 1 Assignment */  #define			AT91_MATRIX_CS1A_SMC		(0 << 1)  #define			AT91_MATRIX_CS1A_SDRAMC		(1 << 1) diff --git a/arch/arm/mach-at91/include/mach/at91sam9261.h b/arch/arm/mach-at91/include/mach/at91sam9261.h index 2b561851812..a041406d06e 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9261.h +++ b/arch/arm/mach-at91/include/mach/at91sam9261.h @@ -18,8 +18,6 @@  /*   * Peripheral identifiers/interrupts.   */ -#define AT91_ID_FIQ		0	/* Advanced Interrupt Controller (FIQ) */ -#define AT91_ID_SYS		1	/* System Peripherals */  #define AT91SAM9261_ID_PIOA	2	/* Parallel IO Controller A */  #define AT91SAM9261_ID_PIOB	3	/* Parallel IO Controller B */  #define AT91SAM9261_ID_PIOC	4	/* Parallel IO Controller C */ @@ -62,31 +60,24 @@  #define AT91SAM9261_BASE_SSC2		0xfffc4000  #define AT91SAM9261_BASE_SPI0		0xfffc8000  #define AT91SAM9261_BASE_SPI1		0xfffcc000 -#define AT91_BASE_SYS			0xffffea00  /* - * System Peripherals (offset from AT91_BASE_SYS) + * System Peripherals   */ -#define AT91_SDRAMC0	(0xffffea00 - AT91_BASE_SYS) -#define AT91_SMC	(0xffffec00 - AT91_BASE_SYS) -#define AT91_MATRIX	(0xffffee00 - AT91_BASE_SYS) -#define AT91_AIC	(0xfffff000 - AT91_BASE_SYS) -#define AT91_DBGU	(0xfffff200 - AT91_BASE_SYS) -#define AT91_PIOA	(0xfffff400 - AT91_BASE_SYS) -#define AT91_PIOB	(0xfffff600 - AT91_BASE_SYS) -#define AT91_PIOC	(0xfffff800 - AT91_BASE_SYS) -#define AT91_PMC	(0xfffffc00 - AT91_BASE_SYS) -#define AT91_RSTC	(0xfffffd00 - AT91_BASE_SYS) -#define AT91_SHDWC	(0xfffffd10 - AT91_BASE_SYS) -#define AT91_RTT	(0xfffffd20 - AT91_BASE_SYS) -#define AT91_PIT	(0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT	(0xfffffd40 - AT91_BASE_SYS) -#define AT91_GPBR	(0xfffffd50 - AT91_BASE_SYS) - -#define AT91_USART0	AT91SAM9261_BASE_US0 -#define AT91_USART1	AT91SAM9261_BASE_US1 -#define AT91_USART2	AT91SAM9261_BASE_US2 +#define AT91SAM9261_BASE_SMC	0xffffec00 +#define AT91SAM9261_BASE_MATRIX	0xffffee00 +#define AT91SAM9261_BASE_SDRAMC	0xffffea00 +#define AT91SAM9261_BASE_DBGU	AT91_BASE_DBGU0 +#define AT91SAM9261_BASE_PIOA	0xfffff400 +#define AT91SAM9261_BASE_PIOB	0xfffff600 +#define AT91SAM9261_BASE_PIOC	0xfffff800 +#define AT91SAM9261_BASE_RSTC	0xfffffd00 +#define AT91SAM9261_BASE_SHDWC	0xfffffd10 +#define AT91SAM9261_BASE_RTT	0xfffffd20 +#define AT91SAM9261_BASE_PIT	0xfffffd30 +#define AT91SAM9261_BASE_WDT	0xfffffd40 +#define AT91SAM9261_BASE_GPBR	0xfffffd50  /* diff --git a/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h index 69c6501915d..a50cdf8b8ca 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h +++ b/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h @@ -15,15 +15,15 @@  #ifndef AT91SAM9261_MATRIX_H  #define AT91SAM9261_MATRIX_H -#define AT91_MATRIX_MCFG	(AT91_MATRIX + 0x00)	/* Master Configuration Register */ +#define AT91_MATRIX_MCFG	0x00			/* Master Configuration Register */  #define		AT91_MATRIX_RCB0	(1 << 0)		/* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */  #define		AT91_MATRIX_RCB1	(1 << 1)		/* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ -#define AT91_MATRIX_SCFG0	(AT91_MATRIX + 0x04)	/* Slave Configuration Register 0 */ -#define AT91_MATRIX_SCFG1	(AT91_MATRIX + 0x08)	/* Slave Configuration Register 1 */ -#define AT91_MATRIX_SCFG2	(AT91_MATRIX + 0x0C)	/* Slave Configuration Register 2 */ -#define AT91_MATRIX_SCFG3	(AT91_MATRIX + 0x10)	/* Slave Configuration Register 3 */ -#define AT91_MATRIX_SCFG4	(AT91_MATRIX + 0x14)	/* Slave Configuration Register 4 */ +#define AT91_MATRIX_SCFG0	0x04			/* Slave Configuration Register 0 */ +#define AT91_MATRIX_SCFG1	0x08			/* Slave Configuration Register 1 */ +#define AT91_MATRIX_SCFG2	0x0C			/* Slave Configuration Register 2 */ +#define AT91_MATRIX_SCFG3	0x10			/* Slave Configuration Register 3 */ +#define AT91_MATRIX_SCFG4	0x14			/* Slave Configuration Register 4 */  #define		AT91_MATRIX_SLOT_CYCLE		(0xff << 0)	/* Maximum Number of Allowed Cycles for a Burst */  #define		AT91_MATRIX_DEFMSTR_TYPE	(3    << 16)	/* Default Master Type */  #define			AT91_MATRIX_DEFMSTR_TYPE_NONE	(0 << 16) @@ -31,7 +31,7 @@  #define			AT91_MATRIX_DEFMSTR_TYPE_FIXED	(2 << 16)  #define		AT91_MATRIX_FIXED_DEFMSTR	(7    << 18)	/* Fixed Index of Default Master */ -#define AT91_MATRIX_TCR		(AT91_MATRIX + 0x24)	/* TCM Configuration Register */ +#define AT91_MATRIX_TCR		0x24			/* TCM Configuration Register */  #define		AT91_MATRIX_ITCM_SIZE		(0xf << 0)	/* Size of ITCM enabled memory block */  #define			AT91_MATRIX_ITCM_0		(0 << 0)  #define			AT91_MATRIX_ITCM_16		(5 << 0) @@ -43,7 +43,7 @@  #define			AT91_MATRIX_DTCM_32		(6 << 4)  #define			AT91_MATRIX_DTCM_64		(7 << 4) -#define AT91_MATRIX_EBICSA	(AT91_MATRIX + 0x30)	/* EBI Chip Select Assignment Register */ +#define AT91_MATRIX_EBICSA	0x30			/* EBI Chip Select Assignment Register */  #define		AT91_MATRIX_CS1A		(1 << 1)	/* Chip Select 1 Assignment */  #define			AT91_MATRIX_CS1A_SMC		(0 << 1)  #define			AT91_MATRIX_CS1A_SDRAMC		(1 << 1) @@ -58,7 +58,7 @@  #define			AT91_MATRIX_CS5A_SMC_CF2	(1 << 5)  #define		AT91_MATRIX_DBPUC		(1 << 8)	/* Data Bus Pull-up Configuration */ -#define AT91_MATRIX_USBPUCR	(AT91_MATRIX + 0x34)	/* USB Pad Pull-Up Control Register */ +#define AT91_MATRIX_USBPUCR	0x34			/* USB Pad Pull-Up Control Register */  #define		AT91_MATRIX_USBPUCR_PUON	(1 << 30)	/* USB Device PAD Pull-up Enable */  #endif diff --git a/arch/arm/mach-at91/include/mach/at91sam9263.h b/arch/arm/mach-at91/include/mach/at91sam9263.h index 2091f1e42d4..d201029d60b 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9263.h +++ b/arch/arm/mach-at91/include/mach/at91sam9263.h @@ -18,8 +18,6 @@  /*   * Peripheral identifiers/interrupts.   */ -#define AT91_ID_FIQ		0	/* Advanced Interrupt Controller (FIQ) */ -#define AT91_ID_SYS		1	/* System Peripherals */  #define AT91SAM9263_ID_PIOA	2	/* Parallel IO Controller A */  #define AT91SAM9263_ID_PIOB	3	/* Parallel IO Controller B */  #define AT91SAM9263_ID_PIOCDE	4	/* Parallel IO Controller C, D and E */ @@ -72,38 +70,30 @@  #define AT91SAM9263_BASE_EMAC		0xfffbc000  #define AT91SAM9263_BASE_ISI		0xfffc4000  #define AT91SAM9263_BASE_2DGE		0xfffc8000 -#define AT91_BASE_SYS			0xffffe000  /* - * System Peripherals (offset from AT91_BASE_SYS) + * System Peripherals   */ -#define AT91_ECC0	(0xffffe000 - AT91_BASE_SYS) -#define AT91_SDRAMC0	(0xffffe200 - AT91_BASE_SYS) -#define AT91_SMC0	(0xffffe400 - AT91_BASE_SYS) -#define AT91_ECC1	(0xffffe600 - AT91_BASE_SYS) -#define AT91_SDRAMC1	(0xffffe800 - AT91_BASE_SYS) -#define AT91_SMC1	(0xffffea00 - AT91_BASE_SYS) -#define AT91_MATRIX	(0xffffec00 - AT91_BASE_SYS) -#define AT91_CCFG	(0xffffed10 - AT91_BASE_SYS) -#define AT91_DBGU	(0xffffee00 - AT91_BASE_SYS) -#define AT91_AIC	(0xfffff000 - AT91_BASE_SYS) -#define AT91_PIOA	(0xfffff200 - AT91_BASE_SYS) -#define AT91_PIOB	(0xfffff400 - AT91_BASE_SYS) -#define AT91_PIOC	(0xfffff600 - AT91_BASE_SYS) -#define AT91_PIOD	(0xfffff800 - AT91_BASE_SYS) -#define AT91_PIOE	(0xfffffa00 - AT91_BASE_SYS) -#define AT91_PMC	(0xfffffc00 - AT91_BASE_SYS) -#define AT91_RSTC	(0xfffffd00 - AT91_BASE_SYS) -#define AT91_SHDWC	(0xfffffd10 - AT91_BASE_SYS) -#define AT91_RTT0	(0xfffffd20 - AT91_BASE_SYS) -#define AT91_PIT	(0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT	(0xfffffd40 - AT91_BASE_SYS) -#define AT91_RTT1	(0xfffffd50 - AT91_BASE_SYS) -#define AT91_GPBR	(0xfffffd60 - AT91_BASE_SYS) - -#define AT91_USART0	AT91SAM9263_BASE_US0 -#define AT91_USART1	AT91SAM9263_BASE_US1 -#define AT91_USART2	AT91SAM9263_BASE_US2 +#define AT91SAM9263_BASE_ECC0	0xffffe000 +#define AT91SAM9263_BASE_SDRAMC0 0xffffe200 +#define AT91SAM9263_BASE_SMC0	0xffffe400 +#define AT91SAM9263_BASE_ECC1	0xffffe600 +#define AT91SAM9263_BASE_SDRAMC1 0xffffe800 +#define AT91SAM9263_BASE_SMC1	0xffffea00 +#define AT91SAM9263_BASE_MATRIX	0xffffec00 +#define AT91SAM9263_BASE_DBGU	AT91_BASE_DBGU1 +#define AT91SAM9263_BASE_PIOA	0xfffff200 +#define AT91SAM9263_BASE_PIOB	0xfffff400 +#define AT91SAM9263_BASE_PIOC	0xfffff600 +#define AT91SAM9263_BASE_PIOD	0xfffff800 +#define AT91SAM9263_BASE_PIOE	0xfffffa00 +#define AT91SAM9263_BASE_RSTC	0xfffffd00 +#define AT91SAM9263_BASE_SHDWC	0xfffffd10 +#define AT91SAM9263_BASE_RTT0	0xfffffd20 +#define AT91SAM9263_BASE_PIT	0xfffffd30 +#define AT91SAM9263_BASE_WDT	0xfffffd40 +#define AT91SAM9263_BASE_RTT1	0xfffffd50 +#define AT91SAM9263_BASE_GPBR	0xfffffd60  #define AT91_SMC	AT91_SMC0 diff --git a/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h index 9b3efd3eb2f..ebb5fdb565e 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h +++ b/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h @@ -15,15 +15,15 @@  #ifndef AT91SAM9263_MATRIX_H  #define AT91SAM9263_MATRIX_H -#define AT91_MATRIX_MCFG0	(AT91_MATRIX + 0x00)	/* Master Configuration Register 0 */ -#define AT91_MATRIX_MCFG1	(AT91_MATRIX + 0x04)	/* Master Configuration Register 1 */ -#define AT91_MATRIX_MCFG2	(AT91_MATRIX + 0x08)	/* Master Configuration Register 2 */ -#define AT91_MATRIX_MCFG3	(AT91_MATRIX + 0x0C)	/* Master Configuration Register 3 */ -#define AT91_MATRIX_MCFG4	(AT91_MATRIX + 0x10)	/* Master Configuration Register 4 */ -#define AT91_MATRIX_MCFG5	(AT91_MATRIX + 0x14)	/* Master Configuration Register 5 */ -#define AT91_MATRIX_MCFG6	(AT91_MATRIX + 0x18)	/* Master Configuration Register 6 */ -#define AT91_MATRIX_MCFG7	(AT91_MATRIX + 0x1C)	/* Master Configuration Register 7 */ -#define AT91_MATRIX_MCFG8	(AT91_MATRIX + 0x20)	/* Master Configuration Register 8 */ +#define AT91_MATRIX_MCFG0	0x00			/* Master Configuration Register 0 */ +#define AT91_MATRIX_MCFG1	0x04			/* Master Configuration Register 1 */ +#define AT91_MATRIX_MCFG2	0x08			/* Master Configuration Register 2 */ +#define AT91_MATRIX_MCFG3	0x0C			/* Master Configuration Register 3 */ +#define AT91_MATRIX_MCFG4	0x10			/* Master Configuration Register 4 */ +#define AT91_MATRIX_MCFG5	0x14			/* Master Configuration Register 5 */ +#define AT91_MATRIX_MCFG6	0x18			/* Master Configuration Register 6 */ +#define AT91_MATRIX_MCFG7	0x1C			/* Master Configuration Register 7 */ +#define AT91_MATRIX_MCFG8	0x20			/* Master Configuration Register 8 */  #define		AT91_MATRIX_ULBT	(7 << 0)	/* Undefined Length Burst Type */  #define			AT91_MATRIX_ULBT_INFINITE	(0 << 0)  #define			AT91_MATRIX_ULBT_SINGLE		(1 << 0) @@ -31,14 +31,14 @@  #define			AT91_MATRIX_ULBT_EIGHT		(3 << 0)  #define			AT91_MATRIX_ULBT_SIXTEEN	(4 << 0) -#define AT91_MATRIX_SCFG0	(AT91_MATRIX + 0x40)	/* Slave Configuration Register 0 */ -#define AT91_MATRIX_SCFG1	(AT91_MATRIX + 0x44)	/* Slave Configuration Register 1 */ -#define AT91_MATRIX_SCFG2	(AT91_MATRIX + 0x48)	/* Slave Configuration Register 2 */ -#define AT91_MATRIX_SCFG3	(AT91_MATRIX + 0x4C)	/* Slave Configuration Register 3 */ -#define AT91_MATRIX_SCFG4	(AT91_MATRIX + 0x50)	/* Slave Configuration Register 4 */ -#define AT91_MATRIX_SCFG5	(AT91_MATRIX + 0x54)	/* Slave Configuration Register 5 */ -#define AT91_MATRIX_SCFG6	(AT91_MATRIX + 0x58)	/* Slave Configuration Register 6 */ -#define AT91_MATRIX_SCFG7	(AT91_MATRIX + 0x5C)	/* Slave Configuration Register 7 */ +#define AT91_MATRIX_SCFG0	0x40			/* Slave Configuration Register 0 */ +#define AT91_MATRIX_SCFG1	0x44			/* Slave Configuration Register 1 */ +#define AT91_MATRIX_SCFG2	0x48			/* Slave Configuration Register 2 */ +#define AT91_MATRIX_SCFG3	0x4C			/* Slave Configuration Register 3 */ +#define AT91_MATRIX_SCFG4	0x50			/* Slave Configuration Register 4 */ +#define AT91_MATRIX_SCFG5	0x54			/* Slave Configuration Register 5 */ +#define AT91_MATRIX_SCFG6	0x58			/* Slave Configuration Register 6 */ +#define AT91_MATRIX_SCFG7	0x5C			/* Slave Configuration Register 7 */  #define		AT91_MATRIX_SLOT_CYCLE		(0xff << 0)	/* Maximum Number of Allowed Cycles for a Burst */  #define		AT91_MATRIX_DEFMSTR_TYPE	(3    << 16)	/* Default Master Type */  #define			AT91_MATRIX_DEFMSTR_TYPE_NONE	(0 << 16) @@ -49,22 +49,22 @@  #define			AT91_MATRIX_ARBT_ROUND_ROBIN	(0 << 24)  #define			AT91_MATRIX_ARBT_FIXED_PRIORITY	(1 << 24) -#define AT91_MATRIX_PRAS0	(AT91_MATRIX + 0x80)	/* Priority Register A for Slave 0 */ -#define AT91_MATRIX_PRBS0	(AT91_MATRIX + 0x84)	/* Priority Register B for Slave 0 */ -#define AT91_MATRIX_PRAS1	(AT91_MATRIX + 0x88)	/* Priority Register A for Slave 1 */ -#define AT91_MATRIX_PRBS1	(AT91_MATRIX + 0x8C)	/* Priority Register B for Slave 1 */ -#define AT91_MATRIX_PRAS2	(AT91_MATRIX + 0x90)	/* Priority Register A for Slave 2 */ -#define AT91_MATRIX_PRBS2	(AT91_MATRIX + 0x94)	/* Priority Register B for Slave 2 */ -#define AT91_MATRIX_PRAS3	(AT91_MATRIX + 0x98)	/* Priority Register A for Slave 3 */ -#define AT91_MATRIX_PRBS3	(AT91_MATRIX + 0x9C)	/* Priority Register B for Slave 3 */ -#define AT91_MATRIX_PRAS4	(AT91_MATRIX + 0xA0)	/* Priority Register A for Slave 4 */ -#define AT91_MATRIX_PRBS4	(AT91_MATRIX + 0xA4)	/* Priority Register B for Slave 4 */ -#define AT91_MATRIX_PRAS5	(AT91_MATRIX + 0xA8)	/* Priority Register A for Slave 5 */ -#define AT91_MATRIX_PRBS5	(AT91_MATRIX + 0xAC)	/* Priority Register B for Slave 5 */ -#define AT91_MATRIX_PRAS6	(AT91_MATRIX + 0xB0)	/* Priority Register A for Slave 6 */ -#define AT91_MATRIX_PRBS6	(AT91_MATRIX + 0xB4)	/* Priority Register B for Slave 6 */ -#define AT91_MATRIX_PRAS7	(AT91_MATRIX + 0xB8)	/* Priority Register A for Slave 7 */ -#define AT91_MATRIX_PRBS7	(AT91_MATRIX + 0xBC)	/* Priority Register B for Slave 7 */ +#define AT91_MATRIX_PRAS0	0x80			/* Priority Register A for Slave 0 */ +#define AT91_MATRIX_PRBS0	0x84			/* Priority Register B for Slave 0 */ +#define AT91_MATRIX_PRAS1	0x88			/* Priority Register A for Slave 1 */ +#define AT91_MATRIX_PRBS1	0x8C			/* Priority Register B for Slave 1 */ +#define AT91_MATRIX_PRAS2	0x90			/* Priority Register A for Slave 2 */ +#define AT91_MATRIX_PRBS2	0x94			/* Priority Register B for Slave 2 */ +#define AT91_MATRIX_PRAS3	0x98			/* Priority Register A for Slave 3 */ +#define AT91_MATRIX_PRBS3	0x9C			/* Priority Register B for Slave 3 */ +#define AT91_MATRIX_PRAS4	0xA0			/* Priority Register A for Slave 4 */ +#define AT91_MATRIX_PRBS4	0xA4			/* Priority Register B for Slave 4 */ +#define AT91_MATRIX_PRAS5	0xA8			/* Priority Register A for Slave 5 */ +#define AT91_MATRIX_PRBS5	0xAC			/* Priority Register B for Slave 5 */ +#define AT91_MATRIX_PRAS6	0xB0			/* Priority Register A for Slave 6 */ +#define AT91_MATRIX_PRBS6	0xB4			/* Priority Register B for Slave 6 */ +#define AT91_MATRIX_PRAS7	0xB8			/* Priority Register A for Slave 7 */ +#define AT91_MATRIX_PRBS7	0xBC			/* Priority Register B for Slave 7 */  #define		AT91_MATRIX_M0PR		(3 << 0)	/* Master 0 Priority */  #define		AT91_MATRIX_M1PR		(3 << 4)	/* Master 1 Priority */  #define		AT91_MATRIX_M2PR		(3 << 8)	/* Master 2 Priority */ @@ -75,7 +75,7 @@  #define		AT91_MATRIX_M7PR		(3 << 28)	/* Master 7 Priority */  #define		AT91_MATRIX_M8PR		(3 << 0)	/* Master 8 Priority (in Register B) */ -#define AT91_MATRIX_MRCR	(AT91_MATRIX + 0x100)	/* Master Remap Control Register */ +#define AT91_MATRIX_MRCR	0x100			/* Master Remap Control Register */  #define		AT91_MATRIX_RCB0		(1 << 0)	/* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */  #define		AT91_MATRIX_RCB1		(1 << 1)	/* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */  #define		AT91_MATRIX_RCB2		(1 << 2) @@ -86,7 +86,7 @@  #define		AT91_MATRIX_RCB7		(1 << 7)  #define		AT91_MATRIX_RCB8		(1 << 8) -#define AT91_MATRIX_TCMR	(AT91_MATRIX + 0x114)	/* TCM Configuration Register */ +#define AT91_MATRIX_TCMR	0x114			/* TCM Configuration Register */  #define		AT91_MATRIX_ITCM_SIZE		(0xf << 0)	/* Size of ITCM enabled memory block */  #define			AT91_MATRIX_ITCM_0		(0 << 0)  #define			AT91_MATRIX_ITCM_16		(5 << 0) @@ -96,7 +96,7 @@  #define			AT91_MATRIX_DTCM_16		(5 << 4)  #define			AT91_MATRIX_DTCM_32		(6 << 4) -#define AT91_MATRIX_EBI0CSA	(AT91_MATRIX + 0x120)	/* EBI0 Chip Select Assignment Register */ +#define AT91_MATRIX_EBI0CSA	0x120			/* EBI0 Chip Select Assignment Register */  #define		AT91_MATRIX_EBI0_CS1A		(1 << 1)	/* Chip Select 1 Assignment */  #define			AT91_MATRIX_EBI0_CS1A_SMC		(0 << 1)  #define			AT91_MATRIX_EBI0_CS1A_SDRAMC		(1 << 1) @@ -114,7 +114,7 @@  #define			AT91_MATRIX_EBI0_VDDIOMSEL_1_8V		(0 << 16)  #define			AT91_MATRIX_EBI0_VDDIOMSEL_3_3V		(1 << 16) -#define AT91_MATRIX_EBI1CSA	(AT91_MATRIX + 0x124)	/* EBI1 Chip Select Assignment Register */ +#define AT91_MATRIX_EBI1CSA	0x124			/* EBI1 Chip Select Assignment Register */  #define		AT91_MATRIX_EBI1_CS1A		(1 << 1)	/* Chip Select 1 Assignment */  #define			AT91_MATRIX_EBI1_CS1A_SMC		(0 << 1)  #define			AT91_MATRIX_EBI1_CS1A_SDRAMC		(1 << 1) diff --git a/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h b/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h index d27b15ba8eb..0210797abf2 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h +++ b/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h @@ -46,10 +46,10 @@  #define			AT91_DDRSDRC_CAS_25	(6 << 4)  #define		AT91_DDRSDRC_RST_DLL	(1 << 7)		/* Reset DLL */  #define		AT91_DDRSDRC_DICDS	(1 << 8)		/* Output impedance control */ -#define		AT91_DDRSDRC_DIS_DLL	(1 << 9)		/* Disable DLL */ -#define		AT91_DDRSDRC_OCD	(1 << 12)		/* Off-Chip Driver */ -#define		AT91_DDRSDRC_DQMS	(1 << 16)		/* Mask Data is Shared */ -#define		AT91_DDRSDRC_ACTBST	(1 << 18)		/* Active Bank X to Burst Stop Read Access Bank Y */ +#define		AT91_DDRSDRC_DIS_DLL	(1 << 9)		/* Disable DLL [SAM9 Only] */ +#define		AT91_DDRSDRC_OCD	(1 << 12)		/* Off-Chip Driver [SAM9 Only] */ +#define		AT91_DDRSDRC_DQMS	(1 << 16)		/* Mask Data is Shared [SAM9 Only] */ +#define		AT91_DDRSDRC_ACTBST	(1 << 18)		/* Active Bank X to Burst Stop Read Access Bank Y [SAM9 Only] */  #define AT91_DDRSDRC_T0PR	0x0C	/* Timing 0 Register */  #define		AT91_DDRSDRC_TRAS	(0xf <<  0)		/* Active to Precharge delay */ @@ -59,7 +59,7 @@  #define		AT91_DDRSDRC_TRP	(0xf << 16)		/* Row precharge delay */  #define		AT91_DDRSDRC_TRRD	(0xf << 20)		/* Active BankA to BankB */  #define		AT91_DDRSDRC_TWTR	(0x7 << 24)		/* Internal Write to Read delay */ -#define		AT91_DDRSDRC_RED_WRRD	(0x1 << 27)		/* Reduce Write to Read Delay */ +#define		AT91_DDRSDRC_RED_WRRD	(0x1 << 27)		/* Reduce Write to Read Delay [SAM9 Only] */  #define		AT91_DDRSDRC_TMRD	(0xf << 28)		/* Load mode to active/refresh delay */  #define AT91_DDRSDRC_T1PR	0x10	/* Timing 1 Register */ @@ -68,7 +68,7 @@  #define		AT91_DDRSDRC_TXSRD	(0xff << 16)		/* Exit self-refresh to read */  #define		AT91_DDRSDRC_TXP	(0xf  << 24)		/* Exit power-down delay */ -#define AT91_DDRSDRC_T2PR	0x14	/* Timing 2 Register */ +#define AT91_DDRSDRC_T2PR	0x14	/* Timing 2 Register [SAM9 Only] */  #define		AT91_DDRSDRC_TXARD	(0xf  << 0)		/* Exit active power down delay to read command in mode "Fast Exit" */  #define		AT91_DDRSDRC_TXARDS	(0xf  << 4)		/* Exit active power down delay to read command in mode "Slow Exit" */  #define		AT91_DDRSDRC_TRPA	(0xf  << 8)		/* Row Precharge All delay */ @@ -96,7 +96,7 @@  #define			AT91_DDRSDRC_MD_SDR		0  #define			AT91_DDRSDRC_MD_LOW_POWER_SDR	1  #define			AT91_DDRSDRC_MD_LOW_POWER_DDR	3 -#define			AT91_DDRSDRC_MD_DDR2		6 +#define			AT91_DDRSDRC_MD_DDR2		6	/* [SAM9 Only] */  #define		AT91_DDRSDRC_DBW	(1 << 4)		/* Data Bus Width */  #define			AT91_DDRSDRC_DBW_32BITS		(0 <<  4)  #define			AT91_DDRSDRC_DBW_16BITS		(1 <<  4) @@ -107,24 +107,18 @@  #define		AT91_DDRSDRC_MDOVF	(1 << 2)		/* Master Delay Overflow */  #define		AT91_DDRSDRC_MDVAL	(0xff <<  8)		/* Master Delay value */ -#define AT91_DDRSDRC_HS		0x2C	/* High Speed Register */ +#define AT91_DDRSDRC_HS		0x2C	/* High Speed Register [SAM9 Only] */  #define		AT91_DDRSDRC_DIS_ATCP_RD	(1 << 2)	/* Anticip read access is disabled */  #define AT91_DDRSDRC_DELAY(n)	(0x30 + (0x4 * (n)))	/* Delay I/O Register n */ -#define AT91_DDRSDRC_WPMR	0xE4	/* Write Protect Mode Register */ +#define AT91_DDRSDRC_WPMR	0xE4	/* Write Protect Mode Register [SAM9 Only] */  #define		AT91_DDRSDRC_WP		(1 << 0)		/* Write protect enable */  #define		AT91_DDRSDRC_WPKEY	(0xffffff << 8)		/* Write protect key */  #define		AT91_DDRSDRC_KEY	(0x444452 << 8)		/* Write protect key = "DDR" */ -#define AT91_DDRSDRC_WPSR	0xE8	/* Write Protect Status Register */ +#define AT91_DDRSDRC_WPSR	0xE8	/* Write Protect Status Register [SAM9 Only] */  #define		AT91_DDRSDRC_WPVS	(1 << 0)		/* Write protect violation status */  #define		AT91_DDRSDRC_WPVSRC	(0xffff << 8)		/* Write protect violation source */ -/* Register access macros */ -#define at91_ramc_read(num, reg) \ -	at91_sys_read(AT91_DDRSDRC##num + reg) -#define at91_ramc_write(num, reg, value) \ -	at91_sys_write(AT91_DDRSDRC##num + reg, value) -  #endif diff --git a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h index 100f5a59292..3d085a9a745 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h +++ b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h @@ -82,10 +82,4 @@  #define			AT91_SDRAMC_MD_SDRAM		0  #define			AT91_SDRAMC_MD_LOW_POWER_SDRAM	1 -/* Register access macros */ -#define at91_ramc_read(num, reg) \ -	at91_sys_read(AT91_SDRAMC##num + reg) -#define at91_ramc_write(num, reg, value) \ -	at91_sys_write(AT91_SDRAMC##num + reg, value) -  #endif diff --git a/arch/arm/mach-at91/include/mach/at91sam9_smc.h b/arch/arm/mach-at91/include/mach/at91sam9_smc.h index 57de6207e57..175e1fdd9fe 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9_smc.h +++ b/arch/arm/mach-at91/include/mach/at91sam9_smc.h @@ -16,7 +16,38 @@  #ifndef AT91SAM9_SMC_H  #define AT91SAM9_SMC_H -#define AT91_SMC_SETUP(n)	(AT91_SMC + 0x00 + ((n)*0x10))	/* Setup Register for CS n */ +#include <mach/cpu.h> + +#ifndef __ASSEMBLY__ +struct sam9_smc_config { +	/* Setup register */ +	u8 ncs_read_setup; +	u8 nrd_setup; +	u8 ncs_write_setup; +	u8 nwe_setup; + +	/* Pulse register */ +	u8 ncs_read_pulse; +	u8 nrd_pulse; +	u8 ncs_write_pulse; +	u8 nwe_pulse; + +	/* Cycle register */ +	u16 read_cycle; +	u16 write_cycle; + +	/* Mode register */ +	u32 mode; +	u8 tdf_cycles:4; +}; + +extern void sam9_smc_configure(int id, int cs, struct sam9_smc_config *config); +extern void sam9_smc_read(int id, int cs, struct sam9_smc_config *config); +extern void sam9_smc_read_mode(int id, int cs, struct sam9_smc_config *config); +extern void sam9_smc_write_mode(int id, int cs, struct sam9_smc_config *config); +#endif + +#define AT91_SMC_SETUP		0x00				/* Setup Register for CS n */  #define		AT91_SMC_NWESETUP	(0x3f << 0)			/* NWE Setup Length */  #define			AT91_SMC_NWESETUP_(x)	((x) << 0)  #define		AT91_SMC_NCS_WRSETUP	(0x3f << 8)			/* NCS Setup Length in Write Access */ @@ -26,7 +57,7 @@  #define		AT91_SMC_NCS_RDSETUP	(0x3f << 24)			/* NCS Setup Length in Read Access */  #define			AT91_SMC_NCS_RDSETUP_(x)	((x) << 24) -#define AT91_SMC_PULSE(n)	(AT91_SMC + 0x04 + ((n)*0x10))	/* Pulse Register for CS n */ +#define AT91_SMC_PULSE		0x04				/* Pulse Register for CS n */  #define		AT91_SMC_NWEPULSE	(0x7f <<  0)			/* NWE Pulse Length */  #define			AT91_SMC_NWEPULSE_(x)	((x) << 0)  #define		AT91_SMC_NCS_WRPULSE	(0x7f <<  8)			/* NCS Pulse Length in Write Access */ @@ -36,13 +67,13 @@  #define		AT91_SMC_NCS_RDPULSE	(0x7f << 24)			/* NCS Pulse Length in Read Access */  #define			AT91_SMC_NCS_RDPULSE_(x)((x) << 24) -#define AT91_SMC_CYCLE(n)	(AT91_SMC + 0x08 + ((n)*0x10))	/* Cycle Register for CS n */ +#define AT91_SMC_CYCLE		0x08				/* Cycle Register for CS n */  #define		AT91_SMC_NWECYCLE	(0x1ff << 0 )			/* Total Write Cycle Length */  #define			AT91_SMC_NWECYCLE_(x)	((x) << 0)  #define		AT91_SMC_NRDCYCLE	(0x1ff << 16)			/* Total Read Cycle Length */  #define			AT91_SMC_NRDCYCLE_(x)	((x) << 16) -#define AT91_SMC_MODE(n)	(AT91_SMC + 0x0c + ((n)*0x10))	/* Mode Register for CS n */ +#define AT91_SMC_MODE		0x0c				/* Mode Register for CS n */  #define		AT91_SMC_READMODE	(1 <<  0)			/* Read Mode */  #define		AT91_SMC_WRITEMODE	(1 <<  1)			/* Write Mode */  #define		AT91_SMC_EXNWMODE	(3 <<  4)			/* NWAIT Mode */ @@ -66,11 +97,4 @@  #define			AT91_SMC_PS_16			(2 << 28)  #define			AT91_SMC_PS_32			(3 << 28) -#if defined(AT91_SMC1)		/* The AT91SAM9263 has 2 Static Memory contollers */ -#define AT91_SMC1_SETUP(n)	(AT91_SMC1 + 0x00 + ((n)*0x10))	/* Setup Register for CS n */ -#define AT91_SMC1_PULSE(n)	(AT91_SMC1 + 0x04 + ((n)*0x10))	/* Pulse Register for CS n */ -#define AT91_SMC1_CYCLE(n)	(AT91_SMC1 + 0x08 + ((n)*0x10))	/* Cycle Register for CS n */ -#define AT91_SMC1_MODE(n)	(AT91_SMC1 + 0x0c + ((n)*0x10))	/* Mode Register for CS n */ -#endif -  #endif diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45.h b/arch/arm/mach-at91/include/mach/at91sam9g45.h index a526869aee3..8eba1021f53 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9g45.h +++ b/arch/arm/mach-at91/include/mach/at91sam9g45.h @@ -18,8 +18,6 @@  /*   * Peripheral identifiers/interrupts.   */ -#define AT91_ID_FIQ		0	/* Advanced Interrupt Controller (FIQ) */ -#define AT91_ID_SYS		1	/* System Controller Interrupt */  #define AT91SAM9G45_ID_PIOA	2	/* Parallel I/O Controller A */  #define AT91SAM9G45_ID_PIOB	3	/* Parallel I/O Controller B */  #define AT91SAM9G45_ID_PIOC	4	/* Parallel I/O Controller C */ @@ -84,37 +82,29 @@  #define AT91SAM9G45_BASE_TC3		0xfffd4000  #define AT91SAM9G45_BASE_TC4		0xfffd4040  #define AT91SAM9G45_BASE_TC5		0xfffd4080 -#define AT91_BASE_SYS			0xffffe200  /* - * System Peripherals (offset from AT91_BASE_SYS) + * System Peripherals   */ -#define AT91_ECC	(0xffffe200 - AT91_BASE_SYS) -#define AT91_DDRSDRC1	(0xffffe400 - AT91_BASE_SYS) -#define AT91_DDRSDRC0	(0xffffe600 - AT91_BASE_SYS) -#define AT91_SMC	(0xffffe800 - AT91_BASE_SYS) -#define AT91_MATRIX	(0xffffea00 - AT91_BASE_SYS) -#define AT91_DMA	(0xffffec00 - AT91_BASE_SYS) -#define AT91_DBGU	(0xffffee00 - AT91_BASE_SYS) -#define AT91_AIC	(0xfffff000 - AT91_BASE_SYS) -#define AT91_PIOA	(0xfffff200 - AT91_BASE_SYS) -#define AT91_PIOB	(0xfffff400 - AT91_BASE_SYS) -#define AT91_PIOC	(0xfffff600 - AT91_BASE_SYS) -#define AT91_PIOD	(0xfffff800 - AT91_BASE_SYS) -#define AT91_PIOE	(0xfffffa00 - AT91_BASE_SYS) -#define AT91_PMC	(0xfffffc00 - AT91_BASE_SYS) -#define AT91_RSTC	(0xfffffd00 - AT91_BASE_SYS) -#define AT91_SHDWC	(0xfffffd10 - AT91_BASE_SYS) -#define AT91_RTT	(0xfffffd20 - AT91_BASE_SYS) -#define AT91_PIT	(0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT	(0xfffffd40 - AT91_BASE_SYS) -#define AT91_GPBR	(0xfffffd60 - AT91_BASE_SYS) -#define AT91_RTC	(0xfffffdb0 - AT91_BASE_SYS) - -#define AT91_USART0	AT91SAM9G45_BASE_US0 -#define AT91_USART1	AT91SAM9G45_BASE_US1 -#define AT91_USART2	AT91SAM9G45_BASE_US2 -#define AT91_USART3	AT91SAM9G45_BASE_US3 +#define AT91SAM9G45_BASE_ECC	0xffffe200 +#define AT91SAM9G45_BASE_DDRSDRC1 0xffffe400 +#define AT91SAM9G45_BASE_DDRSDRC0 0xffffe600 +#define AT91SAM9G45_BASE_DMA	0xffffec00 +#define AT91SAM9G45_BASE_SMC	0xffffe800 +#define AT91SAM9G45_BASE_MATRIX	0xffffea00 +#define AT91SAM9G45_BASE_DBGU	AT91_BASE_DBGU1 +#define AT91SAM9G45_BASE_PIOA	0xfffff200 +#define AT91SAM9G45_BASE_PIOB	0xfffff400 +#define AT91SAM9G45_BASE_PIOC	0xfffff600 +#define AT91SAM9G45_BASE_PIOD	0xfffff800 +#define AT91SAM9G45_BASE_PIOE	0xfffffa00 +#define AT91SAM9G45_BASE_RSTC	0xfffffd00 +#define AT91SAM9G45_BASE_SHDWC	0xfffffd10 +#define AT91SAM9G45_BASE_RTT	0xfffffd20 +#define AT91SAM9G45_BASE_PIT	0xfffffd30 +#define AT91SAM9G45_BASE_WDT	0xfffffd40 +#define AT91SAM9G45_BASE_RTC	0xfffffdb0 +#define AT91SAM9G45_BASE_GPBR	0xfffffd60  /*   * Internal Memory. @@ -131,10 +121,6 @@  #define AT91SAM9G45_EHCI_BASE	0x00800000	/* USB Host controller (EHCI) */  #define AT91SAM9G45_VDEC_BASE	0x00900000	/* Video Decoder Controller */ -#define CONFIG_DRAM_BASE	AT91_CHIPSELECT_6 - -#define CONSISTENT_DMA_SIZE	SZ_4M -  /*   * DMA peripheral identifiers   * for hardware handshaking interface @@ -150,6 +136,8 @@  #define AT_DMA_ID_SSC1_RX	 8  #define AT_DMA_ID_AC97_TX	 9  #define AT_DMA_ID_AC97_RX	10 +#define AT_DMA_ID_AES_TX	11 +#define AT_DMA_ID_AES_RX	12  #define AT_DMA_ID_MCI1		13  #endif diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h index c972d60e0ae..b76e2ed2fbc 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h +++ b/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h @@ -15,18 +15,18 @@  #ifndef AT91SAM9G45_MATRIX_H  #define AT91SAM9G45_MATRIX_H -#define AT91_MATRIX_MCFG0	(AT91_MATRIX + 0x00)	/* Master Configuration Register 0 */ -#define AT91_MATRIX_MCFG1	(AT91_MATRIX + 0x04)	/* Master Configuration Register 1 */ -#define AT91_MATRIX_MCFG2	(AT91_MATRIX + 0x08)	/* Master Configuration Register 2 */ -#define AT91_MATRIX_MCFG3	(AT91_MATRIX + 0x0C)	/* Master Configuration Register 3 */ -#define AT91_MATRIX_MCFG4	(AT91_MATRIX + 0x10)	/* Master Configuration Register 4 */ -#define AT91_MATRIX_MCFG5	(AT91_MATRIX + 0x14)	/* Master Configuration Register 5 */ -#define AT91_MATRIX_MCFG6	(AT91_MATRIX + 0x18)	/* Master Configuration Register 6 */ -#define AT91_MATRIX_MCFG7	(AT91_MATRIX + 0x1C)	/* Master Configuration Register 7 */ -#define AT91_MATRIX_MCFG8	(AT91_MATRIX + 0x20)	/* Master Configuration Register 8 */ -#define AT91_MATRIX_MCFG9	(AT91_MATRIX + 0x24)	/* Master Configuration Register 9 */ -#define AT91_MATRIX_MCFG10	(AT91_MATRIX + 0x28)	/* Master Configuration Register 10 */ -#define AT91_MATRIX_MCFG11	(AT91_MATRIX + 0x2C)	/* Master Configuration Register 11 */ +#define AT91_MATRIX_MCFG0	0x00			/* Master Configuration Register 0 */ +#define AT91_MATRIX_MCFG1	0x04			/* Master Configuration Register 1 */ +#define AT91_MATRIX_MCFG2	0x08			/* Master Configuration Register 2 */ +#define AT91_MATRIX_MCFG3	0x0C			/* Master Configuration Register 3 */ +#define AT91_MATRIX_MCFG4	0x10			/* Master Configuration Register 4 */ +#define AT91_MATRIX_MCFG5	0x14			/* Master Configuration Register 5 */ +#define AT91_MATRIX_MCFG6	0x18			/* Master Configuration Register 6 */ +#define AT91_MATRIX_MCFG7	0x1C			/* Master Configuration Register 7 */ +#define AT91_MATRIX_MCFG8	0x20			/* Master Configuration Register 8 */ +#define AT91_MATRIX_MCFG9	0x24			/* Master Configuration Register 9 */ +#define AT91_MATRIX_MCFG10	0x28			/* Master Configuration Register 10 */ +#define AT91_MATRIX_MCFG11	0x2C			/* Master Configuration Register 11 */  #define		AT91_MATRIX_ULBT	(7 << 0)	/* Undefined Length Burst Type */  #define			AT91_MATRIX_ULBT_INFINITE	(0 << 0)  #define			AT91_MATRIX_ULBT_SINGLE		(1 << 0) @@ -37,14 +37,14 @@  #define			AT91_MATRIX_ULBT_SIXTYFOUR	(6 << 0)  #define			AT91_MATRIX_ULBT_128		(7 << 0) -#define AT91_MATRIX_SCFG0	(AT91_MATRIX + 0x40)	/* Slave Configuration Register 0 */ -#define AT91_MATRIX_SCFG1	(AT91_MATRIX + 0x44)	/* Slave Configuration Register 1 */ -#define AT91_MATRIX_SCFG2	(AT91_MATRIX + 0x48)	/* Slave Configuration Register 2 */ -#define AT91_MATRIX_SCFG3	(AT91_MATRIX + 0x4C)	/* Slave Configuration Register 3 */ -#define AT91_MATRIX_SCFG4	(AT91_MATRIX + 0x50)	/* Slave Configuration Register 4 */ -#define AT91_MATRIX_SCFG5	(AT91_MATRIX + 0x54)	/* Slave Configuration Register 5 */ -#define AT91_MATRIX_SCFG6	(AT91_MATRIX + 0x58)	/* Slave Configuration Register 6 */ -#define AT91_MATRIX_SCFG7	(AT91_MATRIX + 0x5C)	/* Slave Configuration Register 7 */ +#define AT91_MATRIX_SCFG0	0x40			/* Slave Configuration Register 0 */ +#define AT91_MATRIX_SCFG1	0x44			/* Slave Configuration Register 1 */ +#define AT91_MATRIX_SCFG2	0x48			/* Slave Configuration Register 2 */ +#define AT91_MATRIX_SCFG3	0x4C			/* Slave Configuration Register 3 */ +#define AT91_MATRIX_SCFG4	0x50			/* Slave Configuration Register 4 */ +#define AT91_MATRIX_SCFG5	0x54			/* Slave Configuration Register 5 */ +#define AT91_MATRIX_SCFG6	0x58			/* Slave Configuration Register 6 */ +#define AT91_MATRIX_SCFG7	0x5C			/* Slave Configuration Register 7 */  #define		AT91_MATRIX_SLOT_CYCLE		(0x1ff << 0)	/* Maximum Number of Allowed Cycles for a Burst */  #define		AT91_MATRIX_DEFMSTR_TYPE	(3    << 16)	/* Default Master Type */  #define			AT91_MATRIX_DEFMSTR_TYPE_NONE	(0 << 16) @@ -52,22 +52,22 @@  #define			AT91_MATRIX_DEFMSTR_TYPE_FIXED	(2 << 16)  #define		AT91_MATRIX_FIXED_DEFMSTR	(0xf  << 18)	/* Fixed Index of Default Master */ -#define AT91_MATRIX_PRAS0	(AT91_MATRIX + 0x80)	/* Priority Register A for Slave 0 */ -#define AT91_MATRIX_PRBS0	(AT91_MATRIX + 0x84)	/* Priority Register B for Slave 0 */ -#define AT91_MATRIX_PRAS1	(AT91_MATRIX + 0x88)	/* Priority Register A for Slave 1 */ -#define AT91_MATRIX_PRBS1	(AT91_MATRIX + 0x8C)	/* Priority Register B for Slave 1 */ -#define AT91_MATRIX_PRAS2	(AT91_MATRIX + 0x90)	/* Priority Register A for Slave 2 */ -#define AT91_MATRIX_PRBS2	(AT91_MATRIX + 0x94)	/* Priority Register B for Slave 2 */ -#define AT91_MATRIX_PRAS3	(AT91_MATRIX + 0x98)	/* Priority Register A for Slave 3 */ -#define AT91_MATRIX_PRBS3	(AT91_MATRIX + 0x9C)	/* Priority Register B for Slave 3 */ -#define AT91_MATRIX_PRAS4	(AT91_MATRIX + 0xA0)	/* Priority Register A for Slave 4 */ -#define AT91_MATRIX_PRBS4	(AT91_MATRIX + 0xA4)	/* Priority Register B for Slave 4 */ -#define AT91_MATRIX_PRAS5	(AT91_MATRIX + 0xA8)	/* Priority Register A for Slave 5 */ -#define AT91_MATRIX_PRBS5	(AT91_MATRIX + 0xAC)	/* Priority Register B for Slave 5 */ -#define AT91_MATRIX_PRAS6	(AT91_MATRIX + 0xB0)	/* Priority Register A for Slave 6 */ -#define AT91_MATRIX_PRBS6	(AT91_MATRIX + 0xB4)	/* Priority Register B for Slave 6 */ -#define AT91_MATRIX_PRAS7	(AT91_MATRIX + 0xB8)	/* Priority Register A for Slave 7 */ -#define AT91_MATRIX_PRBS7	(AT91_MATRIX + 0xBC)	/* Priority Register B for Slave 7 */ +#define AT91_MATRIX_PRAS0	0x80			/* Priority Register A for Slave 0 */ +#define AT91_MATRIX_PRBS0	0x84			/* Priority Register B for Slave 0 */ +#define AT91_MATRIX_PRAS1	0x88			/* Priority Register A for Slave 1 */ +#define AT91_MATRIX_PRBS1	0x8C			/* Priority Register B for Slave 1 */ +#define AT91_MATRIX_PRAS2	0x90			/* Priority Register A for Slave 2 */ +#define AT91_MATRIX_PRBS2	0x94			/* Priority Register B for Slave 2 */ +#define AT91_MATRIX_PRAS3	0x98			/* Priority Register A for Slave 3 */ +#define AT91_MATRIX_PRBS3	0x9C			/* Priority Register B for Slave 3 */ +#define AT91_MATRIX_PRAS4	0xA0			/* Priority Register A for Slave 4 */ +#define AT91_MATRIX_PRBS4	0xA4			/* Priority Register B for Slave 4 */ +#define AT91_MATRIX_PRAS5	0xA8			/* Priority Register A for Slave 5 */ +#define AT91_MATRIX_PRBS5	0xAC			/* Priority Register B for Slave 5 */ +#define AT91_MATRIX_PRAS6	0xB0			/* Priority Register A for Slave 6 */ +#define AT91_MATRIX_PRBS6	0xB4			/* Priority Register B for Slave 6 */ +#define AT91_MATRIX_PRAS7	0xB8			/* Priority Register A for Slave 7 */ +#define AT91_MATRIX_PRBS7	0xBC			/* Priority Register B for Slave 7 */  #define		AT91_MATRIX_M0PR		(3 << 0)	/* Master 0 Priority */  #define		AT91_MATRIX_M1PR		(3 << 4)	/* Master 1 Priority */  #define		AT91_MATRIX_M2PR		(3 << 8)	/* Master 2 Priority */ @@ -81,7 +81,7 @@  #define		AT91_MATRIX_M10PR		(3 << 8)	/* Master 10 Priority (in Register B) */  #define		AT91_MATRIX_M11PR		(3 << 12)	/* Master 11 Priority (in Register B) */ -#define AT91_MATRIX_MRCR	(AT91_MATRIX + 0x100)	/* Master Remap Control Register */ +#define AT91_MATRIX_MRCR	0x100			/* Master Remap Control Register */  #define		AT91_MATRIX_RCB0		(1 << 0)	/* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */  #define		AT91_MATRIX_RCB1		(1 << 1)	/* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */  #define		AT91_MATRIX_RCB2		(1 << 2) @@ -95,7 +95,7 @@  #define		AT91_MATRIX_RCB10		(1 << 10)  #define		AT91_MATRIX_RCB11		(1 << 11) -#define AT91_MATRIX_TCMR	(AT91_MATRIX + 0x110)	/* TCM Configuration Register */ +#define AT91_MATRIX_TCMR	0x110			/* TCM Configuration Register */  #define		AT91_MATRIX_ITCM_SIZE		(0xf << 0)	/* Size of ITCM enabled memory block */  #define			AT91_MATRIX_ITCM_0		(0 << 0)  #define			AT91_MATRIX_ITCM_32		(6 << 0) @@ -107,12 +107,12 @@  #define			AT91_MATRIX_TCM_NO_WS		(0x0 << 11)  #define			AT91_MATRIX_TCM_ONE_WS		(0x1 << 11) -#define AT91_MATRIX_VIDEO	(AT91_MATRIX + 0x118)	/* Video Mode Configuration Register */ +#define AT91_MATRIX_VIDEO	0x118			/* Video Mode Configuration Register */  #define		AT91C_VDEC_SEL			(0x1 <<  0) /* Video Mode Selection */  #define			AT91C_VDEC_SEL_OFF		(0 << 0)  #define			AT91C_VDEC_SEL_ON		(1 << 0) -#define AT91_MATRIX_EBICSA	(AT91_MATRIX + 0x128)	/* EBI Chip Select Assignment Register */ +#define AT91_MATRIX_EBICSA	0x128			/* EBI Chip Select Assignment Register */  #define		AT91_MATRIX_EBI_CS1A		(1 << 1)	/* Chip Select 1 Assignment */  #define			AT91_MATRIX_EBI_CS1A_SMC		(0 << 1)  #define			AT91_MATRIX_EBI_CS1A_SDRAMC		(1 << 1) @@ -138,13 +138,13 @@  #define			AT91_MATRIX_EBI_DDR_IOSR_REDUCED	(0 << 18)  #define			AT91_MATRIX_EBI_DDR_IOSR_NORMAL		(1 << 18) -#define AT91_MATRIX_WPMR	(AT91_MATRIX + 0x1E4)	/* Write Protect Mode Register */ +#define AT91_MATRIX_WPMR	0x1E4			/* Write Protect Mode Register */  #define		AT91_MATRIX_WPMR_WPEN		(1 << 0)	/* Write Protect ENable */  #define			AT91_MATRIX_WPMR_WP_WPDIS		(0 << 0)  #define			AT91_MATRIX_WPMR_WP_WPEN		(1 << 0)  #define		AT91_MATRIX_WPMR_WPKEY		(0xFFFFFF << 8)	/* Write Protect KEY */ -#define AT91_MATRIX_WPSR	(AT91_MATRIX + 0x1E8)	/* Write Protect Status Register */ +#define AT91_MATRIX_WPSR	0x1E8			/* Write Protect Status Register */  #define		AT91_MATRIX_WPSR_WPVS		(1 << 0)	/* Write Protect Violation Status */  #define			AT91_MATRIX_WPSR_NO_WPV		(0 << 0)  #define			AT91_MATRIX_WPSR_WPV		(1 << 0) diff --git a/arch/arm/mach-at91/include/mach/at91sam9n12.h b/arch/arm/mach-at91/include/mach/at91sam9n12.h new file mode 100644 index 00000000000..0151bcf6163 --- /dev/null +++ b/arch/arm/mach-at91/include/mach/at91sam9n12.h @@ -0,0 +1,65 @@ +/* + * SoC specific header file for the AT91SAM9N12 + * + * Copyright (C) 2012 Atmel Corporation + * + * Common definitions, based on AT91SAM9N12 SoC datasheet + * + * Licensed under GPLv2 or later + */ + +#ifndef _AT91SAM9N12_H_ +#define _AT91SAM9N12_H_ + +/* + * Peripheral identifiers/interrupts. + */ +#define AT91SAM9N12_ID_PIOAB	2	/* Parallel I/O Controller A and B */ +#define AT91SAM9N12_ID_PIOCD	3	/* Parallel I/O Controller C and D */ +#define AT91SAM9N12_ID_FUSE	4	/* FUSE Controller */ +#define AT91SAM9N12_ID_USART0	5	/* USART 0 */ +#define AT91SAM9N12_ID_USART1	6	/* USART 1 */ +#define AT91SAM9N12_ID_USART2	7	/* USART 2 */ +#define AT91SAM9N12_ID_USART3	8	/* USART 3 */ +#define AT91SAM9N12_ID_TWI0	9	/* Two-Wire Interface 0 */ +#define AT91SAM9N12_ID_TWI1	10	/* Two-Wire Interface 1 */ +#define AT91SAM9N12_ID_MCI	12	/* High Speed Multimedia Card Interface */ +#define AT91SAM9N12_ID_SPI0	13	/* Serial Peripheral Interface 0 */ +#define AT91SAM9N12_ID_SPI1	14	/* Serial Peripheral Interface 1 */ +#define AT91SAM9N12_ID_UART0	15	/* UART 0 */ +#define AT91SAM9N12_ID_UART1	16	/* UART 1 */ +#define AT91SAM9N12_ID_TCB	17	/* Timer Counter 0, 1, 2, 3, 4 and 5 */ +#define AT91SAM9N12_ID_PWM	18	/* Pulse Width Modulation Controller */ +#define AT91SAM9N12_ID_ADC	19	/* ADC Controller */ +#define AT91SAM9N12_ID_DMA	20	/* DMA Controller */ +#define AT91SAM9N12_ID_UHP	22	/* USB Host High Speed */ +#define AT91SAM9N12_ID_UDP	23	/* USB Device High Speed */ +#define AT91SAM9N12_ID_LCDC	25	/* LCD Controller */ +#define AT91SAM9N12_ID_ISI	25	/* Image Sensor Interface */ +#define AT91SAM9N12_ID_SSC	28	/* Synchronous Serial Controller */ +#define AT91SAM9N12_ID_TRNG	30	/* TRNG */ +#define AT91SAM9N12_ID_IRQ0	31	/* Advanced Interrupt Controller */ + +/* + * User Peripheral physical base addresses. + */ +#define AT91SAM9N12_BASE_USART0	0xf801c000 +#define AT91SAM9N12_BASE_USART1	0xf8020000 +#define AT91SAM9N12_BASE_USART2	0xf8024000 +#define AT91SAM9N12_BASE_USART3	0xf8028000 + +/* + * System Peripherals + */ +#define AT91SAM9N12_BASE_RTC	0xfffffeb0 + +/* + * Internal Memory. + */ +#define AT91SAM9N12_SRAM_BASE	0x00300000	/* Internal SRAM base address */ +#define AT91SAM9N12_SRAM_SIZE	SZ_32K		/* Internal SRAM size (32Kb) */ + +#define AT91SAM9N12_ROM_BASE	0x00100000	/* Internal ROM base address */ +#define AT91SAM9N12_ROM_SIZE	SZ_128K		/* Internal ROM size (128Kb) */ + +#endif diff --git a/arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h new file mode 100644 index 00000000000..40060cd62fa --- /dev/null +++ b/arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h @@ -0,0 +1,53 @@ +/* + * Matrix-centric header file for the AT91SAM9N12 + * + * Copyright (C) 2012 Atmel Corporation. + * + * Only EBI related registers. + * Write Protect register definitions may be useful. + * + * Licensed under GPLv2 or later. + */ + +#ifndef _AT91SAM9N12_MATRIX_H_ +#define _AT91SAM9N12_MATRIX_H_ + +#define AT91_MATRIX_EBICSA	(AT91_MATRIX + 0x118)	/* EBI Chip Select Assignment Register */ +#define		AT91_MATRIX_EBI_CS1A		(1 << 1)	/* Chip Select 1 Assignment */ +#define			AT91_MATRIX_EBI_CS1A_SMC		(0 << 1) +#define			AT91_MATRIX_EBI_CS1A_SDRAMC		(1 << 1) +#define		AT91_MATRIX_EBI_CS3A		(1 << 3)	/* Chip Select 3 Assignment */ +#define			AT91_MATRIX_EBI_CS3A_SMC		(0 << 3) +#define			AT91_MATRIX_EBI_CS3A_SMC_NANDFLASH	(1 << 3) +#define		AT91_MATRIX_EBI_DBPUC		(1 << 8)	/* Data Bus Pull-up Configuration */ +#define			AT91_MATRIX_EBI_DBPU_ON			(0 << 8) +#define			AT91_MATRIX_EBI_DBPU_OFF		(1 << 8) +#define		AT91_MATRIX_EBI_VDDIOMSEL	(1 << 16)	/* Memory voltage selection */ +#define			AT91_MATRIX_EBI_VDDIOMSEL_1_8V		(0 << 16) +#define			AT91_MATRIX_EBI_VDDIOMSEL_3_3V		(1 << 16) +#define		AT91_MATRIX_EBI_EBI_IOSR	(1 << 17)	/* EBI I/O slew rate selection */ +#define			AT91_MATRIX_EBI_EBI_IOSR_REDUCED	(0 << 17) +#define			AT91_MATRIX_EBI_EBI_IOSR_NORMAL		(1 << 17) +#define		AT91_MATRIX_EBI_DDR_IOSR	(1 << 18)	/* DDR2 dedicated port I/O slew rate selection */ +#define			AT91_MATRIX_EBI_DDR_IOSR_REDUCED	(0 << 18) +#define			AT91_MATRIX_EBI_DDR_IOSR_NORMAL		(1 << 18) +#define		AT91_MATRIX_NFD0_SELECT		(1 << 24)	/* NAND Flash Data Bus Selection */ +#define			AT91_MATRIX_NFD0_ON_D0			(0 << 24) +#define			AT91_MATRIX_NFD0_ON_D16			(1 << 24) +#define		AT91_MATRIX_DDR_MP_EN		(1 << 25)	/* DDR Multi-port Enable */ +#define			AT91_MATRIX_MP_OFF			(0 << 25) +#define			AT91_MATRIX_MP_ON			(1 << 25) + +#define AT91_MATRIX_WPMR	(AT91_MATRIX + 0x1E4)	/* Write Protect Mode Register */ +#define		AT91_MATRIX_WPMR_WPEN		(1 << 0)	/* Write Protect ENable */ +#define			AT91_MATRIX_WPMR_WP_WPDIS		(0 << 0) +#define			AT91_MATRIX_WPMR_WP_WPEN		(1 << 0) +#define		AT91_MATRIX_WPMR_WPKEY		(0xFFFFFF << 8)	/* Write Protect KEY */ + +#define AT91_MATRIX_WPSR	(AT91_MATRIX + 0x1E8)	/* Write Protect Status Register */ +#define		AT91_MATRIX_WPSR_WPVS		(1 << 0)	/* Write Protect Violation Status */ +#define			AT91_MATRIX_WPSR_NO_WPV		(0 << 0) +#define			AT91_MATRIX_WPSR_WPV		(1 << 0) +#define		AT91_MATRIX_WPSR_WPVSRC		(0xFFFF << 8)	/* Write Protect Violation Source */ + +#endif diff --git a/arch/arm/mach-at91/include/mach/at91sam9rl.h b/arch/arm/mach-at91/include/mach/at91sam9rl.h index 87ba8517ad9..a15db56d33f 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9rl.h +++ b/arch/arm/mach-at91/include/mach/at91sam9rl.h @@ -17,8 +17,6 @@  /*   * Peripheral identifiers/interrupts.   */ -#define AT91_ID_FIQ		0	/* Advanced Interrupt Controller (FIQ) */ -#define AT91_ID_SYS		1	/* System Controller */  #define AT91SAM9RL_ID_PIOA	2	/* Parallel IO Controller A */  #define AT91SAM9RL_ID_PIOB	3	/* Parallel IO Controller B */  #define AT91SAM9RL_ID_PIOC	4	/* Parallel IO Controller C */ @@ -66,38 +64,30 @@  #define AT91SAM9RL_BASE_TSC	0xfffd0000  #define AT91SAM9RL_BASE_UDPHS	0xfffd4000  #define AT91SAM9RL_BASE_AC97C	0xfffd8000 -#define AT91_BASE_SYS		0xffffc000  /*   * System Peripherals (offset from AT91_BASE_SYS)   */ -#define AT91_DMA	(0xffffe600 - AT91_BASE_SYS) -#define AT91_ECC	(0xffffe800 - AT91_BASE_SYS) -#define AT91_SDRAMC0	(0xffffea00 - AT91_BASE_SYS) -#define AT91_SMC	(0xffffec00 - AT91_BASE_SYS) -#define AT91_MATRIX	(0xffffee00 - AT91_BASE_SYS) -#define AT91_CCFG	(0xffffef10 - AT91_BASE_SYS) -#define AT91_AIC	(0xfffff000 - AT91_BASE_SYS) -#define AT91_DBGU	(0xfffff200 - AT91_BASE_SYS) -#define AT91_PIOA	(0xfffff400 - AT91_BASE_SYS) -#define AT91_PIOB	(0xfffff600 - AT91_BASE_SYS) -#define AT91_PIOC	(0xfffff800 - AT91_BASE_SYS) -#define AT91_PIOD	(0xfffffa00 - AT91_BASE_SYS) -#define AT91_PMC	(0xfffffc00 - AT91_BASE_SYS) -#define AT91_RSTC	(0xfffffd00 - AT91_BASE_SYS) -#define AT91_SHDWC	(0xfffffd10 - AT91_BASE_SYS) -#define AT91_RTT	(0xfffffd20 - AT91_BASE_SYS) -#define AT91_PIT	(0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT	(0xfffffd40 - AT91_BASE_SYS)  #define AT91_SCKCR	(0xfffffd50 - AT91_BASE_SYS) -#define AT91_GPBR	(0xfffffd60 - AT91_BASE_SYS) -#define AT91_RTC	(0xfffffe00 - AT91_BASE_SYS) -#define AT91_USART0	AT91SAM9RL_BASE_US0 -#define AT91_USART1	AT91SAM9RL_BASE_US1 -#define AT91_USART2	AT91SAM9RL_BASE_US2 -#define AT91_USART3	AT91SAM9RL_BASE_US3 +#define AT91SAM9RL_BASE_DMA	0xffffe600 +#define AT91SAM9RL_BASE_ECC	0xffffe800 +#define AT91SAM9RL_BASE_SDRAMC	0xffffea00 +#define AT91SAM9RL_BASE_SMC	0xffffec00 +#define AT91SAM9RL_BASE_MATRIX	0xffffee00 +#define AT91SAM9RL_BASE_DBGU	AT91_BASE_DBGU0 +#define AT91SAM9RL_BASE_PIOA	0xfffff400 +#define AT91SAM9RL_BASE_PIOB	0xfffff600 +#define AT91SAM9RL_BASE_PIOC	0xfffff800 +#define AT91SAM9RL_BASE_PIOD	0xfffffa00 +#define AT91SAM9RL_BASE_RSTC	0xfffffd00 +#define AT91SAM9RL_BASE_SHDWC	0xfffffd10 +#define AT91SAM9RL_BASE_RTT	0xfffffd20 +#define AT91SAM9RL_BASE_PIT	0xfffffd30 +#define AT91SAM9RL_BASE_WDT	0xfffffd40 +#define AT91SAM9RL_BASE_GPBR	0xfffffd60 +#define AT91SAM9RL_BASE_RTC	0xfffffe00  /* diff --git a/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h index 5f9149071fe..6d160adadaf 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h +++ b/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h @@ -14,12 +14,12 @@  #ifndef AT91SAM9RL_MATRIX_H  #define AT91SAM9RL_MATRIX_H -#define AT91_MATRIX_MCFG0	(AT91_MATRIX + 0x00)	/* Master Configuration Register 0 */ -#define AT91_MATRIX_MCFG1	(AT91_MATRIX + 0x04)	/* Master Configuration Register 1 */ -#define AT91_MATRIX_MCFG2	(AT91_MATRIX + 0x08)	/* Master Configuration Register 2 */ -#define AT91_MATRIX_MCFG3	(AT91_MATRIX + 0x0C)	/* Master Configuration Register 3 */ -#define AT91_MATRIX_MCFG4	(AT91_MATRIX + 0x10)	/* Master Configuration Register 4 */ -#define AT91_MATRIX_MCFG5	(AT91_MATRIX + 0x14)	/* Master Configuration Register 5 */ +#define AT91_MATRIX_MCFG0	0x00			/* Master Configuration Register 0 */ +#define AT91_MATRIX_MCFG1	0x04			/* Master Configuration Register 1 */ +#define AT91_MATRIX_MCFG2	0x08			/* Master Configuration Register 2 */ +#define AT91_MATRIX_MCFG3	0x0C			/* Master Configuration Register 3 */ +#define AT91_MATRIX_MCFG4	0x10			/* Master Configuration Register 4 */ +#define AT91_MATRIX_MCFG5	0x14			/* Master Configuration Register 5 */  #define		AT91_MATRIX_ULBT	(7 << 0)	/* Undefined Length Burst Type */  #define			AT91_MATRIX_ULBT_INFINITE	(0 << 0)  #define			AT91_MATRIX_ULBT_SINGLE		(1 << 0) @@ -27,12 +27,12 @@  #define			AT91_MATRIX_ULBT_EIGHT		(3 << 0)  #define			AT91_MATRIX_ULBT_SIXTEEN	(4 << 0) -#define AT91_MATRIX_SCFG0	(AT91_MATRIX + 0x40)	/* Slave Configuration Register 0 */ -#define AT91_MATRIX_SCFG1	(AT91_MATRIX + 0x44)	/* Slave Configuration Register 1 */ -#define AT91_MATRIX_SCFG2	(AT91_MATRIX + 0x48)	/* Slave Configuration Register 2 */ -#define AT91_MATRIX_SCFG3	(AT91_MATRIX + 0x4C)	/* Slave Configuration Register 3 */ -#define AT91_MATRIX_SCFG4	(AT91_MATRIX + 0x50)	/* Slave Configuration Register 4 */ -#define AT91_MATRIX_SCFG5	(AT91_MATRIX + 0x54)	/* Slave Configuration Register 5 */ +#define AT91_MATRIX_SCFG0	0x40			/* Slave Configuration Register 0 */ +#define AT91_MATRIX_SCFG1	0x44			/* Slave Configuration Register 1 */ +#define AT91_MATRIX_SCFG2	0x48			/* Slave Configuration Register 2 */ +#define AT91_MATRIX_SCFG3	0x4C			/* Slave Configuration Register 3 */ +#define AT91_MATRIX_SCFG4	0x50			/* Slave Configuration Register 4 */ +#define AT91_MATRIX_SCFG5	0x54			/* Slave Configuration Register 5 */  #define		AT91_MATRIX_SLOT_CYCLE		(0xff << 0)	/* Maximum Number of Allowed Cycles for a Burst */  #define		AT91_MATRIX_DEFMSTR_TYPE	(3    << 16)	/* Default Master Type */  #define			AT91_MATRIX_DEFMSTR_TYPE_NONE	(0 << 16) @@ -43,12 +43,12 @@  #define			AT91_MATRIX_ARBT_ROUND_ROBIN	(0 << 24)  #define			AT91_MATRIX_ARBT_FIXED_PRIORITY	(1 << 24) -#define AT91_MATRIX_PRAS0	(AT91_MATRIX + 0x80)	/* Priority Register A for Slave 0 */ -#define AT91_MATRIX_PRAS1	(AT91_MATRIX + 0x88)	/* Priority Register A for Slave 1 */ -#define AT91_MATRIX_PRAS2	(AT91_MATRIX + 0x90)	/* Priority Register A for Slave 2 */ -#define AT91_MATRIX_PRAS3	(AT91_MATRIX + 0x98)	/* Priority Register A for Slave 3 */ -#define AT91_MATRIX_PRAS4	(AT91_MATRIX + 0xA0)	/* Priority Register A for Slave 4 */ -#define AT91_MATRIX_PRAS5	(AT91_MATRIX + 0xA8)	/* Priority Register A for Slave 5 */ +#define AT91_MATRIX_PRAS0	0x80			/* Priority Register A for Slave 0 */ +#define AT91_MATRIX_PRAS1	0x88			/* Priority Register A for Slave 1 */ +#define AT91_MATRIX_PRAS2	0x90			/* Priority Register A for Slave 2 */ +#define AT91_MATRIX_PRAS3	0x98			/* Priority Register A for Slave 3 */ +#define AT91_MATRIX_PRAS4	0xA0			/* Priority Register A for Slave 4 */ +#define AT91_MATRIX_PRAS5	0xA8			/* Priority Register A for Slave 5 */  #define		AT91_MATRIX_M0PR		(3 << 0)	/* Master 0 Priority */  #define		AT91_MATRIX_M1PR		(3 << 4)	/* Master 1 Priority */  #define		AT91_MATRIX_M2PR		(3 << 8)	/* Master 2 Priority */ @@ -56,7 +56,7 @@  #define		AT91_MATRIX_M4PR		(3 << 16)	/* Master 4 Priority */  #define		AT91_MATRIX_M5PR		(3 << 20)	/* Master 5 Priority */ -#define AT91_MATRIX_MRCR	(AT91_MATRIX + 0x100)	/* Master Remap Control Register */ +#define AT91_MATRIX_MRCR	0x100			/* Master Remap Control Register */  #define		AT91_MATRIX_RCB0		(1 << 0)	/* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */  #define		AT91_MATRIX_RCB1		(1 << 1)	/* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */  #define		AT91_MATRIX_RCB2		(1 << 2) @@ -64,7 +64,7 @@  #define		AT91_MATRIX_RCB4		(1 << 4)  #define		AT91_MATRIX_RCB5		(1 << 5) -#define AT91_MATRIX_TCMR	(AT91_MATRIX + 0x114)	/* TCM Configuration Register */ +#define AT91_MATRIX_TCMR	0x114			/* TCM Configuration Register */  #define		AT91_MATRIX_ITCM_SIZE		(0xf << 0)	/* Size of ITCM enabled memory block */  #define			AT91_MATRIX_ITCM_0		(0 << 0)  #define			AT91_MATRIX_ITCM_16		(5 << 0) @@ -74,7 +74,7 @@  #define			AT91_MATRIX_DTCM_16		(5 << 4)  #define			AT91_MATRIX_DTCM_32		(6 << 4) -#define AT91_MATRIX_EBICSA	(AT91_MATRIX + 0x120)	/* EBI0 Chip Select Assignment Register */ +#define AT91_MATRIX_EBICSA	0x120			/* EBI0 Chip Select Assignment Register */  #define		AT91_MATRIX_CS1A		(1 << 1)	/* Chip Select 1 Assignment */  #define			AT91_MATRIX_CS1A_SMC		(0 << 1)  #define			AT91_MATRIX_CS1A_SDRAMC		(1 << 1) diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5.h b/arch/arm/mach-at91/include/mach/at91sam9x5.h new file mode 100644 index 00000000000..2fc76c49e97 --- /dev/null +++ b/arch/arm/mach-at91/include/mach/at91sam9x5.h @@ -0,0 +1,71 @@ +/* + * Chip-specific header file for the AT91SAM9x5 family + * + *  Copyright (C) 2009-2012 Atmel Corporation. + * + * Common definitions. + * Based on AT91SAM9x5 datasheet. + * + * Licensed under GPLv2 or later. + */ + +#ifndef AT91SAM9X5_H +#define AT91SAM9X5_H + +/* + * Peripheral identifiers/interrupts. + */ +#define AT91SAM9X5_ID_PIOAB	2	/* Parallel I/O Controller A and B */ +#define AT91SAM9X5_ID_PIOCD	3	/* Parallel I/O Controller C and D */ +#define AT91SAM9X5_ID_SMD	4	/* SMD Soft Modem (SMD) */ +#define AT91SAM9X5_ID_USART0	5	/* USART 0 */ +#define AT91SAM9X5_ID_USART1	6	/* USART 1 */ +#define AT91SAM9X5_ID_USART2	7	/* USART 2 */ +#define AT91SAM9X5_ID_USART3	8	/* USART 3 */ +#define AT91SAM9X5_ID_TWI0	9	/* Two-Wire Interface 0 */ +#define AT91SAM9X5_ID_TWI1	10	/* Two-Wire Interface 1 */ +#define AT91SAM9X5_ID_TWI2	11	/* Two-Wire Interface 2 */ +#define AT91SAM9X5_ID_MCI0	12	/* High Speed Multimedia Card Interface 0 */ +#define AT91SAM9X5_ID_SPI0	13	/* Serial Peripheral Interface 0 */ +#define AT91SAM9X5_ID_SPI1	14	/* Serial Peripheral Interface 1 */ +#define AT91SAM9X5_ID_UART0	15	/* UART 0 */ +#define AT91SAM9X5_ID_UART1	16	/* UART 1 */ +#define AT91SAM9X5_ID_TCB	17	/* Timer Counter 0, 1, 2, 3, 4 and 5 */ +#define AT91SAM9X5_ID_PWM	18	/* Pulse Width Modulation Controller */ +#define AT91SAM9X5_ID_ADC	19	/* ADC Controller */ +#define AT91SAM9X5_ID_DMA0	20	/* DMA Controller 0 */ +#define AT91SAM9X5_ID_DMA1	21	/* DMA Controller 1 */ +#define AT91SAM9X5_ID_UHPHS	22	/* USB Host High Speed */ +#define AT91SAM9X5_ID_UDPHS	23	/* USB Device High Speed */ +#define AT91SAM9X5_ID_EMAC0	24	/* Ethernet MAC0 */ +#define AT91SAM9X5_ID_LCDC	25	/* LCD Controller */ +#define AT91SAM9X5_ID_ISI	25	/* Image Sensor Interface */ +#define AT91SAM9X5_ID_MCI1	26	/* High Speed Multimedia Card Interface 1 */ +#define AT91SAM9X5_ID_EMAC1	27	/* Ethernet MAC1 */ +#define AT91SAM9X5_ID_SSC	28	/* Synchronous Serial Controller */ +#define AT91SAM9X5_ID_CAN0	29	/* CAN Controller 0 */ +#define AT91SAM9X5_ID_CAN1	30	/* CAN Controller 1 */ +#define AT91SAM9X5_ID_IRQ0	31	/* Advanced Interrupt Controller */ + +/* + * User Peripheral physical base addresses. + */ +#define AT91SAM9X5_BASE_USART0	0xf801c000 +#define AT91SAM9X5_BASE_USART1	0xf8020000 +#define AT91SAM9X5_BASE_USART2	0xf8024000 + +/* + * System Peripherals + */ +#define AT91SAM9X5_BASE_RTC	0xfffffeb0 + +/* + * Internal Memory. + */ +#define AT91SAM9X5_SRAM_BASE	0x00300000	/* Internal SRAM base address */ +#define AT91SAM9X5_SRAM_SIZE	SZ_32K		/* Internal SRAM size (32Kb) */ + +#define AT91SAM9X5_ROM_BASE	0x00400000	/* Internal ROM base address */ +#define AT91SAM9X5_ROM_SIZE	SZ_64K		/* Internal ROM size (64Kb) */ + +#endif diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h new file mode 100644 index 00000000000..a606d396647 --- /dev/null +++ b/arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h @@ -0,0 +1,53 @@ +/* + * Matrix-centric header file for the AT91SAM9x5 family + * + *  Copyright (C) 2009-2012 Atmel Corporation. + * + * Only EBI related registers. + * Write Protect register definitions may be useful. + * + * Licensed under GPLv2 or later. + */ + +#ifndef AT91SAM9X5_MATRIX_H +#define AT91SAM9X5_MATRIX_H + +#define AT91_MATRIX_EBICSA	(AT91_MATRIX + 0x120)	/* EBI Chip Select Assignment Register */ +#define		AT91_MATRIX_EBI_CS1A		(1 << 1)	/* Chip Select 1 Assignment */ +#define			AT91_MATRIX_EBI_CS1A_SMC		(0 << 1) +#define			AT91_MATRIX_EBI_CS1A_SDRAMC		(1 << 1) +#define		AT91_MATRIX_EBI_CS3A		(1 << 3)	/* Chip Select 3 Assignment */ +#define			AT91_MATRIX_EBI_CS3A_SMC		(0 << 3) +#define			AT91_MATRIX_EBI_CS3A_SMC_NANDFLASH	(1 << 3) +#define		AT91_MATRIX_EBI_DBPUC		(1 << 8)	/* Data Bus Pull-up Configuration */ +#define			AT91_MATRIX_EBI_DBPU_ON			(0 << 8) +#define			AT91_MATRIX_EBI_DBPU_OFF		(1 << 8) +#define		AT91_MATRIX_EBI_VDDIOMSEL	(1 << 16)	/* Memory voltage selection */ +#define			AT91_MATRIX_EBI_VDDIOMSEL_1_8V		(0 << 16) +#define			AT91_MATRIX_EBI_VDDIOMSEL_3_3V		(1 << 16) +#define		AT91_MATRIX_EBI_EBI_IOSR	(1 << 17)	/* EBI I/O slew rate selection */ +#define			AT91_MATRIX_EBI_EBI_IOSR_REDUCED	(0 << 17) +#define			AT91_MATRIX_EBI_EBI_IOSR_NORMAL		(1 << 17) +#define		AT91_MATRIX_EBI_DDR_IOSR	(1 << 18)	/* DDR2 dedicated port I/O slew rate selection */ +#define			AT91_MATRIX_EBI_DDR_IOSR_REDUCED	(0 << 18) +#define			AT91_MATRIX_EBI_DDR_IOSR_NORMAL		(1 << 18) +#define		AT91_MATRIX_NFD0_SELECT		(1 << 24)	/* NAND Flash Data Bus Selection */ +#define			AT91_MATRIX_NFD0_ON_D0			(0 << 24) +#define			AT91_MATRIX_NFD0_ON_D16			(1 << 24) +#define		AT91_MATRIX_DDR_MP_EN		(1 << 25)	/* DDR Multi-port Enable */ +#define			AT91_MATRIX_MP_OFF			(0 << 25) +#define			AT91_MATRIX_MP_ON			(1 << 25) + +#define AT91_MATRIX_WPMR	(AT91_MATRIX + 0x1E4)	/* Write Protect Mode Register */ +#define		AT91_MATRIX_WPMR_WPEN		(1 << 0)	/* Write Protect ENable */ +#define			AT91_MATRIX_WPMR_WP_WPDIS		(0 << 0) +#define			AT91_MATRIX_WPMR_WP_WPEN		(1 << 0) +#define		AT91_MATRIX_WPMR_WPKEY		(0xFFFFFF << 8)	/* Write Protect KEY */ + +#define AT91_MATRIX_WPSR	(AT91_MATRIX + 0x1E8)	/* Write Protect Status Register */ +#define		AT91_MATRIX_WPSR_WPVS		(1 << 0)	/* Write Protect Violation Status */ +#define			AT91_MATRIX_WPSR_NO_WPV		(0 << 0) +#define			AT91_MATRIX_WPSR_WPV		(1 << 0) +#define		AT91_MATRIX_WPSR_WPVSRC		(0xFFFF << 8)	/* Write Protect Violation Source */ + +#endif diff --git a/arch/arm/mach-at91/include/mach/at91x40.h b/arch/arm/mach-at91/include/mach/at91x40.h index 063ac44a020..38dca2bb027 100644 --- a/arch/arm/mach-at91/include/mach/at91x40.h +++ b/arch/arm/mach-at91/include/mach/at91x40.h @@ -15,8 +15,6 @@  /*   *	IRQ list.   */ -#define AT91_ID_FIQ		0	/* FIQ */ -#define AT91_ID_SYS		1	/* System Peripheral */  #define AT91X40_ID_USART0	2	/* USART port 0 */  #define AT91X40_ID_USART1	3	/* USART port 1 */  #define AT91X40_ID_TC0		4	/* Timer/Counter 0 */ @@ -30,19 +28,18 @@  #define AT91X40_ID_IRQ2		18	/* External IRQ 2 */  /* - * System Peripherals (offset from AT91_BASE_SYS) + * System Peripherals   */  #define AT91_BASE_SYS	0xffc00000 -#define AT91_EBI	(0xffe00000 - AT91_BASE_SYS)	/* External Bus Interface */ -#define AT91_SF		(0xfff00000 - AT91_BASE_SYS)	/* Special Function */ -#define AT91_USART1	(0xfffcc000 - AT91_BASE_SYS)	/* USART 1 */ -#define AT91_USART0	(0xfffd0000 - AT91_BASE_SYS)	/* USART 0 */ -#define AT91_TC		(0xfffe0000 - AT91_BASE_SYS)	/* Timer Counter */ -#define AT91_PIOA	(0xffff0000 - AT91_BASE_SYS)	/* PIO Controller A */ -#define AT91_PS		(0xffff4000 - AT91_BASE_SYS)	/* Power Save */ -#define AT91_WD		(0xffff8000 - AT91_BASE_SYS)	/* Watchdog Timer */ -#define AT91_AIC	(0xfffff000 - AT91_BASE_SYS)	/* Advanced Interrupt Controller */ +#define AT91_EBI	0xffe00000	/* External Bus Interface */ +#define AT91_SF		0xfff00000	/* Special Function */ +#define AT91_USART1	0xfffcc000	/* USART 1 */ +#define AT91_USART0	0xfffd0000	/* USART 0 */ +#define AT91_TC		0xfffe0000	/* Timer Counter */ +#define AT91_PIOA	0xffff0000	/* PIO Controller A */ +#define AT91_PS		0xffff4000	/* Power Save */ +#define AT91_WD		0xffff8000	/* Watchdog Timer */  /*   * The AT91x40 series doesn't have a debug unit like the other AT91 parts. @@ -58,4 +55,6 @@  #define	AT91_PS_CR	(AT91_PS + 0)	/* PS Control register */  #define	AT91_PS_CR_CPU	(1 << 0)	/* CPU clock disable bit */ +#define AT91X40_MASTER_CLOCK	40000000 +  #endif /* AT91X40_H */ diff --git a/arch/arm/mach-at91/include/mach/at_hdmac.h b/arch/arm/mach-at91/include/mach/at_hdmac.h deleted file mode 100644 index 187cb58345c..00000000000 --- a/arch/arm/mach-at91/include/mach/at_hdmac.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Header file for the Atmel AHB DMA Controller driver - * - * Copyright (C) 2008 Atmel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ -#ifndef AT_HDMAC_H -#define AT_HDMAC_H - -#include <linux/dmaengine.h> - -/** - * struct at_dma_platform_data - Controller configuration parameters - * @nr_channels: Number of channels supported by hardware (max 8) - * @cap_mask: dma_capability flags supported by the platform - */ -struct at_dma_platform_data { -	unsigned int	nr_channels; -	dma_cap_mask_t  cap_mask; -}; - -/** - * enum at_dma_slave_width - DMA slave register access width. - * @AT_DMA_SLAVE_WIDTH_8BIT: Do 8-bit slave register accesses - * @AT_DMA_SLAVE_WIDTH_16BIT: Do 16-bit slave register accesses - * @AT_DMA_SLAVE_WIDTH_32BIT: Do 32-bit slave register accesses - */ -enum at_dma_slave_width { -	AT_DMA_SLAVE_WIDTH_8BIT = 0, -	AT_DMA_SLAVE_WIDTH_16BIT, -	AT_DMA_SLAVE_WIDTH_32BIT, -}; - -/** - * struct at_dma_slave - Controller-specific information about a slave - * @dma_dev: required DMA master device - * @tx_reg: physical address of data register used for - *	memory-to-peripheral transfers - * @rx_reg: physical address of data register used for - *	peripheral-to-memory transfers - * @reg_width: peripheral register width - * @cfg: Platform-specific initializer for the CFG register - * @ctrla: Platform-specific initializer for the CTRLA register - */ -struct at_dma_slave { -	struct device		*dma_dev; -	dma_addr_t		tx_reg; -	dma_addr_t		rx_reg; -	enum at_dma_slave_width	reg_width; -	u32			cfg; -	u32			ctrla; -}; - - -/* Platform-configurable bits in CFG */ -#define	ATC_SRC_PER(h)		(0xFU & (h))	/* Channel src rq associated with periph handshaking ifc h */ -#define	ATC_DST_PER(h)		((0xFU & (h)) <<  4)	/* Channel dst rq associated with periph handshaking ifc h */ -#define	ATC_SRC_REP		(0x1 <<  8)	/* Source Replay Mod */ -#define	ATC_SRC_H2SEL		(0x1 <<  9)	/* Source Handshaking Mod */ -#define		ATC_SRC_H2SEL_SW	(0x0 <<  9) -#define		ATC_SRC_H2SEL_HW	(0x1 <<  9) -#define	ATC_DST_REP		(0x1 << 12)	/* Destination Replay Mod */ -#define	ATC_DST_H2SEL		(0x1 << 13)	/* Destination Handshaking Mod */ -#define		ATC_DST_H2SEL_SW	(0x0 << 13) -#define		ATC_DST_H2SEL_HW	(0x1 << 13) -#define	ATC_SOD			(0x1 << 16)	/* Stop On Done */ -#define	ATC_LOCK_IF		(0x1 << 20)	/* Interface Lock */ -#define	ATC_LOCK_B		(0x1 << 21)	/* AHB Bus Lock */ -#define	ATC_LOCK_IF_L		(0x1 << 22)	/* Master Interface Arbiter Lock */ -#define		ATC_LOCK_IF_L_CHUNK	(0x0 << 22) -#define		ATC_LOCK_IF_L_BUFFER	(0x1 << 22) -#define	ATC_AHB_PROT_MASK	(0x7 << 24)	/* AHB Protection */ -#define	ATC_FIFOCFG_MASK	(0x3 << 28)	/* FIFO Request Configuration */ -#define		ATC_FIFOCFG_LARGESTBURST	(0x0 << 28) -#define		ATC_FIFOCFG_HALFFIFO		(0x1 << 28) -#define		ATC_FIFOCFG_ENOUGHSPACE		(0x2 << 28) - -/* Platform-configurable bits in CTRLA */ -#define	ATC_SCSIZE_MASK		(0x7 << 16)	/* Source Chunk Transfer Size */ -#define		ATC_SCSIZE_1		(0x0 << 16) -#define		ATC_SCSIZE_4		(0x1 << 16) -#define		ATC_SCSIZE_8		(0x2 << 16) -#define		ATC_SCSIZE_16		(0x3 << 16) -#define		ATC_SCSIZE_32		(0x4 << 16) -#define		ATC_SCSIZE_64		(0x5 << 16) -#define		ATC_SCSIZE_128		(0x6 << 16) -#define		ATC_SCSIZE_256		(0x7 << 16) -#define	ATC_DCSIZE_MASK		(0x7 << 20)	/* Destination Chunk Transfer Size */ -#define		ATC_DCSIZE_1		(0x0 << 20) -#define		ATC_DCSIZE_4		(0x1 << 20) -#define		ATC_DCSIZE_8		(0x2 << 20) -#define		ATC_DCSIZE_16		(0x3 << 20) -#define		ATC_DCSIZE_32		(0x4 << 20) -#define		ATC_DCSIZE_64		(0x5 << 20) -#define		ATC_DCSIZE_128		(0x6 << 20) -#define		ATC_DCSIZE_256		(0x7 << 20) - -#endif /* AT_HDMAC_H */ diff --git a/arch/arm/mach-at91/include/mach/atmel-mci.h b/arch/arm/mach-at91/include/mach/atmel-mci.h index 998cb0c0713..3069e413557 100644 --- a/arch/arm/mach-at91/include/mach/atmel-mci.h +++ b/arch/arm/mach-at91/include/mach/atmel-mci.h @@ -1,7 +1,7 @@  #ifndef __MACH_ATMEL_MCI_H  #define __MACH_ATMEL_MCI_H -#include <mach/at_hdmac.h> +#include <linux/platform_data/dma-atmel.h>  /**   * struct mci_dma_data - DMA data for MCI interface @@ -14,11 +14,4 @@ struct mci_dma_data {  #define	slave_data_ptr(s)	(&(s)->sdata)  #define find_slave_dev(s)	((s)->sdata.dma_dev) -#define	setup_dma_addr(s, t, r)	do {		\ -	if (s) {				\ -		(s)->sdata.tx_reg = (t);	\ -		(s)->sdata.rx_reg = (r);	\ -	}					\ -} while (0) -  #endif /* __MACH_ATMEL_MCI_H */ diff --git a/arch/arm/mach-at91/include/mach/cpu.h b/arch/arm/mach-at91/include/mach/cpu.h index 3bef931d0b1..86c71debab5 100644 --- a/arch/arm/mach-at91/include/mach/cpu.h +++ b/arch/arm/mach-at91/include/mach/cpu.h @@ -1,7 +1,8 @@  /*   * arch/arm/mach-at91/include/mach/cpu.h   * - *  Copyright (C) 2006 SAN People + * Copyright (C) 2006 SAN People + * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>   *   * This program is free software; you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -10,12 +11,8 @@   *   */ -#ifndef __ASM_ARCH_CPU_H -#define __ASM_ARCH_CPU_H - -#include <mach/hardware.h> -#include <mach/at91_dbgu.h> - +#ifndef __MACH_CPU_H__ +#define __MACH_CPU_H__  #define ARCH_ID_AT91RM9200	0x09290780  #define ARCH_ID_AT91SAM9260	0x019803a0 @@ -27,114 +24,157 @@  #define ARCH_ID_AT91SAM9G45	0x819b05a0  #define ARCH_ID_AT91SAM9G45MRL	0x819b05a2	/* aka 9G45-ES2 & non ES lots */  #define ARCH_ID_AT91SAM9G45ES	0x819b05a1	/* 9G45-ES (Engineering Sample) */ -#define ARCH_ID_AT91CAP9	0x039A03A0 +#define ARCH_ID_AT91SAM9X5	0x819a05a0 +#define ARCH_ID_AT91SAM9N12	0x819a07a0  #define ARCH_ID_AT91SAM9XE128	0x329973a0  #define ARCH_ID_AT91SAM9XE256	0x329a93a0  #define ARCH_ID_AT91SAM9XE512	0x329aa3a0 -#define ARCH_ID_AT572D940HF	0x0e0303e0 -  #define ARCH_ID_AT91M40800	0x14080044  #define ARCH_ID_AT91R40807	0x44080746  #define ARCH_ID_AT91M40807	0x14080745  #define ARCH_ID_AT91R40008	0x44000840 -static inline unsigned long at91_cpu_identify(void) -{ -	return (at91_sys_read(AT91_DBGU_CIDR) & ~AT91_CIDR_VERSION); -} - -static inline unsigned long at91_cpu_fully_identify(void) -{ -	return at91_sys_read(AT91_DBGU_CIDR); -} +#define ARCH_ID_SAMA5D3		0x8A5C07C0  #define ARCH_EXID_AT91SAM9M11	0x00000001  #define ARCH_EXID_AT91SAM9M10	0x00000002  #define ARCH_EXID_AT91SAM9G46	0x00000003  #define ARCH_EXID_AT91SAM9G45	0x00000004 -static inline unsigned long at91_exid_identify(void) -{ -	return at91_sys_read(AT91_DBGU_EXID); -} +#define ARCH_EXID_AT91SAM9G15	0x00000000 +#define ARCH_EXID_AT91SAM9G35	0x00000001 +#define ARCH_EXID_AT91SAM9X35	0x00000002 +#define ARCH_EXID_AT91SAM9G25	0x00000003 +#define ARCH_EXID_AT91SAM9X25	0x00000004 +#define ARCH_EXID_SAMA5D31	0x00444300 +#define ARCH_EXID_SAMA5D33	0x00414300 +#define ARCH_EXID_SAMA5D34	0x00414301 +#define ARCH_EXID_SAMA5D35	0x00584300 +#define ARCH_EXID_SAMA5D36	0x00004301  #define ARCH_FAMILY_AT91X92	0x09200000  #define ARCH_FAMILY_AT91SAM9	0x01900000  #define ARCH_FAMILY_AT91SAM9XE	0x02900000 -static inline unsigned long at91_arch_identify(void) -{ -	return (at91_sys_read(AT91_DBGU_CIDR) & AT91_CIDR_ARCH); -} +/* RM9200 type */ +#define ARCH_REVISON_9200_BGA	(0 << 0) +#define ARCH_REVISON_9200_PQFP	(1 << 0) + +#ifndef __ASSEMBLY__ +enum at91_soc_type { +	/* 920T */ +	AT91_SOC_RM9200, + +	/* SAM92xx */ +	AT91_SOC_SAM9260, AT91_SOC_SAM9261, AT91_SOC_SAM9263, + +	/* SAM9Gxx */ +	AT91_SOC_SAM9G10, AT91_SOC_SAM9G20, AT91_SOC_SAM9G45, + +	/* SAM9RL */ +	AT91_SOC_SAM9RL, + +	/* SAM9X5 */ +	AT91_SOC_SAM9X5, + +	/* SAM9N12 */ +	AT91_SOC_SAM9N12, + +	/* SAMA5D3 */ +	AT91_SOC_SAMA5D3, -#ifdef CONFIG_ARCH_AT91CAP9 -#include <mach/at91_pmc.h> +	/* Unknown type */ +	AT91_SOC_UNKNOWN, +}; -#define ARCH_REVISION_CAP9_B	0x399 -#define ARCH_REVISION_CAP9_C	0x601 +enum at91_soc_subtype { +	/* RM9200 */ +	AT91_SOC_RM9200_BGA, AT91_SOC_RM9200_PQFP, -static inline unsigned long at91cap9_rev_identify(void) +	/* SAM9260 */ +	AT91_SOC_SAM9XE, + +	/* SAM9G45 */ +	AT91_SOC_SAM9G45ES, AT91_SOC_SAM9M10, AT91_SOC_SAM9G46, AT91_SOC_SAM9M11, + +	/* SAM9X5 */ +	AT91_SOC_SAM9G15, AT91_SOC_SAM9G35, AT91_SOC_SAM9X35, +	AT91_SOC_SAM9G25, AT91_SOC_SAM9X25, + +	/* SAMA5D3 */ +	AT91_SOC_SAMA5D31, AT91_SOC_SAMA5D33, AT91_SOC_SAMA5D34, +	AT91_SOC_SAMA5D35, AT91_SOC_SAMA5D36, + +	/* No subtype for this SoC */ +	AT91_SOC_SUBTYPE_NONE, + +	/* Unknown subtype */ +	AT91_SOC_SUBTYPE_UNKNOWN, +}; + +struct at91_socinfo { +	unsigned int type, subtype; +	unsigned int cidr, exid; +}; + +extern struct at91_socinfo at91_soc_initdata; +const char *at91_get_soc_type(struct at91_socinfo *c); +const char *at91_get_soc_subtype(struct at91_socinfo *c); + +static inline int at91_soc_is_detected(void)  { -	return (at91_sys_read(AT91_PMC_VER)); +	return at91_soc_initdata.type != AT91_SOC_UNKNOWN;  } -#endif -#ifdef CONFIG_ARCH_AT91RM9200 -#define cpu_is_at91rm9200()	(at91_cpu_identify() == ARCH_ID_AT91RM9200) +#ifdef CONFIG_SOC_AT91RM9200 +#define cpu_is_at91rm9200()	(at91_soc_initdata.type == AT91_SOC_RM9200) +#define cpu_is_at91rm9200_bga()	(at91_soc_initdata.subtype == AT91_SOC_RM9200_BGA) +#define cpu_is_at91rm9200_pqfp() (at91_soc_initdata.subtype == AT91_SOC_RM9200_PQFP)  #else  #define cpu_is_at91rm9200()	(0) +#define cpu_is_at91rm9200_bga()	(0) +#define cpu_is_at91rm9200_pqfp() (0)  #endif -#ifdef CONFIG_ARCH_AT91SAM9260 -#define cpu_is_at91sam9xe()	(at91_arch_identify() == ARCH_FAMILY_AT91SAM9XE) -#define cpu_is_at91sam9260()	((at91_cpu_identify() == ARCH_ID_AT91SAM9260) || cpu_is_at91sam9xe()) +#ifdef CONFIG_SOC_AT91SAM9260 +#define cpu_is_at91sam9xe()	(at91_soc_initdata.subtype == AT91_SOC_SAM9XE) +#define cpu_is_at91sam9260()	(at91_soc_initdata.type == AT91_SOC_SAM9260) +#define cpu_is_at91sam9g20()	(at91_soc_initdata.type == AT91_SOC_SAM9G20)  #else  #define cpu_is_at91sam9xe()	(0)  #define cpu_is_at91sam9260()	(0) -#endif - -#ifdef CONFIG_ARCH_AT91SAM9G20 -#define cpu_is_at91sam9g20()	(at91_cpu_identify() == ARCH_ID_AT91SAM9G20) -#else  #define cpu_is_at91sam9g20()	(0)  #endif -#ifdef CONFIG_ARCH_AT91SAM9261 -#define cpu_is_at91sam9261()	(at91_cpu_identify() == ARCH_ID_AT91SAM9261) +#ifdef CONFIG_SOC_AT91SAM9261 +#define cpu_is_at91sam9261()	(at91_soc_initdata.type == AT91_SOC_SAM9261) +#define cpu_is_at91sam9g10()	(at91_soc_initdata.type == AT91_SOC_SAM9G10)  #else  #define cpu_is_at91sam9261()	(0) -#endif - -#ifdef CONFIG_ARCH_AT91SAM9G10 -#define cpu_is_at91sam9g10()	((at91_cpu_identify() & ~AT91_CIDR_EXT)	== ARCH_ID_AT91SAM9G10) -#else  #define cpu_is_at91sam9g10()	(0)  #endif -#ifdef CONFIG_ARCH_AT91SAM9263 -#define cpu_is_at91sam9263()	(at91_cpu_identify() == ARCH_ID_AT91SAM9263) +#ifdef CONFIG_SOC_AT91SAM9263 +#define cpu_is_at91sam9263()	(at91_soc_initdata.type == AT91_SOC_SAM9263)  #else  #define cpu_is_at91sam9263()	(0)  #endif -#ifdef CONFIG_ARCH_AT91SAM9RL -#define cpu_is_at91sam9rl()	(at91_cpu_identify() == ARCH_ID_AT91SAM9RL64) +#ifdef CONFIG_SOC_AT91SAM9RL +#define cpu_is_at91sam9rl()	(at91_soc_initdata.type == AT91_SOC_SAM9RL)  #else  #define cpu_is_at91sam9rl()	(0)  #endif -#ifdef CONFIG_ARCH_AT91SAM9G45 -#define cpu_is_at91sam9g45()	(at91_cpu_identify() == ARCH_ID_AT91SAM9G45) -#define cpu_is_at91sam9g45es()	(at91_cpu_fully_identify() == ARCH_ID_AT91SAM9G45ES) -#define cpu_is_at91sam9m10()    (cpu_is_at91sam9g45() && \ -                                (at91_exid_identify() == ARCH_EXID_AT91SAM9M10)) -#define cpu_is_at91sam9m46()    (cpu_is_at91sam9g45() && \ -                                (at91_exid_identify() == ARCH_EXID_AT91SAM9G46)) -#define cpu_is_at91sam9m11()    (cpu_is_at91sam9g45() && \ -                                (at91_exid_identify() == ARCH_EXID_AT91SAM9M11)) +#ifdef CONFIG_SOC_AT91SAM9G45 +#define cpu_is_at91sam9g45()	(at91_soc_initdata.type == AT91_SOC_SAM9G45) +#define cpu_is_at91sam9g45es()	(at91_soc_initdata.subtype == AT91_SOC_SAM9G45ES) +#define cpu_is_at91sam9m10()	(at91_soc_initdata.subtype == AT91_SOC_SAM9M10) +#define cpu_is_at91sam9g46()	(at91_soc_initdata.subtype == AT91_SOC_SAM9G46) +#define cpu_is_at91sam9m11()	(at91_soc_initdata.subtype == AT91_SOC_SAM9M11)  #else  #define cpu_is_at91sam9g45()	(0)  #define cpu_is_at91sam9g45es()	(0) @@ -143,20 +183,32 @@ static inline unsigned long at91cap9_rev_identify(void)  #define cpu_is_at91sam9m11()	(0)  #endif -#ifdef CONFIG_ARCH_AT91CAP9 -#define cpu_is_at91cap9()	(at91_cpu_identify() == ARCH_ID_AT91CAP9) -#define cpu_is_at91cap9_revB()	(at91cap9_rev_identify() == ARCH_REVISION_CAP9_B) -#define cpu_is_at91cap9_revC()	(at91cap9_rev_identify() == ARCH_REVISION_CAP9_C) +#ifdef CONFIG_SOC_AT91SAM9X5 +#define cpu_is_at91sam9x5()	(at91_soc_initdata.type == AT91_SOC_SAM9X5) +#define cpu_is_at91sam9g15()	(at91_soc_initdata.subtype == AT91_SOC_SAM9G15) +#define cpu_is_at91sam9g35()	(at91_soc_initdata.subtype == AT91_SOC_SAM9G35) +#define cpu_is_at91sam9x35()	(at91_soc_initdata.subtype == AT91_SOC_SAM9X35) +#define cpu_is_at91sam9g25()	(at91_soc_initdata.subtype == AT91_SOC_SAM9G25) +#define cpu_is_at91sam9x25()	(at91_soc_initdata.subtype == AT91_SOC_SAM9X25)  #else -#define cpu_is_at91cap9()	(0) -#define cpu_is_at91cap9_revB()	(0) -#define cpu_is_at91cap9_revC()	(0) +#define cpu_is_at91sam9x5()	(0) +#define cpu_is_at91sam9g15()	(0) +#define cpu_is_at91sam9g35()	(0) +#define cpu_is_at91sam9x35()	(0) +#define cpu_is_at91sam9g25()	(0) +#define cpu_is_at91sam9x25()	(0)  #endif -#ifdef CONFIG_ARCH_AT572D940HF -#define cpu_is_at572d940hf() (at91_cpu_identify() == ARCH_ID_AT572D940HF) +#ifdef CONFIG_SOC_AT91SAM9N12 +#define cpu_is_at91sam9n12()	(at91_soc_initdata.type == AT91_SOC_SAM9N12)  #else -#define cpu_is_at572d940hf() (0) +#define cpu_is_at91sam9n12()	(0) +#endif + +#ifdef CONFIG_SOC_SAMA5D3 +#define cpu_is_sama5d3()	(at91_soc_initdata.type == AT91_SOC_SAMA5D3) +#else +#define cpu_is_sama5d3()	(0)  #endif  /* @@ -164,5 +216,6 @@ static inline unsigned long at91cap9_rev_identify(void)   * definitions may reduce clutter in common drivers.   */  #define cpu_is_at32ap7000()	(0) +#endif /* __ASSEMBLY__ */ -#endif +#endif /* __MACH_CPU_H__ */ diff --git a/arch/arm/mach-at91/include/mach/debug-macro.S b/arch/arm/mach-at91/include/mach/debug-macro.S index 0f959faf74a..c6bb9e2d9ba 100644 --- a/arch/arm/mach-at91/include/mach/debug-macro.S +++ b/arch/arm/mach-at91/include/mach/debug-macro.S @@ -14,24 +14,30 @@  #include <mach/hardware.h>  #include <mach/at91_dbgu.h> -	.macro	addruart, rp, rv -	ldr	\rp, =(AT91_BASE_SYS + AT91_DBGU)		@ System peripherals (phys address) -	ldr	\rv, =(AT91_VA_BASE_SYS	+ AT91_DBGU)		@ System peripherals (virt address) +#if defined(CONFIG_AT91_DEBUG_LL_DBGU0) +#define AT91_DBGU AT91_BASE_DBGU0 +#else +#define AT91_DBGU AT91_BASE_DBGU1 +#endif + +	.macro	addruart, rp, rv, tmp +	ldr	\rp, =AT91_DBGU				@ System peripherals (phys address) +	ldr	\rv, =AT91_IO_P2V(AT91_DBGU)		@ System peripherals (virt address)  	.endm  	.macro	senduart,rd,rx -	strb	\rd, [\rx, #(AT91_DBGU_THR - AT91_DBGU)]	@ Write to Transmitter Holding Register +	strb	\rd, [\rx, #(AT91_DBGU_THR)]		@ Write to Transmitter Holding Register  	.endm  	.macro	waituart,rd,rx -1001:	ldr	\rd, [\rx, #(AT91_DBGU_SR - AT91_DBGU)]		@ Read Status Register -	tst	\rd, #AT91_DBGU_TXRDY				@ DBGU_TXRDY = 1 when ready to transmit +1001:	ldr	\rd, [\rx, #(AT91_DBGU_SR)]		@ Read Status Register +	tst	\rd, #AT91_DBGU_TXRDY			@ DBGU_TXRDY = 1 when ready to transmit  	beq	1001b  	.endm  	.macro	busyuart,rd,rx -1001:	ldr	\rd, [\rx, #(AT91_DBGU_SR - AT91_DBGU)]		@ Read Status Register -	tst	\rd, #AT91_DBGU_TXEMPTY				@ DBGU_TXEMPTY = 1 when transmission complete +1001:	ldr	\rd, [\rx, #(AT91_DBGU_SR)]		@ Read Status Register +	tst	\rd, #AT91_DBGU_TXEMPTY			@ DBGU_TXEMPTY = 1 when transmission complete  	beq	1001b  	.endm diff --git a/arch/arm/mach-at91/include/mach/entry-macro.S b/arch/arm/mach-at91/include/mach/entry-macro.S deleted file mode 100644 index 7ab68f97222..00000000000 --- a/arch/arm/mach-at91/include/mach/entry-macro.S +++ /dev/null @@ -1,32 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/entry-macro.S - * - *  Copyright (C) 2003-2005 SAN People - * - * Low-level IRQ helper macros for AT91RM9200 platforms - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. - */ - -#include <mach/hardware.h> -#include <mach/at91_aic.h> - -	.macro	disable_fiq -	.endm - -	.macro  get_irqnr_preamble, base, tmp -	ldr	\base, =(AT91_VA_BASE_SYS + AT91_AIC)		@ base virtual address of AIC peripheral -	.endm - -	.macro  arch_ret_to_user, tmp1, tmp2 -	.endm - -	.macro	get_irqnr_and_base, irqnr, irqstat, base, tmp -	ldr	\irqnr, [\base, #(AT91_AIC_IVR - AT91_AIC)]	@ read IRQ vector register: de-asserts nIRQ to processor (and clears interrupt) -	ldr	\irqstat, [\base, #(AT91_AIC_ISR - AT91_AIC)]	@ read interrupt source number -	teq	\irqstat, #0					@ ISR is 0 when no current interrupt, or spurious interrupt -	streq	\tmp, [\base, #(AT91_AIC_EOICR - AT91_AIC)]	@ not going to be handled further, then ACK it now. -	.endm - diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h deleted file mode 100644 index bfdd8ab26dc..00000000000 --- a/arch/arm/mach-at91/include/mach/gpio.h +++ /dev/null @@ -1,235 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/gpio.h - * - *  Copyright (C) 2005 HP Labs - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - */ - -#ifndef __ASM_ARCH_AT91RM9200_GPIO_H -#define __ASM_ARCH_AT91RM9200_GPIO_H - -#include <linux/kernel.h> -#include <asm/irq.h> - -#define PIN_BASE		NR_AIC_IRQS - -#define MAX_GPIO_BANKS		5 -#define NR_BUILTIN_GPIO		(PIN_BASE + (MAX_GPIO_BANKS * 32)) - -/* these pin numbers double as IRQ numbers, like AT91xxx_ID_* values */ - -#define	AT91_PIN_PA0	(PIN_BASE + 0x00 + 0) -#define	AT91_PIN_PA1	(PIN_BASE + 0x00 + 1) -#define	AT91_PIN_PA2	(PIN_BASE + 0x00 + 2) -#define	AT91_PIN_PA3	(PIN_BASE + 0x00 + 3) -#define	AT91_PIN_PA4	(PIN_BASE + 0x00 + 4) -#define	AT91_PIN_PA5	(PIN_BASE + 0x00 + 5) -#define	AT91_PIN_PA6	(PIN_BASE + 0x00 + 6) -#define	AT91_PIN_PA7	(PIN_BASE + 0x00 + 7) -#define	AT91_PIN_PA8	(PIN_BASE + 0x00 + 8) -#define	AT91_PIN_PA9	(PIN_BASE + 0x00 + 9) -#define	AT91_PIN_PA10	(PIN_BASE + 0x00 + 10) -#define	AT91_PIN_PA11	(PIN_BASE + 0x00 + 11) -#define	AT91_PIN_PA12	(PIN_BASE + 0x00 + 12) -#define	AT91_PIN_PA13	(PIN_BASE + 0x00 + 13) -#define	AT91_PIN_PA14	(PIN_BASE + 0x00 + 14) -#define	AT91_PIN_PA15	(PIN_BASE + 0x00 + 15) -#define	AT91_PIN_PA16	(PIN_BASE + 0x00 + 16) -#define	AT91_PIN_PA17	(PIN_BASE + 0x00 + 17) -#define	AT91_PIN_PA18	(PIN_BASE + 0x00 + 18) -#define	AT91_PIN_PA19	(PIN_BASE + 0x00 + 19) -#define	AT91_PIN_PA20	(PIN_BASE + 0x00 + 20) -#define	AT91_PIN_PA21	(PIN_BASE + 0x00 + 21) -#define	AT91_PIN_PA22	(PIN_BASE + 0x00 + 22) -#define	AT91_PIN_PA23	(PIN_BASE + 0x00 + 23) -#define	AT91_PIN_PA24	(PIN_BASE + 0x00 + 24) -#define	AT91_PIN_PA25	(PIN_BASE + 0x00 + 25) -#define	AT91_PIN_PA26	(PIN_BASE + 0x00 + 26) -#define	AT91_PIN_PA27	(PIN_BASE + 0x00 + 27) -#define	AT91_PIN_PA28	(PIN_BASE + 0x00 + 28) -#define	AT91_PIN_PA29	(PIN_BASE + 0x00 + 29) -#define	AT91_PIN_PA30	(PIN_BASE + 0x00 + 30) -#define	AT91_PIN_PA31	(PIN_BASE + 0x00 + 31) - -#define	AT91_PIN_PB0	(PIN_BASE + 0x20 + 0) -#define	AT91_PIN_PB1	(PIN_BASE + 0x20 + 1) -#define	AT91_PIN_PB2	(PIN_BASE + 0x20 + 2) -#define	AT91_PIN_PB3	(PIN_BASE + 0x20 + 3) -#define	AT91_PIN_PB4	(PIN_BASE + 0x20 + 4) -#define	AT91_PIN_PB5	(PIN_BASE + 0x20 + 5) -#define	AT91_PIN_PB6	(PIN_BASE + 0x20 + 6) -#define	AT91_PIN_PB7	(PIN_BASE + 0x20 + 7) -#define	AT91_PIN_PB8	(PIN_BASE + 0x20 + 8) -#define	AT91_PIN_PB9	(PIN_BASE + 0x20 + 9) -#define	AT91_PIN_PB10	(PIN_BASE + 0x20 + 10) -#define	AT91_PIN_PB11	(PIN_BASE + 0x20 + 11) -#define	AT91_PIN_PB12	(PIN_BASE + 0x20 + 12) -#define	AT91_PIN_PB13	(PIN_BASE + 0x20 + 13) -#define	AT91_PIN_PB14	(PIN_BASE + 0x20 + 14) -#define	AT91_PIN_PB15	(PIN_BASE + 0x20 + 15) -#define	AT91_PIN_PB16	(PIN_BASE + 0x20 + 16) -#define	AT91_PIN_PB17	(PIN_BASE + 0x20 + 17) -#define	AT91_PIN_PB18	(PIN_BASE + 0x20 + 18) -#define	AT91_PIN_PB19	(PIN_BASE + 0x20 + 19) -#define	AT91_PIN_PB20	(PIN_BASE + 0x20 + 20) -#define	AT91_PIN_PB21	(PIN_BASE + 0x20 + 21) -#define	AT91_PIN_PB22	(PIN_BASE + 0x20 + 22) -#define	AT91_PIN_PB23	(PIN_BASE + 0x20 + 23) -#define	AT91_PIN_PB24	(PIN_BASE + 0x20 + 24) -#define	AT91_PIN_PB25	(PIN_BASE + 0x20 + 25) -#define	AT91_PIN_PB26	(PIN_BASE + 0x20 + 26) -#define	AT91_PIN_PB27	(PIN_BASE + 0x20 + 27) -#define	AT91_PIN_PB28	(PIN_BASE + 0x20 + 28) -#define	AT91_PIN_PB29	(PIN_BASE + 0x20 + 29) -#define	AT91_PIN_PB30	(PIN_BASE + 0x20 + 30) -#define	AT91_PIN_PB31	(PIN_BASE + 0x20 + 31) - -#define	AT91_PIN_PC0	(PIN_BASE + 0x40 + 0) -#define	AT91_PIN_PC1	(PIN_BASE + 0x40 + 1) -#define	AT91_PIN_PC2	(PIN_BASE + 0x40 + 2) -#define	AT91_PIN_PC3	(PIN_BASE + 0x40 + 3) -#define	AT91_PIN_PC4	(PIN_BASE + 0x40 + 4) -#define	AT91_PIN_PC5	(PIN_BASE + 0x40 + 5) -#define	AT91_PIN_PC6	(PIN_BASE + 0x40 + 6) -#define	AT91_PIN_PC7	(PIN_BASE + 0x40 + 7) -#define	AT91_PIN_PC8	(PIN_BASE + 0x40 + 8) -#define	AT91_PIN_PC9	(PIN_BASE + 0x40 + 9) -#define	AT91_PIN_PC10	(PIN_BASE + 0x40 + 10) -#define	AT91_PIN_PC11	(PIN_BASE + 0x40 + 11) -#define	AT91_PIN_PC12	(PIN_BASE + 0x40 + 12) -#define	AT91_PIN_PC13	(PIN_BASE + 0x40 + 13) -#define	AT91_PIN_PC14	(PIN_BASE + 0x40 + 14) -#define	AT91_PIN_PC15	(PIN_BASE + 0x40 + 15) -#define	AT91_PIN_PC16	(PIN_BASE + 0x40 + 16) -#define	AT91_PIN_PC17	(PIN_BASE + 0x40 + 17) -#define	AT91_PIN_PC18	(PIN_BASE + 0x40 + 18) -#define	AT91_PIN_PC19	(PIN_BASE + 0x40 + 19) -#define	AT91_PIN_PC20	(PIN_BASE + 0x40 + 20) -#define	AT91_PIN_PC21	(PIN_BASE + 0x40 + 21) -#define	AT91_PIN_PC22	(PIN_BASE + 0x40 + 22) -#define	AT91_PIN_PC23	(PIN_BASE + 0x40 + 23) -#define	AT91_PIN_PC24	(PIN_BASE + 0x40 + 24) -#define	AT91_PIN_PC25	(PIN_BASE + 0x40 + 25) -#define	AT91_PIN_PC26	(PIN_BASE + 0x40 + 26) -#define	AT91_PIN_PC27	(PIN_BASE + 0x40 + 27) -#define	AT91_PIN_PC28	(PIN_BASE + 0x40 + 28) -#define	AT91_PIN_PC29	(PIN_BASE + 0x40 + 29) -#define	AT91_PIN_PC30	(PIN_BASE + 0x40 + 30) -#define	AT91_PIN_PC31	(PIN_BASE + 0x40 + 31) - -#define	AT91_PIN_PD0	(PIN_BASE + 0x60 + 0) -#define	AT91_PIN_PD1	(PIN_BASE + 0x60 + 1) -#define	AT91_PIN_PD2	(PIN_BASE + 0x60 + 2) -#define	AT91_PIN_PD3	(PIN_BASE + 0x60 + 3) -#define	AT91_PIN_PD4	(PIN_BASE + 0x60 + 4) -#define	AT91_PIN_PD5	(PIN_BASE + 0x60 + 5) -#define	AT91_PIN_PD6	(PIN_BASE + 0x60 + 6) -#define	AT91_PIN_PD7	(PIN_BASE + 0x60 + 7) -#define	AT91_PIN_PD8	(PIN_BASE + 0x60 + 8) -#define	AT91_PIN_PD9	(PIN_BASE + 0x60 + 9) -#define	AT91_PIN_PD10	(PIN_BASE + 0x60 + 10) -#define	AT91_PIN_PD11	(PIN_BASE + 0x60 + 11) -#define	AT91_PIN_PD12	(PIN_BASE + 0x60 + 12) -#define	AT91_PIN_PD13	(PIN_BASE + 0x60 + 13) -#define	AT91_PIN_PD14	(PIN_BASE + 0x60 + 14) -#define	AT91_PIN_PD15	(PIN_BASE + 0x60 + 15) -#define	AT91_PIN_PD16	(PIN_BASE + 0x60 + 16) -#define	AT91_PIN_PD17	(PIN_BASE + 0x60 + 17) -#define	AT91_PIN_PD18	(PIN_BASE + 0x60 + 18) -#define	AT91_PIN_PD19	(PIN_BASE + 0x60 + 19) -#define	AT91_PIN_PD20	(PIN_BASE + 0x60 + 20) -#define	AT91_PIN_PD21	(PIN_BASE + 0x60 + 21) -#define	AT91_PIN_PD22	(PIN_BASE + 0x60 + 22) -#define	AT91_PIN_PD23	(PIN_BASE + 0x60 + 23) -#define	AT91_PIN_PD24	(PIN_BASE + 0x60 + 24) -#define	AT91_PIN_PD25	(PIN_BASE + 0x60 + 25) -#define	AT91_PIN_PD26	(PIN_BASE + 0x60 + 26) -#define	AT91_PIN_PD27	(PIN_BASE + 0x60 + 27) -#define	AT91_PIN_PD28	(PIN_BASE + 0x60 + 28) -#define	AT91_PIN_PD29	(PIN_BASE + 0x60 + 29) -#define	AT91_PIN_PD30	(PIN_BASE + 0x60 + 30) -#define	AT91_PIN_PD31	(PIN_BASE + 0x60 + 31) - -#define	AT91_PIN_PE0	(PIN_BASE + 0x80 + 0) -#define	AT91_PIN_PE1	(PIN_BASE + 0x80 + 1) -#define	AT91_PIN_PE2	(PIN_BASE + 0x80 + 2) -#define	AT91_PIN_PE3	(PIN_BASE + 0x80 + 3) -#define	AT91_PIN_PE4	(PIN_BASE + 0x80 + 4) -#define	AT91_PIN_PE5	(PIN_BASE + 0x80 + 5) -#define	AT91_PIN_PE6	(PIN_BASE + 0x80 + 6) -#define	AT91_PIN_PE7	(PIN_BASE + 0x80 + 7) -#define	AT91_PIN_PE8	(PIN_BASE + 0x80 + 8) -#define	AT91_PIN_PE9	(PIN_BASE + 0x80 + 9) -#define	AT91_PIN_PE10	(PIN_BASE + 0x80 + 10) -#define	AT91_PIN_PE11	(PIN_BASE + 0x80 + 11) -#define	AT91_PIN_PE12	(PIN_BASE + 0x80 + 12) -#define	AT91_PIN_PE13	(PIN_BASE + 0x80 + 13) -#define	AT91_PIN_PE14	(PIN_BASE + 0x80 + 14) -#define	AT91_PIN_PE15	(PIN_BASE + 0x80 + 15) -#define	AT91_PIN_PE16	(PIN_BASE + 0x80 + 16) -#define	AT91_PIN_PE17	(PIN_BASE + 0x80 + 17) -#define	AT91_PIN_PE18	(PIN_BASE + 0x80 + 18) -#define	AT91_PIN_PE19	(PIN_BASE + 0x80 + 19) -#define	AT91_PIN_PE20	(PIN_BASE + 0x80 + 20) -#define	AT91_PIN_PE21	(PIN_BASE + 0x80 + 21) -#define	AT91_PIN_PE22	(PIN_BASE + 0x80 + 22) -#define	AT91_PIN_PE23	(PIN_BASE + 0x80 + 23) -#define	AT91_PIN_PE24	(PIN_BASE + 0x80 + 24) -#define	AT91_PIN_PE25	(PIN_BASE + 0x80 + 25) -#define	AT91_PIN_PE26	(PIN_BASE + 0x80 + 26) -#define	AT91_PIN_PE27	(PIN_BASE + 0x80 + 27) -#define	AT91_PIN_PE28	(PIN_BASE + 0x80 + 28) -#define	AT91_PIN_PE29	(PIN_BASE + 0x80 + 29) -#define	AT91_PIN_PE30	(PIN_BASE + 0x80 + 30) -#define	AT91_PIN_PE31	(PIN_BASE + 0x80 + 31) - -#ifndef __ASSEMBLY__ -/* setup setup routines, called from board init or driver probe() */ -extern int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup); -extern int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup); -extern int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup); -extern int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup); -extern int __init_or_module at91_set_gpio_output(unsigned pin, int value); -extern int __init_or_module at91_set_deglitch(unsigned pin, int is_on); -extern int __init_or_module at91_set_multi_drive(unsigned pin, int is_on); - -/* callable at any time */ -extern int at91_set_gpio_value(unsigned pin, int value); -extern int at91_get_gpio_value(unsigned pin); - -/* callable only from core power-management code */ -extern void at91_gpio_suspend(void); -extern void at91_gpio_resume(void); - -/*-------------------------------------------------------------------------*/ - -/* wrappers for "new style" GPIO calls. the old AT91-specfic ones should - * eventually be removed (along with this errno.h inclusion), and the - * gpio request/free calls should probably be implemented. - */ - -#include <asm/errno.h> -#include <asm-generic/gpio.h>		/* cansleep wrappers */ - -#define gpio_get_value	__gpio_get_value -#define gpio_set_value	__gpio_set_value -#define gpio_cansleep	__gpio_cansleep - -static inline int gpio_to_irq(unsigned gpio) -{ -	return gpio; -} - -static inline int irq_to_gpio(unsigned irq) -{ -	return irq; -} - -#endif	/* __ASSEMBLY__ */ - -#endif diff --git a/arch/arm/mach-at91/include/mach/hardware.h b/arch/arm/mach-at91/include/mach/hardware.h index 3d64a75e3ed..56338245653 100644 --- a/arch/arm/mach-at91/include/mach/hardware.h +++ b/arch/arm/mach-at91/include/mach/hardware.h @@ -16,28 +16,51 @@  #include <asm/sizes.h> -#if defined(CONFIG_ARCH_AT91RM9200) +/* DBGU base */ +/* rm9200, 9260/9g20, 9261/9g10, 9rl */ +#define AT91_BASE_DBGU0	0xfffff200 +/* 9263, 9g45 */ +#define AT91_BASE_DBGU1	0xffffee00 + +#if defined(CONFIG_ARCH_AT91X40) +#include <mach/at91x40.h> +#else  #include <mach/at91rm9200.h> -#elif defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9G20)  #include <mach/at91sam9260.h> -#elif defined(CONFIG_ARCH_AT91SAM9261) || defined(CONFIG_ARCH_AT91SAM9G10)  #include <mach/at91sam9261.h> -#elif defined(CONFIG_ARCH_AT91SAM9263)  #include <mach/at91sam9263.h> -#elif defined(CONFIG_ARCH_AT91SAM9RL)  #include <mach/at91sam9rl.h> -#elif defined(CONFIG_ARCH_AT91SAM9G45)  #include <mach/at91sam9g45.h> -#elif defined(CONFIG_ARCH_AT91CAP9) -#include <mach/at91cap9.h> -#elif defined(CONFIG_ARCH_AT91X40) -#include <mach/at91x40.h> -#elif defined(CONFIG_ARCH_AT572D940HF) -#include <mach/at572d940hf.h> -#else -#error "Unsupported AT91 processor" +#include <mach/at91sam9x5.h> +#include <mach/at91sam9n12.h> +#include <mach/sama5d3.h> + +/* + * On all at91 except rm9200 and x40 have the System Controller starts + * at address 0xffffc000 and has a size of 16KiB. + * + * On rm9200 it's start at 0xfffe4000 of 111KiB with non reserved data starting + * at 0xfffff000 + * + * Removes the individual definitions of AT91_BASE_SYS and + * replaces them with a common version at base 0xfffffc000 and size 16KiB + * and map the same memory space + */ +#define AT91_BASE_SYS	0xffffc000  #endif +/* + * On all at91 have the Advanced Interrupt Controller starts at address + * 0xfffff000 and the Power Management Controller starts at 0xfffffc00 + */ +#define AT91_AIC	0xfffff000 +#define AT91_PMC	0xfffffc00 + +/* + * Peripheral identifiers/interrupts. + */ +#define AT91_ID_FIQ		0	/* Advanced Interrupt Controller (FIQ) */ +#define AT91_ID_SYS		1	/* System Peripherals */  #ifdef CONFIG_MMU  /* @@ -45,13 +68,13 @@   * to 0xFEF78000 .. 0xFF000000.  (544Kb)   */  #define AT91_IO_PHYS_BASE	0xFFF78000 -#define AT91_IO_VIRT_BASE	(0xFF000000 - AT91_IO_SIZE) +#define AT91_IO_VIRT_BASE	IOMEM(0xFF000000 - AT91_IO_SIZE)  #else  /*   * Identity mapping for the non MMU case.   */  #define AT91_IO_PHYS_BASE	AT91_BASE_SYS -#define AT91_IO_VIRT_BASE	AT91_IO_PHYS_BASE +#define AT91_IO_VIRT_BASE	IOMEM(AT91_IO_PHYS_BASE)  #endif  #define AT91_IO_SIZE		(0xFFFFFFFF - AT91_IO_PHYS_BASE + 1) @@ -63,15 +86,11 @@   * Virtual to Physical Address mapping for IO devices.   */  #define AT91_VA_BASE_SYS	AT91_IO_P2V(AT91_BASE_SYS) -#define AT91_VA_BASE_EMAC	AT91_IO_P2V(AT91RM9200_BASE_EMAC)   /* Internal SRAM is mapped below the IO devices */  #define AT91_SRAM_MAX		SZ_1M  #define AT91_VIRT_BASE		(AT91_IO_VIRT_BASE - AT91_SRAM_MAX) -/* Serial ports */ -#define ATMEL_MAX_UART		7		/* 6 USART3's and one DBGU port (SAM9260) */ -  /* External Memory Map */  #define AT91_CHIPSELECT_0	0x10000000  #define AT91_CHIPSELECT_1	0x20000000 @@ -82,15 +101,23 @@  #define AT91_CHIPSELECT_6	0x70000000  #define AT91_CHIPSELECT_7	0x80000000 -/* SDRAM */ -#ifdef CONFIG_DRAM_BASE -#define AT91_SDRAM_BASE		CONFIG_DRAM_BASE -#else -#define AT91_SDRAM_BASE		AT91_CHIPSELECT_1 -#endif -  /* Clocks */  #define AT91_SLOW_CLOCK		32768		/* slow clock */ +/* + * FIXME: this is needed to communicate between the pinctrl driver and + * the PM implementation in the machine. Possibly part of the PM + * implementation should be moved down into the pinctrl driver and get + * called as part of the generic suspend/resume path. + */ +#ifndef __ASSEMBLY__ +#ifdef CONFIG_PINCTRL_AT91 +extern void at91_pinctrl_gpio_suspend(void); +extern void at91_pinctrl_gpio_resume(void); +#else +static inline void at91_pinctrl_gpio_suspend(void) {} +static inline void at91_pinctrl_gpio_resume(void) {} +#endif +#endif  #endif diff --git a/arch/arm/mach-at91/include/mach/io.h b/arch/arm/mach-at91/include/mach/io.h index 0b0cccc46e6..2d9ca045574 100644 --- a/arch/arm/mach-at91/include/mach/io.h +++ b/arch/arm/mach-at91/include/mach/io.h @@ -22,27 +22,6 @@  #define __ASM_ARCH_IO_H  #define IO_SPACE_LIMIT		0xFFFFFFFF - -#define __io(a)		__typesafe_io(a) -#define __mem_pci(a)	(a) - - -#ifndef __ASSEMBLY__ - -static inline unsigned int at91_sys_read(unsigned int reg_offset) -{ -	void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS; - -	return __raw_readl(addr + reg_offset); -} - -static inline void at91_sys_write(unsigned int reg_offset, unsigned long value) -{ -	void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS; - -	__raw_writel(value, addr + reg_offset); -} - -#endif +#define __io(a)			__typesafe_io(a)  #endif diff --git a/arch/arm/mach-at91/include/mach/irqs.h b/arch/arm/mach-at91/include/mach/irqs.h deleted file mode 100644 index 36bd55f3fc6..00000000000 --- a/arch/arm/mach-at91/include/mach/irqs.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/irqs.h - * - *  Copyright (C) 2004 SAN People - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#ifndef __ASM_ARCH_IRQS_H -#define __ASM_ARCH_IRQS_H - -#include <linux/io.h> -#include <mach/at91_aic.h> - -#define NR_AIC_IRQS 32 - - -/* - * Acknowledge interrupt with AIC after interrupt has been handled. - *   (by kernel/irq.c) - */ -#define irq_finish(irq) do { at91_sys_write(AT91_AIC_EOICR, 0); } while (0) - - -/* - * IRQ interrupt symbols are the AT91xxx_ID_* symbols - * for IRQs handled directly through the AIC, or else the AT91_PIN_* - * symbols in gpio.h for ones handled indirectly as GPIOs. - * We make provision for 5 banks of GPIO. - */ -#define	NR_IRQS		(NR_AIC_IRQS + (5 * 32)) - -/* FIQ is AIC source 0. */ -#define FIQ_START AT91_ID_FIQ - -#endif diff --git a/arch/arm/mach-at91/include/mach/memory.h b/arch/arm/mach-at91/include/mach/memory.h index 14f4ef4b6a9..401c207f2f3 100644 --- a/arch/arm/mach-at91/include/mach/memory.h +++ b/arch/arm/mach-at91/include/mach/memory.h @@ -23,6 +23,4 @@  #include <mach/hardware.h> -#define PHYS_OFFSET	(AT91_SDRAM_BASE) -  #endif diff --git a/arch/arm/mach-at91/include/mach/sama5d3.h b/arch/arm/mach-at91/include/mach/sama5d3.h new file mode 100644 index 00000000000..25613d8c6dc --- /dev/null +++ b/arch/arm/mach-at91/include/mach/sama5d3.h @@ -0,0 +1,86 @@ +/* + * Chip-specific header file for the SAMA5D3 family + * + *  Copyright (C) 2013 Atmel, + *                2013 Ludovic Desroches <ludovic.desroches@atmel.com> + * + * Common definitions. + * Based on SAMA5D3 datasheet. + * + * Licensed under GPLv2 or later. + */ + +#ifndef SAMA5D3_H +#define SAMA5D3_H + +/* + * Peripheral identifiers/interrupts. + */ +#define AT91_ID_FIQ		 0	/* Advanced Interrupt Controller (FIQ) */ +#define AT91_ID_SYS		 1	/* System Peripherals */ +#define SAMA5D3_ID_DBGU		 2	/* debug Unit (usually no special interrupt line) */ +#define AT91_ID_PIT		 3	/* PIT */ +#define SAMA5D3_ID_WDT		 4	/* Watchdog Timer Interrupt */ +#define SAMA5D3_ID_HSMC		 5	/* Static Memory Controller */ +#define SAMA5D3_ID_PIOA		 6	/* PIOA */ +#define SAMA5D3_ID_PIOB		 7	/* PIOB */ +#define SAMA5D3_ID_PIOC		 8	/* PIOC */ +#define SAMA5D3_ID_PIOD		 9	/* PIOD */ +#define SAMA5D3_ID_PIOE		10	/* PIOE */ +#define SAMA5D3_ID_SMD		11	/* SMD Soft Modem */ +#define SAMA5D3_ID_USART0	12	/* USART0 */ +#define SAMA5D3_ID_USART1	13	/* USART1 */ +#define SAMA5D3_ID_USART2	14	/* USART2 */ +#define SAMA5D3_ID_USART3	15	/* USART3 */ +#define SAMA5D3_ID_UART0	16	/* UART 0 */ +#define SAMA5D3_ID_UART1	17	/* UART 1 */ +#define SAMA5D3_ID_TWI0		18	/* Two-Wire Interface 0 */ +#define SAMA5D3_ID_TWI1		19	/* Two-Wire Interface 1 */ +#define SAMA5D3_ID_TWI2		20	/* Two-Wire Interface 2 */ +#define SAMA5D3_ID_HSMCI0	21	/* MCI */ +#define SAMA5D3_ID_HSMCI1	22	/* MCI */ +#define SAMA5D3_ID_HSMCI2	23	/* MCI */ +#define SAMA5D3_ID_SPI0		24	/* Serial Peripheral Interface 0 */ +#define SAMA5D3_ID_SPI1		25	/* Serial Peripheral Interface 1 */ +#define SAMA5D3_ID_TC0		26	/* Timer Counter 0 */ +#define SAMA5D3_ID_TC1		27	/* Timer Counter 2 */ +#define SAMA5D3_ID_PWM		28	/* Pulse Width Modulation Controller */ +#define SAMA5D3_ID_ADC		29	/* Touch Screen ADC Controller */ +#define SAMA5D3_ID_DMA0		30	/* DMA Controller 0 */ +#define SAMA5D3_ID_DMA1		31	/* DMA Controller 1 */ +#define SAMA5D3_ID_UHPHS	32	/* USB Host High Speed */ +#define SAMA5D3_ID_UDPHS	33	/* USB Device High Speed */ +#define SAMA5D3_ID_GMAC		34	/* Gigabit Ethernet MAC */ +#define SAMA5D3_ID_EMAC		35	/* Ethernet MAC */ +#define SAMA5D3_ID_LCDC		36	/* LCD Controller */ +#define SAMA5D3_ID_ISI		37	/* Image Sensor Interface */ +#define SAMA5D3_ID_SSC0		38	/* Synchronous Serial Controller 0 */ +#define SAMA5D3_ID_SSC1		39	/* Synchronous Serial Controller 1 */ +#define SAMA5D3_ID_CAN0		40	/* CAN Controller 0 */ +#define SAMA5D3_ID_CAN1		41	/* CAN Controller 1 */ +#define SAMA5D3_ID_SHA		42	/* Secure Hash Algorithm */ +#define SAMA5D3_ID_AES		43	/* Advanced Encryption Standard */ +#define SAMA5D3_ID_TDES		44	/* Triple Data Encryption Standard */ +#define SAMA5D3_ID_TRNG		45	/* True Random Generator Number */ +#define SAMA5D3_ID_IRQ0		47	/* Advanced Interrupt Controller (IRQ0) */ + +/* + * User Peripheral physical base addresses. + */ +#define SAMA5D3_BASE_USART0	0xf001c000 +#define SAMA5D3_BASE_USART1	0xf0020000 +#define SAMA5D3_BASE_USART2	0xf8020000 +#define SAMA5D3_BASE_USART3	0xf8024000 + +/* + * System Peripherals + */ +#define SAMA5D3_BASE_RTC	0xfffffeb0 + +/* + * Internal Memory + */ +#define SAMA5D3_SRAM_BASE	0x00300000	/* Internal SRAM base address */ +#define SAMA5D3_SRAM_SIZE	(128 * SZ_1K)	/* Internal SRAM size (128Kb) */ + +#endif diff --git a/arch/arm/mach-at91/include/mach/system.h b/arch/arm/mach-at91/include/mach/system.h deleted file mode 100644 index 36af14bc13b..00000000000 --- a/arch/arm/mach-at91/include/mach/system.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/system.h - * - *  Copyright (C) 2003 SAN People - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#ifndef __ASM_ARCH_SYSTEM_H -#define __ASM_ARCH_SYSTEM_H - -#include <mach/hardware.h> -#include <mach/at91_st.h> -#include <mach/at91_dbgu.h> -#include <mach/at91_pmc.h> - -static inline void arch_idle(void) -{ -	/* -	 * Disable the processor clock.  The processor will be automatically -	 * re-enabled by an interrupt or by a reset. -	 */ -#ifdef AT91_PS -	at91_sys_write(AT91_PS_CR, AT91_PS_CR_CPU); -#else -	at91_sys_write(AT91_PMC_SCDR, AT91_PMC_PCK); -#endif -#ifndef CONFIG_CPU_ARM920T -	/* -	 * Set the processor (CP15) into 'Wait for Interrupt' mode. -	 * Post-RM9200 processors need this in conjunction with the above -	 * to save power when idle. -	 */ -	cpu_do_idle(); -#endif -} - -void (*at91_arch_reset)(void); - -static inline void arch_reset(char mode, const char *cmd) -{ -	/* call the CPU-specific reset function */ -	if (at91_arch_reset) -		(at91_arch_reset)(); -} - -#endif diff --git a/arch/arm/mach-at91/include/mach/system_rev.h b/arch/arm/mach-at91/include/mach/system_rev.h new file mode 100644 index 00000000000..ef79a9aafc0 --- /dev/null +++ b/arch/arm/mach-at91/include/mach/system_rev.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> + * + * Under GPLv2 only + */ + +#ifndef __ARCH_SYSTEM_REV_H__ +#define __ARCH_SYSTEM_REV_H__ + +#include <asm/system_info.h> + +/* + * board revision encoding + * mach specific + * the 16-31 bit are reserved for at91 generic information + * + * bit 31: + *	0 => nand 8 bit + *	1 => nand 16 bit + */ +#define BOARD_HAVE_NAND_16BIT	(1 << 31) +static inline int board_have_nand_16bit(void) +{ +	return (system_rev & BOARD_HAVE_NAND_16BIT) ? 1 : 0; +} + +#endif /* __ARCH_SYSTEM_REV_H__ */ diff --git a/arch/arm/mach-at91/include/mach/timex.h b/arch/arm/mach-at91/include/mach/timex.h deleted file mode 100644 index 05a6e8af80c..00000000000 --- a/arch/arm/mach-at91/include/mach/timex.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/timex.h - * - *  Copyright (C) 2003 SAN People - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#ifndef __ASM_ARCH_TIMEX_H -#define __ASM_ARCH_TIMEX_H - -#include <mach/hardware.h> - -#if defined(CONFIG_ARCH_AT91RM9200) - -#define CLOCK_TICK_RATE		(AT91_SLOW_CLOCK) - -#elif defined(CONFIG_ARCH_AT91SAM9260) - -#if defined(CONFIG_MACH_USB_A9260) || defined(CONFIG_MACH_QIL_A9260) -#define AT91SAM9_MASTER_CLOCK	90000000 -#else -#define AT91SAM9_MASTER_CLOCK	99300000 -#endif - -#define CLOCK_TICK_RATE		(AT91SAM9_MASTER_CLOCK/16) - -#elif defined(CONFIG_ARCH_AT91SAM9261) - -#define AT91SAM9_MASTER_CLOCK	99300000 -#define CLOCK_TICK_RATE		(AT91SAM9_MASTER_CLOCK/16) - -#elif defined(CONFIG_ARCH_AT91SAM9G10) - -#define AT91SAM9_MASTER_CLOCK	133000000 -#define CLOCK_TICK_RATE		(AT91SAM9_MASTER_CLOCK/16) - -#elif defined(CONFIG_ARCH_AT91SAM9263) - -#if defined(CONFIG_MACH_USB_A9263) -#define AT91SAM9_MASTER_CLOCK	90000000 -#else -#define AT91SAM9_MASTER_CLOCK	99959500 -#endif - -#define CLOCK_TICK_RATE		(AT91SAM9_MASTER_CLOCK/16) - -#elif defined(CONFIG_ARCH_AT91SAM9RL) - -#define AT91SAM9_MASTER_CLOCK	100000000 -#define CLOCK_TICK_RATE		(AT91SAM9_MASTER_CLOCK/16) - -#elif defined(CONFIG_ARCH_AT91SAM9G20) - -#define AT91SAM9_MASTER_CLOCK	132096000 -#define CLOCK_TICK_RATE		(AT91SAM9_MASTER_CLOCK/16) - -#elif defined(CONFIG_ARCH_AT91SAM9G45) - -#define AT91SAM9_MASTER_CLOCK	133333333 -#define CLOCK_TICK_RATE		(AT91SAM9_MASTER_CLOCK/16) - -#elif defined(CONFIG_ARCH_AT91CAP9) - -#define AT91CAP9_MASTER_CLOCK	100000000 -#define CLOCK_TICK_RATE		(AT91CAP9_MASTER_CLOCK/16) - -#elif defined(CONFIG_ARCH_AT91X40) - -#define AT91X40_MASTER_CLOCK	40000000 -#define CLOCK_TICK_RATE		(AT91X40_MASTER_CLOCK) - -#elif defined(CONFIG_ARCH_AT572D940HF) - -#define AT572D940HF_MASTER_CLOCK	80000000 -#define CLOCK_TICK_RATE		(AT572D940HF_MASTER_CLOCK/16) - -#endif - -#endif diff --git a/arch/arm/mach-at91/include/mach/uncompress.h b/arch/arm/mach-at91/include/mach/uncompress.h index 18bdcdeb474..4bb644f8e87 100644 --- a/arch/arm/mach-at91/include/mach/uncompress.h +++ b/arch/arm/mach-at91/include/mach/uncompress.h @@ -1,7 +1,8 @@  /*   * arch/arm/mach-at91/include/mach/uncompress.h   * - *  Copyright (C) 2003 SAN People + * Copyright (C) 2003 SAN People + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>   *   * This program is free software; you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -23,21 +24,162 @@  #include <linux/io.h>  #include <linux/atmel_serial.h> +#include <mach/hardware.h> -#if defined(CONFIG_AT91_EARLY_DBGU) -#define UART_OFFSET (AT91_DBGU + AT91_BASE_SYS) -#elif defined(CONFIG_AT91_EARLY_USART0) -#define UART_OFFSET AT91_USART0 -#elif defined(CONFIG_AT91_EARLY_USART1) -#define UART_OFFSET AT91_USART1 -#elif defined(CONFIG_AT91_EARLY_USART2) -#define UART_OFFSET AT91_USART2 -#elif defined(CONFIG_AT91_EARLY_USART3) -#define UART_OFFSET AT91_USART3 -#elif defined(CONFIG_AT91_EARLY_USART4) -#define UART_OFFSET AT91_USART4 -#elif defined(CONFIG_AT91_EARLY_USART5) -#define UART_OFFSET AT91_USART5 +#include <mach/at91_dbgu.h> +#include <mach/cpu.h> + +void __iomem *at91_uart; + +#if !defined(CONFIG_ARCH_AT91X40) +static const u32 uarts_rm9200[] = { +	AT91_BASE_DBGU0, +	AT91RM9200_BASE_US0, +	AT91RM9200_BASE_US1, +	AT91RM9200_BASE_US2, +	AT91RM9200_BASE_US3, +	0, +}; + +static const u32 uarts_sam9260[] = { +	AT91_BASE_DBGU0, +	AT91SAM9260_BASE_US0, +	AT91SAM9260_BASE_US1, +	AT91SAM9260_BASE_US2, +	AT91SAM9260_BASE_US3, +	AT91SAM9260_BASE_US4, +	AT91SAM9260_BASE_US5, +	0, +}; + +static const u32 uarts_sam9261[] = { +	AT91_BASE_DBGU0, +	AT91SAM9261_BASE_US0, +	AT91SAM9261_BASE_US1, +	AT91SAM9261_BASE_US2, +	0, +}; + +static const u32 uarts_sam9263[] = { +	AT91_BASE_DBGU1, +	AT91SAM9263_BASE_US0, +	AT91SAM9263_BASE_US1, +	AT91SAM9263_BASE_US2, +	0, +}; + +static const u32 uarts_sam9g45[] = { +	AT91_BASE_DBGU1, +	AT91SAM9G45_BASE_US0, +	AT91SAM9G45_BASE_US1, +	AT91SAM9G45_BASE_US2, +	AT91SAM9G45_BASE_US3, +	0, +}; + +static const u32 uarts_sam9rl[] = { +	AT91_BASE_DBGU0, +	AT91SAM9RL_BASE_US0, +	AT91SAM9RL_BASE_US1, +	AT91SAM9RL_BASE_US2, +	AT91SAM9RL_BASE_US3, +	0, +}; + +static const u32 uarts_sam9x5[] = { +	AT91_BASE_DBGU0, +	AT91SAM9X5_BASE_USART0, +	AT91SAM9X5_BASE_USART1, +	AT91SAM9X5_BASE_USART2, +	0, +}; + +static const u32 uarts_sama5[] = { +	AT91_BASE_DBGU1, +	SAMA5D3_BASE_USART0, +	SAMA5D3_BASE_USART1, +	SAMA5D3_BASE_USART2, +	SAMA5D3_BASE_USART3, +	0, +}; + +static inline const u32* decomp_soc_detect(void __iomem *dbgu_base) +{ +	u32 cidr, socid; + +	cidr = __raw_readl(dbgu_base + AT91_DBGU_CIDR); +	socid = cidr & ~AT91_CIDR_VERSION; + +	switch (socid) { +	case ARCH_ID_AT91RM9200: +		return uarts_rm9200; + +	case ARCH_ID_AT91SAM9G20: +	case ARCH_ID_AT91SAM9260: +		return uarts_sam9260; + +	case ARCH_ID_AT91SAM9261: +		return uarts_sam9261; + +	case ARCH_ID_AT91SAM9263: +		return uarts_sam9263; + +	case ARCH_ID_AT91SAM9G45: +		return uarts_sam9g45; + +	case ARCH_ID_AT91SAM9RL64: +		return uarts_sam9rl; + +	case ARCH_ID_AT91SAM9N12: +	case ARCH_ID_AT91SAM9X5: +		return uarts_sam9x5; + +	case ARCH_ID_SAMA5D3: +		return uarts_sama5; +	} + +	/* at91sam9g10 */ +	if ((cidr & ~AT91_CIDR_EXT) == ARCH_ID_AT91SAM9G10) { +		return uarts_sam9261; +	} +	/* at91sam9xe */ +	else if ((cidr & AT91_CIDR_ARCH) == ARCH_FAMILY_AT91SAM9XE) { +		return uarts_sam9260; +	} + +	return NULL; +} + +static inline void arch_decomp_setup(void) +{ +	int i = 0; +	const u32* usarts; + +	usarts = decomp_soc_detect((void __iomem *)AT91_BASE_DBGU0); + +	if (!usarts) +		usarts = decomp_soc_detect((void __iomem *)AT91_BASE_DBGU1); +	if (!usarts) { +		at91_uart = NULL; +		return; +	} + +	do { +		/* physical address */ +		at91_uart = (void __iomem *)usarts[i]; + +		if (__raw_readl(at91_uart + ATMEL_US_BRGR)) +			return; +		i++; +	} while (usarts[i]); + +	at91_uart = NULL; +} +#else +static inline void arch_decomp_setup(void) +{ +	at91_uart = NULL; +}  #endif  /* @@ -49,28 +191,22 @@   */  static void putc(int c)  { -#ifdef UART_OFFSET -	void __iomem *sys = (void __iomem *) UART_OFFSET;	/* physical address */ +	if (!at91_uart) +		return; -	while (!(__raw_readl(sys + ATMEL_US_CSR) & ATMEL_US_TXRDY)) +	while (!(__raw_readl(at91_uart + ATMEL_US_CSR) & ATMEL_US_TXRDY))  		barrier(); -	__raw_writel(c, sys + ATMEL_US_THR); -#endif +	__raw_writel(c, at91_uart + ATMEL_US_THR);  }  static inline void flush(void)  { -#ifdef UART_OFFSET -	void __iomem *sys = (void __iomem *) UART_OFFSET;	/* physical address */ +	if (!at91_uart) +		return;  	/* wait for transmission to complete */ -	while (!(__raw_readl(sys + ATMEL_US_CSR) & ATMEL_US_TXEMPTY)) +	while (!(__raw_readl(at91_uart + ATMEL_US_CSR) & ATMEL_US_TXEMPTY))  		barrier(); -#endif  } -#define arch_decomp_setup() - -#define arch_decomp_wdog() -  #endif diff --git a/arch/arm/mach-at91/include/mach/vmalloc.h b/arch/arm/mach-at91/include/mach/vmalloc.h deleted file mode 100644 index 8eb459f3f5b..00000000000 --- a/arch/arm/mach-at91/include/mach/vmalloc.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/vmalloc.h - * - *  Copyright (C) 2003 SAN People - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - */ - -#ifndef __ASM_ARCH_VMALLOC_H -#define __ASM_ARCH_VMALLOC_H - -#define VMALLOC_END		(AT91_VIRT_BASE & PGDIR_MASK) - -#endif diff --git a/arch/arm/mach-at91/irq.c b/arch/arm/mach-at91/irq.c index da3494a5342..3d192c5aee6 100644 --- a/arch/arm/mach-at91/irq.c +++ b/arch/arm/mach-at91/irq.c @@ -23,36 +23,229 @@  #include <linux/init.h>  #include <linux/module.h>  #include <linux/mm.h> +#include <linux/bitmap.h>  #include <linux/types.h> +#include <linux/irq.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> +#include <linux/irqdomain.h> +#include <linux/err.h> +#include <linux/slab.h>  #include <mach/hardware.h>  #include <asm/irq.h>  #include <asm/setup.h> +#include <asm/exception.h>  #include <asm/mach/arch.h>  #include <asm/mach/irq.h>  #include <asm/mach/map.h> +#include "at91_aic.h" -static void at91_aic_mask_irq(unsigned int irq) +void __iomem *at91_aic_base; +static struct irq_domain *at91_aic_domain; +static struct device_node *at91_aic_np; +static unsigned int n_irqs = NR_AIC_IRQS; +static unsigned long at91_aic_caps = 0; + +/* AIC5 introduces a Source Select Register */ +#define AT91_AIC_CAP_AIC5	(1 << 0) +#define has_aic5()		(at91_aic_caps & AT91_AIC_CAP_AIC5) + +#ifdef CONFIG_PM + +static unsigned long *wakeups; +static unsigned long *backups; + +#define set_backup(bit) set_bit(bit, backups) +#define clear_backup(bit) clear_bit(bit, backups) + +static int at91_aic_pm_init(void) +{ +	backups = kzalloc(BITS_TO_LONGS(n_irqs) * sizeof(*backups), GFP_KERNEL); +	if (!backups) +		return -ENOMEM; + +	wakeups = kzalloc(BITS_TO_LONGS(n_irqs) * sizeof(*backups), GFP_KERNEL); +	if (!wakeups) { +		kfree(backups); +		return -ENOMEM; +	} + +	return 0; +} + +static int at91_aic_set_wake(struct irq_data *d, unsigned value) +{ +	if (unlikely(d->hwirq >= n_irqs)) +		return -EINVAL; + +	if (value) +		set_bit(d->hwirq, wakeups); +	else +		clear_bit(d->hwirq, wakeups); + +	return 0; +} + +void at91_irq_suspend(void) +{ +	int bit = -1; + +	if (has_aic5()) { +		/* disable enabled irqs */ +		while ((bit = find_next_bit(backups, n_irqs, bit + 1)) < n_irqs) { +			at91_aic_write(AT91_AIC5_SSR, +				       bit & AT91_AIC5_INTSEL_MSK); +			at91_aic_write(AT91_AIC5_IDCR, 1); +		} +		/* enable wakeup irqs */ +		bit = -1; +		while ((bit = find_next_bit(wakeups, n_irqs, bit + 1)) < n_irqs) { +			at91_aic_write(AT91_AIC5_SSR, +				       bit & AT91_AIC5_INTSEL_MSK); +			at91_aic_write(AT91_AIC5_IECR, 1); +		} +	} else { +		at91_aic_write(AT91_AIC_IDCR, *backups); +		at91_aic_write(AT91_AIC_IECR, *wakeups); +	} +} + +void at91_irq_resume(void) +{ +	int bit = -1; + +	if (has_aic5()) { +		/* disable wakeup irqs */ +		while ((bit = find_next_bit(wakeups, n_irqs, bit + 1)) < n_irqs) { +			at91_aic_write(AT91_AIC5_SSR, +				       bit & AT91_AIC5_INTSEL_MSK); +			at91_aic_write(AT91_AIC5_IDCR, 1); +		} +		/* enable irqs disabled for suspend */ +		bit = -1; +		while ((bit = find_next_bit(backups, n_irqs, bit + 1)) < n_irqs) { +			at91_aic_write(AT91_AIC5_SSR, +				       bit & AT91_AIC5_INTSEL_MSK); +			at91_aic_write(AT91_AIC5_IECR, 1); +		} +	} else { +		at91_aic_write(AT91_AIC_IDCR, *wakeups); +		at91_aic_write(AT91_AIC_IECR, *backups); +	} +} + +#else +static inline int at91_aic_pm_init(void) +{ +	return 0; +} + +#define set_backup(bit) +#define clear_backup(bit) +#define at91_aic_set_wake	NULL + +#endif /* CONFIG_PM */ + +asmlinkage void __exception_irq_entry +at91_aic_handle_irq(struct pt_regs *regs) +{ +	u32 irqnr; +	u32 irqstat; + +	irqnr = at91_aic_read(AT91_AIC_IVR); +	irqstat = at91_aic_read(AT91_AIC_ISR); + +	/* +	 * ISR value is 0 when there is no current interrupt or when there is +	 * a spurious interrupt +	 */ +	if (!irqstat) +		at91_aic_write(AT91_AIC_EOICR, 0); +	else +		handle_IRQ(irqnr, regs); +} + +asmlinkage void __exception_irq_entry +at91_aic5_handle_irq(struct pt_regs *regs) +{ +	u32 irqnr; +	u32 irqstat; + +	irqnr = at91_aic_read(AT91_AIC5_IVR); +	irqstat = at91_aic_read(AT91_AIC5_ISR); + +	if (!irqstat) +		at91_aic_write(AT91_AIC5_EOICR, 0); +	else +		handle_IRQ(irqnr, regs); +} + +static void at91_aic_mask_irq(struct irq_data *d)  {  	/* Disable interrupt on AIC */ -	at91_sys_write(AT91_AIC_IDCR, 1 << irq); +	at91_aic_write(AT91_AIC_IDCR, 1 << d->hwirq); +	/* Update ISR cache */ +	clear_backup(d->hwirq);  } -static void at91_aic_unmask_irq(unsigned int irq) +static void __maybe_unused at91_aic5_mask_irq(struct irq_data *d) +{ +	/* Disable interrupt on AIC5 */ +	at91_aic_write(AT91_AIC5_SSR, d->hwirq & AT91_AIC5_INTSEL_MSK); +	at91_aic_write(AT91_AIC5_IDCR, 1); +	/* Update ISR cache */ +	clear_backup(d->hwirq); +} + +static void at91_aic_unmask_irq(struct irq_data *d)  {  	/* Enable interrupt on AIC */ -	at91_sys_write(AT91_AIC_IECR, 1 << irq); +	at91_aic_write(AT91_AIC_IECR, 1 << d->hwirq); +	/* Update ISR cache */ +	set_backup(d->hwirq);  } -unsigned int at91_extern_irq; +static void __maybe_unused at91_aic5_unmask_irq(struct irq_data *d) +{ +	/* Enable interrupt on AIC5 */ +	at91_aic_write(AT91_AIC5_SSR, d->hwirq & AT91_AIC5_INTSEL_MSK); +	at91_aic_write(AT91_AIC5_IECR, 1); +	/* Update ISR cache */ +	set_backup(d->hwirq); +} -#define is_extern_irq(irq) ((1 << (irq)) & at91_extern_irq) +static void at91_aic_eoi(struct irq_data *d) +{ +	/* +	 * Mark end-of-interrupt on AIC, the controller doesn't care about +	 * the value written. Moreover it's a write-only register. +	 */ +	at91_aic_write(AT91_AIC_EOICR, 0); +} -static int at91_aic_set_type(unsigned irq, unsigned type) +static void __maybe_unused at91_aic5_eoi(struct irq_data *d)  { -	unsigned int smr, srctype; +	at91_aic_write(AT91_AIC5_EOICR, 0); +} + +static unsigned long *at91_extern_irq; + +u32 at91_get_extern_irq(void) +{ +	if (!at91_extern_irq) +		return 0; +	return *at91_extern_irq; +} + +#define is_extern_irq(hwirq) test_bit(hwirq, at91_extern_irq) + +static int at91_aic_compute_srctype(struct irq_data *d, unsigned type) +{ +	int srctype;  	switch (type) {  	case IRQ_TYPE_LEVEL_HIGH: @@ -62,106 +255,300 @@ static int at91_aic_set_type(unsigned irq, unsigned type)  		srctype = AT91_AIC_SRCTYPE_RISING;  		break;  	case IRQ_TYPE_LEVEL_LOW: -		if ((irq == AT91_ID_FIQ) || is_extern_irq(irq))		/* only supported on external interrupts */ +		if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq))		/* only supported on external interrupts */  			srctype = AT91_AIC_SRCTYPE_LOW;  		else -			return -EINVAL; +			srctype = -EINVAL;  		break;  	case IRQ_TYPE_EDGE_FALLING: -		if ((irq == AT91_ID_FIQ) || is_extern_irq(irq))		/* only supported on external interrupts */ +		if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq))		/* only supported on external interrupts */  			srctype = AT91_AIC_SRCTYPE_FALLING;  		else -			return -EINVAL; +			srctype = -EINVAL;  		break;  	default: -		return -EINVAL; +		srctype = -EINVAL; +	} + +	return srctype; +} + +static int at91_aic_set_type(struct irq_data *d, unsigned type) +{ +	unsigned int smr; +	int srctype; + +	srctype = at91_aic_compute_srctype(d, type); +	if (srctype < 0) +		return srctype; + +	if (has_aic5()) { +		at91_aic_write(AT91_AIC5_SSR, +			       d->hwirq & AT91_AIC5_INTSEL_MSK); +		smr = at91_aic_read(AT91_AIC5_SMR) & ~AT91_AIC_SRCTYPE; +		at91_aic_write(AT91_AIC5_SMR, smr | srctype); +	} else { +		smr = at91_aic_read(AT91_AIC_SMR(d->hwirq)) +		      & ~AT91_AIC_SRCTYPE; +		at91_aic_write(AT91_AIC_SMR(d->hwirq), smr | srctype);  	} -	smr = at91_sys_read(AT91_AIC_SMR(irq)) & ~AT91_AIC_SRCTYPE; -	at91_sys_write(AT91_AIC_SMR(irq), smr | srctype);  	return 0;  } -#ifdef CONFIG_PM +static struct irq_chip at91_aic_chip = { +	.name		= "AIC", +	.irq_mask	= at91_aic_mask_irq, +	.irq_unmask	= at91_aic_unmask_irq, +	.irq_set_type	= at91_aic_set_type, +	.irq_set_wake	= at91_aic_set_wake, +	.irq_eoi	= at91_aic_eoi, +}; + +static void __init at91_aic_hw_init(unsigned int spu_vector) +{ +	int i; + +	/* +	 * Perform 8 End Of Interrupt Command to make sure AIC +	 * will not Lock out nIRQ +	 */ +	for (i = 0; i < 8; i++) +		at91_aic_write(AT91_AIC_EOICR, 0); -static u32 wakeups; -static u32 backups; +	/* +	 * Spurious Interrupt ID in Spurious Vector Register. +	 * When there is no current interrupt, the IRQ Vector Register +	 * reads the value stored in AIC_SPU +	 */ +	at91_aic_write(AT91_AIC_SPU, spu_vector); + +	/* No debugging in AIC: Debug (Protect) Control Register */ +	at91_aic_write(AT91_AIC_DCR, 0); + +	/* Disable and clear all interrupts initially */ +	at91_aic_write(AT91_AIC_IDCR, 0xFFFFFFFF); +	at91_aic_write(AT91_AIC_ICCR, 0xFFFFFFFF); +} -static int at91_aic_set_wake(unsigned irq, unsigned value) +static void __init __maybe_unused at91_aic5_hw_init(unsigned int spu_vector)  { -	if (unlikely(irq >= 32)) +	int i; + +	/* +	 * Perform 8 End Of Interrupt Command to make sure AIC +	 * will not Lock out nIRQ +	 */ +	for (i = 0; i < 8; i++) +		at91_aic_write(AT91_AIC5_EOICR, 0); + +	/* +	 * Spurious Interrupt ID in Spurious Vector Register. +	 * When there is no current interrupt, the IRQ Vector Register +	 * reads the value stored in AIC_SPU +	 */ +	at91_aic_write(AT91_AIC5_SPU, spu_vector); + +	/* No debugging in AIC: Debug (Protect) Control Register */ +	at91_aic_write(AT91_AIC5_DCR, 0); + +	/* Disable and clear all interrupts initially */ +	for (i = 0; i < n_irqs; i++) { +		at91_aic_write(AT91_AIC5_SSR, i & AT91_AIC5_INTSEL_MSK); +		at91_aic_write(AT91_AIC5_IDCR, 1); +		at91_aic_write(AT91_AIC5_ICCR, 1); +	} +} + +#if defined(CONFIG_OF) +static unsigned int *at91_aic_irq_priorities; + +static int at91_aic_irq_map(struct irq_domain *h, unsigned int virq, +							irq_hw_number_t hw) +{ +	/* Put virq number in Source Vector Register */ +	at91_aic_write(AT91_AIC_SVR(hw), virq); + +	/* Active Low interrupt, with priority */ +	at91_aic_write(AT91_AIC_SMR(hw), +		       AT91_AIC_SRCTYPE_LOW | at91_aic_irq_priorities[hw]); + +	irq_set_chip_and_handler(virq, &at91_aic_chip, handle_fasteoi_irq); +	set_irq_flags(virq, IRQF_VALID | IRQF_PROBE); + +	return 0; +} + +static int at91_aic5_irq_map(struct irq_domain *h, unsigned int virq, +		irq_hw_number_t hw) +{ +	at91_aic_write(AT91_AIC5_SSR, hw & AT91_AIC5_INTSEL_MSK); + +	/* Put virq number in Source Vector Register */ +	at91_aic_write(AT91_AIC5_SVR, virq); + +	/* Active Low interrupt, with priority */ +	at91_aic_write(AT91_AIC5_SMR, +		       AT91_AIC_SRCTYPE_LOW | at91_aic_irq_priorities[hw]); + +	irq_set_chip_and_handler(virq, &at91_aic_chip, handle_fasteoi_irq); +	set_irq_flags(virq, IRQF_VALID | IRQF_PROBE); + +	return 0; +} + +static int at91_aic_irq_domain_xlate(struct irq_domain *d, struct device_node *ctrlr, +				const u32 *intspec, unsigned int intsize, +				irq_hw_number_t *out_hwirq, unsigned int *out_type) +{ +	if (WARN_ON(intsize < 3)) +		return -EINVAL; +	if (WARN_ON(intspec[0] >= n_irqs)) +		return -EINVAL; +	if (WARN_ON((intspec[2] < AT91_AIC_IRQ_MIN_PRIORITY) +		    || (intspec[2] > AT91_AIC_IRQ_MAX_PRIORITY)))  		return -EINVAL; -	if (value) -		wakeups |= (1 << irq); -	else -		wakeups &= ~(1 << irq); +	*out_hwirq = intspec[0]; +	*out_type = intspec[1] & IRQ_TYPE_SENSE_MASK; +	at91_aic_irq_priorities[*out_hwirq] = intspec[2];  	return 0;  } -void at91_irq_suspend(void) +static struct irq_domain_ops at91_aic_irq_ops = { +	.map	= at91_aic_irq_map, +	.xlate	= at91_aic_irq_domain_xlate, +}; + +int __init at91_aic_of_common_init(struct device_node *node, +				    struct device_node *parent)  { -	backups = at91_sys_read(AT91_AIC_IMR); -	at91_sys_write(AT91_AIC_IDCR, backups); -	at91_sys_write(AT91_AIC_IECR, wakeups); +	struct property *prop; +	const __be32 *p; +	u32 val; + +	at91_extern_irq = kzalloc(BITS_TO_LONGS(n_irqs) +				  * sizeof(*at91_extern_irq), GFP_KERNEL); +	if (!at91_extern_irq) +		return -ENOMEM; + +	if (at91_aic_pm_init()) { +		kfree(at91_extern_irq); +		return -ENOMEM; +	} + +	at91_aic_irq_priorities = kzalloc(n_irqs +					  * sizeof(*at91_aic_irq_priorities), +					  GFP_KERNEL); +	if (!at91_aic_irq_priorities) +		return -ENOMEM; + +	at91_aic_base = of_iomap(node, 0); +	at91_aic_np = node; + +	at91_aic_domain = irq_domain_add_linear(at91_aic_np, n_irqs, +						&at91_aic_irq_ops, NULL); +	if (!at91_aic_domain) +		panic("Unable to add AIC irq domain (DT)\n"); + +	of_property_for_each_u32(node, "atmel,external-irqs", prop, p, val) { +		if (val >= n_irqs) +			pr_warn("AIC: external irq %d >= %d skip it\n", +				val, n_irqs); +		else +			set_bit(val, at91_extern_irq); +	} + +	irq_set_default_host(at91_aic_domain); + +	return 0;  } -void at91_irq_resume(void) +int __init at91_aic_of_init(struct device_node *node, +				     struct device_node *parent)  { -	at91_sys_write(AT91_AIC_IDCR, wakeups); -	at91_sys_write(AT91_AIC_IECR, backups); +	int err; + +	err = at91_aic_of_common_init(node, parent); +	if (err) +		return err; + +	at91_aic_hw_init(n_irqs); + +	return 0;  } -#else -#define at91_aic_set_wake	NULL -#endif +int __init at91_aic5_of_init(struct device_node *node, +				     struct device_node *parent) +{ +	int err; -static struct irq_chip at91_aic_chip = { -	.name		= "AIC", -	.ack		= at91_aic_mask_irq, -	.mask		= at91_aic_mask_irq, -	.unmask		= at91_aic_unmask_irq, -	.set_type	= at91_aic_set_type, -	.set_wake	= at91_aic_set_wake, -}; +	at91_aic_caps |= AT91_AIC_CAP_AIC5; +	n_irqs = NR_AIC5_IRQS; +	at91_aic_chip.irq_ack           = at91_aic5_mask_irq; +	at91_aic_chip.irq_mask		= at91_aic5_mask_irq; +	at91_aic_chip.irq_unmask	= at91_aic5_unmask_irq; +	at91_aic_chip.irq_eoi		= at91_aic5_eoi; +	at91_aic_irq_ops.map		= at91_aic5_irq_map; + +	err = at91_aic_of_common_init(node, parent); +	if (err) +		return err; + +	at91_aic5_hw_init(n_irqs); + +	return 0; +} +#endif  /*   * Initialize the AIC interrupt controller.   */ -void __init at91_aic_init(unsigned int priority[NR_AIC_IRQS]) +void __init at91_aic_init(unsigned int *priority, unsigned int ext_irq_mask)  {  	unsigned int i; +	int irq_base; + +	at91_extern_irq = kzalloc(BITS_TO_LONGS(n_irqs) +				  * sizeof(*at91_extern_irq), GFP_KERNEL); + +	if (at91_aic_pm_init() || at91_extern_irq == NULL) +		panic("Unable to allocate bit maps\n"); + +	*at91_extern_irq = ext_irq_mask; + +	at91_aic_base = ioremap(AT91_AIC, 512); +	if (!at91_aic_base) +		panic("Unable to ioremap AIC registers\n"); + +	/* Add irq domain for AIC */ +	irq_base = irq_alloc_descs(-1, 0, n_irqs, 0); +	if (irq_base < 0) { +		WARN(1, "Cannot allocate irq_descs, assuming pre-allocated\n"); +		irq_base = 0; +	} +	at91_aic_domain = irq_domain_add_legacy(at91_aic_np, n_irqs, +						irq_base, 0, +						&irq_domain_simple_ops, NULL); + +	if (!at91_aic_domain) +		panic("Unable to add AIC irq domain\n"); + +	irq_set_default_host(at91_aic_domain);  	/*  	 * The IVR is used by macro get_irqnr_and_base to read and verify.  	 * The irq number is NR_AIC_IRQS when a spurious interrupt has occurred.  	 */ -	for (i = 0; i < NR_AIC_IRQS; i++) { -		/* Put irq number in Source Vector Register: */ -		at91_sys_write(AT91_AIC_SVR(i), i); +	for (i = 0; i < n_irqs; i++) { +		/* Put hardware irq number in Source Vector Register: */ +		at91_aic_write(AT91_AIC_SVR(i), NR_IRQS_LEGACY + i);  		/* Active Low interrupt, with the specified priority */ -		at91_sys_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]); - -		set_irq_chip(i, &at91_aic_chip); -		set_irq_handler(i, handle_level_irq); +		at91_aic_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]); +		irq_set_chip_and_handler(NR_IRQS_LEGACY + i, &at91_aic_chip, handle_fasteoi_irq);  		set_irq_flags(i, IRQF_VALID | IRQF_PROBE); - -		/* Perform 8 End Of Interrupt Command to make sure AIC will not Lock out nIRQ */ -		if (i < 8) -			at91_sys_write(AT91_AIC_EOICR, 0);  	} -	/* -	 * Spurious Interrupt ID in Spurious Vector Register is NR_AIC_IRQS -	 * When there is no current interrupt, the IRQ Vector Register reads the value stored in AIC_SPU -	 */ -	at91_sys_write(AT91_AIC_SPU, NR_AIC_IRQS); - -	/* No debugging in AIC: Debug (Protect) Control Register */ -	at91_sys_write(AT91_AIC_DCR, 0); - -	/* Disable and clear all interrupts initially */ -	at91_sys_write(AT91_AIC_IDCR, 0xFFFFFFFF); -	at91_sys_write(AT91_AIC_ICCR, 0xFFFFFFFF); +	at91_aic_hw_init(n_irqs);  } diff --git a/arch/arm/mach-at91/leds.c b/arch/arm/mach-at91/leds.c index 0415a839e1a..77c4d8fd03f 100644 --- a/arch/arm/mach-at91/leds.c +++ b/arch/arm/mach-at91/leds.c @@ -9,13 +9,14 @@   * 2 of the License, or (at your option) any later version.  */ +#include <linux/gpio.h>  #include <linux/kernel.h>  #include <linux/module.h>  #include <linux/init.h>  #include <linux/platform_device.h> -#include <mach/board.h> -#include <mach/gpio.h> +#include "board.h" +#include "gpio.h"  /* ------------------------------------------------------------------------- */ @@ -90,108 +91,3 @@ void __init at91_pwm_leds(struct gpio_led *leds, int nr)  #else  void __init at91_pwm_leds(struct gpio_led *leds, int nr){}  #endif - - -/* ------------------------------------------------------------------------- */ - -#if defined(CONFIG_LEDS) - -#include <asm/leds.h> - -/* - * Old ARM-specific LED framework; not fully functional when generic time is - * in use. - */ - -static u8 at91_leds_cpu; -static u8 at91_leds_timer; - -static inline void at91_led_on(unsigned int led) -{ -	at91_set_gpio_value(led, 0); -} - -static inline void at91_led_off(unsigned int led) -{ -	at91_set_gpio_value(led, 1); -} - -static inline void at91_led_toggle(unsigned int led) -{ -	unsigned long is_off = at91_get_gpio_value(led); -	if (is_off) -		at91_led_on(led); -	else -		at91_led_off(led); -} - - -/* - * Handle LED events. - */ -static void at91_leds_event(led_event_t evt) -{ -	unsigned long flags; - -	local_irq_save(flags); - -	switch(evt) { -	case led_start:		/* System startup */ -		at91_led_on(at91_leds_cpu); -		break; - -	case led_stop:		/* System stop / suspend */ -		at91_led_off(at91_leds_cpu); -		break; - -#ifdef CONFIG_LEDS_TIMER -	case led_timer:		/* Every 50 timer ticks */ -		at91_led_toggle(at91_leds_timer); -		break; -#endif - -#ifdef CONFIG_LEDS_CPU -	case led_idle_start:	/* Entering idle state */ -		at91_led_off(at91_leds_cpu); -		break; - -	case led_idle_end:	/* Exit idle state */ -		at91_led_on(at91_leds_cpu); -		break; -#endif - -	default: -		break; -	} - -	local_irq_restore(flags); -} - - -static int __init leds_init(void) -{ -	if (!at91_leds_timer || !at91_leds_cpu) -		return -ENODEV; - -	leds_event = at91_leds_event; - -	leds_event(led_start); -	return 0; -} - -__initcall(leds_init); - - -void __init at91_init_leds(u8 cpu_led, u8 timer_led) -{ -	/* Enable GPIO to access the LEDs */ -	at91_set_gpio_output(cpu_led, 1); -	at91_set_gpio_output(timer_led, 1); - -	at91_leds_cpu	= cpu_led; -	at91_leds_timer	= timer_led; -} - -#else -void __init at91_init_leds(u8 cpu_led, u8 timer_led) {} -#endif diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index dafbacc25eb..e9555453298 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -10,6 +10,7 @@   * (at your option) any later version.   */ +#include <linux/gpio.h>  #include <linux/suspend.h>  #include <linux/sched.h>  #include <linux/proc_fs.h> @@ -18,26 +19,29 @@  #include <linux/module.h>  #include <linux/platform_device.h>  #include <linux/io.h> +#include <linux/clk/at91_pmc.h>  #include <asm/irq.h> -#include <asm/atomic.h> +#include <linux/atomic.h>  #include <asm/mach/time.h>  #include <asm/mach/irq.h> -#include <mach/at91_pmc.h> -#include <mach/gpio.h>  #include <mach/cpu.h> +#include <mach/hardware.h> +#include "at91_aic.h"  #include "generic.h"  #include "pm.h" +#include "gpio.h"  /*   * Show the reason for the previous system reset.   */ -#if defined(AT91_SHDWC) -#include <mach/at91_rstc.h> -#include <mach/at91_shdwc.h> +#include "at91_rstc.h" +#include "at91_shdwc.h" + +static void (*at91_pm_standby)(void);  static void __init show_reset_status(void)  { @@ -58,8 +62,11 @@ static void __init show_reset_status(void)  	char *reason, *r2 = reset;  	u32 reset_type, wake_type; -	reset_type = at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_RSTTYP; -	wake_type = at91_sys_read(AT91_SHDW_SR); +	if (!at91_shdwc_base || !at91_rstc_base) +		return; + +	reset_type = at91_rstc_read(AT91_RSTC_SR) & AT91_RSTC_RSTTYP; +	wake_type = at91_shdwc_read(AT91_SHDW_SR);  	switch (reset_type) {  	case AT91_RSTC_RSTTYP_GENERAL: @@ -99,10 +106,6 @@ static void __init show_reset_status(void)  	}  	pr_info("AT91: Starting after %s %s\n", reason, r2);  } -#else -static void __init show_reset_status(void) {} -#endif -  static int at91_pm_valid_state(suspend_state_t state)  { @@ -138,7 +141,7 @@ static int at91_pm_verify_clocks(void)  	unsigned long scsr;  	int i; -	scsr = at91_sys_read(AT91_PMC_SCSR); +	scsr = at91_pmc_read(AT91_PMC_SCSR);  	/* USB must not be using PLLB */  	if (cpu_is_at91rm9200()) { @@ -152,14 +155,8 @@ static int at91_pm_verify_clocks(void)  			pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");  			return 0;  		} -	} else if (cpu_is_at91cap9()) { -		if ((scsr & AT91CAP9_PMC_UHP) != 0) { -			pr_err("AT91: PM - Suspend-to-RAM with USB still active\n"); -			return 0; -		}  	} -#ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS  	/* PCK0..PCK3 must be disabled, or configured to use clk32k */  	for (i = 0; i < 4; i++) {  		u32 css; @@ -167,13 +164,12 @@ static int at91_pm_verify_clocks(void)  		if ((scsr & (AT91_PMC_PCK0 << i)) == 0)  			continue; -		css = at91_sys_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS; +		css = at91_pmc_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS;  		if (css != AT91_PMC_CSS_SLOW) {  			pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css);  			return 0;  		}  	} -#endif  	return 1;  } @@ -195,27 +191,30 @@ int at91_suspend_entering_slow_clock(void)  EXPORT_SYMBOL(at91_suspend_entering_slow_clock); -static void (*slow_clock)(void); +static void (*slow_clock)(void __iomem *pmc, void __iomem *ramc0, +			  void __iomem *ramc1, int memctrl);  #ifdef CONFIG_AT91_SLOW_CLOCK -extern void at91_slow_clock(void); +extern void at91_slow_clock(void __iomem *pmc, void __iomem *ramc0, +			    void __iomem *ramc1, int memctrl);  extern u32 at91_slow_clock_sz;  #endif -  static int at91_pm_enter(suspend_state_t state)  { -	u32 saved_lpr; -	at91_gpio_suspend(); +	if (of_have_populated_dt()) +		at91_pinctrl_gpio_suspend(); +	else +		at91_gpio_suspend();  	at91_irq_suspend();  	pr_debug("AT91: PM - wake mask %08x, pm state %d\n",  			/* remember all the always-wake irqs */ -			(at91_sys_read(AT91_PMC_PCSR) +			(at91_pmc_read(AT91_PMC_PCSR)  					| (1 << AT91_ID_FIQ)  					| (1 << AT91_ID_SYS) -					| (at91_extern_irq)) -				& at91_sys_read(AT91_AIC_IMR), +					| (at91_get_extern_irq())) +				& at91_aic_read(AT91_AIC_IMR),  			state);  	switch (state) { @@ -236,11 +235,18 @@ static int at91_pm_enter(suspend_state_t state)  			 * turning off the main oscillator; reverse on wakeup.  			 */  			if (slow_clock) { +				int memctrl = AT91_MEMCTRL_SDRAMC; + +				if (cpu_is_at91rm9200()) +					memctrl = AT91_MEMCTRL_MC; +				else if (cpu_is_at91sam9g45()) +					memctrl = AT91_MEMCTRL_DDRSDR;  #ifdef CONFIG_AT91_SLOW_CLOCK  				/* copy slow_clock handler to SRAM, and call it */  				memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);  #endif -				slow_clock(); +				slow_clock(at91_pmc_base, at91_ramc_base[0], +					   at91_ramc_base[1], memctrl);  				break;  			} else {  				pr_info("AT91: PM - no slow clock mode enabled ...\n"); @@ -261,16 +267,8 @@ static int at91_pm_enter(suspend_state_t state)  			 * For ARM 926 based chips, this requirement is weaker  			 * as at91sam9 can access a RAM in self-refresh mode.  			 */ -			asm volatile (	"mov r0, #0\n\t" -					"b 1f\n\t" -					".align 5\n\t" -					"1: mcr p15, 0, r0, c7, c10, 4\n\t" -					: /* no output */ -					: /* no input */ -					: "r0"); -			saved_lpr = sdram_selfrefresh_enable(); -			wait_for_interrupt_enable(); -			sdram_selfrefresh_disable(saved_lpr); +			if (at91_pm_standby) +				at91_pm_standby();  			break;  		case PM_SUSPEND_ON: @@ -283,12 +281,15 @@ static int at91_pm_enter(suspend_state_t state)  	}  	pr_debug("AT91: PM - wakeup %08x\n", -			at91_sys_read(AT91_AIC_IPR) & at91_sys_read(AT91_AIC_IMR)); +			at91_aic_read(AT91_AIC_IPR) & at91_aic_read(AT91_AIC_IMR));  error:  	target_state = PM_SUSPEND_ON;  	at91_irq_resume(); -	at91_gpio_resume(); +	if (of_have_populated_dt()) +		at91_pinctrl_gpio_resume(); +	else +		at91_gpio_resume();  	return 0;  } @@ -301,13 +302,25 @@ static void at91_pm_end(void)  } -static struct platform_suspend_ops at91_pm_ops ={ +static const struct platform_suspend_ops at91_pm_ops = {  	.valid	= at91_pm_valid_state,  	.begin	= at91_pm_begin,  	.enter	= at91_pm_enter,  	.end	= at91_pm_end,  }; +static struct platform_device at91_cpuidle_device = { +	.name = "cpuidle-at91", +}; + +void at91_pm_set_standby(void (*at91_standby)(void)) +{ +	if (at91_standby) { +		at91_cpuidle_device.dev.platform_data = at91_standby; +		at91_pm_standby = at91_standby; +	} +} +  static int __init at91_pm_init(void)  {  #ifdef CONFIG_AT91_SLOW_CLOCK @@ -316,10 +329,12 @@ static int __init at91_pm_init(void)  	pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : "")); -#ifdef CONFIG_ARCH_AT91RM9200  	/* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */ -	at91_sys_write(AT91_SDRAMC_LPR, 0); -#endif +	if (cpu_is_at91rm9200()) +		at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0); +	 +	if (at91_cpuidle_device.dev.platform_data) +		platform_device_register(&at91_cpuidle_device);  	suspend_set_ops(&at91_pm_ops); diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h index ce9a2069911..c5101dcb4fb 100644 --- a/arch/arm/mach-at91/pm.h +++ b/arch/arm/mach-at91/pm.h @@ -1,5 +1,26 @@ -#ifdef CONFIG_ARCH_AT91RM9200 -#include <mach/at91rm9200_mc.h> +/* + * AT91 Power Management + * + * Copyright (C) 2005 David Brownell + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#ifndef __ARCH_ARM_MACH_AT91_PM +#define __ARCH_ARM_MACH_AT91_PM + +#include <asm/proc-fns.h> + +#include <mach/at91_ramc.h> +#include <mach/at91rm9200_sdramc.h> + +#ifdef CONFIG_PM +extern void at91_pm_set_standby(void (*at91_standby)(void)); +#else +static inline void at91_pm_set_standby(void (*at91_standby)(void)) { } +#endif  /*   * The AT91RM9200 goes into self-refresh mode with this command, and will @@ -11,55 +32,39 @@   * still in self-refresh is "not recommended", but seems to work.   */ -static inline u32 sdram_selfrefresh_enable(void) +static inline void at91rm9200_standby(void)  { -	u32 saved_lpr = at91_sys_read(AT91_SDRAMC_LPR); - -	at91_sys_write(AT91_SDRAMC_LPR, 0); -	at91_sys_write(AT91_SDRAMC_SRR, 1); -	return saved_lpr; +	u32 lpr = at91_ramc_read(0, AT91RM9200_SDRAMC_LPR); + +	asm volatile( +		"b    1f\n\t" +		".align    5\n\t" +		"1:  mcr    p15, 0, %0, c7, c10, 4\n\t" +		"    str    %0, [%1, %2]\n\t" +		"    str    %3, [%1, %4]\n\t" +		"    mcr    p15, 0, %0, c7, c0, 4\n\t" +		"    str    %5, [%1, %2]" +		: +		: "r" (0), "r" (AT91_BASE_SYS), "r" (AT91RM9200_SDRAMC_LPR), +		  "r" (1), "r" (AT91RM9200_SDRAMC_SRR), +		  "r" (lpr));  } -#define sdram_selfrefresh_disable(saved_lpr)	at91_sys_write(AT91_SDRAMC_LPR, saved_lpr) -#define wait_for_interrupt_enable()		asm volatile ("mcr p15, 0, %0, c7, c0, 4" \ -								: : "r" (0)) - -#elif defined(CONFIG_ARCH_AT91CAP9) -#include <mach/at91cap9_ddrsdr.h> - - -static inline u32 sdram_selfrefresh_enable(void) -{ -	u32 saved_lpr, lpr; - -	saved_lpr = at91_ramc_read(0, AT91_DDRSDRC_LPR); - -	lpr = saved_lpr & ~AT91_DDRSDRC_LPCB; -	at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr | AT91_DDRSDRC_LPCB_SELF_REFRESH); -	return saved_lpr; -} - -#define sdram_selfrefresh_disable(saved_lpr)	at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr) -#define wait_for_interrupt_enable()		cpu_do_idle() - -#elif defined(CONFIG_ARCH_AT91SAM9G45) -#include <mach/at91sam9_ddrsdr.h> -  /* We manage both DDRAM/SDRAM controllers, we need more than one value to   * remember.   */ -static u32 saved_lpr1; - -static inline u32 sdram_selfrefresh_enable(void) +static inline void at91_ddr_standby(void)  { -	/* Those tow values allow us to delay self-refresh activation +	/* Those two values allow us to delay self-refresh activation  	 * to the maximum. */ -	u32 lpr0, lpr1; -	u32 saved_lpr0; +	u32 lpr0, lpr1 = 0; +	u32 saved_lpr0, saved_lpr1 = 0; -	saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR); -	lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB; -	lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH; +	if (at91_ramc_base[1]) { +		saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR); +		lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB; +		lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH; +	}  	saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);  	lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB; @@ -67,41 +72,44 @@ static inline u32 sdram_selfrefresh_enable(void)  	/* self-refresh mode now */  	at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0); -	at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1); +	if (at91_ramc_base[1]) +		at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1); -	return saved_lpr0; +	cpu_do_idle(); + +	at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); +	if (at91_ramc_base[1]) +		at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);  } -#define sdram_selfrefresh_disable(saved_lpr0)	\ -	do { \ -		at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); \ -		at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); \ -	} while (0) -#define wait_for_interrupt_enable()		cpu_do_idle() +/* We manage both DDRAM/SDRAM controllers, we need more than one value to + * remember. + */ +static inline void at91sam9_sdram_standby(void) +{ +	u32 lpr0, lpr1 = 0; +	u32 saved_lpr0, saved_lpr1 = 0; -#else -#include <mach/at91sam9_sdramc.h> +	if (at91_ramc_base[1]) { +		saved_lpr1 = at91_ramc_read(1, AT91_SDRAMC_LPR); +		lpr1 = saved_lpr1 & ~AT91_SDRAMC_LPCB; +		lpr1 |= AT91_SDRAMC_LPCB_SELF_REFRESH; +	} -#ifdef CONFIG_ARCH_AT91SAM9263 -/* - * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use; - * handle those cases both here and in the Suspend-To-RAM support. - */ -#warning Assuming EB1 SDRAM controller is *NOT* used -#endif +	saved_lpr0 = at91_ramc_read(0, AT91_SDRAMC_LPR); +	lpr0 = saved_lpr0 & ~AT91_SDRAMC_LPCB; +	lpr0 |= AT91_SDRAMC_LPCB_SELF_REFRESH; -static inline u32 sdram_selfrefresh_enable(void) -{ -	u32 saved_lpr, lpr; +	/* self-refresh mode now */ +	at91_ramc_write(0, AT91_SDRAMC_LPR, lpr0); +	if (at91_ramc_base[1]) +		at91_ramc_write(1, AT91_SDRAMC_LPR, lpr1); -	saved_lpr = at91_ramc_read(0, AT91_SDRAMC_LPR); +	cpu_do_idle(); -	lpr = saved_lpr & ~AT91_SDRAMC_LPCB; -	at91_ramc_write(0, AT91_SDRAMC_LPR, lpr | AT91_SDRAMC_LPCB_SELF_REFRESH); -	return saved_lpr; +	at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr0); +	if (at91_ramc_base[1]) +		at91_ramc_write(1, AT91_SDRAMC_LPR, saved_lpr1);  } -#define sdram_selfrefresh_disable(saved_lpr)	at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr) -#define wait_for_interrupt_enable()		cpu_do_idle() -  #endif diff --git a/arch/arm/mach-at91/pm_slowclock.S b/arch/arm/mach-at91/pm_slowclock.S index f7922a43617..20018779bae 100644 --- a/arch/arm/mach-at91/pm_slowclock.S +++ b/arch/arm/mach-at91/pm_slowclock.S @@ -13,21 +13,12 @@   */  #include <linux/linkage.h> +#include <linux/clk/at91_pmc.h>  #include <mach/hardware.h> -#include <mach/at91_pmc.h> - -#if defined(CONFIG_ARCH_AT91RM9200) -#include <mach/at91rm9200_mc.h> -#elif defined(CONFIG_ARCH_AT91CAP9) -#include <mach/at91cap9_ddrsdr.h> -#elif defined(CONFIG_ARCH_AT91SAM9G45) -#include <mach/at91sam9_ddrsdr.h> -#else -#include <mach/at91sam9_sdramc.h> -#endif +#include <mach/at91_ramc.h> -#ifdef CONFIG_ARCH_AT91SAM9263 +#ifdef CONFIG_SOC_AT91SAM9263  /*   * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;   * handle those cases both here and in the Suspend-To-RAM support. @@ -48,17 +39,23 @@  #define PLLALOCK_TIMEOUT	1000  #define PLLBLOCK_TIMEOUT	1000 +pmc	.req	r0 +sdramc	.req	r1 +ramc1	.req	r2 +memctrl	.req	r3 +tmp1	.req	r4 +tmp2	.req	r5  /*   * Wait until master clock is ready (after switching master clock source)   */  	.macro wait_mckrdy -	mov	r4, #MCKRDY_TIMEOUT -1:	sub	r4, r4, #1 -	cmp	r4, #0 +	mov	tmp2, #MCKRDY_TIMEOUT +1:	sub	tmp2, tmp2, #1 +	cmp	tmp2, #0  	beq	2f -	ldr	r3, [r1, #(AT91_PMC_SR - AT91_PMC)] -	tst	r3, #AT91_PMC_MCKRDY +	ldr	tmp1, [pmc, #AT91_PMC_SR] +	tst	tmp1, #AT91_PMC_MCKRDY  	beq	1b  2:  	.endm @@ -67,12 +64,12 @@   * Wait until master oscillator has stabilized.   */  	.macro wait_moscrdy -	mov	r4, #MOSCRDY_TIMEOUT -1:	sub	r4, r4, #1 -	cmp	r4, #0 +	mov	tmp2, #MOSCRDY_TIMEOUT +1:	sub	tmp2, tmp2, #1 +	cmp	tmp2, #0  	beq	2f -	ldr	r3, [r1, #(AT91_PMC_SR - AT91_PMC)] -	tst	r3, #AT91_PMC_MOSCS +	ldr	tmp1, [pmc, #AT91_PMC_SR] +	tst	tmp1, #AT91_PMC_MOSCS  	beq	1b  2:  	.endm @@ -81,12 +78,12 @@   * Wait until PLLA has locked.   */  	.macro wait_pllalock -	mov	r4, #PLLALOCK_TIMEOUT -1:	sub	r4, r4, #1 -	cmp	r4, #0 +	mov	tmp2, #PLLALOCK_TIMEOUT +1:	sub	tmp2, tmp2, #1 +	cmp	tmp2, #0  	beq	2f -	ldr	r3, [r1, #(AT91_PMC_SR - AT91_PMC)] -	tst	r3, #AT91_PMC_LOCKA +	ldr	tmp1, [pmc, #AT91_PMC_SR] +	tst	tmp1, #AT91_PMC_LOCKA  	beq	1b  2:  	.endm @@ -95,80 +92,98 @@   * Wait until PLLB has locked.   */  	.macro wait_pllblock -	mov	r4, #PLLBLOCK_TIMEOUT -1:	sub	r4, r4, #1 -	cmp	r4, #0 +	mov	tmp2, #PLLBLOCK_TIMEOUT +1:	sub	tmp2, tmp2, #1 +	cmp	tmp2, #0  	beq	2f -	ldr	r3, [r1, #(AT91_PMC_SR - AT91_PMC)] -	tst	r3, #AT91_PMC_LOCKB +	ldr	tmp1, [pmc, #AT91_PMC_SR] +	tst	tmp1, #AT91_PMC_LOCKB  	beq	1b  2:  	.endm  	.text +/* void at91_slow_clock(void __iomem *pmc, void __iomem *sdramc, + *			void __iomem *ramc1, int memctrl) + */  ENTRY(at91_slow_clock)  	/* Save registers on stack */ -	stmfd	sp!, {r0 - r12, lr} +	stmfd	sp!, {r4 - r12, lr}  	/*  	 * Register usage: -	 *  R1 = Base address of AT91_PMC -	 *  R2 = Base address of RAM Controller (SDRAM, DDRSDR, or AT91_SYS) -	 *  R3 = temporary register +	 *  R0 = Base address of AT91_PMC +	 *  R1 = Base address of RAM Controller (SDRAM, DDRSDR, or AT91_SYS) +	 *  R2 = Base address of second RAM Controller or 0 if not present +	 *  R3 = Memory controller  	 *  R4 = temporary register -	 *  R5 = Base address of second RAM Controller or 0 if not present +	 *  R5 = temporary register  	 */ -	ldr	r1, .at91_va_base_pmc -	ldr	r2, .at91_va_base_sdramc -	ldr	r5, .at91_va_base_ramc1  	/* Drain write buffer */ -	mov	r0, #0 -	mcr	p15, 0, r0, c7, c10, 4 +	mov	tmp1, #0 +	mcr	p15, 0, tmp1, c7, c10, 4 -#ifdef CONFIG_ARCH_AT91RM9200 +	cmp	memctrl, #AT91_MEMCTRL_MC +	bne	ddr_sr_enable + +	/* +	 * at91rm9200 Memory controller +	 */  	/* Put SDRAM in self-refresh mode */ -	mov	r3, #1 -	str	r3, [r2, #AT91_SDRAMC_SRR] -#elif defined(CONFIG_ARCH_AT91CAP9) \ -	|| defined(CONFIG_ARCH_AT91SAM9G45) +	mov	tmp1, #1 +	str	tmp1, [sdramc, #AT91RM9200_SDRAMC_SRR] +	b	sdr_sr_done + +	/* +	 * DDRSDR Memory controller +	 */ +ddr_sr_enable: +	cmp	memctrl, #AT91_MEMCTRL_DDRSDR +	bne	sdr_sr_enable  	/* prepare for DDRAM self-refresh mode */ -	ldr	r3, [r2, #AT91_DDRSDRC_LPR] -	str	r3, .saved_sam9_lpr -	bic	r3, #AT91_DDRSDRC_LPCB -	orr	r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH +	ldr	tmp1, [sdramc, #AT91_DDRSDRC_LPR] +	str	tmp1, .saved_sam9_lpr +	bic	tmp1, #AT91_DDRSDRC_LPCB +	orr	tmp1, #AT91_DDRSDRC_LPCB_SELF_REFRESH  	/* figure out if we use the second ram controller */ -	cmp	r5, #0 -	ldrne	r4, [r5, #AT91_DDRSDRC_LPR] -	strne	r4, .saved_sam9_lpr1 -	bicne	r4, #AT91_DDRSDRC_LPCB -	orrne	r4, #AT91_DDRSDRC_LPCB_SELF_REFRESH +	cmp	ramc1, #0 +	ldrne	tmp2, [ramc1, #AT91_DDRSDRC_LPR] +	strne	tmp2, .saved_sam9_lpr1 +	bicne	tmp2, #AT91_DDRSDRC_LPCB +	orrne	tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH  	/* Enable DDRAM self-refresh mode */ -	str	r3, [r2, #AT91_DDRSDRC_LPR] -	strne	r4, [r5, #AT91_DDRSDRC_LPR] -#else +	str	tmp1, [sdramc, #AT91_DDRSDRC_LPR] +	strne	tmp2, [ramc1, #AT91_DDRSDRC_LPR] + +	b	sdr_sr_done + +	/* +	 * SDRAMC Memory controller +	 */ +sdr_sr_enable:  	/* Enable SDRAM self-refresh mode */ -	ldr	r3, [r2, #AT91_SDRAMC_LPR] -	str	r3, .saved_sam9_lpr +	ldr	tmp1, [sdramc, #AT91_SDRAMC_LPR] +	str	tmp1, .saved_sam9_lpr -	bic	r3, #AT91_SDRAMC_LPCB -	orr	r3, #AT91_SDRAMC_LPCB_SELF_REFRESH -	str	r3, [r2, #AT91_SDRAMC_LPR] -#endif +	bic	tmp1, #AT91_SDRAMC_LPCB +	orr	tmp1, #AT91_SDRAMC_LPCB_SELF_REFRESH +	str	tmp1, [sdramc, #AT91_SDRAMC_LPR] +sdr_sr_done:  	/* Save Master clock setting */ -	ldr	r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] -	str	r3, .saved_mckr +	ldr	tmp1, [pmc, #AT91_PMC_MCKR] +	str	tmp1, .saved_mckr  	/*  	 * Set the Master clock source to slow clock  	 */ -	bic	r3, r3, #AT91_PMC_CSS -	str	r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] +	bic	tmp1, tmp1, #AT91_PMC_CSS +	str	tmp1, [pmc, #AT91_PMC_MCKR]  	wait_mckrdy @@ -178,61 +193,61 @@ ENTRY(at91_slow_clock)  	 *  	 * See AT91RM9200 errata #27 and #28 for details.  	 */ -	mov	r3, #0 -	str	r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] +	mov	tmp1, #0 +	str	tmp1, [pmc, #AT91_PMC_MCKR]  	wait_mckrdy  #endif  	/* Save PLLA setting and disable it */ -	ldr	r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)] -	str	r3, .saved_pllar +	ldr	tmp1, [pmc, #AT91_CKGR_PLLAR] +	str	tmp1, .saved_pllar -	mov	r3, #AT91_PMC_PLLCOUNT -	orr	r3, r3, #(1 << 29)		/* bit 29 always set */ -	str	r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)] +	mov	tmp1, #AT91_PMC_PLLCOUNT +	orr	tmp1, tmp1, #(1 << 29)		/* bit 29 always set */ +	str	tmp1, [pmc, #AT91_CKGR_PLLAR]  	/* Save PLLB setting and disable it */ -	ldr	r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)] -	str	r3, .saved_pllbr +	ldr	tmp1, [pmc, #AT91_CKGR_PLLBR] +	str	tmp1, .saved_pllbr -	mov	r3, #AT91_PMC_PLLCOUNT -	str	r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)] +	mov	tmp1, #AT91_PMC_PLLCOUNT +	str	tmp1, [pmc, #AT91_CKGR_PLLBR]  	/* Turn off the main oscillator */ -	ldr	r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] -	bic	r3, r3, #AT91_PMC_MOSCEN -	str	r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] +	ldr	tmp1, [pmc, #AT91_CKGR_MOR] +	bic	tmp1, tmp1, #AT91_PMC_MOSCEN +	str	tmp1, [pmc, #AT91_CKGR_MOR]  	/* Wait for interrupt */ -	mcr	p15, 0, r0, c7, c0, 4 +	mcr	p15, 0, tmp1, c7, c0, 4  	/* Turn on the main oscillator */ -	ldr	r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] -	orr	r3, r3, #AT91_PMC_MOSCEN -	str	r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] +	ldr	tmp1, [pmc, #AT91_CKGR_MOR] +	orr	tmp1, tmp1, #AT91_PMC_MOSCEN +	str	tmp1, [pmc, #AT91_CKGR_MOR]  	wait_moscrdy  	/* Restore PLLB setting */ -	ldr	r3, .saved_pllbr -	str	r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)] +	ldr	tmp1, .saved_pllbr +	str	tmp1, [pmc, #AT91_CKGR_PLLBR] -	tst	r3, #(AT91_PMC_MUL &  0xff0000) +	tst	tmp1, #(AT91_PMC_MUL &  0xff0000)  	bne	1f -	tst	r3, #(AT91_PMC_MUL & ~0xff0000) +	tst	tmp1, #(AT91_PMC_MUL & ~0xff0000)  	beq	2f  1:  	wait_pllblock  2:  	/* Restore PLLA setting */ -	ldr	r3, .saved_pllar -	str	r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)] +	ldr	tmp1, .saved_pllar +	str	tmp1, [pmc, #AT91_CKGR_PLLAR] -	tst	r3, #(AT91_PMC_MUL &  0xff0000) +	tst	tmp1, #(AT91_PMC_MUL &  0xff0000)  	bne	3f -	tst	r3, #(AT91_PMC_MUL & ~0xff0000) +	tst	tmp1, #(AT91_PMC_MUL & ~0xff0000)  	beq	4f  3:  	wait_pllalock @@ -245,11 +260,11 @@ ENTRY(at91_slow_clock)  	 *  	 * See AT91RM9200 errata #27 and #28 for details.  	 */ -	ldr	r3, .saved_mckr -	tst	r3, #AT91_PMC_PRES +	ldr	tmp1, .saved_mckr +	tst	tmp1, #AT91_PMC_PRES  	beq	2f -	and	r3, r3, #AT91_PMC_PRES -	str	r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] +	and	tmp1, tmp1, #AT91_PMC_PRES +	str	tmp1, [pmc, #AT91_PMC_MCKR]  	wait_mckrdy  #endif @@ -257,32 +272,45 @@ ENTRY(at91_slow_clock)  	/*  	 * Restore master clock setting  	 */ -2:	ldr	r3, .saved_mckr -	str	r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] +2:	ldr	tmp1, .saved_mckr +	str	tmp1, [pmc, #AT91_PMC_MCKR]  	wait_mckrdy -#ifdef CONFIG_ARCH_AT91RM9200 -	/* Do nothing - self-refresh is automatically disabled. */ -#elif defined(CONFIG_ARCH_AT91CAP9) \ -	|| defined(CONFIG_ARCH_AT91SAM9G45) +	/* +	 * at91rm9200 Memory controller +	 * Do nothing - self-refresh is automatically disabled. +	 */ +	cmp	memctrl, #AT91_MEMCTRL_MC +	beq	ram_restored + +	/* +	 * DDRSDR Memory controller +	 */ +	cmp	memctrl, #AT91_MEMCTRL_DDRSDR +	bne	sdr_en_restore  	/* Restore LPR on AT91 with DDRAM */ -	ldr	r3, .saved_sam9_lpr -	str	r3, [r2, #AT91_DDRSDRC_LPR] +	ldr	tmp1, .saved_sam9_lpr +	str	tmp1, [sdramc, #AT91_DDRSDRC_LPR]  	/* if we use the second ram controller */ -	cmp	r5, #0 -	ldrne	r4, .saved_sam9_lpr1 -	strne	r4, [r5, #AT91_DDRSDRC_LPR] +	cmp	ramc1, #0 +	ldrne	tmp2, .saved_sam9_lpr1 +	strne	tmp2, [ramc1, #AT91_DDRSDRC_LPR] -#else +	b	ram_restored + +	/* +	 * SDRAMC Memory controller +	 */ +sdr_en_restore:  	/* Restore LPR on AT91 with SDRAM */ -	ldr	r3, .saved_sam9_lpr -	str	r3, [r2, #AT91_SDRAMC_LPR] -#endif +	ldr	tmp1, .saved_sam9_lpr +	str	tmp1, [sdramc, #AT91_SDRAMC_LPR] +ram_restored:  	/* Restore registers, and return */ -	ldmfd	sp!, {r0 - r12, pc} +	ldmfd	sp!, {r4 - r12, pc}  .saved_mckr: @@ -300,27 +328,5 @@ ENTRY(at91_slow_clock)  .saved_sam9_lpr1:  	.word 0 -.at91_va_base_pmc: -	.word AT91_VA_BASE_SYS + AT91_PMC - -#ifdef CONFIG_ARCH_AT91RM9200 -.at91_va_base_sdramc: -	.word AT91_VA_BASE_SYS -#elif defined(CONFIG_ARCH_AT91CAP9) \ -	|| defined(CONFIG_ARCH_AT91SAM9G45) -.at91_va_base_sdramc: -	.word AT91_VA_BASE_SYS + AT91_DDRSDRC0 -#else -.at91_va_base_sdramc: -	.word AT91_VA_BASE_SYS + AT91_SDRAMC0 -#endif - -.at91_va_base_ramc1: -#if defined(CONFIG_ARCH_AT91SAM9G45) -	.word AT91_VA_BASE_SYS + AT91_DDRSDRC1 -#else -	.word 0 -#endif -  ENTRY(at91_slow_clock_sz)  	.word .-at91_slow_clock diff --git a/arch/arm/mach-at91/sam9_smc.c b/arch/arm/mach-at91/sam9_smc.c index 5eab6aa621d..826315af6d1 100644 --- a/arch/arm/mach-at91/sam9_smc.c +++ b/arch/arm/mach-at91/sam9_smc.c @@ -2,6 +2,7 @@   * linux/arch/arm/mach-at91/sam9_smc.c   *   * Copyright (C) 2008 Andrew Victor + * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>   *   * This program is free software; you can redistribute it and/or modify   * it under the terms of the GNU General Public License version 2 as @@ -10,38 +11,126 @@  #include <linux/module.h>  #include <linux/io.h> +#include <linux/of.h> +#include <linux/of_address.h>  #include <mach/at91sam9_smc.h>  #include "sam9_smc.h" -void __init sam9_smc_configure(int cs, struct sam9_smc_config* config) + +#define AT91_SMC_CS(id, n)	(smc_base_addr[id] + ((n) * 0x10)) + +static void __iomem *smc_base_addr[2]; + +static void sam9_smc_cs_write_mode(void __iomem *base, +					struct sam9_smc_config *config) +{ +	__raw_writel(config->mode +		   | AT91_SMC_TDF_(config->tdf_cycles), +		   base + AT91_SMC_MODE); +} + +void sam9_smc_write_mode(int id, int cs, +					struct sam9_smc_config *config) +{ +	sam9_smc_cs_write_mode(AT91_SMC_CS(id, cs), config); +} +EXPORT_SYMBOL_GPL(sam9_smc_write_mode); + +static void sam9_smc_cs_configure(void __iomem *base, +					struct sam9_smc_config *config) +{ + +	/* Setup register */ +	__raw_writel(AT91_SMC_NWESETUP_(config->nwe_setup) +		   | AT91_SMC_NCS_WRSETUP_(config->ncs_write_setup) +		   | AT91_SMC_NRDSETUP_(config->nrd_setup) +		   | AT91_SMC_NCS_RDSETUP_(config->ncs_read_setup), +		   base + AT91_SMC_SETUP); + +	/* Pulse register */ +	__raw_writel(AT91_SMC_NWEPULSE_(config->nwe_pulse) +		   | AT91_SMC_NCS_WRPULSE_(config->ncs_write_pulse) +		   | AT91_SMC_NRDPULSE_(config->nrd_pulse) +		   | AT91_SMC_NCS_RDPULSE_(config->ncs_read_pulse), +		   base + AT91_SMC_PULSE); + +	/* Cycle register */ +	__raw_writel(AT91_SMC_NWECYCLE_(config->write_cycle) +		   | AT91_SMC_NRDCYCLE_(config->read_cycle), +		   base + AT91_SMC_CYCLE); + +	/* Mode register */ +	sam9_smc_cs_write_mode(base, config); +} + +void sam9_smc_configure(int id, int cs, +					struct sam9_smc_config *config)  { +	sam9_smc_cs_configure(AT91_SMC_CS(id, cs), config); +} +EXPORT_SYMBOL_GPL(sam9_smc_configure); + +static void sam9_smc_cs_read_mode(void __iomem *base, +					struct sam9_smc_config *config) +{ +	u32 val = __raw_readl(base + AT91_SMC_MODE); + +	config->mode = (val & ~AT91_SMC_NWECYCLE); +	config->tdf_cycles = (val & AT91_SMC_NWECYCLE) >> 16 ; +} + +void sam9_smc_read_mode(int id, int cs, +					struct sam9_smc_config *config) +{ +	sam9_smc_cs_read_mode(AT91_SMC_CS(id, cs), config); +} +EXPORT_SYMBOL_GPL(sam9_smc_read_mode); + +static void sam9_smc_cs_read(void __iomem *base, +					struct sam9_smc_config *config) +{ +	u32 val; +  	/* Setup register */ -	at91_sys_write(AT91_SMC_SETUP(cs), -		  AT91_SMC_NWESETUP_(config->nwe_setup) -		| AT91_SMC_NCS_WRSETUP_(config->ncs_write_setup) -		| AT91_SMC_NRDSETUP_(config->nrd_setup) -		| AT91_SMC_NCS_RDSETUP_(config->ncs_read_setup) -	); +	val = __raw_readl(base + AT91_SMC_SETUP); + +	config->nwe_setup = val & AT91_SMC_NWESETUP; +	config->ncs_write_setup = (val & AT91_SMC_NCS_WRSETUP) >> 8; +	config->nrd_setup = (val & AT91_SMC_NRDSETUP) >> 16; +	config->ncs_read_setup = (val & AT91_SMC_NCS_RDSETUP) >> 24;  	/* Pulse register */ -	at91_sys_write(AT91_SMC_PULSE(cs), -		  AT91_SMC_NWEPULSE_(config->nwe_pulse) -		| AT91_SMC_NCS_WRPULSE_(config->ncs_write_pulse) -                | AT91_SMC_NRDPULSE_(config->nrd_pulse) -		| AT91_SMC_NCS_RDPULSE_(config->ncs_read_pulse) -	); +	val = __raw_readl(base + AT91_SMC_PULSE); + +	config->nwe_pulse = val & AT91_SMC_NWEPULSE; +	config->ncs_write_pulse = (val & AT91_SMC_NCS_WRPULSE) >> 8; +	config->nrd_pulse = (val & AT91_SMC_NRDPULSE) >> 16; +	config->ncs_read_pulse = (val & AT91_SMC_NCS_RDPULSE) >> 24;  	/* Cycle register */ -	at91_sys_write(AT91_SMC_CYCLE(cs), -		  AT91_SMC_NWECYCLE_(config->write_cycle) -		| AT91_SMC_NRDCYCLE_(config->read_cycle) -	); +	val = __raw_readl(base + AT91_SMC_CYCLE); + +	config->write_cycle = val & AT91_SMC_NWECYCLE; +	config->read_cycle = (val & AT91_SMC_NRDCYCLE) >> 16;  	/* Mode register */ -	at91_sys_write(AT91_SMC_MODE(cs), -		  config->mode -		| AT91_SMC_TDF_(config->tdf_cycles) -	); +	sam9_smc_cs_read_mode(base, config); +} + +void sam9_smc_read(int id, int cs, struct sam9_smc_config *config) +{ +	sam9_smc_cs_read(AT91_SMC_CS(id, cs), config); +} + +void __init at91sam9_ioremap_smc(int id, u32 addr) +{ +	if (id > 1) { +		pr_warn("%s: id > 2\n", __func__); +		return; +	} +	smc_base_addr[id] = ioremap(addr, 512); +	if (!smc_base_addr[id]) +		pr_warn("Impossible to ioremap smc.%d 0x%x\n", id, addr);  } diff --git a/arch/arm/mach-at91/sam9_smc.h b/arch/arm/mach-at91/sam9_smc.h index bf72cfb3455..3e52dcd4a59 100644 --- a/arch/arm/mach-at91/sam9_smc.h +++ b/arch/arm/mach-at91/sam9_smc.h @@ -8,26 +8,4 @@   * published by the Free Software Foundation.   */ -struct sam9_smc_config { -	/* Setup register */ -	u8 ncs_read_setup; -	u8 nrd_setup; -	u8 ncs_write_setup; -	u8 nwe_setup; - -	/* Pulse register */ -	u8 ncs_read_pulse; -	u8 nrd_pulse; -	u8 ncs_write_pulse; -	u8 nwe_pulse; - -	/* Cycle register */ -	u16 read_cycle; -	u16 write_cycle; - -	/* Mode register */ -	u32 mode; -	u8 tdf_cycles:4; -}; - -extern void __init sam9_smc_configure(int cs, struct sam9_smc_config* config); +extern void __init at91sam9_ioremap_smc(int id, u32 addr); diff --git a/arch/arm/mach-at91/sama5d3.c b/arch/arm/mach-at91/sama5d3.c new file mode 100644 index 00000000000..3d775d08de0 --- /dev/null +++ b/arch/arm/mach-at91/sama5d3.c @@ -0,0 +1,41 @@ +/* + *  Chip-specific setup code for the SAMA5D3 family + * + *  Copyright (C) 2013 Atmel, + *                2013 Ludovic Desroches <ludovic.desroches@atmel.com> + * + * Licensed under GPLv2 or later. + */ + +#include <linux/module.h> +#include <linux/dma-mapping.h> +#include <linux/clk/at91_pmc.h> + +#include <asm/irq.h> +#include <asm/mach/arch.h> +#include <asm/mach/map.h> +#include <mach/sama5d3.h> +#include <mach/cpu.h> + +#include "soc.h" +#include "generic.h" +#include "sam9_smc.h" + +/* -------------------------------------------------------------------- + *  AT91SAM9x5 processor initialization + * -------------------------------------------------------------------- */ + +static void __init sama5d3_map_io(void) +{ +	at91_init_sram(0, SAMA5D3_SRAM_BASE, SAMA5D3_SRAM_SIZE); +} + +static void __init sama5d3_initialize(void) +{ +	at91_sysirq_mask_rtc(SAMA5D3_BASE_RTC); +} + +AT91_SOC_START(sama5d3) +	.map_io = sama5d3_map_io, +	.init = sama5d3_initialize, +AT91_SOC_END diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c new file mode 100644 index 00000000000..f7a07a58ebb --- /dev/null +++ b/arch/arm/mach-at91/setup.c @@ -0,0 +1,535 @@ +/* + * Copyright (C) 2007 Atmel Corporation. + * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> + * + * Under GPLv2 + */ + +#include <linux/module.h> +#include <linux/io.h> +#include <linux/mm.h> +#include <linux/pm.h> +#include <linux/of_address.h> +#include <linux/pinctrl/machine.h> +#include <linux/clk/at91_pmc.h> + +#include <asm/system_misc.h> +#include <asm/mach/map.h> + +#include <mach/hardware.h> +#include <mach/cpu.h> +#include <mach/at91_dbgu.h> + +#include "at91_shdwc.h" +#include "soc.h" +#include "generic.h" +#include "pm.h" + +struct at91_init_soc __initdata at91_boot_soc; + +struct at91_socinfo at91_soc_initdata; +EXPORT_SYMBOL(at91_soc_initdata); + +void __init at91rm9200_set_type(int type) +{ +	if (type == ARCH_REVISON_9200_PQFP) +		at91_soc_initdata.subtype = AT91_SOC_RM9200_PQFP; +	else +		at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA; + +	pr_info("AT91: filled in soc subtype: %s\n", +		at91_get_soc_subtype(&at91_soc_initdata)); +} + +void __init at91_init_irq_default(void) +{ +	at91_init_interrupts(at91_boot_soc.default_irq_priority); +} + +void __init at91_init_interrupts(unsigned int *priority) +{ +	/* Initialize the AIC interrupt controller */ +	at91_aic_init(priority, at91_boot_soc.extern_irq); + +	/* Enable GPIO interrupts */ +	at91_gpio_irq_setup(); +} + +void __iomem *at91_ramc_base[2]; +EXPORT_SYMBOL_GPL(at91_ramc_base); + +void __init at91_ioremap_ramc(int id, u32 addr, u32 size) +{ +	if (id < 0 || id > 1) { +		pr_emerg("Wrong RAM controller id (%d), cannot continue\n", id); +		BUG(); +	} +	at91_ramc_base[id] = ioremap(addr, size); +	if (!at91_ramc_base[id]) +		panic("Impossible to ioremap ramc.%d 0x%x\n", id, addr); +} + +static struct map_desc sram_desc[2] __initdata; + +void __init at91_init_sram(int bank, unsigned long base, unsigned int length) +{ +	struct map_desc *desc = &sram_desc[bank]; + +	desc->virtual = (unsigned long)AT91_IO_VIRT_BASE - length; +	if (bank > 0) +		desc->virtual -= sram_desc[bank - 1].length; + +	desc->pfn = __phys_to_pfn(base); +	desc->length = length; +	desc->type = MT_MEMORY_RWX_NONCACHED; + +	pr_info("AT91: sram at 0x%lx of 0x%x mapped at 0x%lx\n", +		base, length, desc->virtual); + +	iotable_init(desc, 1); +} + +static struct map_desc at91_io_desc __initdata __maybe_unused = { +	.virtual	= (unsigned long)AT91_VA_BASE_SYS, +	.pfn		= __phys_to_pfn(AT91_BASE_SYS), +	.length		= SZ_16K, +	.type		= MT_DEVICE, +}; + +static void __init soc_detect(u32 dbgu_base) +{ +	u32 cidr, socid; + +	cidr = __raw_readl(AT91_IO_P2V(dbgu_base) + AT91_DBGU_CIDR); +	socid = cidr & ~AT91_CIDR_VERSION; + +	switch (socid) { +	case ARCH_ID_AT91RM9200: +		at91_soc_initdata.type = AT91_SOC_RM9200; +		if (at91_soc_initdata.subtype == AT91_SOC_SUBTYPE_UNKNOWN) +			at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA; +		at91_boot_soc = at91rm9200_soc; +		break; + +	case ARCH_ID_AT91SAM9260: +		at91_soc_initdata.type = AT91_SOC_SAM9260; +		at91_soc_initdata.subtype = AT91_SOC_SUBTYPE_NONE; +		at91_boot_soc = at91sam9260_soc; +		break; + +	case ARCH_ID_AT91SAM9261: +		at91_soc_initdata.type = AT91_SOC_SAM9261; +		at91_soc_initdata.subtype = AT91_SOC_SUBTYPE_NONE; +		at91_boot_soc = at91sam9261_soc; +		break; + +	case ARCH_ID_AT91SAM9263: +		at91_soc_initdata.type = AT91_SOC_SAM9263; +		at91_soc_initdata.subtype = AT91_SOC_SUBTYPE_NONE; +		at91_boot_soc = at91sam9263_soc; +		break; + +	case ARCH_ID_AT91SAM9G20: +		at91_soc_initdata.type = AT91_SOC_SAM9G20; +		at91_soc_initdata.subtype = AT91_SOC_SUBTYPE_NONE; +		at91_boot_soc = at91sam9260_soc; +		break; + +	case ARCH_ID_AT91SAM9G45: +		at91_soc_initdata.type = AT91_SOC_SAM9G45; +		if (cidr == ARCH_ID_AT91SAM9G45ES) +			at91_soc_initdata.subtype = AT91_SOC_SAM9G45ES; +		at91_boot_soc = at91sam9g45_soc; +		break; + +	case ARCH_ID_AT91SAM9RL64: +		at91_soc_initdata.type = AT91_SOC_SAM9RL; +		at91_soc_initdata.subtype = AT91_SOC_SUBTYPE_NONE; +		at91_boot_soc = at91sam9rl_soc; +		break; + +	case ARCH_ID_AT91SAM9X5: +		at91_soc_initdata.type = AT91_SOC_SAM9X5; +		at91_boot_soc = at91sam9x5_soc; +		break; + +	case ARCH_ID_AT91SAM9N12: +		at91_soc_initdata.type = AT91_SOC_SAM9N12; +		at91_boot_soc = at91sam9n12_soc; +		break; + +	case ARCH_ID_SAMA5D3: +		at91_soc_initdata.type = AT91_SOC_SAMA5D3; +		at91_boot_soc = sama5d3_soc; +		break; +	} + +	/* at91sam9g10 */ +	if ((socid & ~AT91_CIDR_EXT) == ARCH_ID_AT91SAM9G10) { +		at91_soc_initdata.type = AT91_SOC_SAM9G10; +		at91_soc_initdata.subtype = AT91_SOC_SUBTYPE_NONE; +		at91_boot_soc = at91sam9261_soc; +	} +	/* at91sam9xe */ +	else if ((cidr & AT91_CIDR_ARCH) == ARCH_FAMILY_AT91SAM9XE) { +		at91_soc_initdata.type = AT91_SOC_SAM9260; +		at91_soc_initdata.subtype = AT91_SOC_SAM9XE; +		at91_boot_soc = at91sam9260_soc; +	} + +	if (!at91_soc_is_detected()) +		return; + +	at91_soc_initdata.cidr = cidr; + +	/* sub version of soc */ +	at91_soc_initdata.exid = __raw_readl(AT91_IO_P2V(dbgu_base) + AT91_DBGU_EXID); + +	if (at91_soc_initdata.type == AT91_SOC_SAM9G45) { +		switch (at91_soc_initdata.exid) { +		case ARCH_EXID_AT91SAM9M10: +			at91_soc_initdata.subtype = AT91_SOC_SAM9M10; +			break; +		case ARCH_EXID_AT91SAM9G46: +			at91_soc_initdata.subtype = AT91_SOC_SAM9G46; +			break; +		case ARCH_EXID_AT91SAM9M11: +			at91_soc_initdata.subtype = AT91_SOC_SAM9M11; +			break; +		} +	} + +	if (at91_soc_initdata.type == AT91_SOC_SAM9X5) { +		switch (at91_soc_initdata.exid) { +		case ARCH_EXID_AT91SAM9G15: +			at91_soc_initdata.subtype = AT91_SOC_SAM9G15; +			break; +		case ARCH_EXID_AT91SAM9G35: +			at91_soc_initdata.subtype = AT91_SOC_SAM9G35; +			break; +		case ARCH_EXID_AT91SAM9X35: +			at91_soc_initdata.subtype = AT91_SOC_SAM9X35; +			break; +		case ARCH_EXID_AT91SAM9G25: +			at91_soc_initdata.subtype = AT91_SOC_SAM9G25; +			break; +		case ARCH_EXID_AT91SAM9X25: +			at91_soc_initdata.subtype = AT91_SOC_SAM9X25; +			break; +		} +	} + +	if (at91_soc_initdata.type == AT91_SOC_SAMA5D3) { +		switch (at91_soc_initdata.exid) { +		case ARCH_EXID_SAMA5D31: +			at91_soc_initdata.subtype = AT91_SOC_SAMA5D31; +			break; +		case ARCH_EXID_SAMA5D33: +			at91_soc_initdata.subtype = AT91_SOC_SAMA5D33; +			break; +		case ARCH_EXID_SAMA5D34: +			at91_soc_initdata.subtype = AT91_SOC_SAMA5D34; +			break; +		case ARCH_EXID_SAMA5D35: +			at91_soc_initdata.subtype = AT91_SOC_SAMA5D35; +			break; +		case ARCH_EXID_SAMA5D36: +			at91_soc_initdata.subtype = AT91_SOC_SAMA5D36; +			break; +		} +	} +} + +static const char *soc_name[] = { +	[AT91_SOC_RM9200]	= "at91rm9200", +	[AT91_SOC_SAM9260]	= "at91sam9260", +	[AT91_SOC_SAM9261]	= "at91sam9261", +	[AT91_SOC_SAM9263]	= "at91sam9263", +	[AT91_SOC_SAM9G10]	= "at91sam9g10", +	[AT91_SOC_SAM9G20]	= "at91sam9g20", +	[AT91_SOC_SAM9G45]	= "at91sam9g45", +	[AT91_SOC_SAM9RL]	= "at91sam9rl", +	[AT91_SOC_SAM9X5]	= "at91sam9x5", +	[AT91_SOC_SAM9N12]	= "at91sam9n12", +	[AT91_SOC_SAMA5D3]	= "sama5d3", +	[AT91_SOC_UNKNOWN]	= "Unknown", +}; + +const char *at91_get_soc_type(struct at91_socinfo *c) +{ +	return soc_name[c->type]; +} +EXPORT_SYMBOL(at91_get_soc_type); + +static const char *soc_subtype_name[] = { +	[AT91_SOC_RM9200_BGA]	= "at91rm9200 BGA", +	[AT91_SOC_RM9200_PQFP]	= "at91rm9200 PQFP", +	[AT91_SOC_SAM9XE]	= "at91sam9xe", +	[AT91_SOC_SAM9G45ES]	= "at91sam9g45es", +	[AT91_SOC_SAM9M10]	= "at91sam9m10", +	[AT91_SOC_SAM9G46]	= "at91sam9g46", +	[AT91_SOC_SAM9M11]	= "at91sam9m11", +	[AT91_SOC_SAM9G15]	= "at91sam9g15", +	[AT91_SOC_SAM9G35]	= "at91sam9g35", +	[AT91_SOC_SAM9X35]	= "at91sam9x35", +	[AT91_SOC_SAM9G25]	= "at91sam9g25", +	[AT91_SOC_SAM9X25]	= "at91sam9x25", +	[AT91_SOC_SAMA5D31]	= "sama5d31", +	[AT91_SOC_SAMA5D33]	= "sama5d33", +	[AT91_SOC_SAMA5D34]	= "sama5d34", +	[AT91_SOC_SAMA5D35]	= "sama5d35", +	[AT91_SOC_SAMA5D36]	= "sama5d36", +	[AT91_SOC_SUBTYPE_NONE]	= "None", +	[AT91_SOC_SUBTYPE_UNKNOWN] = "Unknown", +}; + +const char *at91_get_soc_subtype(struct at91_socinfo *c) +{ +	return soc_subtype_name[c->subtype]; +} +EXPORT_SYMBOL(at91_get_soc_subtype); + +void __init at91_map_io(void) +{ +	/* Map peripherals */ +	iotable_init(&at91_io_desc, 1); + +	at91_soc_initdata.type = AT91_SOC_UNKNOWN; +	at91_soc_initdata.subtype = AT91_SOC_SUBTYPE_UNKNOWN; + +	soc_detect(AT91_BASE_DBGU0); +	if (!at91_soc_is_detected()) +		soc_detect(AT91_BASE_DBGU1); + +	if (!at91_soc_is_detected()) +		panic("AT91: Impossible to detect the SOC type"); + +	pr_info("AT91: Detected soc type: %s\n", +		at91_get_soc_type(&at91_soc_initdata)); +	if (at91_soc_initdata.subtype != AT91_SOC_SUBTYPE_NONE) +		pr_info("AT91: Detected soc subtype: %s\n", +			at91_get_soc_subtype(&at91_soc_initdata)); + +	if (!at91_soc_is_enabled()) +		panic("AT91: Soc not enabled"); + +	if (at91_boot_soc.map_io) +		at91_boot_soc.map_io(); +} + +void __iomem *at91_shdwc_base = NULL; + +static void at91sam9_poweroff(void) +{ +	at91_shdwc_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); +} + +void __init at91_ioremap_shdwc(u32 base_addr) +{ +	at91_shdwc_base = ioremap(base_addr, 16); +	if (!at91_shdwc_base) +		panic("Impossible to ioremap at91_shdwc_base\n"); +	pm_power_off = at91sam9_poweroff; +} + +void __iomem *at91_rstc_base; + +void __init at91_ioremap_rstc(u32 base_addr) +{ +	at91_rstc_base = ioremap(base_addr, 16); +	if (!at91_rstc_base) +		panic("Impossible to ioremap at91_rstc_base\n"); +} + +void __iomem *at91_matrix_base; +EXPORT_SYMBOL_GPL(at91_matrix_base); + +void __init at91_ioremap_matrix(u32 base_addr) +{ +	at91_matrix_base = ioremap(base_addr, 512); +	if (!at91_matrix_base) +		panic("Impossible to ioremap at91_matrix_base\n"); +} + +#if defined(CONFIG_OF) && !defined(CONFIG_ARCH_AT91X40) +static struct of_device_id rstc_ids[] = { +	{ .compatible = "atmel,at91sam9260-rstc", .data = at91sam9_alt_restart }, +	{ .compatible = "atmel,at91sam9g45-rstc", .data = at91sam9g45_restart }, +	{ /*sentinel*/ } +}; + +static void at91_dt_rstc(void) +{ +	struct device_node *np; +	const struct of_device_id *of_id; + +	np = of_find_matching_node(NULL, rstc_ids); +	if (!np) +		panic("unable to find compatible rstc node in dtb\n"); + +	at91_rstc_base = of_iomap(np, 0); +	if (!at91_rstc_base) +		panic("unable to map rstc cpu registers\n"); + +	of_id = of_match_node(rstc_ids, np); +	if (!of_id) +		panic("AT91: rtsc no restart function available\n"); + +	arm_pm_restart = of_id->data; + +	of_node_put(np); +} + +static struct of_device_id ramc_ids[] = { +	{ .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby }, +	{ .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby }, +	{ .compatible = "atmel,at91sam9g45-ddramc", .data = at91_ddr_standby }, +	{ /*sentinel*/ } +}; + +static void at91_dt_ramc(void) +{ +	struct device_node *np; +	const struct of_device_id *of_id; + +	np = of_find_matching_node(NULL, ramc_ids); +	if (!np) +		panic("unable to find compatible ram controller node in dtb\n"); + +	at91_ramc_base[0] = of_iomap(np, 0); +	if (!at91_ramc_base[0]) +		panic("unable to map ramc[0] cpu registers\n"); +	/* the controller may have 2 banks */ +	at91_ramc_base[1] = of_iomap(np, 1); + +	of_id = of_match_node(ramc_ids, np); +	if (!of_id) +		pr_warn("AT91: ramc no standby function available\n"); +	else +		at91_pm_set_standby(of_id->data); + +	of_node_put(np); +} + +static struct of_device_id shdwc_ids[] = { +	{ .compatible = "atmel,at91sam9260-shdwc", }, +	{ .compatible = "atmel,at91sam9rl-shdwc", }, +	{ .compatible = "atmel,at91sam9x5-shdwc", }, +	{ /*sentinel*/ } +}; + +static const char *shdwc_wakeup_modes[] = { +	[AT91_SHDW_WKMODE0_NONE]	= "none", +	[AT91_SHDW_WKMODE0_HIGH]	= "high", +	[AT91_SHDW_WKMODE0_LOW]		= "low", +	[AT91_SHDW_WKMODE0_ANYLEVEL]	= "any", +}; + +const int at91_dtget_shdwc_wakeup_mode(struct device_node *np) +{ +	const char *pm; +	int err, i; + +	err = of_property_read_string(np, "atmel,wakeup-mode", &pm); +	if (err < 0) +		return AT91_SHDW_WKMODE0_ANYLEVEL; + +	for (i = 0; i < ARRAY_SIZE(shdwc_wakeup_modes); i++) +		if (!strcasecmp(pm, shdwc_wakeup_modes[i])) +			return i; + +	return -ENODEV; +} + +static void at91_dt_shdwc(void) +{ +	struct device_node *np; +	int wakeup_mode; +	u32 reg; +	u32 mode = 0; + +	np = of_find_matching_node(NULL, shdwc_ids); +	if (!np) { +		pr_debug("AT91: unable to find compatible shutdown (shdwc) controller node in dtb\n"); +		return; +	} + +	at91_shdwc_base = of_iomap(np, 0); +	if (!at91_shdwc_base) +		panic("AT91: unable to map shdwc cpu registers\n"); + +	wakeup_mode = at91_dtget_shdwc_wakeup_mode(np); +	if (wakeup_mode < 0) { +		pr_warn("AT91: shdwc unknown wakeup mode\n"); +		goto end; +	} + +	if (!of_property_read_u32(np, "atmel,wakeup-counter", ®)) { +		if (reg > AT91_SHDW_CPTWK0_MAX) { +			pr_warn("AT91: shdwc wakeup counter 0x%x > 0x%x reduce it to 0x%x\n", +				reg, AT91_SHDW_CPTWK0_MAX, AT91_SHDW_CPTWK0_MAX); +			reg = AT91_SHDW_CPTWK0_MAX; +		} +		mode |= AT91_SHDW_CPTWK0_(reg); +	} + +	if (of_property_read_bool(np, "atmel,wakeup-rtc-timer")) +			mode |= AT91_SHDW_RTCWKEN; + +	if (of_property_read_bool(np, "atmel,wakeup-rtt-timer")) +			mode |= AT91_SHDW_RTTWKEN; + +	at91_shdwc_write(AT91_SHDW_MR, wakeup_mode | mode); + +end: +	pm_power_off = at91sam9_poweroff; + +	of_node_put(np); +} + +void __init at91rm9200_dt_initialize(void) +{ +	at91_dt_ramc(); + +	/* Init clock subsystem */ +	at91_dt_clock_init(); + +	/* Register the processor-specific clocks */ +	if (at91_boot_soc.register_clocks) +		at91_boot_soc.register_clocks(); + +	at91_boot_soc.init(); +} + +void __init at91_dt_initialize(void) +{ +	at91_dt_rstc(); +	at91_dt_ramc(); +	at91_dt_shdwc(); + +	/* Init clock subsystem */ +	at91_dt_clock_init(); + +	/* Register the processor-specific clocks */ +	if (at91_boot_soc.register_clocks) +		at91_boot_soc.register_clocks(); + +	if (at91_boot_soc.init) +		at91_boot_soc.init(); +} +#endif + +void __init at91_initialize(unsigned long main_clock) +{ +	at91_boot_soc.ioremap_registers(); + +	/* Init clock subsystem */ +	at91_clock_init(main_clock); + +	/* Register the processor-specific clocks */ +	at91_boot_soc.register_clocks(); + +	at91_boot_soc.init(); + +	pinctrl_provide_dummies(); +} diff --git a/arch/arm/mach-at91/soc.h b/arch/arm/mach-at91/soc.h new file mode 100644 index 00000000000..a1e1482c6da --- /dev/null +++ b/arch/arm/mach-at91/soc.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> + * + * Under GPLv2 + */ + +struct at91_init_soc { +	int builtin; +	u32 extern_irq; +	unsigned int *default_irq_priority; +	void (*map_io)(void); +	void (*ioremap_registers)(void); +	void (*register_clocks)(void); +	void (*init)(void); +}; + +extern struct at91_init_soc at91_boot_soc; +extern struct at91_init_soc at91rm9200_soc; +extern struct at91_init_soc at91sam9260_soc; +extern struct at91_init_soc at91sam9261_soc; +extern struct at91_init_soc at91sam9263_soc; +extern struct at91_init_soc at91sam9g45_soc; +extern struct at91_init_soc at91sam9rl_soc; +extern struct at91_init_soc at91sam9x5_soc; +extern struct at91_init_soc at91sam9n12_soc; +extern struct at91_init_soc sama5d3_soc; + +#define AT91_SOC_START(_name)				\ +struct at91_init_soc __initdata _name##_soc		\ + __used							\ +						= {	\ +	.builtin	= 1,				\ + +#define AT91_SOC_END					\ +}; + +static inline int at91_soc_is_enabled(void) +{ +	return at91_boot_soc.builtin; +} + +#if !defined(CONFIG_SOC_AT91RM9200) +#define at91rm9200_soc	at91_boot_soc +#endif + +#if !defined(CONFIG_SOC_AT91SAM9260) +#define at91sam9260_soc	at91_boot_soc +#endif + +#if !defined(CONFIG_SOC_AT91SAM9261) +#define at91sam9261_soc	at91_boot_soc +#endif + +#if !defined(CONFIG_SOC_AT91SAM9263) +#define at91sam9263_soc	at91_boot_soc +#endif + +#if !defined(CONFIG_SOC_AT91SAM9G45) +#define at91sam9g45_soc	at91_boot_soc +#endif + +#if !defined(CONFIG_SOC_AT91SAM9RL) +#define at91sam9rl_soc	at91_boot_soc +#endif + +#if !defined(CONFIG_SOC_AT91SAM9X5) +#define at91sam9x5_soc	at91_boot_soc +#endif + +#if !defined(CONFIG_SOC_AT91SAM9N12) +#define at91sam9n12_soc	at91_boot_soc +#endif + +#if !defined(CONFIG_SOC_SAMA5D3) +#define sama5d3_soc	at91_boot_soc +#endif diff --git a/arch/arm/mach-at91/stamp9g20.h b/arch/arm/mach-at91/stamp9g20.h new file mode 100644 index 00000000000..f62c0abca4b --- /dev/null +++ b/arch/arm/mach-at91/stamp9g20.h @@ -0,0 +1,7 @@ +#ifndef __MACH_STAMP9G20_H +#define __MACH_STAMP9G20_H + +void stamp9g20_init_early(void); +void stamp9g20_board_init(void); + +#endif diff --git a/arch/arm/mach-at91/sysirq_mask.c b/arch/arm/mach-at91/sysirq_mask.c new file mode 100644 index 00000000000..f8bc3511a8c --- /dev/null +++ b/arch/arm/mach-at91/sysirq_mask.c @@ -0,0 +1,75 @@ +/* + * sysirq_mask.c - System-interrupt masking + * + * Copyright (C) 2013 Johan Hovold <jhovold@gmail.com> + * + * Functions to disable system interrupts from backup-powered peripherals. + * + * The RTC and RTT-peripherals are generally powered by backup power (VDDBU) + * and are not reset on wake-up, user, watchdog or software reset. This means + * that their interrupts may be enabled during early boot (e.g. after a user + * reset). + * + * As the RTC and RTT share the system-interrupt line with the PIT, an + * interrupt occurring before a handler has been installed would lead to the + * system interrupt being disabled and prevent the system from booting. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include <linux/io.h> +#include <mach/at91_rtt.h> + +#include "generic.h" + +#define AT91_RTC_IDR		0x24	/* Interrupt Disable Register */ +#define AT91_RTC_IMR		0x28	/* Interrupt Mask Register */ +#define AT91_RTC_IRQ_MASK	0x1f	/* Available IRQs mask */ + +void __init at91_sysirq_mask_rtc(u32 rtc_base) +{ +	void __iomem *base; + +	base = ioremap(rtc_base, 64); +	if (!base) +		return; + +	/* +	 * sam9x5 SoCs have the following errata: +	 * "RTC: Interrupt Mask Register cannot be used +	 *  Interrupt Mask Register read always returns 0." +	 * +	 * Hence we're not relying on IMR values to disable +	 * interrupts. +	 */ +	writel_relaxed(AT91_RTC_IRQ_MASK, base + AT91_RTC_IDR); +	(void)readl_relaxed(base + AT91_RTC_IMR);	/* flush */ + +	iounmap(base); +} + +void __init at91_sysirq_mask_rtt(u32 rtt_base) +{ +	void __iomem *base; +	void __iomem *reg; +	u32 mode; + +	base = ioremap(rtt_base, 16); +	if (!base) +		return; + +	reg = base + AT91_RTT_MR; + +	mode = readl_relaxed(reg); +	if (mode & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)) { +		pr_info("AT91: Disabling rtt irq\n"); +		mode &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN); +		writel_relaxed(mode, reg); +		(void)readl_relaxed(reg);			/* flush */ +	} + +	iounmap(base); +}  | 
