summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2010-03-16 18:53:45 -0700
committerJean-Baptiste Queru <jbq@google.com>2010-03-16 18:53:45 -0700
commitb7a9936fb200f50c3c0310fba9475162fdce0662 (patch)
tree58a23e2759fa42ff66a268bd91490c7b4646c6ad
parentf6f62d5c654bce6f10b3c17c8deac7a99123c120 (diff)
downloaddream-sapphire-b7a9936fb200f50c3c0310fba9475162fdce0662.tar.gz
share the boot library between dream and sapphire
Change-Id: I18ea14180847eed2780a411c3e6d61554a892af5
-rw-r--r--Android.mk2
-rw-r--r--boot/Android.mk35
-rw-r--r--boot/board.c105
-rw-r--r--boot/keypad.c74
-rw-r--r--boot/panel.c29
-rw-r--r--boot/usb.c38
6 files changed, 282 insertions, 1 deletions
diff --git a/Android.mk b/Android.mk
index c895fe8..56de54f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -13,4 +13,4 @@
# limitations under the License.
-include $(call all-named-subdir-makefiles, libsensors)
+include $(call all-named-subdir-makefiles, boot libsensors)
diff --git a/boot/Android.mk b/boot/Android.mk
new file mode 100644
index 0000000..142b712
--- /dev/null
+++ b/boot/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2007 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+ifneq ($(TARGET_SIMULATOR),true)
+
+include $(CLEAR_VARS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES := board.c panel.c keypad.c usb.c
+
+LOCAL_C_INCLUDES := $(call include-path-for, bootloader)
+
+LOCAL_CFLAGS := -O2 -g -W -Wall
+LOCAL_CFLAGS += -march=armv6
+
+LOCAL_MODULE := libboot_board_dream_sapphire
+
+include $(BUILD_RAW_STATIC_LIBRARY)
+
+endif # !TARGET_SIMULATOR
+
diff --git a/boot/board.c b/boot/board.c
new file mode 100644
index 0000000..f2b4daf
--- /dev/null
+++ b/boot/board.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <boot/boot.h>
+#include <boot/flash.h>
+
+ptentry PTABLE[] = {
+ {
+ .start = 310,
+ .length = 40,
+ .name = "recovery",
+ },
+ {
+ .start = 350,
+ .length = 20,
+ .name = "boot",
+ },
+ {
+ .start = 370,
+ .length = 540,
+ .name = "system",
+ },
+ {
+ .start = 910,
+ .length = 1138,
+ .name = "userdata",
+ },
+ {
+ .start = 0,
+ .length = 0,
+ .name = "",
+ },
+};
+
+#define MISC2_CHARGER_OFF 0x01 /* DISABLE charge circuitry */
+#define MISC2_ISET 0x02 /* Enable Current Limit */
+
+#define MISC2_H2W_MASK 0xC0
+#define MISC2_H2W_GPIO 0x00
+#define MISC2_H2W_UART1 0x40
+#define MISC2_H2W_UART3 0x80
+#define MISC2_H2W_BT 0xC0
+
+void board_init()
+{
+ unsigned n;
+
+ /* if we already have partitions from elsewhere,
+ ** don't use the hardcoded ones
+ */
+ if(flash_get_ptn_count() == 0) {
+ for(n = 0; PTABLE[n].name[0]; n++) {
+ flash_add_ptn(PTABLE + n);
+ }
+ }
+
+ /* UART configuration */
+#if 1
+ /* UART3 */
+ writeb(MISC2_H2W_UART3, 0x98000000);
+ uart_init(2);
+#else
+ /* UART1 */
+ writeb(MISC2_H2W_UART1, 0x98000000);
+ uart_init(0);
+#endif
+ mdelay(100);
+}
+
+const char *board_cmdline(void)
+{
+ return "mem=112M console=ttyMSM0 androidboot.console=ttyMSM0";
+};
+
+unsigned board_machtype(void)
+{
+ return 1440;
+}
+
+void board_reboot(void)
+{
+ gpio_set(25, 0);
+}
+
+void board_getvar(const char *name, char *value)
+{
+ if(!strcmp(name, "version.amss")) {
+ get_version_modem(value);
+ } else if(!strcmp(name, "version.amss.sbl")) {
+ get_version_modem_sbl(value);
+ }
+}
diff --git a/boot/keypad.c b/boot/keypad.c
new file mode 100644
index 0000000..b1de09d
--- /dev/null
+++ b/boot/keypad.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <boot/boot.h>
+#include <boot/board.h>
+#include <boot/gpio_keypad.h>
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+static unsigned int dream_row_gpios[] = {
+#if 0 // unused?
+ 35, /* KP_MKOUT0 */
+ 34, /* KP_MKOUT1 */
+ 33, /* KP_MKOUT2 */
+ 32, /* KP_MKOUT3 */
+ 31, /* KP_MKOUT4 */
+ 23, /* KP_MKOUT5 */
+#endif
+#if 1
+ 30, /* KP_MKOUT6 */
+ 78, /* KP_MKOUT7 */
+#endif
+};
+
+static unsigned int dream_col_gpios[] = {
+#if 1 // main buttons
+ 42, /* KP_MKIN0 */
+ 41, /* KP_MKIN1 */
+ 40, /* KP_MKIN2 */
+ 39, /* KP_MKIN3 */
+#endif
+#if 1 // side buttons
+ 38, /* KP_MKIN4 */
+ 37, /* KP_MKIN5 */
+ 36, /* KP_MKIN6 */
+#endif
+};
+static gpio_keypad_info dream_keypad = {
+ .output_gpios = dream_row_gpios,
+ .input_gpios = dream_col_gpios,
+ .noutputs = ARRAY_SIZE(dream_row_gpios),
+ .ninputs = ARRAY_SIZE(dream_col_gpios),
+ .settle_time = 5000,
+ .polarity = 0
+};
+
+static void keypad_poll()
+{
+ static int skip = 0;
+ skip++;
+ if(skip > 10) {
+ gpio_keypad_scan_keys(&dream_keypad);
+ skip = 0;
+ }
+}
+
+
+void keypad_init(void)
+{
+ gpio_keypad_init(&dream_keypad);
+ boot_register_poll_func(keypad_poll);
+}
diff --git a/boot/panel.c b/boot/panel.c
new file mode 100644
index 0000000..e264027
--- /dev/null
+++ b/boot/panel.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <boot/board.h>
+
+void panel_init(struct mddi_client_caps *caps)
+{
+}
+
+void panel_poweron(void)
+{
+}
+
+void panel_backlight(int on)
+{
+}
diff --git a/boot/usb.c b/boot/usb.c
new file mode 100644
index 0000000..d2856c3
--- /dev/null
+++ b/boot/usb.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <boot/boot.h>
+
+void ulpi_write(unsigned val, unsigned reg);
+unsigned ulpi_read(unsigned reg);
+
+void board_usb_init(void)
+{
+ writeb(0, 0x98000004);
+ mdelay(100);
+ writeb((1 << 5), 0x98000004);
+ mdelay(100);
+}
+
+void board_ulpi_init(void)
+{
+ /* adjust eye diagram */
+ ulpi_write(0x40, 0x31);
+
+ /* disable VBUS interrupt to avoid stuck PHY issue */
+ ulpi_write(0x1D, 0x0D);
+ ulpi_write(0x1D, 0x10);
+}