summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/freescale/mx53_pcba/mx53_pcba.c142
-rw-r--r--include/asm-arm/arch-mx53/imx_spi_pmic.h33
-rw-r--r--include/configs/mx53_pcba_android.h6
3 files changed, 173 insertions, 8 deletions
diff --git a/board/freescale/mx53_pcba/mx53_pcba.c b/board/freescale/mx53_pcba/mx53_pcba.c
index 1214417..9ef654b 100644
--- a/board/freescale/mx53_pcba/mx53_pcba.c
+++ b/board/freescale/mx53_pcba/mx53_pcba.c
@@ -55,6 +55,11 @@
#include <jffs2/load_kernel.h>
#endif
+#ifdef CONFIG_IMX_ECSPI
+#include <imx_spi.h>
+#include <asm/arch/imx_spi_pmic.h>
+#endif
+
DECLARE_GLOBAL_DATA_PTR;
static u32 system_rev;
@@ -321,6 +326,7 @@ void setup_pmic_voltages(void)
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
if (!i2c_probe(0x8)) {
+ printf("Found mc34708 on board by I2C!\n");
if (i2c_read(0x8, 24, 1, &buf[0], 3)) {
printf("%s:i2c_read:error\n", __func__);
}
@@ -367,11 +373,132 @@ void setup_pmic_voltages(void)
printf("%s:i2c_write:error\n", __func__);
return -1;
}
+ } else {
+ if (setup_pmic_voltages_spi()) /*Probe by spi*/
+ printf("Error: Dont't found mc34708 on board.\n");
+ else
+ printf("Found mc34708 on board by SPI!\n");
+ }
+}
+
+#endif
+
+#ifdef CONFIG_IMX_ECSPI
+s32 spi_get_cfg(struct imx_spi_dev_t *dev)
+{
+ switch (dev->slave.cs) {
+ case 1:
+ dev->base = CSPI1_BASE_ADDR;
+ dev->freq = 25000000;
+ dev->ss_pol = IMX_SPI_ACTIVE_HIGH;
+ dev->ss = 1;
+ dev->fifo_sz = 64 * 4;
+ dev->us_delay = 0;
+ break;
+ default:
+ printf("Invalid Bus ID!\n");
+ }
+
+ return 0;
+}
- } else
- printf("Error: Dont't found mc34708 on board.\n");
+void spi_io_init(struct imx_spi_dev_t *dev)
+{
+ switch (dev->base) {
+ case CSPI1_BASE_ADDR:
+ /* Select mux mode: ALT0 mux port: SCLK of instance: ecspi1. */
+ mxc_request_iomux(MX53_PIN_EIM_D16, IOMUX_CONFIG_ALT4);
+ mxc_iomux_set_pad(MX53_PIN_EIM_D16, 0x104);
+ mxc_iomux_set_input(
+ MUX_IN_CSPI_IPP_CSPI_CLK_IN_SELECT_INPUT, 0x3);
+
+ /* Select mux mode: ALT4 mux port: MISO of instance: ecspi1. */
+ mxc_request_iomux(MX53_PIN_EIM_D17, IOMUX_CONFIG_ALT4);
+ mxc_iomux_set_pad(MX53_PIN_EIM_D17, 0x104);
+ mxc_iomux_set_input(
+ MUX_IN_ECSPI1_IPP_IND_MISO_SELECT_INPUT, 0x3);
+
+ /* Select mux mode: ALT4 mux port: MOSI of instance: ecspi1 */
+ mxc_request_iomux(MX53_PIN_EIM_D18, IOMUX_CONFIG_ALT4);
+ mxc_iomux_set_pad(MX53_PIN_EIM_D18, 0x104);
+ mxc_iomux_set_input(
+ MUX_IN_ECSPI1_IPP_IND_MOSI_SELECT_INPUT, 0x3);
+
+ if (dev->ss == 0) {
+ mxc_request_iomux(MX53_PIN_EIM_EB2,
+ IOMUX_CONFIG_ALT4);
+ mxc_iomux_set_pad(MX53_PIN_EIM_EB2, 0x104);
+ mxc_iomux_set_input(
+ MUX_IN_ECSPI1_IPP_IND_SS_B_1_SELECT_INPUT,
+ 0x3);
+ } else if (dev->ss == 1) {
+ mxc_request_iomux(MX53_PIN_EIM_D19, IOMUX_CONFIG_ALT4);
+ mxc_iomux_set_pad(MX53_PIN_EIM_D19, 0x104);
+ mxc_iomux_set_input(
+ MUX_IN_ECSPI1_IPP_IND_SS_B_2_SELECT_INPUT,
+ 0x2);
+ }
+ break;
+ default:
+ break;
+ }
}
+int setup_pmic_voltages_spi(void)
+{
+ struct spi_slave *slave = NULL;
+ unsigned int val;
+
+ slave = spi_pmic_probe();
+ if (slave) {
+ /* increase VDDGP as 1.25V for 1GHZ on SW1 */
+ val = pmic_reg(slave, 24, 0, 0);
+ val &= ~0x3F;
+ val |= 0x30;
+ if (pmic_reg(slave, 24, val, 1) == -1) {
+ printf("%s:spi_write 24:error\n", __func__);
+ return -1;
+ }
+
+ /* Charger Source: set VBUS threshold low to 4.25V,
+ * set Weak VBUS threshold to 4.275V */
+ val = pmic_reg(slave, 53, 0, 0);
+ val = (val & 0xfc7038) | 0x8e47;
+ if (pmic_reg(slave, 53, val, 1) == -1) {
+ printf("%s:spi_write 53:error\n", __func__);
+ return -1;
+ }
+ /* set 1P5 */
+ val = pmic_reg(slave, 52, 0, 0);
+ val |= 0x100000;
+ if (pmic_reg(slave, 52, val, 1) == -1) {
+ printf("%s:spi_write 52:error\n", __func__);
+ return -1;
+ }
+
+ /* Change CC current to 1550mA */
+ /* Change CV voltage as 4.2v */
+ val = pmic_reg(slave, 51, 0, 0);
+ val = (val & 0xf83f00) | 0x7c0d8;
+ if (pmic_reg(slave, 51, val, 1) == -1) {
+ printf("%s:spi_write:error\n", __func__);
+ return -1;
+ }
+
+ /*change global reset time as 4s*/
+ val = pmic_reg(slave, 15, 0, 0);
+ val &= ~0x300;
+ val |= 0x100;
+ if (pmic_reg(slave, 15, val, 1) == -1) {
+ printf("%s:spi_write:error\n", __func__);
+ return -1;
+ }
+ } else {
+ printf("spi_pmic_probe failed!\n");
+ return -1;
+ }
+ return 0;
+}
#endif
#ifdef CONFIG_CMD_MMC
@@ -498,13 +625,7 @@ int board_init(void)
setup_uart();
-#ifdef CONFIG_I2C_MXC
- setup_i2c(CONFIG_SYS_I2C_PORT);
- /* Increase VDDGP voltage */
- setup_pmic_voltages();
- /* Switch to 1GHZ */
clk_config(CONFIG_REF_CLK_FREQ, 1000, CPU_CLK);
-#endif
return 0;
}
@@ -636,6 +757,11 @@ int check_recovery_cmd_file(void)
int board_late_init(void)
{
+#ifdef CONFIG_I2C_MXC
+ setup_i2c(CONFIG_SYS_I2C_PORT);
+ /* Increase VDDGP voltage */
+ setup_pmic_voltages();
+#endif
return 0;
}
diff --git a/include/asm-arm/arch-mx53/imx_spi_pmic.h b/include/asm-arm/arch-mx53/imx_spi_pmic.h
new file mode 100644
index 0000000..b7f41c9
--- /dev/null
+++ b/include/asm-arm/arch-mx53/imx_spi_pmic.h
@@ -0,0 +1,33 @@
+/*
+ * (C) Copyright 2008-2011 Freescale Semiconductor, Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _IMX_SPI_PMIC_H_
+#define _IMX_SPI_PMIC_H_
+
+#include <linux/types.h>
+
+extern struct spi_slave *spi_pmic_probe(void);
+extern void spi_pmic_free(struct spi_slave *slave);
+extern u32 pmic_reg(struct spi_slave *slave,
+ u32 reg, u32 val, u32 write);
+
+#endif /* _IMX_SPI_PMIC_H_ */
diff --git a/include/configs/mx53_pcba_android.h b/include/configs/mx53_pcba_android.h
index 3164b38..242a180 100644
--- a/include/configs/mx53_pcba_android.h
+++ b/include/configs/mx53_pcba_android.h
@@ -197,6 +197,12 @@
#define CONFIG_SYS_I2C_SLAVE 0xfe
#endif
+#define CONFIG_IMX_ECSPI
+#define IMX_CSPI_VER_2_3 1
+#define CONFIG_IMX_SPI_PMIC
+#define CONFIG_IMX_SPI_PMIC_CS 1
+#define MAX_SPI_BYTES (64 * 4)
+
/*
* SPI Configs