]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[AVR32] Wire up USBA device
authorHaavard Skinnemoen <hskinnemoen@atmel.com>
Thu, 14 Jun 2007 15:37:31 +0000 (17:37 +0200)
committerHaavard Skinnemoen <hskinnemoen@atmel.com>
Thu, 11 Oct 2007 09:40:27 +0000 (11:40 +0200)
Implement at32_add_device_usba() and use it to wire up the USBA device
on ATSTK1000 and ATNGW100.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
arch/avr32/boards/atngw100/setup.c
arch/avr32/boards/atstk1000/atstk1002.c
arch/avr32/mach-at32ap/at32ap7000.c
include/asm-avr32/arch-at32ap/board.h

index ef801563bbf58930cfb90762a345b0d480c99841..6e180f435253bb561cafb5a9eec81163e81c01e8 100644 (file)
@@ -154,6 +154,7 @@ static int __init atngw100_init(void)
        set_hw_addr(at32_add_device_eth(1, &eth_data[1]));
 
        at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
+       at32_add_device_usba(0, NULL);
 
        for (i = 0; i < ARRAY_SIZE(ngw_leds); i++) {
                at32_select_gpio(ngw_leds[i].gpio,
index c9981b731efa58e1d20aecee60222081ed813b06..6b9e466104ad04d8c5be831774a937931eb298e3 100644 (file)
@@ -241,6 +241,7 @@ static int __init atstk1002_init(void)
        at32_add_device_lcdc(0, &atstk1000_lcdc_data,
                             fbmem_start, fbmem_size);
 #endif
+       at32_add_device_usba(0, NULL);
 #ifndef CONFIG_BOARD_ATSTK1002_SW3_CUSTOM
        at32_add_device_ssc(0, ATMEL_SSC_TX);
 #endif
index 373242aab976eca6656bf7e4bfe6086873c9b534..f6d154ca4d24ebdd91c2fa1fef37d15a25184777 100644 (file)
@@ -1161,6 +1161,72 @@ at32_add_device_ssc(unsigned int id, unsigned int flags)
        return pdev;
 }
 
+/* --------------------------------------------------------------------
+ *  USB Device Controller
+ * -------------------------------------------------------------------- */
+static struct resource usba0_resource[] __initdata = {
+       {
+               .start          = 0xff300000,
+               .end            = 0xff3fffff,
+               .flags          = IORESOURCE_MEM,
+       }, {
+               .start          = 0xfff03000,
+               .end            = 0xfff033ff,
+               .flags          = IORESOURCE_MEM,
+       },
+       IRQ(31),
+};
+static struct clk usba0_pclk = {
+       .name           = "pclk",
+       .parent         = &pbb_clk,
+       .mode           = pbb_clk_mode,
+       .get_rate       = pbb_clk_get_rate,
+       .index          = 12,
+};
+static struct clk usba0_hclk = {
+       .name           = "hclk",
+       .parent         = &hsb_clk,
+       .mode           = hsb_clk_mode,
+       .get_rate       = hsb_clk_get_rate,
+       .index          = 6,
+};
+
+struct platform_device *__init
+at32_add_device_usba(unsigned int id, struct usba_platform_data *data)
+{
+       struct platform_device *pdev;
+
+       if (id != 0)
+               return NULL;
+
+       pdev = platform_device_alloc("atmel_usba_udc", 0);
+       if (!pdev)
+               return NULL;
+
+       if (platform_device_add_resources(pdev, usba0_resource,
+                                         ARRAY_SIZE(usba0_resource)))
+               goto out_free_pdev;
+
+       if (data) {
+               if (platform_device_add_data(pdev, data, sizeof(*data)))
+                       goto out_free_pdev;
+
+               if (data->vbus_pin != GPIO_PIN_NONE)
+                       at32_select_gpio(data->vbus_pin, 0);
+       }
+
+       usba0_pclk.dev = &pdev->dev;
+       usba0_hclk.dev = &pdev->dev;
+
+       platform_device_add(pdev);
+
+       return pdev;
+
+out_free_pdev:
+       platform_device_put(pdev);
+       return NULL;
+}
+
 /* --------------------------------------------------------------------
  *  GCLK
  * -------------------------------------------------------------------- */
@@ -1246,6 +1312,8 @@ struct clk *at32_clock_list[] = {
        &ssc0_pclk,
        &ssc1_pclk,
        &ssc2_pclk,
+       &usba0_hclk,
+       &usba0_pclk,
        &gclk0,
        &gclk1,
        &gclk2,
index 0215965dc586d4db7037299ef56e735e9cb5a0b4..7dbd603c38cc3cf6e5a2244e547c90b45df46e7e 100644 (file)
@@ -6,6 +6,8 @@
 
 #include <linux/types.h>
 
+#define GPIO_PIN_NONE  (-1)
+
 /* Add basic devices: system manager, interrupt controller, portmuxes, etc. */
 void at32_add_system_devices(void);
 
@@ -36,6 +38,12 @@ struct platform_device *
 at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
                     unsigned long fbmem_start, unsigned long fbmem_len);
 
+struct usba_platform_data {
+       int vbus_pin;
+};
+struct platform_device *
+at32_add_device_usba(unsigned int id, struct usba_platform_data *data);
+
 /* depending on what's hooked up, not all SSC pins will be used */
 #define        ATMEL_SSC_TK            0x01
 #define        ATMEL_SSC_TF            0x02