]> err.no Git - linux-2.6/commitdiff
[AVR32] SPI platform code update
authorHaavard Skinnemoen <hskinnemoen@atmel.com>
Wed, 10 Jan 2007 19:20:02 +0000 (20:20 +0100)
committerHaavard Skinnemoen <hskinnemoen@atmel.com>
Fri, 9 Feb 2007 14:01:59 +0000 (15:01 +0100)
Move stuff in spi.c into ATSTK1002 board code and update SPI
platform device definitions according to the new GPIO API.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
arch/avr32/boards/atstk1000/Makefile
arch/avr32/boards/atstk1000/atstk1002.c
arch/avr32/boards/atstk1000/spi.c [deleted file]
arch/avr32/mach-at32ap/at32ap7000.c

index df9499480530bf2640cfd2b653ae609175c6e2ea..8e0992201bb98b931d9578feeac8a05d5a9ae828 100644 (file)
@@ -1,2 +1,2 @@
-obj-y                          += setup.o spi.o flash.o
+obj-y                          += setup.o flash.o
 obj-$(CONFIG_BOARD_ATSTK1002)  += atstk1002.o
index bca815ff11f219b21030c16b77cf01847174f3ee..d47e39f0e971925f81cba2588fa185b5829ed1a0 100644 (file)
@@ -8,15 +8,18 @@
  * published by the Free Software Foundation.
  */
 #include <linux/clk.h>
+#include <linux/device.h>
 #include <linux/etherdevice.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/string.h>
 #include <linux/types.h>
+#include <linux/spi/spi.h>
 
 #include <asm/io.h>
 #include <asm/setup.h>
+#include <asm/arch/at32ap7000.h>
 #include <asm/arch/board.h>
 #include <asm/arch/init.h>
 #include <asm/arch/portmux.h>
@@ -33,6 +36,16 @@ static struct eth_addr __initdata hw_addr[2];
 static struct eth_platform_data __initdata eth_data[2];
 extern struct lcdc_platform_data atstk1000_fb0_data;
 
+static struct spi_board_info spi_board_info[] __initdata = {
+       {
+               .modalias       = "ltv350qv",
+               .controller_data = (void *)GPIO_PIN_PA(4),
+               .max_speed_hz   = 16000000,
+               .bus_num        = 0,
+               .chip_select    = 1,
+       },
+};
+
 /*
  * The next two functions should go away as the boot loader is
  * supposed to initialize the macb address registers with a valid
@@ -136,6 +149,7 @@ static int __init atstk1002_init(void)
 
        set_hw_addr(at32_add_device_eth(0, &eth_data[0]));
 
+       spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
        at32_add_device_spi(0);
        at32_add_device_lcdc(0, &atstk1000_fb0_data);
 
diff --git a/arch/avr32/boards/atstk1000/spi.c b/arch/avr32/boards/atstk1000/spi.c
deleted file mode 100644 (file)
index 567726c..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * ATSTK1000 SPI devices
- *
- * Copyright (C) 2005 Atmel Norway
- *
- * 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
- * published by the Free Software Foundation.
- */
-#include <linux/device.h>
-#include <linux/spi/spi.h>
-
-static struct spi_board_info spi_board_info[] __initdata = {
-       {
-               .modalias       = "ltv350qv",
-               .max_speed_hz   = 16000000,
-               .bus_num        = 0,
-               .chip_select    = 1,
-       },
-};
-
-static int board_init_spi(void)
-{
-       spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
-       return 0;
-}
-arch_initcall(board_init_spi);
index 981d553e471bf3aa57e02830dd3c585379e123aa..c1e477ec7576850887591f9cc14c7d42128fa0b0 100644 (file)
@@ -736,12 +736,19 @@ at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
 /* --------------------------------------------------------------------
  *  SPI
  * -------------------------------------------------------------------- */
-static struct resource spi0_resource[] = {
+static struct resource atmel_spi0_resource[] = {
        PBMEM(0xffe00000),
        IRQ(3),
 };
-DEFINE_DEV(spi, 0);
-DEV_CLK(mck, spi0, pba, 0);
+DEFINE_DEV(atmel_spi, 0);
+DEV_CLK(spi_clk, atmel_spi0, pba, 0);
+
+static struct resource atmel_spi1_resource[] = {
+       PBMEM(0xffe00400),
+       IRQ(4),
+};
+DEFINE_DEV(atmel_spi, 1);
+DEV_CLK(spi_clk, atmel_spi1, pba, 1);
 
 struct platform_device *__init at32_add_device_spi(unsigned int id)
 {
@@ -749,13 +756,33 @@ struct platform_device *__init at32_add_device_spi(unsigned int id)
 
        switch (id) {
        case 0:
-               pdev = &spi0_device;
+               pdev = &atmel_spi0_device;
                select_peripheral(PA(0),  PERIPH_A, 0); /* MISO  */
                select_peripheral(PA(1),  PERIPH_A, 0); /* MOSI  */
                select_peripheral(PA(2),  PERIPH_A, 0); /* SCK   */
-               select_peripheral(PA(3),  PERIPH_A, 0); /* NPCS0 */
-               select_peripheral(PA(4),  PERIPH_A, 0); /* NPCS1 */
-               select_peripheral(PA(5),  PERIPH_A, 0); /* NPCS2 */
+
+               /* NPCS[2:0] */
+               at32_select_gpio(GPIO_PIN_PA(3),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PA(4),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PA(5),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               break;
+
+       case 1:
+               pdev = &atmel_spi1_device;
+               select_peripheral(PB(0),  PERIPH_B, 0); /* MISO  */
+               select_peripheral(PB(1),  PERIPH_B, 0); /* MOSI  */
+               select_peripheral(PB(5),  PERIPH_B, 0); /* SCK   */
+
+               /* NPCS[2:0] */
+               at32_select_gpio(GPIO_PIN_PB(2),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PB(3),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PB(4),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
                break;
 
        default:
@@ -877,7 +904,8 @@ struct clk *at32_clock_list[] = {
        &macb0_pclk,
        &macb1_hclk,
        &macb1_pclk,
-       &spi0_mck,
+       &atmel_spi0_spi_clk,
+       &atmel_spi1_spi_clk,
        &lcdc0_hclk,
        &lcdc0_pixclk,
 };