linux-atmel: Add support for latest AT91 kernel
PATCH v2 1/1 linux-atmel: Add support for latest AT91 kernel
Add support for building AT91 2.6.30 kernel
Vanilla 2.6.30 recipe has moved on to 2.6.30.x
Add maxim.org.za patches + Atmel experimental patches. (With the exception of the SAM9M10-EK support) Add support for configurable NAND flash partitions Add support for sam9m10g45-ek
The contents of the maxim & experimental kernel patches has various authors described inide the patches.
--- .../linux-atmel-2.6.30/at91/2.6.30-at91-exp.patch |36510 ++++++++++++++++++++ ...linux-2.6.30-at91-exp-002-NAND-partitions.patch | 100 + ...-004-NAND-001-configurable-partition-size.patch | 214 + ...-2.6.30-at91-exp-005-at91sam9m10g45ek_BSP.patch | 30 + ....30-at91-exp-006-at91sam9m10g45ek_machine.patch | 39 + .../linux-atmel-2.6.30/at91sam9g45ek/defconfig | 1798 + recipes/linux/linux-atmel_2.6.30.bb | 25 + 7 files changed, 38716 insertions(+), 0 deletions(-) create mode 100644 recipes/linux/linux-atmel-2.6.30/at91/2.6.30-at91-exp.patch create mode 100644 recipes/linux/linux-atmel-2.6.30/at91/linux-2.6.30-at91-exp-002-NAND-partitions.patch create mode 100644 recipes/linux/linux-atmel-2.6.30/at91/linux-2.6.30-at91-exp-004-NAND-001-configurable-partition-size.patch create mode 100644 recipes/linux/linux-atmel-2.6.30/at91/linux-2.6.30-at91-exp-005-at91sam9m10g45ek_BSP.patch create mode 100644 recipes/linux/linux-atmel-2.6.30/at91/linux-2.6.30-at91-exp-006-at91sam9m10g45ek_machine.patch create mode 100644 recipes/linux/linux-atmel-2.6.30/at91sam9g45ek/defconfig create mode 100644 recipes/linux/linux-atmel_2.6.30.bb
recipes/linux/linux-atmel-2.6.30/at91/2.6.30-at91-exp.patch new file +36510 -0
@@ -0,0 +1,36510 @@ +From 460964e13607480ec141bd72fc76c5af52989175 Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:17 +0000 +Subject: [PATCH] at91: dm9000 initialization update + +Add information in dm9000 mac/phy chip initialization: +- irq resource details +- platform data details + +Signed-off-by: Nicolas Ferre <[email protected]> + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11572 50fbe906-d41e-0410-8a96-31537896a350 +--- + arch/arm/mach-at91/board-sam9261ek.c | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c +index ef392bb..9d82c22 100644 +--- a/arch/arm/mach-at91/board-sam9261ek.c ++++ b/arch/arm/mach-at91/board-sam9261ek.c +@@ -93,11 +93,12 @@ static struct resource dm9000_resource[] = { + .start = AT91_PIN_PC11, + .end = AT91_PIN_PC11, + .flags = IORESOURCE_IRQ ++ | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE, + } + }; + + static struct dm9000_plat_data dm9000_platdata = { +- .flags = DM9000_PLATF_16BITONLY, ++ .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM, + }; + + static struct platform_device dm9000_device = { +-- +1.5.6.5 + +From 7ee075f18835d4ad9a7da886b26bdf306f50c00f Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:18 +0000 +Subject: [PATCH] at91: add gpio button support for at91sam9g20ek + +This adds input keyboard gpio support on at91sam9g20ek board. It adds button 3 +and 4. + +Signed-off-by: Nicolas Ferre <[email protected]> + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11573 50fbe906-d41e-0410-8a96-31537896a350 +--- + arch/arm/mach-at91/board-sam9g20ek.c | 52 ++++++++++++++++++++++++++++++++++ + 1 files changed, 52 insertions(+), 0 deletions(-) + +diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c +index 438efbb..88c724d 100644 +--- a/arch/arm/mach-at91/board-sam9g20ek.c ++++ b/arch/arm/mach-at91/board-sam9g20ek.c +@@ -37,6 +37,8 @@ + + #include <mach/board.h> + #include <mach/gpio.h> ++#include <linux/gpio_keys.h> ++#include <linux/input.h> + #include <mach/at91sam9_smc.h> + + #include "sam9_smc.h" +@@ -218,6 +220,54 @@ static struct gpio_led ek_leds[] = { + } + }; + ++/* ++ * GPIO Buttons ++ */ ++#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) ++static struct gpio_keys_button ek_buttons[] = { ++ { ++ .gpio = AT91_PIN_PA30, ++ .code = BTN_3, ++ .desc = "Button 3", ++ .active_low = 1, ++ .wakeup = 1, ++ }, ++ { ++ .gpio = AT91_PIN_PA31, ++ .code = BTN_4, ++ .desc = "Button 4", ++ .active_low = 1, ++ .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_input(AT91_PIN_PA30, 1); /* btn3 */ ++ at91_set_deglitch(AT91_PIN_PA30, 1); ++ at91_set_gpio_input(AT91_PIN_PA31, 1); /* btn4 */ ++ at91_set_deglitch(AT91_PIN_PA31, 1); ++ ++ platform_device_register(&ek_button_device); ++} ++#else ++static void __init ek_add_device_buttons(void) {} ++#endif ++ + static void __init ek_board_init(void) + { + /* Serial */ +@@ -238,6 +288,8 @@ static void __init ek_board_init(void) + at91_add_device_i2c(NULL, 0); + /* LEDs */ + at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); ++ /* Push Buttons */ ++ ek_add_device_buttons(); + /* PCK0 provides MCLK to the WM8731 */ + at91_set_B_periph(AT91_PIN_PC1, 0); + /* SSC (for WM8731) */ +-- +1.5.6.5 + +From b6bd69b65c722f006da46d226d6fce1644f214a8 Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:18 +0000 +Subject: [PATCH] at91: add gpio button and leds support for at91sam9rlek + +This adds input keyboard gpio support on at91sam9rlek board. It adds button 1 +and 2 (left and right click). +It also adds gpio leds ds1, ds2 and ds3. + +Signed-off-by: Nicolas Ferre <[email protected]> + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11574 50fbe906-d41e-0410-8a96-31537896a350 +--- + arch/arm/mach-at91/board-sam9rlek.c | 79 +++++++++++++++++++++++++++++++++++ + 1 files changed, 79 insertions(+), 0 deletions(-) + +diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c +index d34e343..ee4137b 100644 +--- a/arch/arm/mach-at91/board-sam9rlek.c ++++ b/arch/arm/mach-at91/board-sam9rlek.c +@@ -15,6 +15,8 @@ + #include <linux/spi/spi.h> + #include <linux/fb.h> + #include <linux/clk.h> ++#include <linux/input.h> ++#include <linux/gpio_keys.h> + + #include <video/atmel_lcdc.h> + +@@ -206,6 +208,79 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data; + #endif + + ++/* ++ * LEDs ++ */ ++static struct gpio_led ek_leds[] = { ++ { /* "bottom" led, green, userled1 to be defined */ ++ .name = "ds1", ++ .gpio = AT91_PIN_PD15, ++ .active_low = 1, ++ .default_trigger = "none", ++ }, ++ { /* "bottom" led, green, userled2 to be defined */ ++ .name = "ds2", ++ .gpio = AT91_PIN_PD16, ++ .active_low = 1, ++ .default_trigger = "none", ++ }, ++ { /* "power" led, yellow */ ++ .name = "ds3", ++ .gpio = AT91_PIN_PD14, ++ .default_trigger = "heartbeat", ++ } ++}; ++ ++ ++/* ++ * GPIO Buttons ++ */ ++#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) ++static struct gpio_keys_button ek_buttons[] = { ++ { ++ .gpio = AT91_PIN_PB0, ++ .code = BTN_2, ++ .desc = "Right Click", ++ .active_low = 1, ++ .wakeup = 1, ++ }, ++ { ++ .gpio = AT91_PIN_PB1, ++ .code = BTN_1, ++ .desc = "Left Click", ++ .active_low = 1, ++ .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_input(AT91_PIN_PB1, 1); /* btn1 */ ++ at91_set_deglitch(AT91_PIN_PB1, 1); ++ at91_set_gpio_input(AT91_PIN_PB0, 1); /* btn2 */ ++ at91_set_deglitch(AT91_PIN_PB0, 1); ++ ++ platform_device_register(&ek_button_device); ++} ++#else ++static void __init ek_add_device_buttons(void) {} ++#endif ++ ++ + static void __init ek_board_init(void) + { + /* Serial */ +@@ -224,6 +299,10 @@ static void __init ek_board_init(void) + at91_add_device_lcdc(&ek_lcdc_data); + /* Touch Screen Controller */ + at91_add_device_tsadcc(); ++ /* LEDs */ ++ at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); ++ /* Push Buttons */ ++ ek_add_device_buttons(); + /* shutdown controller, wakeup button (5 msec low) */ + at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW + | AT91_SHDW_RTTWKEN); +-- +1.5.6.5 + +From 88178da92bd7bb5512a6b2f068fb231e928ac4a4 Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:19 +0000 +Subject: [PATCH] at91: at91sam9rlek lcd interface correction + +Here is a little update to the at91sam9rlek lcd interface. +This will correct the power pin of the LCD. +It will also add precision to the struct atmel_lcdfb_info +scructure: backlight enabling and wiring mode +correction: RGB wiring on the -EK board. + +Signed-off-by: Nicolas Ferre <[email protected]> + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11575 50fbe906-d41e-0410-8a96-31537896a350 +--- + arch/arm/mach-at91/board-sam9rlek.c | 6 ++++-- + 1 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c +index ee4137b..450a7be 100644 +--- a/arch/arm/mach-at91/board-sam9rlek.c ++++ b/arch/arm/mach-at91/board-sam9rlek.c +@@ -188,19 +188,21 @@ static struct fb_monspecs at91fb_default_monspecs = { + static void at91_lcdc_power_control(int on) + { + if (on) +- at91_set_gpio_value(AT91_PIN_PA30, 0); /* power up */ ++ at91_set_gpio_value(AT91_PIN_PC1, 0); /* power up */ + else +- at91_set_gpio_value(AT91_PIN_PA30, 1); /* power down */ ++ at91_set_gpio_value(AT91_PIN_PC1, 1); /* power down */ + } + + /* Driver datas */ + static struct atmel_lcdfb_info __initdata ek_lcdc_data = { ++ .lcdcon_is_backlight = true, + .default_bpp = 16, + .default_dmacon = ATMEL_LCDC_DMAEN, + .default_lcdcon2 = AT91SAM9RL_DEFAULT_LCDCON2, + .default_monspecs = &at91fb_default_monspecs, + .atmel_lcdfb_power_control = at91_lcdc_power_control, + .guard_time = 1, ++ .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB, + }; + + #else +-- +1.5.6.5 + +From 6581ef8f58379ff0d02afe8b0359ecf91b116f7d Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:20 +0000 +Subject: [PATCH] avr32: add two new at91 to cpu.h definition + +Somme common drivers will need those at91 cpu_is_xxx() definitions. As +at91sam9g10 and at91sam9g45 are on the way to linus' tree, here is the patch +that adds those chips to cpu.h in AVR32 architecture. + +Signed-off-by: Nicolas Ferre <[email protected]> + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11576 50fbe906-d41e-0410-8a96-31537896a350 +--- + arch/avr32/mach-at32ap/include/mach/cpu.h | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/arch/avr32/mach-at32ap/include/mach/cpu.h b/arch/avr32/mach-at32ap/include/mach/cpu.h +index 44d0bfa..c253e9b 100644 +--- a/arch/avr32/mach-at32ap/include/mach/cpu.h ++++ b/arch/avr32/mach-at32ap/include/mach/cpu.h +@@ -31,5 +31,7 @@ + #define cpu_is_at91sam9263() (0) + #define cpu_is_at91sam9rl() (0) + #define cpu_is_at91cap9() (0) ++#define cpu_is_at91sam9g10() (0) ++#define cpu_is_at91sam9g45() (0) + + #endif /* __ASM_ARCH_CPU_H */ +-- +1.5.6.5 + +From 39cdfe9f86b4ff30c151de1f55afc1f5a6aaf63c Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:20 +0000 +Subject: [PATCH] 5438/1: AT91: manage clock by functionality instead of CPUs + +In clock.c file the clock management is grouped by cpu with cpu_is_xxx() +function. This lead to some kind of difficulties to read this file and +maintainability issues as the number of AT91 cpus & PLLs/clocks is growing. + +In this patch, I try to group clock functionality together and match cpus with +this functionality set. +An update to at91_pmc.h is needed to cover some new PMC possibilities (and +some update in comments). + +Signed-off-by: Nicolas Ferre <[email protected]> +Acked-by: Andrew Victor <[email protected]> +Signed-off-by: Russell King <[email protected]> + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11577 50fbe906-d41e-0410-8a96-31537896a350 +--- + arch/arm/mach-at91/clock.c | 152 ++++++++++++++++++++------- + arch/arm/mach-at91/include/mach/at91_pmc.h | 26 ++++- + 2 files changed, 132 insertions(+), 46 deletions(-) + +diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c +index 611e2a7..c09148c 100644 +--- a/arch/arm/mach-at91/clock.c ++++ b/arch/arm/mach-at91/clock.c +@@ -44,6 +44,25 @@ + #define clk_is_sys(x) ((x)->type & CLK_TYPE_SYSTEM) + + ++/* ++ * Chips have some kind of clocks : group them by functionality ++ */ ++#define cpu_has_utmi() ( cpu_is_at91cap9() \ ++ || cpu_is_at91sam9rl()) ++ ++#define cpu_has_800M_plla() (cpu_is_at91sam9g20()) ++ ++#define cpu_has_pllb() (!cpu_is_at91sam9rl()) ++ ++#define cpu_has_upll() (0) ++ ++/* USB host HS & FS */ ++#define cpu_has_uhp() (!cpu_is_at91sam9rl()) ++ ++/* USB device FS only */ ++#define cpu_has_udpfs() (!cpu_is_at91sam9rl()) ++ ++ + static LIST_HEAD(clocks); + static DEFINE_SPINLOCK(clk_lock); + +@@ -141,7 +160,7 @@ static struct clk utmi_clk = { + }; + static struct clk uhpck = { + .name = "uhpck", +- .parent = &pllb, ++ /*.parent = ... we choose parent at runtime */ + .mode = pmc_sys_mode, + }; + +@@ -174,7 +193,11 @@ static struct clk __init *at91_css_to_clk(unsigned long css) + case AT91_PMC_CSS_PLLA: + return &plla; + case AT91_PMC_CSS_PLLB: +- return &pllb; ++ if (cpu_has_upll()) ++ /* CSS_PLLB == CSS_UPLL */ ++ return &utmi_clk; ++ else if (cpu_has_pllb()) ++ return &pllb; + } + + return NULL; +@@ -340,7 +363,7 @@ int clk_set_rate(struct clk *clk, unsigned long rate) + u32 pckr; + + pckr = at91_sys_read(AT91_PMC_PCKR(clk->id)); +- pckr &= AT91_PMC_CSS_PLLB; /* clock selection */ ++ pckr &= AT91_PMC_CSS; /* clock selection */ + pckr |= prescale << 2; + at91_sys_write(AT91_PMC_PCKR(clk->id), pckr); + clk->rate_hz = actual; +@@ -379,7 +402,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent) + } + EXPORT_SYMBOL(clk_set_parent); + +-/* establish PCK0..PCK4 parentage and rate */ ++/* establish PCK0..PCKN parentage and rate */ + static void __init init_programmable_clock(struct clk *clk) + { + struct clk *parent; +@@ -407,11 +430,13 @@ static int at91_clk_show(struct seq_file *s, void *unused) + 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)); +- if (!cpu_is_at91sam9rl()) ++ if (cpu_has_pllb()) + seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR)); +- if (cpu_is_at91cap9() || cpu_is_at91sam9rl()) ++ 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, "\n"); +@@ -572,16 +597,60 @@ static struct clk *const standard_pmc_clocks[] __initdata = { + &clk32k, + &main_clk, + &plla, +- &pllb, +- +- /* PLLB children (USB) */ +- &udpck, +- &uhpck, + + /* MCK */ + &mck + }; + ++/* PLLB generated USB full speed clock init */ ++static void __init at91_pllb_usbfs_clock_init(unsigned long main_clock) ++{ ++ /* ++ * USB clock init: choose 48 MHz PLLB value, ++ * disable 48MHz clock during usb peripheral suspend. ++ * ++ * REVISIT: assumes MCK doesn't derive from PLLB! ++ */ ++ uhpck.parent = &pllb; ++ ++ at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2) | AT91_PMC_USB96M; ++ pllb.rate_hz = at91_pll_rate(&pllb, main_clock, at91_pllb_usb_init); ++ if (cpu_is_at91rm9200()) { ++ uhpck.pmc_mask = AT91RM9200_PMC_UHP; ++ udpck.pmc_mask = AT91RM9200_PMC_UDP; ++ at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP); ++ } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263() || cpu_is_at91sam9g20() || cpu_is_at572d940hf()) { ++ 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); ++ ++ 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); ++} ++ ++/* UPLL generated USB full speed clock init */ ++static void __init at91_upll_usbfs_clock_init(unsigned long main_clock) ++{ ++ /* ++ * USB clock init: choose 480 MHz from UPLL, ++ */ ++ unsigned int usbr = AT91_PMC_USBS_UPLL; ++ ++ /* Setup divider by 10 to reach 48 MHz */ ++ usbr |= ((10 - 1) << 8) & AT91_PMC_OHCIUSBDIV; ++ ++ at91_sys_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); ++} ++ + int __init at91_clock_init(unsigned long main_clock) + { + unsigned tmp, freq, mckr; +@@ -603,43 +672,36 @@ int __init at91_clock_init(unsigned long 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_is_at91sam9g20() && plla.rate_hz > 209000000) +- || (cpu_is_at91sam9g20() && plla.rate_hz > 800000000)) ++ if ((!cpu_has_800M_plla() && plla.rate_hz > 209000000) ++ || (cpu_has_800M_plla() && plla.rate_hz > 800000000)) + pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000); + +- /* +- * USB clock init: choose 48 MHz PLLB value, +- * disable 48MHz clock during usb peripheral suspend. +- * +- * REVISIT: assumes MCK doesn't derive from PLLB! +- */ +- at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2) | AT91_PMC_USB96M; +- pllb.rate_hz = at91_pll_rate(&pllb, main_clock, at91_pllb_usb_init); +- if (cpu_is_at91rm9200()) { +- uhpck.pmc_mask = AT91RM9200_PMC_UHP; +- udpck.pmc_mask = AT91RM9200_PMC_UDP; +- at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP); +- } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263() || cpu_is_at91sam9g20() || cpu_is_at572d940hf()) { +- uhpck.pmc_mask = AT91SAM926x_PMC_UHP; +- udpck.pmc_mask = AT91SAM926x_PMC_UDP; +- } else if (cpu_is_at91cap9()) { +- uhpck.pmc_mask = AT91CAP9_PMC_UHP; ++ if (cpu_has_upll() && !cpu_has_pllb()) { ++ /* setup UTMI clock as the fourth primary clock ++ * (instead of pllb) */ ++ utmi_clk.type |= CLK_TYPE_PRIMARY; ++ utmi_clk.id = 3; + } +- at91_sys_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); + + /* + * USB HS clock init + */ +- if (cpu_is_at91cap9() || cpu_is_at91sam9rl()) { ++ if (cpu_has_utmi()) + /* + * multiplier is hard-wired to 40 + * (obtain the USB High Speed 480 MHz when input is 12 MHz) + */ + utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz; +- } ++ ++ /* ++ * USB FS clock init ++ */ ++ if (cpu_has_pllb()) ++ at91_pllb_usbfs_clock_init(main_clock); ++ if (cpu_has_upll()) ++ /* assumes that we choose UPLL for USB and not PLLA */ ++ at91_upll_usbfs_clock_init(main_clock); + + /* + * MCK and CPU derive from one of those primary clocks. +@@ -649,21 +711,31 @@ int __init at91_clock_init(unsigned long main_clock) + mck.parent = at91_css_to_clk(mckr & AT91_PMC_CSS); + freq = mck.parent->rate_hz; + freq /= (1 << ((mckr & AT91_PMC_PRES) >> 2)); /* prescale */ +- if (cpu_is_at91rm9200()) ++ if (cpu_is_at91rm9200()) { + mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ +- else if (cpu_is_at91sam9g20()) { ++ } else if (cpu_is_at91sam9g20()) { + mck.rate_hz = (mckr & AT91_PMC_MDIV) ? + freq / ((mckr & AT91_PMC_MDIV) >> 7) : freq; /* mdiv ; (x >> 7) = ((x >> 8) * 2) */ + if (mckr & AT91_PMC_PDIV) + freq /= 2; /* processor clock division */ +- } else +- mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ ++ } else { ++ mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ ++ } + + /* 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); + +- if (cpu_is_at91cap9() || cpu_is_at91sam9rl()) ++ if (cpu_has_pllb()) ++ list_add_tail(&pllb.node, &clocks); ++ ++ if (cpu_has_uhp()) ++ list_add_tail(&uhpck.node, &clocks); ++ ++ if (cpu_has_udpfs()) ++ list_add_tail(&udpck.node, &clocks); ++ ++ if (cpu_has_utmi()) + list_add_tail(&utmi_clk.node, &clocks); + + /* MCK and CPU clock are "always on" */ +diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h b/arch/arm/mach-at91/include/mach/at91_pmc.h +index e803376..ba429f7 100644 +--- a/arch/arm/mach-at91/include/mach/at91_pmc.h ++++ b/arch/arm/mach-at91/include/mach/at91_pmc.h +@@ -23,7 +23,7 @@ + #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 [AT91CAP9 revC 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] */ +@@ -40,11 +40,11 @@ + #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 [SAM9RL, CAP9] */ ++#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 PLL Start-up Time */ ++#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 */ +@@ -73,6 +73,7 @@ + #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) +@@ -89,12 +90,25 @@ + #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) ++#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_PCKR(n) (AT91_PMC + 0x40 + ((n) * 4)) /* Programmable Clock 0-4 Registers */ ++#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 */ +@@ -103,7 +117,7 @@ + #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 [AT91CAP9 only] */ ++#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 */ +-- +1.5.6.5 + +From 4651aaf6d53d6e17b323e6ccc929f34bb50aedf9 Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:21 +0000 +Subject: [PATCH] atmel_serial: fix hang in set_termios when crtscts is enabled + +After enabling hardware flow control, any subsequent termios call may hang +waiting for the transmitter to drain. This appears to be caused by a +busy-loop in set_termios() waiting for the transmitter to become empty, +which may take a very long time (or hang indefinitely) if the device at +the other end is blocking us. + +A quick look through the tty and serial_core code indicates that any +necessary flushing (which is optional) has already been done at this +point, so there's no need for the driver to flush the transmitter on its +own. + +Fix it by removing the busy-loop altogether. + +Tested-by: Eirik Aanonsen <[email protected]> +Signed-off-by: Haavard Skinnemoen <[email protected]> +Signed-off-by: Andrew Morton <[email protected]> +Signed-off-by: Alan Cox <[email protected]> +Signed-off-by: Linus Torvalds <[email protected]> +(cherry picked from commit 0ccad87012c6c2e7446e4dc0f0894cf182a5270a) + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11578 50fbe906-d41e-0410-8a96-31537896a350 +--- + drivers/serial/atmel_serial.c | 8 +++++--- + 1 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c +index b3497d7..338b15c 100644 +--- a/drivers/serial/atmel_serial.c ++++ b/drivers/serial/atmel_serial.c +@@ -1104,11 +1104,13 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, + /* update the per-port timeout */ + uart_update_timeout(port, termios->c_cflag, baud); + +- /* save/disable interrupts and drain transmitter */ ++ /* ++ * save/disable interrupts. The tty layer will ensure that the ++ * transmitter is empty if requested by the caller, so there's ++ * no need to wait for it here. ++ */ + imr = UART_GET_IMR(port); + UART_PUT_IDR(port, -1); +- while (!(UART_GET_CSR(port) & ATMEL_US_TXEMPTY)) +- cpu_relax(); + + /* disable receiver and transmitter */ + UART_PUT_CR(port, ATMEL_US_TXDIS | ATMEL_US_RXDIS); +-- +1.5.6.5 + +From 3302b2f2b77f3672be5977b89d3a4c5dc65f5793 Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:22 +0000 +Subject: [PATCH] USB: atmel_usba_udc: change way of specifying bias function + +The toggle_bias() function was specified differently for avr32 and at91 +architectures. Now, new at91 have the same behavior as avr32. +Consequently, we change to a particular chip function definition: only for +at91sam9rl. + +Signed-off-by: Nicolas Ferre <[email protected]> +Acked-by: Haavard Skinnemoen <[email protected]> +Acked-by: David Brownell <[email protected]> +Signed-off-by: Greg Kroah-Hartman <[email protected]> + +(cherry picked from commit e60c65d35951ef3527596442338c371ea16d55ed) + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11579 50fbe906-d41e-0410-8a96-31537896a350 +--- + drivers/usb/gadget/atmel_usba_udc.c | 16 ++++++++-------- + 1 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c +index 05c913c..d6ef3d5 100644 +--- a/drivers/usb/gadget/atmel_usba_udc.c ++++ b/drivers/usb/gadget/atmel_usba_udc.c +@@ -326,13 +326,7 @@ static int vbus_is_present(struct usba_udc *udc) + return 1; + } + +-#if defined(CONFIG_AVR32) +- +-static void toggle_bias(int is_on) +-{ +-} +- +-#elif defined(CONFIG_ARCH_AT91) ++#if defined(CONFIG_ARCH_AT91SAM9RL) + + #include <mach/at91_pmc.h> + +@@ -346,7 +340,13 @@ static void toggle_bias(int is_on) + at91_sys_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN)); + } + +-#endif /* CONFIG_ARCH_AT91 */ ++#else ++ ++static void toggle_bias(int is_on) ++{ ++} ++ ++#endif /* CONFIG_ARCH_AT91SAM9RL */ + + static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req) + { +-- +1.5.6.5 + +From 280aab6bc59331ee30ca7864101bbe4ba674569b Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:23 +0000 +Subject: [PATCH] Add MACB TX Buffer in SRAM support + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11580 50fbe906-d41e-0410-8a96-31537896a350 +--- + drivers/net/Kconfig | 6 ++++ + drivers/net/macb.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++- + drivers/net/macb.h | 9 ++++++ + 3 files changed, 85 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig +index 7048037..bd6e9f2 100644 +--- a/drivers/net/Kconfig ++++ b/drivers/net/Kconfig +@@ -228,6 +228,12 @@ config MACB + To compile this driver as a module, choose M here: the module + will be called macb. + ++config MACB_TX_SRAM ++ bool "Atmel MACB TX buffers in internal SRAM" ++ depends on NET_ETHERNET && MACB && (ARCH_AT91SAM9260 || ARCH_AT91SAM9263) ++ help ++ Use internal SRAM for TX buffers. ++ + source "drivers/net/arm/Kconfig" + + config AX88796 +diff --git a/drivers/net/macb.c b/drivers/net/macb.c +index e82aee4..8bfe99a 100644 +--- a/drivers/net/macb.c ++++ b/drivers/net/macb.c +@@ -33,9 +33,21 @@ + /* Make the IP header word-aligned (the ethernet header is 14 bytes) */ + #define RX_OFFSET 2 + +-#define TX_RING_SIZE 128 ++#if defined(CONFIG_ARCH_AT91) && defined(CONFIG_MACB_TX_SRAM) ++ #if defined(CONFIG_ARCH_AT91SAM9260) ++ #define TX_RING_SIZE 2 ++ #elif defined(CONFIG_ARCH_AT91SAM9263) ++ #define TX_RING_SIZE 32 ++ #endif ++ #define TX_BUFFER_SIZE 1536 ++ #define TX_RING_BYTES (sizeof(struct dma_desc) * TX_RING_SIZE) ++ #define TX_DMA_SIZE ((TX_RING_BYTES) + (TX_RING_SIZE) * (TX_BUFFER_SIZE)) ++#else ++ #define TX_RING_SIZE 128 ++ #define TX_RING_BYTES (sizeof(struct dma_desc) * TX_RING_SIZE) ++#endif ++ + #define DEF_TX_RING_PENDING (TX_RING_SIZE - 1) +-#define TX_RING_BYTES (sizeof(struct dma_desc) * TX_RING_SIZE) + + #define TX_RING_GAP(bp) \ + (TX_RING_SIZE - (bp)->tx_pending) +@@ -378,8 +390,10 @@ static void macb_tx(struct macb *bp) + + dev_dbg(&bp->pdev->dev, "skb %u (data %p) TX complete\n", + tail, skb->data); ++#if !defined(CONFIG_MACB_TX_SRAM) + dma_unmap_single(&bp->pdev->dev, rp->mapping, skb->len, + DMA_TO_DEVICE); ++#endif + bp->stats.tx_packets++; + bp->stats.tx_bytes += skb->len; + rp->skb = NULL; +@@ -635,8 +649,13 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) + + entry = bp->tx_head; + dev_dbg(&bp->pdev->dev, "Allocated ring entry %u\n", entry); ++#if defined(CONFIG_ARCH_AT91) && defined(CONFIG_MACB_TX_SRAM) ++ mapping = bp->tx_ring[entry].addr; ++ memcpy(bp->tx_buffers + entry * TX_BUFFER_SIZE, skb->data, len); ++#else + mapping = dma_map_single(&bp->pdev->dev, skb->data, + len, DMA_TO_DEVICE); ++#endif + bp->tx_skb[entry].skb = skb; + bp->tx_skb[entry].mapping = mapping; + dev_dbg(&bp->pdev->dev, "Mapped skb data %p to DMA addr %08lx\n", +@@ -647,7 +666,9 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) + if (entry == (TX_RING_SIZE - 1)) + ctrl |= MACB_BIT(TX_WRAP); + ++#if !defined(CONFIG_MACB_TX_SRAM) + bp->tx_ring[entry].addr = mapping; ++#endif + bp->tx_ring[entry].ctrl = ctrl; + wmb(); + +@@ -678,8 +699,12 @@ static void macb_free_consistent(struct macb *bp) + bp->rx_ring = NULL; + } + if (bp->tx_ring) { ++#if defined(CONFIG_ARCH_AT91) && defined(CONFIG_MACB_TX_SRAM) ++ iounmap((void *)bp->tx_ring); ++#else + dma_free_coherent(&bp->pdev->dev, TX_RING_BYTES, + bp->tx_ring, bp->tx_ring_dma); ++#endif + bp->tx_ring = NULL; + } + if (bp->rx_buffers) { +@@ -688,6 +713,11 @@ static void macb_free_consistent(struct macb *bp) + bp->rx_buffers, bp->rx_buffers_dma); + bp->rx_buffers = NULL; + } ++ ++#if defined(CONFIG_ARCH_AT91) && defined(CONFIG_MACB_TX_SRAM) ++ if (bp->tx_ring_dma) ++ release_mem_region(bp->tx_ring_dma, TX_DMA_SIZE); ++#endif + } + + static int macb_alloc_consistent(struct macb *bp) +@@ -708,14 +738,44 @@ static int macb_alloc_consistent(struct macb *bp) + "Allocated RX ring of %d bytes at %08lx (mapped %p)\n", + size, (unsigned long)bp->rx_ring_dma, bp->rx_ring); + ++#if defined(CONFIG_ARCH_AT91) && defined(CONFIG_MACB_TX_SRAM) ++#if defined(CONFIG_ARCH_AT91SAM9260) ++ if (request_mem_region(AT91SAM9260_SRAM0_BASE, TX_DMA_SIZE, "macb")) { ++ bp->tx_ring_dma = AT91SAM9260_SRAM0_BASE; ++ } else { ++ if (request_mem_region(AT91SAM9260_SRAM1_BASE, TX_DMA_SIZE, "macb")) { ++ bp->tx_ring_dma = AT91SAM9260_SRAM1_BASE; ++ } else { ++ printk(KERN_WARNING "Cannot request SRAM memory for TX ring, already used\n"); ++ return -EBUSY; ++ } ++ } ++#elif defined(CONFIG_ARCH_AT91SAM9263) ++ if (request_mem_region(AT91SAM9263_SRAM0_BASE, TX_DMA_SIZE, "macb")) { ++ bp->tx_ring_dma = AT91SAM9263_SRAM0_BASE; ++ } else { ++ printk(KERN_WARNING "Cannot request SRAM memory for TX ring, already used\n"); ++ return -EBUSY; ++ } ++#endif ++ ++ bp->tx_ring = ioremap(bp->tx_ring_dma, TX_DMA_SIZE); ++ if (!bp->tx_ring) ++ return -ENOMEM; ++ ++ bp->tx_buffers_dma = bp->tx_ring_dma + TX_RING_BYTES; ++ bp->tx_buffers = (char *) bp->tx_ring + TX_RING_BYTES; ++#else + size = TX_RING_BYTES; + bp->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size, + &bp->tx_ring_dma, GFP_KERNEL); + if (!bp->tx_ring) + goto out_err; ++ + dev_dbg(&bp->pdev->dev, + "Allocated TX ring of %d bytes at %08lx (mapped %p)\n", + size, (unsigned long)bp->tx_ring_dma, bp->tx_ring); ++#endif + + size = RX_RING_SIZE * RX_BUFFER_SIZE; + bp->rx_buffers = dma_alloc_coherent(&bp->pdev->dev, size, +@@ -746,10 +806,18 @@ static void macb_init_rings(struct macb *bp) + } + bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP); + ++#if defined(CONFIG_ARCH_AT91) && defined(CONFIG_MACB_TX_SRAM) ++ for (i = 0; i < TX_RING_SIZE; i++) { ++ bp->tx_ring[i].addr = bp->tx_buffers_dma + i * TX_BUFFER_SIZE; ++ bp->tx_ring[i].ctrl = MACB_BIT(TX_USED); ++ } ++#else + for (i = 0; i < TX_RING_SIZE; i++) { + bp->tx_ring[i].addr = 0; + bp->tx_ring[i].ctrl = MACB_BIT(TX_USED); + } ++#endif ++ + bp->tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP); + + bp->rx_tail = bp->tx_head = bp->tx_tail = 0; +diff --git a/drivers/net/macb.h b/drivers/net/macb.h +index d3212f6..e27dd43 100644 +--- a/drivers/net/macb.h ++++ b/drivers/net/macb.h +@@ -369,8 +369,13 @@ struct macb { + struct dma_desc *tx_ring; + struct ring_info *tx_skb; + ++#if defined(CONFIG_ARCH_AT91) ++ void *tx_buffers; ++#endif ++ + spinlock_t lock; + struct platform_device *pdev; ++ struct clk *macb_clk; + struct clk *pclk; + struct clk *hclk; + struct net_device *dev; +@@ -382,6 +387,10 @@ struct macb { + dma_addr_t tx_ring_dma; + dma_addr_t rx_buffers_dma; + ++#if defined(CONFIG_ARCH_AT91) ++ dma_addr_t tx_buffers_dma; ++#endif ++ + unsigned int rx_pending, tx_pending; + + struct mii_bus *mii_bus; +-- +1.5.6.5 + +From e0490c5300f12e886b89224bb41f03ffff02de04 Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:23 +0000 +Subject: [PATCH] 5569/1: at91: Support for at91sam9g45: clocks management + +Add the at91sam9g45 series support to the AT91 generic clock file. +This takes care of the particularities of the PMC for this series. +It also takes advantage of the management by functionalities of +those PLLs and clocks. + +Signed-off-by: Nicolas Ferre <[email protected]> +Acked-by: Andrew Victor <[email protected]> +Signed-off-by: Russell King <[email protected]> + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11581 50fbe906-d41e-0410-8a96-31537896a350 +--- + arch/arm/mach-at91/clock.c | 61 +++++++++++++++++++++++++++++++++++++------ + 1 files changed, 52 insertions(+), 9 deletions(-) + +diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c +index c09148c..b83bfad 100644 +--- a/arch/arm/mach-at91/clock.c ++++ b/arch/arm/mach-at91/clock.c +@@ -48,20 +48,25 @@ + * Chips have some kind of clocks : group them by functionality + */ + #define cpu_has_utmi() ( cpu_is_at91cap9() \ +- || cpu_is_at91sam9rl()) ++ || cpu_is_at91sam9rl() \ ++ || cpu_is_at91sam9g45()) + +-#define cpu_has_800M_plla() (cpu_is_at91sam9g20()) ++#define cpu_has_800M_plla() ( cpu_is_at91sam9g20() \ ++ || cpu_is_at91sam9g45()) + +-#define cpu_has_pllb() (!cpu_is_at91sam9rl()) ++#define cpu_has_300M_plla() (0) + +-#define cpu_has_upll() (0) ++#define cpu_has_pllb() (!(cpu_is_at91sam9rl() \ ++ || cpu_is_at91sam9g45())) ++ ++#define cpu_has_upll() (cpu_is_at91sam9g45()) + + /* USB host HS & FS */ + #define cpu_has_uhp() (!cpu_is_at91sam9rl()) + + /* USB device FS only */ +-#define cpu_has_udpfs() (!cpu_is_at91sam9rl()) +- ++#define cpu_has_udpfs() (!(cpu_is_at91sam9rl() \ ++ || cpu_is_at91sam9g45())) + + static LIST_HEAD(clocks); + static DEFINE_SPINLOCK(clk_lock); +@@ -134,6 +139,13 @@ 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; ++ } ++ + if (is_on) { + is_on = AT91_PMC_LOCKU; + at91_sys_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask); +@@ -328,6 +340,7 @@ long clk_round_rate(struct clk *clk, unsigned long rate) + unsigned long flags; + unsigned prescale; + unsigned long actual; ++ unsigned long prev = ULONG_MAX; + + if (!clk_is_programmable(clk)) + return -EINVAL; +@@ -335,8 +348,16 @@ long clk_round_rate(struct clk *clk, unsigned long rate) + + actual = clk->parent->rate_hz; + for (prescale = 0; prescale < 7; prescale++) { +- if (actual && actual <= rate) ++ if (actual > rate) ++ prev = actual; ++ ++ if (actual && actual <= rate) { ++ if ((prev - rate) < (rate - actual)) { ++ actual = prev; ++ prescale--; ++ } + break; ++ } + actual >>= 1; + } + +@@ -391,6 +412,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent) + return -EBUSY; + if (!clk_is_primary(parent) || !clk_is_programmable(clk)) + return -EINVAL; ++ ++ if (cpu_is_at91sam9rl() && parent->id == AT91_PMC_CSS_PLLB) ++ return -EINVAL; ++ + spin_lock_irqsave(&clk_lock, flags); + + clk->rate_hz = parent->rate_hz; +@@ -655,6 +680,7 @@ int __init at91_clock_init(unsigned long main_clock) + { + unsigned tmp, freq, mckr; + int i; ++ int pll_overclock = false; + + /* + * When the bootloader initialized the main oscillator correctly, +@@ -672,10 +698,24 @@ int __init at91_clock_init(unsigned long 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_800M_plla() && plla.rate_hz > 209000000) +- || (cpu_has_800M_plla() && plla.rate_hz > 800000000)) ++ if (cpu_has_300M_plla()) { ++ if (plla.rate_hz > 300000000) ++ pll_overclock = true; ++ } else if (cpu_has_800M_plla()) { ++ if (plla.rate_hz > 800000000) ++ pll_overclock = true; ++ } else { ++ if (plla.rate_hz > 209000000) ++ pll_overclock = true; ++ } ++ 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); ++ plla.rate_hz /= (1 << ((mckr & AT91_PMC_PLLADIV2) >> 12)); /* plla divisor by 2 */ ++ } ++ + if (cpu_has_upll() && !cpu_has_pllb()) { + /* setup UTMI clock as the fourth primary clock + * (instead of pllb) */ +@@ -718,6 +758,9 @@ 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()) { ++ 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 */ + } +-- +1.5.6.5 + +From a5496d94f287f8d5e9e7fa626c2839a4d6aff097 Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:24 +0000 +Subject: [PATCH] 5571/1: at91: Basic support for at91sam9g45 series: header files. + +AT91sam9g45 series is an ARM 926ej-s SOC family clocked at 400/133MHz. +It embedds USB high speed host and device, LCD, DDR2 RAM, and a full set of +peripherals. + +Here is the basic header file support for this product series. + +Signed-off-by: Nicolas Ferre <[email protected]> +Acked-by: Andrew Victor <[email protected]> +Signed-off-by: Russell King <[email protected]> +(cherry picked from commit fddcc0ae58edefeb7ac1e460411d7dfbe8ebdacc) + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11582 50fbe906-d41e-0410-8a96-31537896a350 +--- + arch/arm/mach-at91/include/mach/at91sam9g45.h | 138 ++++++++++++++++++ + .../mach-at91/include/mach/at91sam9g45_matrix.h | 153 ++++++++++++++++++++ + arch/arm/mach-at91/include/mach/cpu.h | 16 ++ + arch/arm/mach-at91/include/mach/hardware.h | 2 + + arch/arm/mach-at91/include/mach/timex.h | 5 + + 5 files changed, 314 insertions(+), 0 deletions(-) + create mode 100644 arch/arm/mach-at91/include/mach/at91sam9g45.h + create mode 100644 arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h + +diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45.h b/arch/arm/mach-at91/include/mach/at91sam9g45.h +new file mode 100644 +index 0000000..2c42cf5 +--- /dev/null ++++ b/arch/arm/mach-at91/include/mach/at91sam9g45.h +@@ -0,0 +1,138 @@ ++/* ++ * Chip-specific header file for the AT91SAM9G45 family ++ * ++ * Copyright (C) 2008-2009 Atmel Corporation. ++ * ++ * Common definitions. ++ * Based on AT91SAM9G45 preliminary datasheet. ++ * ++ * 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 AT91SAM9G45_H ++#define AT91SAM9G45_H ++ ++/* ++ * 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 */ ++#define AT91SAM9G45_ID_PIODE 5 /* Parallel I/O Controller D and E */ ++#define AT91SAM9G45_ID_TRNG 6 /* True Random Number Generator */ ++#define AT91SAM9G45_ID_US0 7 /* USART 0 */ ++#define AT91SAM9G45_ID_US1 8 /* USART 1 */ ++#define AT91SAM9G45_ID_US2 9 /* USART 2 */ ++#define AT91SAM9G45_ID_US3 10 /* USART 3 */ ++#define AT91SAM9G45_ID_MCI0 11 /* High Speed Multimedia Card Interface 0 */ ++#define AT91SAM9G45_ID_TWI0 12 /* Two-Wire Interface 0 */ ++#define AT91SAM9G45_ID_TWI1 13 /* Two-Wire Interface 1 */ ++#define AT91SAM9G45_ID_SPI0 14 /* Serial Peripheral Interface 0 */ ++#define AT91SAM9G45_ID_SPI1 15 /* Serial Peripheral Interface 1 */ ++#define AT91SAM9G45_ID_SSC0 16 /* Synchronous Serial Controller 0 */ ++#define AT91SAM9G45_ID_SSC1 17 /* Synchronous Serial Controller 1 */ ++#define AT91SAM9G45_ID_TCB 18 /* Timer Counter 0, 1, 2, 3, 4 and 5 */ ++#define AT91SAM9G45_ID_PWMC 19 /* Pulse Width Modulation Controller */ ++#define AT91SAM9G45_ID_TSC 20 /* Touch Screen ADC Controller */ ++#define AT91SAM9G45_ID_DMA 21 /* DMA Controller */ ++#define AT91SAM9G45_ID_UHPHS 22 /* USB Host High Speed */ ++#define AT91SAM9G45_ID_LCDC 23 /* LCD Controller */ ++#define AT91SAM9G45_ID_AC97C 24 /* AC97 Controller */ ++#define AT91SAM9G45_ID_EMAC 25 /* Ethernet MAC */ ++#define AT91SAM9G45_ID_ISI 26 /* Image Sensor Interface */ ++#define AT91SAM9G45_ID_UDPHS 27 /* USB Device High Speed */ ++#define AT91SAM9G45_ID_AESTDESSHA 28 /* AES + T-DES + SHA */ ++#define AT91SAM9G45_ID_MCI1 29 /* High Speed Multimedia Card Interface 1 */ ++#define AT91SAM9G45_ID_VDEC 30 /* Video Decoder */ ++#define AT91SAM9G45_ID_IRQ0 31 /* Advanced Interrupt Controller */ ++ ++/* ++ * User Peripheral physical base addresses. ++ */ ++#define AT91SAM9G45_BASE_UDPHS 0xfff78000 ++#define AT91SAM9G45_BASE_TCB0 0xfff7c000 ++#define AT91SAM9G45_BASE_TC0 0xfff7c000 ++#define AT91SAM9G45_BASE_TC1 0xfff7c040 ++#define AT91SAM9G45_BASE_TC2 0xfff7c080 ++#define AT91SAM9G45_BASE_MCI0 0xfff80000 ++#define AT91SAM9G45_BASE_TWI0 0xfff84000 ++#define AT91SAM9G45_BASE_TWI1 0xfff88000 ++#define AT91SAM9G45_BASE_US0 0xfff8c000 ++#define AT91SAM9G45_BASE_US1 0xfff90000 ++#define AT91SAM9G45_BASE_US2 0xfff94000 ++#define AT91SAM9G45_BASE_US3 0xfff98000 ++#define AT91SAM9G45_BASE_SSC0 0xfff9c000 ++#define AT91SAM9G45_BASE_SSC1 0xfffa0000 ++#define AT91SAM9G45_BASE_SPI0 0xfffa4000 ++#define AT91SAM9G45_BASE_SPI1 0xfffa8000 ++#define AT91SAM9G45_BASE_AC97C 0xfffac000 ++#define AT91SAM9G45_BASE_TSC 0xfffb0000 ++#define AT91SAM9G45_BASE_ISI 0xfffb4000 ++#define AT91SAM9G45_BASE_PWMC 0xfffb8000 ++#define AT91SAM9G45_BASE_EMAC 0xfffbc000 ++#define AT91SAM9G45_BASE_AES 0xfffc0000 ++#define AT91SAM9G45_BASE_TDES 0xfffc4000 ++#define AT91SAM9G45_BASE_SHA 0xfffc8000 ++#define AT91SAM9G45_BASE_TRNG 0xfffcc000 ++#define AT91SAM9G45_BASE_MCI1 0xfffd0000 ++#define AT91SAM9G45_BASE_TCB1 0xfffd4000 ++#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) ++ */ ++#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 ++ ++/* ++ * Internal Memory. ++ */ ++#define AT91SAM9G45_SRAM_BASE 0x00300000 /* Internal SRAM base address */ ++#define AT91SAM9G45_SRAM_SIZE SZ_64K /* Internal SRAM size (64Kb) */ ++ ++#define AT91SAM9G45_ROM_BASE 0x00400000 /* Internal ROM base address */ ++#define AT91SAM9G45_ROM_SIZE SZ_64K /* Internal ROM size (64Kb) */ ++ ++#define AT91SAM9G45_LCDC_BASE 0x00500000 /* LCD Controller */ ++#define AT91SAM9G45_UDPHS_FIFO 0x00600000 /* USB Device HS controller */ ++#define AT91SAM9G45_OHCI_BASE 0x00700000 /* USB Host controller (OHCI) */ ++#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 ++ ++#endif +diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h +new file mode 100644 +index 0000000..c972d60 +--- /dev/null ++++ b/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h +@@ -0,0 +1,153 @@ ++/* ++ * Matrix-centric header file for the AT91SAM9G45 family ++ * ++ * Copyright (C) 2008-2009 Atmel Corporation. ++ * ++ * Memory Controllers (MATRIX, EBI) - System peripherals registers. ++ * Based on AT91SAM9G45 preliminary datasheet. ++ * ++ * 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 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_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_ULBT_THIRTYTWO (5 << 0) ++#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_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) ++#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_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_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_MATRIX_TCMR (AT91_MATRIX + 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) ++#define AT91_MATRIX_DTCM_SIZE (0xf << 4) /* Size of DTCM enabled memory block */ ++#define AT91_MATRIX_DTCM_0 (0 << 4) ++#define AT91_MATRIX_DTCM_32 (6 << 4) ++#define AT91_MATRIX_DTCM_64 (7 << 4) ++#define AT91_MATRIX_TCM_NWS (0x1 << 11) /* Wait state TCM register */ ++#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 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_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_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_CF0 (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_CF1 (1 << 5) ++#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_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/cpu.h b/arch/arm/mach-at91/include/mach/cpu.h +index 43d88fb..64af079 100644 +--- a/arch/arm/mach-at91/include/mach/cpu.h ++++ b/arch/arm/mach-at91/include/mach/cpu.h +@@ -23,6 +23,7 @@ + #define ARCH_ID_AT91SAM9263 0x019607a0 + #define ARCH_ID_AT91SAM9G20 0x019905a0 + #define ARCH_ID_AT91SAM9RL64 0x019b03a0 ++#define ARCH_ID_AT91SAM9G45 0x819b05a0 + #define ARCH_ID_AT91CAP9 0x039A03A0 + + #define ARCH_ID_AT91SAM9XE128 0x329973a0 +@@ -41,6 +42,15 @@ static inline unsigned long at91_cpu_identify(void) + return (at91_sys_read(AT91_DBGU_CIDR) & ~AT91_CIDR_VERSION); + } + ++#define ARCH_EXID_AT91SAM9M11 0x00000001 ++#define ARCH_EXID_AT91SAM9M10 0x00000002 ++#define ARCH_EXID_AT91SAM9G45 0x00000004 ++ ++static inline unsigned long at91_exid_identify(void) ++{ ++ return at91_sys_read(AT91_DBGU_EXID); ++} ++ + + #define ARCH_FAMILY_AT91X92 0x09200000 + #define ARCH_FAMILY_AT91SAM9 0x01900000 +@@ -101,6 +111,12 @@ static inline unsigned long at91cap9_rev_identify(void) + #define cpu_is_at91sam9rl() (0) + #endif + ++#ifdef CONFIG_ARCH_AT91SAM9G45 ++#define cpu_is_at91sam9g45() (at91_cpu_identify() == ARCH_ID_AT91SAM9G45) ++#else ++#define cpu_is_at91sam9g45() (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) +diff --git a/arch/arm/mach-at91/include/mach/hardware.h b/arch/arm/mach-at91/include/mach/hardware.h +index e045996..a747d37 100644 +--- a/arch/arm/mach-at91/include/mach/hardware.h ++++ b/arch/arm/mach-at91/include/mach/hardware.h +@@ -26,6 +26,8 @@ + #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) +diff --git a/arch/arm/mach-at91/include/mach/timex.h b/arch/arm/mach-at91/include/mach/timex.h +index 55b6b9e..5abdf73 100644 +--- a/arch/arm/mach-at91/include/mach/timex.h ++++ b/arch/arm/mach-at91/include/mach/timex.h +@@ -66,6 +66,11 @@ + #endif + #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 +-- +1.5.6.5 + +From 2d79574469d7a58cad231b77a7c709be2e275b44 Mon Sep 17 00:00:00 2001 +From: nferre <nferre@50fbe906-d41e-0410-8a96-31537896a350> +Date: Wed, 14 Oct 2009 13:31:25 +0000 +Subject: [PATCH] 5572/1: at91: Support for at91sam9g45 series: core chip & board support + +Here are the at91 specific files dedicated to the at91sam9g45 series. They +mimic the traditional at91 way of managing chips & boards. + +The first board that embeds at91sam9g45 chip is the AT91SAM9G45-EKES. In +the future, the main board for this 9g45 series will be the +AT91SAM9M10G45-EK (I choose this last name for the board file). + +Simple drivers are enabled in _devices and board- files. Newer peripheral +support will be added in future patches. + +Incuded peripherals support (for now): +- USART +- SPI +- Ethernet +- NAND flash +- LCD +- gpio/joystick/buttons +- leds and pwm + +Signed-off-by: Nicolas Ferre <[email protected]> +Acked-by: Andrew Victor <[email protected]> +Signed-off-by: Russell King <[email protected]> + +git-svn-id: svn://rfolxts01.rfo.atmel.com/at91_sandbox/linux-2.6.x/branches/linux-2.6.30-at91@11583 50fbe906-d41e-0410-8a96-31537896a350 +--- + arch/arm/mach-at91/Kconfig | 26 +- + arch/arm/mach-at91/Makefile | 4 + + arch/arm/mach-at91/Makefile.boot | 4 + + arch/arm/mach-at91/at91sam9g45.c | 360 +++++++++ + arch/arm/mach-at91/at91sam9g45_devices.c | 1230 ++++++++++++++++++++++++++++++ + arch/arm/mach-at91/board-sam9m10g45ek.c | 389 ++++++++++ + arch/arm/mach-at91/generic.h | 2 + + arch/arm/mach-at91/include/mach/board.h | 8 +- + drivers/net/Kconfig | 2 +- + drivers/video/Kconfig | 2 +- + 10 files changed, 2022 insertions(+), 5 deletions(-) + create mode 100644 arch/arm/mach-at91/at91sam9g45.c + create mode 100644 arch/arm/mach-at91/at91sam9g45_devices.c + create mode 100644 arch/arm/mach-at91/board-sam9m10g45ek.c + +diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig +index 9db021e..6ea88b4 100644 +--- a/arch/arm/mach-at91/Kconfig ++++ b/arch/arm/mach-at91/Kconfig +@@ -41,6 +41,12 @@ config ARCH_AT91SAM9G20 + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + ++config ARCH_AT91SAM9G45 ++ bool "AT91SAM9G45" ++ select CPU_ARM926T ++ select GENERIC_TIME ++ select GENERIC_CLOCKEVENTS ++ + config ARCH_AT91CAP9 + bool "AT91CAP9" + select CPU_ARM926T +@@ -359,6 +365,22 @@ endif + + # ---------------------------------------------------------- + ++if ARCH_AT91SAM9G45 ++ ++comment "AT91SAM9G45 Board Type" ++ ++config MACH_AT91SAM9G45EKES ++ bool "Atmel AT91SAM9G45-EKES Evaluation Kit" ++ depends on ARCH_AT91SAM9G45 ++ 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 ++ ++# ---------------------------------------------------------- ++ + if ARCH_AT91CAP9 + + comment "AT91CAP9 Board Type" +@@ -415,7 +437,7 @@ config MTD_AT91_DATAFLASH_CARD + + config MTD_NAND_ATMEL_BUSWIDTH_16 + bool "Enable 16-bit data bus interface to NAND flash" +- depends on (MACH_AT91SAM9260EK || MACH_AT91SAM9261EK || MACH_AT91SAM9263EK || MACH_AT91SAM9G20EK || MACH_AT91CAP9ADK || MACH_AT572D940HFEB) ++ depends on (MACH_AT91SAM9260EK || MACH_AT91SAM9261EK || MACH_AT91SAM9263EK || MACH_AT91SAM9G20EK || MACH_AT91SAM9G45EKES || MACH_AT91CAP9ADK || MACH_AT572D940HFEB) + help + On AT91SAM926x boards both types of NAND flash can be present + (8 and 16 bit data bus width). +@@ -477,7 +499,7 @@ config AT91_EARLY_USART2 + + config AT91_EARLY_USART3 + bool "USART3" +- depends on (ARCH_AT91RM9200 || ARCH_AT91SAM9RL || ARCH_AT91SAM9260 || ARCH_AT91SAM9G20) ++ depends on (ARCH_AT91RM9200 || ARCH_AT91SAM9RL || ARCH_AT91SAM9260 || ARCH_AT91SAM9G20 || ARCH_AT91SAM9G45) + + config AT91_EARLY_USART4 + bool "USART4" +diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile +index cd2c2f1..cf31340 100644 +--- a/arch/arm/mach-at91/Makefile ++++ b/arch/arm/mach-at91/Makefile +@@ -16,6 +16,7 @@ obj-$(CONFIG_ARCH_AT91SAM9261) += at91sam9261.o at91sam926x_time.o at91sam9261_d + obj-$(CONFIG_ARCH_AT91SAM9263) += at91sam9263.o at91sam926x_time.o at91sam9263_devices.o sam9_smc.o + obj-$(CONFIG_ARCH_AT91SAM9RL) += at91sam9rl.o at91sam926x_time.o at91sam9rl_devices.o sam9_smc.o + obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.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_ARCH_AT91X40) += at91x40.o at91x40_time.o +@@ -66,6 +67,9 @@ obj-$(CONFIG_MACH_USB_A9G20) += board-usb-a9g20.o + obj-$(CONFIG_MACH_QIL_A9G20) += board-qil-a9g20.o + obj-$(CONFIG_MACH_SBC35_A9G20) += board-sbc35-a9g20.o + ++# AT91SAM9G45 board-specific support ++obj-$(CONFIG_MACH_AT91SAM9G45EKES) += board-sam9m10g45ek.o ++ + # AT91CAP9 board-specific support + obj-$(CONFIG_MACH_AT91CAP9ADK) += board-cap9adk.o + +diff --git a/arch/arm/mach-at91/Makefile.boot b/arch/arm/mach-at91/Makefile.boot +index 071a250..3462b81 100644 +--- a/arch/arm/mach-at91/Makefile.boot ++++ b/arch/arm/mach-at91/Makefile.boot +@@ -7,6 +7,10 @@ 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 ++params_phys-y := 0x70000100 ++initrd_phys-y := 0x70410000 + else + zreladdr-y := 0x20008000 + params_phys-y := 0x20000100 +diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c +new file mode 100644 +index 0000000..85166b7 +--- /dev/null ++++ b/arch/arm/mach-at91/at91sam9g45.c +@@ -0,0 +1,360 @@ ++/* ++ * Chip-specific setup code for the AT91SAM9G45 family ++ * ++ * Copyright (C) 2009 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/at91sam9g45.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 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, ++ } ++}; ++ ++/* -------------------------------------------------------------------- ++ * Clocks ++ * -------------------------------------------------------------------- */ ++ ++/* ++ * The peripheral clocks. ++ */ ++static struct clk pioA_clk = { ++ .name = "pioA_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_PIOA, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk pioB_clk = { ++ .name = "pioB_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_PIOB, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk pioC_clk = { ++ .name = "pioC_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_PIOC, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk pioDE_clk = { ++ .name = "pioDE_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_PIODE, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk usart0_clk = { ++ .name = "usart0_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_US0, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk usart1_clk = { ++ .name = "usart1_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_US1, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk usart2_clk = { ++ .name = "usart2_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_US2, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk usart3_clk = { ++ .name = "usart3_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_US3, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk mmc0_clk = { ++ .name = "mci0_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_MCI0, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk twi0_clk = { ++ .name = "twi0_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_TWI0, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk twi1_clk = { ++ .name = "twi1_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_TWI1, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk spi0_clk = { ++ .name = "spi0_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_SPI0, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk spi1_clk = { ++ .name = "spi1_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_SPI1, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk ssc0_clk = { ++ .name = "ssc0_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_SSC0, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk ssc1_clk = { ++ .name = "ssc1_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_SSC1, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk tcb_clk = { ++ .name = "tcb_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_TCB, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk pwm_clk = { ++ .name = "pwm_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_PWMC, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk tsc_clk = { ++ .name = "tsc_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_TSC, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk dma_clk = { ++ .name = "dma_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_DMA, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk uhphs_clk = { ++ .name = "uhphs_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_UHPHS, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk lcdc_clk = { ++ .name = "lcdc_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_LCDC, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk ac97_clk = { ++ .name = "ac97_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_AC97C, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk macb_clk = { ++ .name = "macb_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_EMAC, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk isi_clk = { ++ .name = "isi_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_ISI, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk udphs_clk = { ++ .name = "udphs_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_UDPHS, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++static struct clk mmc1_clk = { ++ .name = "mci1_clk", ++ .pmc_mask = 1 << AT91SAM9G45_ID_MCI1, ++ .type = CLK_TYPE_PERIPHERAL, ++}; ++ ++/* One additional fake clock for ohci */ ++static struct clk ohci_clk = { ++ .name = "ohci_clk", ++ .pmc_mask = 0, ++ .type = CLK_TYPE_PERIPHERAL, ++ .parent = &uhphs_clk, ++}; ++ ++static struct clk *periph_clocks[] __initdata = { ++ &pioA_clk, ++ &pioB_clk, ++ &pioC_clk, ++ &pioDE_clk, ++ &usart0_clk, ++ &usart1_clk, ++ &usart2_clk, ++ &usart3_clk, ++ &mmc0_clk, ++ &twi0_clk, ++ &twi1_clk, ++ &spi0_clk, ++ &spi1_clk, ++ &ssc0_clk, ++ &ssc1_clk, ++ &tcb_clk, ++ &pwm_clk, ++ &tsc_clk, ++ &dma_clk, ++ &uhphs_clk, ++ &lcdc_clk, ++ &ac97_clk, ++ &macb_clk, ++ &isi_clk, ++ &udphs_clk, ++ &mmc1_clk, ++ // irq0 ++ &ohci_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 at91sam9g45_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); ++} ++ ++/* -------------------------------------------------------------------- ++ * GPIO ++ * -------------------------------------------------------------------- */ ++ ++static struct at91_gpio_bank at91sam9g45_gpio[] = { ++ { ++ .id = AT91SAM9G45_ID_PIOA, ++ .offset = AT91_PIOA, ++ .clock = &pioA_clk, ++ }, { ++ .id = AT91SAM9G45_ID_PIOB, ++ .offset = AT91_PIOB, ++ .clock = &pioB_clk, ++ }, { ++ .id = AT91SAM9G45_ID_PIOC, ++ .offset = AT91_PIOC, ++ .clock = &pioC_clk, ++ }, { ++ .id = AT91SAM9G45_ID_PIODE, ++ .offset = AT91_PIOD, ++ .clock = &pioDE_clk, ++ }, { ++ .id = AT91SAM9G45_ID_PIODE, ++ .offset = AT91_PIOE, ++ .clock = &pioDE_clk, ++ } ++}; ++ ++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) ++{ ++ /* Map peripherals */ ++ iotable_init(at91sam9g45_io_desc, ARRAY_SIZE(at91sam9g45_io_desc)); ++ ++ at91_arch_reset = at91sam9g45_reset; ++ pm_power_off = at91sam9g45_poweroff; ++ at91_extern_irq = (1 << AT91SAM9G45_ID_IRQ0); ++ ++ /* Init clock subsystem */ ++ at91_clock_init(main_clock); ++ ++ /* Register the processor-specific clocks */ ++ at91sam9g45_register_clocks(); ++ ++ /* Register GPIO subsystem */ ++ at91_gpio_init(at91sam9g45_gpio, 5); ++} ++ ++/* -------------------------------------------------------------------- ++ * Interrupt initialization ++ * -------------------------------------------------------------------- */ ++ ++/* ++ * The default interrupt priority levels (0 = lowest, 7 = highest). ++ */ ++static unsigned int at91sam9g45_default_irq_priority[NR_AIC_IRQS] __initdata = { ++ 7, /* Advanced Interrupt Controller (FIQ) */ ++ 7, /* System Peripherals */ ++ 1, /* Parallel IO Controller A */ ++ 1, /* Parallel IO Controller B */ ++ 1, /* Parallel IO Controller C */ ++ 1, /* Parallel IO Controller D and E */ ++ 0, ++ 5, /* USART 0 */ ++ 5, /* USART 1 */ ++ 5, /* USART 2 */ ++ 5, /* USART 3 */ ++ 0, /* Multimedia Card Interface 0 */ ++ 6, /* Two-Wire Interface 0 */ ++ 6, /* Two-Wire Interface 1 */ ++ 5, /* Serial Peripheral Interface 0 */ ++ 5, /* Serial Peripheral Interface 1 */ ++ 4, /* Serial Synchronous Controller 0 */ ++ 4, /* Serial Synchronous Controller 1 */ ++ 0, /* Timer Counter 0, 1, 2, 3, 4 and 5 */ ++ 0, /* Pulse Width Modulation Controller */ ++ 0, /* Touch Screen Controller */ ++ 0, /* DMA Controller */ ++ 2, /* USB Host High Speed port */ ++ 3, /* LDC Controller */ ++ 5, /* AC97 Controller */ ++ 3, /* Ethernet */ ++ 0, /* Image Sensor Interface */ ++ 2, /* USB Device High speed port */ ++ 0, ++ 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(); ++} +diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c +new file mode 100644 +index 0000000..d746e86 +--- /dev/null ++++ b/arch/arm/mach-at91/at91sam9g45_devices.c +@@ -0,0 +1,1230 @@ ++/* ++ * On-Chip devices setup code for the AT91SAM9G45 family ++ * ++ * Copyright (C) 2009 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 <linux/dma-mapping.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/at91sam9g45.h> ++#include <mach/at91sam9g45_matrix.h> ++#include <mach/at91sam9_smc.h> ++ ++#include "generic.h" ++ ++ ++/* -------------------------------------------------------------------- ++ * USB Host (OHCI) ++ * -------------------------------------------------------------------- */ ++ ++#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_ohci_data; ++ ++static struct resource usbh_ohci_resources[] = { ++ [0] = { ++ .start = AT91SAM9G45_OHCI_BASE, ++ .end = AT91SAM9G45_OHCI_BASE + SZ_1M - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_UHPHS, ++ .end = AT91SAM9G45_ID_UHPHS, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91_usbh_ohci_device = { ++ .name = "at91_ohci", ++ .id = -1, ++ .dev = { ++ .dma_mask = &ohci_dmamask, ++ .coherent_dma_mask = DMA_BIT_MASK(32), ++ .platform_data = &usbh_ohci_data, ++ }, ++ .resource = usbh_ohci_resources, ++ .num_resources = ARRAY_SIZE(usbh_ohci_resources), ++}; ++ ++void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data) ++{ ++ int i; ++ ++ if (!data) ++ return; ++ ++ /* 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_ohci_data = *data; ++ platform_device_register(&at91_usbh_ohci_device); ++} ++#else ++void __init at91_add_device_usbh_ohci(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 = AT91SAM9G45_UDPHS_FIFO, ++ .end = AT91SAM9G45_UDPHS_FIFO + SZ_512K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_BASE_UDPHS, ++ .end = AT91SAM9G45_BASE_UDPHS + SZ_1K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [2] = { ++ .start = AT91SAM9G45_ID_UDPHS, ++ .end = AT91SAM9G45_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[] __initdata = { ++ EP("ep0", 0, 64, 1, 0, 0), ++ EP("ep1", 1, 1024, 2, 1, 1), ++ EP("ep2", 2, 1024, 2, 1, 1), ++ EP("ep3", 3, 1024, 3, 1, 0), ++ EP("ep4", 4, 1024, 3, 1, 0), ++ EP("ep5", 5, 1024, 3, 1, 1), ++ EP("ep6", 6, 1024, 3, 1, 1), ++}; ++ ++#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[7]; ++} 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) ++{ ++ 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 = AT91SAM9G45_BASE_EMAC, ++ .end = AT91SAM9G45_BASE_EMAC + SZ_16K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_EMAC, ++ .end = AT91SAM9G45_ID_EMAC, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91sam9g45_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_PA17, 0); /* ETXCK_EREFCK */ ++ at91_set_A_periph(AT91_PIN_PA15, 0); /* ERXDV */ ++ at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */ ++ at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */ ++ at91_set_A_periph(AT91_PIN_PA16, 0); /* ERXER */ ++ at91_set_A_periph(AT91_PIN_PA14, 0); /* ETXEN */ ++ at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX0 */ ++ at91_set_A_periph(AT91_PIN_PA11, 0); /* ETX1 */ ++ at91_set_A_periph(AT91_PIN_PA19, 0); /* EMDIO */ ++ at91_set_A_periph(AT91_PIN_PA18, 0); /* EMDC */ ++ ++ if (!data->is_rmii) { ++ at91_set_B_periph(AT91_PIN_PA29, 0); /* ECRS */ ++ at91_set_B_periph(AT91_PIN_PA30, 0); /* ECOL */ ++ at91_set_B_periph(AT91_PIN_PA8, 0); /* ERX2 */ ++ at91_set_B_periph(AT91_PIN_PA9, 0); /* ERX3 */ ++ at91_set_B_periph(AT91_PIN_PA28, 0); /* ERXCK */ ++ at91_set_B_periph(AT91_PIN_PA6, 0); /* ETX2 */ ++ at91_set_B_periph(AT91_PIN_PA7, 0); /* ETX3 */ ++ at91_set_B_periph(AT91_PIN_PA27, 0); /* ETXER */ ++ } ++ ++ eth_data = *data; ++ platform_device_register(&at91sam9g45_eth_device); ++} ++#else ++void __init at91_add_device_eth(struct at91_eth_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 at91sam9g45_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(&at91sam9g45_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_i2c0 = { ++ .sda_pin = AT91_PIN_PA20, ++ .sda_is_open_drain = 1, ++ .scl_pin = AT91_PIN_PA21, ++ .scl_is_open_drain = 1, ++ .udelay = 2, /* ~100 kHz */ ++}; ++ ++static struct platform_device at91sam9g45_twi0_device = { ++ .name = "i2c-gpio", ++ .id = 0, ++ .dev.platform_data = &pdata_i2c0, ++}; ++ ++static struct i2c_gpio_platform_data pdata_i2c1 = { ++ .sda_pin = AT91_PIN_PB10, ++ .sda_is_open_drain = 1, ++ .scl_pin = AT91_PIN_PB11, ++ .scl_is_open_drain = 1, ++ .udelay = 2, /* ~100 kHz */ ++}; ++ ++static struct platform_device at91sam9g45_twi1_device = { ++ .name = "i2c-gpio", ++ .id = 1, ++ .dev.platform_data = &pdata_i2c1, ++}; ++ ++void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) ++{ ++ i2c_register_board_info(i2c_id, devices, nr_devices); ++ ++ if (i2c_id == 0) { ++ at91_set_GPIO_periph(AT91_PIN_PA20, 1); /* TWD (SDA) */ ++ at91_set_multi_drive(AT91_PIN_PA20, 1); ++ ++ at91_set_GPIO_periph(AT91_PIN_PA21, 1); /* TWCK (SCL) */ ++ at91_set_multi_drive(AT91_PIN_PA21, 1); ++ ++ platform_device_register(&at91sam9g45_twi0_device); ++ } else { ++ at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* TWD (SDA) */ ++ at91_set_multi_drive(AT91_PIN_PB10, 1); ++ ++ at91_set_GPIO_periph(AT91_PIN_PB11, 1); /* TWCK (SCL) */ ++ at91_set_multi_drive(AT91_PIN_PB11, 1); ++ ++ platform_device_register(&at91sam9g45_twi1_device); ++ } ++} ++ ++#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) ++static struct resource twi0_resources[] = { ++ [0] = { ++ .start = AT91SAM9G45_BASE_TWI0, ++ .end = AT91SAM9G45_BASE_TWI0 + SZ_16K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_TWI0, ++ .end = AT91SAM9G45_ID_TWI0, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91sam9g45_twi0_device = { ++ .name = "at91_i2c", ++ .id = 0, ++ .resource = twi0_resources, ++ .num_resources = ARRAY_SIZE(twi0_resources), ++}; ++ ++static struct resource twi1_resources[] = { ++ [0] = { ++ .start = AT91SAM9G45_BASE_TWI1, ++ .end = AT91SAM9G45_BASE_TWI1 + SZ_16K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_TWI1, ++ .end = AT91SAM9G45_ID_TWI1, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91sam9g45_twi1_device = { ++ .name = "at91_i2c", ++ .id = 1, ++ .resource = twi1_resources, ++ .num_resources = ARRAY_SIZE(twi1_resources), ++}; ++ ++void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) ++{ ++ i2c_register_board_info(i2c_id, devices, nr_devices); ++ ++ /* 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); ++ } ++} ++#else ++void __init at91_add_device_i2c(short i2c_id, 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 = AT91SAM9G45_BASE_SPI0, ++ .end = AT91SAM9G45_BASE_SPI0 + SZ_16K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_SPI0, ++ .end = AT91SAM9G45_ID_SPI0, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91sam9g45_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_PB3, AT91_PIN_PB18, AT91_PIN_PB19, AT91_PIN_PD27 }; ++ ++static struct resource spi1_resources[] = { ++ [0] = { ++ .start = AT91SAM9G45_BASE_SPI1, ++ .end = AT91SAM9G45_BASE_SPI1 + SZ_16K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_SPI1, ++ .end = AT91SAM9G45_ID_SPI1, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91sam9g45_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_PB17, AT91_PIN_PD28, AT91_PIN_PD18, AT91_PIN_PD19 }; ++ ++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_PB0, 0); /* SPI0_MISO */ ++ 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) { ++ at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_MISO */ ++ 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); ++ } ++} ++#else ++void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {} ++#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 = AT91SAM9G45_LCDC_BASE, ++ .end = AT91SAM9G45_LCDC_BASE + SZ_4K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_LCDC, ++ .end = AT91SAM9G45_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; ++ ++ at91_set_A_periph(AT91_PIN_PE0, 0); /* LCDDPWR */ ++ ++ at91_set_A_periph(AT91_PIN_PE2, 0); /* LCDCC */ ++ at91_set_A_periph(AT91_PIN_PE3, 0); /* LCDVSYNC */ ++ at91_set_A_periph(AT91_PIN_PE4, 0); /* LCDHSYNC */ ++ at91_set_A_periph(AT91_PIN_PE5, 0); /* LCDDOTCK */ ++ at91_set_A_periph(AT91_PIN_PE6, 0); /* LCDDEN */ ++ at91_set_A_periph(AT91_PIN_PE7, 0); /* LCDD0 */ ++ at91_set_A_periph(AT91_PIN_PE8, 0); /* LCDD1 */ ++ at91_set_A_periph(AT91_PIN_PE9, 0); /* LCDD2 */ ++ at91_set_A_periph(AT91_PIN_PE10, 0); /* LCDD3 */ ++ at91_set_A_periph(AT91_PIN_PE11, 0); /* LCDD4 */ ++ at91_set_A_periph(AT91_PIN_PE12, 0); /* LCDD5 */ ++ at91_set_A_periph(AT91_PIN_PE13, 0); /* LCDD6 */ ++ at91_set_A_periph(AT91_PIN_PE14, 0); /* LCDD7 */ ++ at91_set_A_periph(AT91_PIN_PE15, 0); /* LCDD8 */ ++ at91_set_A_periph(AT91_PIN_PE16, 0); /* LCDD9 */ ++ at91_set_A_periph(AT91_PIN_PE17, 0); /* LCDD10 */ ++ at91_set_A_periph(AT91_PIN_PE18, 0); /* LCDD11 */ ++ at91_set_A_periph(AT91_PIN_PE19, 0); /* LCDD12 */ ++ at91_set_A_periph(AT91_PIN_PE20, 0); /* LCDD13 */ ++ at91_set_A_periph(AT91_PIN_PE21, 0); /* LCDD14 */ ++ at91_set_A_periph(AT91_PIN_PE22, 0); /* LCDD15 */ ++ at91_set_A_periph(AT91_PIN_PE23, 0); /* LCDD16 */ ++ at91_set_A_periph(AT91_PIN_PE24, 0); /* LCDD17 */ ++ at91_set_A_periph(AT91_PIN_PE25, 0); /* LCDD18 */ ++ at91_set_A_periph(AT91_PIN_PE26, 0); /* LCDD19 */ ++ at91_set_A_periph(AT91_PIN_PE27, 0); /* LCDD20 */ ++ at91_set_A_periph(AT91_PIN_PE28, 0); /* LCDD21 */ ++ at91_set_A_periph(AT91_PIN_PE29, 0); /* LCDD22 */ ++ at91_set_A_periph(AT91_PIN_PE30, 0); /* LCDD23 */ ++ ++ lcdc_data = *data; ++ platform_device_register(&at91_lcdc_device); ++} ++#else ++void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} ++#endif ++ ++ ++/* -------------------------------------------------------------------- ++ * Timer/Counter block ++ * -------------------------------------------------------------------- */ ++ ++#ifdef CONFIG_ATMEL_TCLIB ++static struct resource tcb0_resources[] = { ++ [0] = { ++ .start = AT91SAM9G45_BASE_TCB0, ++ .end = AT91SAM9G45_BASE_TCB0 + SZ_16K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_TCB, ++ .end = AT91SAM9G45_ID_TCB, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91sam9g45_tcb0_device = { ++ .name = "atmel_tcb", ++ .id = 0, ++ .resource = tcb0_resources, ++ .num_resources = ARRAY_SIZE(tcb0_resources), ++}; ++ ++/* TCB1 begins with TC3 */ ++static struct resource tcb1_resources[] = { ++ [0] = { ++ .start = AT91SAM9G45_BASE_TCB1, ++ .end = AT91SAM9G45_BASE_TCB1 + SZ_16K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_TCB, ++ .end = AT91SAM9G45_ID_TCB, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91sam9g45_tcb1_device = { ++ .name = "atmel_tcb", ++ .id = 1, ++ .resource = tcb1_resources, ++ .num_resources = ARRAY_SIZE(tcb1_resources), ++}; ++ ++static void __init at91_add_device_tc(void) ++{ ++ /* this chip has one clock and irq for all six TC channels */ ++ at91_clock_associate("tcb_clk", &at91sam9g45_tcb0_device.dev, "t0_clk"); ++ platform_device_register(&at91sam9g45_tcb0_device); ++ at91_clock_associate("tcb_clk", &at91sam9g45_tcb1_device.dev, "t0_clk"); ++ platform_device_register(&at91sam9g45_tcb1_device); ++} ++#else ++static void __init at91_add_device_tc(void) { } ++#endif ++ ++ ++/* -------------------------------------------------------------------- ++ * RTC ++ * -------------------------------------------------------------------- */ ++ ++#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE) ++static struct platform_device at91sam9g45_rtc_device = { ++ .name = "at91_rtc", ++ .id = -1, ++ .num_resources = 0, ++}; ++ ++static void __init at91_add_device_rtc(void) ++{ ++ platform_device_register(&at91sam9g45_rtc_device); ++} ++#else ++static void __init at91_add_device_rtc(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 at91sam9g45_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(&at91sam9g45_rtt_device); ++} ++ ++ ++/* -------------------------------------------------------------------- ++ * Watchdog ++ * -------------------------------------------------------------------- */ ++ ++#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) ++static struct platform_device at91sam9g45_wdt_device = { ++ .name = "at91_wdt", ++ .id = -1, ++ .num_resources = 0, ++}; ++ ++static void __init at91_add_device_watchdog(void) ++{ ++ platform_device_register(&at91sam9g45_wdt_device); ++} ++#else ++static void __init at91_add_device_watchdog(void) {} ++#endif ++ ++ ++/* -------------------------------------------------------------------- ++ * PWM ++ * --------------------------------------------------------------------*/ ++ ++#if defined(CONFIG_ATMEL_PWM) || defined(CONFIG_ATMEL_PWM_MODULE) ++static u32 pwm_mask; ++ ++static struct resource pwm_resources[] = { ++ [0] = { ++ .start = AT91SAM9G45_BASE_PWMC, ++ .end = AT91SAM9G45_BASE_PWMC + SZ_16K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_PWMC, ++ .end = AT91SAM9G45_ID_PWMC, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91sam9g45_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_B_periph(AT91_PIN_PD24, 1); /* enable PWM0 */ ++ ++ if (mask & (1 << AT91_PWM1)) ++ at91_set_B_periph(AT91_PIN_PD31, 1); /* enable PWM1 */ ++ ++ if (mask & (1 << AT91_PWM2)) ++ at91_set_B_periph(AT91_PIN_PD26, 1); /* enable PWM2 */ ++ ++ if (mask & (1 << AT91_PWM3)) ++ at91_set_B_periph(AT91_PIN_PD0, 1); /* enable PWM3 */ ++ ++ pwm_mask = mask; ++ ++ platform_device_register(&at91sam9g45_pwm0_device); ++} ++#else ++void __init at91_add_device_pwm(u32 mask) {} ++#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 = AT91SAM9G45_BASE_SSC0, ++ .end = AT91SAM9G45_BASE_SSC0 + SZ_16K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_SSC0, ++ .end = AT91SAM9G45_ID_SSC0, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91sam9g45_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_PD1, 1); ++ if (pins & ATMEL_SSC_TK) ++ at91_set_A_periph(AT91_PIN_PD0, 1); ++ if (pins & ATMEL_SSC_TD) ++ at91_set_A_periph(AT91_PIN_PD2, 1); ++ if (pins & ATMEL_SSC_RD) ++ at91_set_A_periph(AT91_PIN_PD3, 1); ++ if (pins & ATMEL_SSC_RK) ++ at91_set_A_periph(AT91_PIN_PD4, 1); ++ if (pins & ATMEL_SSC_RF) ++ at91_set_A_periph(AT91_PIN_PD5, 1); ++} ++ ++static u64 ssc1_dmamask = DMA_BIT_MASK(32); ++ ++static struct resource ssc1_resources[] = { ++ [0] = { ++ .start = AT91SAM9G45_BASE_SSC1, ++ .end = AT91SAM9G45_BASE_SSC1 + SZ_16K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = AT91SAM9G45_ID_SSC1, ++ .end = AT91SAM9G45_ID_SSC1, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device at91sam9g45_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_PD14, 1); ++ if (pins & ATMEL_SSC_TK) ++ at91_set_A_periph(AT91_PIN_PD12, 1); ++ if (pins & ATMEL_SSC_TD) ++ at91_set_A_periph(AT91_PIN_PD10, 1); ++ if (pins & ATMEL_SSC_RD) ++ at91_set_A_periph(AT91_PIN_PD11, 1); ++ if (pins & ATMEL_SSC_RK) ++ at91_set_A_periph(AT91_PIN_PD13, 1); ++ if (pins & ATMEL_SSC_RF) ++ at91_set_A_periph(AT91_PIN_PD15, 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 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:
Lines of this file are not shown. View the raw message.
recipes/linux/linux-atmel-2.6.30/at91/linux-2.6.30-at91-exp-002-NAND-partitions.patch new file +100 -0
100 lines not on this page · raw message
recipes/linux/linux-atmel-2.6.30/at91/linux-2.6.30-at91-exp-004-NAND-001-configurable-partition-size.patch new file +214 -0
214 lines not on this page · raw message
recipes/linux/linux-atmel-2.6.30/at91/linux-2.6.30-at91-exp-005-at91sam9m10g45ek_BSP.patch new file +30 -0
Lines of this file are not shown. View the raw message.
recipes/linux/linux-atmel-2.6.30/at91/linux-2.6.30-at91-exp-006-at91sam9m10g45ek_machine.patch new file +39 -0
Lines of this file are not shown. View the raw message.
recipes/linux/linux-atmel-2.6.30/at91sam9g45ek/defconfig new file +1798 -0
1,798 lines not on this page · raw message
recipes/linux/linux-atmel_2.6.30.bb new file +25 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.0.2
Part of the diff is not shown here. View the raw message.
Dnia sobota, 13 marca 2010 o 08:48:34 Ulf Samuelsson napisał(a):
Quoted 10 lines
Add support for building AT91 2.6.30 kernel Vanilla 2.6.30 recipe has moved on to 2.6.30.x
Add maxim.org.za patches + Atmel experimental patches. (With the exception of the SAM9M10-EK support) Add support for configurable NAND flash partitions Add support for sam9m10g45-ek
The contents of the maxim & experimental kernel patches has various authors described inide the patches.
NAK - please merge it into linux_2.6.30.bb as there is really no need to duplicate it.
Regards,
Signature · 3 lines
JID: [email protected] Website: http://marcin.juszkiewicz.com.pl/ LinkedIn: http://www.linkedin.com/in/marcinjuszkiewicz
Marcin Juszkiewicz skrev:
Quoted 9 lines
Dnia sobota, 13 marca 2010 o 08:48:34 Ulf Samuelsson napisał(a):
Quoted 8 lines
Add support for building AT91 2.6.30 kernel Vanilla 2.6.30 recipe has moved on to 2.6.30.x
Add maxim.org.za patches + Atmel experimental patches. (With the exception of the SAM9M10-EK support) Add support for configurable NAND flash partitions Add support for sam9m10g45-ek
Quoted 7 lines
Quoted 2 lines
The contents of the maxim & experimental kernel patches has various authors described inide the patches.
NAK - please merge it into linux_2.6.30.bb as there is really no need to duplicate it.
Regards,
The reasons for doing it this way, is that this is something that has received extensive testing by our friends in Rousset. I tried doing it vs the generic 2.6.30 recipe, but since that adds a minor patch, this patchset breaks.
If I do it, then this minor patch needs to be optional and not applied for these boards.
Obviously the minor patch can be applied by someone with more time to do testing.
Signature · 2 lines
Best Regards Ulf Samuelsson