]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - board/genesi/mx51_efikamx/efikamx.c
Merge branch 'master' of git://git.denx.de/u-boot-arm
[karo-tx-uboot.git] / board / genesi / mx51_efikamx / efikamx.c
index 18ab8d9465772e7d3702d58318413ca61284bfa7..6ba55cd08a82f62a5cd420b024ff68cdb0cc171a 100644 (file)
@@ -3,23 +3,7 @@
  * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com>
  * Copyright (C) 2009-2012 Genesi USA, 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
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <asm/errno.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/crm_regs.h>
+#include <asm/arch/clock.h>
+#include <asm/imx-common/spi.h>
 #include <i2c.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
-#include <pmic.h>
+#include <power/pmic.h>
 #include <fsl_pmic.h>
 #include <mc13892.h>
 
@@ -81,19 +67,19 @@ static u32 get_mx_rev(void)
         */
 
        /* set to 1 in order to get correct value on board rev 1.1 */
-       gpio_direction_output(GPIO_NUMBER(3, 16), 1);
-       gpio_direction_input(GPIO_NUMBER(3, 11));
-       gpio_direction_input(GPIO_NUMBER(3, 16));
-       gpio_direction_input(GPIO_NUMBER(3, 17));
+       gpio_direction_output(IMX_GPIO_NR(3, 16), 1);
+       gpio_direction_input(IMX_GPIO_NR(3, 11));
+       gpio_direction_input(IMX_GPIO_NR(3, 16));
+       gpio_direction_input(IMX_GPIO_NR(3, 17));
 
-       rev |= (!!gpio_get_value(GPIO_NUMBER(3, 16))) << 0;
-       rev |= (!!gpio_get_value(GPIO_NUMBER(3, 17))) << 1;
-       rev |= (!!gpio_get_value(GPIO_NUMBER(3, 11))) << 2;
+       rev |= (!!gpio_get_value(IMX_GPIO_NR(3, 16))) << 0;
+       rev |= (!!gpio_get_value(IMX_GPIO_NR(3, 17))) << 1;
+       rev |= (!!gpio_get_value(IMX_GPIO_NR(3, 11))) << 2;
 
        return (~rev & 0x7) + 1;
 }
 
-static iomux_v3_cfg_t efikasb_revision_pads[] = {
+static iomux_v3_cfg_t const efikasb_revision_pads[] = {
        MX51_PAD_EIM_CS3__GPIO2_28,
        MX51_PAD_EIM_CS4__GPIO2_29,
 };
@@ -104,11 +90,11 @@ static inline u32 get_sb_rev(void)
 
        imx_iomux_v3_setup_multiple_pads(efikasb_revision_pads,
                                ARRAY_SIZE(efikasb_revision_pads));
-       gpio_direction_input(GPIO_NUMBER(2, 28));
-       gpio_direction_input(GPIO_NUMBER(2, 29));
+       gpio_direction_input(IMX_GPIO_NR(2, 28));
+       gpio_direction_input(IMX_GPIO_NR(2, 29));
 
-       rev |= (!!gpio_get_value(GPIO_NUMBER(2, 28))) << 0;
-       rev |= (!!gpio_get_value(GPIO_NUMBER(2, 29))) << 1;
+       rev |= (!!gpio_get_value(IMX_GPIO_NR(2, 28))) << 0;
+       rev |= (!!gpio_get_value(IMX_GPIO_NR(2, 29))) << 1;
 
        return rev;
 }
@@ -140,7 +126,7 @@ int dram_init(void)
 /*
  * UART configuration
  */
-static iomux_v3_cfg_t efikamx_uart_pads[] = {
+static iomux_v3_cfg_t const efikamx_uart_pads[] = {
        MX51_PAD_UART1_RXD__UART1_RXD,
        MX51_PAD_UART1_TXD__UART1_TXD,
        MX51_PAD_UART1_RTS__UART1_RTS,
@@ -150,7 +136,7 @@ static iomux_v3_cfg_t efikamx_uart_pads[] = {
 /*
  * SPI configuration
  */
-static iomux_v3_cfg_t efikamx_spi_pads[] = {
+static iomux_v3_cfg_t const efikamx_spi_pads[] = {
        MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI,
        MX51_PAD_CSPI1_MISO__ECSPI1_MISO,
        MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK,
@@ -159,22 +145,33 @@ static iomux_v3_cfg_t efikamx_spi_pads[] = {
        MX51_PAD_GPIO1_6__GPIO1_6,
 };
 
-#define EFIKAMX_SPI_SS0                GPIO_NUMBER(4, 24)
-#define EFIKAMX_SPI_SS1                GPIO_NUMBER(4, 25)
-#define EFIKAMX_PMIC_IRQ       GPIO_NUMBER(1, 6)
+#define EFIKAMX_SPI_SS0                IMX_GPIO_NR(4, 24)
+#define EFIKAMX_SPI_SS1                IMX_GPIO_NR(4, 25)
+#define EFIKAMX_PMIC_IRQ       IMX_GPIO_NR(1, 6)
 
 /*
  * PMIC configuration
  */
 #ifdef CONFIG_MXC_SPI
+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+       return (bus == 0 && cs == 1) ? 121 : -1;
+}
+
 static void power_init(void)
 {
        unsigned int val;
        struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
        struct pmic *p;
+       int ret;
+
+       ret = pmic_init(CONFIG_FSL_PMIC_BUS);
+       if (ret)
+               return;
 
-       pmic_init();
-       p = get_pmic();
+       p = pmic_get("FSL_PMIC");
+       if (!p)
+               return;
 
        /* Write needed to Power Gate 2 register */
        pmic_reg_read(p, REG_POWER_MISC, &val);
@@ -268,11 +265,11 @@ static inline void power_init(void) { }
 #ifdef CONFIG_FSL_ESDHC
 
 struct fsl_esdhc_cfg esdhc_cfg[2] = {
-       {MMC_SDHC1_BASE_ADDR, 1},
-       {MMC_SDHC2_BASE_ADDR, 1},
+       {MMC_SDHC1_BASE_ADDR},
+       {MMC_SDHC2_BASE_ADDR},
 };
 
-static iomux_v3_cfg_t efikamx_sdhc1_pads[] = {
+static iomux_v3_cfg_t const efikamx_sdhc1_pads[] = {
        MX51_PAD_SD1_CMD__SD1_CMD,
        MX51_PAD_SD1_CLK__SD1_CLK,
        MX51_PAD_SD1_DATA0__SD1_DATA0,
@@ -282,17 +279,17 @@ static iomux_v3_cfg_t efikamx_sdhc1_pads[] = {
        MX51_PAD_GPIO1_1__SD1_WP,
 };
 
-#define EFIKAMX_SDHC1_WP       GPIO_NUMBER(1, 1)
+#define EFIKAMX_SDHC1_WP       IMX_GPIO_NR(1, 1)
 
-static iomux_v3_cfg_t efikamx_sdhc1_cd_pads[] = {
+static iomux_v3_cfg_t const efikamx_sdhc1_cd_pads[] = {
        MX51_PAD_GPIO1_0__SD1_CD,
-       MX51_PAD_EIM_CS2__SD1_CD,
+       NEW_PAD_CTRL(MX51_PAD_EIM_CS2__GPIO2_27, MX51_ESDHC_PAD_CTRL),
 };
 
-#define EFIKAMX_SDHC1_CD       GPIO_NUMBER(1, 0)
-#define EFIKASB_SDHC1_CD       GPIO_NUMBER(2, 27)
+#define EFIKAMX_SDHC1_CD       IMX_GPIO_NR(1, 0)
+#define EFIKASB_SDHC1_CD       IMX_GPIO_NR(2, 27)
 
-static iomux_v3_cfg_t efikasb_sdhc2_pads[] = {
+static iomux_v3_cfg_t const efikasb_sdhc2_pads[] = {
        MX51_PAD_SD2_CMD__SD2_CMD,
        MX51_PAD_SD2_CLK__SD2_CLK,
        MX51_PAD_SD2_DATA0__SD2_DATA0,
@@ -303,8 +300,8 @@ static iomux_v3_cfg_t efikasb_sdhc2_pads[] = {
        MX51_PAD_GPIO1_8__SD2_CD,
 };
 
-#define EFIKASB_SDHC2_CD       GPIO_NUMBER(1, 8)
-#define EFIKASB_SDHC2_WP       GPIO_NUMBER(1, 7)
+#define EFIKASB_SDHC2_CD       IMX_GPIO_NR(1, 8)
+#define EFIKASB_SDHC2_WP       IMX_GPIO_NR(1, 7)
 
 static inline uint32_t efikamx_mmc_getcd(u32 base)
 {
@@ -349,6 +346,9 @@ int board_mmc_init(bd_t *bis)
                gpio_direction_input(EFIKASB_SDHC1_CD);
        }
 
+       esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
+       esdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
+
        ret = fsl_esdhc_initialize(bis, &esdhc_cfg[0]);
 
        if (machine_is_efikasb()) {
@@ -368,7 +368,7 @@ int board_mmc_init(bd_t *bis)
 /*
  * PATA
  */
-static iomux_v3_cfg_t efikamx_pata_pads[] = {
+static iomux_v3_cfg_t const efikamx_pata_pads[] = {
        MX51_PAD_NANDF_WE_B__PATA_DIOW,
        MX51_PAD_NANDF_RE_B__PATA_DIOR,
        MX51_PAD_NANDF_ALE__PATA_BUFFER_EN,
@@ -415,17 +415,17 @@ static inline void setup_iomux_usb(void) { }
  * Smarttop LED pad config is done in the DCD
  *
  */
-#define EFIKAMX_LED_BLUE       GPIO_NUMBER(3, 13)
-#define EFIKAMX_LED_GREEN      GPIO_NUMBER(3, 14)
-#define EFIKAMX_LED_RED                GPIO_NUMBER(3, 15)
+#define EFIKAMX_LED_BLUE       IMX_GPIO_NR(3, 13)
+#define EFIKAMX_LED_GREEN      IMX_GPIO_NR(3, 14)
+#define EFIKAMX_LED_RED                IMX_GPIO_NR(3, 15)
 
-static iomux_v3_cfg_t efikasb_led_pads[] = {
+static iomux_v3_cfg_t const efikasb_led_pads[] = {
        MX51_PAD_GPIO1_3__GPIO1_3,
        MX51_PAD_EIM_CS0__GPIO2_25,
 };
 
-#define EFIKASB_CAPSLOCK_LED   GPIO_NUMBER(2, 25)
-#define EFIKASB_MESSAGE_LED    GPIO_NUMBER(1, 3) /* Note: active low */
+#define EFIKASB_CAPSLOCK_LED   IMX_GPIO_NR(2, 25)
+#define EFIKASB_MESSAGE_LED    IMX_GPIO_NR(1, 3) /* Note: active low */
 
 /*
  * Board initialization
@@ -492,9 +492,6 @@ int board_late_init(void)
                                        ARRAY_SIZE(efikamx_pata_pads));
        setup_iomux_usb();
 
-       if (machine_is_efikasb())
-               setenv("preboot", "usb reset ; setenv stdin usbkbd\0");
-
        return 0;
 }