blob: b7671dd3b70420a5720ad6da9ac2c1704f0d92d7 [file] [log] [blame]
Markus Klotzbücher20e3b322006-02-20 16:37:37 +01001/*
2 * (C) Copyright 2002
3 * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
4 *
5 * (C) Copyright 2002
6 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
7 * Marius Groeger <mgroeger@sysgo.de>
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
28#include <common.h>
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +010029#include <i2c.h>
30#include <da9030.h>
31#include <asm/arch/pxa-regs.h>
Markus Klotzbücher20e3b322006-02-20 16:37:37 +010032
Wolfgang Denk6405a152006-03-31 18:32:53 +020033DECLARE_GLOBAL_DATA_PTR;
34
Markus Klotzbücher20e3b322006-02-20 16:37:37 +010035/* ------------------------------------------------------------------------- */
36
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +010037static void init_DA9030(void);
Markus Klotzbücher20e3b322006-02-20 16:37:37 +010038
39/*
40 * Miscelaneous platform dependent initialisations
41 */
42
43int board_init (void)
44{
Markus Klotzbücher20e3b322006-02-20 16:37:37 +010045 /* memory and cpu-speed are setup before relocation */
46 /* so we do _nothing_ here */
47
Markus Klotzbücherf4a5c612006-02-28 18:05:25 +010048 /* arch number of Lubbock-Board mk@tbd: fix this! */
Markus Klotzbücher20e3b322006-02-20 16:37:37 +010049 gd->bd->bi_arch_number = MACH_TYPE_LUBBOCK;
50
51 /* adress of boot parameters */
52 gd->bd->bi_boot_params = 0xa0000100;
53
54 return 0;
55}
56
57int board_late_init(void)
58{
59 setenv("stdout", "serial");
60 setenv("stderr", "serial");
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +010061 init_DA9030();
Markus Klotzbücher20e3b322006-02-20 16:37:37 +010062 return 0;
63}
64
65
66int dram_init (void)
67{
Markus Klotzbücher20e3b322006-02-20 16:37:37 +010068 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
69 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
70 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
71 gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
72 gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
73 gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE;
74 gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
75 gd->bd->bi_dram[3].size = PHYS_SDRAM_4_SIZE;
76
77 return 0;
78}
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +010079
Markus Klotzbuecher30413192006-03-30 17:00:39 +020080void i2c_init_board()
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +010081{
Markus Klotzbuecher30413192006-03-30 17:00:39 +020082 CKENB |= (CKENB_4_I2C);
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +010083
84 /* setup I2C GPIO's */
85 GPIO32 = 0x801; /* SCL = Alt. Fkt. 1 */
86 GPIO33 = 0x801; /* SDA = Alt. Fkt. 1 */
Markus Klotzbuecher30413192006-03-30 17:00:39 +020087}
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +010088
Markus Klotzbuecher30413192006-03-30 17:00:39 +020089/* initialize the DA9030 Power Controller */
90static void init_DA9030()
91{
92 uchar addr = (uchar) DA9030_I2C_ADDR, val = 0;
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +010093
Markus Klotzbuecher30413192006-03-30 17:00:39 +020094 CKENB |= CKENB_7_GPIO;
95 udelay(100);
96
97 /* Rising Edge on EXTON to reset DA9030 */
98 GPIO17 = 0x8800; /* configure GPIO17, no pullup, -down */
Markus Klotzbuecherb62261b2006-03-27 16:01:03 +020099 GPDR0 |= (1<<17); /* GPIO17 is output */
100 GSDR0 = (1<<17);
101 GPCR0 = (1<<17); /* drive GPIO17 low */
Markus Klotzbuecherb62261b2006-03-27 16:01:03 +0200102 GPSR0 = (1<<17); /* drive GPIO17 high */
Markus Klotzbuecher30413192006-03-30 17:00:39 +0200103
Markus Klotzbuecherb62261b2006-03-27 16:01:03 +0200104#if CFG_DA9030_EXTON_DELAY
105 udelay((unsigned long) CFG_DA9030_EXTON_DELAY); /* wait for DA9030 */
106#endif
107 GPCR0 = (1<<17); /* drive GPIO17 low */
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +0100108
109 /* reset the watchdog and go active (0xec) */
110 val = (SYS_CONTROL_A_HWRES_ENABLE |
111 (0x6<<4) |
112 SYS_CONTROL_A_WDOG_ACTION |
113 SYS_CONTROL_A_WATCHDOG);
Markus Klotzbuecherfdc33ac2006-03-29 17:49:27 +0200114 if(i2c_write(addr, SYS_CONTROL_A, 1, &val, 1)) {
115 printf("Error accessing DA9030 via i2c.\n");
116 return;
117 }
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +0100118
119 i2c_reg_write(addr, REG_CONTROL_1_97, 0xfd); /* disable LDO1, enable LDO6 */
120 i2c_reg_write(addr, LDO2_3, 0xd1); /* LDO2 =1,9V, LDO3=3,1V */
121 i2c_reg_write(addr, LDO4_5, 0xcc); /* LDO2 =1,9V, LDO3=3,1V */
Markus Klotzbuecher30413192006-03-30 17:00:39 +0200122 i2c_reg_write(addr, LDO6_SIMCP, 0x3e); /* LDO6=3,2V, SIMCP = 5V support */
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +0100123 i2c_reg_write(addr, LDO7_8, 0xc9); /* LDO7=2,7V, LDO8=3,0V */
124 i2c_reg_write(addr, LDO9_12, 0xec); /* LDO9=3,0V, LDO12=3,2V */
Markus Klotzbuecher30413192006-03-30 17:00:39 +0200125 i2c_reg_write(addr, BUCK, 0x0c); /* Buck=1.2V */
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +0100126 i2c_reg_write(addr, REG_CONTROL_2_98, 0x7f); /* All LDO'S on 8,9,10,11,12,14 */
Markus Klotzbuecher30413192006-03-30 17:00:39 +0200127 i2c_reg_write(addr, LDO_10_11, 0xcc); /* LDO10=3.0V LDO11=3.0V */
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +0100128 i2c_reg_write(addr, LDO_15, 0xae); /* LDO15=1.8V, dislock first 3bit */
Markus Klotzbuecher30413192006-03-30 17:00:39 +0200129 i2c_reg_write(addr, LDO_14_16, 0x05); /* LDO14=2.8V, LDO16=NB */
Markus Klotzbuecher7cf18be2006-03-24 12:23:27 +0100130 i2c_reg_write(addr, LDO_18_19, 0x9c); /* LDO18=3.0V, LDO19=2.7V */
131 i2c_reg_write(addr, LDO_17_SIMCP0, 0x2c); /* LDO17=3.0V, SIMCP=3V support */
132 i2c_reg_write(addr, BUCK2_DVC1, 0x9a); /* Buck2=1.5V plus Update support of 520 MHz */
133 i2c_reg_write(addr, REG_CONTROL_2_18, 0x43); /* Ball on */
134 i2c_reg_write(addr, MISC_CONTROLB, 0x08); /* session valid enable */
135 i2c_reg_write(addr, USBPUMP, 0xc1); /* start pump, ignore HW signals */
136
137 val = i2c_reg_read(addr, STATUS);
138 if(val & STATUS_CHDET)
139 printf("Charger detected, turning on LED.\n");
140 else {
141 printf("No charger detetected.\n");
142 /* undervoltage? print error and power down */
143 }
144}
145
146
147#if 0
148/* reset the DA9030 watchdog */
149void hw_watchdog_reset(void)
150{
151 uchar addr = (uchar) DA9030_I2C_ADDR, val = 0;
152 val = i2c_reg_read(addr, SYS_CONTROL_A);
153 val |= SYS_CONTROL_A_WATCHDOG;
154 i2c_reg_write(addr, SYS_CONTROL_A, val);
155}
156#endif