Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * BRIEF MODULE DESCRIPTION |
| 4 | * Alchemy Pb1200/Db1200 board setup. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. |
| 10 | * |
| 11 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 12 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 13 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| 14 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 15 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 16 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 17 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 18 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 19 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 20 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along |
| 23 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 24 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 25 | */ |
Sergei Shtylyov | ce28f94 | 2008-04-23 22:43:55 +0400 | [diff] [blame] | 26 | |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 27 | #include <linux/init.h> |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 28 | #include <linux/interrupt.h> |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 29 | #include <linux/sched.h> |
Yoichi Yuasa | 25b31cb | 2007-10-15 19:11:24 +0900 | [diff] [blame] | 30 | |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 31 | #include <asm/mach-au1x00/au1000.h> |
Manuel Lauss | 9bdcf33 | 2009-10-04 14:55:24 +0200 | [diff] [blame] | 32 | #include <asm/mach-db1x00/bcsr.h> |
| 33 | |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 34 | #ifdef CONFIG_MIPS_PB1200 |
| 35 | #include <asm/mach-pb1x00/pb1200.h> |
| 36 | #endif |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 37 | |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 38 | #ifdef CONFIG_MIPS_DB1200 |
| 39 | #include <asm/mach-db1x00/db1200.h> |
| 40 | #define PB1200_INT_BEGIN DB1200_INT_BEGIN |
| 41 | #define PB1200_INT_END DB1200_INT_END |
| 42 | #endif |
| 43 | |
| 44 | #include <prom.h> |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 45 | |
Manuel Lauss | 23ba25d | 2008-12-21 09:26:15 +0100 | [diff] [blame] | 46 | const char *get_system_type(void) |
| 47 | { |
| 48 | return "Alchemy Pb1200"; |
| 49 | } |
| 50 | |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 51 | void board_reset(void) |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 52 | { |
Manuel Lauss | 9bdcf33 | 2009-10-04 14:55:24 +0200 | [diff] [blame] | 53 | bcsr_write(BCSR_RESETS, 0); |
| 54 | bcsr_write(BCSR_SYSTEM, 0); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | void __init board_setup(void) |
| 58 | { |
Manuel Lauss | 9bdcf33 | 2009-10-04 14:55:24 +0200 | [diff] [blame] | 59 | printk(KERN_INFO "AMD Alchemy Pb1200 Board\n"); |
| 60 | bcsr_init(PB1200_BCSR_PHYS_ADDR, |
| 61 | PB1200_BCSR_PHYS_ADDR + PB1200_BCSR_HEXLED_OFS); |
Manuel Lauss | 9bdcf33 | 2009-10-04 14:55:24 +0200 | [diff] [blame] | 62 | |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 63 | #if 0 |
Ralf Baechle | f5cd9f1 | 2007-11-01 12:22:53 +0000 | [diff] [blame] | 64 | { |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 65 | u32 pin_func; |
Ralf Baechle | f5cd9f1 | 2007-11-01 12:22:53 +0000 | [diff] [blame] | 66 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 67 | /* |
| 68 | * Enable PSC1 SYNC for AC97. Normaly done in audio driver, |
| 69 | * but it is board specific code, so put it here. |
| 70 | */ |
| 71 | pin_func = au_readl(SYS_PINFUNC); |
| 72 | au_sync(); |
| 73 | pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1; |
| 74 | au_writel(pin_func, SYS_PINFUNC); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 75 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 76 | au_writel(0, (u32)bcsr | 0x10); /* turn off PCMCIA power */ |
| 77 | au_sync(); |
Ralf Baechle | f5cd9f1 | 2007-11-01 12:22:53 +0000 | [diff] [blame] | 78 | } |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 79 | #endif |
| 80 | |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 81 | #if defined(CONFIG_I2C_AU1550) |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 82 | { |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 83 | u32 freq0, clksrc; |
| 84 | u32 pin_func; |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 85 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 86 | /* Select SMBus in CPLD */ |
Manuel Lauss | 9bdcf33 | 2009-10-04 14:55:24 +0200 | [diff] [blame] | 87 | bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC0MUX, 0); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 88 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 89 | pin_func = au_readl(SYS_PINFUNC); |
| 90 | au_sync(); |
| 91 | pin_func &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B); |
| 92 | /* Set GPIOs correctly */ |
| 93 | pin_func |= 2 << 17; |
| 94 | au_writel(pin_func, SYS_PINFUNC); |
| 95 | au_sync(); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 96 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 97 | /* The I2C driver depends on 50 MHz clock */ |
| 98 | freq0 = au_readl(SYS_FREQCTRL0); |
| 99 | au_sync(); |
| 100 | freq0 &= ~(SYS_FC_FRDIV1_MASK | SYS_FC_FS1 | SYS_FC_FE1); |
| 101 | freq0 |= 3 << SYS_FC_FRDIV1_BIT; |
| 102 | /* 396 MHz / (3 + 1) * 2 == 49.5 MHz */ |
| 103 | au_writel(freq0, SYS_FREQCTRL0); |
| 104 | au_sync(); |
| 105 | freq0 |= SYS_FC_FE1; |
| 106 | au_writel(freq0, SYS_FREQCTRL0); |
| 107 | au_sync(); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 108 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 109 | clksrc = au_readl(SYS_CLKSRC); |
| 110 | au_sync(); |
| 111 | clksrc &= ~(SYS_CS_CE0 | SYS_CS_DE0 | SYS_CS_ME0_MASK); |
| 112 | /* Bit 22 is EXTCLK0 for PSC0 */ |
| 113 | clksrc |= SYS_CS_MUX_FQ1 << SYS_CS_ME0_BIT; |
| 114 | au_writel(clksrc, SYS_CLKSRC); |
| 115 | au_sync(); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 116 | } |
| 117 | #endif |
| 118 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 119 | /* |
| 120 | * The Pb1200 development board uses external MUX for PSC0 to |
Manuel Lauss | 9bdcf33 | 2009-10-04 14:55:24 +0200 | [diff] [blame] | 121 | * support SMB/SPI. bcsr_resets bit 12: 0=SMB 1=SPI |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 122 | */ |
Ralf Baechle | 6fec2e1 | 2007-07-13 06:33:09 +0100 | [diff] [blame] | 123 | #ifdef CONFIG_I2C_AU1550 |
Manuel Lauss | 9bdcf33 | 2009-10-04 14:55:24 +0200 | [diff] [blame] | 124 | bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC0MUX, 0); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 125 | #endif |
| 126 | au_sync(); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 127 | } |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 128 | |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 129 | static int __init pb1200_init_irq(void) |
| 130 | { |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 131 | /* We have a problem with CPLD rev 3. */ |
| 132 | if (BCSR_WHOAMI_CPLD(bcsr_read(BCSR_WHOAMI)) <= 3) { |
| 133 | printk(KERN_ERR "WARNING!!!\n"); |
| 134 | printk(KERN_ERR "WARNING!!!\n"); |
| 135 | printk(KERN_ERR "WARNING!!!\n"); |
| 136 | printk(KERN_ERR "WARNING!!!\n"); |
| 137 | printk(KERN_ERR "WARNING!!!\n"); |
| 138 | printk(KERN_ERR "WARNING!!!\n"); |
| 139 | printk(KERN_ERR "Pb1200 must be at CPLD rev 4. Please have Pb1200\n"); |
| 140 | printk(KERN_ERR "updated to latest revision. This software will\n"); |
| 141 | printk(KERN_ERR "not work on anything less than CPLD rev 4.\n"); |
| 142 | printk(KERN_ERR "WARNING!!!\n"); |
| 143 | printk(KERN_ERR "WARNING!!!\n"); |
| 144 | printk(KERN_ERR "WARNING!!!\n"); |
| 145 | printk(KERN_ERR "WARNING!!!\n"); |
| 146 | printk(KERN_ERR "WARNING!!!\n"); |
| 147 | printk(KERN_ERR "WARNING!!!\n"); |
| 148 | panic("Game over. Your score is 0."); |
| 149 | } |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 150 | |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 151 | set_irq_type(AU1200_GPIO7_INT, IRQF_TRIGGER_LOW); |
| 152 | bcsr_init_irq(PB1200_INT_BEGIN, PB1200_INT_END, AU1200_GPIO7_INT); |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 153 | |
| 154 | return 0; |
| 155 | } |
| 156 | arch_initcall(pb1200_init_irq); |
| 157 | |
| 158 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 159 | int board_au1200fb_panel(void) |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 160 | { |
Manuel Lauss | 9bdcf33 | 2009-10-04 14:55:24 +0200 | [diff] [blame] | 161 | return (bcsr_read(BCSR_SWITCHES) >> 8) & 0x0f; |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 164 | int board_au1200fb_panel_init(void) |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 165 | { |
| 166 | /* Apply power */ |
Manuel Lauss | 9bdcf33 | 2009-10-04 14:55:24 +0200 | [diff] [blame] | 167 | bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | |
| 168 | BCSR_BOARD_LCDBL); |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 169 | /* printk(KERN_DEBUG "board_au1200fb_panel_init()\n"); */ |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 170 | return 0; |
| 171 | } |
| 172 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 173 | int board_au1200fb_panel_shutdown(void) |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 174 | { |
| 175 | /* Remove power */ |
Manuel Lauss | 9bdcf33 | 2009-10-04 14:55:24 +0200 | [diff] [blame] | 176 | bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | |
| 177 | BCSR_BOARD_LCDBL, 0); |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 178 | /* printk(KERN_DEBUG "board_au1200fb_panel_shutdown()\n"); */ |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 179 | return 0; |
| 180 | } |