blob: 86ce730f791321a11b7b8a52bb553a374ddfa5d7 [file] [log] [blame]
Johannes Weinerf82e9392009-03-04 16:21:33 +01001/*
2 * s6105 control routines
3 *
4 * Copyright (c) 2009 emlix GmbH
5 */
6#include <linux/irq.h>
7#include <linux/io.h>
8#include <linux/gpio.h>
9
10#include <asm/bootparam.h>
11
12#include <variant/hardware.h>
Johannes Weiner1fb137c2009-05-11 15:43:34 +020013#include <variant/gpio.h>
14
Johannes Weinerf82e9392009-03-04 16:21:33 +010015#include <platform/gpio.h>
16
17void platform_halt(void)
18{
19 local_irq_disable();
20 while (1)
21 ;
22}
23
24void platform_power_off(void)
25{
26 platform_halt();
27}
28
29void platform_restart(void)
30{
31 platform_halt();
32}
33
34void __init platform_setup(char **cmdline)
35{
36 unsigned long reg;
37
Oskar Schirmer059cafe2009-06-10 12:58:48 -070038 reg = readl(S6_REG_GREG1 + S6_GREG1_PLLSEL);
39 reg &= ~(S6_GREG1_PLLSEL_GMAC_MASK << S6_GREG1_PLLSEL_GMAC |
40 S6_GREG1_PLLSEL_GMII_MASK << S6_GREG1_PLLSEL_GMII);
41 reg |= S6_GREG1_PLLSEL_GMAC_125MHZ << S6_GREG1_PLLSEL_GMAC |
42 S6_GREG1_PLLSEL_GMII_125MHZ << S6_GREG1_PLLSEL_GMII;
43 writel(reg, S6_REG_GREG1 + S6_GREG1_PLLSEL);
44
Johannes Weinerf82e9392009-03-04 16:21:33 +010045 reg = readl(S6_REG_GREG1 + S6_GREG1_CLKGATE);
46 reg &= ~(1 << S6_GREG1_BLOCK_SB);
Oskar Schirmer059cafe2009-06-10 12:58:48 -070047 reg &= ~(1 << S6_GREG1_BLOCK_GMAC);
Johannes Weinerf82e9392009-03-04 16:21:33 +010048 writel(reg, S6_REG_GREG1 + S6_GREG1_CLKGATE);
49
50 reg = readl(S6_REG_GREG1 + S6_GREG1_BLOCKENA);
51 reg |= 1 << S6_GREG1_BLOCK_SB;
Oskar Schirmer059cafe2009-06-10 12:58:48 -070052 reg |= 1 << S6_GREG1_BLOCK_GMAC;
Johannes Weinerf82e9392009-03-04 16:21:33 +010053 writel(reg, S6_REG_GREG1 + S6_GREG1_BLOCKENA);
54
55 printk(KERN_NOTICE "S6105 on Stretch S6000 - "
56 "Copyright (C) 2009 emlix GmbH <info@emlix.com>\n");
57}
58
59void __init platform_init(bp_tag_t *first)
60{
Daniel Glöckner0b3eb212009-05-05 15:03:22 +000061 s6_gpio_init(0);
Johannes Weinerf82e9392009-03-04 16:21:33 +010062 gpio_request(GPIO_LED1_NGREEN, "led1_green");
63 gpio_request(GPIO_LED1_RED, "led1_red");
64 gpio_direction_output(GPIO_LED1_NGREEN, 1);
65}
66
67void platform_heartbeat(void)
68{
69 static unsigned int c;
70
71 if (!(++c & 0x4F))
72 gpio_direction_output(GPIO_LED1_RED, !(c & 0x10));
73}